Cart Contact NSDSP Home

nsdsp_session_program

This function programs the target device

Syntax

int nsdsp_session_program(
        nsdsp_session_t   session,
        hex_map_t         hex_map,
        int               verify
);

Parameters

session - a reference to the Session Object

hex_map - a Hex Map object containing data to be programmed on the device

verify - non-zero if you want to verify programming, zero otherwise.

Return

The function returns non-zero if programming succeeds, or zero otherwise. If programming fails, you can use nsdsp_get_error to retrieve the error message.

Notes

After successful completion, the type of the session changes to idle or SPI depending on the nsdsp_reset_after_prog setting. If the operation fails, the session becomes idle.

Example

int ProgramDevice(char* DeviceName, char* HexFileName) {
  hex_map_t hm;
  mcu_t mcu;
  nsdsp_t nsdsp;
  nsdsp_session_t sess;
  int ret;

  ret = 0;
  hm = hex_map_read(HexFileName,NULL);
  if (hm) {
    mcu = mcu_create(DeviceName);
    if (mcu) {
      nsdsp = nsdsp_connect(NULL);
      if (nsdsp) {
        sess = nsdsp_start_prog_session(nsdsp,mcu,0);
        if (sess) {
          ret = nsdsp_session_program(sess,hm,1);
        }
        nsdsp_free(nsdsp);
      }
      mcu_free(mcu);
    }
    hex_map_free(hm);
  }
  return ret;
}

 

Supported session types: program

Minimum library version - 163

Northern Software Home NSDSP Contact Us Purchase/View Cart

© 2007-2025 Northern Software Inc. All Rights Reserved.