打印

STM32菜鸟之IAR环境下的C++演示程序包

[复制链接]
20964|44
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hotpower|  楼主 | 2008-1-13 07:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*-----------------------------------------------------------------------
        STM32菜鸟之IAR环境下的C++演示程序包

本程序主要是IAR环境下C++工程的建立,LED/LCD显示及按钮/操作杆的中断.
从而完成IO/中断/定时这菜鸟进化过程中比较重要的前两项,为STM32菜鸟
毕业打下了基础~~~

本程序引用了C++最基本也是不可缺少的内容,多了肯定要被拍砖的~~~
不过C++用于MCU/ARM/DSP俺菜农全用了,而且感觉很爽~~~

哈哈,在近代"生活条件不错时",为何还要过我们那个年代的"苦日子"???
string类不爽吗???class的封装,析构,多态,内联等等不方便吗???

本程序实际是把STM32的LCDDemo简单地拼凑成C++程序,由于俺还在菜鸟阶段
故以调通程序和熟悉固件库为目的,所以拍砖者也别追究俺什么C++用的不当
或不妥刑事责任~~~

要知道自己建立C++工程有多么倒塌才是...俺还没见过网上有什么例程~~~
哈哈~~~还是不见为好,自己琢磨的是不会忘记的,这就是俺菜鸟进化的硬道理.

注: 本压缩包目录E:ManleyEKBoardEKSTM32F

菜农 HotPower@126.com   2008.1.13 6:58 于大雁塔菜地的雪地中
------------------------------------------------------------------------*/


相关链接:http://space.**/Upload/Blog/2008/1/13/908f9626-a4bc-4e26-8e79-3e831c2ea698.rar
沙发
hotpower|  楼主 | 2008-1-13 07:11 | 只看该作者

交完作业,该迷糊了~~~

使用特权

评论回复
板凳
walnutcy| | 2008-1-13 10:20 | 只看该作者

又熬夜了啊??

使用特权

评论回复
地板
hotpower|  楼主 | 2008-1-13 10:24 | 只看该作者

哈哈~~~菜鸟就是熬出来的~~~

使用特权

评论回复
5
sz_kd| | 2008-1-13 10:48 | 只看该作者

大叔这样个练法估计都要成精了

使用特权

评论回复
6
phoenixmy| | 2008-1-13 10:51 | 只看该作者

SZ I服了u


灌水精神真是叫人感动~~~~~~~~~~~~~


言规正传,没有完全用C++啊
还有些文件是c的

而且firmware的库是c写的,要是改起来是不是很费力?

使用特权

评论回复
7
hotpower|  楼主 | 2008-1-13 10:57 | 只看该作者

哈哈~~~现在不都时兴"把握时代脉搏"吗???俺岂能错过???

玩完你就是得出一个结论---"一切都该扔了"~~

"而且firmware的库是c写的,要是改起来是不是很费力?"

可以直接引用的~~~

C++不过是构建程序框架和用户层面的进化.

使用特权

评论回复
8
sz_kd| | 2008-1-13 11:01 | 只看该作者

你做项目用的上这么多型号的MCU吗

使用特权

评论回复
9
phoenixmy| | 2008-1-13 11:02 | 只看该作者

感觉还是图形化配置这个想法不错~~~~~



在脚本基础上。。。

使用特权

评论回复
10
hotpower|  楼主 | 2008-1-13 11:04 | 只看该作者

看见stm32_init.c了吧,俺在Keil里设置好在IAR编译

使用特权

评论回复
11
phoenixmy| | 2008-1-13 11:32 | 只看该作者

这么快就是酷了?版主呢,没见上线啊



刚才上网搜了一下,发现主要流行的是一篇 “Using ARM C++ in Embedded Systems”的**

在一个鼠标的例子的基础上讲了C++的使用

先发个链接过来

http://211.157.110.165/Embedded/20070418/497.zip

使用特权

评论回复
12
hotpower|  楼主 | 2008-1-13 11:37 | 只看该作者

哈哈~~~这贴不穿裤子都难~~~何况它是一夜的心血~~~

本来可以早完,都是你们250楼闹腾的~~~

下来准备写个C++工程创建的步骤图示和要点及为什么要用C++~~~

使用特权

评论回复
13
hotpower|  楼主 | 2008-1-13 11:49 | 只看该作者

倒塌了~~~此文无任何应用价值,更别谈什么实战,晕!!!

使用特权

评论回复
14
phoenixmy| | 2008-1-13 11:58 | 只看该作者

呼呼,我也是刚看完,的确没啥价值~~~



我还看了ARM的编译器和库使用指南

大部分的限制均是与处理器的memory相关

这个比较头大

使用特权

评论回复
15
hotpower|  楼主 | 2008-1-13 12:08 | 只看该作者

这次的STM32的C++构建最头痛,不过类成员函数变中断可能为现

好事呀~~~几乎所有的C++编译器都不允许类成员函数成为中断函数.

既然这次IAR和KEIL都是声明普通的函数即可为一函数指针或地址,

那么这个梦想虽为尝试,但凭借第六感认为是可行的~~~

使用特权

评论回复
16
phoenixmy| | 2008-1-13 12:34 | 只看该作者

A.3

A.3   const type qualifier

      Note

          In C, a const-qualified object at file scope without an
          explicit storage class specifier has external linkage.  In
          C++, it has internal linkage.

      Example

          +- file1 --------------------+
          |      extern const int n;   |
          +----------------------------+
          +- file2 --------------------+
          |      const int n = 10;     |
          +----------------------------+

          In C, object n of file2 has external linkage, so it can
          satisfy the reference to n (also with external linkage) in
          file1.  In C++, object n in file2 has internal linkage,
          and will not satisfy the reference to n in file1.

      Guideline

          Const-qualified objects with external linkage must have an
          explicit extern specifier.

使用特权

评论回复
17
phoenixmy| | 2008-1-13 12:38 | 只看该作者

A.4 Conversion to void *

A.4   Conversion to void *

      Note

          In C, there is a standard conversion from void * to T *
          (for any object type T).  In C++, there is no such
          conversion.  Such conversions require a cast in C++.

          The following Standard C library functions return void *:

              calloc, malloc, realloc, bsearch, memcpy, memmove,
              memchr, memset

          C++ requires an explicit cast when assigning the return
          value of such a function to a pointer to non-void type.

      Example

          int* p;
          p = malloc(10 * sizeof(int));

          In C++, the assignment to p requires an explicit cast, as
          in

          p = (int *)malloc(10 * sizeof(int));

      Guideline

          In C++, use operator new instead of calloc, malloc, or
          realloc.  (See item A.12).

          Ignore the return value of a memcpy, memmove, and memset.
          (They just return their first argument converted to void
          *.)

          For all other functions that return void * (standard or
          user-defined), use an explicit cast when converting the
          return value to another pointer type.

使用特权

评论回复
18
phoenixmy| | 2008-1-13 12:40 | 只看该作者

A.5 Enumeration type

A.5   Enumeration type

      Note

          In C, enumerations are integral types.  A program can
          convert from an enumeration type to an integral type, and
          back, without a cast.  A C program can apply ++ and -- to
          an enumeration object.

          In C++, each enumeration is a distinct type.  There are
          standard conversions from enumeration type to integral
          types, but not from integral types to enumeration types.
          A C++ program cannot apply built-in ++ and --, nor any
          compound assignment (such as +=) to an enumeration object.

      Example

          enum RGB { red, green, blue } rgb;
          ++rgb;

          ++rgb is an error in C++ if it uses the built-in ++
          operator.  It means the same as

          rgb = rgb + 1;

          This is also an error unless you write it with a cast:

          rgb = RGB(rgb + 1);

          The best alternative is to implement an operator++ for
          type RGB, as in

          RBG &operator++(RGB &x)
          {
              return x = RGB(x + 1);
          }

      Guideline

          When converting a C program to C++, provide typesafe
          implementations for operator++ and operator-- as needed
          for enumeration types.

使用特权

评论回复
19
phoenixmy| | 2008-1-13 12:41 | 只看该作者

A.6 Type definition in cast, parameter declarati

A.6   Type definition in cast, parameter declaration, or sizeof

      Note

          In C, types can be defined in a cast expression, parameter
          declaration or sizeof expression.  In C++ they cannot.

      Example

          void func(struct TAG { int a; } st)
          {
              ...
          }

          Here, TAG is defined in the parameter declaration.

      Guideline

          Define a type used in a parameter declaration in the scope
          enclosing the function declaration, or some larger
          enclosing scope.

          Define a type used in a cast expression or sizeof
          expression in the scope enclosing the expression, or some
          larger enclosing scope.

使用特权

评论回复
20
phoenixmy| | 2008-1-13 12:44 | 只看该作者

Maybe this is important:A.10 Keywords added in C++

A.10  Keywords added in C++

      Note

          The following C++ keywords are not keywords in C:

          asm             bool            catch           class
          const_cast      delete          dynamic_cast    explicit
          false           friend          inline          mutable
          namespace       new             operator        private
          protected       public          reinterpret_cast
          static_cast     template        this            throw
          true            try             typeid          typename
          using           virtual         wchar_t

      Example

          int class, new, old;

          This declaration is valid in C, but not in C++.

      Guideline

          Do not use a C++ keyword as an identifier.

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1538

主题

21697

帖子

505

粉丝