Posts

Showing posts from February, 2018

Dreamy diaries

/* Below is a fictional story without much explanation or context. Currently its gist of some ideas that I had. Read at your own risk. Suggestions are welcome. Grammar Nazis are most welcome with suggestions. */ Life is tough these days. A plague has spread and people are missing each day. The good thing is I am safe and sound, working, making plans for future. .... I just interviewed for a company and got selected. Felt like I made a good decision as I got unexpected hike. Things will be in my control from now on. ...... first day and I was expecting someone to come and introduce me to the team or give some information about the work. I am Sitting at a place whole day , looking frantically same faces again and again. ...... I am at the company looking here and there, and feeling it's been days I have seen any microcontroller at any place . Is it an embedded company? .... There is a big desk where the manager sits and I am about to go and ask him few detai...

device tree overlay for adxl345

experiment1: exporting device tree overlay and getting probe function called. took this one as an example /home/nikhil/bbblatest/bb.org-overlays/src/arm/BB-I2C2-00A0.dts changed last lines as // commented out example of a touchscreen (taken from BB-BONE-LCD7-01-00A4) */ adxl345@53 { compatible = "adxl345"; reg = <0x53>;//chip ID of adxl345 //interrupt-parent = <&gpio4>; //interrupts = <19 0x0>; //atmel,irq-gpio = <&gpio4 19 0>; }; }; }; }; renamed as BB-I2C2-ADXL-00A0.dts compiled overlay as dtc -I dts -O dtb -o BB-I2C2-ADXL-00A0.dtbo -b 0 -@ BB-I2C2-ADXL-00A0.dts (before compiling i checked my dtc version, that was old. So updated from this directory/home/nikhil/bbblatest/bb.org-overlays and run dtc-overlay.sh. Now version is Version: DTC 1.4.4 ) copy the dtbo file in rootfs/lib/firmware folder booted the board with sdcard. cd /sys/devices/platform/bone_capemger then cat slots ...

Git useful commands

git commands 1. Initialize the local directory as a Git repository.     git init 2. Add the files in your new local repository. This stages them for the first commit.     git add . 3. Commit the files that you've staged in your local repository.     git commit -m "First commit" 4. Create a repository at github account 5.In Terminal, add the URL for the remote repository where your local repository will be pushed.     git remote add origin remote repository URL 6. Verifies the new remote URL     git remote -v 7.Push the changes in your local repository to GitHub.     git push origin master 8. if too many old untracked files are seen in git status then do this,     git reset --hard It will make git repo to last commit state.

c musings

Some of the corner case are discussed in below links fgets and char *s 1.fgets and char *s why we should use wrong way, char *s; fgets(s, 6, stdint); right way char *s; s = malloc(sizeof(s)*5); fgets(s, 6, stdint); or char s[10]; fgets(s, 6, stdint); 2. Why casting malloc is not a good idea Malloc and casting  Also using malloc like this char  *s = malloc ( sizeof ( char ) * 5 ); is not good. Instead use it this way, char *s = malloc ( sizeof ( *s ) * 5 ); for portability. if the type of s changes from  char to, say, float.   malloc( sizeof (*s) * length );   will work regardless of the type. Reasons for not casting is, 1.It is unnecessary, as void * is automatically and safely promoted to any other pointer type in this case. 2.It adds clutter to the code, casts are not very easy to read (especially if the pointer type is long). 3.It makes you repeat yourself, which is generally bad.