Last week, I talked about how I was able to run STORE and LOAD related functions which are methods of JavaScript Objects. Maybe I have not explained this part very well, so, I will review it first. I have added methods to an object from which all modules objects inherit. Thus, these methods will be shared among all the modules. Let’s say we have only two methods declared in our objects, store() and load(), which are defined accordingly:

store(data){

// store data

}

load(){

// load stored data

}

These two methods can be called by all modules objects. Thus,

uart.store();

mspi.store();

lcd.store();

All of the three previous commands call the same store() function, also,

uart.load();

mspi.load();

lcd.load();

All of the three previous commands call the same load() function.

This is because all of the modules inherit from the same object where the functions store() & load() were defined. However, we can override these functions if we define them inside the module object itself. For example, let’s define the following inside UART object:

store(){

// store data into UART buffer

}

Now, if we call the following:

1. uart.store();

2. mspi.store();

3. lcd.store();

When the 2nd and 3rd commands are called, the first defined store() method which is in the parent object will run to store data, however, when the 1st command is called, the second store() method which is defined in UART object will run to store data into UART buffer. Thus, store() method of the child object has overridden the store() method of the parent.

Now, my next task is to make UART Demo to ensure the simulator I have been working on during my internship is working as expected. This can be done by defining STORE & LOAD related functions that simulate a real UART inside the UART child object. I have not done this task completely yet. Thus, I will talk to you about it next week. Stay tuned!


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.