Sonoma (MAXREFDES14#) Code Documentation  V01.00
Isolated EMP (Energy Measurement Processor)
 All Data Structures Files Functions Variables Macros Pages
utilities.h
Go to the documentation of this file.
1 
29 /*
30  * Copyright (C) 2012 Maxim Integrated Products, All Rights Reserved.
31  *
32  * Permission is hereby granted, free of charge, to any person obtaining a
33  * copy of this software and associated documentation files (the "Software"),
34  * to deal in the Software without restriction, including without limitation
35  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
36  * and/or sell copies of the Software, and to permit persons to whom the
37  * Software is furnished to do so, subject to the following conditions:
38  *
39  * The above copyright notice and this permission notice shall be included
40  * in all copies or substantial portions of the Software.
41  *
42  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
43  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45  * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
46  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
47  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
48  * OTHER DEALINGS IN THE SOFTWARE.
49  *
50  * Except as contained in this notice, the name of Maxim Integrated Products
51  * shall not be used except as stated in the Maxim Integrated Products
52  * Branding Policy.
53  *
54  * The mere transfer of this software does not imply any licenses
55  * of trade secrets, proprietary technology, copyrights, patents,
56  * trademarks, maskwork rights, or any other form of intellectual
57  * property whatsoever. Maxim Integrated Products retains all ownership rights.
58  *
59  ***************************************************************************/
60 
61 #ifndef UTILITIES_H_
62 #define UTILITIES_H_
63 #include "xbasic_types.h"
64 #include "xspi_l.h"
65 #include "stdio.h"
66 #include "xiic_l.h"
67 #include "xuartlite_i.h"
68 #include "xparameters.h"
69 #include "xgpio.h"
70 #include "xgpio_l.h"
71 #include "MAXREFDES14.h"
72 #endif /* UTILITIES_H_ */
73 
74 #pragma once
75 
76 //====================================================================================================
77 // Function: SpiRW()
78 //
79 // @param unBaseAddr: Base address of SPI master. Find it in "xparameters.h".
80 // @param unCPHA: CPHA setting for SPI port. See IC datasheet.
81 // @param unCPOL: CPOL setting for SPI port. See IC datasheet.
82 // @param auchWriteBuf: Buffer containing write data for transfer. Set to 0 if not writing data.
83 // @param auchReadBuf: Buffer into which read data will be placed. Set to 0 if not reading data.
84 // @param unNumBytes: Number of bytes to be read/written.
85 // @param uchCsActiveHigh: 1 if CS is active high, 0 if CS is active low.
86 //
87 // @return: 0 if successful, nonzero otherwise. Note -- error checking not completed.
88 //====================================================================================================
89 int SpiRW(u32 unPeripheralAddressSPI, unsigned int unCPHA, unsigned int unCPOL,
90  u8* auchWriteBuf, u8* auchReadBuf, int unNumBytes, u8 uchCsActiveHigh );
91 
92 void delay(int nStopValue);
93 void led_knight_rider(XGpio *pLED_GPIO, int nNumberOfTimes);
94 void max_configure_PMOD_port(u8 uchPmodPortA, u8 uchPmodPortB, u8 uchPmodPortC, u8 uchPmodPortD);
96 int number_raised_to_power(int nBase, int nExponent);
97 int receive_byte_with_timeout(u32 unUartAddress, int nTimeoutInTenthsOfSeconds, u8 *uchRxData);
98 
99 void set_seven_segment_character(u8 uchDigitNumber, u8 uchValue, u8 uchDecimalActive);
100 void print_seven_segment_number(float fNumber);
101 struct maximDateTime *t;
103 int GetLine( char* sInputString, unsigned int unMaxSize );
104 void print_asterisks(int nQuantity);
105 void printf_temp(float fTemp, u8 uchPrintCelsius, u8 uchAddCarriageReturn);
106 void print_seven_segment_temperature(float temp, u8 uchPrintCelsius);
107 void print_seven_segment_four_digits(char *puchArray);
108 int htoi(char *sStr);
109 u8 getUartByte(u32 nUartAddress);
110 
111 
112 
113 
114 
115 
116 
117 
118