USB EPROM/Flash Programmer
Static Public Member Functions | List of all members
OpCode Class Reference

Opcode Manager Class. More...

#include <opcodes.hpp>

Static Public Member Functions

static bool isOk (const void *buf, size_t size)
 Checks if the return code was OK. More...
 
static TCmdOpCode getOpCode (const void *buf, size_t size)
 Gets the opcode from communication frame. More...
 
static TCmdOpCode getOpCode (uint8_t code)
 Gets the opcode from code (byte). More...
 
static float getValueAsFloat (const void *buf, size_t size)
 Gets the param value as float. More...
 
static uint8_t getValueAsByte (const void *buf, size_t size)
 Gets the param value as byte. More...
 
static bool getValueAsBool (const void *buf, size_t size)
 Gets the param value as bool. More...
 
static uint16_t getValueAsWord (const void *buf, size_t size)
 Gets the param value as word. More...
 
static uint32_t getValueAsDWord (const void *buf, size_t size)
 Gets the param value as double word. More...
 
static bool setFloat (void *buf, size_t size, float value)
 Sets the param value into the communication frame. More...
 
static bool setByte (void *buf, size_t size, uint8_t value)
 Sets the param value into the communication frame. More...
 
static bool setWord (void *buf, size_t size, uint16_t value)
 Sets the param value into the communication frame. More...
 
static bool setDWord (void *buf, size_t size, uint32_t value)
 Sets the param value into the communication frame. More...
 
static bool setBool (void *buf, size_t size, bool value)
 Sets the param value into the communication frame. More...
 

Detailed Description

Opcode Manager Class.

The purpose of this class is to handle the opcodes of the communication (via USB-CDC).

Member Function Documentation

◆ isOk()

bool isOk ( const void *  buf,
size_t  size 
)
static

Checks if the return code was OK.

Parameters
bufPointer to the buffer that contains the result of the communication.
sizeSize of buffer, in bytes.
Returns
True if return code is OK, false otherwise.

◆ getOpCode() [1/2]

TCmdOpCode getOpCode ( const void *  buf,
size_t  size 
)
static

Gets the opcode from communication frame.

Parameters
bufPointer to the buffer that contains the communication frame.
sizeSize of buffer, in bytes.
Returns
Opcode of the operation, or kCmdNop if not found.

◆ getOpCode() [2/2]

TCmdOpCode getOpCode ( uint8_t  code)
static

Gets the opcode from code (byte).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
codeCode (byte).
Returns
Opcode of the operation, or kCmdNop if not found.

◆ getValueAsFloat()

float getValueAsFloat ( const void *  buf,
size_t  size 
)
static

Gets the param value as float.

Parameters
bufPointer to the buffer that contains the result of the communication.
sizeSize of buffer, in bytes.
Returns
Value of parameter as float, or 0.0f if an error occurs.

◆ getValueAsByte()

uint8_t getValueAsByte ( const void *  buf,
size_t  size 
)
static

Gets the param value as byte.

Parameters
bufPointer to the buffer that contains the result of the communication.
sizeSize of buffer, in bytes.
Returns
Value of parameter as byte, or 0 if an error occurs.

◆ getValueAsBool()

bool getValueAsBool ( const void *  buf,
size_t  size 
)
static

Gets the param value as bool.

Parameters
bufPointer to the buffer that contains the result of the communication.
sizeSize of buffer, in bytes.
Returns
Value of parameter as bool, or false if an error occurs.

◆ getValueAsWord()

uint16_t getValueAsWord ( const void *  buf,
size_t  size 
)
static

Gets the param value as word.

Parameters
bufPointer to the buffer that contains the result of the communication.
sizeSize of buffer, in bytes.
Returns
Value of parameter as word, or 0 if an error occurs.

◆ getValueAsDWord()

uint32_t getValueAsDWord ( const void *  buf,
size_t  size 
)
static

Gets the param value as double word.

Parameters
bufPointer to the buffer that contains the result of the communication.
sizeSize of buffer, in bytes.
Returns
Value of parameter as double word, or 0 if an error occurs.

◆ setFloat()

bool setFloat ( void *  buf,
size_t  size,
float  value 
)
static

Sets the param value into the communication frame.

Parameters
bufPointer to the buffer that contains the communication frame.
sizeSize of buffer, in bytes.
valueValue to set.
Returns
True if success, false otherwise.

◆ setByte()

bool setByte ( void *  buf,
size_t  size,
uint8_t  value 
)
static

Sets the param value into the communication frame.

Parameters
bufPointer to the buffer that contains the communication frame.
sizeSize of buffer, in bytes.
valueValue to set.
Returns
True if success, false otherwise.

◆ setWord()

bool setWord ( void *  buf,
size_t  size,
uint16_t  value 
)
static

Sets the param value into the communication frame.

Parameters
bufPointer to the buffer that contains the communication frame.
sizeSize of buffer, in bytes.
valueValue to set.
Returns
True if success, false otherwise.

◆ setDWord()

bool setDWord ( void *  buf,
size_t  size,
uint32_t  value 
)
static

Sets the param value into the communication frame.

Parameters
bufPointer to the buffer that contains the communication frame.
sizeSize of buffer, in bytes.
valueValue to set.
Returns
True if success, false otherwise.

◆ setBool()

bool setBool ( void *  buf,
size_t  size,
bool  value 
)
static

Sets the param value into the communication frame.

Parameters
bufPointer to the buffer that contains the communication frame.
sizeSize of buffer, in bytes.
valueValue to set.
Returns
True if success, false otherwise.

The documentation for this class was generated from the following files: