Nuttx下新建路径以及motors

前言

之前在nuttx下编写应用的时候,陷入了之前写单片机代码的误区,没有很好的讲逻辑层和驱动层的代码分割开来,
导致写出来的程序,可读性和可移植性太差,这次参考ardupilot的思路重新整理下实现的过程;

目标

实现一个电机接口库,具体目标如下:
1.这个库应该是建立在nuttx上;
2.利用os原有的PWM驱动以及IO驱动实现电机的控制接口;
3.抽象出电机模型(例如差速模型、姿态模型、自行车模型、单电机模型...);
4.文件目录层级:
	|—../app/libraries
					|—motor
							|—差速模型(*.c、.h、.....)
							|—自行车模型(*.c、.h、.....)
							|—.......
							|—单电机模型(*.c、.h、.....)
					|—InertialSensor
					....
					|—编译文件(makefile、Kconfig、make.dep、make.defs)

文件的大概目录就是这样,下面结合实际的例子来详细说明。

libraries

 libraries这个文件夹是新建的,就从这里开始吧~

然后编译器在编译的时候才找得到新建的源文件,从而编译;
首先在app下面按照上面的文件目录层级建立好所需要的源文件,接下怎么呢?
刚开始我蒙圈了,经验告诉我去看看readme,里面有如下描述:(我就只挑重点的来了)

Building NuttX with Board-Specific Pieces Outside the Source Tree
-----------------------------------------------------------------
   3) If you like the random collection of stuff in the apps/ directory
      but just want to expand the existing components with your own,
      external sub-directory then there is an easy way to that too:
      You just create a sympolic link in the apps/ directory that
      redirects to your application sub-directory.

      In order to be incorporated into the build, the directory that
      you link under the apps/ directory should contain (1) a Makefile
      that supports the clean and distclean targets (see other Makefiles
      for examples), and (2) a tiny Make.defs file that simply adds the
      custon build directories to the variable CONFIGURED_APPS like:

        CONFIGURED_APPS += my_directory1 my_directory2

      The apps/Makefile will always automatically check for the
      existence of subdirectories containing a Makefile and a Make.defs
      file.  The Makefile will be used only to support cleaning ope
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值