Legacy-Free Keyboard/Embedded Controller with SPI and LPC Docking Interface
// Declarations
ERROR_MASK = 0x0070;
BUSY_MASK = 0x0080;
// CSI Status Reg. Error Bits Mask.
// CSI Status Reg. Busy Bit Mask.
// Executable Code
boolean NO_ERRORS_&_BUSY (int *errors)
{
NOTE
//
: Call only in CSI Idle (Read Status) State.
int etmp;
// Temp Value for CSI Status Register.
// Get CSI Status Register (Address = Don’t Care).
// First Check for Errors.
// Stop Loop Because of Error Flags.
// Look at Busy Bit.
// Continue Loop Because Busy Bit Asserted.
// Stop Loop Because Busy Bit Deasserted and No Errors.
etmp = CSIREAD(0x0000);
IF (*errors = (etmp & ERROR_MASK))
return (FALSE);
ELSE IF (etmp & BUSY_MASK)
return (TRUE);
ELSE return (FALSE);
};
Figure 8.11 NO_ERRORS_and_BUSY Function
8.6.2
Byte Programming Example
Byte programming requires three basic steps: 1) activate the CSI Host Interface with the Program Byte
command code, 2) send the program address and data arguments to the CSI address & data latches,
and 3) monitor the completion status and check for errors.
The byte programming example pseudo-code is shown below in Figure 8.12. A return to the Read Array
mode is also shown in Figure 8.12 to verify the Program Byte operation.
// Declarations
// Programming Loop Control Variable
// Program Byte Address Argument Value
// Program Byte Data Argument Value
// CSI Program Byte Command Code Value
// CSI Read Array Command Code Value
// CSI Clear Status Command Code Value
// Variable for Status Register Errors
DONE = FALSE;
WRITE_ADDRESS = 00F0;
WRITE_DATA = 0xA0;
PROGRAM_BYTE_CMD = 0x80;
READ_ARRAY_CMD = 0xFF;
CLEAR_STATUS_CMD = 0xA0;
ERRORS = 0x00;
// Executable Code
WHILE (NOT DONE)
{
// Send Program Byte Command Code (Address = Don’t
Care).
// Send Program Byte Argument.
// Loop Until Errors Occur or BUSY Bit Deasserted.
// Take Remedial Steps.
CSIWRITE(0x0000, PROGRAM_BYTE_CMD);
CSIWRITE(WRITE_ADDRESS, WRITE_DATA);
WHILE (NO_ERRORS_&_BUSY(&ERRORS));
IF (ERRORS)
{
FIX_ERRORS(ERRORS);
// Correct Problems (e.g. Protect or Setup Errors).
// Clear Status Register (Address = Don’t Care).
// Try Again.
// Restore Read Ar ray Mode To Verify Byte
Programming.
CSIWRITE(0x0000, CLEAR_STATUS_CMD);
}
ELSE
{
CSIWRITE(0x0000, READ_ARRAY_CMD);
IF (CSIREAD(WRITE_ADDRESS) = WRITE_DATA)
DONE = TRUE;
}
}
// If Not Verified, Try Again.
Figure 8.12 Program Byte Example Pseudo-Code
8.6.3
Mass Erase Example
Mass Erase requires two basic steps: 1) activate the CSI Host Interface with the Mass Erase command
code and 2) monitor the completion status and check for errors. The Mass Erase example pseudo-code
is shown in Figure 8.13. A return to the Read Array mode is also shown in Figure 8.13.
SMSC LPC47N350
105
Revision 1.1 (01-14-03)
DATASHEET