TESIS SATUROMETRICA / vector_int24

vector_integer.cpp

Committer:
cesarcazal
Date:
2017-03-29
Revision:
1:d043a9b85963

File content as of revision 1:d043a9b85963:

#include "vector_integer.h"
#include "mbed.h"
//LOS VALORES SON DEVUELTOS EN FORMATO INT32; SIN EMBARGO SOLO SE REALIZAN CONVERSIONES EQUIVALENTES A VARIABLES DE 24BITS

int pointer_to_int(char *vect) {
    int aux1;
    int result=0; 
    for (aux1 = 2; aux1>0; aux1--){
        result= result|*(vect+aux1);
        result <<= 8;
        if((aux1==1)&&(*(vect+2)>127))
            result = result|(0xff000000);  
    }
    result= *vect|result;
    return (result);
}

void int_to_pointer (int dato, char *point){
    *(point)    = dato;
    *(point+1)  = dato >> 8;
    *(point+2)  = dato >> 16;
    *(point+3)  = dato >> 24;
}