/** \file utilities.h ********************************************************
 * 
 *             Project: Maxim Plug-in Peripheral Modules
 *            Filename: utilities.h
 *         Description: This module contains a collection of general utility
 *                      functions which are not specific to any particular
 *                      module.
 * 
 *    Revision History:
 *\n       4-13-12 Rev 1.0 Seth Messimer   Initial Release
 *\n       7-20-12 Rev 1.4 Nathan Young    Additional functions
 * 
 *  --------------------------------------------------------------------
 * 
 *    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 UTILITIES_H_
#define UTILITIES_H_
#include "xparameters.h"	/* EDK generated parameters */
#include "xspips_hw.h"		/* SPI device driver */
//MTS#include "xbasic_types.h"
//MTS#include "xspi_l.h"
#include "stdio.h"
//MTS#include "xiic_l.h"
//MTS#include "xuartlite_i.h"
#include "xgpio.h"
#include "xgpio_l.h"
#include "MAXREFDES5.h"
#endif /* UTILITIES_H_ */

#pragma once


int ARMSpi4ByteRW( unsigned int unPeripheralAddressSPI, unsigned int* auchWriteBuf, unsigned int* auchReadBuf);
void print_asterisks(int nQuantity);
void delay(int nStopValue);
unsigned long number_raised_to_power(int nBase, int nExponent);
int GetLine( char* sInputString, unsigned int unMaxSize );

//
void led_knight_rider(XGpio *pLED_GPIO, int nNumberOfTimes);
//void max_configure_PMOD_port(u8 uchPmodPortA, u8 uchPmodPortB, u8 uchPmodPortC, u8 uchPmodPortD);
//int check_if_i2c_device_is_present();
//int number_raised_to_power(int nBase, int nExponent);
int receive_byte_with_timeout(u32 unUartAddress, int nTimeoutInTenthsOfSeconds, u8 *uchRxData);

//void set_seven_segment_character(u8 uchDigitNumber, u8 uchValue, u8 uchDecimalActive);
//void print_seven_segment_number(float fNumber);
//struct maximDateTime *t;
//void print_seven_segment_time(struct maximDateTime *t);
//int GetLine( char* sInputString, unsigned int unMaxSize );
void print_asterisks(int nQuantity);
void printf_temp(float fTemp, u8 uchPrintCelsius, u8 uchAddCarriageReturn);
//void print_seven_segment_temperature(float temp, u8 uchPrintCelsius);
//void print_seven_segment_four_digits(char *puchArray);
//void increment_active_PMOD_Port();
//void max_set_PMOD_port(int nPortNumber, u8 uchPortType);
//u8 getUartByte(u32 nUartAddress);
//void sendUartByte(u32 unUartAddress, u8 uchByte);
//u8 checkUartEmpty(u32 unUartAddress);
void initializeOLED(u8 *pFont);
void sendOLEDSPI(u8 uchDataToWrite);
void clearOLEDBuffer(u8 *pauchBuffer);
void displayOLEDBuffer(u8 *pauchBuffer);
void putCharOLED(int x, int y, char chCharacter);
void printfToBufferOLED(int x, int y,char *chString);
void printfToOLED(int x, int y,char *chString);
void flipAndCopyDisplayBuffer(u8 *pauchSourceBuffer, u8 *pauchDestinationBuffer);
void printOLED_31855(float fInternalTemp,float fProbeTemp, int displayCelsius);
void printOLED_31723(float fTemp);
void printOLED_3231M(struct maximDateTime t, float fTemp);
void printOLED_44000Lux(float fLuxReading);
void printOLED_44000Prox(float fProxReading);
