使用IAR如何修改STM8S库(一)

    技术2022-05-19  22

    注意:以下修改在IAR for STM8 1.10 SP3下验证,库文件为IAR自带的1.1.1

    1、选择CPU类型(支持STM8S系列设备)

    stm8s.h

    ...

    /* Uncomment the line below according to the target STM8S device used in your

    application.

       Tip: To avoid modifying this file each time you need to switch between these

    devices, you can define the device in your toolchain compiler preprocessor. */

    #if !defined (STM8S208) && !defined (STM8S207) && !defined (STM8S105) && !defined (STM8S103) && !defined (STM8S903)

    #define STM8S208

    /* #define STM8S207 */

    /* #define STM8S105 */ 

    /* #define STM8S103 */

    /* #define STM8S903 */

    #endif

    根据你的CPU类型选择宏定义,比如我这里用的是105系列,则修改为:

    /* #define STM8S208 */

    /* #define STM8S207 */

      #define STM8S105 

    /* #define STM8S103 */

    /* #define STM8S903 */

    选择好CPU类型后,还需查看选择的类型中哪些外设是包含的哪些外设没有包含,将没有包含的外设驱动c文件在工程中去掉

    如105系列没有adc2、can、uart1、uart3

    2、修改stm8s_conf.h文件

    选择好CPU类型后,接下来就是选择要使用的外设了,stm8s_conf.h就是外设驱动选择开关,在用户函数中,只需包含此头文件即可。

    比如程序中需要使用到SPI外设,则将此文件的

    /************************************* SPI ************************************/ /* #define _SPI (1) */

    修改为:

    /************************************* SPI ************************************/ #define _SPI (1)


    最新回复(0)