Datasheet
chipKIT™ Basic I/O Shield™ Reference Manual 
Copyright Digilent, Inc. All rights reserved. 
Other product and company names mentioned may be trademarks of their respective owners. 
Page 13 of 13 
void 
OledPutBuffer(int cb, BYTE * rgbTx) 
  { 
  int    ib; 
  BYTE bTmp; 
  /* Write/Read the data 
  */ 
  for (ib = 0; ib < cb; ib++) { 
    /* Wait for transmitter to be ready 
    */ 
    while (SPI2STATbits.SPITBE == 0); 
    /* Write the next transmit byte. 
    */ 
    SPI2BUF = *rgbTx++; 
    /* Wait for receive byte. 
    */ 
    while (SPI2STATbits.SPIRBF == 0); 
    bTmp = SPI2BUF; 
  } 
} 
/* ------------------------------------------------------------ */ 
/*** Spi2PutByte 
** 
**  Parameters: 
**    bVal  - byte value to write 
** 
**  Return Value: 
**    Returns byte read 
** 
**  Errors: 
**    none 
** 
**  Description: 
**    Write/Read a byte on SPI port 2 
*/ 
BYTE 
Spi2PutByte(BYTE bVal) 
  { 
  BYTE bRx; 
  /* Wait for transmitter to be ready 
  */ 
  while (SPI2STATbits.SPITBE == 0); 
  /* Write the next transmit byte. 
  */ 
  SPI2BUF = bVal; 
  /* Wait for receive byte. 
  */ 
  while (SPI2STATbits.SPIRBF == 0); 
  /* Put the received byte in the buffer. 
  */ 
  bRx = SPI2BUF; 
  return bRx; 
}










