 Rhaid i'w ddweud y ffordd yn ystyried, felly mae'n edrychwch ar y ddweud. Felly y ddweud yma maen nhw ydweud y freartos cyfnodwch ar y prosiect. Rhaid i'w ddweud hynny, mae'n gweithio'n dod yn fawr o'ch mwynhau'r bwysigol cyfnodwch ar yr arfer o'r ffordd o'r ffordd o'r system. Why are we using anarthos? The benefits of using anarthos means we can make the design more modular. It's very good if the parameters of your project haven't been completed. It's also very easy to add and remove functionality if you decide it's no longer important. We want to use the anarthos so that we can add more functions, as we add the FATFS, the text on the LCD, the push buttons. We can add all these things as one-off individual sections rather than having to modify a big list of code. It's available to us. We can do it. For this particular example, we have far more flash and RAM and performance than we actually need from the device. This particular application is not really going to push the STM32-L4 to its limits. We're just using it so that we can show you how to develop an application using the freearthos within the CubeMX environment. Some of the basics of anarthos. Conventional code would be a linear bank of code with a switch statement doing all the various functions. Each of those tasks in the switch statement are now classed as an individual thread or task within the arthos. Each of these arthos will have their own small amounts of stack. Each thread will have its own small amounts of stack available to it. Each of these will have their own routines and own while one loops inside. Some basics on the arthos. We have different modes. We've got thread mode and handler mode. Every time each task finishes its time perimeter it's been assigned, it then moves on to the next thread. You can set things so that they wait for other threads to be actioned as and when they're needed. You can play around with the functioning and signalling and messaging within the arthos itself. A signal is a way of sending one bit or a condition from one thread to another thread. If you want to send more information then you can use a message so you can send a full 32 bit value between different threads that are in the system. The final way is you can use mail or a mailbox and that means you can send a whole block of memory between different tasks or threads within the system. There's different ways of transferring information between each of the different tasks that are running in the whole application. Quick introduction to how it sits. FreeArthos is bundled inside the Cubimx. It's usually the latest version that we've ported to the STM32 and every time we update the libraries of the Cubimx if there's a newer version of FreeArthos we'll add it at that point. Normally your application code will sit at the top and your main code will go through into the arthos in one direction, interrupt and manage slightly differently in the Arthos API commands. They are taken care of slightly differently so that you don't lose the benefits of an interrupt-based system just because you're using the Arthos. There's two more very useful documents that we have. There's the user manual 1722. It shows you about developing applications using the Cubimx and then there's the FreeArthos website as well. There's lots of information there on the freearthos.org website. Back to our cube environment now. We're going to add the FreeArthos to our project. To do that we can do it from the configuration tab and enable the FreeArthos. If we go back to our cube project and I'm already in the configuration tab I'm now just going to enable the FreeArthos and you'll see it's now appeared as another middleware available to us for configuration. We'll now go and configure the parameters of the FreeArthos. In the config parameters tab we need to set the heap size for our application to 32,768. If I go into my cube FreeArthos and configure parameters and if I scroll down to my total heap size I need to change it from 3000 to 32,768. Apply and then so now we need to add some tasks and queues so we need to select the tasks and queues tab first we need to modify the default task so this will then become our app task. It will have a priority of normal a stack size of 4096 and the entry function will be app task body. If we go back to our tasks and queues tab in the cube we want to modify this one so you need to double click on default task so we're now going to change the name of that to app task priority is normal our stack size is 4096 and our entry point is app task body and capital B for body and then we can okay that so that's our default task amended to become our application task. We now need to add a new task which will be our usb task so again we fill in the various parameters stack size for this one will be 256 the priority for this one will be high and the entry function will be usb task body so if we now go back to our cube we want to add a new task so it's called usb task with a capital T our priority is going to be high our stack size is 256 and our entry point will be usb task body with a capital T under capital B in task and body so there we go so we've now got two tasks added to our freeartos settings so there we go so this is what you should now have in your freeartos so we now want to generate our code again but again do not open the project until we've done the patch to add all the actual application parts of the code so I need to go into my IAR that I had originally and close it first and now I want to OK that and project generate code so there's a warning message being brought up by the cube environment telling you when freeartos is strongly recommended to use the hal time base other than the sys tick do you want to generate code so we're going to say yes because the whole point of using the sys tick is so that it doesn't use a resource on the device itself so the sys tick was specifically designed for running OSs the reason why cube is warning you that is because you have no way to change the value of sys tick so it is a fixed duration whereas if you went to a normal time base then you were able to control the duration that you put into the freeartos but we're happy to use the sys tick so we will say yes to generate code and as we said earlier we don't want to open yet because we need to apply our patch so I'll say close to that and again we need to add some source files which contain all the various elements that we are using the freeartos.c with all the contents in there to do the control of the freeartos the usb control because we've now added a usb task into the freeartos and because we're using the sys tick now to control the freeartos we are making use of the interrupt for the sys tick timer so those are the three files that we need now need to patch into our created project so if we go into our project so section 2 the patch this is the artos section so there's the three files that we need to select and they now need to go into our audio player source file paste those in there copy and replace for all of them and that is created so we're now going to our eWarm and launch our project EWW