📄 opensourcebdm.h
字号:
/* header file for opensourcebdm.DLL
Change History:
------------------
*****Prominent Notice-This software was modified from TBDML software - 12/05
*/
#define SELAHCS08 1
typedef enum { /* type of BDM target */
HC12=0,
HCS08=1
} target_type_e;
typedef enum { /* type of reset action required */
SPECIAL_MODE=0,
NORMAL_MODE=1
} target_mode_e;
typedef enum { /* state of ACKN feature (supported or not) */
WAIT=0,
ACKN=1
} ackn_state_e;
typedef enum { /* target reset detection state */
RESET_INACTIVE=0,
RESET_DETECTED=1
} reset_state_e;
typedef enum { /* how was the target speed detected */
NO_CONNECTION=0,
SYNC=1,
RESERVED=2,
MANUAL_SETUP=3
} connection_state_e;
typedef struct { /* state of BDM communication */
ackn_state_e ackn_state;
reset_state_e reset_state;
connection_state_e connection_state;
} bdm_status_t;
typedef union {
struct {
unsigned int pc;
unsigned int sp;
unsigned int ix;
unsigned int iy;
unsigned int d;
unsigned int ccr;
} hc12;
struct {
unsigned int pc;
unsigned int sp;
unsigned int hx;
unsigned int a;
unsigned int ccr;
} hcs08;
} registers_t;
unsigned char WINAPI opensourcebdm_dll_version(void); /* returns DLL version in BCD */
unsigned char WINAPI opensourcebdm_init(void); /* initialises USB and returns number of devices found */
unsigned char WINAPI opensourcebdm_open(unsigned char device_no); /* opens a device with given number (0...), returns 0 on success and 1 on error */
void WINAPI opensourcebdm_close(void); /* closes currently open device */
unsigned int WINAPI opensourcebdm_get_version(void); /* returns version of HW (MSB) and SW (LSB) of the interface in BCD format */
unsigned char WINAPI opensourcebdm_get_last_sts(void); /* returns status of the last command: 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_set_target_type(target_type_e target_type); /* sets target MCU type, returns 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_target_sync(void); /* measures BDM frequency of the target using the SYNC feature and connects to it, returns 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_target_reset(target_mode_e target_mode); /* resets the target to normal or special mode, returns 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_bdm_sts(bdm_status_t *bdm_status); /* fills user supplied structure with actual state of BDM communication channel, returns 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_write_bd(unsigned int address, unsigned char data); /* writes one byte to the BDM area of memory, returns 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_target_go(void); /* starts target execution from current PC address, returns 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_target_step(void); /* steps over a single target instruction, returns 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_target_halt(void); /* brings the target into active background mode, returns 0 on success and non-zero on failure */
unsigned char WINAPI opensourcebdm_set_speed(float crystal_frequency); /* sets the communication speed, parameter is crystal frequency in MHz, returns 0 on success and non-zero on failure */
float WINAPI opensourcebdm_get_speed(void); /* returns crystal frequency of the target in MHz */
unsigned char WINAPI opensourcebdm_read_byte(unsigned int address); /* reads one byte from memory */
void WINAPI opensourcebdm_write_byte(unsigned int address, unsigned char data); /* writes one byte to memory */
//*******************************
#if SELAHCS08
unsigned char WINAPI opensourcebdm_read_status(void);
void WINAPI opensourcebdm_write_bkpt(unsigned int value);
void WINAPI opensourcebdm_write_control(unsigned char value);
unsigned int WINAPI opensourcebdm_read_bkpt(void);
#else
unsigned char WINAPI opensourcebdm_read_bd(unsigned int address); /* reads one byte from the BDM area of memory */
unsigned int WINAPI opensourcebdm_read_word(unsigned int address); /* reads one word from memory (address must be aligned) */
void WINAPI opensourcebdm_write_word(unsigned int address, unsigned int data); /* writes one word to memory (address must be aligned) */
#endif
void WINAPI opensourcebdm_read_block(unsigned int address, unsigned int count, unsigned char *data); /* reads block from memory, data is returned to the user supplied buffer */
void WINAPI opensourcebdm_write_block(unsigned int address, unsigned int count, unsigned char *data); /* writes block to memory */
unsigned char WINAPI opensourcebdm_read_regs(registers_t *registers); /* reads contents of core registers, returns 0 on success and non-zero on failure */
void WINAPI opensourcebdm_write_reg_pc(unsigned int value); /* writes PC */
void WINAPI opensourcebdm_write_reg_sp(unsigned int value); /* writes SP */
void WINAPI opensourcebdm_write_reg_x(unsigned int value); /* writes H:X (HCS08) or IX (HC12) */
void WINAPI opensourcebdm_write_reg_y(unsigned int value); /* writes IY (HC12 only) */
void WINAPI opensourcebdm_write_reg_d(unsigned int value); /* writes B:A (HC12) or A (HCS08) */
void WINAPI opensourcebdm_write_reg_ccr(unsigned int value); /* writes CCR */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -