Toradex WinCE Libraries' Evolution: The New Library Approach Explained

Tuesday, November 8, 2016
Further information about our libraries including demo application downloads can be found in our developer center.
Overview
WindowsOver 10 years ago, we wrote some small pieces of WinCE code in order to demonstrate different features of our computer on modules (CoM), or system on modules (SoM); for example: GPIOs, I2C, Analog Inputs (ADC), etc. With the pure demo purpose in our minds we didn’t pay attention to things like maintenance, compatibility across different modules, etc. However, these demos were used by a huge Windows Embedded Compact customer base. We received more and more support and feature requests which we then started to integrate into the demo code. As a result, we got the library package for our PXA and Tegra® based SoMs as it exists today. These libraries are a reliable and easy way of using our modules. But it wasn’t an easy way to get there with the many maintenance iterations and bending the API to make use of newer features.
When we added newer processors (system on chip or SoC) to our module families, we decided to stop extending our old API and instead design a completely new API wherein we can put all our experience, which we gained over the last years. We called the new library package “Toradex CE Libraries”. The basic goal of the library pack is the same as it was with the older libraries: Make our SoM features easily available for customers.
But we had three very important additional requirements:
  1. Extensible, yet compatible API
  2. Allow library configuration through the registry
  3. Easy maintenance
We were able to fit all three requirements into our new library approach.
Extensible, yet compatible API
To keep our API future-proof, we decided to introduce two sets of API calls. The first one is rather generic and uses strings or integers to pass information to the library. The following example shows how to set a SoM pin to GPIO input and activate a pull-down using the SetConfigString function:
// Set pin to alternate function GPIO, Input with pull-down
    success = Gpio_SetConfigString(hGpio, io1, NULL,
              L"altfn=ioAltFnGpio,dir=in,pull=down", StoreVolatile);
Another example uses the SetConfigInt function to set the bit rate of the I2C controller to 400KHz:
// Set I2C speed to 400KHz
    success = I2c_SetConfigInt(i2c, L"BitRateHz", 400000,
              StoreVolatile);
Using this generic string approach allows us to keep the API 100% compatible also in the future if we need to add more features which aren’t available on today’s SoMs.
The second set of API calls is used for either performance reasons or standard functions. Here is an example for the GPIO library function which allows to modify a GPIO. The same could be done using SetConfigString or Set ConfigInt, but for performance reasons we provide functions which don’t require to parse strings:
// Set it to Output,  High
    Gpio_ConfigureAsGpio(hGpio, io1);
    Gpio_SetDir         (hGpio, io1, ioOutput);
    Gpio_SetLevel       (hGpio, io1, ioHigh);
As an example for standard functions we can look at an I2C read. We decided to not use the more generic string approach (Get/SetConfig as shown above) for performance reasons, but also because I2C read (and similar functions) are fixed and not expected to change for future SoCs:
    returnValue = I2c_Read(i2c, (DWORD*) data, 8);
Allow library configuration through the registry
As you saw earlier, we allow to configure our libraries through strings and integers. It is for example possible to setup the SPI library to use a certain SPI port, chip selects, baud rate, etc. in the registry and just load the settings from there at your application start. If you initialize the library with the following call:
    hSPI = Spi_Init(L"SPI2");
the library will automatically load the settings found in the registry under:
    [HKEY_LOCAL_MACHINE\SOFTWARE\Toradex\SPI2]
      BitRateHz=500000
      DmaEnable=1
      etc.
You might wonder which benefits this brings. Well, one very nice advantage of this approach is to be able to maintain only one application on different devices, e.g. you can use the same application on a SoM based on the NXP® (or should I write Qualcomm) i.MX6 SoC but also on an NXP Vybrid-based SoM. The only difference between these modules is the pin configuration which can be stored in the registry now. The rest is absolutely identical and therefore allows you to use one single binary application for different SoMs which makes your life easier.
Easy Maintenance
The last Toradex CE Libraries feature which I would like to highlight in this post is the “designed for maintenance” aspect. For an easy and risk-free maintenance on our side, we split the libraries into individual source code files per SoC. This ensures we can fix bugs or add SoC-specific features without touching other SoC’s code. This lowers the risk of breaking existing code and therefore makes our software offerings more robust and stable overall.
References
You can find a list of supported features and download the libraries, API descriptions, etc. on our developer website.
Please also have a look at the library roadmap where we transparently show all known issues and when we plan to address them.
Author: Roman Schnarwiler, CTO, Toradex AG

Comments

  1. very good content . I like it
    http://jobs24hunt.com

    ReplyDelete
  2. Welcome To Job Consultancy!
    We are one of the rising stars among the best manpower consulting firm in the online platform. We have been providing our services to numerous job seekers since 2013. We help our clients to find their dream jobs in various sectors via our online portal. A majority of our clients are successfully placed into banks, retail department, telecom department, BPOs and many other avenues.
    We are just the inkling of the professional sectors! Being one of the most reliable online job consultancy service providers, you will find our registration procedure to be simple with the swift reply by email.
    Placement Consultancy

    ReplyDelete
    Replies
    1. www.sportsfox.ga ( Cricket HD Live Streams )

      Delete
  3. Writing very useful, thanks to the author

    http://ghesofa.net.vn/tu-van-mua-ghe-sofa-phong-khach

    ReplyDelete
  4. Get instant support for MSN Hotmail UK, Microsoft Outlook UK or Windows Live Mail UK service from certified tech experts. Just dialing toll free Hotmail Phone Number UK or visit website hotmailemailsupport.uk

    ReplyDelete
  5. Nice
    Myno1smartphonesworld.blogspot.in

    ReplyDelete
  6. http://trafficonic.com

    Get free traffic to your website.

    ReplyDelete
  7. Dear Website Owner!
    Hope you are doing well.

    My name is Khurram Munawar and I am the owner and admin of Trafficonic.com

    I am writing you this email because I have seen your website listed on different Traffic Exchange Networks.

    I would like to introduce you the world’s best and fastest growing traffic exchange network which is called Trafficonic.

    You can promote your website with Trafficonic.com totally free and promotion time of you website will be 10 seconds to 30 seconds.

    Such longer time promotion will surely increase your website ranking in google and will increase your sales.

    This is a great feature makes us unique from any other Traffic Exchange across the internet.

    I can assure you that you will surely benefited by promoting your website on Trafficonic.com

    Looking forward to see your website listed on Trafficonic.

    Please visit this link to submit your website at Trafficonic.

    http://www.trafficonic.com

    If you have any question, you can always reach me at admin@trafficonic.com

    Regards

    Khurram Munawar
    Admin
    Trafficonic.com

    ReplyDelete

Post a Comment

Popular posts from this blog

Patching Kernel in OpenEmbedded

Customizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoM