mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ad...@apache.org
Subject [2/3] incubator-mynewt-site git commit: Closes pull request #52
Date Wed, 16 Mar 2016 05:54:52 GMT
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/e7607d4b/mkdocs/search_index.json
----------------------------------------------------------------------
diff --git a/mkdocs/search_index.json b/mkdocs/search_index.json
index e689819..034f2e2 100644
--- a/mkdocs/search_index.json
+++ b/mkdocs/search_index.json
@@ -142,7 +142,7 @@
         }, 
         {
             "location": "/os/get_started/project_create/", 
-            "text": "Creating a Mynewt Project\n\n\nThis page shows how to create a Mynewt Project using \nnewt\n\n\nPre-Requisites\n\n\n\n\nEnsure you have installed \nnewt\n and that the \nnewt command is in your system path.\n\n\nYou must have Internet connectivity to fetch remote Mynewt components\n\n\nYou must \ninstall the compiler tools\n to \nsupport native compiling to build the project this tutorial creates.  \n\n\n\n\nNewt New\n\n\nChose a project name. For this tutorial we will call this project \nmyproj\n.\nEnter the \nnewt new myproj\n command. Your put\n\n\n$ \nnewt new myproj\nDownloading project skeleton from apache/incubator-mynewt-blinky...\nInstalling skeleton in myproj...\nProject myproj successfully created.\n\n\n\n\n\nThe \nnewt\n tool has created a project directory structure like the one below:\n\n\n\u2500\u2500\u2500 myproj\n    \u251c\u2500\u2500 DISCLAIMER\n    \u251c\u2500\u2500 LICENSE\n    \u251c\u2500\u2500 NOTICE\n    \u251c\u2500\u2500 README.md\n  
   \u251c\u2500\u2500 apps\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 blinky\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 pkg.yml\n    \u2502\u00a0\u00a0     \u2514\u2500\u2500 src\n    \u2502\u00a0\u00a0         \u2514\u2500\u2500 main.c\n    \u251c\u2500\u2500 project.yml\n    \u2514\u2500\u2500 targets\n        \u251c\u2500\u2500 my_blinky_sim\n        \u2502\u00a0\u00a0 \u251c\u2500\u2500 pkg.yml\n        \u2502\u00a0\u00a0 \u2514\u2500\u2500 target.yml\n        \u2514\u2500\u2500 unittest\n            \u251c\u2500\u2500 pkg.yml\n            \u2514\u2500\u2500 target.yml\n\n\n\n\n\nnewt\n has installed the base files for a project comprising the following.\n\n\n\n\nfile \nproject.yml\n contains the repository list that the project uses to fetch\nits packages. Your project is a collection of repositories.  In this case, the project just\ncomprises the core mynewt repository.  Later you will add more repositories\nto include other mynewt components.\n\n\nthe file \napps/blinky/pk
 g.yml\n contains the description of your application\nand its package dependencies.\n\n\nA target directory containing \nmy_blinky_sim\n, a target descriptor used to\nbuild a version of myproj.  Use \nnewt target show\n to see available build \ntargets.\n\n\nA non-build-able target called \nunittest\n.  This is used\ninternally by \nnewt\n and is not a formal build target.\n\n\n\n\nNOTE: the actual code and package files are not installed \n(except the template for \nmain.c\n.  See the next step for installing \nthe packages.\n\n\nNewt Install\n\n\nchange into the \nmyproj\n directory.  Then ask newt to install all the \nproject package dependencies using \nnewt install\n\n\n$ \nnewt install -v \napache-mynewt-core\nDownloading repository description \nfor\n apache-mynewt-core... success!\nDownloading repository incubator-mynewt-core \n(\nbranch: master; commit: mynewt_0_8_0_b2_tag\n)\n at https://github.com/apache/incubator-mynewt-core.git\nCloning into \n/var/folders/7l/7b3w9m4n2m
 g3sqmgw2q1b9p80000gn/T/newt-repo969988348\n...\nremote: Counting objects: 17935, \ndone\n.\nremote: Compressing objects: 100% \n(\n234/234\n)\n, \ndone\n.\nremote: Total \n17935\n \n(\ndelta 101\n)\n, reused \n0\n \n(\ndelta 0\n)\n, pack-reused 17686\nReceiving objects: 100% \n(\n17935/17935\n)\n, 6.18 MiB | 315.00 KiB/s, \ndone\n.\nResolving deltas: 100% \n(\n10541/10541\n)\n, \ndone\n.\nChecking connectivity... \ndone\n.\napache-mynewt-core successfully installed version 0.7.9-none\n\n$ \n\n\n\n\n\n\nNow you will have installed packages required to build your project. Note in \nthe package you now have dependent packages stored in the \nrepos\n directory\nunder the specific repository you have included in the base project.  \n\n\n.\n\u251c\u2500\u2500 apps\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 blinky\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 src\n\u251c\u2500\u2500 repos\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 apache-mynewt-core\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 apps\n\u
 2502\u00a0\u00a0     \u251c\u2500\u2500 compiler\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 fs\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 hw\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 libs\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 net\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 scripts\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 sys\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 targets\n\u2514\u2500\u2500 targets\n    \u251c\u2500\u2500 my_blinky_sim\n    \u2514\u2500\u2500 unittest\n\n\n\n\n\nWithin each of these directories are the packages required to build your\nproject for the various targets.\n\n\nTesting the Project\n\n\nTo validate, you can also run all the units test through simulation.\n\n\nnewt test all\n...lots of compiling and testing...\n...about 2 minutes later ...\nArchiving bootutil.a\nLinking test_bootutil\nExecuting test: /myproj/bin/unittest/libs/bootutil/test_bootutil\nPassed tests: [net/nimble/host fs/nffs libs/os hw/hal libs/mbedtls libs/util sys/config libs/bootu
 til]\nAll tests passed\n\n\n\n\n\nBuilding the Project\n\n\nTo build the project you can use \nnewt build\n using the target \n\n\n$ \nnewt build my_blinky_sim\nApp successfully built: /bin/my_blinky_sim/apps/blinky/blinky.elf\n\n\n\n\n\nYou can run the simulated version of your project and see the simulated LED\nblink\n\n\n./bin/my_blinky_sim/apps/blinky/blinky.elf\nhal_gpio set pin  1 to 0\n\n\n\n\n\nJust do \nctrl-c\n to exit.\n\n\nComplete\n\n\nCongratulations, you have created your first project.  This project contains \nthe core OS, a simple application to blink an LED and all of the dependencies\nrequired.", 
+            "text": "Creating a Mynewt Project\n\n\nThis page shows how to create a Mynewt Project using \nnewt\n\n\nPre-Requisites\n\n\n\n\nEnsure you have installed \nnewt\n and that the \nnewt command is in your system path.\n\n\nYou must have Internet connectivity to fetch remote Mynewt components\n\n\nYou must \ninstall the compiler tools\n to \nsupport native compiling to build the project this tutorial creates.  \n\n\n\n\nNewt New\n\n\nChose a project name. For this tutorial we will call this project \nmyproj\n.\nEnter the \nnewt new myproj\n command. Your put\n\n\n    $ newt new myproj\n    Downloading project skeleton from apache/incubator-mynewt-blinky...\n    Installing skeleton in myproj...\n    Project myproj successfully created.\n\n\n\n\n\nThe \nnewt\n tool has created a project directory structure like the one below:\n\n\n    \u2500\u2500\u2500 myproj\n        \u251c\u2500\u2500 DISCLAIMER\n        \u251c\u2500\u2500 LICENSE\n        \u251c\u2500\u2500 NOTICE\n      
   \u251c\u2500\u2500 README.md\n        \u251c\u2500\u2500 apps\n        \u2502\u00a0\u00a0 \u2514\u2500\u2500 blinky\n        \u2502\u00a0\u00a0     \u251c\u2500\u2500 pkg.yml\n        \u2502\u00a0\u00a0     \u2514\u2500\u2500 src\n        \u2502\u00a0\u00a0         \u2514\u2500\u2500 main.c\n        \u251c\u2500\u2500 project.yml\n        \u2514\u2500\u2500 targets\n            \u251c\u2500\u2500 my_blinky_sim\n            \u2502\u00a0\u00a0 \u251c\u2500\u2500 pkg.yml\n            \u2502\u00a0\u00a0 \u2514\u2500\u2500 target.yml\n            \u2514\u2500\u2500 unittest\n                \u251c\u2500\u2500 pkg.yml\n                \u2514\u2500\u2500 target.yml\n\n\n\n\n\nnewt\n has installed the base files for a project comprising the following.\n\n\n\n\nfile \nproject.yml\n contains the repository list that the project uses to fetch\nits packages. Your project is a collection of repositories.  In this case, the project just\ncomprises the core mynewt repository.  Later you will add
  more repositories\nto include other mynewt components.\n\n\nthe file \napps/blinky/pkg.yml\n contains the description of your application\nand its package dependencies.\n\n\nA target directory containing \nmy_blinky_sim\n, a target descriptor used to\nbuild a version of myproj.  Use \nnewt target show\n to see available build \ntargets.\n\n\nA non-build-able target called \nunittest\n.  This is used\ninternally by \nnewt\n and is not a formal build target.\n\n\n\n\nNOTE: the actual code and package files are not installed \n(except the template for \nmain.c\n.  See the next step for installing \nthe packages.\n\n\nNewt Install\n\n\nchange into the \nmyproj\n directory.  Then ask newt to install all the \nproject package dependencies using \nnewt install\n\n\n    \n$\n \nnewt\n \ninstall\n \n-v\n \n    \napache-mynewt-core\n\n    \nDownloading\n \nrepository\n \ndescription\n \nfor\n \napache-mynewt-core...\n \nsuccess!\n\n    \nDownloading\n \nrepository\n \nincubator-mynewt-core\n
  \n(branch:\n \nmaster;\n \ncommit:\n \nmynewt_0_8_0_b2_tag)\n \nat\n \nhttps://github\n.com\n/apache/incubator-mynewt-core\n.git\n\n    \nCloning\n \ninto\n \n/var/folders/7l/7b3w9m4n2mg3sqmgw2q1b9p80000gn/T/newt-repo969988348\n...\n\n    \nremote:\n \nCounting\n \nobjects:\n \n17935,\n \ndone.\n\n    \nremote:\n \nCompressing\n \nobjects:\n \n100%\n \n(234/234),\n \ndone.\n\n    \nremote:\n \nTotal\n \n17935\n \n(delta\n \n101),\n \nreused\n \n0\n \n(delta\n \n0),\n \npack-reused\n \n17686\n\n    \nReceiving\n \nobjects:\n \n100%\n \n(17935/17935),\n \n6\n.18\n \nMiB\n \n|\n \n315\n.00\n \nKiB/s,\n \ndone.\n\n    \nResolving\n \ndeltas:\n \n100%\n \n(10541/10541),\n \ndone.\n\n    \nChecking\n \nconnectivity...\n \ndone.\n\n    \napache-mynewt-core\n \nsuccessfully\n \ninstalled\n \nversion\n \n0\n.7.9-none\n\n    \n$\n \n\n\n\n\n\nNow you will have installed packages required to build your project. Note in \nthe package you now have dependent packages stored in the \nrepos\n dire
 ctory\nunder the specific repository you have included in the base project.  \n\n\n    .\n    \u251c\u2500\u2500 apps\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 blinky\n    \u2502\u00a0\u00a0     \u2514\u2500\u2500 src\n    \u251c\u2500\u2500 repos\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 apache-mynewt-core\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 apps\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 compiler\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 fs\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 hw\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 libs\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 net\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 scripts\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 sys\n    \u2502\u00a0\u00a0     \u2514\u2500\u2500 targets\n    \u2514\u2500\u2500 targets\n        \u251c\u2500\u2500 my_blinky_sim\n        \u2514\u2500\u2500 unittest\n\n\n\n\n\nWithin each of these directories are the packages required to build your\nproject for the va
 rious targets.\n\n\nTesting the Project\n\n\nTo validate, you can also run all the units test through simulation.\n\n\n    $ newt test all\n    ...lots of compiling and testing...\n    ...about 2 minutes later ...\n    Archiving bootutil.a\n    Linking test_bootutil\n    Executing test: /myproj/bin/unittest/libs/bootutil/test_bootutil\n    Passed tests: [net/nimble/host fs/nffs libs/os hw/hal libs/mbedtls libs/util sys/config libs/bootutil]\n    All tests passed\n\n\n\n\n\nBuilding the Project\n\n\nTo build the project you can use \nnewt build\n using the target \n\n\n    $ newt build my_blinky_sim\n    App successfully built: /bin/my_blinky_sim/apps/blinky/blinky.elf\n\n\n\n\n\nYou can run the simulated version of your project and see the simulated LED\nblink\n\n\n    ./bin/my_blinky_sim/apps/blinky/blinky.elf\n    hal_gpio set pin  1 to 0\n\n\n\n\n\nJust do \nctrl-c\n to exit.\n\n\nComplete\n\n\nCongratulations, you have created your first project.  This project contains \nthe cor
 e OS, a simple application to blink an LED and all of the dependencies\nrequired.", 
             "title": "Creating Your First Project"
         }, 
         {
@@ -157,22 +157,22 @@
         }, 
         {
             "location": "/os/get_started/project_create/#newt-new", 
-            "text": "Chose a project name. For this tutorial we will call this project  myproj .\nEnter the  newt new myproj  command. Your put  $  newt new myproj\nDownloading project skeleton from apache/incubator-mynewt-blinky...\nInstalling skeleton in myproj...\nProject myproj successfully created.  The  newt  tool has created a project directory structure like the one below:  \u2500\u2500\u2500 myproj\n    \u251c\u2500\u2500 DISCLAIMER\n    \u251c\u2500\u2500 LICENSE\n    \u251c\u2500\u2500 NOTICE\n    \u251c\u2500\u2500 README.md\n    \u251c\u2500\u2500 apps\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 blinky\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 pkg.yml\n    \u2502\u00a0\u00a0     \u2514\u2500\u2500 src\n    \u2502\u00a0\u00a0         \u2514\u2500\u2500 main.c\n    \u251c\u2500\u2500 project.yml\n    \u2514\u2500\u2500 targets\n        \u251c\u2500\u2500 my_blinky_sim\n        \u2502\u00a0\u00a0 \u251c\u2500\u2500 pkg.yml\n        \u2502\u00a0\u00a0 \u2514\u2500\u2500
  target.yml\n        \u2514\u2500\u2500 unittest\n            \u251c\u2500\u2500 pkg.yml\n            \u2514\u2500\u2500 target.yml  newt  has installed the base files for a project comprising the following.   file  project.yml  contains the repository list that the project uses to fetch\nits packages. Your project is a collection of repositories.  In this case, the project just\ncomprises the core mynewt repository.  Later you will add more repositories\nto include other mynewt components.  the file  apps/blinky/pkg.yml  contains the description of your application\nand its package dependencies.  A target directory containing  my_blinky_sim , a target descriptor used to\nbuild a version of myproj.  Use  newt target show  to see available build \ntargets.  A non-build-able target called  unittest .  This is used\ninternally by  newt  and is not a formal build target.   NOTE: the actual code and package files are not installed \n(except the template for  main.c .  See the next step f
 or installing \nthe packages.", 
+            "text": "Chose a project name. For this tutorial we will call this project  myproj .\nEnter the  newt new myproj  command. Your put      $ newt new myproj\n    Downloading project skeleton from apache/incubator-mynewt-blinky...\n    Installing skeleton in myproj...\n    Project myproj successfully created.  The  newt  tool has created a project directory structure like the one below:      \u2500\u2500\u2500 myproj\n        \u251c\u2500\u2500 DISCLAIMER\n        \u251c\u2500\u2500 LICENSE\n        \u251c\u2500\u2500 NOTICE\n        \u251c\u2500\u2500 README.md\n        \u251c\u2500\u2500 apps\n        \u2502\u00a0\u00a0 \u2514\u2500\u2500 blinky\n        \u2502\u00a0\u00a0     \u251c\u2500\u2500 pkg.yml\n        \u2502\u00a0\u00a0     \u2514\u2500\u2500 src\n        \u2502\u00a0\u00a0         \u2514\u2500\u2500 main.c\n        \u251c\u2500\u2500 project.yml\n        \u2514\u2500\u2500 targets\n            \u251c\u2500\u2500 my_blinky_sim\n            \u2502\u00a0\u00a0 \u
 251c\u2500\u2500 pkg.yml\n            \u2502\u00a0\u00a0 \u2514\u2500\u2500 target.yml\n            \u2514\u2500\u2500 unittest\n                \u251c\u2500\u2500 pkg.yml\n                \u2514\u2500\u2500 target.yml  newt  has installed the base files for a project comprising the following.   file  project.yml  contains the repository list that the project uses to fetch\nits packages. Your project is a collection of repositories.  In this case, the project just\ncomprises the core mynewt repository.  Later you will add more repositories\nto include other mynewt components.  the file  apps/blinky/pkg.yml  contains the description of your application\nand its package dependencies.  A target directory containing  my_blinky_sim , a target descriptor used to\nbuild a version of myproj.  Use  newt target show  to see available build \ntargets.  A non-build-able target called  unittest .  This is used\ninternally by  newt  and is not a formal build target.   NOTE: the actual code and pa
 ckage files are not installed \n(except the template for  main.c .  See the next step for installing \nthe packages.", 
             "title": "Newt New"
         }, 
         {
             "location": "/os/get_started/project_create/#newt-install", 
-            "text": "change into the  myproj  directory.  Then ask newt to install all the \nproject package dependencies using  newt install  $  newt install -v \napache-mynewt-core\nDownloading repository description  for  apache-mynewt-core... success!\nDownloading repository incubator-mynewt-core  ( branch: master; commit: mynewt_0_8_0_b2_tag )  at https://github.com/apache/incubator-mynewt-core.git\nCloning into  /var/folders/7l/7b3w9m4n2mg3sqmgw2q1b9p80000gn/T/newt-repo969988348 ...\nremote: Counting objects: 17935,  done .\nremote: Compressing objects: 100%  ( 234/234 ) ,  done .\nremote: Total  17935   ( delta 101 ) , reused  0   ( delta 0 ) , pack-reused 17686\nReceiving objects: 100%  ( 17935/17935 ) , 6.18 MiB | 315.00 KiB/s,  done .\nResolving deltas: 100%  ( 10541/10541 ) ,  done .\nChecking connectivity...  done .\napache-mynewt-core successfully installed version 0.7.9-none $    Now you will have installed packages required to build your project. Note in \nthe package
  you now have dependent packages stored in the  repos  directory\nunder the specific repository you have included in the base project.    .\n\u251c\u2500\u2500 apps\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 blinky\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 src\n\u251c\u2500\u2500 repos\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 apache-mynewt-core\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 apps\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 compiler\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 fs\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 hw\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 libs\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 net\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 scripts\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 sys\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 targets\n\u2514\u2500\u2500 targets\n    \u251c\u2500\u2500 my_blinky_sim\n    \u2514\u2500\u2500 unittest  Within each of these directories are the packages required to build your\nproject for the various targets.", 
+            "text": "change into the  myproj  directory.  Then ask newt to install all the \nproject package dependencies using  newt install       $   newt   install   -v  \n     apache-mynewt-core \n     Downloading   repository   description   for   apache-mynewt-core...   success! \n     Downloading   repository   incubator-mynewt-core   (branch:   master;   commit:   mynewt_0_8_0_b2_tag)   at   https://github .com /apache/incubator-mynewt-core .git \n     Cloning   into   /var/folders/7l/7b3w9m4n2mg3sqmgw2q1b9p80000gn/T/newt-repo969988348 ... \n     remote:   Counting   objects:   17935,   done. \n     remote:   Compressing   objects:   100%   (234/234),   done. \n     remote:   Total   17935   (delta   101),   reused   0   (delta   0),   pack-reused   17686 \n     Receiving   objects:   100%   (17935/17935),   6 .18   MiB   |   315 .00   KiB/s,   done. \n     Resolving   deltas:   100%   (10541/10541),   done. \n     Checking   connectivity...   done. \n     apache-mynewt-core
    successfully   installed   version   0 .7.9-none \n     $    Now you will have installed packages required to build your project. Note in \nthe package you now have dependent packages stored in the  repos  directory\nunder the specific repository you have included in the base project.        .\n    \u251c\u2500\u2500 apps\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 blinky\n    \u2502\u00a0\u00a0     \u2514\u2500\u2500 src\n    \u251c\u2500\u2500 repos\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 apache-mynewt-core\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 apps\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 compiler\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 fs\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 hw\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 libs\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 net\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 scripts\n    \u2502\u00a0\u00a0     \u251c\u2500\u2500 sys\n    \u2502\u00a0\u00a0     \u2514\u2500\u2500 targets\n    
 \u2514\u2500\u2500 targets\n        \u251c\u2500\u2500 my_blinky_sim\n        \u2514\u2500\u2500 unittest  Within each of these directories are the packages required to build your\nproject for the various targets.", 
             "title": "Newt Install"
         }, 
         {
             "location": "/os/get_started/project_create/#testing-the-project", 
-            "text": "To validate, you can also run all the units test through simulation.  newt test all\n...lots of compiling and testing...\n...about 2 minutes later ...\nArchiving bootutil.a\nLinking test_bootutil\nExecuting test: /myproj/bin/unittest/libs/bootutil/test_bootutil\nPassed tests: [net/nimble/host fs/nffs libs/os hw/hal libs/mbedtls libs/util sys/config libs/bootutil]\nAll tests passed", 
+            "text": "To validate, you can also run all the units test through simulation.      $ newt test all\n    ...lots of compiling and testing...\n    ...about 2 minutes later ...\n    Archiving bootutil.a\n    Linking test_bootutil\n    Executing test: /myproj/bin/unittest/libs/bootutil/test_bootutil\n    Passed tests: [net/nimble/host fs/nffs libs/os hw/hal libs/mbedtls libs/util sys/config libs/bootutil]\n    All tests passed", 
             "title": "Testing the Project"
         }, 
         {
             "location": "/os/get_started/project_create/#building-the-project", 
-            "text": "To build the project you can use  newt build  using the target   $  newt build my_blinky_sim\nApp successfully built: /bin/my_blinky_sim/apps/blinky/blinky.elf  You can run the simulated version of your project and see the simulated LED\nblink  ./bin/my_blinky_sim/apps/blinky/blinky.elf\nhal_gpio set pin  1 to 0  Just do  ctrl-c  to exit.", 
+            "text": "To build the project you can use  newt build  using the target       $ newt build my_blinky_sim\n    App successfully built: /bin/my_blinky_sim/apps/blinky/blinky.elf  You can run the simulated version of your project and see the simulated LED\nblink      ./bin/my_blinky_sim/apps/blinky/blinky.elf\n    hal_gpio set pin  1 to 0  Just do  ctrl-c  to exit.", 
             "title": "Building the Project"
         }, 
         {
@@ -497,7 +497,7 @@
         }, 
         {
             "location": "/os/tutorials/air_quality_sensor/", 
-            "text": "Air quality sensor project\n\n\nSetting up source tree for stuff you need\n\n\nTo start with, you need to create a new app under which you will do this development. So you type in:\n\n\n    $ mkdir $\nHOME\n/src\n    $ cd $\nHOME\n/src\n    $ newt new air_quality\n\n\n\n\n\nLet's say you are using STM32F3discovery board for this project. You know you need the board support package for that hardware. You can look up its location in the repository, fetch the package list from there, and install the egg for the BSP.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ newt app add-pkg-list mynewt_stm32f3 https://github.com/runtimeinc/mynewt_stm32f3.git\n    Downloading pkg-list.yml from https://github.com/runtimeinc/mynewt_stm32f3.git/master... ok!\n    Verifying pkg-list.yml format...\n ok!\n    Package list mynewt_stm32f3 successfully installed to application.\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install hw/bsp/stm32f3discovery\n    Downloading mynewt_stm3
 2f3 from https://github.com/runtimeinc/mynewt_stm32f3.git/master... ok!\n    Installing hw/bsp/stm32f3discovery\n    Installing hw/mcu/stm/stm32f3xx\n    Error: No package libs/cmsis-core found\n\n\n\n\n\nOoops. You forgot to bring in the package list for larva itself. That's the one with most of the packages. Including libs/cmsis-core.\n\n\nThis time you need the latest and greatest from larva, so you want to bring in the 'develop' branch. Note that normally the use of the more stable master branch is recommended. In that case you would drop the '-b develop' from command line.\n\n\nHowever, you want to bring in the packages from develop branch. To make that happen you say:\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ newt app add-pkg-list -b develop larva https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva.git\n    Downloading pkg-list.yml from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva.git/develop... ok!\n    Verifying pkg-list.yml format...\n ok!\n
     Package list larva successfully installed to application.\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install libs/cmsis-core          Downloading     larva from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/develop... ok!\n    Installing libs/cmsis-core\n    Installation was a success!\n\n\n\n\n\nThat's better. You want to make sure you have all the needed bits for supporting your board; so you decide to build the blinky project for it first.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install project/blinky\n    Downloading larva from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/develop... ok!\n    Installing project/blinky\n    Installing libs/console/full\n    Installing libs/newtmgr\n    Installing libs/json\n    Installing libs/shell\n    Installing sys/config\n    Installing sys/log\n    Installing sys/stats\n    Installation was a success!\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install compiler/arm-none-eab
 i-m4\n    Downloading larva from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/develop... ok!\n    Installing compiler/arm-none-eabi-m4\n    Installation was a success!\n\n\n\n\n\nAs you can see, this brought in quite a few other dependencies as well.\n\n\nNow create a target for it and build it.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ newt target create blink_f3\n    Creating target blink_f3\n        Target blink_f3 successfully created!\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 arch=cortex_m4\n    Target blink_f3 successfully set arch to cortex_m4\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 bsp=hw/bsp/stm32f3discovery\n    Target blink_f3 successfully set bsp to hw/bsp/stm32f3discovery\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 compiler=arm-none-eabi-m4\n    Target blink_f3 successfully set compiler to arm-none-eabi-m4\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 co
 mpiler_def=debug\n    Target blink_f3 successfully set compiler_def to debug\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 project=blinky\n    Target blink_f3 successfully set project to blinky\n    [user@IsMyLaptop:~/src/air_quality]$ newt target build blink_f3\n    Building target blink_f3 (project = blinky)\n     ...\n    [user@IsMyLaptop:~/src/air_quality]$ newt target build blink_f3\n    Building target blink_f3 (project = blinky)\n    Building project blinky\n    Linking blinky.elf\n    /usr/local/Cellar/gcc-arm-none-eabi-49/20150609/bin/../lib/gcc/arm-none-eabi \n    4.9.3/../../../../arm-none-eabi/bin/ld: /Users/user/src/air_quality/project/blinky//bin/    blink_f3/blinky.elf section `.text\n will not fit in region `FLASH\n\n    /usr/local/Cellar/gcc-arm-none-eabi-49/20150609/bin/../lib/gcc/arm-none-eabi 4.9.3/../../../../arm-none-eabi/bin/ld: region `FLASH\n overflowed by 5180 bytes\n    collect2: error: ld returned 1 exit status\n\n\n\n\n\nThe error in
 dicates that the images need to be smaller for this board, so you decide to switch over to using baselibc instead of libc.\n\n\nTo do that, you modify the project's egg file project/blinky/pkg.yml. And add \nlibs/baselibc\n to list of package dependencies (pkg.deps).\n\n\nNow:\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ newt target build blink_f3\n    Building target blink_f3 (project = blinky)\n    ....\n    Archiving libstm32f3discovery.a\n    Compiling main.c\n    Building project blinky\n    Linking blinky.elf\n    Successfully run!\n\n\n\n\n\nThat's better.\n\n\nYou know that this platform uses bootloader, which means you have to create a target for that too. And download the bootloader package.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ newt target create boot_f3\n    Creating target boot_f3\n    Target boot_f3 successfully created!\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 arch=cortex_m4\n    newTarget boot_f3 successfully set arch to cortex_m4\n 
    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 bsp=hw/bsp/stm32f3discovery\n    newtTarget boot_f3 successfully set bsp to hw/bsp/stm32f3discovery\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 compiler=arm-none-eabi-m4\n    Target boot_f3 successfully set compiler to arm-none-eabi-m4\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 compiler_def=optimized\n    Target boot_f3 successfully set compiler_def to optimized\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 project=boot\n    Target boot_f3 successfully set project to boot\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install project/boot\n    Downloading larva from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/develop... ok!\n    Installing project/boot\n    Installing fs/nffs\n    Installing fs/fs\n    Installing libs/bootutil\n    Installing libs/mbedtls\n    Installing libs/console/stub\n    Installation was a success!\n\n\n\n\n\nA
 nd then build it:\n\n\n    newt target build boot_f3\n    ....\n    Linking boot.elf\n    Successfully run!\n\n\n\n\n\nNext you must download the targets to board, and see that the LED actually blinks. You plug in the STM32F3 discovery board to your laptop, and say:\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ newt target download blink_f3\n    Downloading with /Users/user/src/air_quality/hw/bsp/stm32f3discovery/stm32f3discovery_download.sh\n    Downloading /Users/user/src/air_quality/project/blinky/bin/blink_f3/blinky.img to 0x08008000\n    Open On-Chip Debugger 0.9.0 (2015-05-28-12:05)\n    ...\n    target state: halted\n    target halted due to debug-request, current mode: Thread \n    xPSR: 0x01000000 pc: 0x0800026c msp: 0x10002000\n    auto erase enabled\n    Error: couldn\nt open /Users/user/src/air_quality/project/blinky/bin/blink_f3/blinky.img\n    Error: exit status 1\n    exit status 1\n\n\n\n\n\nAh. Forgot to create an image out of the blinky binary.\n\n\n    [user@IsMyL
 aptop:~/src/air_quality]$ newt target create-image blink_f3 0.0.1\n    Building target blink_f3 (project = blinky)\n    Compiling hal_flash.c\n    Archiving libhal.a\n    Compiling cons_tty.c\n    Archiving libfull.a\n    Compiling hal_uart.c\n    Archiving libstm32f3xx.a\n    Compiling hal_bsp.c\n    Archiving libstm32f3discovery.a\n    Compiling main.c\n    Building project blinky\n    Linking blinky.elf\n    [user@IsMyLaptop:~/src/air_quality]$ newt target download blink_f3\n    Downloading with /Users/user/src/air_quality/hw/bsp/stm32f3discovery/stm32f3discovery_download.sh\n\n\n\n\n\nAnd it's blinking.\n\n\nCreate test project\n\n\nNow that you have your system setup, you can start creating your own stuff.\nFirst you want to create a project for yourself - you can start by getting project template from blinky, as it pretty much has what you want.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ mkdir project/air_quality\n    [user@IsMyLaptop:~/src/air_quality]$ cp project/blinky/p
 kg.yml project/air_quality/\n    [user@IsMyLaptop:~/src/air_quality]$ mkdir project/air_quality/src\n    [user@IsMyLaptop:~/src/air_quality]$ cp project/blinky/src/main.c project/air_quality/src/\n\n\n\n\n\nThen you modify the project/air_quality/pkg.yml for air_quality in order to change the \npkg.name\n to be \nproject/air_quality\n.\n\n\nAnd create a target for it:\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ newt target create air_q\n    newt targCreating target air_q\n    Target air_q successfully created!\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set air_q arch=cortex_m4\n    Target air_q successfully set arch to cortex_m4\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set air_q bsp=hw/bsp/stm32f3discovery\n    Target air_q successfully set bsp to hw/bsp/stm32f3discovery\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set air_q compiler=arm-none-eabi-m4\n    Target air_q successfully set compiler to arm-none-eabi-m4\n    [user@IsMyLaptop:~/src/air_qua
 lity]$ newt target set air_q compiler_def=debug\n    Target air_q successfully set compiler_def to debug\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set air_q project=air_quality\n    Target air_q successfully set project to air_quality\n    [user@IsMyLaptop:~/src/air_quality]$ newt target build air_q\n       ....\n    Successfully run!\n\n\n\n\n\nCreate packages for drivers\n\n\nOne of the sensors you want to enable is SenseAir K30, which will connect to the board over serial port.\nTo start development of the driver, you first need to create a package description for it, and add stubs for sources.\n\n\nSo you add few files. pkg.yml to describe the driver, and then header stub followed by source stub.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_drivers/senseair/pkg.yml\n\n\n\n\n\n#\n\n\n# Licensed to the Apache Software Foundation (ASF) under one\n\n\n# or more contributor license agreements.  See the NOTICE file\n\n\n# distributed with this work for additional 
 information\n\n\n# regarding copyright ownership.  The ASF licenses this file\n\n\n# to you under the Apache License, Version 2.0 (the\n\n\n# \nLicense\n); you may not use this file except in compliance\n\n\n# with the License.  You may obtain a copy of the License at\n\n\n# \n\n\n#  http:\n//www.apache.org/licenses/LICENSE-2.0\n\n\n#\n\n\n# Unless required by applicable law or agreed to in writing,\n\n\n# software distributed under the License is distributed on an\n\n\n# \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n# KIND, either express or implied.  See the License for the\n\n\n# specific language governing permissions and limitations\n\n\n# under the License.\n\n\n#\n\n\npkg\n.\nname\n: \nlibs/my_drivers/senseair\n\n\npkg\n.\ndeps\n:\n    \n-\n \nhw/hal\n\n\n\n\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_drivers/senseair/include/senseair/senseair.h\n\n\n\n\n\n/*\n\n\n * Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more contribut
 or license agreements.  See the NOTICE file\n\n\n * distributed with this work for additional information\n\n\n * regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n * with the License.  You may obtain a copy of the License at\n\n\n * \n\n\n *  http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applicable law or agreed to in writing,\n\n\n * software distributed under the License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * specific language governing permissions and limitations\n\n\n * under the License.\n\n\n*/\n\n\n#ifndef _SENSEAIR_H_\n\n\n#define _SENSEAIR_H_\n\n\n\nvoid\n \nsenseair_init\n(\nvoid\n);\n\n\n#endif \n/* _SENSEAIR_H_ */\n\n\n\n\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_driver
 s/senseair/src/senseair.c\n\n\n\n\n\n/**\n\n\n * Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor license agreements.  See the NOTICE file\n\n\n * distributed with this work for additional information\n\n\n * regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n * with the License.  You may obtain a copy of the License at\n\n\n * \n\n\n *  http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applicable law or agreed to in writing,\n\n\n * software distributed under the License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * specific language governing permissions and limitations\n\n\n * under the License.\n\n\n */\n\n\n\nvoid\n\n\nsenseair_init\n(\nvoid\n)\n{\n}\n\n\n\n\n\nAn
 d add dependency to this package in my project yml file.\n\n\nHere's from project/air_quality/pkg.yml\n\n\npkg.name: project/air_quality\npkg.vers: 0.8.0\npkg.description: Basic example application which blinks an LED.\npkg.author: Marko Kiiskila \nuser@runtime.io\n\npkg.homepage: http://mynewt.apache.org/os/get_acclimated/project2/\npkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva\npkg.keywords:\n\npkg.deps:\n    - libs/console/full\n    - libs/newtmgr\n    - libs/os\n    - libs/shell\n    - libs/baselibc\n    - sys/config\n    - sys/log\n    - sys/stats\n    - libs/my_drivers/senseair\n\n\n\n\n\nAnd add a call to your main() to initialize this driver.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ diff project/blinky/src/main.c project/air_quality/src/main.c\n    28a29\n    \n #include \nsenseair/senseair.h\n\n    190a192\n    \n senseair_init();\n    [user@IsMyLaptop:~/src/air_quality\n\n\n\n\n\nAnd then build it to make sure all goes well.\n\n\n    [
 user@IsMyLaptop:~/src/air_quality]$ newt target build air_q\n    Building target air_q (project = air_quality)\n    Building project air_quality\n    Successfully run!\n\n\n\n\n\nAll looks good.\n\n\nAdd CLI commands for testing drivers\n\n\nWhile developing the driver, you want to issue operations from console asking it to do stuff. The way to do this is to register your command handler with shell. Whenever your custom command is issued, you can respond to it.\n\n\nThe way you do this is first adding a dependency to shell package for your senseair driver. So you change libs/my_drivers/senseair/pkg.yml to have the following:\n\n\npkg.name: libs/my_drivers/senseair\npkg.deps:\n    - hw/hal\n    - libs/shell\n\n\n\n\n\nAnd then register your shell command in \nsenseair_init()\n.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_drivers/senseair/src/senseair.c\n ....\n\n\n\n\n\n#include \nshell/shell.h\n\n\n#include \nconsole/console.h\n\n\n\nstatic\n \nint\n \nsenseair_shell_func\
 n(\nint\n \nargc\n, \nchar\n \n**argv\n);\n\nstatic\n \nstruct\n \nshell_cmd\n \nsenseair_cmd\n \n=\n {\n    .\nsc_cmd\n \n=\n \nsenseair\n,\n    .\nsc_cmd_func\n \n=\n \nsenseair_shell_func\n,\n};\n\n\nvoid\n\n\nsenseair_init\n(\nvoid\n)\n{\n    \nint\n \nrc\n;\n\n    \nrc\n \n=\n \nshell_cmd_register\n(\nsenseair_cmd\n);\n    \nassert\n(\nrc\n \n==\n \n0\n);\n}\n\n\nstatic\n \nint\n\n\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    \nconsole_printf\n(\nYay! Somebody called!\\n\n);\n    \nreturn\n \n0\n;\n}\n\n\n\n\n\nThen you build this, download to target, and start minicom on your console port.\n\n\n    [user@IsMyLaptop:~]$ minicom -D /dev/tty.usbserial-AH02MIE2\n\n\n    Welcome to minicom 2.7\n\n    OPTIONS: \n    Compiled on Oct 12 2015, 07:48:30.\n    Port /dev/tty.usbserial-AH02MIE2, 13:44:40\n\n    Press CTRL-X Z for help on special keys\n\n    ?\n    141964:Unknown command ?\n    ?\n    143804:config   log     echo    ?       tasks   mempools \n    14
 3806:stat     senseair \n    senseair\n    150644:Yay! Somebody called!\n\n\n\n\n\nNow that's great. You can connect the hardware to board and start developing code for the driver itself.\n\n\nUse of HAL for drivers\n\n\nThe sensor has a serial port connection, and that's how you are going to connect to it. Your original BSP, hw/bsp/stm32f3discovery, has only one UART set up (as specified in src/hal_bsp.c, include/hal/bsp.h). Therefore, you need to create your own bsp which has configuration for this added hardware.\n\n\nSo in the shell you make a copy of the original BSP, and then change the package file a little.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ cp -R hw/bsp/stm32f3discovery hw/bsp/stm32f3discovery_with_senseair\n\n\n\n\n\nThen you modify the pkg.yml in the copied BSP to assign name for this package.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ grep pkg.name hw/bsp/stm32f3discovery_with_senseair/pkg.yml\n    pkg.name: \nhw/bsp/stm32f3discovery_with_senseair\n\n\n\n\n
 \n\nAnd you want to use this BSP with my target. So you change the BSP in the target definition.\n\n\nHere's your new target.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target show air_q                    air_q\n    arch=cortex_m4\n    bsp=hw/bsp/stm32f3discovery_with_senseair\n    compiler=arm-none-eabi-m4\n    compiler_def=debug\n    name=air_q\n    project=air_quality\n    vers=0.0.1\n\n\n\n\n\nYou add the 2nd serial port to my new BSP.\n\n\nModify the include/hal/bsp.h to increase UART_CNT to 2, and add a definition of the 2nd logical UART. You will use this in your sensor driver.\n\n\nstatic\n \nconst\n \nstruct\n \nstm32f3_uart_cfg\n \nuart_cfg\n[\nUART_CNT\n] \n=\n {\n    [\n0\n] \n=\n {\n        .\nsuc_uart\n \n=\n \nUSART1\n,\n        .\nsuc_rcc_cmd\n \n=\n \nRCC_APB2PeriphClockCmd\n,\n        .\nsuc_rcc_dev\n \n=\n \nRCC_APB2Periph_USART1\n,\n        .\nsuc_pin_tx\n \n=\n \n9\n,\n        .\nsuc_pin_rx\n \n=\n \n10\n,\n        .\nsuc_pin_rts\n \n=\n \n12\n,\n        .\
 nsuc_pin_cts\n \n=\n \n11\n,\n        .\nsuc_pin_af\n \n=\n \nGPIO_AF_7\n,\n        .\nsuc_irqn\n \n=\n \nUSART1_IRQn\n\n    },\n    [\n1\n] \n=\n {\n        .\nsuc_uart\n \n=\n \nUSART2\n,\n        .\nsuc_rcc_cmd\n \n=\n \nRCC_APB1PeriphClockCmd\n,\n        .\nsuc_rcc_dev\n \n=\n \nRCC_APB1Periph_USART2\n,\n        .\nsuc_pin_tx\n \n=\n \n19\n, \n/* PB3 */\n\n        .\nsuc_pin_rx\n \n=\n \n20\n, \n/* PB4 */\n\n        .\nsuc_pin_rts\n \n=\n \n1\n,\n        .\nsuc_pin_cts\n \n=\n \n0\n,\n        .\nsuc_pin_af\n \n=\n \nGPIO_AF_7\n,\n        .\nsuc_irqn\n \n=\n \nUSART2_IRQn\n\n    }\n};\n\n\n\n\n\nWith this in place, you can refer to serial port where your SenseAir sensor is by a logical number. This makes the code more platform independent - you could connect this sensor to another board, like Olimex. You will also use the HAL UART abstraction to do the UART port setup and data transfer. That way you don't need to have any platform dependent pieces within your little driver.\n\n\n
 You will now see what the driver code ends up looking like. Here's the header file, filled in from stub you created earlier.\n\n\n/*\n\n\n * Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor license agreements.  See the NOTICE file\n\n\n * distributed with this work for additional information\n\n\n * regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n * with the License.  You may obtain a copy of the License at\n\n\n * \n\n\n *  http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applicable law or agreed to in writing,\n\n\n * software distributed under the License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * specific language governing permissions and limitations\n\n\n 
 * under the License.\n\n\n*/\n\n\n#ifndef _SENSEAIR_H_\n\n\n#define _SENSEAIR_H_\n\n\n\nenum\n \nsenseair_read_type\n {\n        \nSENSEAIR_CO2\n,\n        \nSENSEAIR_TEMPERATURE\n,\n        \nSENSEAIR_HUMIDITY\n\n};\n\n\nint\n \nsenseair_init\n(\nint\n \nuartno\n);\n\n\nint\n \nsenseair_read\n(\nenum\n \nsenseair_read_type\n);\n\n\n#endif \n/* _SENSEAIR_H_ */\n\n\n\n\n\n\nAs you can see, logical UART number has been added to the init routine. A 'read' function has been added, which is a blocking read. If you were making a commercial product, you would probably have a callback for reporting the results.\n\n\nAnd here is the source for the driver.\n\n\n/**\n\n\n * Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor license agreements.  See the NOTICE file\n\n\n * distributed with this work for additional information\n\n\n * regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * \n
 License\n); you may not use this file except in compliance\n\n\n * with the License.  You may obtain a copy of the License at\n\n\n *\n\n\n *  http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applicable law or agreed to in writing,\n\n\n * software distributed under the License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * specific language governing permissions and limitations\n\n\n * under the License.\n\n\n */\n\n\n#include \nstring.h\n\n\n\n#include \nshell/shell.h\n\n\n#include \nconsole/console.h\n\n\n#include \nos/os.h\n\n\n\n#include \nhal/hal_uart.h\n\n\n\n#include \nsenseair/senseair.h\n\n\n\nstatic\n \nconst\n \nuint8_t\n \ncmd_read_co2\n[] \n=\n {\n    \n0xFE\n, \n0\nX44\n, \n0\nX00\n, \n0\nX08\n, \n0\nX02\n, \n0\nX9F\n, \n0\nX25\n\n};\n\nstatic\n \nconst\n \nuint8_t\n \ncmd_read_temp\n[] \n=\n {\n    \n0xFE\n, \n0\nX44\n, \n0\nX0
 0\n, \n0\nX12\n, \n0\nX02\n, \n0\nX94\n, \n0\nX45\n\n};\n\nstatic\n \nconst\n \nuint8_t\n \ncmd_read_humidity\n[] \n=\n {\n    \n0xFE\n, \n0x44\n, \n0x00\n, \n0x14\n, \n0x02\n, \n0x97\n, \n0xE5\n\n};\n\n\nstatic\n \nint\n \nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n);\n\nstatic\n \nstruct\n \nshell_cmd\n \nsenseair_cmd\n \n=\n {\n    .\nsc_cmd\n \n=\n \nsenseair\n,\n    .\nsc_cmd_func\n \n=\n \nsenseair_shell_func\n,\n};\n\n\nstruct\n \nsenseair\n { \n    \nint\n \nuart\n;\n    \nstruct\n \nos_sem\n \nsema\n;\n    \nconst\n \nuint8_t\n \n*tx_data\n;\n    \nint\n \ntx_off\n;\n    \nint\n \ntx_len\n;\n    \nuint8_t\n \nrx_data\n[\n32\n]; \n    \nint\n \nrx_off\n;\n    \nint\n \nvalue\n;\n} \nsenseair\n;\n\n\nstatic\n \nint\n\n\nsenseair_tx_char\n(\nvoid\n \n*arg\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n \nsenseair\n;\n    \nint\n \nrc\n;\n\n    \nif\n (\ns-\ntx_off\n \n=\n \ns-\ntx_len\n) {\n    \n/*\n\n\n         * Command tx finished.\n\n\n         */\n\n     
    \ns-\ntx_data\n \n=\n \nNULL\n;\n        \nreturn\n \n-\n1\n;\n    }\n\n    \nrc\n \n=\n \ns-\ntx_data\n[\ns-\ntx_off\n];\n    \ns-\ntx_off++\n;\n    \nreturn\n \nrc\n;\n}\n\n\n/*\n\n\n * CRC for modbus over serial port.\n\n\n */\n\n\nstatic\n \nconst\n \nuint16_t\n \nmb_crc_tbl\n[] \n=\n {\n    \n0x0000\n, \n0xcc01\n, \n0xd801\n, \n0x1400\n, \n0xf001\n, \n0x3c00\n, \n0x2800\n, \n0xe401\n,\n    \n0xa001\n, \n0x6c00\n, \n0x7800\n, \n0xb401\n, \n0x5000\n, \n0x9c01\n, \n0x8801\n, \n0x4400\n\n};\n\n\nstatic\n \nuint16_t\n\n\nmb_crc\n(\nconst\n \nuint8_t\n \n*data\n, \nint\n \nlen\n, \nuint16_t\n \ncrc\n)\n{\n    \nwhile\n (\nlen--\n \n \n0\n) {\n        \ncrc\n \n^=\n \n*data++\n;\n        \ncrc\n \n=\n (\ncrc\n \n \n4\n) \n^\n \nmb_crc_tbl\n[\ncrc\n \n \n0xf\n];\n        \ncrc\n \n=\n (\ncrc\n \n \n4\n) \n^\n \nmb_crc_tbl\n[\ncrc\n \n \n0xf\n];\n    }\n    \nreturn\n \ncrc\n;\n}\n\n\nstatic\n \nint\n\n\nmb_crc_check\n(\nconst\n \nvoid\n \n*pkt\n, \nint\n \nlen\n)\n{\n    \nuint16_t\
 n \ncrc\n, \ncmp\n;\n    \nuint8_t\n \n*bp\n \n=\n (\nuint8_t\n \n*\n)\npkt\n;\n\n    \nif\n (\nlen\n \n \nsizeof\n(\ncrc\n) \n+\n \n1\n) {\n        \nreturn\n \n-\n1\n;\n    }\n    \ncrc\n \n=\n \nmb_crc\n(\npkt\n, \nlen\n \n-\n \n2\n, \n0xffff\n);\n    \ncmp\n \n=\n \nbp\n[\nlen\n \n-\n \n2\n] \n|\n (\nbp\n[\nlen\n \n-\n \n1\n] \n \n8\n);\n    \nif\n (\ncrc\n \n!=\n \ncmp\n) {\n        \nreturn\n \n-\n1\n;\n    } \nelse\n {\n        \nreturn\n \n0\n;\n    }\n}\n\n\nstatic\n \nint\n\n\nsenseair_rx_char\n(\nvoid\n \n*arg\n, \nuint8_t\n \ndata\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n (\nstruct\n \nsenseair\n \n*\n)\narg\n;\n    \nint\n \nrc\n;\n\n    \nif\n (\ns-\nrx_off\n \n=\n \nsizeof\n(\ns-\nrx_data\n)) {\n        \ns-\nrx_off\n \n=\n \n0\n;\n    }\n    \ns-\nrx_data\n[\ns-\nrx_off\n] \n=\n \ndata\n;\n    \ns-\nrx_off++\n;\n\n    \nif\n (\ns-\nrx_off\n \n==\n \n7\n) {\n        \nrc\n \n=\n \nmb_crc_check\n(\ns-\nrx_data\n, \ns-\nrx_off\n);\n        \nif\n (\nrc\n \n==\n \n
 0\n) {\n            \ns-\nvalue\n \n=\n \ns-\nrx_data\n[\n3\n] \n*\n \n256\n \n+\n \ns-\nrx_data\n[\n4\n];\n            \nos_sem_release\n(\ns-\nsema\n);\n        }\n    }\n    \nreturn\n \n0\n;\n}\n\n\nvoid\n\n\nsenseair_tx\n(\nstruct\n \nsenseair\n \n*s\n, \nconst\n \nuint8_t\n \n*tx_data\n, \nint\n \ndata_len\n)\n{\n    \ns-\ntx_data\n \n=\n \ntx_data\n;\n    \ns-\ntx_len\n \n=\n \ndata_len\n;\n    \ns-\ntx_off\n \n=\n \n0\n;\n    \ns-\nrx_off\n \n=\n \n0\n;\n\n    \nhal_uart_start_tx\n(\ns-\nuart\n);\n}\n\n\nint\n\n\nsenseair_read\n(\nenum\n \nsenseair_read_type\n \ntype\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n \nsenseair\n;\n    \nconst\n \nuint8_t\n \n*cmd\n;\n    \nint\n \ncmd_len\n;\n    \nint\n \nrc\n;\n\n    \nif\n (\ns-\ntx_data\n) {\n        \n/*\n\n\n         * busy\n\n\n         */\n\n        \nreturn\n \n-\n1\n;\n    }\n    \nswitch\n (\ntype\n) {\n    \ncase\n \nSENSEAIR_CO2\n:\n        \ncmd\n \n=\n \ncmd_read_co2\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncm
 d_read_co2\n);\n        \nbreak\n;\n    \ncase\n \nSENSEAIR_TEMPERATURE\n:\n        \ncmd\n \n=\n \ncmd_read_temp\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncmd_read_temp\n);\n        \nbreak\n;\n    \ncase\n \nSENSEAIR_HUMIDITY\n:\n        \ncmd\n \n=\n \ncmd_read_humidity\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncmd_read_humidity\n);\n        \nbreak\n;\n    \ndefault\n:\n\n        \nreturn\n \n-\n1\n;\n    }\n    \nsenseair_tx\n(\ns\n, \ncmd\n, \ncmd_len\n);\n    \nrc\n \n=\n \nos_sem_pend\n(\ns-\nsema\n, \nOS_TICKS_PER_SEC\n \n/\n \n2\n);\n    \nif\n (\nrc\n \n==\n \nOS_TIMEOUT\n) {\n        \n/*\n\n\n         * timeout\n\n\n         */\n\n        \nreturn\n \n-\n2\n;\n    }\n    \nreturn\n \ns-\nvalue\n;\n}\n\n\nstatic\n \nint\n\n\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    \nint\n \nvalue\n;\n    \nenum\n \nsenseair_read_type\n \ntype\n;\n\n    \nif\n (\nargc\n \n \n2\n) {\n\nusage\n:\n        \nconsole_printf\n(\n%s \nco2|temp|humidity\n\\n\n, \nar
 gv\n[\n0\n]);\n        \nreturn\n \n0\n;\n    }\n    \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nco2\n)) {\n        \ntype\n \n=\n \nSENSEAIR_CO2\n;\n    } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \ntemp\n)) {\n        \ntype\n \n=\n \nSENSEAIR_TEMPERATURE\n;\n    } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nhumidity\n)) {\n        \n/*\n\n\n         * timeout\n\n\n         */\n\n        \nreturn\n \n-\n2\n;\n    }\n    \nreturn\n \ns-\nvalue\n;\n}\n\n\nstatic\n \nint\n\n\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    \nint\n \nvalue\n;\n    \nenum\n \nsenseair_read_type\n \ntype\n;\n\n    \nif\n (\nargc\n \n \n2\n) {\n\nusage\n:\n        \nconsole_printf\n(\n%s \nco2|temp|humidity\n\\n\n, \nargv\n[\n0\n]);\n        \nreturn\n \n0\n;\n    }\n    \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nco2\n)) {\n        \ntype\n \n=\n \nSENSEAIR_CO2\n;\n    } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \ntemp\n)) {\n        \ntype\n \n=\n \nSENSEAIR_TEMPERATURE\n;\n    }
  \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nhumidity\n)) {\n        \ntype\n \n=\n \nSENSEAIR_HUMIDITY\n;\n    } \nelse\n {\n        \ngoto\n \nusage\n;\n    }\n    \nvalue\n \n=\n \nsenseair_read\n(\ntype\n);\n    \nif\n (\nvalue\n \n=\n \n0\n) {\n        \nconsole_printf\n(\nGot %d\\n\n, \nvalue\n);\n    } \nelse\n {\n        \nconsole_printf\n(\nError while reading: %d\\n\n, \nvalue\n);\n    }\n    \nreturn\n \n0\n;\n}\n\n\nint\n\n\nsenseair_init\n(\nint\n \nuartno\n)\n{\n    \nint\n \nrc\n;\n    \nstruct\n \nsenseair\n \n*s\n \n=\n \nsenseair\n;\n\n    \nrc\n \n=\n \nshell_cmd_register\n(\nsenseair_cmd\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n\n    \nrc\n \n=\n \nos_sem_init\n(\ns-\nsema\n, \n1\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n    \nrc\n \n=\n \nhal_uart_init_cbs\n(\nuartno\n, \nsenseair_tx_char\n, \nNULL\n,\n      \nsenseair_rx_char\n, \nsenseair\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n    \nrc\n \n
 =\n \nhal_uart_config\n(\nuartno\n, \n9600\n, \n8\n, \n1\n, \nHAL_UART_PARITY_NONE\n,\n      \nHAL_UART_FLOW_CTL_NONE\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n    \ns-\nuart\n \n=\n \nuartno\n;\n\n    \nreturn\n \n0\n;\n}\n\n\n\n\n\nAnd you modified your main() for senseair driver init.\n\n\nint\n\n\nmain\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    ....\n    \nsenseair_init\n(\n1\n);\n    ....\n    }\n\n\n\n\n\nYou can see from the code that you are using the HAL interface to open a UART port, and using OS semaphore as a way of blocking the task when waiting for read response to come back from the sensor.", 
+            "text": "Air quality sensor project\n\n\nSetting up source tree for stuff you need\n\n\nTo start with, you need to create a new project under which you will do this development. So you type in:\n\n\n    $ mkdir $\nHOME\n/src\n    $ cd $\nHOME\n/src\n    $ newt new air_quality\n\n\n\n\n\nLet's say you are using STM32F3discovery board as the platform. You know you need the board support package for that hardware. You can look up its location, add it your project, and fetch that along with the core OS components.\n\n\nTo make this happen, you'll need to modify the project.yml in your project's root directory.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ emacs project.yml \n\n    [user@IsMyLaptop:~/src/air_quality]$ cat project.yml\n    project.name: \nair_quality\n\n\n    project.repositories:\n        - apache-mynewt-core\n        - mynewt_stm32f3\n\n    # Use github\ns distribution mechanism for core ASF libraries.\n    # This provides mirroring automatically for us.\n  
   #\n    repository.apache-mynewt-core:\n        type: github\n        vers: 0-latest\n        user: apache\n        repo: incubator-mynewt-core\n\n    repository.mynewt_stm32f3:\n        type: github\n        vers: 0-latest\n        user: runtimeinc\n        repo: mynewt_stm32f3\n    [user@IsMyLaptop:~/src/air_quality]$ newt install\n    apache-mynewt-core\n    mynewt_stm32f3\n    [user@IsMyLaptop:~/src/air_quality]$ ls repos/\n    apache-mynewt-core  mynewt_stm32f3\n\n\n\n\n\nGood. You want to make sure you have all the needed bits for supporting your board; so you decide to build the blinky project for the platform first.\n\n\nNow create a target for it and build it. Easiest way to proceed is to copy the existing target for blinky, and modify it to build for STM32F3Discovery board.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target copy my_blinky_sim blink_f3\nTarget successfully copied; targets/my_blinky_sim --\n targets/blink_f3\n[user@IsMyLaptop:~/src/air_quality]$ newt tar
 get set blink_f3 bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\nTarget targets/blink_f3 successfully set target.bsp to @mynewt_stm32f3/hw/bsp/stm32f3discovery\n[user@IsMyLaptop:~/src/air_quality]$ newt build blink_f3\nCompiling hal_bsp.c\n...\nLinking blinky.elf\nApp successfully built: /Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.elf\n\n\n\n\n\nGood.\n\n\nYou know that this platform uses bootloader, which means you have to create a target for that too.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target create boot_f3\nTarget targets/boot_f3 successfully created\n[user@IsMyLaptop:~/src/air_quality]$ newt target show\n@apache-mynewt-core/targets/unittest\n    bsp=hw/bsp/native\n    build_profile=debug\n    compiler=compiler/sim\ntargets/blink_f3\n    app=apps/blinky\n    bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\n    build_profile=debug\ntargets/boot_f3\ntargets/my_blinky_sim\n    app=apps/blinky\n    bsp=@apache-mynewt-core/hw/bsp/native\n    build_profile=debug\n[
 user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\nTarget targets/boot_f3 successfully set target.bsp to @mynewt_stm32f3/hw/bsp/stm32f3discovery\n[user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 app=@apache-mynewt-core/apps/boot\nTarget targets/boot_f3 successfully set target.app to @apache-mynewt-core/apps/boot\n[user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 build_profile=optimized\nTarget targets/boot_f3 successfully set target.build_profile to optimized\n\n\n\n\n\nAnd then build it, and load it onto the board.\n\n\nnewt build boot_f3\n....\nLinking boot.elf\nApp successfully built: /Users/user/src/air_quality/bin/boot_f3/apps/boot/boot.elf\n[user@IsMyLaptop:~/src/air_quality]$ newt load boot_f3\n\n\n\n\n\nNext you must download the targets to board, and see that the LED actually blinks. You plug in the STM32F3 discovery board to your laptop, and say:\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt load
  blink_f3\nDownloading /Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.img to 0x08009000\nOpen On-Chip Debugger 0.9.0 (2015-05-28-12:05)\n....\nxPSR: 0x01000000 pc: 0x0800026c msp: 0x10002000\nauto erase enabled\nError: couldn\nt open /Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.img\n\nError: exit status 1\n\nload - Load app image to target for \ntarget-name\n.\n\nUsage:\n  newt load [flags]\n\nExamples:\n  newt load \ntarget-name\n\n\n\nGlobal Flags:\n  -l, --loglevel string   Log level, defaults to WARN. (default \nWARN\n)\n  -o, --outfile string    Filename to tee log output to\n  -q, --quiet             Be quiet; only display error output.\n  -s, --silent            Be silent; don\nt output anything.\n  -v, --verbose           Enable verbose output when executing commands.\nexit status 1\n\n\n\n\n\nAh. Forgot to create an image out of the blinky binary. Note that every time you want to build and load a new firmware image to target board, you need to ru
 n 'create-image' on it.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt create-image blink_f3 0.0.1\nApp image succesfully generated: /Users/user/src/air_quality/bin/blink_f3/apps/blinky/blinky.img\nBuild manifest: /Users/user/src/air_quality/bin/blink_f3/apps/blinky/manifest.json\n[user@IsMyLaptop:~/src/air_quality]$ newt load blink_f3 0.0.1\n\n\n\n\n\nAnd it's blinking.\n\n\nShortcut for doing build/create-image/load/debug steps all in one is 'newt run' command. Check out the usage from command line help.\n\n\nCreate test project\n\n\nNow that you have your system setup, you can start creating your own stuff.\nFirst you want to create a project for yourself - you can start by getting project template from blinky, as it pretty much has what you want.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ mkdir apps/air_quality\n    [user@IsMyLaptop:~/src/air_quality]$ cp repos/apache-mynewt-core/apps/blinky/pkg.yml apps/air_quality/\n    [user@IsMyLaptop:~/src/air_quality]$ mkdir apps/air_qu
 ality/src\n    [user@IsMyLaptop:~/src/air_quality]$ cp repos/apache-mynewt-core/apps/blinky/src/main.c apps/air_quality/src/\n\n\n\n\n\nThen you modify the apps/air_quality/pkg.yml for air_quality in order to change the \npkg.name\n to be \napps/air_quality\n.\nYou also need to point the package dependencies to point to packages in apache-mynewt-core repository.\nSTM32F3discovery board has limited amount of memory, so you must also switch your libc to be baselibc, instead of the standard one.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat apps/air_quality/pkg.yml\npkg.name: apps/air_quality\npkg.type: app\npkg.description: Air quality sensor test\npkg.keywords:\n\npkg.deps:\n    - \n@apache-mynewt-core/libs/console/full\n\n    - \n@apache-mynewt-core/libs/newtmgr\n\n    - \n@apache-mynewt-core/libs/os\n\n    - \n@apache-mynewt-core/libs/shell\n\n    - \n@apache-mynewt-core/sys/config\n\n    - \n@apache-mynewt-core/sys/log\n\n    - \n@apache-mynewt-core/sys/stats\n\n    - \n@apache-my
 newt-core/libs/baselibc\n\n\n\n\n\n\nAnd create a target for it:\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target create air_q\nTarget targets/air_q successfully created\n[user@IsMyLaptop:~/src/air_quality]$ newt target set air_q bsp=@mynewt_stm32f3/hw/bsp/stm32f3discovery\nTarget targets/air_q successfully set target.bsp to @mynewt_stm32f3/hw/bsp/stm32f3discovery\n[user@IsMyLaptop:~/src/air_quality]$ newt target set air_q app=apps/air_quality \nTarget targets/air_q successfully set target.app to apps/air_quality\n[user@IsMyLaptop:~/src/air_quality]$ newt target set air_q build_profile=debug\nTarget targets/air_q successfully set target.build_profile to debug\n[user@IsMyLaptop:~/src/air_quality]$ newt build air_q\n ....\nLinking air_quality.elf\nApp successfully built: /Users/user/src/air_quality/bin/air_q/apps/air_quality/air_quality.elf\n\n\n\n\n\nCreate packages for drivers\n\n\nOne of the sensors you want to enable is SenseAir K30, which will connect to the board over seria
 l port.\nTo start development of the driver, you first need to create a package description for it, and add stubs for sources.\n\n\nSo you add few files. pkg.yml to describe the driver, and then header stub followed by source stub.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_drivers/senseair/pkg.yml\n\n\n\n\n\n#\n\n\n# Licensed to the Apache Software Foundation (ASF) under one\n\n\n# or more contributor license agreements.  See the NOTICE file\n\n\n# distributed with this work for additional information\n\n\n# regarding copyright ownership.  The ASF licenses this file\n\n\n# to you under the Apache License, Version 2.0 (the\n\n\n# \nLicense\n); you may not use this file except in compliance\n\n\n# with the License.  You may obtain a copy of the License at\n\n\n# \n\n\n#  http:\n//www.apache.org/licenses/LICENSE-2.0\n\n\n#\n\n\n# Unless required by applicable law or agreed to in writing,\n\n\n# software distributed under the License is distributed on an\n\n\n# \nAS IS\n BAS
 IS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n# KIND, either express or implied.  See the License for the\n\n\n# specific language governing permissions and limitations\n\n\n# under the License.\n\n\n#\n\n\npkg\n.\nname\n: \nlibs/my_drivers/senseair\n\n\npkg\n.\ndeps\n:\n    \n-\n \n@apache-mynewt-core/hw/hal\n\n\n\n\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_drivers/senseair/include/senseair/senseair.h\n\n\n\n\n\n/*\n\n\n * Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor license agreements.  See the NOTICE file\n\n\n * distributed with this work for additional information\n\n\n * regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n * with the License.  You may obtain a copy of the License at\n\n\n * \n\n\n *  http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applica
 ble law or agreed to in writing,\n\n\n * software distributed under the License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * specific language governing permissions and limitations\n\n\n * under the License.\n\n\n*/\n\n\n#ifndef _SENSEAIR_H_\n\n\n#define _SENSEAIR_H_\n\n\n\nvoid\n \nsenseair_init\n(\nvoid\n);\n\n\n#endif \n/* _SENSEAIR_H_ */\n\n\n\n\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_drivers/senseair/src/senseair.c\n\n\n\n\n\n/**\n\n\n * Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor license agreements.  See the NOTICE file\n\n\n * distributed with this work for additional information\n\n\n * regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n * with the License.  You may ob
 tain a copy of the License at\n\n\n * \n\n\n *  http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applicable law or agreed to in writing,\n\n\n * software distributed under the License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * specific language governing permissions and limitations\n\n\n * under the License.\n\n\n */\n\n\n\nvoid\n\n\nsenseair_init\n(\nvoid\n)\n{\n}\n\n\n\n\n\nAnd add dependency to this package in my project yml file.\n\n\nHere's from apps/air_quality/pkg.yml\n\n\npkg.name: apps/air_quality\npkg.type: app\npkg.description: Air quality sensor test\npkg.keywords:\n\npkg.deps:\n    - \n@apache-mynewt-core/libs/console/full\n\n    - \n@apache-mynewt-core/libs/newtmgr\n\n    - \n@apache-mynewt-core/libs/os\n\n    - \n@apache-mynewt-core/libs/shell\n\n    - \n@apache-mynewt-core/sys/config\n\n    - \n@apache-mynewt-core/sys/log\n
 \n    - \n@apache-mynewt-core/sys/stats\n\n    - \n@apache-mynewt-core/libs/baselibc\n\n    - libs/my_drivers/senseair\n\n\n\n\n\nAnd add a call to your main() to initialize this driver.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ diff project/blinky/src/main.c project/air_quality/src/main.c\n    28a29\n    \n #include \nsenseair/senseair.h\n\n    190a192\n    \n senseair_init();\n    [user@IsMyLaptop:~/src/air_quality\n\n\n\n\n\nAnd then build it to make sure all goes well.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt build air_q\nCompiling senseair.c\nArchiving senseair.a\nLinking air_quality.elf\nApp successfully built: /Users/user/src/air_quality/bin/air_q/apps/air_quality/air_quality.elf\n\n\n\n\n\nAll looks good.\n\n\nAdd CLI commands for testing drivers\n\n\nWhile developing the driver, you want to issue operations from console asking it to do stuff. The way to do this is to register your command handler with shell. Whenever your custom command is issued, you can respond 
 to it.\n\n\nThe way you do this is first adding a dependency to shell package for your senseair driver. So you change libs/my_drivers/senseair/pkg.yml to have the following:\n\n\npkg.name: libs/my_drivers/senseair\npkg.deps:\n    - \n@apache-mynewt-core/hw/hal\n\n    - \n@apache-mynewt-core/libs/shell\n\n\n\n\n\n\nAnd then register your shell command in \nsenseair_init()\n.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_drivers/senseair/src/senseair.c\n ....\n\n\n\n\n\n#include \nshell/shell.h\n\n\n#include \nconsole/console.h\n\n\n\nstatic\n \nint\n \nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n);\n\nstatic\n \nstruct\n \nshell_cmd\n \nsenseair_cmd\n \n=\n {\n    .\nsc_cmd\n \n=\n \nsenseair\n,\n    .\nsc_cmd_func\n \n=\n \nsenseair_shell_func\n,\n};\n\n\nvoid\n\n\nsenseair_init\n(\nvoid\n)\n{\n    \nint\n \nrc\n;\n\n    \nrc\n \n=\n \nshell_cmd_register\n(\nsenseair_cmd\n);\n    \nassert\n(\nrc\n \n==\n \n0\n);\n}\n\n\nstatic\n \nint\n\n\nsenseair_shell_func\
 n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    \nconsole_printf\n(\nYay! Somebody called!\\n\n);\n    \nreturn\n \n0\n;\n}\n\n\n\n\n\nThen you build this, download to target, and start minicom on your console port.\n\n\n    [user@IsMyLaptop:~]$ minicom -D /dev/tty.usbserial-AH02MIE2\n\n\n    Welcome to minicom 2.7\n\n    OPTIONS: \n    Compiled on Oct 12 2015, 07:48:30.\n    Port /dev/tty.usbserial-AH02MIE2, 13:44:40\n\n    Press CTRL-X Z for help on special keys\n\n    ?\n    141964:Unknown command ?\n    ?\n    143804:config   log     echo    ?       tasks   mempools \n    143806:stat     senseair \n    senseair\n    150644:Yay! Somebody called!\n\n\n\n\n\nNow that's great. You can connect the hardware to board and start developing code for the driver itself.\n\n\nUse of HAL for drivers\n\n\nThe sensor has a serial port connection, and that's how you are going to connect to it. Your original BSP, hw/bsp/stm32f3discovery, has only one UART set up (as specified in src/hal_bsp.c, i
 nclude/hal/bsp.h). Therefore, you need to create your own bsp which has configuration for this added hardware.\n\n\nSo in the shell you make a copy of the original BSP, and then change the package file a little.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ mkdir hw\n[user@IsMyLaptop:~/src/air_quality]$ mkdir hw/bsp\n\n[user@IsMyLaptop:~/src/air_quality]$ cp -R repos/mynewt_stm32f3/hw/bsp/stm32f3discovery hw/bsp/stm32f3discovery_with_senseair\n\n\n\n\n\nThen you modify the pkg.yml in the copied BSP to assign name for this package. And modify the dependency for MCU package to point to mynewt_stm32f3 repository.\n\n\n    [user@IsMyLaptop:~/src/air_quality]$ grep pkg.name hw/bsp/stm32f3discovery_with_senseair/pkg.yml\n    pkg.name: \nhw/bsp/stm32f3discovery_with_senseair\n\n    [user@IsMyLaptop:~/src/air_quality]$ tail -2 hw/bsp/stm32f3discovery_with_senseair/pkg.yml\npkg.deps:\n    - \n@mynewt_stm32f3/hw/mcu/stm/stm32f3xx\n\n\n\n\n\n\nAnd you want to use this BSP with my target. So you ch
 ange the BSP in the target definition.\n\n\nHere's your new target.\n\n\n[user@IsMyLaptop:~/src/air_quality]$ newt target show air_q\ntargets/air_q\n    app=apps/air_quality\n    bsp=hw/bsp/stm32f3discovery_with_senseair\n    build_profile=debug\n\n\n\n\n\nYou add the 2nd serial port to my new BSP. Go to hw/bsp/stm32f3discovery_with_senseair directory to do this.\n\n\nModify the include/hal/bsp.h to increase UART_CNT to 2, and add a definition of the 2nd logical UART. You will use this in your sensor driver.\n\n\nstatic\n \nconst\n \nstruct\n \nstm32f3_uart_cfg\n \nuart_cfg\n[\nUART_CNT\n] \n=\n {\n    [\n0\n] \n=\n {\n        .\nsuc_uart\n \n=\n \nUSART1\n,\n        .\nsuc_rcc_cmd\n \n=\n \nRCC_APB2PeriphClockCmd\n,\n        .\nsuc_rcc_dev\n \n=\n \nRCC_APB2Periph_USART1\n,\n        .\nsuc_pin_tx\n \n=\n \n9\n,\n        .\nsuc_pin_rx\n \n=\n \n10\n,\n        .\nsuc_pin_rts\n \n=\n \n12\n,\n        .\nsuc_pin_cts\n \n=\n \n11\n,\n        .\nsuc_pin_af\n \n=\n \nGPIO_AF_7\n,\n       
  .\nsuc_irqn\n \n=\n \nUSART1_IRQn\n\n    },\n    [\n1\n] \n=\n {\n        .\nsuc_uart\n \n=\n \nUSART2\n,\n        .\nsuc_rcc_cmd\n \n=\n \nRCC_APB1PeriphClockCmd\n,\n        .\nsuc_rcc_dev\n \n=\n \nRCC_APB1Periph_USART2\n,\n        .\nsuc_pin_tx\n \n=\n \n19\n, \n/* PB3 */\n\n        .\nsuc_pin_rx\n \n=\n \n20\n, \n/* PB4 */\n\n        .\nsuc_pin_rts\n \n=\n \n1\n,\n        .\nsuc_pin_cts\n \n=\n \n0\n,\n        .\nsuc_pin_af\n \n=\n \nGPIO_AF_7\n,\n        .\nsuc_irqn\n \n=\n \nUSART2_IRQn\n\n    }\n};\n\n\n\n\n\nWith this in place, you can refer to serial port where your SenseAir sensor is by a logical number. This makes the code more platform independent - you could connect this sensor to another board, like Olimex. You will also use the HAL UART abstraction to do the UART port setup and data transfer. That way you don't need to have any platform dependent pieces within your little driver.\n\n\nYou will now see what the driver code ends up looking like. Here's the header file,
  filled in from stub you created earlier.\n\n\n/*\n\n\n * Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor license agreements.  See the NOTICE file\n\n\n * distributed with this work for additional information\n\n\n * regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n * with the License.  You may obtain a copy of the License at\n\n\n * \n\n\n *  http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applicable law or agreed to in writing,\n\n\n * software distributed under the License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * specific language governing permissions and limitations\n\n\n * under the License.\n\n\n*/\n\n\n#ifndef _SENSEAIR_H_\n\n\n#define _SENSEAIR_H_\n\
 n\n\nenum\n \nsenseair_read_type\n {\n        \nSENSEAIR_CO2\n,\n        \nSENSEAIR_TEMPERATURE\n,\n        \nSENSEAIR_HUMIDITY\n\n};\n\n\nint\n \nsenseair_init\n(\nint\n \nuartno\n);\n\n\nint\n \nsenseair_read\n(\nenum\n \nsenseair_read_type\n);\n\n\n#endif \n/* _SENSEAIR_H_ */\n\n\n\n\n\n\nAs you can see, logical UART number has been added to the init routine. A 'read' function has been added, which is a blocking read. If you were making a commercial product, you would probably have a callback for reporting the results.\n\n\nAnd here is the source for the driver.\n\n\n/**\n\n\n * Licensed to the Apache Software Foundation (ASF) under one\n\n\n * or more contributor license agreements.  See the NOTICE file\n\n\n * distributed with this work for additional information\n\n\n * regarding copyright ownership.  The ASF licenses this file\n\n\n * to you under the Apache License, Version 2.0 (the\n\n\n * \nLicense\n); you may not use this file except in compliance\n\n\n * with the License
 .  You may obtain a copy of the License at\n\n\n *\n\n\n *  http://www.apache.org/licenses/LICENSE-2.0\n\n\n *\n\n\n * Unless required by applicable law or agreed to in writing,\n\n\n * software distributed under the License is distributed on an\n\n\n * \nAS IS\n BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n\n\n * KIND, either express or implied.  See the License for the\n\n\n * specific language governing permissions and limitations\n\n\n * under the License.\n\n\n */\n\n\n#include \nstring.h\n\n\n\n#include \nshell/shell.h\n\n\n#include \nconsole/console.h\n\n\n#include \nos/os.h\n\n\n\n#include \nhal/hal_uart.h\n\n\n\n#include \nsenseair/senseair.h\n\n\n\nstatic\n \nconst\n \nuint8_t\n \ncmd_read_co2\n[] \n=\n {\n    \n0xFE\n, \n0\nX44\n, \n0\nX00\n, \n0\nX08\n, \n0\nX02\n, \n0\nX9F\n, \n0\nX25\n\n};\n\nstatic\n \nconst\n \nuint8_t\n \ncmd_read_temp\n[] \n=\n {\n    \n0xFE\n, \n0\nX44\n, \n0\nX00\n, \n0\nX12\n, \n0\nX02\n, \n0\nX94\n, \n0\nX45\n\n};\n\nstatic\n \nconst\n \nuin
 t8_t\n \ncmd_read_humidity\n[] \n=\n {\n    \n0xFE\n, \n0x44\n, \n0x00\n, \n0x14\n, \n0x02\n, \n0x97\n, \n0xE5\n\n};\n\n\nstatic\n \nint\n \nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n);\n\nstatic\n \nstruct\n \nshell_cmd\n \nsenseair_cmd\n \n=\n {\n    .\nsc_cmd\n \n=\n \nsenseair\n,\n    .\nsc_cmd_func\n \n=\n \nsenseair_shell_func\n,\n};\n\n\nstruct\n \nsenseair\n { \n    \nint\n \nuart\n;\n    \nstruct\n \nos_sem\n \nsema\n;\n    \nconst\n \nuint8_t\n \n*tx_data\n;\n    \nint\n \ntx_off\n;\n    \nint\n \ntx_len\n;\n    \nuint8_t\n \nrx_data\n[\n32\n]; \n    \nint\n \nrx_off\n;\n    \nint\n \nvalue\n;\n} \nsenseair\n;\n\n\nstatic\n \nint\n\n\nsenseair_tx_char\n(\nvoid\n \n*arg\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n \nsenseair\n;\n    \nint\n \nrc\n;\n\n    \nif\n (\ns-\ntx_off\n \n=\n \ns-\ntx_len\n) {\n    \n/*\n\n\n         * Command tx finished.\n\n\n         */\n\n        \ns-\ntx_data\n \n=\n \nNULL\n;\n        \nreturn\n \n-\n1\n;\n    }\n\n    \nrc
 \n \n=\n \ns-\ntx_data\n[\ns-\ntx_off\n];\n    \ns-\ntx_off++\n;\n    \nreturn\n \nrc\n;\n}\n\n\n/*\n\n\n * CRC for modbus over serial port.\n\n\n */\n\n\nstatic\n \nconst\n \nuint16_t\n \nmb_crc_tbl\n[] \n=\n {\n    \n0x0000\n, \n0xcc01\n, \n0xd801\n, \n0x1400\n, \n0xf001\n, \n0x3c00\n, \n0x2800\n, \n0xe401\n,\n    \n0xa001\n, \n0x6c00\n, \n0x7800\n, \n0xb401\n, \n0x5000\n, \n0x9c01\n, \n0x8801\n, \n0x4400\n\n};\n\n\nstatic\n \nuint16_t\n\n\nmb_crc\n(\nconst\n \nuint8_t\n \n*data\n, \nint\n \nlen\n, \nuint16_t\n \ncrc\n)\n{\n    \nwhile\n (\nlen--\n \n \n0\n) {\n        \ncrc\n \n^=\n \n*data++\n;\n        \ncrc\n \n=\n (\ncrc\n \n \n4\n) \n^\n \nmb_crc_tbl\n[\ncrc\n \n \n0xf\n];\n        \ncrc\n \n=\n (\ncrc\n \n \n4\n) \n^\n \nmb_crc_tbl\n[\ncrc\n \n \n0xf\n];\n    }\n    \nreturn\n \ncrc\n;\n}\n\n\nstatic\n \nint\n\n\nmb_crc_check\n(\nconst\n \nvoid\n \n*pkt\n, \nint\n \nlen\n)\n{\n    \nuint16_t\n \ncrc\n, \ncmp\n;\n    \nuint8_t\n \n*bp\n \n=\n (\nuint8_t\n \n*\n)\npkt\n;\n\n 
    \nif\n (\nlen\n \n \nsizeof\n(\ncrc\n) \n+\n \n1\n) {\n        \nreturn\n \n-\n1\n;\n    }\n    \ncrc\n \n=\n \nmb_crc\n(\npkt\n, \nlen\n \n-\n \n2\n, \n0xffff\n);\n    \ncmp\n \n=\n \nbp\n[\nlen\n \n-\n \n2\n] \n|\n (\nbp\n[\nlen\n \n-\n \n1\n] \n \n8\n);\n    \nif\n (\ncrc\n \n!=\n \ncmp\n) {\n        \nreturn\n \n-\n1\n;\n    } \nelse\n {\n        \nreturn\n \n0\n;\n    }\n}\n\n\nstatic\n \nint\n\n\nsenseair_rx_char\n(\nvoid\n \n*arg\n, \nuint8_t\n \ndata\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n (\nstruct\n \nsenseair\n \n*\n)\narg\n;\n    \nint\n \nrc\n;\n\n    \nif\n (\ns-\nrx_off\n \n=\n \nsizeof\n(\ns-\nrx_data\n)) {\n        \ns-\nrx_off\n \n=\n \n0\n;\n    }\n    \ns-\nrx_data\n[\ns-\nrx_off\n] \n=\n \ndata\n;\n    \ns-\nrx_off++\n;\n\n    \nif\n (\ns-\nrx_off\n \n==\n \n7\n) {\n        \nrc\n \n=\n \nmb_crc_check\n(\ns-\nrx_data\n, \ns-\nrx_off\n);\n        \nif\n (\nrc\n \n==\n \n0\n) {\n            \ns-\nvalue\n \n=\n \ns-\nrx_data\n[\n3\n] \n*\n \n256\n \n+\n 
 \ns-\nrx_data\n[\n4\n];\n            \nos_sem_release\n(\ns-\nsema\n);\n        }\n    }\n    \nreturn\n \n0\n;\n}\n\n\nvoid\n\n\nsenseair_tx\n(\nstruct\n \nsenseair\n \n*s\n, \nconst\n \nuint8_t\n \n*tx_data\n, \nint\n \ndata_len\n)\n{\n    \ns-\ntx_data\n \n=\n \ntx_data\n;\n    \ns-\ntx_len\n \n=\n \ndata_len\n;\n    \ns-\ntx_off\n \n=\n \n0\n;\n    \ns-\nrx_off\n \n=\n \n0\n;\n\n    \nhal_uart_start_tx\n(\ns-\nuart\n);\n}\n\n\nint\n\n\nsenseair_read\n(\nenum\n \nsenseair_read_type\n \ntype\n)\n{\n    \nstruct\n \nsenseair\n \n*s\n \n=\n \nsenseair\n;\n    \nconst\n \nuint8_t\n \n*cmd\n;\n    \nint\n \ncmd_len\n;\n    \nint\n \nrc\n;\n\n    \nif\n (\ns-\ntx_data\n) {\n        \n/*\n\n\n         * busy\n\n\n         */\n\n        \nreturn\n \n-\n1\n;\n    }\n    \nswitch\n (\ntype\n) {\n    \ncase\n \nSENSEAIR_CO2\n:\n        \ncmd\n \n=\n \ncmd_read_co2\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncmd_read_co2\n);\n        \nbreak\n;\n    \ncase\n \nSENSEAIR_TEMPERATURE\n:\n       
  \ncmd\n \n=\n \ncmd_read_temp\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncmd_read_temp\n);\n        \nbreak\n;\n    \ncase\n \nSENSEAIR_HUMIDITY\n:\n        \ncmd\n \n=\n \ncmd_read_humidity\n;\n        \ncmd_len\n \n=\n \nsizeof\n(\ncmd_read_humidity\n);\n        \nbreak\n;\n    \ndefault\n:\n\n        \nreturn\n \n-\n1\n;\n    }\n    \nsenseair_tx\n(\ns\n, \ncmd\n, \ncmd_len\n);\n    \nrc\n \n=\n \nos_sem_pend\n(\ns-\nsema\n, \nOS_TICKS_PER_SEC\n \n/\n \n2\n);\n    \nif\n (\nrc\n \n==\n \nOS_TIMEOUT\n) {\n        \n/*\n\n\n         * timeout\n\n\n         */\n\n        \nreturn\n \n-\n2\n;\n    }\n    \nreturn\n \ns-\nvalue\n;\n}\n\n\nstatic\n \nint\n\n\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    \nint\n \nvalue\n;\n    \nenum\n \nsenseair_read_type\n \ntype\n;\n\n    \nif\n (\nargc\n \n \n2\n) {\n\nusage\n:\n        \nconsole_printf\n(\n%s \nco2|temp|humidity\n\\n\n, \nargv\n[\n0\n]);\n        \nreturn\n \n0\n;\n    }\n    \nif\n (\n!strcmp\n(\nargv\n[\
 n1\n], \nco2\n)) {\n        \ntype\n \n=\n \nSENSEAIR_CO2\n;\n    } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \ntemp\n)) {\n        \ntype\n \n=\n \nSENSEAIR_TEMPERATURE\n;\n    } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nhumidity\n)) {\n        \n/*\n\n\n         * timeout\n\n\n         */\n\n        \nreturn\n \n-\n2\n;\n    }\n    \nreturn\n \ns-\nvalue\n;\n}\n\n\nstatic\n \nint\n\n\nsenseair_shell_func\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    \nint\n \nvalue\n;\n    \nenum\n \nsenseair_read_type\n \ntype\n;\n\n    \nif\n (\nargc\n \n \n2\n) {\n\nusage\n:\n        \nconsole_printf\n(\n%s \nco2|temp|humidity\n\\n\n, \nargv\n[\n0\n]);\n        \nreturn\n \n0\n;\n    }\n    \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nco2\n)) {\n        \ntype\n \n=\n \nSENSEAIR_CO2\n;\n    } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \ntemp\n)) {\n        \ntype\n \n=\n \nSENSEAIR_TEMPERATURE\n;\n    } \nelse\n \nif\n (\n!strcmp\n(\nargv\n[\n1\n], \nhumidity\n)) {\n        \ntype\n \
 n=\n \nSENSEAIR_HUMIDITY\n;\n    } \nelse\n {\n        \ngoto\n \nusage\n;\n    }\n    \nvalue\n \n=\n \nsenseair_read\n(\ntype\n);\n    \nif\n (\nvalue\n \n=\n \n0\n) {\n        \nconsole_printf\n(\nGot %d\\n\n, \nvalue\n);\n    } \nelse\n {\n        \nconsole_printf\n(\nError while reading: %d\\n\n, \nvalue\n);\n    }\n    \nreturn\n \n0\n;\n}\n\n\nint\n\n\nsenseair_init\n(\nint\n \nuartno\n)\n{\n    \nint\n \nrc\n;\n    \nstruct\n \nsenseair\n \n*s\n \n=\n \nsenseair\n;\n\n    \nrc\n \n=\n \nshell_cmd_register\n(\nsenseair_cmd\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n\n    \nrc\n \n=\n \nos_sem_init\n(\ns-\nsema\n, \n1\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n    \nrc\n \n=\n \nhal_uart_init_cbs\n(\nuartno\n, \nsenseair_tx_char\n, \nNULL\n,\n      \nsenseair_rx_char\n, \nsenseair\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n    \nrc\n \n=\n \nhal_uart_config\n(\nuartno\n, \n9600\n, \n8\n, \n1\n, \nHAL_UART_PARITY_NONE\
 n,\n      \nHAL_UART_FLOW_CTL_NONE\n);\n    \nif\n (\nrc\n) {\n        \nreturn\n \nrc\n;\n    }\n    \ns-\nuart\n \n=\n \nuartno\n;\n\n    \nreturn\n \n0\n;\n}\n\n\n\n\n\nAnd you modified your main() for senseair driver init.\n\n\nint\n\n\nmain\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n    ....\n    \nsenseair_init\n(\n1\n);\n    ....\n    }\n\n\n\n\n\nYou can see from the code that you are using the HAL interface to open a UART port, and using OS semaphore as a way of blocking the task when waiting for read response to come back from the sensor.", 
             "title": "Adding an air-quality sensor"
         }, 
         {
@@ -507,27 +507,27 @@
         }, 
         {
             "location": "/os/tutorials/air_quality_sensor/#setting-up-source-tree-for-stuff-you-need", 
-            "text": "To start with, you need to create a new app under which you will do this development. So you type in:      $ mkdir $ HOME /src\n    $ cd $ HOME /src\n    $ newt new air_quality  Let's say you are using STM32F3discovery board for this project. You know you need the board support package for that hardware. You can look up its location in the repository, fetch the package list from there, and install the egg for the BSP.      [user@IsMyLaptop:~/src/air_quality]$ newt app add-pkg-list mynewt_stm32f3 https://github.com/runtimeinc/mynewt_stm32f3.git\n    Downloading pkg-list.yml from https://github.com/runtimeinc/mynewt_stm32f3.git/master... ok!\n    Verifying pkg-list.yml format...\n ok!\n    Package list mynewt_stm32f3 successfully installed to application.\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install hw/bsp/stm32f3discovery\n    Downloading mynewt_stm32f3 from https://github.com/runtimeinc/mynewt_stm32f3.git/master... ok!\n    Installing hw/bsp/stm32f
 3discovery\n    Installing hw/mcu/stm/stm32f3xx\n    Error: No package libs/cmsis-core found  Ooops. You forgot to bring in the package list for larva itself. That's the one with most of the packages. Including libs/cmsis-core.  This time you need the latest and greatest from larva, so you want to bring in the 'develop' branch. Note that normally the use of the more stable master branch is recommended. In that case you would drop the '-b develop' from command line.  However, you want to bring in the packages from develop branch. To make that happen you say:      [user@IsMyLaptop:~/src/air_quality]$ newt app add-pkg-list -b develop larva https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva.git\n    Downloading pkg-list.yml from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva.git/develop... ok!\n    Verifying pkg-list.yml format...\n ok!\n    Package list larva successfully installed to application.\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install li
 bs/cmsis-core          Downloading     larva from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/develop... ok!\n    Installing libs/cmsis-core\n    Installation was a success!  That's better. You want to make sure you have all the needed bits for supporting your board; so you decide to build the blinky project for it first.      [user@IsMyLaptop:~/src/air_quality]$ newt pkg install project/blinky\n    Downloading larva from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/develop... ok!\n    Installing project/blinky\n    Installing libs/console/full\n    Installing libs/newtmgr\n    Installing libs/json\n    Installing libs/shell\n    Installing sys/config\n    Installing sys/log\n    Installing sys/stats\n    Installation was a success!\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install compiler/arm-none-eabi-m4\n    Downloading larva from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/develop... ok!\n    Installing compiler/a
 rm-none-eabi-m4\n    Installation was a success!  As you can see, this brought in quite a few other dependencies as well.  Now create a target for it and build it.      [user@IsMyLaptop:~/src/air_quality]$ newt target create blink_f3\n    Creating target blink_f3\n        Target blink_f3 successfully created!\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 arch=cortex_m4\n    Target blink_f3 successfully set arch to cortex_m4\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 bsp=hw/bsp/stm32f3discovery\n    Target blink_f3 successfully set bsp to hw/bsp/stm32f3discovery\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 compiler=arm-none-eabi-m4\n    Target blink_f3 successfully set compiler to arm-none-eabi-m4\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 compiler_def=debug\n    Target blink_f3 successfully set compiler_def to debug\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set blink_f3 project=bli
 nky\n    Target blink_f3 successfully set project to blinky\n    [user@IsMyLaptop:~/src/air_quality]$ newt target build blink_f3\n    Building target blink_f3 (project = blinky)\n     ...\n    [user@IsMyLaptop:~/src/air_quality]$ newt target build blink_f3\n    Building target blink_f3 (project = blinky)\n    Building project blinky\n    Linking blinky.elf\n    /usr/local/Cellar/gcc-arm-none-eabi-49/20150609/bin/../lib/gcc/arm-none-eabi \n    4.9.3/../../../../arm-none-eabi/bin/ld: /Users/user/src/air_quality/project/blinky//bin/    blink_f3/blinky.elf section `.text  will not fit in region `FLASH \n    /usr/local/Cellar/gcc-arm-none-eabi-49/20150609/bin/../lib/gcc/arm-none-eabi 4.9.3/../../../../arm-none-eabi/bin/ld: region `FLASH  overflowed by 5180 bytes\n    collect2: error: ld returned 1 exit status  The error indicates that the images need to be smaller for this board, so you decide to switch over to using baselibc instead of libc.  To do that, you modify the project's egg fil
 e project/blinky/pkg.yml. And add  libs/baselibc  to list of package dependencies (pkg.deps).  Now:      [user@IsMyLaptop:~/src/air_quality]$ newt target build blink_f3\n    Building target blink_f3 (project = blinky)\n    ....\n    Archiving libstm32f3discovery.a\n    Compiling main.c\n    Building project blinky\n    Linking blinky.elf\n    Successfully run!  That's better.  You know that this platform uses bootloader, which means you have to create a target for that too. And download the bootloader package.      [user@IsMyLaptop:~/src/air_quality]$ newt target create boot_f3\n    Creating target boot_f3\n    Target boot_f3 successfully created!\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 arch=cortex_m4\n    newTarget boot_f3 successfully set arch to cortex_m4\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 bsp=hw/bsp/stm32f3discovery\n    newtTarget boot_f3 successfully set bsp to hw/bsp/stm32f3discovery\n    [user@IsMyLaptop:~/src/air_qual
 ity]$ newt target set boot_f3 compiler=arm-none-eabi-m4\n    Target boot_f3 successfully set compiler to arm-none-eabi-m4\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 compiler_def=optimized\n    Target boot_f3 successfully set compiler_def to optimized\n    [user@IsMyLaptop:~/src/air_quality]$ newt target set boot_f3 project=boot\n    Target boot_f3 successfully set project to boot\n    [user@IsMyLaptop:~/src/air_quality]$ newt pkg install project/boot\n    Downloading larva from https://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/develop... ok!\n    Installing project/boot\n    Installing fs/nffs\n    Installing fs/fs\n    Installing libs/bootutil\n    Installing libs/mbedtls\n    Installing libs/console/stub\n    Installation was a success!  And then build it:      newt target build boot_f3\n    ....\n    Linking boot.elf\n    Successfully run!  Next you must download the targets to board, and see that the LED actually blinks. You plug in the STM32F
 3 discovery board to your laptop, and say:      [user@IsMyLaptop:~/src/air_quality]$ newt target download blink_f3\n    Downloading with /Users/user/src/air_quality/hw/bsp/stm32f3discovery/stm32f3discovery_download.sh\n    Downloading /Users/user/src/air_quality/project/blinky/bin/blink_f3/blinky.img to 0x08008000\n    Open On-Chip Debugger 0.9.0 (2015-05-28-12:05)\n    ...\n    target state: halted\n   

<TRUNCATED>


Mime
View raw message