The xpcc microcontroller framework

Video thumbnail (Frame 0) Video thumbnail (Frame 640) Video thumbnail (Frame 1849) Video thumbnail (Frame 2466) Video thumbnail (Frame 3952) Video thumbnail (Frame 6620) Video thumbnail (Frame 7115) Video thumbnail (Frame 8625) Video thumbnail (Frame 9602) Video thumbnail (Frame 10693) Video thumbnail (Frame 15082) Video thumbnail (Frame 16242) Video thumbnail (Frame 17491) Video thumbnail (Frame 18285) Video thumbnail (Frame 19288) Video thumbnail (Frame 20509) Video thumbnail (Frame 22042) Video thumbnail (Frame 22585) Video thumbnail (Frame 23579) Video thumbnail (Frame 24525) Video thumbnail (Frame 25352) Video thumbnail (Frame 26024) Video thumbnail (Frame 28997) Video thumbnail (Frame 30263)
Video in TIB AV-Portal: The xpcc microcontroller framework

Formal Metadata

The xpcc microcontroller framework
An efficient, object-oriented approach to embedded software development.
Title of Series
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date

Content Metadata

Subject Area
This talk introduces the xpcc framework for efficient object-oriented programming for micro-controllers. Originally developed by the Roboterclub Aachen e.V. for the Eurobot competition, xpcc became a separate project in 2009 and since then focussed on a new approach to cross target microcontroller libraries. It stands out for its extensive use of static C++ classes and templates which is unusual in this field, but lends itself well to the static nature of embedded development. The main goal of xpcc is to provide a simple API which is efficient enough to be deployed on a small ATtiny, yet powerful enough to make use of advanced capabilities found on 32bit ARM Cortex-M.
Computer animation Cellular automaton
Web page Computer animation Multiplication sign Right angle Bit
Web crawler Code State of matter Similarity (geometry) Device driver Microcontroller Mereology Mathematics Computer hardware Energy level Object-oriented programming Data structure Computing platform Task (computing) Identity management Personal identification number Multiplication Algorithm Cellular automaton Interface (computing) Line code Bit Cartesian coordinate system Kernel (computing) Computer animation Computer science Right angle Communications protocol Writing Library (computing)
Functional (mathematics) Computer animation Interface (computing) output Energy level Microcontroller Function (mathematics) Black box System call Form (programming)
Area Code Multiplication sign Interface (computing) Serial communication Microcontroller Bit Measurement Subject indexing Computer animation Software Logic Robotics Software framework Freeware Compilation album Social class
Group action Functional (mathematics) Game controller Run time (program lifecycle phase) Observational study Code Multiplication sign View (database) Set (mathematics) Device driver Usability Template (C++) Bit rate Computer programming Error message Compilation album Physical system God Personal identification number Algorithm Interface (computing) Expression Interactive television Inertialsystem System call Compiler Computer animation Personal digital assistant Network topology Calculation Computer science Configuration space Communications protocol Resultant Green computing Spacetime Maß <Mathematik>
Emulator Computer animation Interface (computing) Multiplication sign Bus (computing) Device driver Bit Computing platform Social class Physical system
State observer Run time (program lifecycle phase) Surface Interface (computing) Black box Product (business) Fluid statics Mathematics Message passing Computer animation Software Bus (computing) Pattern language Diagram Social class
Crash (computing) Game controller Message passing Word Computer animation Peripheral Semiconductor memory Limit (category theory) Social class Physical system
Scripting language Addition Game controller Computer animation Peripheral Computer file Information Semiconductor memory Device driver Maxima and minima Physical system
Computer animation Computer file Code Software developer Social class
Scripting language Computer file Software developer Gender 1 (number) Device driver Heat transfer Template (C++) Computer animation Peripheral Computer programming Text editor Quicksort Physical system
Game controller Group action Software developer Data recovery Electronic mailing list Device driver Bit Line (geometry) Food energy Computer animation Term (mathematics) Right angle Descriptive statistics Library (computing) Physical system
State of matter Multiplication sign Device driver Water vapor Branch (computer science) Food energy Theory Strategy game Computer programming Resource allocation Traffic reporting Computing platform Predictability Gcc <Compiler> Software developer Projective plane Electronic mailing list Bit Limit (category theory) Compiler Word Computer animation Triangle Right angle Window Row (database) Library (computing)
Functional (mathematics) Overhead (computing) Computer file Divisor Code Multiplication sign Set (mathematics) Device driver Computer font Template (C++) Fluid statics Virtual memory Semiconductor memory Term (mathematics) Internetworking Computer programming Core dump Electronic visual display Codierung <Programmierung> Data compression Mathematical optimization Social class Stochastic process Scripting language Boss Corporation Email Arm Assembly language Information Forcing (mathematics) Surface Bit Virtualization Line (geometry) Instance (computer science) System call Entire function Arithmetic mean Order (biology) Configuration space Right angle
yeah without a cell
without is if this then this is they have in and rare this how you and say I'm just to
make sure the well on the right page brand name mn the well then end end of well yeah here from the Robotics Association nd beautiful said if I end which is very rainy sometimes and endo here to do this time theL this love and and Niamh data this sublinear men this is he he he tho Sal now this 1st chapter the little bit above my life and
thats cell and January on embedded at the end of the cell from my dope so this extremely low level and then this is essentially my story so I had a new microcontroller it's are some nice thing then I can now I'm ready to take the next step and sell at the other end tasting and high yeah threatened of and then this new microcontroller comes along with new features and the same thing happens again have crawl through all this documentation and am I write some code and essentially what I've done is I've express the same task in different code and this is obviously that stupid because as a computer scientist you're like to not work at all preferrably and so the motivation here is to put preferrably right identical code for multiple microcontrollers and if you've read through a lot of microcontroller documentation you find out that there are a lot of similarities between microcontrollers and essentially compiled all of this into a an ice library and added
some goodies like object oriented features and you know it's written in C + + and you can write almost identical code on multiple targets so let's talk about the structure of that were 1st going to pH where we're not gonna go and tell you the API because that's really boring instead I'm going to talk a little bit about concepts and explain in someone line code examples how we actually implemented that and 1st of all we're going to talk about concepts and the interfaces of extra PCC and then we're going to talk about how we use these interfaces to write drivers for external hardware this is low level so it's not so don't confuse this with Linux kernel we're actually talking about low-level stuff here and then Kevin is going to take over to talk a little bit about the magic behind all of this horrible system and about the current state and the future work so there is a lot in next piece C and that we're not gonna talk about I personally think of it in 3 parts as so we have very generic that can run on pretty much any platform without any change to the code as such as root-finding algorithms matrix multiplications uh by the workflow stuff them and then protocols as well communication protocols and then we have uh things where you need to kind of know what tend to connect to What other pin so it's more hardware uh near and obviously our peripheral interfaces which we're going to talk about and then there's the part for low-level axis we actually have to look in the data sheet and the access of registers and we're going to talk about these 3 lower layers In particular the independent peripheral interfaces so
let's talk a little about about how microcontroller looks like that so it looks like it's a black box with lots and lots of friends and for some reason he spends must be there so I could assume that they're used for some sense of intelligent input output and yes that's true so all in general we can say that every
microcontroller has at least this functionality you have some form of input you can read it will return a 1 or 0 depending on how you configure whether it's level low level and you can do the same by setting an output and this should actually be satisfied that every thing's target out there and this is the 1st example of such an interface which you can do on every microcontroller so the traditional way of implementing this this using a function call where you do all this functionality
serial and module a microcontroller you need to connect to the outside world and you can do that in the in class so we have this nice connect method which we get free checking at compile time so you know it works even before you apply that to your code of course you never know if it if you if it works because you're not a good programmer in general but there cool bonuses you know what you did because it's there new code you don't need to write a comment is there in your code it works there's no other way so this
is this GPO interface is available on all these targets the ecstasy framework works on the outer tiny 1890 atom index measure of love love and also on a that might controls and on 32 bit microcontrollers which is actually quite neat and if you apply the same logic of finding the most common interface is the most common code for all these interfaces you can see that there are a lot of interfaces which all these microcontroller support so i squared see that the serial interface obviously you have SPI and something that we use to communicate inside a robots control area network which is also used in cars and the let's talk a bit about
our relationship here for a 2nd so I a computer scientist but I study Computer Science and the studies Electrical Engineering and I come back I come from in human-computer interaction background and I'm always bickering about usability and he's always about going on about efficiency and that's essentially what we end up with so I want to tell the system what I want and I don't want to look up the datasheet and find out exactly how to do it because I am lazy and I'm going to explain to you what I mean by that this don't do this just please for god sakes don't do as ever like I have no clue what the botrytis in fact you force me to do this to go through all of these documents to find out what the system clock rate is that much of currently running find out how the algorithm works and I still have no guarantee that this actually works so this is a bad idea in general the solution to the sisters to compile is to to calculate the settings at run time and that's OK but you have no way of knowing whether the value that actually results in this is actually the value that you put in there so for example in this example it's not about trade that's in your code it also waste time you know because and space it so instead what we do in pieces C we move the calculation to compile time using template magic and France expression functions and that still doesn't exactly solve the issue of the of the of knowing whether that value x she is the value that you get out but at least it's efficient because the only thing that is stored in your program court of of the actual register values that you can copy into the register at runtime the and it does some basic checking and like whether it's even possible if you have a very low bar rates the prescaler might even under were very high population might be and on on on the independent and you don't need to open a datasheet because the intelligence is actually in the function call and it's as I said it's doesn't solve exactly the issue of of knowing whether this is the value that's why we added a tolerance so you can discuss back to the to what I said you can be clear I want the spot rate and I want this exact tolerance and if this is not achievable on the compiler will throw you a warning when error action there and you can see that in the compiler calculates the nearest possible about reducing the current configuration of the clock tree of the the prescalers and it will give you to it's not as beautiful unfortunately because in general template errors in C + + compilers are not beautiful and that it's better than nothing that's what we get and so that's that was an
example of of how we think about these interfaces and so I might be asking yourself why do we use these interfaces in any case and obviously as I said my controllers have a lot of pins and you generally want to connect something to these pants and in this case it's an inertial measurement unit and the question is can I write this driver to be platform-independent through view of things yes raise your hand OK that's too little people so yes you can because you you must think in protocols this is the this is defined protocol it's a distinct chip and you can write it platform-dependent driver because we already have these interfaces they
speak these protocols and um you can build your harder drivers on top of each other and that's exactly what is done in next sissy this is essentially what we've done so you have your there you have 3 devices on the ice bus and they only talk through this interface and the driver doesn't care whether on what platform it is because the interface is always satisfy the same way in fact you can even write a softer emulator which then uses the G bio classes to be truly platform-independent so that's what we've done so we don't have time to talk about this but there's a at a checkpoint bonus the entire API is 1 of the entire the piecewise C is non-blocking on public based so it's really fun to write these drivers and now
can and will talk a little bit about the real system the smarter than I am it was Minnesota let me go on and just take it from work in the class last year and while we are
on the ballot back to the black box again and as an electrical engineer and make some of observations I can see that they're all those patterns and those things don't change once the chip but use so that's what I call static nothing changes during runtime or in your product and also the global under the
surface you see this is what diagram of nest retrieved and you can see the most different at interfaces so of connected to a bus and they don't change you don't get at interfaces or they don't do it I'll they believed the chip during runtime so what I'm getting at is that we want you can model this in our software and what comes to mind when reusing the passes using static classes so classes that only have studied methods that had only in that only have studied members have and what this gets us is that the world but we're getting at with this is that you have all those that
peripherals and we want to generate a
class from any 1 of those so now I say well this is a lot of things to do and I can just not just have 1 your class and then give a deep index and say that you create a new word you 1 and what this is the limit of a problem because you got that you're running my control so there's no way to report on a regular system you can just under like doing so program crashes and there's no message or whatever but in my control you have no no good way of telling the user what there's something wrong so the user creates a you or with wrong idea that it will just not work and you don't know why it we have a class for every you or you can only use the classes that are provided and also is a little more efficient to use the classes because you will never have to calculate any offsets in memory so
now and we know that we want to cluster at the periphery that there are certain problems 1 is that we need to know for each device that we support for it every my controller has different peripherals so we need to know a lot of proposals supported in our device and that's what we're that's why we came
up with the maximal device files and what you can see here is that we get the file for an entity of literature of those 7 is the variations and attentional as what kind of memory the device has and working peripherals that use we actually creating those that's not files through a process of for us script that we wrote from the manufacture information so that's pretty easy to get that and you can also just by hand if there's a problem of that and then she received that we had the peripheral it it has you are and that tells the whole system to search for you a driver and the you driver has an additional XML file that tells you unintelligible system what the files it needs so now we gotta run another problem
but we're all developers role lazy and we don't want to write a duplicate code like I said we would like to have like 1 basic plate and use that to regenerate all the you or classes for example and that's what we do we
get all those in 5 with our template files and we generate all the U. of yours that we need and to do this using the
gender to template and which come from the development but it fits our of the thing that we need quite quite neatly and also 1 could think that we can do is we can check that kind of target rebuilding describe for so for example if 1 manufactured only uses the same peripherals for every controlled adipose out but they change a certain that was sort of things that for example they renamed the data adjusted to transfer data sort the editor transfer data adjusted for the as 0 and f 3 which actually the newer ones as you can do checking and see which can renewed so we don't need to write a whole new driver for then we can just do some basic in in in the template and so
on the system is based on strong switches the business and the runs file with Python as so it's easy to extend we have a lot of custom python scripts that the dual of this that the do look out for you that the generator drivers for you and it got it text-dependency tendencies if you change a template file and you have the stance this construct you program again you you know we mated with that is constructed or whatever and so when you do that it it did realize realize all the template that has changed so I to regenerate all this header and see the and compile them again so that was quite neatly and so
when we want to do that for a long term we wanna like further and generate the whole list this you library hot right now we're just generating the peripheral drivers but we want like made it possible to have a lively description then select all the drugs that you want to see in there like all those different layers that recovery of our library and you might wanna have all of this new library and you can get a constant library and it also fits in better development right neatly because with my controllers what's that what you want to have this for some companies they have their custom-built system so the way
using these you the possible system was during all this simply stuff of all those thousands of line of Python we cannot do you can just use our own library but if you do this they generate the everyone's and then the action user with their possible system and also as you can just put is apologetic in internally and I think that that's the way and that the energy from my control so it's a little bit more and nicely but in the meantime there's some
more of that in new triangles that would be great if any 1 of you ever like once a look at the sissy maybe use your project and related that started is to get 1 of them was assumed 32 of in all 3 discovery records theory that you can get a pretty from from its T and we have good support for them you can just check out sbcc examples that go into folders up you war many of the examples that you can just use and you can just use guns program and just look at the current you water as it is about we need to improve our documentation if ever ever in 1 you ever had a look at a library and says well OK that's neat but it took me a long time to find out if you want a write was about it or whatever we can always include that in our documentation also if you're getting started with their expertise you don't know what to do anything to do with me right NIC driver and and uh maybe do pull request for final meaningless and say that a decisive allocation you integrate and we always have to do that also if you wanna and you that you have 1 of the simplest example you want and advanced feature just go ahead and have a look at the other peripheral drivers and the fact that you yourself but you can also just as much as a limiting the the that's the problem of the problems and also there is this is you can be ported to new platforms almost like on any platform that has the GCC compiler you can get around in the easy or g because of course compiler and another there's some support prediction 28 any 1 of you working that we have a branch of called like back that it's not in the good state but there is a little bit of support for the k 20 and also support for L of C is the diluted but there's not much for the apple on devices and for energy for their should all be possible so if anyone is interested but said well I don't like the the STD vices or whatever is not that hard to forward and you will be happy to support you last
that's what we have right now we supported limits and that was successful so so as you wanna try another strategy you run on Windows but nothing anyone you here's really no and you look words that will yeah introduced got reports work best and that see we that we have 1 of the subordinated just ignore examples and see what kind of course remain there is 1 that the wars were pretty well and we don't have any any of we know about that this opportunity also should be pretty easy to run an ongoing aboard the idea you can check us logic as other reliably on get out or just right in the middle or a development list always happy to answer any questions you have right this thing here has 2 questions that they use the 1 in
already had the 1 used in the 1st year of now and then and then if some of the manufacturers reset itself so you want see so we can have so that the ideal and achieve the the idea was to write these divide these device fonts by hand and that's why they're very simple but if you have two hundred devices this gets kind of tiring so I found some obscure and files on the internet that describe these things in memory mapping and stuff and then I just wrote a Python script that gets all this information out compresses the little time and then you can have these compressed nice device was not compressed in the sense of compression but it aggravates the information and puts displays of nicely so be it how is it called so we're that's nice because you don't have to know because we give you the device for us so there's no licensing problem and an yeah mean we generated them you know you have we use the the the file of from the with the the the layout of this so if there if there is something in the header file on a in the in final use schools that doesn't exist it is all so you just know this yes it was in this uh to the class 3 class to class you see you realize so using this this you yes and it was yes of the yes and I guess I anticipate that question and you can buy so what do we compare different ways of of doing stuff on for example what I do when I start with a new driver I just wrote that in an edge in a drive for instance and I would did forces I wrote everything to register so that that sector this knowledge that you can get to encode size and stuff that all precalculated just right and what I did then is I added like 3 methods to configure DNA because of would be useful to have that general configured then connect to sort saucepan interesting so what it does then it did it would uh that every method that is on his own so what has to do that you 1 configuration register so every other than that of course offered 1st population you guys aren't you gotta read back to configuration adjusted then just change about demand and by back so there's a little bit of a random process and for example and I would add a 65 bytes that limited by what you have is that is that and the critical surface where the things that are called by a lot of time for example if you and set in but nodes to go to the set and the set and that actually just composer but it's it's uh we would love stuff and files which does not necessary benefit compile-time but it's not that much so it doesn't really matter uh and and so what you get for example and 80 you just get a simple assembler command the just the sets you're more high so it's this is this is a little bit of overhead compared to value which your himself but which is a ridiculous for those big devices but if you compare for example true as it was that that we that doesn't use the term optimization our stuff is mostly not most of the time spent the user letter of static stuff like templates and we we try to use all of that will like our code and it will or not people and to translate that essentially we we use static stuff so there are we try and think about function calls so so as it has a set of most of the code and header files and we do aggressively inline manually so for example if you only set up a bit and the register the entire function is in line because there you can do a function call in less than it doesn't work so we we we have to manually optimize this sufficiently so that we do use certain features in C + + that's our an overhead for example virtual function calls which are to I think to do references on an ARM core but on an AB or there more calls because the boss is smaller than the addressing so there are certain things that you need to know in order but it's still it's still a a compromise between suffer engineering and efficiency but compared to traditional C programming it is actually quite efficient so we don't do like over we don't do new you don't allocate memory just because we need a new class it is there that's I think the most important stuff so we have to have the right a of yes