Eric Jung / GMMP_mbed_Ethernet_Reinit

Dependents:   ThingPlug_Ethernet_Example

Fork of GMMP_mbed by Eric Jung

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GMMP_Util.cpp Source File

GMMP_Util.cpp

00001 /*
00002  * GMMP_Util.c
00003  *
00004  *  Created on: 2013. 11. 27.
00005  *      Author: root
00006  */
00007 
00008 #include "GMMP_Util.h"
00009 
00010 short ltobs(const short nShort)
00011 {
00012     return _btols(nShort);
00013 }
00014 
00015 short btols(const short nShort)
00016 {
00017     return _btols(nShort);
00018 }
00019 
00020 short _btols(const short nShort)
00021 {
00022     short nValue = 0;
00023 
00024     nValue = (unsigned short)nShort >> 8;
00025     nValue |=(unsigned short) nShort << 8;
00026 
00027     return  nValue;
00028 }
00029 
00030 long ltobi(const long nInt)
00031 {
00032     return _ltobi(nInt);
00033 }
00034 
00035 long btoli(const long nInt)
00036 {
00037     return _ltobi(nInt);
00038 }
00039 
00040 long _ltobi(const long nInt)
00041 {
00042     long nVal0, nVal1, nVal2, nVal3;
00043 
00044     nVal0 =  (unsigned long)nInt >> 24;
00045     nVal1 =  (unsigned long)(nInt & 0x00FF0000) >> 8;
00046     nVal2 =  (unsigned long)(nInt & 0x0000FF00) << 8;
00047     nVal3 =  (unsigned long)nInt << 24;
00048 
00049     return (nVal0 | nVal1 | nVal2 | nVal3);
00050 }
00051 
00052 int freeRam () {
00053   // __brkval is the address of the top of the heap
00054   // if memory has been allocated.
00055   // If __brkval is zero then it means malloc has not used any memory yet, so
00056   // we look at the address of __heap_start.
00057   
00058   return 0;
00059 }