Last active
February 5, 2019 07:37
-
-
Save parthibx24/5d50ae284315d5e56125f470b4536223 to your computer and use it in GitHub Desktop.
Author: stevenhoneyman (http://www.stevenhoneyman.co.uk/2015/02/reconstructing-mtk-lcm-drivers.html)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Author: stevenhoneyman (http://www.stevenhoneyman.co.uk/2015/02/reconstructing-mtk-lcm-drivers.html) */ | |
| #include <stdio.h> | |
| struct LCM_setting_table { | |
| unsigned int cmd; // 4 bytes | |
| unsigned char count; // 1 byte | |
| unsigned char para_list[66]; // 66 bytes | |
| // total size should be 71 for xc_rm68200 lcm | |
| }; | |
| void print_hex_array(unsigned char *arr, int count) | |
| { | |
| int i; | |
| for (i=0; i<count; i++) { | |
| printf("0x%02X", arr[i]); | |
| if (i<count-1) printf(","); | |
| if (i>=66) { | |
| printf(" *** BAD DATA *** "); | |
| break; | |
| } | |
| } | |
| } | |
| int main(int argc, char **argv) | |
| { | |
| int c, err; | |
| FILE *ptr_file; | |
| struct LCM_setting_table lcmdata; | |
| if (argc<2) { | |
| printf("Usage: %s <filename>\n", argv[0]); | |
| return 1; | |
| } | |
| ptr_file=fopen(argv[1],"rb"); | |
| if (!ptr_file) { | |
| printf("Failed to open file\n"); | |
| return 1; | |
| } | |
| fseek(ptr_file, sizeof(struct LCM_setting_table), SEEK_END); | |
| rewind(ptr_file); | |
| while (fread(&lcmdata,sizeof(struct LCM_setting_table),1,ptr_file)) { | |
| printf("{0x%02X,%d,{", lcmdata.cmd, lcmdata.count); | |
| print_hex_array(lcmdata.para_list, lcmdata.count); | |
| printf("}},\n"); | |
| } | |
| fclose(ptr_file); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment