![stm8 cosmic interrupt example stm8 cosmic interrupt example](http://www.emcu.it/STM8/STM8-Discovery/InputWithDebounce/main.png)
This function has the important functions for the SPI communication on the STM8S. The next function “ SPI_setup(void)” that is mentioned above is a non-returnable function and can be used to initiate the SPI communication. This delay_ms() function can take one parameter as integer that is representing the delay in milliseconds. The _asm(“nop”) can be used to instruct the microcontroller not to perform any operation. You can find two nested for loop containing another function “_asm(“nop”)” inside the delay_ms() function. The function “delay_ms()” that is mentioned above is used to provide delay in milliseconds within a task. Void delay_ms(int ms) //Function Definition In the “stm8s103_spi.h”, the header file has three functions for the SPI communication. Instead of discussing each of and every function in the stm8s_spi.h header file, we are going to discuss the important functions which are being used in our “stm8s103_spi.h” header file. The predefined functions for the SPI communication can be found in the “ stm8s_spi.h” file. The “ STM8S.h” file contains the definition of the “ stm8s_spi.h” header file and the board configuration of the STM8S development boards. Now, let’s get into the coding part.Īt the beginning of the stm8s103_spi.h file, we have included the “ STM8S.h” header file. You can refer to the “STM8S Standard Peripherals Library” manual. You might be wondering about the other header files in the picture. I have created two important libraries to ease the SPI communication on the STM8S. Now, let’s see what is inside the libraries.
#Stm8 cosmic interrupt example how to#
In the first tutorial of the STM8S, we have already discussed on how to add the include files (can be found in the “ inc” folder) and the source files (can be found in the “ src” folder). Once you have done the setup of your project workspace, you should have the following header files under the “ Include Files” folder that I have marked with red circle in the below image. I hope you have gone through our first tutorial on STM8S where we have discussed on how to setup the project workspace. We are going to use the Cosmic C compiler along with the SPL libraries. Go to the “T8_SPI_Communication_on_STM8S_using_Cosmic_C_Compiler” folder which can be found in the downloaded repository.
#Stm8 cosmic interrupt example code#
You need to download the complete code files from our GITHUB repository of the STM8S tutorial series. So, I am not going to discuss about the theory part of the SPI communication. We have covered the SPI communication with different types of microcontrollers so far.
![stm8 cosmic interrupt example stm8 cosmic interrupt example](http://benryves.com/images/stm8s-discovery/tsl_io_alcode.png)
Before getting started with the SPI communication on the STM8S, you need to make sure that you have the basic understanding on how the SPI communication works.