There goes another week. Task for this week is quite similar to last week’s, I was asked to write a MSPI driver. Before I started, I had no idea what it is and what does it do, so I was waiting for my supervisor to fill me up with all the necessary information to carry out my task. However, I was asked to look up the information by myself instead. I was a little taken aback when I heard that, but later I realised that I actually should develop the ability to carry out my work independently, rather than just waiting for step-by-step instructions! What a childish and stupid thought I had!

Alright, let’s talk about the MSPI driver that I have implemented. Basically, Serial Peripheral Interface (SPI) is an interface that enables the serial (one bit at a time) exchange of data between two devices, the Master and the Slave(s). There are three bus lines, which are MISO (Master In Slave Out), MOSI (Master Out Slave In) and SCK (Clock) respectively. Obviously, the SPI driver that I had to implement was the Master device and the registers involved were the data and status registers. Among all the functions that I implemented, xferMSPI() was the most significant as it allowed me to write to the data register and then read from it after checking that the status register was not busy. Thus. the Master device will be able to send data to and receive them from the Slave device. Later, I included a few functions (begin(), end(), setBitOrder(), setClockDivider(), setModeData() and transfer()) so that my program is compatible to Arduino. During the implementation of this task, I have learnt a better coding style which is to replace most of the  functions with inline functions in order to improve the efficiency of my program. Also, I have learnt and understood how to use “volatile” and “const” keywords properly.

My task for next week will be more challenging as the program that I  have to write will include inline assembly  as well, which is something that I have not tried before. I hope I will not spend too much time on it so that I have extra time to start writing a small program using assembler codes that will be used for simulation.