//###########################################################################
//
// FILE:    init_SPI.c
//
// TITLE:
//
// NOTES:
//  1)
//###########################################################################
//
//  Ver  | dd mmm yyyy | Who  		| Description of changes
// ======|=============|============|========================================
//  00 	   05 04 2015 	 HPCS
//
//  Texas Instruments, Inc
//  Copyright Texas Instruments 2008. All rights reserved.
//###########################################################################

#include "system_defines.h"
#include "cyclone_device.h"
#include "variables.h"
#include "function_definitions.h"
#include "software_interrupts.h"
#include "cyclone_defines.h"
#include "pmbus_common.h"
#include "pmbus_topology.h"
#include "pmbus_constants.h"


#if ( UCD3138064 | UCD3138064A | UCD3138128 |UCD3138128A)
void init_slave_SPI(void)
{

    SPIRegs.SPICTRL.bit.SPIEN   = 1;          //
    SPIRegs.SPICTRL.bit.MODE    = 1;          // 1 = Slave
    SPIRegs.SPICTRL.bit.INTEN   = 1;          //
    SPIRegs.SPICTRL.bit.PHA     = 0;          // Mode 0  - Match the slave model
    SPIRegs.SPICTRL.bit.POL     = 0;          // Mode 0
    SPIRegs.SPICTRL.bit.WRSTART = 0;          // unused as slave
    SPIRegs.SPICTRL.bit.WRSTORE = 0;          // unused as slave
    SPIRegs.SPICTRL.bit.TXCNT   = 0;          // unused as slave
    SPIRegs.SPICTRL.bit.RXCNT   = 1;          // Bytes to RX as slave
    SPIRegs.SPICTRL.bit.FRMLEN  = 1;          // unused in slave
    SPIRegs.SPICTRL.bit.CLKRATE = 0;          // unused in slave

    SPIRegs.SPICTRL.bit.SPIEN   = 1;          //

    // Automatic control of IO in FUNCmode = 0
        SPIRegs.SPIFUNC.bit.SCK     = 0;          // 0 = SPI mode
        SPIRegs.SPIFUNC.bit.MOSI    = 0;          //
        SPIRegs.SPIFUNC.bit.MISO    = 0;          //
        SPIRegs.SPIFUNC.bit.SCS     = 0;          //

}
#endif
