element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Internet of Things
  • Technologies
  • More
Internet of Things
Blog Blog #4  SOM Architectural Elements
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Internet of Things to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: james.flynn
  • Date Created: 3 Dec 2018 4:47 PM Date Created
  • Views 441 views
  • Likes 1 like
  • Comments 0 comments
Related
Recommended

Blog #4  SOM Architectural Elements

james.flynn
james.flynn
3 Dec 2018

  • Overview
  • Overall Program Flow
    • Main
    • Threads Used
  • Hardware Interfaces
    • Interrupts
    • Binary I/O's
    • I2C Interface

Overview

The WNC M18Qx Module, running Embedded Linux,  provides access to the hardware either through the Hardware Library, the Modem Abstraction Layer (MAL)--both of which are provided by the WNC SDK--and by using the Azure SDK (which provides the Application Programming Interfaces (APIs) to interact with Azure).  The overall organization for the application is:

 

image

The Azure SDK is well defined and documented by Microsoft so I skip over it.

 

Overall Program Flow

In the following sections, I review each of the major areas of the application to give you a sense of the organization and function.

 

Main

The main function is located in the azIoTClient.cpp file and it is of course, where it all starts.  I create several objects prior to program execution--the WNC GPS, LIS2DW12, ADC, LED, BAROMETER, HTS221 (for humidity), and BUTTON (to capture user key-press) object.  The reason these are created with a global scope is so that they are accessible throughout the application.

 

Several functions are also defined:

  • button_press - A function is called when a user depresses the USR button. All it does is set the LED to WHITE to indicate the button is pressed.
  • button_release - The function is called to restore the LED color back to its original color prior to being depressed and check to see if the button was pressed for >3 seconds signaling program termination.
  • make_message - This function creates the message that is sent to Azure.

 

Once main begins, it creates DEVINFO (WNC Device Info), the WWAN (controlls WWAN LED), and an NTPClient object.  These are created within main because they are only are used within the scope of the main function.

 

Threads Used

Several of the objects create threads that run concurrently.

 

ThreadFile LocationDescription
Buttonbutton.*This thread runs when a button gpio interrupt occurs.  It is called on both depress and release and calculates the time between press and release so it is known how long the button was pressed.
GPSgps.*Because the GPS function in the WNC device can take a long time to complete, this task is set to run once per second.
LEDled.hppRuns at an interval set by a caller.  The default is 500ms (1/2 second) unless someone has set a different interval.
LIS2DW12lis2dw12.*Handles the motion sensor.  It runs when an interrupt is generated by the LIS2DW12 and reads the position of the SOM.
WWANwwan.hppRuns every 2 seconds and monitors the status of the LTE connection so the WWAN LED can be illuminated as appropriate.

 

 

Hardware Interfaces

The hardware interfaces are provided as a link-library that is provided with the WNC SDK.  These functions are detailed in the Avnet M18Qx Perpherial IoT Guide.docx that is included as part of the SDK. 

 

Interrupts

This application implements the interrupt service routines (ISR) as private functions in various classes, but for the functions to have access to the class data, a pointer to the class must be provided. This is similar to how threads are handled in standard pthread programming.  To handle this in the ISRs, a function address to object address association was needed so I created a set of C++ functions (fos.*) to handle this.  It simply creates a linked-list of object address-with-function address table that can be called at the beginning of the ISR so class functions can be utilized seamlessly.

 

Binary I/O's

Binary I/O's are used for interrupt inputs as well as LED control.  The I/Os that are used as interrupts are located in the Binary IO class and the LIS2DW12 class. Simple I/O control is utilized in the LED class.

 

I2C Interface

There is a single I2C Bus which is connected to the LIS2DW12 and Click Modules (hts221 & barometer).  All I2C devices utilize the I2C_interface controls access to the I2C bus.

 

I realize this is a pretty brief overview, but once you know where functionality is located (which files) and a general description of what is happening, hopefully the code itself is pretty easily understood.

 

Previous Blog                                                                                     Next Blog

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube