USBDM  V4.12
USBDM_API.h File Reference

Header file for USBDM_API.c. More...

#include "USBDM_ErrorMessages.h"
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  USBDMStatus_t
 State of BDM Communication. More...
 
struct  BDM_Options_t
 BDM interface options. More...
 
struct  USBDM_ExtendedOptions_t
 BDM interface options. More...
 
struct  USBDM_Version_t
 Structure to hold version information for BDM. More...
 
struct  USBDM_bdmInformation_t
 Structure describing characteristics of currently open BDM. More...
 

Macros

#define CPP_DLL_EXPORT   __attribute__ ((visibility ("default")))
 Functions exported from a library.
 
#define CPP_DLL_IMPORT   __attribute__ ((visibility ("default")))
 Functions imported from a library.
 
#define CPP_DLL_LOCAL   __attribute__ ((visibility ("hidden")))
 Functions local to a library.
 
#define EXTERN_C
 Usual C interface for C.
 
#define USBDM_API   EXTERN_C CPP_DLL_IMPORT
 Importing the DLL.
 
#define bool   char
 Define bool for C to be consistent with C++!
 
#define USBDM_API_VERSION   (0x40A06)
 USBDM Version this header describes.
 
#define CAP_HCS12   (1<<0)
 Supports HCS12 targets.
 
#define CAP_RS08   (1<<1)
 Supports RS08 targets.
 
#define CAP_VDDCONTROL   (1<<2)
 Control over target Vdd.
 
#define CAP_VDDSENSE   (1<<3)
 Sensing of target Vdd.
 
#define CAP_CFVx   (1<<4)
 Supports CFVx.
 
#define CAP_HCS08   (1<<5)
 Supports HCS08 targets - inverted when queried.
 
#define CAP_CFV1   (1<<6)
 Supports CFV1 targets - inverted when queried.
 
#define CAP_JTAG   (1<<7)
 Supports JTAG targets.
 
#define CAP_DSC   (1<<8)
 Supports DSC targets.
 
#define CAP_ARM_JTAG   (1<<9)
 Supports ARM targets via JTAG.
 
#define CAP_RST   (1<<10)
 Control & sensing of RESET.
 
#define CAP_PST   (1<<11)
 Supports PST signal sensing.
 
#define CAP_CDC   (1<<12)
 Supports CDC Serial over USB interface.
 
#define CAP_ARM_SWD   (1<<13)
 Supports ARM targets via SWD.
 

Enumerations

enum  HardwareCapabilities_t { ,
  BDM_CAP_HCS12 = (1<<0), BDM_CAP_RS08 = (1<<1), BDM_CAP_VDDCONTROL = (1<<2), BDM_CAP_VDDSENSE = (1<<3),
  BDM_CAP_CFVx = (1<<4), BDM_CAP_HCS08 = (1<<5), BDM_CAP_CFV1 = (1<<6), BDM_CAP_JTAG = (1<<7),
  BDM_CAP_DSC = (1<<8), BDM_CAP_ARM_JTAG = (1<<9), BDM_CAP_RST = (1<<10), BDM_CAP_PST = (1<<11),
  BDM_CAP_CDC = (1<<12), BDM_CAP_ARM_SWD = (1<<13), BDM_CAP_S12Z = (1<<14)
}
 Capabilities of the hardware. More...
 
enum  TargetType_t {
  T_HC12 = 0, T_HCS12 = T_HC12, T_HCS08 = 1, T_RS08 = 2,
  T_CFV1 = 3, T_CFVx = 4, T_JTAG = 5, T_EZFLASH = 6,
  T_MC56F80xx = 7, T_ARM_JTAG = 8, T_ARM_SWD = 9, T_ARM = 10,
  T_S12Z = 11 , T_ILLEGAL = 0xFE, T_OFF = 0xFF
}
 Target microcontroller types. More...
 
enum  MemorySpace_t
 Memory space indicator - includes element size.
 
enum  AcknMode_t { WAIT = 0, ACKN = 1 }
 Target supports ACKN or uses fixed delay {WAIT} instead. More...
 
enum  SpeedMode_t { SPEED_NO_INFO = 0, SPEED_SYNC = 1, SPEED_GUESSED = 2, SPEED_USER_SUPPLIED = 3 }
 Target speed selection. More...
 
enum  ResetState_t { RSTO_ACTIVE =0, RSTO_INACTIVE =1 }
 Target RSTO state. More...
 
enum  ResetMode_t { NO_RESET_ACTIVITY = 0 , RESET_DETECTED = 1 }
 Target reset status values. More...
 
enum  TargetRunState_t { TARGET_RUNNING = 0, TARGET_HALTED = 1 }
 Target Halt state. More...
 
enum  TargetVddState_t { BDM_TARGET_VDD_NONE = 0, BDM_TARGET_VDD_EXT = 1, BDM_TARGET_VDD_INT = 2, BDM_TARGET_VDD_ERR = 3 }
 Target Voltage supply state. More...
 
enum  AutoConnect_t { AUTOCONNECT_NEVER = 0, AUTOCONNECT_STATUS = 1, AUTOCONNECT_ALWAYS = 2 }
 Auto-reconnect options. More...
 
enum  TargetVddSelect_t {
  BDM_TARGET_VDD_OFF = 0, BDM_TARGET_VDD_3V3 = 1, BDM_TARGET_VDD_5V = 2, BDM_TARGET_VDD_ENABLE = 0x10,
  BDM_TARGET_VDD_DISABLE = 0x11
}
 Internal Target Voltage supply selection. More...
 
enum  TargetVppSelect_t { BDM_TARGET_VPP_OFF = 0, BDM_TARGET_VPP_STANDBY = 1, BDM_TARGET_VPP_ON = 2, BDM_TARGET_VPP_ERROR = 3 }
 Internal Programming Voltage supply selection. More...
 
enum  ClkSwValues_t { CS_DEFAULT = 0xFF, CS_ALT_CLK = 0, CS_NORMAL_CLK = 1 }
 Target BDM Clock selection. More...
 
enum  TargetMode_t {
  RESET_MODE_MASK = (3<<0), RESET_SPECIAL = (0<<0), RESET_NORMAL = (1<<0), RESET_METHOD_MASK = (7<<2),
  RESET_ALL = (0<<2), RESET_HARDWARE = (1<<2), RESET_SOFTWARE = (2<<2), RESET_POWER = (3<<2),
  RESET_VENDOR = (4<<2), RESET_DEFAULT = (7<<2)
}
 Reset mode as used by CMD_USBDM_TARGET_RESET. More...
 
enum  HCS12_Registers_t {
  HCS12_RegPC = 3, HCS12_RegD = 4, HCS12_RegX = 5, HCS12_RegY = 6,
  HCS12_RegSP = 7, HCS12_RegCCR = 0x80
}
 regNo Parameter for USBDM_ReadReg() with HCS12 target More...
 
enum  S12Z_Registers_t {
  S12Z_RegD0 = 0x0, S12Z_RegD1 = 0x1, S12Z_RegD2 = 0x2, S12Z_RegD3 = 0x3,
  S12Z_RegD4 = 0x4, S12Z_RegD5 = 0x5, S12Z_RegD6 = 0x6, S12Z_RegD7 = 0x7,
  S12Z_RegX = 0x8, S12Z_RegY = 0x9, S12Z_RegSP = 0xA, S12Z_RegPC = 0xB,
  S12Z_RegCCR = 0xC
}
 regNo Parameter for USBDM_ReadReg() with HCS12 target More...
 
enum  HCS08_Registers_t {
  HCS08_RegPC = 0xB, HCS08_RegSP = 0xF, HCS08_RegHX = 0xC, HCS08_RegA = 8,
  HCS08_RegCCR = 9
}
 regNo Parameter for USBDM_ReadReg() with HCS08 target More...
 
enum  RS08_Registers_t { RS08_RegCCR_PC = 0xB, RS08_RegSPC = 0xF, RS08_RegA = 8 }
 regNo Parameter for USBDM_ReadReg() with RS08 target More...
 
enum  CFV1_Registers_t {
  CFV1_RegD0 = 0, CFV1_RegD1 = 1, CFV1_RegD2 = 2, CFV1_RegD3 = 3,
  CFV1_RegD4 = 4, CFV1_RegD5 = 5, CFV1_RegD6 = 6, CFV1_RegD7 = 7,
  CFV1_RegA0 = 8, CFV1_RegA1 = 9, CFV1_RegA2 = 10, CFV1_RegA3 = 11,
  CFV1_RegA4 = 12, CFV1_RegA5 = 13, CFV1_RegA6 = 14, CFV1_RegA7 = 15 ,
  CFV1_PSTBASE = 16, CFV1_RegOTHER_A7 = 0xC0|0, CFV1_RegVBR = 0xC0|1, CFV1_RegCPUCR = 0xC0|2,
  CFV1_RegMACSR = 0xC0|4, CFV1_RegMASK = 0xC0|5, CFV1_RegACC = 0xC0|6, CFV1_RegSR = 0xC0|14,
  CFV1_RegPC = 0xC0|15
}
 regNo Parameter for USBDM_ReadReg() with CFV1 target More...
 
enum  CFVx_Registers_t {
  CFVx_RegD0 = 0, CFVx_RegD1 = 1, CFVx_RegD2 = 2, CFVx_RegD3 = 3,
  CFVx_RegD4 = 4, CFVx_RegD5 = 5, CFVx_RegD6 = 6, CFVx_RegD7 = 7,
  CFVx_RegA0 = 8, CFVx_RegA1 = 9, CFVx_RegA2 = 10, CFVx_RegA3 = 11,
  CFVx_RegA4 = 12, CFVx_RegA5 = 13, CFVx_RegA6 = 14, CFVx_RegA7 = 15
}
 regNo Parameter for USBDM_ReadReg() with CFVx target More...
 
enum  ARM_Registers_t {
  ARM_RegR0 = 0, ARM_RegR1 = 1, ARM_RegR2 = 2, ARM_RegR3 = 3,
  ARM_RegR4 = 4, ARM_RegR5 = 5, ARM_RegR6 = 6, ARM_RegR7 = 7,
  ARM_RegR8 = 8, ARM_RegR9 = 9, ARM_RegR10 = 10, ARM_RegR11 = 11,
  ARM_RegR12 = 12, ARM_RegSP = 13, ARM_RegLR = 14, ARM_RegPC = 15,
  ARM_RegxPSR = 16, ARM_RegMSP = 17, ARM_RegPSP = 18, ARM_RegMISC = 20,
  ARM_RegFPSCR = 0x21, ARM_RegFPS0 = 0x40
}
 regNo Parameter for ARM_ReadReg() with ARM (Kinetis) target More...
 
enum  ARM_RegisterIndex_t { ARM_RegIndexFirstCore = 0, ARM_RegIndexLastCore = ARM_RegIndexFirstCore+19, ARM_RegIndexFirstFloat = 20, ARM_RegIndexLastFloat = ARM_RegIndexFirstFloat+32 }
 startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with ARM (Kinetis) target More...
 
enum  CFV1_RegisterIndex_t { CFV1_RegIndexFirstCore = 0, CFV1_RegIndexLastCore = CFV1_RegIndexFirstCore+17 }
 startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with Coldfire V1 target More...
 
enum  CFVx_RegisterIndex_t { CFVx_RegIndexFirstCore = 0, CFVx_RegIndexLastCore = CFV1_RegIndexFirstCore+17 }
 startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with Coldfire Vx target More...
 
enum  DSC_Registers_t
 regNo Parameter for DSC_ReadReg() with DSC target DSC Core registers
 
enum  CFV1_CRegisters_t {
  CFV1_CRegOTHER_A7 = 0, CFV1_CRegVBR = 1, CFV1_CRegCPUCR = 2, CFV1_CRegMACSR = 4,
  CFV1_CRegMASK = 5, CFV1_CRegACC = 6, CFV1_CRegSR = 14, CFV1_CRegPC = 15
}
 regNo Parameter for USBDM_ReadCReg() with CFV1 target More...
 
enum  CFVx_CRegisters_t {
  CFVx_CRegD0 = 0x80 , CFVx_CRegA0 , CFVx_CRegOTHER_SP = 0x800, CFVx_CRegVBR = 0x801,
  CFVx_CRegSR = 0x80E, CFVx_CRegPC = 0x80F, CFV1_CRegFLASHBAR = 0xC04, CFV1_CRegRAMBAR = 0xC05
}
 regNo Parameter for USBDM_ReadCReg() with CFVx target More...
 
enum  ARM_CRegisters_t {
  ARM_CRegAHB_AP_CSW = 0x00000000U, ARM_CRegAHB_AP_TAR = 0x00000004U, ARM_CRegAHB_AP_DRW = 0x0000000CU, ARM_CRegAHB_AP_CFG = 0x000000F4U,
  ARM_CRegAHB_AP_Base = 0x000000F8U, ARM_CRegAHB_AP_Id = 0x000000FCU, ARM_CRegMDM_AP_Status = 0x01000000U, ARM_CRegMDM_AP_Control = 0x01000004U,
  ARM_CRegMDM_AP_Ident = 0x010000FCU
}
 regNo Parameter for USBDM_ReadCReg() with SWD-ARM target More...
 
enum  HCS12_DRegisters_t { HCS12_DRegBDMSTS = (int)0xFF01, HCS12_DRegCCR = (int)0xFF06, HCS12_DRegBDMINR = (int)0xFF07 }
 regNo Parameter for USBDM_ReadDReg() with HCS12 target [BD Space] More...
 
enum  HCS08_DRegisters_t { HCS08_DRegBKPT = 0x0 }
 regNo Parameter for USBDM_ReadDReg() with HCS08 target [BKPT reg] More...
 
enum  RS08_DRegisters_t { RS08_DRegBKPT = 0x0 }
 regNo Parameter for USBDM_ReadDReg() with RS08 target (BKPT) More...
 
enum  CFV1_DRegisters_t {
  CFV1_DRegCSR = 0x00, CFV1_DRegXCSR = 0x01, CFV1_DRegCSR2 = 0x02, CFV1_DRegCSR3 = 0x03,
  CFV1_DRegBAAR = 0x05, CFV1_DRegAATR = 0x06, CFV1_DRegTDR = 0x07, CFV1_DRegPBR0 = 0x08,
  CFV1_DRegPBMR = 0x09, CFV1_DRegABHR = 0x0C, CFV1_DRegABLR = 0x0D, CFV1_DRegDBR = 0x0E,
  CFV1_DRegBDMR = 0x0F, CFV1_DRegPBR1 = 0x18, CFV1_DRegPBR2 = 0x1A, CFV1_DRegPBR3 = 0x1B,
  CFV1_ByteRegs = 0x1000, CFV1_DRegXCSRbyte = CFV1_ByteRegs+CFV1_DRegXCSR, CFV1_DRegCSR2byte = CFV1_ByteRegs+CFV1_DRegCSR2, CFV1_DRegCSR3byte = CFV1_ByteRegs+CFV1_DRegCSR3
}
 regNo Parameter for USBDM_ReadDReg() with CFV1 target More...
 
enum  CFVx_DRegisters_t {
  CFVx_DRegCSR = 0x00, CFVx_DRegBAAR = 0x05, CFVx_DRegAATR = 0x06, CFVx_DRegTDR = 0x07,
  CFVx_DRegPBR0 = 0x08, CFVx_DRegPBMR = 0x09, CFVx_DRegABHR = 0x0C, CFVx_DRegABLR = 0x0D,
  CFVx_DRegDBR = 0x0E, CFVx_DRegBDMR = 0x0F, CFVx_DRegPBR1 = 0x18, CFVx_DRegPBR2 = 0x1A,
  CFVx_DRegPBR3 = 0x1B
}
 regNo Parameter for USBDM_ReadDReg() with CFV1 target More...
 
enum  ARM_DRegisters_t {
  ARM_DRegIDCODE = 0, ARM_DRegABORT = 0, ARM_DRegSTATUS = 1, ARM_DRegCONTROL = 1,
  ARM_DRegRESEND = 2, ARM_DRegSELECT = 2, ARM_DRegRDBUFF = 3, ARM_DRegAPReg0 = 4,
  ARM_DRegAPReg1 = 5, ARM_DRegAPReg2 = 6, ARM_DRegAPReg3 = 7
}
 regNo Parameter for USBDM_ReadDReg() with SWD-ARM target More...
 
enum  JTAG_ExitActions_t {
  JTAG_STAY_SHIFT = 0, JTAG_EXIT_IDLE = 1, JTAG_EXIT_SHIFT_DR = 2, JTAG_EXIT_SHIFT_IR = 3,
  JTAG_EXIT_ACTION_MASK = 0x3, JTAG_WRITE_0 = 0x00, JTAG_WRITE_1 = 0x80, JTAG_WRITE_MASK = 0x80,
  JTAG_SHIFT_DR = 0, JTAG_SHIFT_IR = 1
}
 Options used with JTAG commands. More...
 
enum  PinLevelMasks_t { ,
  PIN_BKGD = (3<<PIN_BKGD_OFFS), PIN_BKGD_NC = (0<<PIN_BKGD_OFFS), PIN_BKGD_3STATE = (1<<PIN_BKGD_OFFS), PIN_BKGD_LOW = (2<<PIN_BKGD_OFFS),
  PIN_BKGD_HIGH = (3<<PIN_BKGD_OFFS) , PIN_RESET = (3<<PIN_RESET_OFFS), PIN_RESET_NC = (0<<PIN_RESET_OFFS), PIN_RESET_3STATE = (1<<PIN_RESET_OFFS),
  PIN_RESET_LOW = (2<<PIN_RESET_OFFS), PIN_RESET_HIGH = (3<<PIN_RESET_OFFS) , PIN_TA = (3<<PIN_TA_OFFS), PIN_TA_NC = (0<<PIN_TA_OFFS),
  PIN_TA_3STATE = (1<<PIN_TA_OFFS), PIN_TA_LOW = (2<<PIN_TA_OFFS) , PIN_DE = (3<<PIN_DE_OFFS), PIN_DE_NC = (0<<PIN_DE_OFFS),
  PIN_DE_3STATE = (1<<PIN_DE_OFFS), PIN_DE_LOW = (2<<PIN_DE_OFFS) , PIN_TRST = (3<<PIN_TRST_OFFS), PIN_TRST_NC = (0<<PIN_TRST_OFFS),
  PIN_TRST_3STATE = (1<<PIN_TRST_OFFS), PIN_TRST_LOW = (2<<PIN_TRST_OFFS) , PIN_BKPT = (3<<PIN_BKPT_OFFS), PIN_BKPT_NC = (0<<PIN_BKPT_OFFS),
  PIN_BKPT_3STATE = (1<<PIN_BKPT_OFFS), PIN_BKPT_LOW = (2<<PIN_BKPT_OFFS) , PIN_SWD = (3<<PIN_SWD_OFFS), PIN_SWD_NC = (0<<PIN_SWD_OFFS),
  PIN_SWD_3STATE = (1<<PIN_SWD_OFFS), PIN_SWD_LOW = (2<<PIN_SWD_OFFS), PIN_SWD_HIGH = (3<<PIN_SWD_OFFS) , PIN_SWCLK = (3<<PIN_SWCLK_OFFS),
  PIN_SWCLK_NC = (0<<PIN_SWCLK_OFFS), PIN_SWCLK_3STATE = (1<<PIN_SWCLK_OFFS), PIN_SWCLK_LOW = (2<<PIN_SWCLK_OFFS), PIN_SWCLK_HIGH = (3<<PIN_SWCLK_OFFS),
  PIN_NOCHANGE = 0, PIN_RELEASE = -1
}
 Control signal masks for CMD_USBDM_CONTROL_PIN (USBDM_ControlPins()) More...
 

Functions

USBDM_API USBDM_ErrorCode USBDM_Init (void)
 Initialises USB interface. More...
 
USBDM_API USBDM_ErrorCode USBDM_Exit (void)
 Clean up. More...
 
USBDM_API unsigned int USBDM_DLLVersion (void)
 Get version of the DLL. More...
 
const USBDM_API char * USBDM_DLLVersionString (void)
 Get version string for DLL. More...
 
const USBDM_API char * USBDM_GetErrorString (USBDM_ErrorCode errorCode)
 Gets string describing a USBDM error code. More...
 
USBDM_API USBDM_ErrorCode USBDM_FindDevices (unsigned int *deviceCount)
 Find USBDM Devices
This function creates an internal list of USBDM devices. More...
 
USBDM_API USBDM_ErrorCode USBDM_ReleaseDevices (void)
 Release USBDM Device list. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetBDMSerialNumber (const char **deviceSerialNumber)
 Obtain serial number of the currently opened BDM. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetBDMDescription (const char **deviceDescription)
 Obtain description of the currently opened BDM. More...
 
USBDM_API USBDM_ErrorCode USBDM_Open (unsigned char deviceNo)
 Opens a device. More...
 
USBDM_API USBDM_ErrorCode USBDM_Close (void)
 Closes currently open device. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetVersion (USBDM_Version_t *version)
 Gets BDM software version and type of hardware. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetCapabilities (HardwareCapabilities_t *capabilities)
 Obtains the Capability vector from the BDM interface. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetBdmInformation (USBDM_bdmInformation_t *info)
 Obtains information about the currently open BDM interface. More...
 
USBDM_API USBDM_ErrorCode USBDM_SetOptions (BDM_Options_t *newBdmOptions)
 Set BDM interface options. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetDefaultExtendedOptions (USBDM_ExtendedOptions_t *bdmOptions)
 Get default (target specific) BDM interface options. More...
 
USBDM_API USBDM_ErrorCode USBDM_SetExtendedOptions (const USBDM_ExtendedOptions_t *newBdmOptions)
 Set BDM interface options. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetExtendedOptions (USBDM_ExtendedOptions_t *currentBdmOptions)
 Get BDM interface options. More...
 
USBDM_API USBDM_ErrorCode USBDM_SetTargetVdd (TargetVddSelect_t targetVdd)
 Sets Target Vdd voltage. More...
 
USBDM_API USBDM_ErrorCode USBDM_SetTargetVpp (TargetVppSelect_t targetVpp)
 Sets Target programming voltage. More...
 
USBDM_API USBDM_ErrorCode USBDM_ControlPins (unsigned int control, unsigned int *status)
 Directly manipulate interface levels. More...
 
USBDM_API USBDM_ErrorCode USBDM_SetTargetType (TargetType_t targetType)
 Sets target MCU type. More...
 
USBDM_API USBDM_ErrorCode USBDM_Debug (unsigned char *usb_data)
 Execute debug command (various, see DebugSubCommands) More...
 
USBDM_API USBDM_ErrorCode USBDM_BDMCommand (unsigned int txSize, unsigned int rxSize, unsigned char data[])
 
USBDM_API USBDM_ErrorCode USBDM_GetCommandStatus (void)
 Get status of the last command. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetBDMStatus (USBDMStatus_t *USBDMStatus)
 Fills user supplied structure with state of BDM communication channel. More...
 
USBDM_API USBDM_ErrorCode USBDM_Connect (void)
 Connects to Target. More...
 
USBDM_API USBDM_ErrorCode USBDM_BasicConnect (void)
 Does basic connect to target. More...
 
USBDM_API USBDM_ErrorCode USBDM_SetSpeed (unsigned long frequency)
 Sets the BDM communication speed. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetSpeed (unsigned long *frequency)
 Get the BDM communication speed in kHz. More...
 
USBDM_API USBDM_ErrorCode USBDM_GetSpeedHz (unsigned long *frequency)
 Get the BDM communication speed in Hz. More...
 
USBDM_API USBDM_ErrorCode USBDM_ReadStatusReg (unsigned long *BDMStatusReg)
 Reads Target Status register byte. More...
 
USBDM_API USBDM_ErrorCode USBDM_WriteControlReg (unsigned int value)
 Write Target Control Register byte. More...
 
USBDM_API USBDM_ErrorCode USBDM_TargetReset (TargetMode_t target_mode)
 Resets the target to normal or special mode. More...
 
USBDM_API USBDM_ErrorCode USBDM_TargetStep (void)
 Steps over a single target instruction. More...
 
USBDM_API USBDM_ErrorCode USBDM_TargetGo (void)
 Starts target execution from current PC address. More...
 
USBDM_API USBDM_ErrorCode USBDM_TargetHalt (void)
 Brings the target into active background mode. More...
 
USBDM_API USBDM_ErrorCode USBDM_WriteReg (unsigned int regNo, unsigned long regValue)
 Write Target Core register. More...
 
USBDM_API USBDM_ErrorCode USBDM_ReadReg (unsigned int regNo, unsigned long *regValue)
 Read Target Core register. More...
 
USBDM_API USBDM_ErrorCode USBDM_ReadMultipleRegs (unsigned char regValueBuffer[], unsigned int startRegIndex, unsigned int endRegIndex)
 Read Multiple Core registers. More...
 
USBDM_API USBDM_ErrorCode USBDM_WriteCReg (unsigned int regNo, unsigned long regValue)
 Write Target Control register. More...
 
USBDM_API USBDM_ErrorCode USBDM_ReadCReg (unsigned int regNo, unsigned long *regValue)
 Read Target Control register. More...
 
USBDM_API USBDM_ErrorCode USBDM_WriteDReg (unsigned int regNo, unsigned long regValue)
 Write Target Debug register. More...
 
USBDM_API USBDM_ErrorCode USBDM_ReadDReg (unsigned int regNo, unsigned long *regValue)
 Read Target Debug register. More...
 
USBDM_API USBDM_ErrorCode USBDM_WriteMemory (unsigned int memorySpace, unsigned int byteCount, unsigned int address, unsigned const char *data)
 Write data to target memory. More...
 
USBDM_API USBDM_ErrorCode USBDM_ReadMemory (unsigned int memorySpace, unsigned int byteCount, unsigned int address, unsigned char *data)
 Read data from target memory. More...
 
USBDM_API USBDM_ErrorCode USBDM_JTAG_Reset (void)
 JTAG - Moves the TAP to TEST-LOGIC-RESET state TMS=11111, TDI=00000 or similar. More...
 
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) SHIFT_IR => TMS=1100, TDI=0 (Actually TMS=0000_1100) More...
 
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,11100 TDI=NxData,00000 EXIT_SHIFT_IR => TMS=Nx0,111100 TDI=NxData,000000 EXIT_IDLE => TMS=Nx0,10 TDI=NxData,00. More...
 
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) More...
 
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) More...
 
USBDM_API USBDM_ErrorCode USBDM_JTAG_ExecuteSequence (unsigned char length, const unsigned char *sequence, unsigned char inLength, unsigned char *inBuffer)
 Execute JTAG Sequence. More...
 
USBDM_API FILE * USBDM_GetLogFile (void)
 Get current log file for messages.
 
USBDM_API void USBDM_SetLogFile (FILE *fp)
 Set log file for messages.
 
USBDM_API void USBDM_RebootToICP (void)
 Set BDM for ICP mode & immediately reboots - used in BDM mode only. More...
 
USBDM_API USBDM_ErrorCode USBDM_ICP_Erase (unsigned int addr, unsigned int count)
 ICP mode - erase BDM Flash memory. More...
 
USBDM_API USBDM_ErrorCode USBDM_ICP_Program (unsigned int addr, unsigned int count, unsigned char *data)
 ICP mode - program BDM Flash memory. More...
 
USBDM_API USBDM_ErrorCode USBDM_ICP_Verify (unsigned int addr, unsigned int count, unsigned char *data)
 ICP mode - verify BDM Flash memory. More...
 
USBDM_API void USBDM_ICP_Reboot (void)
 ICP mode - reboot. More...
 

Detailed Description

Header file for USBDM_API.c.

 Copyright (C) 2010  Peter O'Donoghue

 Based on material from OSBDM-JM60 Target Interface Software Package
 Copyright (C) 2009  Freescale

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 Change History
+====================================================================
|    May 2010 | Created
+====================================================================

Definition in file USBDM_API.h.

Enumeration Type Documentation

◆ AcknMode_t

enum AcknMode_t

Target supports ACKN or uses fixed delay {WAIT} instead.

Enumerator
WAIT 

Use WAIT (delay) instead.

ACKN 

Target supports ACKN feature and it is enabled.

Definition at line 211 of file USBDM_API.h.

◆ ARM_CRegisters_t

regNo Parameter for USBDM_ReadCReg() with SWD-ARM target

The regNo is actually a AP bus address as follows:

  • A[31:24] => DP-AP-SELECT31:24
  • A[23:8] => unused (0)
  • A[7:4] => DP-AP-SELECT[7:4] (Bank select within AP)
  • A[3:2] => APACC[3:2] (Register select within AP bank)
  • A[1:0] => unused (0)
Enumerator
ARM_CRegAHB_AP_CSW 

AHB-AP Control/Status Word register.

ARM_CRegAHB_AP_TAR 

AHB-AP Transfer Address register.

ARM_CRegAHB_AP_DRW 

AHB-AP Data Read/Write register.

ARM_CRegAHB_AP_CFG 

AHB-AP Config register.

ARM_CRegAHB_AP_Base 

AHB-AP IDebug base address register.

ARM_CRegAHB_AP_Id 

AHB-AP ID Register.

ARM_CRegMDM_AP_Status 

Status register.

ARM_CRegMDM_AP_Control 

Control register.

ARM_CRegMDM_AP_Ident 

Identifier register (should read 0x001C_0000)

Definition at line 601 of file USBDM_API.h.

◆ ARM_DRegisters_t

regNo Parameter for USBDM_ReadDReg() with SWD-ARM target

Enumerator
ARM_DRegIDCODE 

IDCODE reg - read, SWD-AP only.

ARM_DRegABORT 

ABORT reg - write only.

ARM_DRegSTATUS 

STATUS reg - read only.

ARM_DRegCONTROL 

CONTROL reg - write only.

ARM_DRegRESEND 

RESEND reg - read only.

ARM_DRegSELECT 

SELECT reg - write only.

ARM_DRegRDBUFF 

RDBUFF reg - read only.

ARM_DRegAPReg0 

AP reg #0.

ARM_DRegAPReg1 

AP reg #1.

ARM_DRegAPReg2 

AP reg #2.

ARM_DRegAPReg3 

AP reg #3.

Definition at line 694 of file USBDM_API.h.

◆ ARM_RegisterIndex_t

startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with ARM (Kinetis) target

Enumerator
ARM_RegIndexFirstCore 

First code reg.

ARM_RegIndexLastCore 

Last core reg (20 regs R0..R12,SP,LR,PC,XPSR,MSP,PSP,MISC)

ARM_RegIndexFirstFloat 

First float register.

ARM_RegIndexLastFloat 

Last float reg (33 regs FPSCR, FPS0..FPS32)

Definition at line 451 of file USBDM_API.h.

◆ ARM_Registers_t

regNo Parameter for ARM_ReadReg() with ARM (Kinetis) target

Enumerator
ARM_RegR0 

R0.

ARM_RegR1 

R1.

ARM_RegR2 

R2.

ARM_RegR3 

R3.

ARM_RegR4 

R4.

ARM_RegR5 

R5.

ARM_RegR6 

R6.

ARM_RegR7 

R7.

ARM_RegR8 

R8.

ARM_RegR9 

R9.

ARM_RegR10 

R10.

ARM_RegR11 

R11.

ARM_RegR12 

R12.

ARM_RegSP 

SP.

ARM_RegLR 

LR.

ARM_RegPC 

PC (Debug return address)

ARM_RegxPSR 

xPSR

ARM_RegMSP 

Main Stack pointer.

ARM_RegPSP 

Process Stack pointer.

ARM_RegMISC 

[31:24]=CONTROL,[23:16]=FAULTMASK,[15:8]=BASEPRI,[7:0]=PRIMASK.

ARM_RegFPSCR 

Floating point control register.

ARM_RegFPS0 

Floating point +0..+31.

Definition at line 422 of file USBDM_API.h.

◆ AutoConnect_t

Auto-reconnect options.

Enumerator
AUTOCONNECT_NEVER 

Only connect explicitly.

AUTOCONNECT_STATUS 

Reconnect on USBDM_ReadStatusReg()

AUTOCONNECT_ALWAYS 

Reconnect before every command.

Definition at line 258 of file USBDM_API.h.

◆ CFV1_CRegisters_t

regNo Parameter for USBDM_ReadCReg() with CFV1 target

Enumerator
CFV1_CRegOTHER_A7 

Other A7 (not active in target)

CFV1_CRegVBR 

Vector Base register.

CFV1_CRegCPUCR 

CPUCR.

CFV1_CRegMACSR 

MACSR.

CFV1_CRegMASK 

MASK.

CFV1_CRegACC 

ACC.

CFV1_CRegSR 

Status register.

CFV1_CRegPC 

Program Counter.

Definition at line 553 of file USBDM_API.h.

◆ CFV1_DRegisters_t

regNo Parameter for USBDM_ReadDReg() with CFV1 target

Note
: There may be other registers
Enumerator
CFV1_DRegCSR 

CSR.

CFV1_DRegXCSR 

XCSR.

CFV1_DRegCSR2 

CSR2.

CFV1_DRegCSR3 

CSR3.

CFV1_DRegBAAR 

BAAR.

CFV1_DRegAATR 

AATR.

CFV1_DRegTDR 

TDR.

CFV1_DRegPBR0 

PBR0.

CFV1_DRegPBMR 

PBMR - mask for PBR0.

CFV1_DRegABHR 

ABHR.

CFV1_DRegABLR 

ABLR.

CFV1_DRegDBR 

DBR.

CFV1_DRegBDMR 

DBMR - mask for DBR.

CFV1_DRegPBR1 

PBR1.

CFV1_DRegPBR2 

PBR2.

CFV1_DRegPBR3 

PBR3.

CFV1_ByteRegs 

Special access to msb.

CFV1_DRegXCSRbyte 

XCSR.msb.

CFV1_DRegCSR2byte 

CSR2.msb.

CFV1_DRegCSR3byte 

CSR3.msb.

Definition at line 650 of file USBDM_API.h.

◆ CFV1_RegisterIndex_t

startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with Coldfire V1 target

Enumerator
CFV1_RegIndexFirstCore 

First code reg.

CFV1_RegIndexLastCore 

Last core reg (18 regs D0..D7,A0..A7,SR,PC)

Definition at line 460 of file USBDM_API.h.

◆ CFV1_Registers_t

regNo Parameter for USBDM_ReadReg() with CFV1 target

Enumerator
CFV1_RegD0 

D0.

CFV1_RegD1 

D1.

CFV1_RegD2 

D2.

CFV1_RegD3 

D3.

CFV1_RegD4 

D4.

CFV1_RegD5 

D5.

CFV1_RegD6 

D6.

CFV1_RegD7 

D7.

CFV1_RegA0 

A0.

CFV1_RegA1 

A1.

CFV1_RegA2 

A2.

CFV1_RegA3 

A3.

CFV1_RegA4 

A4.

CFV1_RegA5 

A5.

CFV1_RegA6 

A6.

CFV1_RegA7 

A7.

CFV1_PSTBASE 

Start of PST registers, access as CFV1_PSTBASE+n.

CFV1_RegOTHER_A7 

Other A7 (not active in target)

CFV1_RegVBR 

Vector Base register.

CFV1_RegCPUCR 

CPUCR.

CFV1_RegMACSR 

MACSR.

CFV1_RegMASK 

MASK.

CFV1_RegACC 

ACC.

CFV1_RegSR 

Status register.

CFV1_RegPC 

Program Counter.

Definition at line 366 of file USBDM_API.h.

◆ CFVx_CRegisters_t

regNo Parameter for USBDM_ReadCReg() with CFVx target

Enumerator
CFVx_CRegD0 

D0-D7.

CFVx_CRegA0 

A0-A7.

CFVx_CRegOTHER_SP 

Other A7 (not active in target)

CFVx_CRegVBR 

Vector Base register.

CFVx_CRegSR 

Status Register.

CFVx_CRegPC 

Program Counter.

CFV1_CRegFLASHBAR 

Flash Base register.

CFV1_CRegRAMBAR 

RAM Base register.

Definition at line 566 of file USBDM_API.h.

◆ CFVx_DRegisters_t

regNo Parameter for USBDM_ReadDReg() with CFV1 target

Enumerator
CFVx_DRegCSR 

CSR.

CFVx_DRegBAAR 

BAAR.

CFVx_DRegAATR 

AATR.

CFVx_DRegTDR 

TDR.

CFVx_DRegPBR0 

PBR0.

CFVx_DRegPBMR 

PBMR - mask for PBR0.

CFVx_DRegABHR 

ABHR.

CFVx_DRegABLR 

ABLR.

CFVx_DRegDBR 

DBR.

CFVx_DRegBDMR 

DBMR - mask for DBR.

CFVx_DRegPBR1 

PBR1.

CFVx_DRegPBR2 

PBR2.

CFVx_DRegPBR3 

PBR3.

Definition at line 676 of file USBDM_API.h.

◆ CFVx_RegisterIndex_t

startRegIndex, endRegIndex Parameters for USBDM_ReadMultipleRegs() with Coldfire Vx target

Enumerator
CFVx_RegIndexFirstCore 

First code reg.

CFVx_RegIndexLastCore 

Last core reg (18 regs D0..D7,A0..A7,SR,PC)

Definition at line 467 of file USBDM_API.h.

◆ CFVx_Registers_t

regNo Parameter for USBDM_ReadReg() with CFVx target

Enumerator
CFVx_RegD0 

D0.

CFVx_RegD1 

D1.

CFVx_RegD2 

D2.

CFVx_RegD3 

D3.

CFVx_RegD4 

D4.

CFVx_RegD5 

D5.

CFVx_RegD6 

D6.

CFVx_RegD7 

D7.

CFVx_RegA0 

A0.

CFVx_RegA1 

A1.

CFVx_RegA2 

A2.

CFVx_RegA3 

A3.

CFVx_RegA4 

A4.

CFVx_RegA5 

A5.

CFVx_RegA6 

A6.

CFVx_RegA7 

A7.

Definition at line 400 of file USBDM_API.h.

◆ ClkSwValues_t

Target BDM Clock selection.

Enumerator
CS_DEFAULT 

Use default clock selection (don't modify target's reset default)

CS_ALT_CLK 

Force ALT clock (CLKSW = 0)

CS_NORMAL_CLK 

Force Normal clock (CLKSW = 1)

Definition at line 287 of file USBDM_API.h.

◆ HardwareCapabilities_t

Capabilities of the hardware.

Enumerator
BDM_CAP_HCS12 

Supports HCS12.

BDM_CAP_RS08 

12 V Flash programming supply available (RS08 support)

BDM_CAP_VDDCONTROL 

Control over target Vdd.

BDM_CAP_VDDSENSE 

Sensing of target Vdd.

BDM_CAP_CFVx 

Support for CFV 1,2 & 3.

BDM_CAP_HCS08 

Supports HCS08 targets - inverted when queried.

BDM_CAP_CFV1 

Supports CFV1 targets - inverted when queried.

BDM_CAP_JTAG 

Supports JTAG targets.

BDM_CAP_DSC 

Supports DSC targets.

BDM_CAP_ARM_JTAG 

Supports ARM targets via JTAG.

BDM_CAP_RST 

Control & sensing of RESET.

BDM_CAP_PST 

Supports PST signal sensing.

BDM_CAP_CDC 

Supports CDC Serial over USB interface.

BDM_CAP_ARM_SWD 

Supports ARM targets via SWD.

BDM_CAP_S12Z 

Supports HCS12Z targets via SWD.

Definition at line 113 of file USBDM_API.h.

◆ HCS08_DRegisters_t

regNo Parameter for USBDM_ReadDReg() with HCS08 target [BKPT reg]

Enumerator
HCS08_DRegBKPT 

Breakpoint register.

Definition at line 637 of file USBDM_API.h.

◆ HCS08_Registers_t

regNo Parameter for USBDM_ReadReg() with HCS08 target

Enumerator
HCS08_RegPC 

PC reg.

HCS08_RegSP 

SP reg.

HCS08_RegHX 

HX reg.

HCS08_RegA 

A reg.

HCS08_RegCCR 

CCR reg.

Definition at line 348 of file USBDM_API.h.

◆ HCS12_DRegisters_t

regNo Parameter for USBDM_ReadDReg() with HCS12 target [BD Space]

Note
: There may be other registers
Enumerator
HCS12_DRegBDMSTS 
  • BDMSTS (debug status/control) register
HCS12_DRegCCR 
  • Saved Target CCR
HCS12_DRegBDMINR 
  • BDM Internal Register Position Register

Definition at line 627 of file USBDM_API.h.

◆ HCS12_Registers_t

regNo Parameter for USBDM_ReadReg() with HCS12 target

Note
CCR is accessed through USBDM_ReadDReg()
Enumerator
HCS12_RegPC 

PC reg.

HCS12_RegD 

D reg.

HCS12_RegX 

X reg.

HCS12_RegY 

Y reg.

HCS12_RegSP 

SP reg.

HCS12_RegCCR 

CCR reg - redirected to USBDM_ReadDReg()

Definition at line 318 of file USBDM_API.h.

◆ JTAG_ExitActions_t

Options used with JTAG commands.

Enumerator
JTAG_STAY_SHIFT 

Remain in SHIFT-DR or SHIFT-IR.

JTAG_EXIT_IDLE 

Exit SHIFT-XX to RUN-TEST/IDLE.

JTAG_EXIT_SHIFT_DR 

Exit SHIFT-XX & enter SHIFT-DR w/o crossing RUN-TEST/IDLE.

JTAG_EXIT_SHIFT_IR 

Exit SHIFT-XX & enter SHIFT-IR w/o crossing RUN-TEST/IDLE.

JTAG_EXIT_ACTION_MASK 

Mask for Exit actions.

JTAG_WRITE_0 

Write 0's when reading - combined with above.

JTAG_WRITE_1 

Write 1's when reading - combined with above.

JTAG_WRITE_MASK 

Mask for Write actions.

JTAG_SHIFT_DR 

Enter SHIFT-DR (from TEST-LOGIC-RESET or RUN-TEST/IDLE)

JTAG_SHIFT_IR 

Enter SHIFT-IR (from TEST-LOGIC-RESET or RUN-TEST/IDLE)

Definition at line 735 of file USBDM_API.h.

◆ PinLevelMasks_t

Control signal masks for CMD_USBDM_CONTROL_PIN (USBDM_ControlPins())

Enumerator
PIN_BKGD 

Mask for BKGD values (PIN_BKGD_LOW, PIN_BKGD_HIGH & PIN_BKGD_3STATE)

PIN_BKGD_NC 

No change.

PIN_BKGD_3STATE 

Set BKGD 3-state.

PIN_BKGD_LOW 

Set BKGD low.

PIN_BKGD_HIGH 

Set BKGD high.

PIN_RESET 

Mask for RESET values (PIN_RESET_LOW & PIN_RESET_3STATE)

PIN_RESET_NC 

No change.

PIN_RESET_3STATE 

Set Reset 3-state.

PIN_RESET_LOW 

Set Reset low.

PIN_RESET_HIGH 

Status only - Reset high.

PIN_TA 

Mask for TA signal.

PIN_TA_NC 

No change.

PIN_TA_3STATE 

Set TA 3-state.

PIN_TA_LOW 

Set TA low.

PIN_DE 

Mask for DE signal.

PIN_DE_NC 

No change.

PIN_DE_3STATE 

Set DE 3-state.

PIN_DE_LOW 

Set DE low.

PIN_TRST 

Mask for TRST signal (not implemented)

PIN_TRST_NC 

No change.

PIN_TRST_3STATE 

Set TRST 3-state.

PIN_TRST_LOW 

Set TRST low.

PIN_BKPT 

Mask for BKPT signal.

PIN_BKPT_NC 

No change.

PIN_BKPT_3STATE 

Set BKPT 3-state.

PIN_BKPT_LOW 

Set BKPT low.

PIN_SWD 

Mask for SWD values (PIN_SWD_LOW, PIN_SWD_HIGH & PIN_SWD_3STATE)

PIN_SWD_NC 

No change.

PIN_SWD_3STATE 

Set SWD 3-state.

PIN_SWD_LOW 

Set SWD low.

PIN_SWD_HIGH 

Set SWD high.

PIN_SWCLK 

Mask for SWD values (PIN_SWCLK_LOW, PIN_SWCLK_HIGH & PIN_SWCLK_3STATE)

PIN_SWCLK_NC 

No change.

PIN_SWCLK_3STATE 

Set SWD 3-state.

PIN_SWCLK_LOW 

Set SWD low.

PIN_SWCLK_HIGH 

Set SWD high.

PIN_NOCHANGE 

No change to pins (used to get pin status)

PIN_RELEASE 

Release all pins (go to default for current target)

Definition at line 752 of file USBDM_API.h.

◆ ResetMode_t

Target reset status values.

Enumerator
NO_RESET_ACTIVITY 

No reset activity since last polled.

RESET_DETECTED 

Reset since last polled.

Definition at line 234 of file USBDM_API.h.

◆ ResetState_t

Target RSTO state.

Enumerator
RSTO_ACTIVE 

RSTO* is currently active [low].

RSTO_INACTIVE 

RSTO* is currently inactive [high].

Definition at line 227 of file USBDM_API.h.

◆ RS08_DRegisters_t

regNo Parameter for USBDM_ReadDReg() with RS08 target (BKPT)

Enumerator
RS08_DRegBKPT 

Breakpoint register.

Definition at line 643 of file USBDM_API.h.

◆ RS08_Registers_t

regNo Parameter for USBDM_ReadReg() with RS08 target

Enumerator
RS08_RegCCR_PC 

Combined CCR/PC register.

RS08_RegSPC 

Shadow PC.

RS08_RegA 

A reg.

Definition at line 358 of file USBDM_API.h.

◆ S12Z_Registers_t

regNo Parameter for USBDM_ReadReg() with HCS12 target

Note
CCR is accessed through USBDM_ReadDReg()
Enumerator
S12Z_RegD0 

D0 reg.

S12Z_RegD1 

D1 reg.

S12Z_RegD2 

D2 reg.

S12Z_RegD3 

D3 reg.

S12Z_RegD4 

D4 reg.

S12Z_RegD5 

D5 reg.

S12Z_RegD6 

D6 reg.

S12Z_RegD7 

D7 reg.

S12Z_RegX 

X reg.

S12Z_RegY 

Y reg.

S12Z_RegSP 

SP reg.

S12Z_RegPC 

PC reg.

S12Z_RegCCR 

CCR reg.

Definition at line 330 of file USBDM_API.h.

◆ SpeedMode_t

Target speed selection.

Enumerator
SPEED_NO_INFO 

Not connected.

SPEED_SYNC 

Speed determined by SYNC.

SPEED_GUESSED 

Speed determined by trial & error.

SPEED_USER_SUPPLIED 

User has specified the speed to use.

Definition at line 218 of file USBDM_API.h.

◆ TargetMode_t

Reset mode as used by CMD_USBDM_TARGET_RESET.

Enumerator
RESET_MODE_MASK 

Mask for reset mode (SPECIAL/NORMAL)

RESET_SPECIAL 

Special mode [BDM active, Target halted].

RESET_NORMAL 

Normal mode [usual reset, Target executes].

RESET_METHOD_MASK 

Mask for reset type (Hardware/Software/Power)

RESET_ALL 

Use all reset strategies as appropriate.

RESET_HARDWARE 

Use hardware RESET pin reset.

RESET_SOFTWARE 

Use software (BDM commands) reset.

RESET_POWER 

Cycle power.

RESET_VENDOR 

Vendor special method e.g. using MDM-AP for Kinetis.

RESET_DEFAULT 

Use target specific default method.

Definition at line 295 of file USBDM_API.h.

◆ TargetRunState_t

Target Halt state.

Enumerator
TARGET_RUNNING 

CFVx target running (ALLPST == 0)

TARGET_HALTED 

CFVx target halted (ALLPST == 1)

Definition at line 242 of file USBDM_API.h.

◆ TargetType_t

Target microcontroller types.

Enumerator
T_HC12 

HC12 or HCS12 target.

T_HCS12 

HC12 or HCS12 target.

T_HCS08 

HCS08 target.

T_RS08 

RS08 target.

T_CFV1 

Coldfire Version 1 target.

T_CFVx 

Coldfire Version 2,3,4 target.

T_JTAG 

JTAG target - TAP is set to RUN-TEST/IDLE.

T_EZFLASH 

EzPort Flash interface (SPI?)

T_MC56F80xx 

JTAG target with MC56F80xx optimised subroutines.

T_ARM_JTAG 

ARM target using JTAG.

T_ARM_SWD 

ARM target using SWD.

T_ARM 

ARM target using either SWD (preferred) or JTAG as supported.

T_S12Z 

S12Z target.

T_ILLEGAL 

Used to indicate error in selecting target.

T_OFF 

Turn off interface (no target)

Definition at line 163 of file USBDM_API.h.

◆ TargetVddSelect_t

Internal Target Voltage supply selection.

Enumerator
BDM_TARGET_VDD_OFF 

Target Vdd Off.

BDM_TARGET_VDD_3V3 

Target Vdd internal 3.3V.

BDM_TARGET_VDD_5V 

Target Vdd internal 5.0V.

BDM_TARGET_VDD_ENABLE 

Target Vdd internal at last set level.

BDM_TARGET_VDD_DISABLE 

Target Vdd Off but previously set level unchanged.

Definition at line 268 of file USBDM_API.h.

◆ TargetVddState_t

Target Voltage supply state.

Enumerator
BDM_TARGET_VDD_NONE 

Target Vdd not detected.

BDM_TARGET_VDD_EXT 

Target Vdd external.

BDM_TARGET_VDD_INT 

Target Vdd internal.

BDM_TARGET_VDD_ERR 

Target Vdd error.

Definition at line 249 of file USBDM_API.h.

◆ TargetVppSelect_t

Internal Programming Voltage supply selection.

Enumerator
BDM_TARGET_VPP_OFF 

Target Vpp Off.

BDM_TARGET_VPP_STANDBY 

Target Vpp Standby (Inverter on, Vpp off)

BDM_TARGET_VPP_ON 

Target Vpp On.

BDM_TARGET_VPP_ERROR 

Target Vpp ??

Definition at line 278 of file USBDM_API.h.

Function Documentation

◆ USBDM_BasicConnect()

USBDM_API USBDM_ErrorCode USBDM_BasicConnect ( void  )

Does basic connect to target.

ARM-SWD - Does JTAG to Serial Wire switching only Other targets same as USBDM_Connect()

◆ USBDM_BDMCommand()

USBDM_API USBDM_ErrorCode USBDM_BDMCommand ( unsigned int  txSize,
unsigned int  rxSize,
unsigned char  data[] 
)

Send Custom BDM command

Parameters
txSize
rxSize
data

◆ USBDM_Close()

USBDM_API USBDM_ErrorCode USBDM_Close ( void  )

Closes currently open device.

Returns

BDM_RC_OK => OK

◆ USBDM_Connect()

USBDM_API USBDM_ErrorCode USBDM_Connect ( void  )

Connects to Target.

This will cause the BDM module to attempt to connect to the Target. In most cases the BDM module will automatically determine the connection speed and successfully connect. If unsuccessful, it may be necessary to manually set the speed using set_speed().

Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_ControlPins()

USBDM_API USBDM_ErrorCode USBDM_ControlPins ( unsigned int  control,
unsigned int *  status 
)

Directly manipulate interface levels.

Parameters
control=> mask indicating interface levels see PinLevelMasks_t
status=> values on pins after action (not yet implemented). May be NULL.
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_Debug()

USBDM_API USBDM_ErrorCode USBDM_Debug ( unsigned char *  usb_data)

Execute debug command (various, see DebugSubCommands)

Parameters
usb_data- Command for BDM
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_DLLVersion()

USBDM_API unsigned int USBDM_DLLVersion ( void  )

Get version of the DLL.

Returns
version number (e.g. V4.9.5 => 0x40905)
Note
Prior to V4.9.5 an 8-bit version number (2 BCD digits, major-minor) was returned
This shouldn't be a problem as still monotonic

◆ USBDM_DLLVersionString()

const USBDM_API char* USBDM_DLLVersionString ( void  )

Get version string for DLL.

Returns
ptr to static ASCII string

◆ USBDM_Exit()

USBDM_API USBDM_ErrorCode USBDM_Exit ( void  )

Clean up.

This must be called after all USBDM operations are finished

Returns

BDM_RC_OK => OK
other => USB Error - see USBDM_ErrorCode

◆ USBDM_FindDevices()

USBDM_API USBDM_ErrorCode USBDM_FindDevices ( unsigned int *  deviceCount)

Find USBDM Devices
This function creates an internal list of USBDM devices.

The list is held until USBDM_ReleaseDevices() is called.
USBDM_FindDevices() must be done before any device may be opened.

Parameters
deviceCountNumber of BDM devices found
Returns

BDM_RC_OK => OK
BDM_RC_NO_USBDM_DEVICE => No devices found. other => other Error - see USBDM_ErrorCode
Note
deviceCount == 0 on any error so may be used w/o checking rc
The device list is held until USBDM_ReleaseDevices() is called

◆ USBDM_GetBDMDescription()

USBDM_API USBDM_ErrorCode USBDM_GetBDMDescription ( const char **  deviceDescription)

Obtain description of the currently opened BDM.

Parameters
deviceDescriptionUpdated to point to UTF-16LE device description
Returns

== BDM_RC_OK (0) => Success
== BDM_RC_USB_ERROR => USB failure
Note
deviceDescription points at a statically allocated buffer - do not free

◆ USBDM_GetBdmInformation()

USBDM_API USBDM_ErrorCode USBDM_GetBdmInformation ( USBDM_bdmInformation_t info)

Obtains information about the currently open BDM interface.

Parameters
infoptr to structure to contain the information
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note
The size element of info should be initialised before call.
Uses cached information from when the BDM was opened.

◆ USBDM_GetBDMSerialNumber()

USBDM_API USBDM_ErrorCode USBDM_GetBDMSerialNumber ( const char **  deviceSerialNumber)

Obtain serial number of the currently opened BDM.

Parameters
deviceSerialNumberUpdated to point to UTF-16LE serial number
Returns

== BDM_RC_OK (0) => Success
== BDM_RC_USB_ERROR => USB failure
Note
deviceDescription points at a statically allocated buffer - do not free

◆ USBDM_GetBDMStatus()

USBDM_API USBDM_ErrorCode USBDM_GetBDMStatus ( USBDMStatus_t USBDMStatus)

Fills user supplied structure with state of BDM communication channel.

Parameters
USBDMStatusPointer to structure to receive status, see USBDMStatus_t
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_GetCapabilities()

USBDM_API USBDM_ErrorCode USBDM_GetCapabilities ( HardwareCapabilities_t capabilities)

Obtains the Capability vector from the BDM interface.

Parameters
capabilities: ptr to where to return capability vector see HardwareCapabilities_t
Returns

BDM_RC_OK => OK
BDM_RC_WRONG_BDM_REVISION => BDM firmware/DLL are incompatible
other => Error code - see USBDM_ErrorCode
Note
Uses cached information from when the BDM was opened.
Can be used to check BDM firmware/DLL compatibility

◆ USBDM_GetCommandStatus()

USBDM_API USBDM_ErrorCode USBDM_GetCommandStatus ( void  )

Get status of the last command.

Returns

BDM_RC_OK => OK
BDM_RC_USB_ERROR => USB failure
other => Error code - see USBDM_ErrorCode

◆ USBDM_GetDefaultExtendedOptions()

USBDM_API USBDM_ErrorCode USBDM_GetDefaultExtendedOptions ( USBDM_ExtendedOptions_t bdmOptions)

Get default (target specific) BDM interface options.

Parameters
bdmOptions: Current options from BDM interface
Note - bdmOptions.size must be initialised
  • bdmOptions.targetType may be set
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note
newBdmOptions.targetType should be set if called before USBDM_SetTarget()

◆ USBDM_GetErrorString()

const USBDM_API char* USBDM_GetErrorString ( USBDM_ErrorCode  errorCode)

Gets string describing a USBDM error code.

Parameters
errorCode- error code returned from USBDM API routine.
Returns
- ptr to static string describing the error.

◆ USBDM_GetExtendedOptions()

USBDM_API USBDM_ErrorCode USBDM_GetExtendedOptions ( USBDM_ExtendedOptions_t currentBdmOptions)

Get BDM interface options.

Parameters
currentBdmOptions: Current options from BDM interface
Note - currentBdmOptions.size must be initialised
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_GetSpeed()

USBDM_API USBDM_ErrorCode USBDM_GetSpeed ( unsigned long *  frequency)

Get the BDM communication speed in kHz.

Parameters
frequency=> BDM Communication speed in kHz
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_GetSpeedHz()

USBDM_API USBDM_ErrorCode USBDM_GetSpeedHz ( unsigned long *  frequency)

Get the BDM communication speed in Hz.

Parameters
frequency=> BDM Communication speed in Hz
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_GetVersion()

USBDM_API USBDM_ErrorCode USBDM_GetVersion ( USBDM_Version_t version)

Gets BDM software version and type of hardware.

Parameters
versionVersion numbers (4 bytes)
  • USBDM software version
  • USBDM hardware type
  • ICP software version
  • ICP hardware type
    USBDM & ICP hardware versions should always agree
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note
- This command is directed to EP0 and is also allowed in ICP mode
Deprecated:
: use USBDM_GetBdmInformation()

◆ USBDM_ICP_Erase()

USBDM_API USBDM_ErrorCode USBDM_ICP_Erase ( unsigned int  addr,
unsigned int  count 
)

ICP mode - erase BDM Flash memory.

Parameters
addr32-bit memory address
countnumber of bytes to erase
Returns
Note
Flash memory alignment requirements should be taken into account. The range erased should be a multiple of the Flash erase block size.

◆ USBDM_ICP_Program()

USBDM_API USBDM_ErrorCode USBDM_ICP_Program ( unsigned int  addr,
unsigned int  count,
unsigned char *  data 
)

ICP mode - program BDM Flash memory.

Parameters
addr32-bit memory address
countnumber of bytes to program
dataPointer to buffer containing data
Returns

◆ USBDM_ICP_Reboot()

USBDM_API void USBDM_ICP_Reboot ( void  )

ICP mode - reboot.

The BDM does a normal reset

Used in ICP mode to reset to normal (BDM) mode.

Note
Communication is lost.
The BDM will do the usual flash validity checks before entering BDM mode so if flash is not correctly programmed the BDM may remain in ICP mode.

◆ USBDM_ICP_Verify()

USBDM_API USBDM_ErrorCode USBDM_ICP_Verify ( unsigned int  addr,
unsigned int  count,
unsigned char *  data 
)

ICP mode - verify BDM Flash memory.

Parameters
addr32-bit memory address
countnumber of bytes to verify
dataPointer to buffer containing data
Returns

◆ USBDM_Init()

USBDM_API USBDM_ErrorCode USBDM_Init ( void  )

Initialises USB interface.

This must be done before any other operations.

Returns

BDM_RC_OK => OK
other => USB Error - see USBDM_ErrorCode

◆ USBDM_JTAG_ExecuteSequence()

USBDM_API USBDM_ErrorCode USBDM_JTAG_ExecuteSequence ( unsigned char  length,
const unsigned char *  sequence,
unsigned char  inLength,
unsigned char *  inBuffer 
)

Execute JTAG Sequence.

Parameters
length- JTAG sequence length.
sequence- Pointer to sequence.
inLength- Expected length of input data
inBuffer- Returned values
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_JTAG_Read()

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)

Parameters
exitaction after shift, see JTAG_ExitActions_t
  • JTAG_STAY_SHIFT - Remain in SHIFT-DR or SHIFT-IR
  • JTAG_EXIT_IDLE - Exit SHIFT-XX to RUN-TEST/IDLE
  • JTAG_EXIT_SHIFT_DR - Exit SHIFT-XX & enter SHIFT-DR w/o crossing RUN-TEST/IDLE
  • JTAG_EXIT_SHIFT_IR - Exit SHIFT-XX & enter SHIFT-IR w/o crossing RUN-TEST/IDLE
  • +JTAG_WRITE_0 - Write 0's when reading - combined with one of above
  • +JTAG_WRITE_1 - Write 1's when reading - combined with one of above
bitCount8-bit count of bits to shift in. [>0]
It is not possible to do 0 bits.
bufferPointer to buffer for data read out of the device (first bit in LSB of the last byte in the buffer)
Note
Requires the tap to be in SHIFT-DR or SHIFT-IR state.
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_JTAG_ReadWrite()

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)

Parameters
exitaction after shift, see JTAG_ExitActions_t
  • JTAG_STAY_SHIFT - Remain in SHIFT-DR or SHIFT-IR
  • JTAG_EXIT_IDLE - Exit SHIFT-XX to RUN-TEST/IDLE
  • JTAG_EXIT_SHIFT_DR - Exit SHIFT-XX & enter SHIFT-DR w/o crossing RUN-TEST/IDLE
  • JTAG_EXIT_SHIFT_IR - Exit SHIFT-XX & enter SHIFT-IR w/o crossing RUN-TEST/IDLE
  • +JTAG_WRITE_0 - Write 0's when reading - combined with one of above
  • +JTAG_WRITE_1 - Write 1's when reading - combined with one of above
bitCount8-bit count of bits to shift in. [>0]
It is not possible to do 0 bits.
inBufferPointer to buffer for data written to the device (first bit in LSB of the last byte in the buffer)
outBufferPointer to buffer for data read out of the device (first bit in LSB of the last byte in the buffer)
Note
Requires the tap to be in SHIFT-DR or SHIFT-IR state.
inbuffer and outbuffer may be the same location
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_JTAG_Reset()

USBDM_API USBDM_ErrorCode USBDM_JTAG_Reset ( void  )

JTAG - Moves the TAP to TEST-LOGIC-RESET state TMS=11111, TDI=00000 or similar.

Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note
This uses the CMD_USBDM_JTAG_GOTORESET to move the TAP, it does not use TRST.

◆ USBDM_JTAG_SelectShift()

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) SHIFT_IR => TMS=1100, TDI=0 (Actually TMS=0000_1100)

Parameters
modeAction, ref JTAG_ExitActions_t
  • SHIFT_DR - Enter SHIFT-DR
  • SHIFT_IR - Enter SHIFT-IR
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note
- Requires the tap to be initially in TEST-LOGIC-RESET or RUN-TEST/IDLE

◆ USBDM_JTAG_Write()

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,11100 TDI=NxData,00000 EXIT_SHIFT_IR => TMS=Nx0,111100 TDI=NxData,000000 EXIT_IDLE => TMS=Nx0,10 TDI=NxData,00.

Parameters
exitaction after shift, see JTAG_ExitActions_t
  • JTAG_STAY_SHIFT - Remain in SHIFT-DR or SHIFT-IR
  • JTAG_EXIT_IDLE - Exit SHIFT-XX to RUN-TEST/IDLE
  • JTAG_EXIT_SHIFT_DR - Exit SHIFT-XX & enter SHIFT-DR w/o crossing RUN-TEST/IDLE
  • JTAG_EXIT_SHIFT_IR - Exit SHIFT-XX & enter SHIFT-IR w/o crossing RUN-TEST/IDLE
bitCount8-bit count of bits to shift in. [>0]
It is not possible to do 0 bits.
bufferPointer to data buffer. The data is shifted in LSB (last byte) first, unused bits (if any) are in the MSB (first) byte;
Note
Requires the tap to be in SHIFT-DR or SHIFT-IR state.
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_Open()

USBDM_API USBDM_ErrorCode USBDM_Open ( unsigned char  deviceNo)

Opens a device.

Parameters
deviceNoNumber (0..N) of device to open. A device must be open before any communication with the device can take place.
Note
The range of device numbers must be obtained from USBDM_FindDevices() before calling this function.
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_ReadCReg()

USBDM_API USBDM_ErrorCode USBDM_ReadCReg ( unsigned int  regNo,
unsigned long *  regValue 
)

Read Target Control register.

Parameters
regNoRegister # or address
regValue8/16/32-bit value
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_ReadDReg()

USBDM_API USBDM_ErrorCode USBDM_ReadDReg ( unsigned int  regNo,
unsigned long *  regValue 
)

Read Target Debug register.

Parameters
regNoRegister #
regValue8/16/32-bit value
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_ReadMemory()

USBDM_API USBDM_ErrorCode USBDM_ReadMemory ( unsigned int  memorySpace,
unsigned int  byteCount,
unsigned int  address,
unsigned char *  data 
)

Read data from target memory.

Parameters
memorySpace= Size of data (1/2/4 bytes)
byteCount= Number of bytes to transfer
address= Memory address
data= Where to place data
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_ReadMultipleRegs()

USBDM_API USBDM_ErrorCode USBDM_ReadMultipleRegs ( unsigned char  regValueBuffer[],
unsigned int  startRegIndex,
unsigned int  endRegIndex 
)

Read Multiple Core registers.

Parameters
regValueBufferValues in Target byte order??
startRegIndexRegister index (inclusive) to start reading at
endRegIndexRegister index (inclusive) to stop reading at
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note
The indexes mentioned above are magic numbers indexing an arbitrary table.
Use only the predefined values provided - ARM_RegisterIndex_t, CFV1_RegisterIndex_t, CFVx_RegisterIndex_t

◆ USBDM_ReadReg()

USBDM_API USBDM_ErrorCode USBDM_ReadReg ( unsigned int  regNo,
unsigned long *  regValue 
)

Read Target Core register.

Parameters
regNoRegister #
regValue8/16/32-bit value
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note
HCS12_RegCCR is accessed through USBDM_ReadDReg()

◆ USBDM_ReadStatusReg()

USBDM_API USBDM_ErrorCode USBDM_ReadStatusReg ( unsigned long *  BDMStatusReg)

Reads Target Status register byte.

Parameters
BDMStatusReg=> status register value read.
The register read depends on target:
  • HCS12 = BDMSTS, BDM Status register
  • HCS08 = BDCSCR, BDM Status & Control register
  • RS08 = BDCSCR, BDM Status & Control register
  • CFV1 = XCSR[31..24], Extended Configuration/Status Register
  • CFVx = CSR, Configuration/Status Register (CSR)
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note

The BDM may resynchronize/reconnect with the target before doing this read.

◆ USBDM_RebootToICP()

USBDM_API void USBDM_RebootToICP ( void  )

Set BDM for ICP mode & immediately reboots - used in BDM mode only.

The BDM resets in ICP mode after this command

Note
Communication is lost.

◆ USBDM_ReleaseDevices()

USBDM_API USBDM_ErrorCode USBDM_ReleaseDevices ( void  )

Release USBDM Device list.

Returns

BDM_RC_OK => OK
other => USB Error - see USBDM_ErrorCode

◆ USBDM_SetExtendedOptions()

USBDM_API USBDM_ErrorCode USBDM_SetExtendedOptions ( const USBDM_ExtendedOptions_t newBdmOptions)

Set BDM interface options.

Parameters
newBdmOptions: Options to pass to BDM interface
Note - size field must be initialised
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_SetOptions()

USBDM_API USBDM_ErrorCode USBDM_SetOptions ( BDM_Options_t newBdmOptions)

Set BDM interface options.

Parameters
newBdmOptions: Options to pass to BDM interface
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Deprecated:

◆ USBDM_SetSpeed()

USBDM_API USBDM_ErrorCode USBDM_SetSpeed ( unsigned long  frequency)

Sets the BDM communication speed.

Parameters
frequency=> BDM Communication speed in kHz
  • T_CFVx, T_JTAG, T_MC56F80xx : JTAG clock frequency
  • RS08, HCS08, HCS12, CFV1 : BDM interface frequency
    Usually equal to the CPU Bus frequency.
    May be unrelated to bus speed if alternative BDM clock is in use.
    Once a speed is set then automatic speed determination (by sync etc) is disabled. Automatic operation is restored by setting a speed of zero.
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_SetTargetType()

USBDM_API USBDM_ErrorCode USBDM_SetTargetType ( TargetType_t  targetType)

Sets target MCU type.

If the BDM has target power control then it will also:

  • Turn on target power
  • Halt the target if power has been newly applied (in special mode if appropriate)
  • ARM targets have hardware reset active to avoid power-on lockups or COP timeouts
Parameters
targetTypetype of target
Returns
0 => Success,
!=0 => Fail

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_SetTargetVdd()

USBDM_API USBDM_ErrorCode USBDM_SetTargetVdd ( TargetVddSelect_t  targetVdd)

Sets Target Vdd voltage.

Parameters
targetVdd=> control value for Vdd
Returns

BDM_RC_OK => OK
else => Various errors
Note
  • BDM_TARGET_VDD_ENABLE & BDM_TARGET_VDD_DISABLE should be used to enable and disable Vdd
  • BDM_TARGET_VDD_OFF, BDM_TARGET_VDD_3V3 & BDM_TARGET_VDD_5V should be used to set the required Vdd.
  • It is expected that the USBDM_SetTargetVdd() will be used to set the initial Vdd before calling USBDM_SetTarget() so that the appropriate power on sequence may be used.

◆ USBDM_SetTargetVpp()

USBDM_API USBDM_ErrorCode USBDM_SetTargetVpp ( TargetVppSelect_t  targetVpp)

Sets Target programming voltage.

Parameters
targetVpp=> control value for Vpp
Note
Before enabling target Vpp it is necessary to do the following:
  • Target device must be set to T_RS08
  • Target Vdd must be present (internally or externally)
  • The Target Vpp must be first set to BDM_TARGET_VPP_STANDBY then BDM_TARGET_VPP_ON
    The above is checked by the BDM firmware
Returns

BDM_RC_OK => OK
else => Various errors

◆ USBDM_TargetGo()

USBDM_API USBDM_ErrorCode USBDM_TargetGo ( void  )

Starts target execution from current PC address.

Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_TargetHalt()

USBDM_API USBDM_ErrorCode USBDM_TargetHalt ( void  )

Brings the target into active background mode.

The target will be halted.

Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_TargetReset()

USBDM_API USBDM_ErrorCode USBDM_TargetReset ( TargetMode_t  target_mode)

Resets the target to normal or special mode.

Parameters
target_modesee
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode
Note
V4.4 onwards - Communication with the target may be lost. It is necessary to use USBDM_Connect() to re-connect. This is no longer done automatically as it may interfere with security checking if attempted too soon after reset.

◆ USBDM_TargetStep()

USBDM_API USBDM_ErrorCode USBDM_TargetStep ( void  )

Steps over a single target instruction.

Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_WriteControlReg()

USBDM_API USBDM_ErrorCode USBDM_WriteControlReg ( unsigned int  value)

Write Target Control Register byte.

Parameters
value=> value to write The register written depends on target:
  • HCS12 = BDMSTS, BDM Status register
  • HCS08 = BDCSCR, BDM Status & Control register
  • RS08 = BDCSCR, BDM Status & Control register
  • CFV1 = XCSR[31..24], Extended Configuration/Status Register
  • CFVx not supported (Access CSR through writeControlReg())
Returns

BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_WriteCReg()

USBDM_API USBDM_ErrorCode USBDM_WriteCReg ( unsigned int  regNo,
unsigned long  regValue 
)

Write Target Control register.

Parameters
regNoRegister #
regValue8/16/32-bit value
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_WriteDReg()

USBDM_API USBDM_ErrorCode USBDM_WriteDReg ( unsigned int  regNo,
unsigned long  regValue 
)

Write Target Debug register.

Parameters
regNoRegister #
regValue8/16/32-bit value
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_WriteMemory()

USBDM_API USBDM_ErrorCode USBDM_WriteMemory ( unsigned int  memorySpace,
unsigned int  byteCount,
unsigned int  address,
unsigned const char *  data 
)

Write data to target memory.

Parameters
memorySpace= Size of data elements (1/2/4 bytes)
byteCount= Number of bytes to transfer
address= Memory address
data= Ptr to block of data to write
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode

◆ USBDM_WriteReg()

USBDM_API USBDM_ErrorCode USBDM_WriteReg ( unsigned int  regNo,
unsigned long  regValue 
)

Write Target Core register.

Parameters
regNoRegister #
regValue8/16/32-bit value
Returns
error code
BDM_RC_OK => OK
other => Error code - see USBDM_ErrorCode