utils.h

Here are the macros you can use by including utils.h.

S_OCTET(x)

Write one byte of memory.

uint8 *q = &sTx.au8Data[0];

S_OCTET(0x12); 
S_BE_WORD(0x1234); 
S_BE_DWORD(0x12345678);

Declare uint8 *q as a local variable and use it as a pointer to the area where you want to read the data. After evaluating the assignment operator, q++ is executed.

S_BE_WORD(x)

Write 2 bytes of memory.

uint8 *q = &sTx.au8Data[0];

S_OCTET(0x12); 
S_BE_WORD(0x1234); 
S_BE_DWORD(0x12345678);

Declare uint8 *q as a local variable and use it as a pointer to the area where you want to read the data. After evaluating the assignment operator, q+=2 is executed.

BE represents Big Endian.

S_BE_DWORD(x)

Write 4 bytes of memory.

Declare uint8 *q as a local variable and use it as a pointer to the area where you want to read the data. After evaluating the assignment operator, q+=4 is executed.

BE represents Big Endian.

G_OCTET()

Reads a single byte of memory and stores the value in a variable of type uint8.

Declare uint8 *p as a local variable and use it as a pointer to the area where you want to read the data. After evaluating the = operator, p++ is executed.

G_BE_WORD()

2バイトメモリを読み込み uint16 型の変数に値を格納する。

Declare uint8 *p as a local variable and use it as a pointer to the area where you want to read the data. After evaluating the = operator, p+=2 is executed.

BE represents Big Endian.

G_BE_DWORD()

1バイトメモリを読み込み uint8 型の変数に値を格納する。

Declare uint8 *p as a local variable and use it as a pointer to the area where you want to read the data. After evaluating the = operator, p+=4 is executed.

BE represents Big Endian.

ENCODE_VOLT(x)

Converts values between 2000 and 3600 into 8-bit values.

  • 1.95~2.80V in steps of 5mV

  • 2.81~3.65V in steps of 10mV

Values between 2000 and 2800 are assigned to 8-bit values in steps of 5 and from 2800 in steps of 10.

DECODE_VOLT(x)

Returns the 8-bit value obtained by ENCODE_VOLT() to its original value.

  • 1.95~2.80V in steps of 5mV

  • 2.81~3.65V in steps of 10mV

Values between 2000 and 2800 are assigned to 8-bit values in steps of 5 and from 2800 in steps of 10.

vPortAsInput(c)

Set port c as input

vPortAsOutput(c)

Set port c as output

​vPortSetHi(c)

Set port c to Hi state

​​vPortSetLo(c)

Set port c to Lo state

​​​vPortSet_TrueAsLo(c, s)

Set port c to Lo if s is TRUE, Hi if FALSE.

bPortRead(c)

Reads port c, returns TRUE if Lo level.

​u32PortReadBitmap()

Reads port c, returning TRUE if Lo level.

​bPortCheckBitmap(bitmap, c)

If the bit corresponding to port c of the read bitmap is Lo level, TRUE is returned.

vPortDisablePullup(c)

Stop the pull-up on port c.

_C

If you want to define a scope with switch, you have to write _C { ... }.

LB

A newline code (CRLF) string.

最終更新