Instagram

Friday, January 4, 2008

typical procrastinator showing that cramming may not be such a bad thing

[migrated from livejournal]


an excerpt from my undergraduate research project....
this code solves the problem i mentioned in the previous post:

this will serve as reference hehehe. finally. it works....well, this is just like a thirteenth (1/13) of the code i made from scratch....and thank God it works! now, it's time to sleep! =) smile smile smile. i have a big update after all...but what would be bigger is if i manage to integrate all the firmware (source codes) that all of us three (virna raissa and me) have done...by next week. that would mean that a huge part of my final presentation demo is accomplished and what would be left is to add the lcd interface to the axel activity monitor. yesh!!! and consequently, i may already have a demo for my halfway presentation....but then again, that's being too much of a dreamer...that feat can only be achieved through hard work, perseverance, determination and will power! hehehe, i hope i'll have what it takes.

<copyright>
<if you're going to take this code - DONT. hahaha. but do acknowledge me if you will - but i do doubt that you will be able to make much use of it considering that it's very application oriented. the end result of the conversion of the int is to an unsigned character array (512 bytes) which is the typical sector size used in MMC block transfers>

and once again, THANK YOU LORD.

Stephen Quedi
BS ECE
UP Instrumentation, Robotics, and Control Laboratory

unsigned int encode_data_to_char (unsigned int get_axel_data, unsigned int counter, unsigned char * data_array_proper,unsigned long int current_addr)
{
    unsigned char temp_storage,clear,err=0;
    char data_holder[10];
    unsigned int buffer;
    int i,j;
    int length;
    
    buffer =get_axel_data;
    i=0;
    while(buffer>0)    //stores the equivalent character values of the integer place, but in reverse
    {
        data_holder[i++] = '0' + buffer%10;
        buffer /= 10;
    }
    data_holder[i]='\0';
    length = strlen(data_holder);

    for(i=length;;i--)
    {
        data_array_proper[counter]= ((unsigned char)data_holder[i]);
        counter ++;
        if(counter==512)
        {
            WriteMMC(current_addr,data_array_proper);
            current_addr = current_addr + 512;
            for(j=0;j<512;j++)
            {
                clear=0x00;
                data_array_proper[i]=clear;
            }
            counter=0;
        }
        if(i==0) break;
    }
    return counter;    
}

No comments:

Post a Comment