Go to the documentation of this file.
34 #if !defined(CPP_DLL_LOCAL)
36 #define CPP_DLL_EXPORT __declspec(dllexport)
38 #define CPP_DLL_IMPORT __declspec(dllimport)
43 #define CPP_DLL_EXPORT __attribute__ ((visibility ("default")))
45 #define CPP_DLL_IMPORT __attribute__ ((visibility ("default")))
47 #define CPP_DLL_LOCAL __attribute__ ((visibility ("hidden")))
53 #if defined __cplusplus
54 #define EXTERN_C extern "C"
66 #define WINAPI __attribute__((__stdcall__))
74 #ifdef USBDM_DLL_EXPORTS
75 #define USBDM_API EXTERN_C CPP_DLL_EXPORT WINAPI
77 #define OSBDM_API_JM60 EXTERN_C CPP_DLL_EXPORT WINAPI
79 #define USBDM_API EXTERN_C CPP_DLL_IMPORT WINAPI
81 #define OSBDM_API_JM60 EXTERN_C CPP_DLL_IMPORT WINAPI
84 #ifdef USBDM_DLL_EXPORTS
85 #define USBDM_API EXTERN_C CPP_DLL_EXPORT
87 #define OSBDM_API_JM60 EXTERN_C CPP_DLL_EXPORT
89 #define USBDM_API EXTERN_C CPP_DLL_IMPORT
91 #define OSBDM_API_JM60 EXTERN_C CPP_DLL_IMPORT
101 #if defined __cplusplus
109 #define USBDM_API_VERSION (0x40A06) // V4.10.6 (in hex xx.xx.xx)
115 BDM_CAP_ALL = (0xFFFF),
145 #define CAP_HCS12 (1<<0)
146 #define CAP_RS08 (1<<1)
147 #define CAP_VDDCONTROL (1<<2)
148 #define CAP_VDDSENSE (1<<3)
149 #define CAP_CFVx (1<<4)
150 #define CAP_HCS08 (1<<5)
151 #define CAP_CFV1 (1<<6)
152 #define CAP_JTAG (1<<7)
153 #define CAP_DSC (1<<8)
154 #define CAP_ARM_JTAG (1<<9)
155 #define CAP_RST (1<<10)
156 #define CAP_PST (1<<11)
157 #define CAP_CDC (1<<12)
158 #define CAP_ARM_SWD (1<<13)
202 MS_PWord = MS_Word+MS_Program,
203 MS_PLong = MS_Long+MS_Program,
204 MS_XByte = MS_Byte+MS_Data,
205 MS_XWord = MS_Word+MS_Data,
206 MS_XLong = MS_Long+MS_Data,
478 DSC_FirstCoreRegister = DSC_RegX0,
516 DSC_LastCoreRegister = DSC_RegPC,
521 DSC_FirstONCERegister = DSC_RegOCR,
539 DSC_LastONCERegister = DSC_RegOB0CNTR,
541 DSC_GdiStatus = 0x1001,
542 DSC_UnknownReg = 0xFFFFFF,
760 PIN_RESET_OFFS = (2),
798 PIN_SWCLK_OFFS = (12),
1155 #if defined __cplusplus
1525 unsigned int byteCount,
1526 unsigned int address,
1527 unsigned const char *data);
1542 unsigned int byteCount,
1543 unsigned int address,
1544 unsigned char *data);
1606 const unsigned char *buffer);
1631 unsigned char *buffer);
1658 const unsigned char *outBuffer,
1659 unsigned char *inBuffer);
1673 const unsigned char *sequence,
1674 unsigned char inLength,
1675 unsigned char *inBuffer);
1719 unsigned int count);
1734 unsigned char *data);
1749 unsigned char *data);
1771 class ProgressDialogue;
1784 void USBDM_ICP_SetCallback(ProgressDialogue *icpCallBack);
1787 void dll_initialize(HINSTANCE _hDLLInst);
1788 void dll_uninitialize(
void);
1789 #endif // COMMANDLINE
1790 #endif //__cplusplus
1792 #if defined __cplusplus
1796 #endif //_USBDM_API_H_
USBDM_API USBDM_ErrorCode USBDM_GetBDMSerialNumber(const char **deviceSerialNumber)
Obtain serial number of the currently opened BDM.
JTAG_ExitActions_t
Options used with JTAG commands.
unsigned resetDuration
How long to assert reset (ms)
unsigned char bdmSoftwareVersion
Version of USBDM Firmware.
Last core reg (20 regs R0..R12,SP,LR,PC,XPSR,MSP,PSP,MISC)
HCS08_DRegisters_t
regNo Parameter for USBDM_ReadDReg() with HCS08 target [BKPT reg]
Enter SHIFT-IR (from TEST-LOGIC-RESET or RUN-TEST/IDLE)
AHB-AP Data Read/Write register.
USBDM_ErrorCode
Error codes returned from BDM routines and BDM commands.
Write 0's when reading - combined with above.
ClkSwValues_t bdmClockSource
BDM clock source in target.
AHB-AP Control/Status Word register.
USBDM_API USBDM_ErrorCode USBDM_GetSpeedHz(unsigned long *frequency)
Get the BDM communication speed in Hz.
Status only - Reset high.
Coldfire Version 1 target.
TargetRunState_t halt_state
CFVx halted (from ALLPST)?
USBDM_API USBDM_ErrorCode USBDM_GetCommandStatus(void)
Get status of the last command.
RS08_Registers_t
regNo Parameter for USBDM_ReadReg() with RS08 target
USBDM_API USBDM_ErrorCode USBDM_Init(void)
Initialises USB interface.
ARM_RegisterIndex_t
startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with ARM (Kinetis) target
AutoConnect_t
Auto-reconnect options.
int leaveTargetPowered
Leave target power on exit.
RS08_DRegisters_t
regNo Parameter for USBDM_ReadDReg() with RS08 target (BKPT)
Force ALT clock (CLKSW = 0)
USBDM_API USBDM_ErrorCode USBDM_GetDefaultExtendedOptions(USBDM_ExtendedOptions_t *bdmOptions)
Get default (target specific) BDM interface options.
TargetVddSelect_t targetVdd
Target Vdd (off, 3.3V or 5V)
USBDM_API USBDM_ErrorCode USBDM_WriteReg(unsigned int regNo, unsigned long regValue)
Write Target Core register.
USBDM_API USBDM_ErrorCode USBDM_GetBdmInformation(USBDM_bdmInformation_t *info)
Obtains information about the currently open BDM interface.
USBDM_API USBDM_ErrorCode USBDM_SetSpeed(unsigned long frequency)
Sets the BDM communication speed.
bool usePSTSignals
CFVx, PST Signal monitors.
USBDM_API USBDM_ErrorCode USBDM_SetTargetVdd(TargetVddSelect_t targetVdd)
Sets Target Vdd voltage.
USBDM_API unsigned int USBDM_DLLVersion(void)
Get version of the DLL.
ClkSwValues_t
Target BDM Clock selection.
unsigned size
Size of this structure - must be initialised!
Remain in SHIFT-DR or SHIFT-IR.
Mask for SWD values (PIN_SWCLK_LOW, PIN_SWCLK_HIGH & PIN_SWCLK_3STATE)
Last float reg (33 regs FPSCR, FPS0..FPS32)
USBDM_API USBDM_ErrorCode USBDM_JTAG_ExecuteSequence(unsigned char length, const unsigned char *sequence, unsigned char inLength, unsigned char *inBuffer)
Execute JTAG Sequence.
ARM_DRegisters_t
regNo Parameter for USBDM_ReadDReg() with SWD-ARM target
Vendor special method e.g. using MDM-AP for Kinetis.
int guessSpeed
Guess speed for target w/o ACKN.
USBDM_API USBDM_ErrorCode USBDM_GetBDMStatus(USBDMStatus_t *USBDMStatus)
Fills user supplied structure with state of BDM communication channel.
Release all pins (go to default for current target)
State of BDM Communication.
USBDM_API USBDM_ErrorCode USBDM_Open(unsigned char deviceNo)
Opens a device.
IDCODE reg - read, SWD-AP only.
int cycleVddOnConnect
Cycle target Power if connection problems)
USBDM_API USBDM_ErrorCode USBDM_WriteDReg(unsigned int regNo, unsigned long regValue)
Write Target Debug register.
ResetMode_t
Target reset status values.
CFV1_RegisterIndex_t
startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with Coldfire V1 target
HCS08_Registers_t
regNo Parameter for USBDM_ReadReg() with HCS08 target
Start of PST registers, access as CFV1_PSTBASE+n.
unsigned hcs08sbdfrAddress
Address to use to access SBDFR register.
USBDM_API USBDM_ErrorCode USBDM_ICP_Erase(unsigned int addr, unsigned int count)
ICP mode - erase BDM Flash memory.
int usePSTSignals
CFVx, PST Signal monitors.
S12Z_Registers_t
regNo Parameter for USBDM_ReadReg() with HCS12 target
Mask for reset type (Hardware/Software/Power)
12 V Flash programming supply available (RS08 support)
Write 1's when reading - combined with above.
Target Vdd internal 5.0V.
USBDM_API USBDM_ErrorCode USBDM_JTAG_Read(unsigned char bitCount, unsigned char exit, unsigned char *buffer)
JTAG - read data from JTAG shift register SHIFT_DR => TMS=Nx0, TDI=0, TDO=NxData (captured)
unsigned resetRecoveryInterval
How long to wait after reset sequence completes (ms)
Coldfire Version 2,3,4 target.
ARM_Registers_t
regNo Parameter for ARM_ReadReg() with ARM (Kinetis) target
USBDM_API USBDM_ErrorCode USBDM_GetSpeed(unsigned long *frequency)
Get the BDM communication speed in kHz.
Special mode [BDM active, Target halted].
User has specified the speed to use.
USBDM_API USBDM_ErrorCode USBDM_SetTargetType(TargetType_t targetType)
Sets target MCU type.
USBDM_API USBDM_ErrorCode USBDM_Connect(void)
Connects to Target.
USBDM_API void USBDM_SetLogFile(FILE *fp)
Set log file for messages.
USBDM_API USBDM_ErrorCode USBDM_SetExtendedOptions(const USBDM_ExtendedOptions_t *newBdmOptions)
Set BDM interface options.
int maskInterrupts
Whether to mask interrupts when stepping.
[31:24]=CONTROL,[23:16]=FAULTMASK,[15:8]=BASEPRI,[7:0]=PRIMASK.
unsigned char icpSoftwareVersion
Version of ICP bootloader Firmware.
CFVx_RegisterIndex_t
startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with Coldfire Vx target
int autoReconnect
Automatically re-connect to target (for speed change)
Supports ARM targets via JTAG.
CFVx target halted (ALLPST == 1)
USBDM_API void USBDM_RebootToICP(void)
Set BDM for ICP mode & immediately reboots - used in BDM mode only.
SpeedMode_t connection_state
Connection status & speed determination method.
USBDM_API USBDM_ErrorCode USBDM_ReadReg(unsigned int regNo, unsigned long *regValue)
Read Target Core register.
USBDM_API USBDM_ErrorCode USBDM_TargetReset(TargetMode_t target_mode)
Resets the target to normal or special mode.
CFVx_Registers_t
regNo Parameter for USBDM_ReadReg() with CFVx target
Exit SHIFT-XX & enter SHIFT-DR w/o crossing RUN-TEST/IDLE.
Other A7 (not active in target)
CFV1_CRegisters_t
regNo Parameter for USBDM_ReadCReg() with CFV1 target
unsigned powerOffDuration
How long to remove power (ms)
Exit SHIFT-XX to RUN-TEST/IDLE.
int manuallyCycleVdd
Prompt user to manually cycle Vdd on connection problems.
Other A7 (not active in target)
Mask for SWD values (PIN_SWD_LOW, PIN_SWD_HIGH & PIN_SWD_3STATE)
USBDM_API USBDM_ErrorCode USBDM_WriteMemory(unsigned int memorySpace, unsigned int byteCount, unsigned int address, unsigned const char *data)
Write data to target memory.
Supports PST signal sensing.
HCS12_Registers_t
regNo Parameter for USBDM_ReadReg() with HCS12 target
PinLevelMasks_t
Control signal masks for CMD_USBDM_CONTROL_PIN (USBDM_ControlPins())
Target Vdd internal at last set level.
USBDM_API void USBDM_ICP_Reboot(void)
ICP mode - reboot.
Target Vdd internal 3.3V.
DSC_Registers_t
regNo Parameter for DSC_ReadReg() with DSC target DSC Core registers
Supports HCS12Z targets via SWD.
int interfaceSpeed
CFVx/JTAG etc - Interface speed (kHz). .
Floating point control register.
TargetRunState_t
Target Halt state.
USBDM_API USBDM_ErrorCode USBDM_JTAG_ReadWrite(unsigned char bitCount, unsigned char exit, const unsigned char *outBuffer, unsigned char *inBuffer)
JTAG - read/write data from/to JTAG shift register SHIFT_DR => TMS=Nx0, TDI=0, TDO=NxData (captured)
unsigned interfaceFrequency
CFVx/JTAG etc - Interface speed (kHz)
JTAG target - TAP is set to RUN-TEST/IDLE.
Use all reset strategies as appropriate.
RSTO* is currently active [low].
USBDM_API USBDM_ErrorCode USBDM_FindDevices(unsigned int *deviceCount)
Find USBDM Devices This function creates an internal list of USBDM devices.
Mask for reset mode (SPECIAL/NORMAL)
bool leaveTargetPowered
Leave target power on exit.
const USBDM_API char * USBDM_DLLVersionString(void)
Get version string for DLL.
Supports CFV1 targets - inverted when queried.
CFVx_CRegisters_t
regNo Parameter for USBDM_ReadCReg() with CFVx target
USBDM_API USBDM_ErrorCode USBDM_ReadMultipleRegs(unsigned char regValueBuffer[], unsigned int startRegIndex, unsigned int endRegIndex)
Read Multiple Core registers.
USBDM_API USBDM_ErrorCode USBDM_ReadCReg(unsigned int regNo, unsigned long *regValue)
Read Target Control register.
Use software (BDM commands) reset.
bool cycleVddOnConnect
Cycle target Power if connection problems)
CCR reg - redirected to USBDM_ReadDReg()
Supports HCS08 targets - inverted when queried.
Identifier register (should read 0x001C_0000)
Used to indicate error in selecting target.
Target Vdd Off but previously set level unchanged.
USBDM_API USBDM_ErrorCode USBDM_ControlPins(unsigned int control, unsigned int *status)
Directly manipulate interface levels.
#define USBDM_API
Importing the DLL.
TargetMode_t
Reset mode as used by CMD_USBDM_TARGET_RESET.
Enter SHIFT-DR (from TEST-LOGIC-RESET or RUN-TEST/IDLE)
USBDM_API USBDM_ErrorCode USBDM_SetOptions(BDM_Options_t *newBdmOptions)
Set BDM interface options.
int miscOptions
Various misc options.
USBDM_API USBDM_ErrorCode USBDM_WriteControlReg(unsigned int value)
Write Target Control Register byte.
Normal mode [usual reset, Target executes].
Structure to hold version information for BDM.
bool guessSpeed
Guess speed for target w/o ACKN.
TargetVppSelect_t flash_state
State of Target Vpp.
AcknMode_t
Target supports ACKN or uses fixed delay {WAIT} instead.
USBDM_API USBDM_ErrorCode USBDM_ReadDReg(unsigned int regNo, unsigned long *regValue)
Read Target Debug register.
Reconnect before every command.
Speed determined by trial & error.
Mask for TRST signal (not implemented)
Last core reg (18 regs D0..D7,A0..A7,SR,PC)
AHB-AP Transfer Address register.
ARM_CRegisters_t
regNo Parameter for USBDM_ReadCReg() with SWD-ARM target
Control & sensing of RESET.
Exit SHIFT-XX & enter SHIFT-IR w/o crossing RUN-TEST/IDLE.
int useAltBDMClock
Use alternative BDM clock source in target.
RSTO* is currently inactive [high].
USBDM_API USBDM_ErrorCode USBDM_GetBDMDescription(const char **deviceDescription)
Obtain description of the currently opened BDM.
USBDM_API USBDM_ErrorCode USBDM_Exit(void)
Clean up.
USBDM_API USBDM_ErrorCode USBDM_ReadStatusReg(unsigned long *BDMStatusReg)
Reads Target Status register byte.
CFVx_DRegisters_t
regNo Parameter for USBDM_ReadDReg() with CFV1 target
Other A7 (not active in target)
USBDM_API USBDM_ErrorCode USBDM_SetTargetVpp(TargetVppSelect_t targetVpp)
Sets Target programming voltage.
USBDM_API USBDM_ErrorCode USBDM_ICP_Verify(unsigned int addr, unsigned int count, unsigned char *data)
ICP mode - verify BDM Flash memory.
TargetVddSelect_t
Internal Target Voltage supply selection.
SpeedMode_t
Target speed selection.
unsigned char icpHardwareVersion
Version of Hardware (reported by ICP code)
Use WAIT (delay) instead.
int cycleVddOnReset
Cycle target Power when resetting.
USBDM_API USBDM_ErrorCode USBDM_Debug(unsigned char *usb_data)
Execute debug command (various, see DebugSubCommands)
TargetVppSelect_t
Internal Programming Voltage supply selection.
USBDM_API USBDM_ErrorCode USBDM_GetVersion(USBDM_Version_t *version)
Gets BDM software version and type of hardware.
No change to pins (used to get pin status)
ARM target using either SWD (preferred) or JTAG as supported.
USBDM_API USBDM_ErrorCode USBDM_JTAG_SelectShift(unsigned char mode)
JTAG - move the TAP to SHIFT-DR or SHIFT-IR state SHIFT_DR => TMS=100, TDI=0 (Actually TMS=0000_0100)...
bool maskInterrupts
Whether to mask interrupts when stepping.
ResetState_t reset_state
Current target RST0 state.
USBDM_API USBDM_ErrorCode USBDM_WriteCReg(unsigned int regNo, unsigned long regValue)
Write Target Control register.
TargetType_t
Target microcontroller types.
HardwareCapabilities_t
Capabilities of the hardware.
HCS12_DRegisters_t
regNo Parameter for USBDM_ReadDReg() with HCS12 target [BD Space]
Use default clock selection (don't modify target's reset default)
CFV1_DRegisters_t
regNo Parameter for USBDM_ReadDReg() with CFV1 target
USBDM_API USBDM_ErrorCode USBDM_BDMCommand(unsigned int txSize, unsigned int rxSize, unsigned char data[])
Use hardware RESET pin reset.
PC (Debug return address)
JTAG target with MC56F80xx optimised subroutines.
unsigned powerOnRecoveryInterval
How long to wait after power enabled (ms)
Reconnect on USBDM_ReadStatusReg()
int useResetSignal
Whether to use RESET signal on BDM interface.
No reset activity since last polled.
Use target specific default method.
const USBDM_API char * USBDM_GetErrorString(USBDM_ErrorCode errorCode)
Gets string describing a USBDM error code.
USBDM_API USBDM_ErrorCode USBDM_GetExtendedOptions(USBDM_ExtendedOptions_t *currentBdmOptions)
Get BDM interface options.
CONTROL reg - write only.
USBDM_API USBDM_ErrorCode USBDM_GetCapabilities(HardwareCapabilities_t *capabilities)
Obtains the Capability vector from the BDM interface.
Target supports ACKN feature and it is enabled.
Mask for RESET values (PIN_RESET_LOW & PIN_RESET_3STATE)
TargetVddState_t power_state
Target has power?
USBDM_API USBDM_ErrorCode USBDM_Close(void)
Closes currently open device.
unsigned resetReleaseInterval
How long to wait after reset release to release other signals (ms)
int derivative_type
RS08 Derivative.
Target Vpp Standby (Inverter on, Vpp off)
bool cycleVddOnReset
Cycle target Power when resetting.
EzPort Flash interface (SPI?)
CFV1_Registers_t
regNo Parameter for USBDM_ReadReg() with CFV1 target
Last core reg (18 regs D0..D7,A0..A7,SR,PC)
Supports ARM targets via SWD.
AcknMode_t ackn_state
Supports ACKN ?
USBDM_API USBDM_ErrorCode USBDM_JTAG_Write(unsigned char bitCount, unsigned char exit, const unsigned char *buffer)
JTAG - write data to JTAG shift register STAY_SHIFT => TMS=Nx0, TDI=NxData EXIT_SHIFT_DR => TMS=Nx0,...
CFVx target running (ALLPST == 0)
USBDM_API USBDM_ErrorCode USBDM_JTAG_Reset(void)
JTAG - Moves the TAP to TEST-LOGIC-RESET state TMS=11111, TDI=00000 or similar.
Speed determined by SYNC.
USBDM_API FILE * USBDM_GetLogFile(void)
Get current log file for messages.
bool useResetSignal
Whether to use RESET signal on BDM interface.
TargetType_t targetType
Target type.
unsigned char bdmHardwareVersion
Version of USBDM Hardware.
USBDM_API USBDM_ErrorCode USBDM_TargetStep(void)
Steps over a single target instruction.
USBDM_API USBDM_ErrorCode USBDM_TargetHalt(void)
Brings the target into active background mode.
Supports CDC Serial over USB interface.
AutoConnect_t autoReconnect
Automatically re-connect to target (for speed change)
ResetMode_t reset_recent
Target reset recently?
MemorySpace_t
Memory space indicator - includes element size.
TargetType_t target_type
Type of target (HCS12, HCS08 etc)
Force Normal clock (CLKSW = 1)
USBDM_API USBDM_ErrorCode USBDM_ICP_Program(unsigned int addr, unsigned int count, unsigned char *data)
ICP mode - program BDM Flash memory.
USBDM_API USBDM_ErrorCode USBDM_TargetGo(void)
Starts target execution from current PC address.
Mask for BKGD values (PIN_BKGD_LOW, PIN_BKGD_HIGH & PIN_BKGD_3STATE)
Turn off interface (no target)
ResetState_t
Target RSTO state.
USBDM_API USBDM_ErrorCode USBDM_ReadMemory(unsigned int memorySpace, unsigned int byteCount, unsigned int address, unsigned char *data)
Read data from target memory.
Combined CCR/PC register.
int targetVdd
Target Vdd (off, 3.3V or 5V)
USBDM_API USBDM_ErrorCode USBDM_BasicConnect(void)
Does basic connect to target.
USBDM_API USBDM_ErrorCode USBDM_ReleaseDevices(void)
Release USBDM Device list.
TargetVddState_t
Target Voltage supply state.
AHB-AP IDebug base address register.