//*****************************************************************************
//
// SPIdriver.h - Stellaris development board Peripheral Device Controller definitions
//         and prototypes.
//
// Copyright (c) 2005-2008 Luminary Micro, Inc.  All rights reserved.
// 
// Software License Agreement
// 
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
// exclusively on LMI's microcontroller products.
// 
// The software is owned by LMI and/or its suppliers, and is protected under
// applicable copyright laws.  All rights are reserved.  You may not combine
// this software with "viral" open-source software in order to form a larger
// program.  Any use in violation of the foregoing restrictions may subject
// the user to criminal sanctions under applicable laws, as well as to civil
// liability for the breach of the terms and conditions of this license.
// 
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 3416 of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

#ifndef __SPI_H__
#define __SPI_H__

//Definice konstant------------------------------------------------------------
// The registers within the peripheral device controller
#define SPI_VER                 0x0                                             // Version register
#define SPI_CSR                 0x1                                             // Command/Status register
#define SPI_DSW                 0x4                                             // DIP Switch register
#define SPI_LED                 0x5                                             // LED register
#define SPI_GPXDAT              0x8                                             // GPIO X Data register
#define SPI_GPXDIR              0x9                                             // GPIO X Direction register
#define SPI_GPYDAT              0xA                                             // GPIO Y Data register
#define SPI_GPYDIR              0xB                                             // GPIO Y Direction register
#define SPI_GPZDAT              0xC                                             // GPIO Z Data register
#define SPI_GPZDIR              0xD                                             // GPIO Z Direction register

// Flags indicating a read or write to the peripheral device controller.
#define SPI_RD                  0x80                                            // SPI read command
#define SPI_WR                  0x00                                            // SPI write command

// The GPIO port A pin numbers for the various SSI signals.
#define SSI_CS                  GPIO_PIN_3
#define SPI_CS                  GPIO_PIN_3
#define SSI_CLK                 GPIO_PIN_2
#define SSI_TX                  GPIO_PIN_5
#define SSI_RX                  GPIO_PIN_4

//Definice pinu pro rizeni CS pro AD prevodniky
#define SPI_CS_PINS  (GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7)

#define SPI_CS_INPUT_CHANNEL1 0x00
#define SPI_CS_INPUT_CHANNEL2 0x01
#define SPI_CS_INPUT_CHANNEL3 0x02
#define SPI_CS_INPUT_CHANNEL4 0x03
#define SPI_CS_OUTPUT         0x04
#define SPI_CS_OFF            0x07
  
//Deklarace funkci-------------------------------------------------------------
extern void SPI_Init(void);
extern unsigned char SPI_Read(unsigned char ucAddr);
extern void SPI_Write32b(unsigned char command, unsigned char address, unsigned short data);
extern void SPI_Write16b(unsigned char Shdn, unsigned char address, unsigned short data);
extern unsigned short SPI_Read16b();
extern void SPI_SetCS(char value);


#endif // __SPI_H__
