/*==================================================================================================

FILE INFORMATION HEADER

USED IN PROJECT:			S1003065-01 PPS-TX/S1003067-01 PPS-RX software application
ITEM TYPE:					Source Code
ITEM NAME:					xlru_common_func.h
ITEM DESCRIPTION:			This file contains convertions functions between char* to int/float/uint/etc
TARGET:						ATSAM4LC8B / ATSAM4LS8B
DOC REFERENCES:				SWDS1003065-01/SWDS1003065-01
PROGRAMMER NAME(S):			A.Chessa, L.Vallongo
COPYRIGHT:					LEONARDO-FINMECCANICA S.p.A
REVISION HISTORY:
- 01.00: first release

====================================================================================================
© Copyright LEONARDO S.p.A.. All rights reserved
Any right of industrial and intellectual property on this document,
and of technical Know-how herein contained, belongs to
LEONARDO S.p.A. and/or third parties.
According to the law, it is forbidden to disclose, reproduce or however
use this document and any data herein contained for any use without
previous written authorization by LEONARDO S.p.A.
==================================================================================================*/

#ifndef XLRU_COMMON_FUNC_H_
#define XLRU_COMMON_FUNC_H_

#include <stdint.h>

namespace xlru
{
	uint16_t check_sum_calculus(const char *pstring, short bytestoshift, short bytetocheck);

	void conv_decimale_to_hex(char s[], uint32_t num_temp,  uint8_t nrbytes);

	void reverse(char s[], int nrchar);

	int check_complements_2(uint8_t rawValue);

	int check_complements_2_from_buffer(char* buff, int index);

	void calc_checksum(char output[2], char* pstring);

	bool hex2u8(int* res, const char* data);

	bool hex2s8(int* res, const char* data);

	bool hex2u16(int* res, const char* data);

	bool hex2s16(int* res, const char* data);

	bool hex2u32(int* res, const char* data);

	bool hex2u48(int* res, const char* data);

	bool hex2u8(unsigned int* res, const char* data);

	bool hex2u16(unsigned int* res, const char* data);

	bool hex3u8f(float* res, const char* data, float lsb);

	bool hex3u16f(float* res, const char* data, float lsb);

	bool hex3u32f(float* res, const char* data, float lsb);

	bool hex3s8f(float* res, const char* data, float lsb);

	bool hex3s16f(float* res, const char* data, float lsb);
}

#endif /* XLRU_COMMON_FUNC_H_ */
