2020年5月13日 星期三

Conference note: Linux I2C in the 21st Century - Wolfram Sang, Consultant / Renesas

This conference is intent to brief overview what't new in Linux I2C subsystem.
I found some interesting part of the I2C subsystem of the latest linux kernel:


  • The API i2c_dummy_device() for I2C device have more than one slave address.

Declare a dummy I2C deivce share same device but different slave address

  • Recommend new API to create I2C device: i2c_new_ancillary_device()

  • Dynamic address assign : In same I2C bus and dynamic detect what address should use.


I2C has been widely used in industry for decades and has some enhance feature like have multi slave address or dynamic assign address of slave in the same bus,
 bring lots of challenge for developer and Linux kernel provide some new API for more generic driver development.


Further speaking:
I3C is the next generation serial bus to replace I2C but I didn't saw much application  right now.


Reference : 
  1.  Linux I2C in the 21st Century - Wolfram Sang, Consultant / Renesas
  2.  I2C and SMBus Subsystem
  3.  I3C 



2020年5月12日 星期二

Machine Learning Foundations: Exercise 2 Handwriting digit model with 99% accuracy

Exercise 2: Handwriting digit model with 99% accuracy:code lab link
Write an MNIST classifier that trains to 99% accuracy or above, and does it without a fixed number of epochs -- i.e. you should stop training once you reach that level of accuracy.

Code:

Result:







Machine Learning Foundations : Exercise 1 House Price Question


Exercise 1 : House Prices Question : code lab link
Build a neural network that predicts the price of a house according to a simple formula, house pricing was as easy as a house costs 50k + 50k per bedroom, so that a 1 bedroom house costs 100k, a 2 bedroom house costs 150k etc.

Training data set
Bedroom amount [1, 2, 3, 4,]
House price [100, 150, 200, 250]

Code:

2020年5月6日 星期三

Octave: Read data from csv file.

Octave/Matlab can read CSV file and do some processing or plot the data quickly and easily.
Below are simple codes that read a CSV file and make some parse.


1. Read Sample_Data.csv file and stored as char array:
    char = strsplit(fileread ("Sample_Data.csv"));

2. Simple parse: Iterate each element and skip first 5 column data

    for i = 1:size(char,2)
        result(i,:) = char((10*i)-5:(10*i));
    end





Ref:

2020年3月11日 星期三

How to get main() function return value in Linux terminal.

Sometimes we want to get the exit value of main() function, using the "echo $? " can get the most recently program exit value.

Example program:



Result:



Reference:
  1. UNIX Shell Programming 

2019年7月12日 星期五

C : strrchr() analyze and example get self executable directory function.

strrchr() function will return a pointer to the last occurrence.
Another example is modify from Advanced Linux Programming chapter 11.We can get a sub-sting without the occurrence with sub two pointer.





Ref:
   1. http://www.cplusplus.com/reference/cstring/strrchr/
   2. Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham, and Alex Samuel www.newriders.com

2018年12月18日 星期二

Keil C: Warning: #1296-D: extended constant initialiser used"?


The root cause is miss use a pointer to a static variable like:

int x = 1;
int y = (int) &x;

Modify version

int x = 1;
int *y = &x;

printf("%p\n", &x);  // memory address of x
printf("%p\n", &y);   // memory address of y

printf("%p\n", y);     // y = memory address of x
printf("%d\n", *y);   // *y = memory content of x  = 1


Addresses are not arithmetic types in ANSI C spec, so if need to get the address of a static variable, use a pointer point to the variable's address.







Ref :
 1. http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15182.html
 2.https://openhome.cc/Gossip/CGossip/Pointer.html

Linux driver: How to enable dynamic debug at booting time for built-in driver.

 Dynamic debug is useful for debug driver, and can be enable by: 1. Mount debug fs #>mount -t debugfs none /sys/kernel/debug 2. Enable dy...