OpenOCD
nulink_usb.c File Reference
Include dependency graph for nulink_usb.c:

Go to the source code of this file.

Data Structures

struct  nulink_usb_handle_s
 

Macros

#define ARM_SRAM_BASE   0x20000000UL
 
#define CMD_CHECK_ID   0xA3UL
 
#define CMD_CHECK_MCU_STOP   0xD8UL
 
#define CMD_MCU_FREE_RUN   0xD3UL
 
#define CMD_MCU_RESET   0xE2UL
 
#define CMD_MCU_STEP_RUN   0xD1UL
 
#define CMD_MCU_STOP_RUN   0xD2UL
 
#define CMD_READ_RAM   0xB1UL
 
#define CMD_READ_REG   0xB5UL
 
#define CMD_SET_CONFIG   0xA2UL
 
#define CMD_WRITE_RAM   0xB9UL
 
#define CMD_WRITE_REG   0xB8UL
 
#define HARDWARE_CONFIG_NULINK2   2
 
#define HARDWARE_CONFIG_NULINKPRO   1
 
#define NULINK2_HID_MAX_SIZE   (1024)
 
#define NULINK2_USB_PID1   (0x5200)
 
#define NULINK2_USB_PID2   (0x5201)
 
#define NULINK_HID_MAX_SIZE   (64)
 
#define NULINK_READ_TIMEOUT   LIBUSB_TIMEOUT_MS
 
#define V6M_MAX_COMMAND_LENGTH   (NULINK_HID_MAX_SIZE - 2)
 
#define V7M_MAX_COMMAND_LENGTH   (NULINK_HID_MAX_SIZE - 3)
 

Enumerations

enum  nulink_connect {
  CONNECT_NORMAL = 0 , CONNECT_PRE_RESET = 1 , CONNECT_UNDER_RESET = 2 , CONNECT_NONE = 3 ,
  CONNECT_DISCONNECT = 4 , CONNECT_ICP_MODE = 5
}
 
enum  nulink_reset {
  RESET_AUTO = 0 , RESET_HW = 1 , RESET_SYSRESETREQ = 2 , RESET_VECTRESET = 3 ,
  RESET_FAST_RESCUE = 4
}
 

Functions

static void nulink1_usb_init_buffer (void *handle, uint32_t size)
 
static int nulink1_usb_xfer (void *handle, uint8_t *buf, int size)
 
static void nulink2_usb_init_buffer (void *handle, uint32_t size)
 
static int nulink2_usb_xfer (void *handle, uint8_t *buf, int size)
 
static uint32_t nulink_max_block_size (uint32_t tar_autoincr_block, uint32_t address)
 
static int nulink_speed (void *handle, int khz, bool query)
 
static int nulink_usb_assert_srst (void *handle, int srst)
 
static int nulink_usb_close (void *handle)
 
static int nulink_usb_halt (void *handle)
 
static int nulink_usb_idcode (void *handle, uint32_t *idcode)
 
static void nulink_usb_init_buffer (void *handle, uint32_t size)
 
static int nulink_usb_open (struct hl_interface_param_s *param, void **fd)
 
static int nulink_usb_override_target (const char *targetname)
 
static int nulink_usb_read_mem (void *handle, uint32_t addr, uint32_t size, uint32_t count, uint8_t *buffer)
 
static int nulink_usb_read_mem32 (void *handle, uint32_t addr, uint16_t len, uint8_t *buffer)
 
static int nulink_usb_read_mem8 (void *handle, uint32_t addr, uint16_t len, uint8_t *buffer)
 
static int nulink_usb_read_reg (void *handle, unsigned int regsel, uint32_t *val)
 
static int nulink_usb_reset (void *handle)
 
static int nulink_usb_run (void *handle)
 
static enum target_state nulink_usb_state (void *handle)
 
static int nulink_usb_step (void *handle)
 
static int nulink_usb_version (void *handle)
 
static int nulink_usb_write_debug_reg (void *handle, uint32_t addr, uint32_t val)
 
static int nulink_usb_write_mem (void *handle, uint32_t addr, uint32_t size, uint32_t count, const uint8_t *buffer)
 
static int nulink_usb_write_mem32 (void *handle, uint32_t addr, uint16_t len, const uint8_t *buffer)
 
static int nulink_usb_write_mem8 (void *handle, uint32_t addr, uint16_t len, const uint8_t *buffer)
 
static int nulink_usb_write_reg (void *handle, unsigned int regsel, uint32_t val)
 
static int nulink_usb_xfer (void *handle, uint8_t *buf, int size)
 
static int nulink_usb_xfer_rw (void *handle, uint8_t *buf)
 

Variables

struct hl_layout_api_s nulink_usb_layout_api
 

Macro Definition Documentation

◆ ARM_SRAM_BASE

#define ARM_SRAM_BASE   0x20000000UL

Definition at line 66 of file nulink_usb.c.

◆ CMD_CHECK_ID

#define CMD_CHECK_ID   0xA3UL

Definition at line 58 of file nulink_usb.c.

◆ CMD_CHECK_MCU_STOP

#define CMD_CHECK_MCU_STOP   0xD8UL

Definition at line 60 of file nulink_usb.c.

◆ CMD_MCU_FREE_RUN

#define CMD_MCU_FREE_RUN   0xD3UL

Definition at line 63 of file nulink_usb.c.

◆ CMD_MCU_RESET

#define CMD_MCU_RESET   0xE2UL

Definition at line 59 of file nulink_usb.c.

◆ CMD_MCU_STEP_RUN

#define CMD_MCU_STEP_RUN   0xD1UL

Definition at line 61 of file nulink_usb.c.

◆ CMD_MCU_STOP_RUN

#define CMD_MCU_STOP_RUN   0xD2UL

Definition at line 62 of file nulink_usb.c.

◆ CMD_READ_RAM

#define CMD_READ_RAM   0xB1UL

Definition at line 55 of file nulink_usb.c.

◆ CMD_READ_REG

#define CMD_READ_REG   0xB5UL

Definition at line 54 of file nulink_usb.c.

◆ CMD_SET_CONFIG

#define CMD_SET_CONFIG   0xA2UL

Definition at line 64 of file nulink_usb.c.

◆ CMD_WRITE_RAM

#define CMD_WRITE_RAM   0xB9UL

Definition at line 57 of file nulink_usb.c.

◆ CMD_WRITE_REG

#define CMD_WRITE_REG   0xB8UL

Definition at line 56 of file nulink_usb.c.

◆ HARDWARE_CONFIG_NULINK2

#define HARDWARE_CONFIG_NULINK2   2

Definition at line 69 of file nulink_usb.c.

◆ HARDWARE_CONFIG_NULINKPRO

#define HARDWARE_CONFIG_NULINKPRO   1

Definition at line 68 of file nulink_usb.c.

◆ NULINK2_HID_MAX_SIZE

#define NULINK2_HID_MAX_SIZE   (1024)

Definition at line 30 of file nulink_usb.c.

◆ NULINK2_USB_PID1

#define NULINK2_USB_PID1   (0x5200)

Definition at line 34 of file nulink_usb.c.

◆ NULINK2_USB_PID2

#define NULINK2_USB_PID2   (0x5201)

Definition at line 35 of file nulink_usb.c.

◆ NULINK_HID_MAX_SIZE

#define NULINK_HID_MAX_SIZE   (64)

Definition at line 29 of file nulink_usb.c.

◆ NULINK_READ_TIMEOUT

#define NULINK_READ_TIMEOUT   LIBUSB_TIMEOUT_MS

Definition at line 27 of file nulink_usb.c.

◆ V6M_MAX_COMMAND_LENGTH

#define V6M_MAX_COMMAND_LENGTH   (NULINK_HID_MAX_SIZE - 2)

Definition at line 31 of file nulink_usb.c.

◆ V7M_MAX_COMMAND_LENGTH

#define V7M_MAX_COMMAND_LENGTH   (NULINK_HID_MAX_SIZE - 3)

Definition at line 32 of file nulink_usb.c.

Enumeration Type Documentation

◆ nulink_connect

Enumerator
CONNECT_NORMAL 
CONNECT_PRE_RESET 
CONNECT_UNDER_RESET 
CONNECT_NONE 
CONNECT_DISCONNECT 
CONNECT_ICP_MODE 

Definition at line 79 of file nulink_usb.c.

◆ nulink_reset

Enumerator
RESET_AUTO 
RESET_HW 
RESET_SYSRESETREQ 
RESET_VECTRESET 
RESET_FAST_RESCUE 

Definition at line 71 of file nulink_usb.c.

Function Documentation

◆ nulink1_usb_init_buffer()

static void nulink1_usb_init_buffer ( void *  handle,
uint32_t  size 
)
static

◆ nulink1_usb_xfer()

static int nulink1_usb_xfer ( void *  handle,
uint8_t *  buf,
int  size 
)
static

◆ nulink2_usb_init_buffer()

static void nulink2_usb_init_buffer ( void *  handle,
uint32_t  size 
)
static

◆ nulink2_usb_xfer()

static int nulink2_usb_xfer ( void *  handle,
uint8_t *  buf,
int  size 
)
static

◆ nulink_max_block_size()

static uint32_t nulink_max_block_size ( uint32_t  tar_autoincr_block,
uint32_t  address 
)
static

Definition at line 808 of file nulink_usb.c.

Referenced by nulink_usb_read_mem(), and nulink_usb_write_mem().

◆ nulink_speed()

◆ nulink_usb_assert_srst()

static int nulink_usb_assert_srst ( void *  handle,
int  srst 
)
static

◆ nulink_usb_close()

static int nulink_usb_close ( void *  handle)
static

Definition at line 1005 of file nulink_usb.c.

References nulink_usb_handle_s::dev_handle, ERROR_OK, and LOG_DEBUG.

◆ nulink_usb_halt()

◆ nulink_usb_idcode()

static int nulink_usb_idcode ( void *  handle,
uint32_t *  idcode 
)
static

◆ nulink_usb_init_buffer()

◆ nulink_usb_open()

static int nulink_usb_open ( struct hl_interface_param_s param,
void **  fd 
)
static

Definition at line 1021 of file nulink_usb.c.

◆ nulink_usb_override_target()

static int nulink_usb_override_target ( const char *  targetname)
static

Definition at line 944 of file nulink_usb.c.

References LOG_DEBUG.

◆ nulink_usb_read_mem()

static int nulink_usb_read_mem ( void *  handle,
uint32_t  addr,
uint32_t  size,
uint32_t  count,
uint8_t *  buffer 
)
static

◆ nulink_usb_read_mem32()

static int nulink_usb_read_mem32 ( void *  handle,
uint32_t  addr,
uint16_t  len,
uint8_t *  buffer 
)
static

◆ nulink_usb_read_mem8()

static int nulink_usb_read_mem8 ( void *  handle,
uint32_t  addr,
uint16_t  len,
uint8_t *  buffer 
)
static

◆ nulink_usb_read_reg()

static int nulink_usb_read_reg ( void *  handle,
unsigned int  regsel,
uint32_t *  val 
)
static

◆ nulink_usb_reset()

◆ nulink_usb_run()

◆ nulink_usb_state()

◆ nulink_usb_step()

◆ nulink_usb_version()

◆ nulink_usb_write_debug_reg()

static int nulink_usb_write_debug_reg ( void *  handle,
uint32_t  addr,
uint32_t  val 
)
static

Definition at line 244 of file nulink_usb.c.

◆ nulink_usb_write_mem()

static int nulink_usb_write_mem ( void *  handle,
uint32_t  addr,
uint32_t  size,
uint32_t  count,
const uint8_t *  buffer 
)
static

◆ nulink_usb_write_mem32()

static int nulink_usb_write_mem32 ( void *  handle,
uint32_t  addr,
uint16_t  len,
const uint8_t *  buffer 
)
static

◆ nulink_usb_write_mem8()

static int nulink_usb_write_mem8 ( void *  handle,
uint32_t  addr,
uint16_t  len,
const uint8_t *  buffer 
)
static

◆ nulink_usb_write_reg()

static int nulink_usb_write_reg ( void *  handle,
unsigned int  regsel,
uint32_t  val 
)
static

◆ nulink_usb_xfer()

◆ nulink_usb_xfer_rw()

static int nulink_usb_xfer_rw ( void *  handle,
uint8_t *  buf 
)
static

Variable Documentation

◆ nulink_usb_layout_api

struct hl_layout_api_s nulink_usb_layout_api
Initial value:
= {
.open = nulink_usb_open,
.close = nulink_usb_close,
.idcode = nulink_usb_idcode,
.state = nulink_usb_state,
.reset = nulink_usb_reset,
.assert_srst = nulink_usb_assert_srst,
.halt = nulink_usb_halt,
.step = nulink_usb_step,
.read_reg = nulink_usb_read_reg,
.write_reg = nulink_usb_write_reg,
.read_mem = nulink_usb_read_mem,
.write_mem = nulink_usb_write_mem,
.write_debug_reg = nulink_usb_write_debug_reg,
.override_target = nulink_usb_override_target,
.speed = nulink_speed,
}

Definition at line 1021 of file nulink_usb.c.