
AN1886 - APPLICATION NOTE
22/54
High Level Interface
At the highest level, the Windows application and the μPSD32xxA firmware communicates using
MCU_CMD
structures. This is shown in
APPENDIX H.
. The only exception is LCD display mirror data,
which is discussed in the next section.
This structure is a union of sub-structures, each of which specifies the parameters for a particular com-
mand.
The first byte of the structure specifies a command code. For instance, the application sends a Flash mem-
ory erase command to the firmware by setting up a
MCU_CMD
structure as follows:
reportBuf.report.u.erase.cmd = CMD_ERASE;
reportBuf.report.u.erase.address = SWAP_UINT16(address);
reportBuf.report.u.erase.flash = (uchar) flash;
Note the
SWAP_UINT16
macro used to convert from little-endian to big-endian format for the 8032 pro-
cessor core of the μPSD32xx.
See the Application Interface,
Firmware\app_intr.h
, header file for the complete declaration of the
MCU_CMD
structure along with the
CMD_xxx
codes for all the commands that can be passed between
the application and the firmware. This header file is included in both the application and firmware projects,
and has the following content:
#define CMD_RESET 0x01
#define CMD_ERASE 0x02
#define CMD_WRITE 0x03
#define CMD_READ 0x04
#define CMD_STATUS 0x05
#define CMD_SET_REGS 0x06
#define CMD_SET_PAGE 0x07
#define CMD_SET_VM 0x08
The physical execution of the commands is initiated by the
OnReportReceived()
routine, which is shown
in
APPENDIX I.
.
The only exceptions are:
–
the
Erase
command, which takes a long execution time and thus must be executed in the background,
not as a part of USB interrupt service routine
–
commands that are executed for more packets (
Read
and
Write
commands). These commands are
triggered by a software interrupt process.
HID Level Interface
Communication with HID devices is achieved through the structures, called “HID Reports”, that are de-
fined in the descriptor data for each HID device. For more information on HID, see the appropriate sections
of this document, or directly in the HID standards.
The USB example firmware defines three standard HID reports in the Report Descriptor,
reportDesc,
structure in
Firmware\usb_desc.c
:
Feature Report
64 bytes of command data, passed through EP0 control endpoint.
Input Report
8 bytes of raw LCD buffer data, passed through EP1 IN interrupt endpoint
Output Report
64 bytes of command data, passed through EP0 control endpoint.
The
Report Descriptor
is read by the Microsoft HID driver during device enumeration.
At the Windows API layer, the application must break up large commands into one or more report struc-
tures. HID reports are passed to a HID device using the Win32
WriteFile
routine. Reports are read from a