OneTechnologyWay•P. O . Box9106•Norwood,MA02062-9106,U.S.A.•Tel : 781.329.4700•Fax: 781.461.3113•www.analog.com
APPLICATION NOTE
LINB DLL Programmer´s Guide
by Holger Grothe
INTRODUCTION
This application note describes the library functions available in
the LINBWSD.dll library. These functions can be used to create
an USB-to-LIN downloader for integrated battery sensor devices.
LINBWSD.dll uses Protocol 6 for Flash/EE memory programming
via LIN. Protocol 6 is explained in detail in Application Note
AN-946. LINBWSD.dll can be used for LIN programming with
the following IBS devices:
• ADuC7032-8L
• ADuC7033
• ADuC7036DCPZ
• ADuC7039
LIN DOWNLOADER
DISCLAIMER
All LINBWSD library code provided by Analog Devices, Inc.,
including this file, is provided as is without warranty of any
kind, either expressed or implied. Users assume all risk from the
use of this code. It is the responsibility of the user integrating
this code into an application to ensure that the resulting
application performs as required and is safe.
The downloader board allows two interfaces to be connected, LIN and I2C. The LIN functionality of the interface is determined by the
on-board jumper connections, J5 and J6, as shown in Figure 2.
B
AB
J7
J5
J6
LIN
GND
LIN
VBAT
2
C
I
GND
SDA
SCL
VDD
10456-002
USB
J4
U1
ADuC832
J2
A
J8
Figure 2. LIN Downloader Jumper Configuration
Rev. 0 | Page 3 of 20
AN-1138 Application Note
DOWNLOAD SEQUENCE
LINBWSD.dll contains a security sequencer to prevent corruption of the Flash. The normal download sequence using the DLL functions follows:
* pcDLLInfoPointer to a char buffer that contains the version information from the DLL
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
Return Value
There is no return value.
Remark
It is necessary that an application close the opened USB port before closing the application. If an error occurs, the DLL opens a
MessageBox.
*pcOpenPortErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
Return Value
The return values for OpenDongle are as follows:
• 0 = no error.
• 1 = error during opening of USB port or no LIN-Dongle connected.
Remark
If the application tries to open an already open port, the DLL ignores the command.
*pcOpenPortErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
Return Value
The return values for GetDongleStatus are as follows:
• 0 = no error.
• 1 = error during dongle initialization or wrong dongle.
1
*pcDongleIdentPointer to a char buffer that contains the hardware and software information in ASCII from the dongle
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
Return Value
The return values for DoReadDongleIdent are as follows:
*pcLinInitErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
*pusCPU_IdentPointer to a variable of type BYTE that receives the CPU variant
Return Value
The return values for InitLinKernel are as follows:
• 0 = no error.
• 1 = error during initialization or no LIN-Dongle connected.
• 2 = detecting wrong CPU signature.
Remark
If GetDongleStatus() failed, the application should not use this function.
If the application does not use the default NAD, the AssignNAD() should call before InitLinKernel is called.
*cHexFilePath The file path to the hex file
*pcImportErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
Return Value
The return values for ImportHexData are as follows:
• 0 = no error.
• 1 = error during import.
Remark
The application should use GetImportInfo() to get information about the imported data for erase, program, and verify.
&ulEndAdrVariable for the highest address in hex file
&ulHexBytesVariable for the number of bytes imported
&ucMaxPagesVariable for the number of pages to erase
&ulAdrOffset Offset for programming (not necessary at the moment)
*pcPageEraseErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
*pusErasedPageNumberPointer to a variable of type BYTE that receives the number of pages that are erased
Return Value
The return values for DoPageErase are as follows:
• 0 = no error.
• 1 = error during page erase.
• 2 = application tries to erase more pages than necessary.
*pcWriteDataErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
*pusDataLenPointer to a variable of type BYTE that receives the number of bytes that are written
Return Value
The return values for DoDataWrite are as follows:
• 0 = no error.
• 1 = error during data write.
Remark
If not all pages are erased, the application cannot write data.
*pcWriteCRCErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
usCRC_Val
Return Value
The return values for DoWriteCRC are as follows:
• 0 = no error.
• 1 = error during writing checksum.
Remark
If program and verify are not successful, the DLL blocks this function.
*pcResetKernelErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
Return Value
The return values for DoResetKernel are as follows:
*pcAssignNADErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE that receives the length of the ASCII data
*pcRBIErrorPointer to a char buffer that contains ASCII data
*pusStringLenPointer to a variable of type BYTE which receives the length of the ASCII data
usIdentifier
Return Value
The return values for ReadByIdentifier are as follows: