Library for Nuvoton ISD1700 chipcorder family

Hi there cincailo,

I'm afraid I cannot be much of help porting the library code to the Microchip PIC platform, since there is a lot of Arduino language embedded into it.

However, I can help you a bit with the differences between platforms.

According to some references I've found hanging low on the internet, PIC's SSPCONx, SSPSTAT and SSPBUF registers correspond to ATmega's SPCR, SPSR and SPDR registers, respectively, which hold all bits that deal with the SPI communication.

This is what your SPI initialization code would look like:

/**
 * void spi_init(void)
 * 
 * Initializes SPI communication in a Microchip PICmicro
 * This is a Hi-tech PICC compiler compliant code
 *
 * @author Marcelo Shiniti Uchimura
 */
void spi_init(void)
{
    SSPCON = 0x32;  /* set up SSP to clock data out on falling edge
                       whilst clock data in on rising edge, clock idle high */
    TRISC = 0x10;   /* RC4 and SDI (or MISO) are the same pin in Microchip PIC16F87x uC family */

    PORTC |= 0x04;  /* de-selecting chipcorder (RC2 is attached to chipcorder's SS pin) */
}

/**
 * char spi_transfer(char)
 * 
 * Send/get data to/from an SPI peripheral device
 * This is a Hi-tech PICC compiler compliant code
 *
 * @author Marcelo Shiniti Uchimura
 */
char spi_transfer(char data)
{
    PORTC &= ~(0x04);    /* selecting chipcorder */
    SSPBUF = data;
    while(!(SSPSTAT & 0x01))
    {
        /* wait for transfer complete */
    }
    return SSPBUF;
}