base file
This commit is contained in:
46
北极星光OPENWRT/编程器软件/scripts/AT25D161_SecRegister.pas
Normal file
46
北极星光OPENWRT/编程器软件/scripts/AT25D161_SecRegister.pas
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
{$ READ_ID}
|
||||
begin
|
||||
ID_9F:= CreateByteArray(3);
|
||||
ID_90:= CreateByteArray(2);
|
||||
ID_AB:= CreateByteArray(2);
|
||||
ID_15:= CreateByteArray(2);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read ID');
|
||||
|
||||
// read ID to test installation
|
||||
SPIWrite (0, 1, $9F);
|
||||
SPIRead(1, 3, ID_9F);
|
||||
logprint('ID(9F): ' + inttohex((GetArrayItem(ID_9F, 0)),2)+ inttohex((GetArrayItem(ID_9F, 1)),2)+ inttohex((GetArrayItem(ID_9F, 2)),2));
|
||||
|
||||
SPIWrite (0, 4, $90, 0, 0, 0);
|
||||
SPIRead(1, 2, ID_90);
|
||||
logprint('ID(90): ' + inttohex((GetArrayItem(ID_90, 0)),2)+ inttohex((GetArrayItem(ID_90, 1)),2));
|
||||
|
||||
SPIWrite (0, 4, $AB, 0, 0, 0);
|
||||
SPIRead(1, 2, ID_AB);
|
||||
logprint('ID(AB): ' + inttohex((GetArrayItem(ID_AB, 0)),2)+ inttohex((GetArrayItem(ID_AB, 1)),2));
|
||||
|
||||
SPIWrite (0, 1, $15);
|
||||
SPIRead(1, 2, ID_15);
|
||||
logprint('ID(15): ' + inttohex((GetArrayItem(ID_15, 0)),2)+ inttohex((GetArrayItem(ID_15, 1)),2));
|
||||
|
||||
LogPrint ('End read ID ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_SECURITY_REGISTER}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read AT25DF161 security register ');
|
||||
RegSize :=128;
|
||||
// read register
|
||||
SPIWrite (0, 6, $77, $00, $00, $00, $00, $00);
|
||||
SPIReadToEditor (1, RegSize);
|
||||
|
||||
LogPrint ('End read AT25DF161');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
|
||||
|
||||
172
北极星光OPENWRT/编程器软件/scripts/AT45DB161E_SecurityFunc_test.pas
Normal file
172
北极星光OPENWRT/编程器软件/scripts/AT45DB161E_SecurityFunc_test.pas
Normal file
@@ -0,0 +1,172 @@
|
||||
|
||||
{$ READ_ID}
|
||||
begin
|
||||
ID_9F:= CreateByteArray(3);
|
||||
ID_90:= CreateByteArray(2);
|
||||
ID_AB:= CreateByteArray(2);
|
||||
ID_15:= CreateByteArray(2);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read ID');
|
||||
|
||||
// read ID to test installation
|
||||
SPIWrite (0, 1, $9F);
|
||||
SPIRead(1, 3, ID_9F);
|
||||
logprint('ID(9F): ' + inttohex((GetArrayItem(ID_9F, 0)),2)+ inttohex((GetArrayItem(ID_9F, 1)),2)+ inttohex((GetArrayItem(ID_9F, 2)),2));
|
||||
|
||||
SPIWrite (0, 4, $90, 0, 0, 0);
|
||||
SPIRead(1, 2, ID_90);
|
||||
logprint('ID(90): ' + inttohex((GetArrayItem(ID_90, 0)),2)+ inttohex((GetArrayItem(ID_90, 1)),2));
|
||||
|
||||
SPIWrite (0, 4, $AB, 0, 0, 0);
|
||||
SPIRead(1, 2, ID_AB);
|
||||
logprint('ID(AB): ' + inttohex((GetArrayItem(ID_AB, 0)),2)+ inttohex((GetArrayItem(ID_AB, 1)),2));
|
||||
|
||||
SPIWrite (0, 1, $15);
|
||||
SPIRead(1, 2, ID_15);
|
||||
logprint('ID(15): ' + inttohex((GetArrayItem(ID_15, 0)),2)+ inttohex((GetArrayItem(ID_15, 1)),2));
|
||||
|
||||
LogPrint ('End read ID ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
|
||||
{$ READ_BUFFER_1}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read AT45DB161E Buffer 1 ');
|
||||
//PageSize :=_IC_Page;
|
||||
PageSize := 1056;
|
||||
buff:= CreateByteArray(5);
|
||||
SetArrayItem(buff, 0, $D4); // read buffer 1 opcode
|
||||
SetArrayItem(buff, 1, 0);
|
||||
SetArrayItem(buff, 2, 0);
|
||||
SetArrayItem(buff, 3, 0);
|
||||
SetArrayItem(buff, 4, 0);
|
||||
SPIWrite (0, 5, buff);
|
||||
SPIReadToEditor (1, PageSize);
|
||||
|
||||
LogPrint ('End ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ WRITE_BUFFER_1}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start write AT45DB161E Buffer 1 ');
|
||||
//PageSize :=_IC_Page;
|
||||
PageSize := 1056;
|
||||
buff:= CreateByteArray(4);
|
||||
SetArrayItem(buff, 0, $84); // write buffer 1 opcode
|
||||
SetArrayItem(buff, 1, 0);
|
||||
SetArrayItem(buff, 2, 0);
|
||||
SetArrayItem(buff, 3, 0);
|
||||
SPIWrite (0, 4, buff);
|
||||
SPIWriteFromEditor (1, PageSize, 0);
|
||||
|
||||
LogPrint ('End ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
|
||||
{$ ENABLE_SECTOR_PROTECTION}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
SPIWrite (1, 4, $3D, $2A, $7F, $A9); //enable
|
||||
LogPrint ('Sector protection enabled');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ DISABLE_SECTOR_PROTECTION}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
SPIWrite (1, 4, $3D, $2A, $7F, $9A); //disable
|
||||
LogPrint ('Sector protection disabled');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_SECTOR_PROTECTION_REGISTER}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read AT45DB161E sector protection register ');
|
||||
RegSize :=16;
|
||||
// read register
|
||||
SPIWrite (0, 4, $32, $00, $00, $00);
|
||||
SPIReadToEditor (1, RegSize);
|
||||
|
||||
LogPrint ('End read AT45DB161E sector protection register ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ WRITE_SECTOR_PROTECTION_REGISTER}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start write AT45DB161E sector protection register ');
|
||||
RegSize :=16;
|
||||
sreg := 0;
|
||||
SPIWrite (1, 4, $3D, $2A, $7F, $CF); //erase
|
||||
repeat //Busy 45
|
||||
SPIWrite(0, 1, $D7);
|
||||
SPIRead(1, 1, sreg);
|
||||
// LogPrint ('busy, sreg=' + inttohex(sreg,2));
|
||||
until((sreg and $80) = $80);
|
||||
|
||||
SPIWrite (0, 4, $3D, $2A, $7F, $FC); //write
|
||||
SPIWriteFromEditor(1, RegSize, 0);
|
||||
repeat //Busy 45
|
||||
SPIWrite(0, 1, $D7);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and $80) = $80);
|
||||
|
||||
LogPrint ('End write AT45DB161E sector protection register ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_SECTOR_LOCKDOWN_REGISTER}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read AT45DB161E sector lockdown register ');
|
||||
RegSize :=16;
|
||||
// read register
|
||||
SPIWrite (0, 4, $35, $00, $00, $00);
|
||||
SPIReadToEditor (1, RegSize);
|
||||
|
||||
LogPrint ('End read AT45DB161E sector lockdown register ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_SECURITY_REGISTER}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read AT45DB161E security register ');
|
||||
LogPrint ('00..3F - One-Time User Programmable Area');
|
||||
LogPrint ('40..7F - Factory Programmed Area (S/N)');
|
||||
RegSize :=128;
|
||||
// read register
|
||||
SPIWrite (0, 4, $77, $00, $00, $00);
|
||||
SPIReadToEditor (1, RegSize);
|
||||
|
||||
LogPrint ('End read AT45DB161E security register ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ WRITE_SECURITY_REGISTER_OTP}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start write AT45DB161E security register (OTP)');
|
||||
LogPrint ('00..3F - One-Time User Programmable Area');
|
||||
RegSize :=64;
|
||||
repeat
|
||||
Confirm := InputBox('Are you really SHURE??? (YES/NO)','','NO');
|
||||
until (Confirm = 'YES') or (Confirm = 'NO');
|
||||
if (Confirm = 'YES') then
|
||||
begin
|
||||
SPIWrite (0, 4, $9B, $00, $00, $00); //write
|
||||
SPIWriteFromEditor(1, RegSize, 0);
|
||||
LogPrint ('OTP security register written!');
|
||||
end
|
||||
else LogPrint ('OTP security register not written, good choice!');
|
||||
|
||||
LogPrint ('End write AT45DB161E security register (OTP)');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
21
北极星光OPENWRT/编程器软件/scripts/GPR25L3203F_OTP.pas
Normal file
21
北极星光OPENWRT/编程器软件/scripts/GPR25L3203F_OTP.pas
Normal file
@@ -0,0 +1,21 @@
|
||||
{$读取OTP分区}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
|
||||
PageSize := 256;
|
||||
OTPsize := 4096;
|
||||
ProgressBar(0, (OTPsize / PageSize)-1, 0);
|
||||
|
||||
SPIWrite(1, 1, $B1); //enter secured OTP
|
||||
|
||||
for i:=0 to (OTPsize / PageSize)-1 do
|
||||
begin
|
||||
SPIWrite(0, 4, $03, 0,i,0);
|
||||
SPIReadToEditor(1, PageSize);
|
||||
ProgressBar(1);
|
||||
end;
|
||||
|
||||
ProgressBar(0, 0, 0);
|
||||
SPIWrite(1, 1, $C1); //exit secured OTP
|
||||
SPIExitProgMode();
|
||||
end
|
||||
46
北极星光OPENWRT/编程器软件/scripts/IS25LQ040_SafeGuardRegister.pas
Normal file
46
北极星光OPENWRT/编程器软件/scripts/IS25LQ040_SafeGuardRegister.pas
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
{$ READ_ID}
|
||||
begin
|
||||
ID_9F:= CreateByteArray(3);
|
||||
ID_90:= CreateByteArray(2);
|
||||
ID_AB:= CreateByteArray(2);
|
||||
ID_15:= CreateByteArray(2);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read ID');
|
||||
|
||||
// read ID to test installation
|
||||
SPIWrite (0, 1, $9F);
|
||||
SPIRead(1, 3, ID_9F);
|
||||
logprint('ID(9F): ' + inttohex((GetArrayItem(ID_9F, 0)),2)+ inttohex((GetArrayItem(ID_9F, 1)),2)+ inttohex((GetArrayItem(ID_9F, 2)),2));
|
||||
|
||||
SPIWrite (0, 4, $90, 0, 0, 0);
|
||||
SPIRead(1, 2, ID_90);
|
||||
logprint('ID(90): ' + inttohex((GetArrayItem(ID_90, 0)),2)+ inttohex((GetArrayItem(ID_90, 1)),2));
|
||||
|
||||
SPIWrite (0, 4, $AB, 0, 0, 0);
|
||||
SPIRead(1, 2, ID_AB);
|
||||
logprint('ID(AB): ' + inttohex((GetArrayItem(ID_AB, 0)),2)+ inttohex((GetArrayItem(ID_AB, 1)),2));
|
||||
|
||||
SPIWrite (0, 1, $15);
|
||||
SPIRead(1, 2, ID_15);
|
||||
logprint('ID(15): ' + inttohex((GetArrayItem(ID_15, 0)),2)+ inttohex((GetArrayItem(ID_15, 1)),2));
|
||||
|
||||
LogPrint ('End read ID ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_SECURITY_REGISTER}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read IS25LQ020/040 safe guard register ');
|
||||
RegSize :=16;
|
||||
// read register
|
||||
SPIWrite (0, 4, $2F, $00, $00, $00);
|
||||
SPIReadToEditor (1, RegSize);
|
||||
|
||||
LogPrint ('End read ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
|
||||
|
||||
91
北极星光OPENWRT/编程器软件/scripts/MX25L1605D_OTP.pas
Normal file
91
北极星光OPENWRT/编程器软件/scripts/MX25L1605D_OTP.pas
Normal file
@@ -0,0 +1,91 @@
|
||||
// designed for MACRONIX MX25L1605D
|
||||
// READ / WRITE 512-bit OTP PAGE, read and set OTP_LOCK bit
|
||||
// WRITE is really OTP operation, be careful, OTP page can not be erased.
|
||||
{$ READ_ID}
|
||||
begin
|
||||
ID_9F:= CreateByteArray(3);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read ID');
|
||||
// read ID
|
||||
SPIWrite (0, 1, $9F);
|
||||
SPIRead(1, 3, ID_9F);
|
||||
logprint('ID(9F): ' + inttohex((GetArrayItem(ID_9F, 0)),2)+ inttohex((GetArrayItem(ID_9F, 1)),2)+ inttohex((GetArrayItem(ID_9F, 2)),2));
|
||||
LogPrint ('End read ID ');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_OTP_LOCK_BIT}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
sreg :=0;
|
||||
SPIWrite (0, 1, $2B);
|
||||
SPIRead (1, 1, sreg);
|
||||
if (sreg and $01) then LogPrint ('Factory OTP LockBit = 1')
|
||||
else if (sreg and $02) then LogPrint ('Customer OTP LockBit = 1')
|
||||
else LogPrint ('OTP LockBit = 0');
|
||||
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_OTP_PAGE}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start READ 512-bit OTP page of MX25L1605D');
|
||||
RegSize :=64;
|
||||
SPIWrite (1, 1, $B1); //Enter OTP mode
|
||||
SPIWrite (0, 4, $03, $00, $00, $00);
|
||||
SPIReadToEditor (1, RegSize);
|
||||
SPIWrite (1, 1, $C1); //Exit OTP mode
|
||||
|
||||
LogPrint ('End read OTP page of MX25L1605D');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
|
||||
{$ WRITE_OTP_PAGE}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
RegSize :=64;
|
||||
sreg :=0;
|
||||
repeat // Write is really OTP, so also confirm
|
||||
Confirm := InputBox('Are you really SHURE??? (YES/NO)','','NO');
|
||||
until (Confirm = 'YES') or (Confirm = 'NO');
|
||||
if (Confirm = 'YES') then
|
||||
begin
|
||||
LogPrint ('Start WRITE 512-bit OTP page of MX25L1605D');
|
||||
SPIWrite (1, 1, $B1); // Enter OTP mode
|
||||
SPIWrite (0, 1, $2B);
|
||||
SPIRead (1, 1, sreg);
|
||||
if (sreg and $03) then LogPrint ('OTP LockBit = 1, write not possible anymore!')
|
||||
else for i:=0 to RegSize-1 do
|
||||
begin
|
||||
SPIWrite (1, 1, $06); // write enable
|
||||
SPIWrite (0, 4, $02, $00, $00, i); // write byte-by-byte only!
|
||||
SPIWriteFromEditor(1, 1, i);
|
||||
repeat //Busy
|
||||
SPIWrite(0, 1, $05);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and 1) <> 1);
|
||||
end;
|
||||
SPIWrite (1, 1, $C1); //Exit OTP mode
|
||||
LogPrint ('End write OTP page of MX25L1605D');
|
||||
end;
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ SET_OTP_LOCK_BIT}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
sreg :=0;
|
||||
repeat
|
||||
Confirm := InputBox('Are you really SURE??? (YES/NO)','','NO');
|
||||
until (Confirm = 'YES') or (Confirm = 'NO');
|
||||
if (Confirm = 'YES') then
|
||||
begin
|
||||
SPIWrite (1, 1, $2F); // write secure reg (customer lock)
|
||||
LogPrint ('Customer OTP LockBit written!');
|
||||
end
|
||||
else LogPrint ('OTP LockBit not written, good choice!');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
34
北极星光OPENWRT/编程器软件/scripts/NOR_READ_ID.pas
Normal file
34
北极星光OPENWRT/编程器软件/scripts/NOR_READ_ID.pas
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
{$ READ_ID}
|
||||
begin
|
||||
ID_9F:= CreateByteArray(3);
|
||||
ID_90:= CreateByteArray(2);
|
||||
ID_AB:= CreateByteArray(2);
|
||||
ID_15:= CreateByteArray(4);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read ID');
|
||||
|
||||
// read ID
|
||||
SPIWrite (0, 1, $9F);
|
||||
SPIRead(1, 3, ID_9F);
|
||||
logprint('ID(9F): ' + inttohex((GetArrayItem(ID_9F, 0)),2)+ inttohex((GetArrayItem(ID_9F, 1)),2)+ inttohex((GetArrayItem(ID_9F, 2)),2));
|
||||
|
||||
SPIWrite (0, 4, $90, 0, 0, 0);
|
||||
SPIRead(1, 2, ID_90);
|
||||
logprint('ID(90): ' + inttohex((GetArrayItem(ID_90, 0)),2)+ inttohex((GetArrayItem(ID_90, 1)),2));
|
||||
|
||||
SPIWrite (0, 4, $AB, 0, 0, 0);
|
||||
SPIRead(1, 2, ID_AB);
|
||||
logprint('ID(AB): ' + inttohex((GetArrayItem(ID_AB, 0)),2)+ inttohex((GetArrayItem(ID_AB, 1)),2));
|
||||
|
||||
SPIWrite (0, 1, $15);
|
||||
SPIRead(1, 4, ID_15);
|
||||
if GetArrayItem(ID_15, 0) = $7F then
|
||||
logprint('ID(15): ' + inttohex((GetArrayItem(ID_15, 0)),2) + inttohex((GetArrayItem(ID_15, 1)),2)
|
||||
+ inttohex((GetArrayItem(ID_15, 2)),2) + inttohex((GetArrayItem(ID_15, 3)),2))
|
||||
else
|
||||
logprint('ID(15): ' + inttohex((GetArrayItem(ID_15, 0)),2)+ inttohex((GetArrayItem(ID_15, 1)),2));
|
||||
|
||||
LogPrint ('End read ID');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
456
北极星光OPENWRT/编程器软件/scripts/README.TXT
Normal file
456
北极星光OPENWRT/编程器软件/scripts/README.TXT
Normal file
@@ -0,0 +1,456 @@
|
||||
|
||||
1. Description
|
||||
-------------------
|
||||
|
||||
The module PASCALC.DCU is the Pascal-like language interpreter for Delphi.
|
||||
The basic differences from standard Pascal the following:
|
||||
|
||||
- All variables stored as variants.
|
||||
|
||||
- It's no need to declare variables, labels and functions. PASCALC creates
|
||||
variables dynamically on first assignment. Variable type depends on the
|
||||
last value assigned, type checking is not carried out.
|
||||
|
||||
- Expressions syntax:
|
||||
|
||||
Arithmetic operators: +, -, *, /, ^ (power), SHL, SHR
|
||||
Bitwise operators: BITOR,BITAND,BITXOR,BITNOT
|
||||
Logical operators: >, <, >=, <=, =, <>, AND, OR, NOT,
|
||||
constants TRUE and FALSE.
|
||||
Operators precedence standard, you can use parentheses.
|
||||
|
||||
|
||||
- Statements supported:
|
||||
BEGIN... END
|
||||
IF... THEN... ELSE
|
||||
CASE
|
||||
FOR... TO/DOWNTO... DO
|
||||
WHILE... DO
|
||||
REPEAT... UNTIL
|
||||
BREAK
|
||||
CONTINUE
|
||||
GOTO
|
||||
EXIT
|
||||
USES
|
||||
INCLUDE
|
||||
|
||||
- All reserved words are declared in interface section as string array.
|
||||
You can change them to anyone others. All identifiers should be different
|
||||
(except assignment and equation, they may be the same).
|
||||
|
||||
- Multi-dimensional arrays supported. Array items are variables whose names
|
||||
consist from array name and indexes (in brackets). Array items properties
|
||||
same as the simple variables. It's no need to declare arrays. Array index
|
||||
continuity is not requred. It's possible to access string as char array.
|
||||
You can assign chars or numbers in range 0..255 to string characters.
|
||||
Array name should be unique, simple variable MyArr and array item MyArr[1]
|
||||
can't exist at the same time. This rule allows to distinguish access to
|
||||
1-st character of string variable MyArr (MyArr[1]) from the accees to
|
||||
the first item of array MyArr. To access character of string array item,
|
||||
character index should be written in brackets after item name, for example
|
||||
MyArr[1,2][3].
|
||||
|
||||
- All build-in functions are user-defined. Module pasfunc.pas contain
|
||||
example of PASCALC implementations for common Delphi functions. You can use
|
||||
this functions and write your own implementations for necessary functions.
|
||||
There is no need to declare parameters for user-defined functions, therefore
|
||||
it's types and amount are not limited. If necessary you can provide type
|
||||
checking inside function code. Interpreter calculates all parameter values
|
||||
and creates temporary values list (TVarList). Names of var-parameters in this
|
||||
list are 'VAR', otherwise 'VALUE'. After function call interpreter updates
|
||||
values for var-parameters. Function result type not checked, one function can
|
||||
return number as well as string. Functions can be called as procedures (without
|
||||
result usage).
|
||||
|
||||
- Procedures and functions (in sense of the subroutines on interpreter language)
|
||||
are supported. The function heading specifies only names of formal parameters,
|
||||
without parameters types and pass method (var or value). Also, function's result
|
||||
types are not declared. To return function result you should assign value to
|
||||
variable "result".
|
||||
|
||||
If actual parameter is variable (not expression), it considered as var-parameter.
|
||||
In this case assigning new value to this parameter inside procedure or function
|
||||
will affect the actual parameter variable.
|
||||
|
||||
At the same time, all interpreter global variables inside a function or procedures
|
||||
looks like local variables, with the same initial values as global ones.
|
||||
You can change this values inside procedures (functions), but it's don't affect
|
||||
the global variables. All new variables created inside procedures and functions
|
||||
are local, and will be destroyed after exiting.
|
||||
Therefore, it is possible to use any names for local variables, without conflicts
|
||||
with the global variables.
|
||||
|
||||
For libraries implementation, it is possible to use operators USES and INCLUDE.
|
||||
|
||||
Syntax: USES 'filename';
|
||||
INCLUDE 'filename';
|
||||
|
||||
INCLIDE and USES are parsed by pre-processor before script execution.
|
||||
INCLUDE inserts text from file 'filename' into the script, USES loads
|
||||
procedures and functions declarations.
|
||||
|
||||
|
||||
2. License
|
||||
----------
|
||||
|
||||
This software is provided as it is, without any kind of warranty given.
|
||||
The author can not be held responsible for any kind of damage, problems etc,
|
||||
arised from using this software. PASCALC interpreter is shareware product.
|
||||
Unregistered version has no time or functionality limitations, but can
|
||||
show info screen.
|
||||
|
||||
If you want get source code, you should register PASCALC and get registration code.
|
||||
Use your registration code as password for source archive (Source\pascsrc.zip).
|
||||
|
||||
Address for online registration (price $20):
|
||||
https://www.regnow.com/softsell/nph-softsell.cgi?item=2608-2
|
||||
|
||||
You can modify PASCALC source code as you need, distribute executable files
|
||||
compiled with PASCALC source. But you can't distribute original or modified
|
||||
PASCALC source code, .DCU units or libraries based on PASCALC source code.
|
||||
|
||||
|
||||
3. PASCALC inteface
|
||||
-------------------
|
||||
|
||||
|
||||
unit pascalc;
|
||||
|
||||
{$F+,B-,R-}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Math;
|
||||
|
||||
type TToken =
|
||||
(tEMPTY, tVR, tCON, tTRUE, tFALSE,
|
||||
tEQU, tOR, tAND, tNOT, tXOR,
|
||||
tCOMMA, tLBL, tNEQ, tGT, tLS,
|
||||
tGTE, tLSE, tADD, tSUB, tMUL,
|
||||
tDIV, tPWR, tLBR, tRBR, tLARR,
|
||||
tRARR, tSEMI, tREM, tREMB, tREME,
|
||||
tASSIGN, tBEGIN, tEND, tIF, tTHEN,
|
||||
tELSE, tFOR, tTO, tDOWNTO, tDO,
|
||||
tWHILE, tREPEAT, tUNTIL, tBREAK, tCONTINUE,
|
||||
tEXIT, tGOTO, tSHL, tSHR, tPROC,
|
||||
tFUNCT, tUSES, tINCLUDE, tCASE, tOF,
|
||||
tCOMMA2);
|
||||
|
||||
type TTokenSet = set of TToken;
|
||||
|
||||
const
|
||||
ResWords : array[TToken] of string[10] =
|
||||
('', '', '', 'TRUE', 'FALSE',
|
||||
'=', 'OR', 'AND', 'NOT', 'XOR',
|
||||
',', ':', '<>', '>', '<',
|
||||
'>=', '<=', '+', '-', '*',
|
||||
'/', '^', '(', ')', '[',
|
||||
']', ';', '//', '{', '}',
|
||||
':=', 'BEGIN', 'END', 'IF', 'THEN',
|
||||
'ELSE', 'FOR', 'TO', 'DOWNTO', 'DO',
|
||||
'WHILE', 'REPEAT', 'UNTIL', 'BREAK', 'CONTINUE',
|
||||
'EXIT', 'GOTO', 'SHL', 'SHR', 'PROCEDURE',
|
||||
'FUNCTION', 'USES', 'INCLUDE', 'CASE', 'OF',
|
||||
'..');
|
||||
|
||||
const
|
||||
Alpha : set of char = ['_','0'..'9','a'..'z','A'..'Z','à'..'ÿ','¸','À'..'ß','¨'];
|
||||
StrDelimiter : char = '''';
|
||||
DecimalPoint : char = '.';
|
||||
TokenDelimiter : char = #127;
|
||||
|
||||
|
||||
type TVar = record
|
||||
Name : string;
|
||||
Value : variant;
|
||||
end;
|
||||
|
||||
type TPVar = ^TVar;
|
||||
|
||||
type TVarList = class (TList)
|
||||
destructor Destroy; override;
|
||||
procedure ClearAll;
|
||||
function AddVar(V:TVar) : boolean;
|
||||
function AddValue(N:string; V:variant) : boolean;
|
||||
function VarExist(N:string):boolean;
|
||||
function VarIndex(N:string):integer;
|
||||
function VarByName(N:string;var V:TVar) : boolean;
|
||||
function SetVar(V:TVar) : boolean;
|
||||
function SetValue(N:string; V:variant) : boolean;
|
||||
procedure CopyTo(VL:TVarList);
|
||||
end;
|
||||
|
||||
type TPVarList = ^TVarList;
|
||||
|
||||
type PProcessProc = procedure;
|
||||
|
||||
type PFunction = function(Sender:TObject; var A:TVarList; var R:TVar) : boolean;
|
||||
|
||||
type TFunc = record
|
||||
Name : string;
|
||||
Func : Pointer;
|
||||
end;
|
||||
|
||||
type TPFunc = ^TFunc;
|
||||
|
||||
type TFuncList = class (TList)
|
||||
destructor Destroy; override;
|
||||
procedure ClearAll;
|
||||
function AddFunction(N:string; F:Pointer) : boolean;
|
||||
end;
|
||||
|
||||
type TProcedure = record
|
||||
Name : string;
|
||||
Body : string;
|
||||
Params : string;
|
||||
Result : boolean;
|
||||
end;
|
||||
|
||||
type TPProcedure = ^TProcedure;
|
||||
|
||||
type TProcList = class(TList)
|
||||
destructor Destroy; override;
|
||||
procedure ClearAll;
|
||||
function AddProc(Proc:TProcedure):boolean;
|
||||
function ProcIndex(Name:string):integer;
|
||||
function ProcByName(Name:string; var Proc:TProcedure):boolean;
|
||||
end;
|
||||
|
||||
|
||||
type TPasCalc = class
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure ClearVars;
|
||||
function VarCount : integer;
|
||||
function VarIndex(N:string) : integer;
|
||||
function VarByName(N:string; var V:TVar) : boolean;
|
||||
function VarByIndex(I:integer; var V:TVar) : boolean;
|
||||
function SetVar(V:TVar) : boolean;
|
||||
function SetValue(N:string; V:variant):boolean;
|
||||
procedure ClearFuncs;
|
||||
function SetFunction(N:string; F:Pointer) : boolean;
|
||||
procedure SetProcessProc(P:Pointer);
|
||||
function Parse(S:string) : string;
|
||||
function Calculate(S:string; var R:TVar) : boolean;
|
||||
function Execute(S:string):boolean;
|
||||
private
|
||||
Expr : string;
|
||||
ExprIndex : integer;
|
||||
Token : string;
|
||||
TokenCode : TToken;
|
||||
|
||||
BlockLevel : integer;
|
||||
BlockCmd : TToken;
|
||||
GotoLabel : string;
|
||||
|
||||
VarList : TVarList;
|
||||
FuncList : TFuncList;
|
||||
ProcList : TProcList;
|
||||
|
||||
ProcessProc : PProcessProc;
|
||||
|
||||
LastString : string;
|
||||
LastParsed : string;
|
||||
|
||||
procedure Clear;
|
||||
procedure Process;
|
||||
procedure Error(Msg,Line:string; Code:integer);
|
||||
procedure Level1(var R:TVar);
|
||||
procedure Level2(var R:TVar);
|
||||
procedure Level3(var R:TVar);
|
||||
procedure Level4(var R:TVar);
|
||||
procedure Level5(var R:TVar);
|
||||
procedure Level6(var R:TVar);
|
||||
procedure Level7(var R:TVar);
|
||||
procedure Level8(var R:TVar);
|
||||
procedure Arith(o : TToken; var R,H:TVar);
|
||||
procedure Unary(o : TToken; var R:TVar);
|
||||
function GetIndex(S:string; var Index:integer; var T:TToken) : string;
|
||||
function GetFuncParams(S:string; var Index:integer) : string;
|
||||
function FindFunc(N:string) : integer;
|
||||
function FindArray(N:string) : boolean;
|
||||
procedure SetVarDirect(var R:TVar);
|
||||
function CallFunc(N:string; A:string; var V:TVar) : boolean;
|
||||
function CallProc(N:string; A:string; var V:TVar) : boolean;
|
||||
function GetTextToken(S: string; var Index : integer; var Code : TToken) : string;
|
||||
function TokenStr(T:TToken;S:string) : string;
|
||||
function GetToken(S:string; var Index : integer; var Code : TToken) : string;
|
||||
function GetTokenCode(S: string; var Index:integer; var Code:TToken) : integer;
|
||||
function GetTokenLine(S:string; var Index:integer; var Code:TToken;
|
||||
StopToken:TTokenSet) : string;
|
||||
function NextToken(S:string; Index:integer) : TToken;
|
||||
function GetOperator(Txt:string; var Index : integer; EndToken:TTokenSet) : string;
|
||||
function ParseOperator(Txt:string; var Cmd,Line,Lbl : string) : TToken;
|
||||
function DelRemarks(S:string) : string;
|
||||
function UnParse(S:string; Show:boolean) : string;
|
||||
function PreProcess(Txt:string):string;
|
||||
function Calc(S:string; var R:TVar) : boolean;
|
||||
procedure Exec(Txt:string);
|
||||
procedure DoSet(CmdLine,Cmd,Line:string);
|
||||
procedure DoIf(CmdLine,Line:string);
|
||||
procedure DoBegin(CmdLine,Line:string);
|
||||
procedure DoFor(CmdLine,Line:string);
|
||||
procedure DoBreak(CmdLine,Line:string);
|
||||
procedure DoContinue(CmdLine,Line:string);
|
||||
procedure DoExit(CmdLine,Line:string);
|
||||
procedure DoWhile(CmdLine,Line:string);
|
||||
procedure DoRepeat(CmdLine,Line:string);
|
||||
procedure DoGoto(CmdLine,Line:string);
|
||||
procedure DoCase(CmdLine,Line:string);
|
||||
public
|
||||
Stop : boolean;
|
||||
ErrCode : integer;
|
||||
ErrMsg : string;
|
||||
ErrLine : string;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
4. Functions (unit PASFUNC.PAS)
|
||||
------------------------------
|
||||
|
||||
// String functions
|
||||
|
||||
Val
|
||||
IntToStr
|
||||
StrToInt
|
||||
FloatToStr
|
||||
StrToFloat
|
||||
Copy
|
||||
Pos
|
||||
Length
|
||||
Insert
|
||||
Delete
|
||||
Trim
|
||||
TrimLeft
|
||||
TrimRight
|
||||
UpperCase
|
||||
LowerCase
|
||||
Format
|
||||
|
||||
// DateTime functions
|
||||
|
||||
Now
|
||||
Date
|
||||
Time
|
||||
DateToStr
|
||||
StrToDate
|
||||
TimeToStr
|
||||
StrToTime
|
||||
FormatDateTime
|
||||
DayOfWeek
|
||||
IncMonth
|
||||
DecodeDate
|
||||
DecodeTime
|
||||
EncodeDate
|
||||
EncodeTime
|
||||
YearDays
|
||||
YearFrac
|
||||
|
||||
// Math functions
|
||||
Abs
|
||||
Int
|
||||
Frac
|
||||
Round
|
||||
Ceil
|
||||
Floor
|
||||
Trunc
|
||||
Sin
|
||||
Cos
|
||||
Tan
|
||||
ArcSin
|
||||
ArcCos
|
||||
ArcTan
|
||||
Exp
|
||||
Ln
|
||||
IntPower
|
||||
Sqr
|
||||
Sqrt
|
||||
Min
|
||||
Max
|
||||
Inc
|
||||
Dec
|
||||
|
||||
// Variable handling functions.
|
||||
// Allows get or set variable value by calculated variable name.
|
||||
|
||||
SetVar
|
||||
GetVar
|
||||
|
||||
// Misc functions
|
||||
|
||||
Decode (simular with the Oracle Decode function)
|
||||
|
||||
|
||||
5. Interpreter usage
|
||||
--------------------
|
||||
|
||||
See usage example in demo program (demo.dpr). At first you should write
|
||||
user-defined functions you want to use in scripts and expressions. Function
|
||||
should set result value (field Value of variable R:TVar) and return true.
|
||||
On errors (wrong parameters, etc) function should return false. In your
|
||||
program you should create an instance of TPasCalc class.
|
||||
Then associate functions with names (TPasCalc.SetFunction).
|
||||
To register pasfunc.pas function library, call SetFunctions.
|
||||
You can set predefined variables (TPasCalc.SetVarNum or TPasCalc.SetVarStr).
|
||||
Method TPasCalc.Calculate evaluates expression and returns result in variable
|
||||
R:TVar. Method TPasCalc.Execute executes script and fills variable list.
|
||||
You can access variables using TPasCalc.VarCount, TPasCalc.VarByIndex or
|
||||
TPasCalc.VarByName methods. TPasCalc.ErrCode, TPasCalc.ErrMsg and
|
||||
TPasCalc.ErrLine indicates last error code, error message and line that
|
||||
raises error. Variable list not cleared in Calculate and Execute methods.
|
||||
You can reset all variables using TPasCalc.ClearVars. TPasCalc.ClearFuncs
|
||||
resets function list. Method TPasCalc.SetProcessProc sets pointer to
|
||||
user-defined callback procedure. Interpreter calls this procedure in internal
|
||||
cycles. In this procedure you can check some condition (timeout for example)
|
||||
and break execution by assigning TPasCalc.Stop:=TRUE. It is useful to call
|
||||
Application.ProcessMessages in this procedure. If callback procedure not
|
||||
assigned, interpreter uses Process method instead. Process method performs
|
||||
only messages processing.
|
||||
To improve perfomance you can prepare script using Parse method, and then
|
||||
execute previously prepared script.
|
||||
|
||||
|
||||
6. Error codes
|
||||
--------------
|
||||
|
||||
0 - O.K.
|
||||
1 - Error in expression
|
||||
2 - Unpaired parentheses
|
||||
3 - Variable not found
|
||||
4 - Invalid variable/function/procedure name
|
||||
5 - Invalid typecast
|
||||
6 - Invalid string constant
|
||||
7 - Incorrect function call
|
||||
8 - Function not found
|
||||
9 - Invalid operator
|
||||
10 - END expected
|
||||
11 - Too many END
|
||||
12 - TO or DOWNTO expected
|
||||
13 - FOR-loop variable expected
|
||||
14 - DO expected
|
||||
15 - BREAK outside a loop
|
||||
16 - UNTIL expected
|
||||
17 - Too many UNTIL
|
||||
18 - Label not found
|
||||
19 - Index out of range
|
||||
20 - Value out of range
|
||||
21 - ']' expected
|
||||
22 - Too many '['
|
||||
23 - Division by zero
|
||||
24 - Variable or array name duplicated
|
||||
25 - File îpen error
|
||||
26 - Function must return result
|
||||
27 - CASE without OF
|
||||
28 - Too many ELSE in CASE statement
|
||||
29 - Case range expected
|
||||
|
||||
|
||||
7. Author
|
||||
---------
|
||||
|
||||
Alex Boiko
|
||||
alexboiko@mtu-net.ru
|
||||
http://alexboiko.da.ru
|
||||
http://alexboiko.chat.ru
|
||||
463
北极星光OPENWRT/编程器软件/scripts/README_RU.TXT
Normal file
463
北极星光OPENWRT/编程器软件/scripts/README_RU.TXT
Normal file
@@ -0,0 +1,463 @@
|
||||
1. Описание
|
||||
-----------
|
||||
|
||||
Модуль pascalc.dcu представляет собой интерпретатор Pascal - подобного
|
||||
языка для Delphi. Основные отличия его от стандартного Паскаля следующие:
|
||||
|
||||
- Для значений переменных используеися тип Variant, что позволяет хранить
|
||||
разнообразные типы данных.
|
||||
|
||||
- Переменные обьявлять не надо, они при небходимости создаются динамически
|
||||
при присваивании им значений. Тип определяется по последнему присвоенному
|
||||
значению, типовый контроль при присваивании не выполняется. То есть если
|
||||
существующей числовой переменной присвоить строку, ее тип изменится.
|
||||
Символам строки можно присваивать числовые значения в диапазоне 0..255 или
|
||||
символы (строки длиной 1).
|
||||
|
||||
- В выражениях поддерживаются следующие операции:
|
||||
арифметические: +, -, *, /, ^ (возведение в степень), SHL, SHR
|
||||
операции с битами: BITOR,BITAND,BITXOR,BITNOT
|
||||
логические: >, <, >=, <=, =, <>, AND, OR, NOT, константы TRUE и FALSE.
|
||||
Tакже можно использовать скобки. Порядок выполненния операций стандартный.
|
||||
|
||||
- В интерпретаторе поддерживаются операторы:
|
||||
BEGIN ... END
|
||||
IF ... THEN ... ELSE
|
||||
CASE
|
||||
FOR ... TO/DOWNTO ... DO
|
||||
WHILE ... DO
|
||||
REPEAT ... UNTIL
|
||||
CONTINUE
|
||||
BREAK
|
||||
GOTO
|
||||
EXIT
|
||||
USES
|
||||
INCLUDE
|
||||
|
||||
- Все зарезервированные слова объявлены в interface как массив строк.
|
||||
При желании вы можете изменить их на любые другие, например сделать
|
||||
русскими. Допускаются одинаковые операторы присваивания и равенства.
|
||||
Интерпретатор может сам различать их в зависимости от контекста. Все
|
||||
остальные зарезервированные слова должны отличаться друг от друга.
|
||||
|
||||
- Поддерживаются многомерные массивы, которые хранятся как набор переменных.
|
||||
Имена таких переменных состоят из имени массива и индексов в квадратных
|
||||
скобках. Имя массива должно быть уникальным, не допускается одновременное
|
||||
существование обычной переменной и переменной массива с тем же именем.
|
||||
(например переменная с именем MyArr и элемент массива MyArr[1]).
|
||||
Так как элементы массивов хранятся как обычные переменные, на них
|
||||
распространяются все правила применимые к обычным переменнм. Массивы не надо
|
||||
обьявлять, элементы одного массива могут хранить как строки так и числа.
|
||||
Для диапазона индексов массивов нет никаких ограничений. Непрерывность
|
||||
элементов массива также не обязательна. Чтобы создать непрерывную
|
||||
последовательность элементов массива им надо просто присвоить (например в цикле)
|
||||
какие - либо значения. Кроме того, к символам строк можно обращаться как к
|
||||
массиву символов. Так например MyArr[1][2] значит обрашение ко 2-му символу
|
||||
1-й строки массива MyArr. Запись MyArr[1] может значить либо первый символ
|
||||
обычной строковой переменной MyArr, либо первый элемент массива. Но так как
|
||||
элемент массива и переменная с таким же именем одновременно существовать не могут,
|
||||
неоднозначность не возникает.
|
||||
|
||||
- Все встроенные функции интерпретатора user-defined. Mодуль pasfunc.pas содержит
|
||||
библиотеку в которую включены аналоги многих функций Delphi. Пример ее
|
||||
использования есть в demo-программе. Вы можете использовать эту библиотеку,
|
||||
дополнив при необходимости любым количеством своих функций снужными вам
|
||||
параметрами. Параметры функций заранее не описываются, поэтому их количество
|
||||
и типы ничем не ограничены (подобно процедуре write паскаля). Интерпретатор
|
||||
вычисляет все параметры конкретного вызова и передает их функции как список
|
||||
значений. При необходимости вы можете реализовать типовый контроль внутри
|
||||
своей реализации функции. Если в качестве параметра функции передается
|
||||
переменная интерпретатора, этот пареметр считается VAR-параметром, и его
|
||||
изменение в коде функции вызовет изменение значения соответствующей переменной
|
||||
интерпретатора. Тип возвращаемого функцией значения тоже может быть разным при
|
||||
разных параметрах вызова. В модуле pasfunc.pas есть пример реализации таких
|
||||
функций (ф-ции Max, Min). Функции можно вызывать как процедуры, не используя
|
||||
возвращаемое значение.
|
||||
|
||||
- Поддерживаются процедуры и функции на языке интерпретатора. В списке параметров
|
||||
процедур и функций необходимо только перечислить имена формальных параметров.
|
||||
Типы параметров и способ передачи указывать не надо, также в объявлении функций
|
||||
не надо указывать тип возвращаемого значения. Для возврата значения функции
|
||||
используется переменная "result". Если в качестве параметра функции или процедуры
|
||||
передается глобальная переменная интерпретатора, этот параметр для данного вызова
|
||||
считается VAR-параметром и его изменение внутри функции изменит значение
|
||||
глобальной переменной. В то же время все глобальные переменные интерпретатора
|
||||
внутри функции или процедуры ведут себя, как локальные переменные, которым
|
||||
присвоены начальные значения совпадающие со значениями одноименных глобальных
|
||||
переменных. Их значения доступны в процедурах и функциях, их можно изменить,
|
||||
но после выхода из процедуры или функции значение глобальной переменной не
|
||||
изменится. Все новые переменные, созданные внутри процедур и функций являются
|
||||
локальными, и после выхода из процедуры/функции исчезнут. Таким образом, в
|
||||
процедурах и функциях можно использовать любые имена для локальных переменных,
|
||||
не опасаясь что они совпадут с именами глобальных переменных.
|
||||
|
||||
Для реализации библиотек процедур можно использовать операторы USES и INCLUDE.
|
||||
Их синтаксис : USES 'имя файла';
|
||||
INCLUDE 'имя файла';
|
||||
|
||||
Операторы USES и INCLUDE обрабатываются препроцессором, до начала выполнения
|
||||
скрипта. Оператор INCLUDE вставляет в скрипт текст из файла. Оператор USES
|
||||
только загружает реализации процедур и функций, чтобы их можно было
|
||||
использовать при выполнении скрипта.
|
||||
|
||||
|
||||
2. Лицензия.
|
||||
------------
|
||||
|
||||
Интерпретатор PASCALC распространяется по принципу "как есть".
|
||||
При этом не предусматривается никаких гарантий, явных или подразумеваемых.
|
||||
Вы используете его на свой собственный риск. Автор не отвечает за потери
|
||||
данных, повреждения, потери прибыли или любые другие виды потерь, связанные
|
||||
с использованием (правильным или неправильным) этого программного продукта.
|
||||
|
||||
http://alexboiko.da.ru
|
||||
http://alexboiko.chat.ru
|
||||
|
||||
|
||||
3. Интерфейс модуля интерпретатора:
|
||||
-----------------------------------
|
||||
|
||||
unit pascalc;
|
||||
|
||||
{$F+,B-,R-}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Math;
|
||||
|
||||
type TToken =
|
||||
(tEMPTY, tVR, tCON, tTRUE, tFALSE,
|
||||
tEQU, tOR, tAND, tNOT, tXOR,
|
||||
tCOMMA, tLBL, tNEQ, tGT, tLS,
|
||||
tGTE, tLSE, tADD, tSUB, tMUL,
|
||||
tDIV, tPWR, tLBR, tRBR, tLARR,
|
||||
tRARR, tSEMI, tREM, tREMB, tREME,
|
||||
tASSIGN, tBEGIN, tEND, tIF, tTHEN,
|
||||
tELSE, tFOR, tTO, tDOWNTO, tDO,
|
||||
tWHILE, tREPEAT, tUNTIL, tBREAK, tCONTINUE,
|
||||
tEXIT, tGOTO, tSHL, tSHR, tPROC,
|
||||
tFUNCT, tUSES, tINCLUDE, tCASE, tOF,
|
||||
tCOMMA2);
|
||||
|
||||
type TTokenSet = set of TToken;
|
||||
|
||||
const
|
||||
ResWords : array[TToken] of string[10] =
|
||||
('', '', '', 'TRUE', 'FALSE',
|
||||
'=', 'OR', 'AND', 'NOT', 'XOR',
|
||||
',', ':', '<>', '>', '<',
|
||||
'>=', '<=', '+', '-', '*',
|
||||
'/', '^', '(', ')', '[',
|
||||
']', ';', '//', '{', '}',
|
||||
':=', 'BEGIN', 'END', 'IF', 'THEN',
|
||||
'ELSE', 'FOR', 'TO', 'DOWNTO', 'DO',
|
||||
'WHILE', 'REPEAT', 'UNTIL', 'BREAK', 'CONTINUE',
|
||||
'EXIT', 'GOTO', 'SHL', 'SHR', 'PROCEDURE',
|
||||
'FUNCTION', 'USES', 'INCLUDE', 'CASE', 'OF',
|
||||
'..');
|
||||
|
||||
const
|
||||
Alpha : set of char = ['_','0'..'9','a'..'z','A'..'Z','а'..'я','ё','А'..'Я','Ё'];
|
||||
StrDelimiter : char = '''';
|
||||
DecimalPoint : char = '.';
|
||||
TokenDelimiter : char = #127;
|
||||
|
||||
|
||||
type TVar = record
|
||||
Name : string;
|
||||
Value : variant;
|
||||
end;
|
||||
|
||||
type TPVar = ^TVar;
|
||||
|
||||
type TVarList = class (TList)
|
||||
destructor Destroy; override;
|
||||
procedure ClearAll;
|
||||
function AddVar(V:TVar) : boolean;
|
||||
function AddValue(N:string; V:variant) : boolean;
|
||||
function VarExist(N:string):boolean;
|
||||
function VarIndex(N:string):integer;
|
||||
function VarByName(N:string;var V:TVar) : boolean;
|
||||
function SetVar(V:TVar) : boolean;
|
||||
function SetValue(N:string; V:variant) : boolean;
|
||||
procedure CopyTo(VL:TVarList);
|
||||
end;
|
||||
|
||||
type TPVarList = ^TVarList;
|
||||
|
||||
type PProcessProc = procedure;
|
||||
|
||||
type PFunction = function(Sender:TObject; var A:TVarList; var R:TVar) : boolean;
|
||||
|
||||
type TFunc = record
|
||||
Name : string;
|
||||
Func : Pointer;
|
||||
end;
|
||||
|
||||
type TPFunc = ^TFunc;
|
||||
|
||||
type TFuncList = class (TList)
|
||||
destructor Destroy; override;
|
||||
procedure ClearAll;
|
||||
function AddFunction(N:string; F:Pointer) : boolean;
|
||||
end;
|
||||
|
||||
type TProcedure = record
|
||||
Name : string;
|
||||
Body : string;
|
||||
Params : string;
|
||||
Result : boolean;
|
||||
end;
|
||||
|
||||
type TPProcedure = ^TProcedure;
|
||||
|
||||
type TProcList = class(TList)
|
||||
destructor Destroy; override;
|
||||
procedure ClearAll;
|
||||
function AddProc(Proc:TProcedure):boolean;
|
||||
function ProcIndex(Name:string):integer;
|
||||
function ProcByName(Name:string; var Proc:TProcedure):boolean;
|
||||
end;
|
||||
|
||||
|
||||
type TPasCalc = class
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure ClearVars;
|
||||
function VarCount : integer;
|
||||
function VarIndex(N:string) : integer;
|
||||
function VarByName(N:string; var V:TVar) : boolean;
|
||||
function VarByIndex(I:integer; var V:TVar) : boolean;
|
||||
function SetVar(V:TVar) : boolean;
|
||||
function SetValue(N:string; V:variant):boolean;
|
||||
procedure ClearFuncs;
|
||||
function SetFunction(N:string; F:Pointer) : boolean;
|
||||
procedure SetProcessProc(P:Pointer);
|
||||
function Parse(S:string) : string;
|
||||
function Calculate(S:string; var R:TVar) : boolean;
|
||||
function Execute(S:string):boolean;
|
||||
private
|
||||
Expr : string;
|
||||
ExprIndex : integer;
|
||||
Token : string;
|
||||
TokenCode : TToken;
|
||||
|
||||
BlockLevel : integer;
|
||||
BlockCmd : TToken;
|
||||
GotoLabel : string;
|
||||
|
||||
VarList : TVarList;
|
||||
FuncList : TFuncList;
|
||||
ProcList : TProcList;
|
||||
|
||||
ProcessProc : PProcessProc;
|
||||
|
||||
LastString : string;
|
||||
LastParsed : string;
|
||||
|
||||
procedure Clear;
|
||||
procedure Process;
|
||||
procedure Error(Msg,Line:string; Code:integer);
|
||||
procedure Level1(var R:TVar);
|
||||
procedure Level2(var R:TVar);
|
||||
procedure Level3(var R:TVar);
|
||||
procedure Level4(var R:TVar);
|
||||
procedure Level5(var R:TVar);
|
||||
procedure Level6(var R:TVar);
|
||||
procedure Level7(var R:TVar);
|
||||
procedure Level8(var R:TVar);
|
||||
procedure Arith(o : TToken; var R,H:TVar);
|
||||
procedure Unary(o : TToken; var R:TVar);
|
||||
function GetIndex(S:string; var Index:integer; var T:TToken) : string;
|
||||
function GetFuncParams(S:string; var Index:integer) : string;
|
||||
function FindFunc(N:string) : integer;
|
||||
function FindArray(N:string) : boolean;
|
||||
procedure SetVarDirect(var R:TVar);
|
||||
function CallFunc(N:string; A:string; var V:TVar) : boolean;
|
||||
function CallProc(N:string; A:string; var V:TVar) : boolean;
|
||||
function GetTextToken(S: string; var Index : integer; var Code : TToken) : string;
|
||||
function TokenStr(T:TToken;S:string) : string;
|
||||
function GetToken(S:string; var Index : integer; var Code : TToken) : string;
|
||||
function GetTokenCode(S: string; var Index:integer; var Code:TToken) : integer;
|
||||
function GetTokenLine(S:string; var Index:integer; var Code:TToken;
|
||||
StopToken:TTokenSet) : string;
|
||||
function NextToken(S:string; Index:integer) : TToken;
|
||||
function GetOperator(Txt:string; var Index : integer; EndToken:TTokenSet) : string;
|
||||
function ParseOperator(Txt:string; var Cmd,Line,Lbl : string) : TToken;
|
||||
function DelRemarks(S:string) : string;
|
||||
function UnParse(S:string; Show:boolean) : string;
|
||||
function PreProcess(Txt:string):string;
|
||||
function Calc(S:string; var R:TVar) : boolean;
|
||||
procedure Exec(Txt:string);
|
||||
procedure DoSet(CmdLine,Cmd,Line:string);
|
||||
procedure DoIf(CmdLine,Line:string);
|
||||
procedure DoBegin(CmdLine,Line:string);
|
||||
procedure DoFor(CmdLine,Line:string);
|
||||
procedure DoBreak(CmdLine,Line:string);
|
||||
procedure DoContinue(CmdLine,Line:string);
|
||||
procedure DoExit(CmdLine,Line:string);
|
||||
procedure DoWhile(CmdLine,Line:string);
|
||||
procedure DoRepeat(CmdLine,Line:string);
|
||||
procedure DoGoto(CmdLine,Line:string);
|
||||
procedure DoCase(CmdLine,Line:string);
|
||||
public
|
||||
Stop : boolean;
|
||||
ErrCode : integer;
|
||||
ErrMsg : string;
|
||||
ErrLine : string;
|
||||
end;
|
||||
|
||||
|
||||
4. Функции (unit PASFUNC.PAS)
|
||||
------------------------------
|
||||
|
||||
// Функции для работы со строками
|
||||
|
||||
Val
|
||||
IntToStr
|
||||
StrToInt
|
||||
FloatToStr
|
||||
StrToFloat
|
||||
Copy
|
||||
Pos
|
||||
Length
|
||||
Insert
|
||||
Delete
|
||||
Trim
|
||||
TrimLeft
|
||||
TrimRight
|
||||
UpperCase
|
||||
LowerCase
|
||||
Format
|
||||
|
||||
// Функции для работы с датой и временем
|
||||
|
||||
Now
|
||||
Date
|
||||
Time
|
||||
DateToStr
|
||||
StrToDate
|
||||
TimeToStr
|
||||
StrToTime
|
||||
FormatDateTime
|
||||
DayOfWeek
|
||||
IncMonth
|
||||
DecodeDate
|
||||
DecodeTime
|
||||
EncodeDate
|
||||
EncodeTime
|
||||
|
||||
// Математические функции
|
||||
|
||||
Abs
|
||||
Int
|
||||
Frac
|
||||
Round
|
||||
Ceil
|
||||
Floor
|
||||
Trunc
|
||||
Sin
|
||||
Cos
|
||||
Tan
|
||||
ArcSin
|
||||
ArcCos
|
||||
ArcTan
|
||||
Exp
|
||||
Ln
|
||||
IntPower
|
||||
Sqr
|
||||
Sqrt
|
||||
Min
|
||||
Max
|
||||
Inc
|
||||
Dec
|
||||
|
||||
// Функции PASCALC для работы с переменными.
|
||||
// Позволяют обращаться к переменной по вычисляемому имени.
|
||||
|
||||
SetVar
|
||||
GetVar
|
||||
|
||||
|
||||
5. Использование интерпретатора
|
||||
-------------------------------
|
||||
|
||||
Пример использования есть в demo-программе. В скриптах интерпретатора вы
|
||||
можете использовать готовую библиотеку функций из модуля pasfunc.pas, или
|
||||
напиcать собственную реализацию нужных вам функций, которых нет в библиотеке.
|
||||
Функция должна записать результат в поле Value переменной R:TVar и вернуть true.
|
||||
В случае ошибки (например при вызове с недопустимыми параметрами) функция
|
||||
должна вернуть false.
|
||||
|
||||
Потом создайте экземпляр класса TPasCalc. С помошью метода SetProcessProc
|
||||
можно задать указатель на процедуру которая будет регулярно вызываться в
|
||||
циклах интерпретатора. С ее помощью можно например реализовать таймаут.
|
||||
Если вы задали такую процедуру, то в ней стоит предусмотреть вызов обработчика
|
||||
сообщений (Application.ProcessMessages например). Если ее не задали, то вместо
|
||||
нее будет использоваться метод Process, в котором предусмотрена обработка сообщений.
|
||||
|
||||
Затем вызовами TPasCalc.SetFunction надо зарегистрировать функции которые вы
|
||||
хотите использовать и задать им имена. В модуле pasfunc.pas регистрация делается
|
||||
вызовом процедуры SetFunctions. Также можно задать предопределенные переменные
|
||||
вызовами SetVarNum или SetVarStr.
|
||||
|
||||
Метод Calculate вычисляет значение математического выражения и возвращает
|
||||
результат в переменной R:TVar, а метод Execute выполняет текст скрипта и
|
||||
заполняет список переменных. С помощью методов VarCount, VarByIndex или
|
||||
VarByName вы можете получить их значения. При возникновении ошибок их код
|
||||
возврашается в ErrCode. В ErrMsg и ErrLine возвращается сообщение об ошибке
|
||||
и строка ее вызвавшая.
|
||||
|
||||
При следуюших вызовах Calculate и Execute список переменных не очищается и
|
||||
их значения можно использовать в выражениях. При желании вы можете сами
|
||||
очистить список переменных вызвав ClearVars. Очистить список функций можно с
|
||||
помощью ClearFuncs. Если возникла необходимость принудительно прервать
|
||||
интерпретацию, надо присвоить значение true перменной TPasCalc.Stop.
|
||||
|
||||
Чтобы ускорить выполнение скриптов их можно предварительно подготовить
|
||||
с помощью метода Parse, который возвращает разобранную строку.
|
||||
Ее можно сохранить и затем выполнять теми же методами Calculate и Execute.
|
||||
|
||||
|
||||
6. Коды ошибок (ErrCode)
|
||||
------------------------
|
||||
|
||||
0 - O.K.
|
||||
1 - ошибка в выражении
|
||||
2 - непарные скобки
|
||||
3 - переменная не найдена
|
||||
4 - недопустимое имя переменной или функции
|
||||
5 - неверный тип операнда
|
||||
6 - невернaя строковая константе
|
||||
7 - неверный вызов функции
|
||||
8 - функция не найдена
|
||||
9 - неизвестный оператор
|
||||
10 - нехватает END
|
||||
11 - лишний END
|
||||
12 - нехватает TO или DOWNTO
|
||||
13 - нет переменной цикла
|
||||
14 - нехватает DO
|
||||
15 - BREAK вне цикла
|
||||
16 - нехватает UNTIL
|
||||
17 - лишний UNTIL
|
||||
18 - метка не найдена
|
||||
19 - индекс за границей диапазона
|
||||
20 - значение за границей диапазона
|
||||
21 - нехватает ']'
|
||||
22 - нехватает '['
|
||||
23 - деление на 0
|
||||
24 - Дублируется имя переменной/массива
|
||||
25 - Ошибка открытия файла
|
||||
26 - Функция должна возвращать значение
|
||||
27 - нет OF в операторе CASE
|
||||
28 - несколько ELSE в операторе CASE
|
||||
29 - неверный диапазон значений в операторе CASE
|
||||
|
||||
|
||||
7. Автор:
|
||||
---------
|
||||
|
||||
Алексей Бойко
|
||||
alexboiko@mtu-net.ru
|
||||
http://alexboiko.da.ru
|
||||
32
北极星光OPENWRT/编程器软件/scripts/S25FL128S_Read_OTP.pas
Normal file
32
北极星光OPENWRT/编程器软件/scripts/S25FL128S_Read_OTP.pas
Normal file
@@ -0,0 +1,32 @@
|
||||
// designed for
|
||||
{$ READ_JEDEC_ID}
|
||||
begin
|
||||
ID:= CreateByteArray(3);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read JEDEC ID');
|
||||
|
||||
// read ID to test installation
|
||||
SPIWrite (0, 1, $9F);
|
||||
SPIRead(1, 3, ID);
|
||||
|
||||
logprint('Read ID: ' + inttohex((GetArrayItem(ID, 0)),2)+ inttohex((GetArrayItem(ID, 1)),2)+ inttohex((GetArrayItem(ID, 2)),2));
|
||||
LogPrint ('End read JEDEC ID');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ Read_OTP}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read OTP');
|
||||
RegSize := 1024;
|
||||
SPIWrite (0, 5, $4B, $00, $00, $00, $00);
|
||||
SPIReadToEditor (1, RegSize);
|
||||
LogPrint ('0-15 bytes = Random serial number');
|
||||
LogPrint ('16-17 bytes = 32 LockBits for OTP area (1 bit for each 32 byte OTP)');
|
||||
LogPrint ('18-31 bytes = Reserved');
|
||||
LogPrint ('Other = Writable OTP area ');
|
||||
LogPrint ('End read OTP');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
|
||||
186
北极星光OPENWRT/编程器软件/scripts/SPI_NAND_utilities_MOD.pas
Normal file
186
北极星光OPENWRT/编程器软件/scripts/SPI_NAND_utilities_MOD.pas
Normal file
@@ -0,0 +1,186 @@
|
||||
// designed for SPI NAND
|
||||
// Read first (full) page of a given block
|
||||
// Read given (full) page
|
||||
// Read BBM Look Up Table (winbond)
|
||||
// Erase a block
|
||||
// write a given page (full or not)
|
||||
{$ READ_JEDEC_ID}
|
||||
begin
|
||||
ID:= CreateByteArray(2);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Read JEDEC ID');
|
||||
|
||||
// read ID to test installation
|
||||
SPIWrite (0, 2, $9F, $00);
|
||||
SPIRead(1, 2, ID);
|
||||
|
||||
logprint('CHIP ID: ' + inttohex((GetArrayItem(ID, 0)),2)+ inttohex((GetArrayItem(ID, 1)),2));
|
||||
LogPrint ('End read JEDEC ID');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ ERASE_a_BLOCK}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Erase a given block');
|
||||
sreg :=$FF;
|
||||
buff:= CreateByteArray(4);
|
||||
maxpage:= _IC_Size / _IC_Page;
|
||||
|
||||
repeat
|
||||
BlockNum := InputBox('Enter Block Number (0 to '+ inttostr((maxpage / 64)-1)+')','','0');
|
||||
until (BlockNum >=0) and (BlockNum <=(maxpage / 64)-1);
|
||||
|
||||
//reset chip
|
||||
SPIWrite(1, 1, $FF);
|
||||
// write enable
|
||||
SPIWrite (1, 1, $06);
|
||||
// reset protection bits
|
||||
SPIWrite(1, 3, $1F, $A0, 0);
|
||||
// wait if busy
|
||||
repeat
|
||||
SPIWrite(0, 2, $0F, $C0);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and 1) <> 1);
|
||||
|
||||
Addr:= BlockNum * 64;
|
||||
SetArrayItem(buff, 0, $D8);
|
||||
SetArrayItem(buff, 1, (addr shr 16)); // div 65536
|
||||
SetArrayItem(buff, 2, (addr shr 8)); // div 256
|
||||
SetArrayItem(buff, 3, (addr));
|
||||
// erase block
|
||||
SPIWrite (1, 4, buff);
|
||||
|
||||
// wait if busy
|
||||
repeat
|
||||
SPIWrite(0, 2, $0F, $C0);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and 1) <> 1);
|
||||
|
||||
LogPrint ('End erase block');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_64_PAGE}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Read (full) given page');
|
||||
sreg :=$FF;
|
||||
buff:= CreateByteArray(4);
|
||||
bufflen:= _IC_Page + _IC_Spare;
|
||||
maxpage:= 64; //_IC_Size / _IC_Page; //uncomment to read full IC
|
||||
// repeat
|
||||
// PageNum := InputBox('Enter page Number (0 to ' +inttostr(maxpage-1) +')','','0');
|
||||
// until (PageNum >=0) and (PageNum <= maxpage-1);
|
||||
|
||||
//reset chip
|
||||
SPIWrite(1, 1, $FF);
|
||||
|
||||
for PageNum:=0 to maxpage-1 do
|
||||
begin
|
||||
Addr:= PageNum;
|
||||
SetArrayItem(buff, 0, $13);
|
||||
SetArrayItem(buff, 1, (addr shr 16)); // div 65536
|
||||
SetArrayItem(buff, 2, (addr shr 8)); // div 256
|
||||
SetArrayItem(buff, 3, (addr));
|
||||
// transfer page datas to cache
|
||||
SPIWrite (1, 4, buff);
|
||||
|
||||
// wait if busy
|
||||
repeat
|
||||
SPIWrite(0, 2, $0F, $C0);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and 1) <> 1);
|
||||
|
||||
SetArrayItem(buff, 0, $03);
|
||||
SetArrayItem(buff, 1, 0);
|
||||
SetArrayItem(buff, 2, 0);
|
||||
SetArrayItem(buff, 3, 0); // dummy byte
|
||||
SPIWrite (0, 4, buff);
|
||||
// read cache from 0, bufflen length
|
||||
SPIReadToEditor (1, bufflen);
|
||||
ProgressBar(1);
|
||||
//LogPrint ('End read page' );
|
||||
end;
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ WRITE_64_PAGE}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Write data to given page');
|
||||
sreg :=$FF;
|
||||
buff:= CreateByteArray(4);
|
||||
buffer:= CreateByteArray(_IC_Page+_IC_Spare);
|
||||
bufflen:= _IC_Page + _IC_Spare;
|
||||
maxpage:= 64; //_IC_Size / _IC_Page; //uncomment to write full IC
|
||||
|
||||
// repeat
|
||||
// PageNum := InputBox('Enter destination page Number (0 to ' +inttostr(maxpage-1) +')','','0');
|
||||
// until (PageNum >=0) and (PageNum <= maxpage-1);
|
||||
|
||||
// repeat
|
||||
// StartAddr := InputBox('Editor Start (decimal) Address (0, 2048,...)','','0');
|
||||
// until (StartAddr >=0) and (StartAddr <=_IC_Size -_IC_Page);
|
||||
|
||||
//reset chip
|
||||
SPIWrite(1, 1, $FF);
|
||||
// write enable
|
||||
SPIWrite (1, 1, $06);
|
||||
// reset protection bits
|
||||
SPIWrite(1, 3, $1F, $A0, 0);
|
||||
// wait if busy
|
||||
repeat
|
||||
SPIWrite(0, 2, $0F, $C0);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and 1) <> 1);
|
||||
|
||||
for PageNum:=0 to maxpage-1 do
|
||||
begin
|
||||
StartAddr:=PageNum*bufflen;
|
||||
// transfer editor datas to buffer array
|
||||
WriteFromEditor (bufflen, StartAddr, buffer);
|
||||
SPIWrite (1, 1, $06); // write enable
|
||||
|
||||
SetArrayItem(buff, 0, $02); // write datas to cache
|
||||
SetArrayItem(buff, 1, 0);
|
||||
SetArrayItem(buff, 2, 0);
|
||||
|
||||
SPIWrite (0, 3, buff);
|
||||
SPIWrite (1, bufflen, buffer);
|
||||
|
||||
// transfer datas from cache to the specified memory page.
|
||||
Addr:= PageNum;
|
||||
SetArrayItem(buff, 0, $10);
|
||||
SetArrayItem(buff, 1, (addr shr 16)); // div 65536
|
||||
SetArrayItem(buff, 2, (addr shr 8)); // div 256
|
||||
SetArrayItem(buff, 3, (addr));
|
||||
|
||||
SPIWrite (1, 4, buff);
|
||||
|
||||
// wait if busy
|
||||
repeat
|
||||
SPIWrite(0, 2, $0F, $C0);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and 1) <> 1);
|
||||
end;
|
||||
//LogPrint ('End write page');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
{$ READ_BBM_table}
|
||||
begin
|
||||
BBM:= CreateByteArray(80);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Read winbond BBM table');
|
||||
|
||||
// read winbond BBM table
|
||||
SPIWrite (0, 2, $A5, $00);
|
||||
SPIRead(1, 80, BBM);
|
||||
|
||||
for i:=0 to 19 do
|
||||
logprint('LBA' +inttostr(i)+': ' + inttohex((GetArrayItem(BBM, i+0)),2) + inttohex((GetArrayItem(BBM, i+1)),2) + ' PBA' +inttostr(i)+': ' + inttohex((GetArrayItem(BBM, i+2)),2) + inttohex((GetArrayItem(BBM, i+3)),2));
|
||||
|
||||
LogPrint ('End read BBM table');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
23
北极星光OPENWRT/编程器软件/scripts/blockerase.pas
Normal file
23
北极星光OPENWRT/编程器软件/scripts/blockerase.pas
Normal file
@@ -0,0 +1,23 @@
|
||||
{$块擦除}
|
||||
begin
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
|
||||
BlockSize := 65536;
|
||||
sreg := 0;
|
||||
ProgressBar(0, (_IC_SIZE / BlockSize)-1, 0);
|
||||
|
||||
for i:=0 to (_IC_SIZE / BlockSize)-1 do
|
||||
begin
|
||||
SPIWrite(1, 1, $06);
|
||||
SPIWrite(1, 4, $D8, i,0,0);
|
||||
|
||||
repeat
|
||||
SPIWrite(0, 1, $05);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and 1) <> 1);
|
||||
ProgressBar(1);
|
||||
end;
|
||||
|
||||
ProgressBar(0, 0, 0);
|
||||
SPIExitProgMode();
|
||||
end
|
||||
59
北极星光OPENWRT/编程器软件/scripts/i2c_example.pas
Normal file
59
北极星光OPENWRT/编程器软件/scripts/i2c_example.pas
Normal file
@@ -0,0 +1,59 @@
|
||||
{$read}
|
||||
//reading 24c08
|
||||
begin
|
||||
ChipSize := 1024;
|
||||
MemAddr := 0;
|
||||
ReadBuff := CreateByteArray(ChipSize);
|
||||
DevAddr := $A8;
|
||||
|
||||
if _IC_Name = '' then
|
||||
begin
|
||||
ShowMessage ('Choose a component in list');
|
||||
exit;
|
||||
end;
|
||||
|
||||
I2CEnterProgMode;
|
||||
|
||||
I2CReadWrite(DevAddr, 1, ChipSize, MemAddr, ReadBuff);
|
||||
ReadToEditor(ChipSize, 0, ReadBuff);
|
||||
|
||||
I2CExitProgMode;
|
||||
end
|
||||
|
||||
{$write}
|
||||
function I2CIsBusy(DevAdr): boolean;
|
||||
begin
|
||||
I2CStart;
|
||||
Result := not I2CWriteByte(DevAdr);
|
||||
I2CStop;
|
||||
end;
|
||||
//writing 24c08
|
||||
begin
|
||||
ChipSize := 1024;
|
||||
MemAddr := 0;
|
||||
WriteByte := 0;
|
||||
DevAddr := $A0;
|
||||
if _IC_Name = '' then
|
||||
begin
|
||||
ShowMessage ('Choose a component in list');
|
||||
exit;
|
||||
end;
|
||||
ProgressBar(0, _IC_SIZE-1, 0);
|
||||
|
||||
I2CEnterProgMode;
|
||||
|
||||
for i:=0 to ChipSize-1 do
|
||||
begin
|
||||
WriteFromEditor(1, i, WriteByte);
|
||||
I2CReadWrite(DevAddr, 2, 0, MemAddr, WriteByte);
|
||||
while I2CIsBusy(DevAddr) do
|
||||
MemAddr := MemAddr + 1;
|
||||
if MemAddr = 256 then DevAddr := $A2;
|
||||
if MemAddr = 512 then DevAddr := $A4;
|
||||
if MemAddr = 768 then DevAddr := $A6;
|
||||
ProgressBar(1);
|
||||
end;
|
||||
|
||||
I2CExitProgMode;
|
||||
ProgressBar(0, 0, 0);
|
||||
end
|
||||
241
北极星光OPENWRT/编程器软件/scripts/read_write_95xxx_example.pas
Normal file
241
北极星光OPENWRT/编程器软件/scripts/read_write_95xxx_example.pas
Normal file
@@ -0,0 +1,241 @@
|
||||
// read_write_95xxx_example.pas
|
||||
// EEPROM 95xxx example of read & write
|
||||
// useless, working script just for learning purpose
|
||||
// READ_MEMORY_IN_ARRAY must be done in assocation with uch_95040_test.bin
|
||||
cvx
|
||||
{$ READ_MEMORY}
|
||||
begin
|
||||
if _IC_Name = '' then
|
||||
begin
|
||||
ShowMessage ('Choose a component in list');
|
||||
exit;
|
||||
end;
|
||||
|
||||
buff:= CreateByteArray(4); // create an array of 4 bytes
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed'); // mandatory programmer initialisation
|
||||
LogPrint ('Start read memory'); // blablabla
|
||||
//ChipSize := 512; // size of memory in byte (manual)
|
||||
ChipSize := _IC_Size; // to recover the size of the chip declared in the application.
|
||||
|
||||
// addressing for 8, 16, 24 bit mode
|
||||
SetArrayItem(buff, 0, $03); // $03 read EEprom opcode
|
||||
SetArrayItem(buff, 1, 0); // equivalent of buff[1]:= Addr in pure pascal
|
||||
SetArrayItem(buff, 2, 0);
|
||||
SetArrayItem(buff, 3, 0);
|
||||
|
||||
len := 2; // length value depends of addressing mode
|
||||
// 2 for 8bit mode, 3 for 16 bit, 4 for 24 bit
|
||||
if (ChipSize > 512) and (ChipSize <= 65536) then len := 3;
|
||||
if (ChipSize > 65536) then len := 4;
|
||||
|
||||
SPIWrite(0, len, buff); // send the read command to the chip, 0 is the state of Chip select (CS) at the end of the command
|
||||
SPIReadToEditor (1, ChipSize); // then, read the content of memory and put values in the editor, (CS) high and the end
|
||||
|
||||
LogPrint ('End read memory');
|
||||
SPIExitProgMode (); // close programmer
|
||||
end
|
||||
|
||||
{$ READ_MEMORY_IN_ARRAY}
|
||||
begin
|
||||
if _IC_Name = '' then
|
||||
begin
|
||||
ShowMessage ('Choose a component in list');
|
||||
exit;
|
||||
end;
|
||||
|
||||
buff:= CreateByteArray(4);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start read memory');
|
||||
//ChipSize := 512; // size of memory in byte (manual)
|
||||
ChipSize := _IC_Size; // to recover the size of the chip declared in the application.
|
||||
|
||||
ReadArray:= CreateByteArray(ChipSize); // create an array of chipsize bytes
|
||||
ASCIItable:= CreateStringArray(128);
|
||||
|
||||
// addressing for 8, 16, 24 bit mode
|
||||
SetArrayItem(buff, 0, $03); // $03 read EEprom opcode
|
||||
SetArrayItem(buff, 1, 0); // equivalent of buff[1]:= Addr in pure pascal
|
||||
SetArrayItem(buff, 2, 0);
|
||||
SetArrayItem(buff, 3, 0);
|
||||
|
||||
len := 2; // length value depends of addressing mode
|
||||
// 2 for 8bit mode, 3 for 16 bit, 4 for 24 bit
|
||||
if (ChipSize > 512) and (ChipSize <= 65536) then len := 3;
|
||||
if (ChipSize > 65536) then len := 4;;
|
||||
|
||||
SPIWrite(0, len, buff);
|
||||
// read the content of memory and put values in an array
|
||||
SPIRead(1, ChipSize, ReadArray);
|
||||
|
||||
// build ASCII table 0..9, A..Z (upcases)
|
||||
for i:= 0 to 127 do
|
||||
begin
|
||||
SetArrayItem(ASCIItable, i, ' '); // initialise the table with spaces
|
||||
end;
|
||||
|
||||
for i:= $30 to $39 do
|
||||
begin
|
||||
SetArrayItem(ASCIItable, i, inttostr(i-$30));
|
||||
end;
|
||||
i:=$40;
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'A');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'B');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'C');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'D');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'E');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'F');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'G');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'H');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'I');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'J');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'K');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'L');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'M');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'N');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'O');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'P');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'Q');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'R');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'S');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'T');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'U');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'V');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'W');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'X');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'Y');
|
||||
inc (i);SetArrayItem(ASCIItable, i, 'Z');
|
||||
|
||||
s0:='';
|
||||
// build VIN number
|
||||
for i:= $1AD to $1BD do
|
||||
begin
|
||||
s0:= s0 + GetArrayItem(ASCIItable, (GetArrayItem(ReadArray, i)));
|
||||
end;
|
||||
s0:= 'VIN = ' + s0;
|
||||
logprint(s0);
|
||||
|
||||
s1:='';
|
||||
// build ISK number
|
||||
for i:= $13A to $13F do
|
||||
begin
|
||||
GetArrayItem(ReadArray, i);
|
||||
s1:= s1 + inttohex(GetArrayItem(ReadArray, i),2) + ' ';
|
||||
end;
|
||||
s1:= 'ISK = ' + s1;
|
||||
logprint(s1);
|
||||
|
||||
// PIN value to be calculated by appropriate algorithm
|
||||
s2:= 'PIN = ' + 'FF FF FF FF FF FF';
|
||||
|
||||
// ShowMessage multiligne workaround
|
||||
// '\n' string is used as a separator and will be replaced by CR LF at display
|
||||
ShowMessage(s0+'\n'+s1+'\n'+s2);
|
||||
|
||||
LogPrint ('End read memory');
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
|
||||
|
||||
{$ WRITE_MEMORY}
|
||||
begin
|
||||
if _IC_Name = '' then
|
||||
begin
|
||||
ShowMessage ('Choose a component in list');
|
||||
exit;
|
||||
end;
|
||||
|
||||
buff:= CreateByteArray(4);
|
||||
if not SPIEnterProgMode(_SPI_SPEED_MAX) then LogPrint('Error setting SPI speed');
|
||||
LogPrint ('Start write memory');
|
||||
//ChipSize := 512; // size of memory in byte (manual)
|
||||
ChipSize := _IC_Size; // to recover the size of the chip declared in the application.
|
||||
//PageSize := 16; // size of page (see 95040 datasheet)
|
||||
PageSize := _IC_Page; // to recover the page size of the chip declared in the application.
|
||||
Addr:= 0;
|
||||
sreg :=0;
|
||||
|
||||
// show progress bar for the fun
|
||||
ProgressBar(0, (ChipSize / PageSize)-1, 0);
|
||||
|
||||
// write (more complex than read)
|
||||
// writing must be done by chunks equal to page size
|
||||
// and addressing is depending of the chip particularities (see datasheet)
|
||||
|
||||
// beginning of writing loop by chunks equal to pagesize value)
|
||||
while Addr < ChipSize do
|
||||
begin
|
||||
// adapted from spi95.pas in asprogrammer source repository
|
||||
// https://github.com/nofeletru/UsbAsp-flash/tree/test
|
||||
// M35080, ST95P08 are excluded
|
||||
|
||||
if ChipSize < 512 then
|
||||
begin
|
||||
SetArrayItem(buff, 0, $02);
|
||||
SetArrayItem(buff, 1, Addr);
|
||||
len := 2;
|
||||
end;
|
||||
|
||||
// For 95040, when A8=1, Bit3 of intruction byte must be set
|
||||
if ChipSize = 512 then
|
||||
begin
|
||||
if Addr < 256 then //A8=0
|
||||
begin
|
||||
SetArrayItem(buff, 0, $02); // $02 write EEprom opcode
|
||||
SetArrayItem(buff, 1, Addr);
|
||||
end;
|
||||
|
||||
if Addr > 255 then //A8=1
|
||||
begin
|
||||
SetArrayItem(buff, 0, ($02 or $8)); // set Bit3 of intruction byte
|
||||
SetArrayItem(buff, 1, Addr-256);
|
||||
end;
|
||||
len := 2;
|
||||
end;
|
||||
|
||||
if (ChipSize > 512) and (ChipSize <= 65536) then // 16-bit Address range
|
||||
begin // 2 bytes
|
||||
SetArrayItem(buff, 0, $02);
|
||||
SetArrayItem(buff, 1, (addr shr 8));
|
||||
SetArrayItem(buff, 2, (addr));
|
||||
len := 3;
|
||||
end;
|
||||
|
||||
if (ChipSize > 65536) then // 24-bit Address range
|
||||
begin // 3 bytes
|
||||
SetArrayItem(buff, 0, $02);
|
||||
SetArrayItem(buff, 1, (addr shr 16));
|
||||
SetArrayItem(buff, 2, (addr shr 8));
|
||||
SetArrayItem(buff, 3, (addr));
|
||||
len := 4;
|
||||
end;
|
||||
|
||||
// write enable (see datasheet)
|
||||
SPIWrite (1, 1, $06);
|
||||
|
||||
// send the write command to the chip
|
||||
SPIWrite(0, len, buff);
|
||||
// then, write the content of the editor at specified address
|
||||
//SPIWriteFromEditor(cs, size, position)
|
||||
SPIWriteFromEditor(1, PageSize, Addr);
|
||||
|
||||
// wait if busy
|
||||
//(see datasheet)
|
||||
repeat
|
||||
SPIWrite(0, 1, $05);
|
||||
SPIRead(1, 1, sreg);
|
||||
until((sreg and 1) <> 1);
|
||||
|
||||
Inc(Addr, PageSize); // next chunk
|
||||
|
||||
// inc progress bar of 1 step
|
||||
progressBar(1);
|
||||
end;
|
||||
|
||||
LogPrint('End write memory');
|
||||
// write disable
|
||||
SPIWrite (1, 1, $04);
|
||||
// reset progress bar
|
||||
ProgressBar(0, 0, 0);
|
||||
// close programmer
|
||||
SPIExitProgMode ();
|
||||
end
|
||||
251
北极星光OPENWRT/编程器软件/scripts/script_func.html
Normal file
251
北极星光OPENWRT/编程器软件/scripts/script_func.html
Normal file
@@ -0,0 +1,251 @@
|
||||
<html lang="ru">
|
||||
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Language" content="ru"> </head>
|
||||
|
||||
<table border="1" cellpadding="5" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><font size="5"><b>Секции</b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>{$read}</b></td>
|
||||
<td>Код секции выполняется при нажатии кнопки чтении памяти</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>{$write}</b></td>
|
||||
<td>Код секции выполняется при нажатии кнопки записи памяти</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>{$erase}</b></td>
|
||||
<td>Код секции выполняется при нажатии кнопки стирания памяти</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>{$verify}</b></td>
|
||||
<td>Код секции выполняется при нажатии кнопки сравнения памяти</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>{$unlock}</b></td>
|
||||
<td>Код секции выполняется при нажатии кнопки снятия защиты</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><font size="5"><b>Предопределенные переменные</b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>_IC_Name</b></td>
|
||||
<td>Название текущей выбранной микросхемы </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>_IC_Size</b></td>
|
||||
<td>Размер, в байтах, текущей выбранной микросхемы</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>_IC_Spare</b></td>
|
||||
<td>Размер резервной области, в байтах, выбранного в данный момент чипа SPI NAND</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>_IC_Page</b></td>
|
||||
<td>Размер страницы, в байтах, текущей выбранной микросхемы </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>_SPI_SPEED_MAX</b></td>
|
||||
<td>Максимально возможная частота для <b style="text-align: center;">SPISetSpeed</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><b><font size="5">Основные функции</font></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>ShowMessage(<font color="#0000FF">text+'\n'+text</font>);</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Аналог ShowMessage(используйте строку '\ n' для нескольких строк)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>LogPrint(<font color="#0000FF">text</font>);</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Выводит сообщение в лог<br>
|
||||
Параметры:<br>
|
||||
<b><font color="#0000FF">text</font></b> текст сообщения<br>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>IntToHex(<font color="#0000FF">value</font>, <font color="#0000FF">digits</font>): string;</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"> Аналог IntToHex</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>ProgressBar(<font color="#0000FF">inc</font>, <font color="#0000FF">max</font>, <font color="#0000FF">pos</font>);</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"> Устанавливает состояние ProgressBar<br>
|
||||
Параметры:<br>
|
||||
<b><font color="#0000FF">inc </font></b>насколько увиличить позицию<br>
|
||||
Необязательные параметры:<br>
|
||||
<font color="#0000FF"><b>max</b></font> максимальная позиция ProgressBar<br>
|
||||
<font color="#0000FF"><b>pos</b></font> устанавливает конкретную позицию ProgressBar</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>CreateByteArray(<font color="#0000FF">size</font>): variant;</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Создает массив с типом элементов varbyte</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>CreateStringArray(<font color="#0000FF">size</font>): variant;</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Создает массив строк</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>GetArrayItem(<font color="#0000FF">array</font>, <font color="#0000FF">index</font>): variant;</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Возвращает значение элемента массива</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>SetArrayItem(<font color="#0000FF">array</font>, <font color="#0000FF">index</font>, <font color="#0000FF">value</font>);</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Устанавливает значение элемента массива</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>ReadToEditor(<font color="#0000FF">size</font>, <font color="#0000FF">position</font>, <font color="#0000FF">buffer, ...</font>);</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Записывает данные из буфера в редактор размером size в позицию position</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>WriteFromEditor(<font color="#0000FF">size</font>, <font color="#0000FF">position</font>, <font color="#0000FF">buffer, ...</font>);</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Записывает данные из редактора размером size с позиции position</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>GetEditorDataSize: longword;</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Возвращает размер данных в редакторе</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><font size="5"><b>Работа с SPI</b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>SPIEnterProgMode(<font color="#0000FF">speed</font>): boolean;</b></td>
|
||||
<td>
|
||||
<p>Инициализирует состояние пинов для SPI и устанавливает частоту SPI <br>
|
||||
Параметры:<br>
|
||||
<font color="#0000FF"><b>speed</b></font><br>
|
||||
<b>_SPI_SPEED_MAX</b> = AvrIsp 8(4) MHz / USbAsp 3 MHz<br>
|
||||
Если частота не установлена возвращает false<br>
|
||||
Игнорируется для устройств с фиксированной частотой</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>SPIExitProgMode();</b></td>
|
||||
<td>
|
||||
<p>Отключает пины SPI</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>SPIRead(<font color="#0000FF">cs</font>, <font color="#0000FF">size</font>, <font color="#0000FF">buffer</font></b><b>, ...</b><b>): integer;</b></td>
|
||||
<td>
|
||||
<p>Читает данные в буфер <br>
|
||||
Параметры: <br>
|
||||
<font color="#0000FF"><b>cs</b></font> если <font color="#0000FF"><b>cs</b></font>=1 отпускать Chip Select после чтения данных <br>
|
||||
<font color="#0000FF"><b>size </b></font>размер данных в байтах <br>
|
||||
<font color="#0000FF"><b>buffer</b></font> переменные для хранения данных или массив созданный <b>CreateByteArray</b> <br>
|
||||
Возвращает количество прочитанных байт</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>SPIWrite(<font color="#0000FF">cs</font>, <font color="#0000FF">size</font>, <font color="#0000FF">buffer</font></b><b>, ...</b><b>): integer;</b></td>
|
||||
<td>
|
||||
<p>Записывает данные из буфера <br>
|
||||
Параметры: <br>
|
||||
<b><font color="#0000FF">cs</font> </b>если <b><font color="#0000FF">cs</font></b>=1 отпускать Chip Select после записи данных <br>
|
||||
<b><font color="#0000FF">size </font></b>размер данных в байтах <br>
|
||||
<b><font color="#0000FF">buffer </font></b>переменные с данными или массив созданный <b>CreateByteArray </b><br>
|
||||
Возвращает количество записанных байт</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>SPIReadToEditor(<font color="#0000FF">cs</font>, <font color="#0000FF">size</font>): integer;</b></td>
|
||||
<td>
|
||||
<p>Читает данные в редактор <br>
|
||||
Параметры: <br>
|
||||
<b><font color="#0000FF">cs </font></b>если <b><font color="#0000FF">cs</font></b>=1 отпускать Chip Select после чтения данных <br>
|
||||
<b><font color="#0000FF">size</font> </b>размер данных в байтах <br>
|
||||
Возвращает количество прочитанных байт</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>SPIWriteFromEditor(<font color="#0000FF">cs</font>, <font color="#0000FF">size</font>, <font color="#0000FF">position</font>): integer;</b></td>
|
||||
<td>
|
||||
<p>Записывает данные из редактора размером <b><font color="#0000FF">size </font></b>с позиции <b><font color="#0000FF">position </font></b><br>
|
||||
Параметры: <br>
|
||||
<b><font color="#0000FF">cs </font></b>если <b><font color="#0000FF">cs</font></b>=1 отпускать Chip Select после записи данных <br>
|
||||
<b><font color="#0000FF">size </font></b>размер данных в байтах <br>
|
||||
<b><font color="#0000FF">position</font> </b>позиция в редакторе <br>
|
||||
Возвращает количество записанных байт</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><font size="5"><b>Работа с I2C</b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>I2CEnterProgMode();</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"> Инициализирует состояние пинов</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>I2cExitProgMode();</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"> Отключает пины</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>I2CReadWrite(<font color="#0000FF">DevAddr</font>, <font color="#0000FF">wsize</font>, <font color="#0000FF">rsize</font>, <font color="#0000FF">wbuffer</font>, <font color="#0000FF">rbuffer</font></b><b>): integer;</b></td>
|
||||
<td>
|
||||
<p>Записывает/читае данные из буферов <br>
|
||||
Параметры: <br>
|
||||
<b><font color="#0000FF">DevAddr</font></b> адрес устройства <br>
|
||||
<b><font color="#0000FF">size </font></b>размер данных в байтах <br>
|
||||
<b><font color="#0000FF">buffer </font></b>переменные с данными или массив созданный <b>CreateByteArray </b><br>
|
||||
Возвращает количество записанных + прочитанных байт<br>
|
||||
*Если <b><font color="#0000FF">rsize</font></b>=0 можно опустить параметр <b><font color="#0000FF">rbuffer</font></b></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>I2CStart();</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Используется вместе с I2CReadByte и I2CWriteByte</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>I2CStop();</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Используется вместе с I2CReadByte и I2CWriteByte</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>I2CReadByte(<font color="#0000FF">ack</font>: boolean): byte;</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Читает байт данных и отправляет ack/nack</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b>I2CWriteByte(<font color="#0000FF">data</font>): boolean;</b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left">Записывает байт данных и возвращает ack/nack</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
250
北极星光OPENWRT/编程器软件/scripts/script_func_EN.html
Normal file
250
北极星光OPENWRT/编程器软件/scripts/script_func_EN.html
Normal file
@@ -0,0 +1,250 @@
|
||||
<html lang="en">
|
||||
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Language" content="en"> </head>
|
||||
|
||||
<body><table border="1" cellpadding="5" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><font size="5"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Sections</font></font></b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">{$ read}</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Section code is executed when the read memory button is pressed.</font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">{$ write}</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">The section code is executed when the memory record button is pressed.</font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">{$ erase}</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">The section code is executed when the memory erase button is pressed.</font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">{$ verify}</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Section code is executed when the memory comparison button is pressed.</font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">{$ unlock}</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Section code is executed when the unprotect button is pressed.</font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><font size="5"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Predefined variables</font></font></b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">_IC_Name</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">The name of the currently selected chip </font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">_IC_Size</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Size, in bytes, of the currently selected chip</font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">_IC_Spare</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Spare area size, in bytes, of the currently selected SPI NAND chip</font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">_IC_Page</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Page size, in bytes, of the currently selected chip </font></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">_SPI_SPEED_MAX</font></font></b></td>
|
||||
<td><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">The highest possible frequency for </font></font><b style="text-align: center;"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">SPISetSpeed</font></font></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><b><font size="5"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Main functions</font></font></font></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">ShowMessage ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">text+'\n'+text</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> );</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Analogue ShowMessage (use '\n' string for multi line)</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">LogPrint ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">text</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> );</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Print a message to the log </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Parameters: </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">text</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> message text </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">IntToHex ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">value</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">digits</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): string;</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> Analog IntToHex</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">ProgressBar ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">inc</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">max</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">pos</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> );</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> Sets the status of the ProgressBar </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Parameters: </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">inc</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> how much the position is increased </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Optional parameters: </font></font><br>
|
||||
<font color="#0000FF"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">max</font></font></b></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> maximum position ProgressBar </font></font><br>
|
||||
<font color="#0000FF"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">pos</font></font></b></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> sets the specific position of the ProgressBar</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">CreateByteArray ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): variant;</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Creates an array with varbyte element type</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">CreateStringArray ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): variant;</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Creates an array of string</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">GetArrayItem ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">array</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">index</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): variant;</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Returns the value of an array element</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">SetArrayItem ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">array</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">index</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">value</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> );</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Sets the value of an array element</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">ReadToEditor ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">position</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">buffer, ...</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> );</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Writes data from the buffer to the size editor at position</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">WriteFromEditor ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">position</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">buffer, ...</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> );</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Writes data from size editor from position</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">GetEditorDataSize: longword;</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Returns data size in editor</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><font size="5"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Work with SPI</font></font></b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">SPIEnterProgMode ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">speed</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): boolean;</font></font></b></td>
|
||||
<td>
|
||||
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Initializes the pin state for SPI and sets the SPI frequency </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Parameters: </font></font><br>
|
||||
<font color="#0000FF"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">speed</font></font></b></font><br>
|
||||
<b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> _SPI_SPEED_MAX</font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> = AvrIsp 8 (4) MHz / USbAsp 3 MHz </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
If the frequency is not set, returns false </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Ignored for devices with a fixed frequency</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">SPIExitProgMode ();</font></font></b></td>
|
||||
<td>
|
||||
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Disables SPI pins</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">SPIRead ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">buffer</font></font></font></b><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , ... </font></font></b><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">): integer;</font></font></b></td>
|
||||
<td>
|
||||
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Reads data to buffer </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Parameters: </font></font><br>
|
||||
<font color="#0000FF"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></b></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> if </font></font><font color="#0000FF"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></b></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> = 1 release Chip Select after reading data </font></font><br>
|
||||
<font color="#0000FF"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></b></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> data </font><font color="#0000FF"><b><font style="vertical-align: inherit;">size</font></b></font><font style="vertical-align: inherit;"> in bytes </font></font><br>
|
||||
<font color="#0000FF"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">buffer</font></font></b></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> variables for storing data or an array created by </font></font><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">CreateByteArray</font></font></b> <br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Returns the number of bytes read</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">SPIWrite ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">buffer</font></font></font></b><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , ... </font></font></b><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">): integer;</font></font></b></td>
|
||||
<td>
|
||||
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Writes data from the buffer </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Parameters: </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></font> </b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> if </font></font><b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> = 1 release Chip Select after writing data </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> data </font><b><font color="#0000FF"><font style="vertical-align: inherit;">size</font></font></b><font style="vertical-align: inherit;"> in bytes </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">buffer</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> data variables or array created </font></font><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">CreateByteArray </font></font></b><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Returns the number of written bytes</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">SPIReadToEditor ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): integer;</font></font></b></td>
|
||||
<td>
|
||||
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Reads data to the editor </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Parameters: </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> if </font></font><b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> = 1 release Chip Select after reading data </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font> </b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> data </font><b><font color="#0000FF"><font style="vertical-align: inherit;">size</font></font></b><font style="vertical-align: inherit;"> in bytes </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Returns the number of bytes read</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">SPIWriteFromEditor ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">cs</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">position</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): integer;</font></font></b></td>
|
||||
<td>
|
||||
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">From Writes data size editor </font></font><b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> from the standpoint </font></font><b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">position </font></font></font></b><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
parameters: </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> Cs</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> if </font></font><b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> Cs</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> = 1 release, after Chip Select data record </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> data size in bytes of the </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">position</font></font></font> </b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> the position in the editor </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
returns the number of bytes written</font></font></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><font size="5"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Work with I2C</font></font></b></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">I2CEnterProgMode ();</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> Initializes the state of the pins</font></font></p>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">I2cExitProgMode ();</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> Disables pins</font></font></p>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">I2CReadWrite ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">DevAddr</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">wsize</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">rsize</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">wbuffer</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> , </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">rbuffer</font></font></font></b><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): integer;</font></font></b></td>
|
||||
<td>
|
||||
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Writes / reads data from buffers </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Parameters: </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">DevAddr</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> device address </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">size</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> data size in bytes </font></font><br>
|
||||
<b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">buffer</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> variable data or array created </font></font><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">CreateByteArray </font></font></b><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
Returns the number of recorded bytes read + </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
|
||||
* If </font></font><b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">rsize</font></font></font></b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> = 0 can omit the parameter </font></font><b><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">rbuffer</font></font></font></b></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">I2CStart ();</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Used with I2CReadByte and I2CWriteByte</font></font></p>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">I2CStop ();</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Used with I2CReadByte and I2CWriteByte</font></font></p>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">I2CReadByte ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">ack</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> : boolean): byte;</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Reads a data byte and sends ack / nack</font></font></p>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center;"><b><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">I2CWriteByte ( </font></font><font color="#0000FF"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">data</font></font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> ): boolean;</font></font></b></td>
|
||||
<td style="text-align: center;">
|
||||
<p align="left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Writes a data byte and returns ack / nack</font></font></p>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p> </p>
|
||||
BIN
北极星光OPENWRT/编程器软件/scripts/uch_95040_test.bin
Normal file
BIN
北极星光OPENWRT/编程器软件/scripts/uch_95040_test.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user