/** \file MAXREFDES14.c ******************************************************
 *
 *             Project: Sonoma (MAXREFDES14#)
 *            Filename: MAXREFDES14.c
 *         Description: This module contains the Main application for the
 *                      AVNET LX9 MicroBoard implementation of the MAXREFDES14
 *                      example program.
 *
 *    Revision History:
 *\n                    05-31-13    Rev 01.00    GL    Initial Release
 * 
 *  --------------------------------------------------------------------
 * 
 *    This code follows the following naming conventions.
 * 
 * 	  char                   chPmodValue
 * 	  char (array)           sPmodString[16]
 * 	  float                  fPmodValue
 * 	  int                    nPmodValue
 * 	  int (array)            anPmodValue[16]
 * 	  u16                    uPmodValue
 * 	  u8                     uchPmodValue
 * 	  u8 (array)             auchPmodBuffer[16]
 * 	  unsigned int           unPmodValue
 * 	  int *                  punPmodValue
 * 
 * ------------------------------------------------------------------------- */
/*
 * Copyright (C) 2012 Maxim Integrated Products, All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name of Maxim Integrated Products
 * shall not be used except as stated in the Maxim Integrated Products
 * Branding Policy.
 *
 * The mere transfer of this software does not imply any licenses
 * of trade secrets, proprietary technology, copyrights, patents,
 * trademarks, maskwork rights, or any other form of intellectual
 * property whatsoever. Maxim Integrated Products retains all ownership rights.
 *
 ***************************************************************************/

#ifndef MAXIMPMOD_H_
#define MAXIMPMOD_H_

#include "xgpio.h"
#include "xgpio_l.h"
#include "xparameters.h"
#include "xuartlite.h"
#include "xspi_l.h"
#include "xspi.h"
#include "xiic_l.h"
#include "utilities.h"
#include <string.h>
#include <stdio.h>
#include "platform.h"

#define DEFAULT_HYPERTERMINAL_UART_ID XPAR_USB_UART_DEVICE_ID  //!< macro used to abstract Physical Port of Hyperterminal UART
#define DEFAULT_HYPERTERMINAL_UART_ADDRESS XPAR_USB_UART_BASEADDR

#define ABOUT_ONE_SECOND 3508380      //!< approx 1 second delay when used as argument with function delay(numberCyclesToDelay)
// Update this if microblaze core frequency is changed, or if the external memory timing changes.
// Although emprirically tested to 1.0000003 seconds, it is not meant to be used for precise timing purposes

#define PMOD_TYPE_UART 0              //!< value which specifies UART in maximProduct structure
#define PMOD_TYPE_SPI 1               //!< value which specifies SPI in maximProduct structure
#define PMOD_TYPE_GPIO 2              //!< value which specifies GPIO in maximProduct structure
#define PMOD_TYPE_I2C 3               //!< value which specifies I2C in maximProduct structure

#define PMOD_PORT_TYPE_UART 0x00      //!< value to switch UART controller into a Pmod port in max_configure_PMOD_port
#define PMOD_PORT_TYPE_SPI  0x01      //!< value to switch SPI controller into a Pmod port in max_configure_PMOD_port
#define PMOD_PORT_TYPE_GPIO 0x02      //!< value to switch GPIO controller into a Pmod port in max_configure_PMOD_port
#define PMOD_PORT_TYPE_I2C	0x03      //!< value to switch I2C controller into a Pmod port in max_configure_PMOD_port

#define BIT_BANG_SPI_CLK 0x08         //!< bit mask for SPI CLK used in max_GPIO_bit_bang_SPI_write
#define BIT_BANG_SPI_CLRB 0x04        //!< bit mask for SPI /CLR used in max_GPIO_bit_bang_SPI_write
#define BIT_BANG_SPI_MISO 0x04        //!< bit mask for SPI MISO used in max_GPIO_bit_bang_SPI_write
#define BIT_BANG_SPI_MOSI 0x02        //!< bit mask for SPI MOSI used in max_GPIO_bit_bang_SPI_write
#define BIT_BANG_SPI_SSB 0x01         //!< bit mask for SPI SS used in max_GPIO_bit_bang_SPI_write

#define RE_B 0x00000001               //!< bit mask for RS-485 /RE used in menu_MAX14840
#define DI 0x00000002                 //!< bit mask for RS-485 DI used in menu_MAX14840
#define RO 0x00000004                 //!< bit mask for RS-485 RO used in menu_MAX14840
#define DE 0x00000008                 //!< bit mask for RS-485 DE used in menu_MAX14840



struct maximProduct                   //!< Structure holding info on each module for menus
{
	char sPartNumber[10];
	char sPartName[80];
	u8 uchPmodType;  // pmod:  i2c, spi, gpio, etc
	u8 uchKeypress;
};

struct maximDateTime                  //!< Structure to hold time, date, day of week
{
	u8 uchHour;
	u8 uchMinute;
	u8 uchSecond;
	u8 uchMonth;
	u8 uchDate;
	u8 uchYear;
	u8 uchDow;
};

#define INPUT_STRING_MAX_SIZE 16
extern XGpio g_xGpioPmodPortA;
extern XGpio g_xGpioPmodPortB;
extern char g_sInputString[ INPUT_STRING_MAX_SIZE ];	//This string will hold user input from terminal.

#endif /* MAXIMPMOD_H_ */
