PICkitS Function Prototypes v2-4
PICkitS Function Prototypes v2-4
Document #:
Title: PICkit Serial DLL (PICkitS.dll) Function Prototypes
Subtitle:
Original Date: July 12, 2007
This document describes the functions available in PICkitS.dll. These functions can be called from any .NET application. While it may
Description:
be possible to use PICkitS.dll in a non .NET environment, non .NET applications are not supported at this time.
Table of Contents
Table of Contents.................................................................................................................................................................................................... 3
Introduction ............................................................................................................................................................................................................. 4
I2C Master Functions.............................................................................................................................................................................................. 6
I2C Slave Functions.............................................................................................................................................................................................. 20
SPI Master Functions............................................................................................................................................................................................ 26
Microwire Master Functions .................................................................................................................................................................................. 34
USART Functions ................................................................................................................................................................................................. 41
LIN Functions ........................................................................................................................................................................................................ 50
Device Functions .................................................................................................................................................................................................. 64
USBRead Functions ............................................................................................................................................................................................. 75
mTouchCap Functions.......................................................................................................................................................................................... 76
mTouch2 Functions .............................................................................................................................................................................................. 79
mTouchLV Functions ............................................................................................................................................................................................ 84
Firmware Functions .............................................................................................................................................................................................. 89
Introduction
History
08-18-08 Added SPI function Send_And_Receive_Data and overloaded I2CM functions Read and Write to handle two byte addressing
Added LIN slave function Add_LIN_Slave_Profile_To_PKS
This release corresponds to PICkitS.dll version 2.1.0.0 and PICkit Serial Analyzer firmware version 0303.
05-03-07 Original release – for PICkitS.dll version 1.5.0.0 and PICkit Serial Analyzer firmware version 0201.
This document describes the functions available in PICkitS.dll. These functions can be called from any .NET application. While it may be possible to use
PICkitS.dll in a non .NET environment, non .NET applications are not supported at this time.
public delegate void GUINotifierRead(byte slave_addr, ushort byte_count, ref byte[] data);
///////////////////////////////////////////////////////////////////////////
//
// Triggered: When the DLL receives a Read command byte sequence.
//
// Parameters: byte slave_addr - Address received by DLL. The
// application which handles the
// Receive trigger must know how
// to respond to the slave_addr.
// ushort byte_count - Number of bytes in between the
// slave Read address and the slave
// Write address.
// byte[] data - Data in-between the slave Read
// address and the slave Write address.
//
// Description: A delegate that is triggered whenever the dll interprets
// incoming data as a Read request. The user should register
// GUINotifierRead during initialization and associate the
// trigger with their own routine to send appropriate data
// using the Send_Bytes command. See the I2C Slave Example
// GUI.doc for an example.
//
///////////////////////////////////////////////////////////////////////////
public delegate void GUINotifierWrite(byte slave_addr, ushort byte_count, ref byte[] data);
///////////////////////////////////////////////////////////////////////////
//
// Triggered: When the DLL receives a Write command byte sequence.
//
// Parameters: byte slave_addr - Address received by DLL. The
// application which handles the
// Receive trigger must know how
// to respond to the slave_addr.
// ushort byte_count - Number of bytes following the
// slave Write address.
// byte[] data - Data following the slave Write
// address.
//
// Description: A delegate that is triggered whenever the dll interprets
// incoming data as a Write request. The user should register
// GUINotifierWrite during initialization and associate the
// trigger with their own routine to handle the incoming
// data. See the I2C Slave Example GUI.doc for an example.
//
///////////////////////////////////////////////////////////////////////////
USART Functions
public static bool Send_Data(byte p_byte_count, ref byte[] p_data_array, ref string p_script_view)
///////////////////////////////////////////////////////////////////////////
//
// Returns: True if successful, False if not
//
// Inputs: p_byte_count - number of bytes in p_data_array to send
// must be less than 252
// p_data_array - reference to byte array that holds
// data to be written
// p_script_view - reference to a string to which will be
// copied a formatted view of the command
//
// Description: Attempts to perform generic USART command using above
// parameters. Regardless of success or failure, the
// PICkit Serial status packet is updated after the
// write attempt and stored for retrieval by the function
// There_Is_A_Status_Error.
//
///////////////////////////////////////////////////////////////////////////
LIN Functions
public delegate void OnReceive(byte masterid, byte[] data, byte length, byte error,
ushort baud, double time);
///////////////////////////////////////////////////////////////////////////
//
// Triggered: When a frame is received, the DLL is in LISTEN mode and
// the frame is different than what is in the buffer.
// OR
// When a frame is received and the DLL is in DISPLAY_All mode
// AND
// In Master mode and sent a whole frame.
//
// Paramters: byte masterid - Frame ID
// byte[] data - array of data associated with ID
// - only contains data, not the ID
// byte length - bytecount of data only, not the ID
// ushort baud - value of baud rate received
// with frame data
// double time - time in seconds since last frame break
// byte error - Error code: 0 - no error
// 1 - timeout
// 2 - no sync break
// 3 - error resetting timestamp
// 4 - PKSA status error
// 5 - PKSA error event marker
//
///////////////////////////////////////////////////////////////////////////
public delegate void OnAnswer(byte masterid, byte[] data, byte length, byte error,
ushort baud, double time);
///////////////////////////////////////////////////////////////////////////
//
// Triggered: When data is successfully retrieved as the result of
// the Transmit command of zero length data bytes.
// Paramters: byte masterid - Frame ID
// byte[] data - array of data associated with ID
// - only contains data, not the ID
// byte length - bytecount of data only, not the ID
// ushort baud - value of baud rate sent
// double time - time in seconds since last frame break
//
// byte error - Error code: 0 - no error
// 1 - timeout
// 2 - no sync break
// 3 - error resetting timestamp
// 4 - PKSA status error
// 5 - PKSA error event marker
//
///////////////////////////////////////////////////////////////////////////
Device Functions
The following functions are all found in class PICkitS.Device and are all communication mode independent.
USBRead Functions
The following delegate is found in class PICkitS.USBRead.
mTouchCap Functions
The following functions are all found in class PICkitS.mTouchCap and are relevant only to devices using I2C
Microchip mTouch Capacitive firmware.
mTouch2 Functions
The following functions are all found in class PICkitS.mTouch2 and are relevant only to devices using
Microchip mTouch2 (Touch Sense 2) firmware.
mTouchLV Functions
Firmware Functions
///////////////////////////////////////////////////////////////////////////
//
// Returns: True if successful, False if not
// Inputs: p_file_name - firmware hex file name, including full path
// p_device_type - 1 for PKSA device
// 2 for LIN device
// p_error_str - reference to a string that will contain
// a detailed error msg if the function fails
// p_error_code - flag that details the reason for
// function failure:
// 0 - no failure, firmware correctly loaded
// 1 - error reading hex file
// 2 - error entering programming mode
// 3 - error clearing flash
// 4 - error writing flash
// 5 - error writing config bytes
// 6 - error reading flash
// 7 - error reading config bytes
// 8 - error verifying flash
// 9 - error verifying config bytes
// 10 - error issuing reset/exiting programming mode
//
// Description: Attempts to download firmware from hex file p_file_name
// into PKSA or LIN device. The steps are:
// - read hex file
// - force device into programming mode
// - verify device is in programming mode
// - clear old flash
// - write new flash
// - write new config bytes
// - read new flash