#ifndef __ACI_PROG_H__ #define __ACI_PROG_H__ // Phyton Application Control Interface for Device Programmers // // (C) Phyton // ACI Error Codes #define ACI_ERR_SUCCESS 0 #define ACI_ERR_INVALID_PARAMS_SIZE 1 // Invalid structure size in ACI function #define ACI_ERR_INVALID_EXE 2 // Invalid executable in ACI_Launch() #define ACI_ERR_EXE_FAILED 3 // Programmer executable failed to launch #define ACI_ERR_FILE_ERROR 4 // File error #define ACI_ERR_ATTACH_FAILED 5 // ACI_Launch() failed #define ACI_ERR_INVALID_PARAMETER 6 // Invalid parameter in function structure #define ACI_ERR_FUNCTION_FAILED 7 // Function execution failed in ACI_ExecFunction() #define ACI_ERR_NOT_CONNECTED 8 // No connection to the target hardware #define ACI_ERR_NOT_AVAILABLE_NOW 9 // Requested operation is not available at the moment #define ACI_ERR_INVALID_LAYER 10 // Invalid buffer or layer number #define ACI_ERR_INVALID_ADDR 11 // Invalid address #define ACI_ERR_OUT_OF_RANGE 12 // Value is out of range #define ACI_ERR_INVALID_SITE 13 // For Gang mode: Invalid site number #define ACI_ERR_GANG_MODE 14 // Gang mode function was called in the single-programmer mode or vice versa // ACI Programming Options defines #define ACI_PO_LONG 0 // Signed integer option #define ACI_PO_FLOAT 1 // Floating point option #define ACI_PO_STRING 2 // String option #define ACI_PO_CHECKBOXES 3 // 32-bit array of bits #define ACI_PO_LIST 4 // List (radiobuttons) #define ACI_PO_BITSTREAM 5 // Bit stream - variable size bit array // ACI Data Split defines #define ACI_SP_NONE 0 #define ACI_SP_EVEN_BYTE 1 #define ACI_SP_ODD_BYTE 2 #define ACI_SP_BYTE_0 3 #define ACI_SP_BYTE_1 4 #define ACI_SP_BYTE_2 5 #define ACI_SP_BYTE_3 6 // ACI Programming Option Mode constants for ACI_GetProgOption()/ACI_SetProgOption() #define ACI_PP_MODE_VALUE 0 // Get/set value specified in Value member of the ACI_ProgOption_Params structure #define ACI_PP_MODE_DEFAULT_VALUE 1 // Get/set default option value, ignore Value member #define ACI_PP_MODE_MIN_VALUE 2 // Get/set minimal option value, ignore Value member #define ACI_PP_MODE_MAX_VALUE 3 // Get/set maximal option value, ignore Value member // ACI Device Status #define ACI_DS_OK 0 // Device detected, pin contacts are ok #define ACI_DS_OUT_OF_SOCKET 1 // No device in the socket #define ACI_DS_SHIFTED 2 // Device detected, inserted with shift #define ACI_DS_BAD_CONTACT 3 // Bad pin contact(s) #define ACI_DS_UNKNOWN 4 // Unknown (Auto Detect is probably off) // ACI Device Auto-Detect or 'Start' button action #define ACI_AD_EXEC_FUNCTION 0 // Execute function currently selected in the list #define ACI_AD_EXEC_AUTO 1 // Execute Auto Programming #define ACI_AD_EXEC_SCRIPT 2 // Execute script choosen in the programmer IDE #define ACI_AD_DO_NOTHING 3 // Do nothing // ACI File formats for ACI_FileLoad() #define ACI_PLF_INTEL_HEX 0 // Standard/Extended Intel HEX #define ACI_PLF_BINARY 1 // Binary image #define ACI_PLF_MOTOROLA_S 2 // Motorola S-record #define ACI_PLF_POF 3 // POF #define ACI_PLF_JEDEC 4 // JEDEC #define ACI_PLF_PRG 5 // PRG #define ACI_PLF_OTP 6 // Holtek OTP #define ACI_PLF_SAV 7 // Angstrem SAV #define ACI_PLF_ASCII_HEX 8 // ASCII Hex #define ACI_PLF_ASCII_OCTAL 9 // ASCII Octal // ACI File formats for ACI_FileSave() #define ACI_PSF_INTEL_HEX 0 // Intel HEX #define ACI_PSF_BINARY 1 // Binary image #define ACI_PSF_MOTOROLA_S 2 // Motorola S-record #define ACI_PSF_POF 3 // POF #define ACI_PSF_JEDEC 4 // JEDEC #define ACI_PSF_PRG 5 // PRG #define ACI_PSF_ASCII_HEX 6 // ASCII Hex #define ACI_PSF_ASCII_OCTAL 7 // ASCII Octal // ACI Structures typedef struct tagACI_Launch_Params { UINT Size; // (in) Size of structure, in bytes LPCSTR ProgrammerExe; // (in) Programmer executable file name LPCSTR CommandLine; // (in) Optional programmer command-line parameters BOOL DebugMode; // (in) Debug mode. Programmer window is not hidden UINT NumSites; // (out) For Gang mode: Number of sites LPVOID ConnectionId; // (out) Connection identifier char ProgrammerName[64]; // (out) Programmer name } ACI_Launch_Params; typedef struct tagACI_Config_Params { UINT Size; // (in) Size of structure, in bytes LPCSTR FileName; // (in) Options file name to load/save configuration } ACI_Config_Params; typedef struct tagACI_Device_Params { UINT Size; // (in) Size of structure, in bytes CHAR Manufacturer[64]; // (in || out) Device Manufacturer CHAR Name[64]; // (in || out) Device Name } ACI_Device_Params; typedef struct tagACI_Layer_Params { UINT Size; // (in) Size of structure, in bytes UINT BufferNumber; // (in) Number of buffer of interest, the first buffer number is 0 UINT LayerNumber; // (in) Number of layer of interest, the first layer number is 0 DWORD LayerSizeLow; // (out) Low 32 bits of layer size, in bytes DWORD LayerSizeHigh; // (out) High 32 bits of layer size, in bytes DWORD DeviceStartAddrLow; // (out) Low 32 bits of device start address for this layer DWORD DeviceStartAddrHigh; // (out) High 32 bits of device start address for this layer DWORD DeviceEndAddrLow; // (out) Low 32 bits of device end address for this layer DWORD DeviceEndAddrHigh; // (out) High 32 bits of device end address for this layer DWORD DeviceBufStartAddrLow; // (out) Low 32 bits of device memory start address in buffer for this layer DWORD DeviceBufStartAddrHigh; // (out) High 32 bits of device memory start address in buffer for this layer UINT UnitSize; // (out) Size of layer unit, in bits (8, 16 or 32) BOOL FixedSize; // (out) Size of layer cannot be changed with ACI_ReallocBuffer() CHAR BufferName[64]; // (out) Buffer name CHAR LayerName[64]; // (out) Layer name, cannot be changed UINT NumBuffers; // (out) Total number of currently allocated buffers UINT NumLayers; // (out) Total number of layers in a buffer } ACI_Layer_Params; typedef struct tagACI_Memory_Params { UINT Size; // (in) Size of structure, in bytes UINT BufferNumber; // (in) Number of buffer of interest, the first buffer number is 0 UINT LayerNumber; // (in) Number of layer of interest, the first layer number is 0 DWORD AddressLow; // (in) Low 32 bits of address, in layer units (natural to device address) DWORD AddressHigh; // (in) High 32 bits of address, in layer units (natural to device address) PVOID Data; // (in || out) Pointer to data to read to or write from DWORD DataSize; // (in) Size of data to read or write, in layer units, max. 16 MB (0x1000000) DWORD FillValue; // (in) Value to fill buffer with, used by ACI_FillLayer() only } ACI_Memory_Params; typedef struct tagACI_Buffer_Params { UINT Size; // (in) Size of structure, in bytes DWORD Layer0SizeLow; // (in/out) Low 32 bits of layer 0 size, in bytes DWORD Layer0SizeHigh; // (in/out) High 32 bits of layer 0 size, in bytes // Layer size is rounded up to a nearest value supported by programmer. LPCSTR BufferName; // (in) Buffer name UINT BufferNumber; // For ACI_CreateBuffer(): out: Created buffer number // For ACI_ReallocBuffer(): in: Buffer number to realloc UINT NumBuffers; // (out) Total number of currently allocated buffers UINT NumLayers; // (out) Total number of layers in a buffer } ACI_Buffer_Params; typedef struct tagACI_Programming_Params { UINT Size; // (in) Size of structure, in bytes BOOL InsertTest; // (in || out) Test if device is attached BOOL CheckDeviceId; // (in || out) Check device identifier BOOL ReverseBytesOrder; // (in || out) Reverse bytes order in buffer BOOL BlankCheckBeforeProgram; // (in || out) Perform blank check before programming BOOL VerifyAfterProgram; // (in || out) Verify after programming BOOL VerifyAfterRead; // (in || out) Verify after read BOOL SplitData; // (in || out) Split data: see ACI_SP_... constants BOOL DeviceAutoDetect; // (in || out) Auto detect device in socket (not all of the programmers provide this feature) BOOL DialogBoxOnError; // (in || out) On error, display dialog box UINT AutoDetectAction; // (in || out) Action to perform on device autodetect or 'Start' button, see ACI_AD_... constants DWORD DeviceStartAddrLow; // (in || out) Low 32 bits of device start address for programming operation DWORD DeviceStartAddrHigh; // (in || out) High 32 bits of device start address for programming operation DWORD DeviceEndAddrLow; // (in || out) Low 32 bits of device end address for programming operation DWORD DeviceEndAddrHigh; // (in || out) High 32 bits of device end address for programming operation DWORD BufferStartAddrLow; // (in || out) Low 32 bits of device memory start address in buffer for programming operation DWORD BufferStartAddrHigh; // (in || out) High 32 bits of device memory start address in buffer for programming operation } ACI_Programming_Params; typedef struct tagACI_ProgOption_Params { UINT Size; // (in) Size of structure, in bytes LPCSTR OptionName; // (in) Name of the option. For lists, it should be in the form "List array name^List Name", e.g. "Configuration Bits^Oscillator" CHAR Units[32]; // (out) Option measurement units ("kHz", "V", etc.) CHAR OptionDescription[64]; // (out) Description of the option CHAR ListString[64]; // (out) For ACI_PO_LIST option: Option string for Value.ListIndex UINT OptionType; // (out) Option type: see ACI_PO_... constants BOOL ReadOnly; // (out) Option is read-only union // (in || out) Option value { LONG LongValue; // (in || out) Value for ACI_PO_LONG option FLOAT FloatValue; // (in || out) Value for ACI_PO_FLOAT option LPSTR String; // (in || out) Pointer to string for ACI_PO_STRING option ULONG CheckBoxesValue; // (in || out) Value for ACI_PO_CHECKBOXES option UINT StateIndex; // (in || out) State index for ACI_PO_LIST option LPBYTE Bitstream; // (in || out) Pointer to bitstream data for ACI_PO_BITSTREAM option } Value; UINT VSize; // For ACI_SetProgOption(): // in: Size of Bitstream if OptionType == ACI_PO_BITSTREAM // For ACI_GetProgOption(): // in: Size of buffer pointed by Bitstream if OptionType == ACI_PO_BITSTREAM // in: Size of buffer pointed by String if OptionType == ACI_PO_STRING // out: Size of buffer needed for storing Bitstream data if OptionType == ACI_PO_BITSTREAM. // Set Value.Bitstream to NULL to get buffer size without setting the bitstream data // out: Size of buffer needed for storing String if OptionType == ACI_PO_STRING, including the terminating NULL character. // Set Value.String to NULL to get buffer size without setting the string UINT Mode; // (in) For ACI_SetProgOption(): SEE ACI_PP_MODE_... constants } ACI_ProgOption_Params; typedef struct tagACI_Function_Params { UINT Size; // (in) Size of structure, in bytes LPCSTR FunctionName; // (in) Name of a function to execute. If a function is under a sub-menu, use '^' to separate menu name from function name, e.g. "Lock Bits^Bit 0" // To execute Auto Programming, set FunctionName to NULL, empty string or "Auto Programming". UINT BufferNumber; // (in) Buffer number to use BOOL Silent; // (in) On error, do not display error message box, just copy error string to ErrorMessage CHAR ErrorMessage[512]; // (out) Error message string if ACI_ExecFunction() fails } ACI_Function_Params; typedef struct tagACI_GangStart_Params { UINT Size; // (in) Size of structure, in bytes UINT SiteNumber; // (in) Site number to start auto programming at UINT BufferNumber; // (in) Buffer number to use BOOL Silent; // (in) On error, do not display error message box. Use ACI_GetStatus() to get error message string } ACI_GangStart_Params; typedef struct tagACI_PStatus_Params { UINT Size; // (in) Size of structure, in bytes UINT SiteNumber; // (in) For Gang mode: site number to get status of, otherwise ignored BOOL Executing; // (out) Device function started by ACI_StartFunction() is executing UINT PercentComplete; // (out) Function complete percent, valid id Executing != FALSE UINT DeviceStatus; // (out) Device/socket status, see ACI_DS_... constants BOOL NewDevice; // (out) New device inserted, no function has been executed yet. Valid if DeviceAutoDetect is ON. BOOL FunctionFailed; // (out) TRUE if last function failed CHAR FunctionName[128]; // (out) Name of a function being executed if Executing != FALSE. If a function is under a sub-menu, function name will be like this: "Lock Bits^Bit 0" CHAR ErrorMessage[512]; // (out) Error message string if FunctionFailed != FALSE } ACI_PStatus_Params; typedef struct tagACI_File_Params { UINT Size; // (in) Size of structure, in bytes LPCSTR FileName; // (in) File name UINT BufferNumber; // (in) Buffer number UINT LayerNumber; // (in) Layer number UINT Format; // (in) File format: see ACI_PLF_... and ACI_PSF_... constants DWORD StartAddressLow; // (in) Low 32 bits of start address for ACI_FileSave(). // For ACI_FileLoad(): Ignored if Format != ACI_PLF_BINARY DWORD StartAddressHigh; // (in) High 32 bits of start address for ACI_FileSave(). // For ACI_FileLoad(): Ignored if Format != ACI_PLF_BINARY DWORD EndAddressLow; // (in) ACI_FileSave(): Low 32 bits of end address DWORD EndAddressHigh; // (in) ACI_FileSave(): High 32 bits of end address DWORD OffsetLow; // (in) Low 32 bits of address offset for ACI_FileLoad() DWORD OffsetHigh; // (in) High 32 bits of address offset for ACI_FileLoad() } ACI_File_Params; typedef struct tagACI_Connection_Params { UINT Size; // (in) Size of structure, in bytes LPVOID ConnectionId; // ACI_SetConnection(): (in), ACI_GetConnection(): (out) // Connection identifier } ACI_Connection_Params; //-------- ACI Functions ------------------------------------------ #ifdef __CPLUSPLUS__ #define EXTERN_C extern "C" #endif #define ACI_FUNC EXTERN_C __declspec(dllexport) UINT __stdcall ACI_FUNC ACI_Launch(ACI_Launch_Params * params); ACI_FUNC ACI_Exit(void); ACI_FUNC ACI_LoadConfigFile(ACI_Config_Params * params); ACI_FUNC ACI_SaveConfigFile(ACI_Config_Params * params); ACI_FUNC ACI_SetDevice(ACI_Device_Params * params); ACI_FUNC ACI_GetDevice(ACI_Device_Params * params); ACI_FUNC ACI_GetLayer(ACI_Layer_Params * params); ACI_FUNC ACI_CreateBuffer(ACI_Buffer_Params * params); ACI_FUNC ACI_ReallocBuffer(ACI_Buffer_Params * params); ACI_FUNC ACI_ReadLayer(ACI_Memory_Params * params); ACI_FUNC ACI_WriteLayer(ACI_Memory_Params * params); ACI_FUNC ACI_FillLayer(ACI_Memory_Params * params); ACI_FUNC ACI_GetProgrammingParams(ACI_Programming_Params * params); ACI_FUNC ACI_SetProgrammingParams(ACI_Programming_Params * params); ACI_FUNC ACI_GetProgOption(ACI_ProgOption_Params * params); ACI_FUNC ACI_SetProgOption(ACI_ProgOption_Params * params); ACI_FUNC ACI_AllProgOptionsDefault(void); ACI_FUNC ACI_ExecFunction(ACI_Function_Params * params); ACI_FUNC ACI_StartFunction(ACI_Function_Params * params); ACI_FUNC ACI_GangStart(ACI_GangStart_Params * params); ACI_FUNC ACI_GetStatus(ACI_PStatus_Params * params); ACI_FUNC ACI_TerminateFunction(void); ACI_FUNC ACI_FileLoad(ACI_File_Params * params); ACI_FUNC ACI_FileSave(ACI_File_Params * params); ACI_FUNC ACI_IDECommand(UINT command); ACI_FUNC ACI_SetConnection(ACI_Connection_Params * params); ACI_FUNC ACI_GetConnection(ACI_Connection_Params * params); #define ACI_SettingsDialog() ACI_IDECommand(20561) #define ACI_SelectDeviceDialog() ACI_IDECommand(21061) #define ACI_BuffersDialog() ACI_IDECommand(21855) #define ACI_LoadFileDialog() ACI_IDECommand(20554) #define ACI_SaveFileDialog() ACI_IDECommand(20553) #endif // __ACI_PROG_H__