📄 e2api.h
字号:
/* (c) Cambridge Silicon Radio Ltd, 2004 */
#ifndef E2API_H
#define E2API_H
#ifdef E2API_EXPORTS
#define E2API_API(T) _declspec(dllexport) T _stdcall
#else
#define E2API_API(T) _declspec(dllimport) T _stdcall
#endif /* E2DLL_EXPORTS */
const int E2_PASS = 1;
const int E2_FAIL = 0;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*******************************************************************************
Function Name : int e2Init(unsigned short port, unsigned short device, unsigned short size, unsigned short mask, unsigned int timeout)
Parameters :
port -
Defines the SPI port number to use (1 to N where N is the
maximum number of SPI ports)
device -
Number of the device on a multispi, or 0 if no multispi.
size -
Defines the size of the EEPROM device in log2 bytes.
E.g. for a 256 Kbit (32 KByte) device size would be 15 (i.e. 2^15)
mask -
Address mask of the EEPROM device to program.
timeout -
Amount of time (in milliseconds) to wait for the
SPI port to become available.
Returns : Returns 1 on successful initialisation, otherwise
0.
Description : This function is used to initialise the SPI interface and
locate an EEPROM device.
It must be called before any other operations can be
performed.
//*****************************************************************************/
E2API_API(int) e2Init(unsigned short port, unsigned short device, unsigned short size, unsigned short mask, unsigned int timeout);
/*******************************************************************************
Function Name : int e2Close(void)
Parameters :
Returns : Returns 1 on successful shutdown, otherwise 0.
Description : This function closes the SPI interface.
It must be called before e2Init can be called again for
a different device.
//*****************************************************************************/
E2API_API(int) e2Close(void);
/*******************************************************************************
Function Name : int e2GetDeviceAddress(unsigned int * address)
Parameters :
address -
Address of the EEPROM device
Returns : Returns the device address.
Description : This function is used to find the address that the EEPROM
device was found at from the last call to e2Init.
//*****************************************************************************/
E2API_API(unsigned int) e2GetDeviceAddress(void);
/*******************************************************************************
Function Name : int e2GetProgress(void)
Parameters : none
Returns : Returns an integer value in the range 0 - 100 representing
the percentage of completion of the current operation.
Description : This function is used to find out how far the current
operation has progressed.
Do not use this function to check if an operation has
completed as an operation may not have truly finished even
though it is at 100% progress. Use e2IsBusy to check if an
operation has completely finished.
//*****************************************************************************/
E2API_API(int) e2GetProgress(void);
/*******************************************************************************
Function Name : int e2GetResult(void)
Parameters : none
Returns : If the previously completed operation was successful the
return value is 1. If the operation failed the return
value is 0.
Description : This function is used to find the outcome of the previously
completed operation. To check if an operation has
completed use the e2IsBusy function.
//*****************************************************************************/
E2API_API(int) e2GetResult(void);
/*******************************************************************************
Function Name : int e2IsBusy(void)
Parameters : none
Returns : If performing an operation the return value is non-zero.
If no operation is being performed the return value is zero.
Description : This function is used to find if an operation is still
busy. Typically this function would be called periodically
after a call to e2Program, e2Clear or e2Dump with the wait
parameter set to 0.
//*****************************************************************************/
E2API_API(int) e2IsBusy(void);
/*******************************************************************************
Function Name : int e2Stop(void)
Parameters : none
Returns : Always returns 1.
Description : This function stops the current operation. The state of the
EEPROM device is undefined if an operation is stopped
before completion.
//*****************************************************************************/
E2API_API(int) e2Stop(void);
/*******************************************************************************
Function Name : int e2Program(const char * filename, const char wait, const char verify)
Parameters :
filename -
The path to a file containing the image to write
to the EEPROM device.
wait -
Defines whether the function will wait for the
programming operation to finish before returning.
Set non-zero to wait, otherwise 0 to return immediately.
If this parameter is 0 you can use the e2IsBusy and
e2GetProgress functions to check the progress of the
operation.
verify -
Defines whether the contents of the EEPROM after
writing should be verified against the given file.
Set to true to verify, otherwise set to false.
Note that verification will cause the operation to
take more time.
Returns : Returns 1 if the device is successfully programmed,
otherwise 0. If wait is non-zero the function will
return 1. The result of the actual operation has to
be found with a call to e2GetResult when the operation has
completed.
Description : This function is used to program the EEPROM device found
in the last call to e2Init.
The function can optionally wait for the programming
operation to finish before returning.
Note that if wait is set to 0 (so that the function
returns straight away) any calls to a function that access
a device will return 0 until the current operation
has completed or a call to e2Stop is made.
It is advisable to poll for completion of an operation
not less than once every second to prevent slow execution
of the operation.
//*****************************************************************************/
E2API_API(int) e2Program(const char * filename, const char wait, const char verify);
/*******************************************************************************
Function Name : int e2Clear(const unsigned char pattern, const char aWait, const char verify)
Parameters :
pattern -
Value to which all byte locations in the EEPROM
device are set to.
wait -
Defines whether the function will wait for the
programming operation to finish before returning.
Set non-zero to wait, otherwise 0 to return immediately.
If this parameter is 0 you can use the e2IsBusy and
e2GetProgress functions to check the progress of the
operation.
verify -
Defines whether the contents of the EEPROM after
clearing should be verified. Set to true to verify,
otherwise set to false. Default is true. Note that
verification will cause the operation to take more
time.
Returns : Returns 1 if successfully cleared, otherwise
0.
Description : This function is used to clear the EEPROM device found
in the last call to e2Init. Each byte location is set to
the given pattern value.
//*****************************************************************************/
E2API_API(int) e2Clear(const unsigned char pattern, const char aWait, const char verify);
/*******************************************************************************
Function Name : int e2Dump(const char * filename, const char aWait, const char verify)
Parameters :
filename -
Path to a file to dump the image contained in the
EEPROM device.
wait -
Defines whether the function will wait for the
programming operation to finish before returning.
Set non-zero to wait, otherwise 0 to return immediately.
If this parameter is 0 you can use the e2IsBusy and
e2GetProgress functions to check the progress of the
operation.
verify -
Defines whether the contents of the EEPROM after
dumping should be verified against the dumped file.
Set to 1 to verify, otherwise set to false.
Default is true. Note that verification will cause
the operation to take more time.
Returns : Returns 1 if successfully dumped, otherwise
0.
Description : This function is used to dump the contents of the EEPROM
device found in the last call to e2Init to a file.
//*****************************************************************************/
E2API_API(int) e2Dump(const char * filename, const char aWait, const char verify);
/*******************************************************************************
Function Name : int e2Verify(const char * filename, const char aWait)
Parameters :
filename -
Path to a file containing an image to compare with
the contents of the EEPROM device.
wait -
Defines whether the function will wait for the
programming operation to finish before returning.
Set non-zero to wait, otherwise 0 to return immediately.
If this parameter is 0 you can use the e2IsBusy and
e2GetProgress functions to check the progress of the
operation.
Returns : Returns 1 if the contents of the EEPROM device match
the image contained in the file, otherwise 0.
Description : This function is used to compare the contents of the EEPROM
device found in the last call to e2Init with the image
contained in the given file.
//*****************************************************************************/
E2API_API(int) e2Verify(const char * filename, const char aWait);
/*******************************************************************************
Function Name : int e2CheckSize(void)
Parameters : none
Returns : Returns 1 if the size of the EEPROM device is at
least as large as the size given in the last call to e2Init,
otherwise 0.
Description : This function is used to verify that the size of the EEPROM
device found in the last call to e2Init is at least as large
as the size that was specified. It does this by attempting
to write to the last location in the device using the size
given to e2Init.<p>
Note that the function will return 1 if the device is
larger than that specified in e2Init.
<p><b>WARNING:</b>This function does not take account of
devices that ignore out-of-range address bits. This may
cause the function to report a device size as valid even if
it is smaller than specified in e2Init.
//*****************************************************************************/
E2API_API(int) e2CheckSize(void);
/*******************************************************************************
Function Name : int e2WriteHeader(void)
Parameters : none
Returns : 1 if the header was written successfully, otherwise 0 on
error.
Description : This function is used to write the special header - as
required by BlueCore firmware - to the EEPROM device.
<p>This function cannot be called without the device first
being initialised with a call to e2Init.
//*****************************************************************************/
E2API_API(int) e2WriteHeader(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* E2API_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -