找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5445|回复: 0
打印 上一主题 下一主题
收起左侧

stm8s stm8s.h stm8s_conf.h头文件的使用

[复制链接]
跳转到指定楼层
楼主
ID:610433 发表于 2019-9-30 13:49 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
在使用IAR for stm8编程的时候,会使用到stm8s.h的头文件。

官网下载的库函数直接用需要在main.c最后加上这么一段代码,才可以编译通过

#ifdef USE_FULL_ASSERT
void assert_failed(u8* file, u32 line)
{
  while (1)
  {
  }
}
#endif


stm8.h头文件中最开始会有这么一段


/* Uncomment the line below according to the target STM8S or STM8A device used in your
   application. */

/* #define STM8S208 */      /*!< STM8S High density devices with CAN */
/* #define STM8S207 */      /*!< STM8S High density devices without CAN */
/* #define STM8S007 */      /*!< STM8S Value Line High density devices */
/* #define STM8AF52Ax */    /*!< STM8A High density devices with CAN */
  #define STM8AF62Ax */    /*!< STM8A High density devices without CAN */
/* #define STM8S105 */      /*!< STM8S Medium density devices */
/* #define STM8S005 */      /*!< STM8S Value Line Medium density devices */
/* #define STM8AF626x */    /*!< STM8A Medium density devices */
/* #define STM8S103 */      /*!< STM8S Low density devices */
/* #define STM8S003 */      /*!< STM8S Value Line Low density devices */
/* #define STM8S903 */      /*!< STM8S Low density devices */


你可以针对自己的型号将前面的/*去除,另一种方法是不需要自己去除,options->c/c++ compiler->Preprocessor中的defined symbols中加入对应的型号,如STM8AF62Ax
如若不然,会跳出错误,因为h文件中有这一段,未预定义则会报错

#if !defined (STM8S208) && !defined (STM8S207) && !defined (STM8S105) && \
    !defined (STM8S103) && !defined (STM8S903) && !defined (STM8AF52Ax) && \
    !defined (STM8AF62Ax) && !defined (STM8AF626x) && !defined (STM8S007) && \
    !defined (STM8S003)&& !defined (STM8S005)
#error "Please select first the target STM8S/A device used in your application (in stm8s.h file)"
#endif


stm8s_conf.h文件是包含了各个型号可用的外设,如

#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S103) ||\
    defined(STM8S003) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
#include "stm8s_uart1.h"
#endif /* STM8S208 || STM8S207 || STM8S103 ||STM8S903 || STM8AF52Ax || STM8AF62Ax */


可见62ax有uart1 但是62a6并没有uart1只有uart3 没有看到哪里有具体说明小型号对应的编号 可以自己尝试调试

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表