你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

为什么最新版的stm32f4xx.h文件中取消了u8, u16, u32的类型定义

[复制链接]
Harry_wu 提问时间:2016-8-23 09:21 /
刚对比了一下最新的STM32F4xx_DFP.2.9.0.pack包和Keil.STM32F4xx_DFP.1.0.8.pac包中的stm32f4xx.h文件, 发现本来在旧的.h文件中对uint_8等有类型定义为u8, 但是新的.h文件中没有了?
有什么特别的原因吗? 我看到的很多工程里面都有用u8, u32定义变量, 如果新版STM32F4xx_DFP.2.9.0.pack包, 更改起来很麻烦.


收藏 评论7 发布时间:2016-8-23 09:21

举报

7个回答
逍遥李 回答时间:2016-8-23 09:29:09
自己加上两句不就好了,也不用更改,不过我还是比较习惯uint8_t
Harry_wu 回答时间:2016-8-23 12:03:32
在新版MDK中, stm32f4xx.h文件是无法修改的, 如果所有.c文件都要用到u8, u32, 岂不得专门建一个.h文件?
QQ截图20160823115510.png
另,附上旧版.h文件中的类型定义:
  1. /** @addtogroup Exported_types
  2.   * @{
  3.   */  
  4. /*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */
  5. typedef int32_t  s32;
  6. typedef int16_t s16;
  7. typedef int8_t  s8;

  8. typedef const int32_t sc32;  /*!< Read Only */
  9. typedef const int16_t sc16;  /*!< Read Only */
  10. typedef const int8_t sc8;   /*!< Read Only */

  11. typedef __IO int32_t  vs32;
  12. typedef __IO int16_t  vs16;
  13. typedef __IO int8_t   vs8;

  14. typedef __I int32_t vsc32;  /*!< Read Only */
  15. typedef __I int16_t vsc16;  /*!< Read Only */
  16. typedef __I int8_t vsc8;   /*!< Read Only */

  17. typedef uint32_t  u32;
  18. typedef uint16_t u16;
  19. typedef uint8_t  u8;

  20. typedef const uint32_t uc32;  /*!< Read Only */
  21. typedef const uint16_t uc16;  /*!< Read Only */
  22. typedef const uint8_t uc8;   /*!< Read Only */

  23. typedef __IO uint32_t  vu32;
  24. typedef __IO uint16_t vu16;
  25. typedef __IO uint8_t  vu8;

  26. typedef __I uint32_t vuc32;  /*!< Read Only */
  27. typedef __I uint16_t vuc16;  /*!< Read Only */
  28. typedef __I uint8_t vuc8;   /*!< Read Only */
复制代码



sunnydevil 回答时间:2016-8-23 13:18:36
Harry_wu 发表于 2016-8-23 12:03
在新版MDK中, stm32f4xx.h文件是无法修改的, 如果所有.c文件都要用到u8, u32, 岂不得专门建一个.h文件?

另 ...

实在要用可以解锁再改吧 不用另外建.h
beebird 回答时间:2016-8-23 15:14:10
这个包老改动,好么?
nashchen17 回答时间:2016-8-24 13:27:38
我也習慣用uin8_t,目前沒問題
Harry_wu 回答时间:2016-8-24 14:45:39
自己建了一个TypeDef.h文件, 发上来, 给有需要的人.

  1. /*****************************************************************************
  2. @File name: MyTypeDef.h
  3. @Description:
  4. @Author: Harry Wu
  5. @Version: V1.0
  6. @Date: 2016-8-23
  7. @History:
  8. *****************************************************************************/

  9. #ifndef _MYTYPEDEF_H_
  10. #define _MYTYPEDEF_H_

  11. #include "core_cm4.h"             /* Cortex-M4 processor and core peripherals */
  12. #include "system_stm32f4xx.h"
  13. #include <stdint.h>

  14. /** @addtogroup Exported_types
  15.   * @{
  16.   */  
  17. /*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */
  18. typedef int32_t  s32;
  19. typedef int16_t s16;
  20. typedef int8_t  s8;

  21. typedef const int32_t sc32;  /*!< Read Only */
  22. typedef const int16_t sc16;  /*!< Read Only */
  23. typedef const int8_t sc8;   /*!< Read Only */

  24. typedef __IO int32_t  vs32;
  25. typedef __IO int16_t  vs16;
  26. typedef __IO int8_t   vs8;

  27. typedef __I int32_t vsc32;  /*!< Read Only */
  28. typedef __I int16_t vsc16;  /*!< Read Only */
  29. typedef __I int8_t vsc8;   /*!< Read Only */

  30. typedef uint32_t  u32;
  31. typedef uint16_t u16;
  32. typedef uint8_t  u8;

  33. typedef const uint32_t uc32;  /*!< Read Only */
  34. typedef const uint16_t uc16;  /*!< Read Only */
  35. typedef const uint8_t uc8;   /*!< Read Only */

  36. typedef __IO uint32_t  vu32;
  37. typedef __IO uint16_t vu16;
  38. typedef __IO uint8_t  vu8;

  39. typedef __I uint32_t vuc32;  /*!< Read Only */
  40. typedef __I uint16_t vuc16;  /*!< Read Only */
  41. typedef __I uint8_t vuc8;   /*!< Read Only */

  42. typedef enum
  43. {
  44.         BOOL_FALSE = 0,
  45.         BOOL_TRUE  = 1
  46. }BOOLEAN;

  47. //typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;

  48. //typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
  49. //#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))

  50. //typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;

  51. #endif
复制代码



MyTypeDef.rar

下载

770 Bytes, 下载次数: 42, 下载积分: ST金币 -1

评分

参与人数 1ST金币 +2 收起 理由
zero99 + 2 神马都是浮云

查看全部评分

myfocus-2048857 回答时间:2016-12-20 17:09:42
学习了,谢谢楼主

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版