/**
 @page SPI_Master_Slave

 @verbatim
 * @file    SPI/Master_Slave/readme.txt
 * @version V1.00
 * @date    2014-06-30
 * @brief   Description of the SPI Master/Slave example.
 @endverbatim

@par Example Description:

This example describes how to exchange data between two HT32 series MCU by SPI peripheral.
Both SPIs are configured with 8 bits mode, FIFO mode with Tx & Rx FIFO depths 4, 6MHz 
transmission speed.

The interrupt mode is used in this example. The SPI_ReadWrite function will prepare which
data will be send or which data buffer can be used to store the received data. The SPI
and the SPI Rx buffer not empty interrupt and the SPI timeout interrupt are enabled in
this function. Because the Rx FIFO depths is 4, the SPI interrupt will occure when Rx FIFO 
data length is equal to or great than 4. The other way to generate the SPI interrupt is the
Rx FIFO data length great than 0 and the timeout condition is occured. This is used to receive 
the last part of data when the Rx FIFO data didn't be read for a specific time caused by 
the Rx FIFO length less than 4 will not trigger Rx FIFO not empty interrupt in FIFO mode.

In the interrupt service routine, the SPI status will be read first and be cleared afterward.
A SPI_TransferHandler will be invoked that will read the Rx FIFO contents and put the data 
into Tx FIFO. If the transfer counter equal to the transfer length, the SPI_TransferHandler
will disable the SPI and it's interrupts and set transmission status as SPI_TRANSFER_DONE. 
A callback function will be invoked afterward if needed. 

To write memory :
1. Master : Send transmission prepare command.      
   Slave  : Put acknowledge information into TxFIFO for the next transmission.
2. Master : Send transmission write command and the target memory address and length.
            Check if the slave non-acknowlage, back to step 1 to restart the procedural again.
   Slave  : Set the received target address as the Rx transmission buffer. 
            Therefor, the data will be written into target memory directly.
3. Master : Start the data burst transmission until the transmission count equal to length.
   Slave  : Store the received data into the target memory.   

To read memory :
1. Master : Send transmission prepare command.      
   Slave  : Put acknowledge information into TxFIFO for the next transmission.
2. Master : Send transmission read command and the target memory address and length.
            Check if the slave non-acknowlage, back to step 1 to restart the procedural again.
   Slave  : Read the data of the target address and put it into the Tx FIFO for the 
            next transmission.
3. Master : Start the data burst transmission.
   Slave  : Put the data into the Tx FIFO until the transmission count equal to length.   

@par Directory Contents:

- SPI/Master_Slave/main.c                    Main program
- SPI/Master_Slave/ht32fxxxx_it.c            Interrupt handlers
- SPI/Master_Slave/spi_transfer.h            Header file for the SPI transmission 


@par Hardware and Software Environment:

- For the loopback mode, only one development board is needed. 
  But remember to connect SPI Master(PD0, PD1, PD2, PD3) 
  to SPI Slave(PD4, PD5, PD6, PD7) respectively. 
- User must prepare two development boards to run the example code. 
  Connect Master Development Board(PD0, PD1, PD2, PD3) 
  to Slave Development Board(PD4, PD5, PD6, PD7) respectively 
  and don't forget to connect the common-ground.  
- This example can be run on HT32 Series development board.

@par Firmware Disclaimer Information

1. The customer hereby acknowledges and agrees that the program technical documentation, including the
   code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
   proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
   other intellectual property laws.

2. The customer hereby acknowledges and agrees that the program technical documentation, including the
   code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
   other than HOLTEK and the customer.

3. The program technical documentation, including the code, is provided "as is" and for customer reference
   only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
   the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
   the warranties of merchantability, satisfactory quality and fitness for a particular purpose.

 * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2>
 */
