IAR compiles STM8S pin operation to modify the library function

Publisher:alpha12Latest update time:2020-01-12 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

IAR compiles the built-in library functions of STM8S. We all know that there is a definition of each IO port as follows:


typedef enum


{

 GPIO_PIN_0 = ((u8)0x01), /*!< Pin 0 selected */

 GPIO_PIN_1 = ((u8)0x02), /*!< Pin 1 selected */

 GPIO_PIN_2 = ((u8)0x04), /*!< Pin 2 selected */

 GPIO_PIN_3 = ((u8)0x08), /*!< Pin 3 selected */

 GPIO_PIN_4 = ((u8)0x10), /*!< Pin 4 selected */

 GPIO_PIN_5 = ((u8)0x20), /*!< Pin 5 selected */

 GPIO_PIN_6 = ((u8)0x40), /*!< Pin 6 selected */

 GPIO_PIN_7 = ((u8)0x80), /*!< Pin 7 selected */

 GPIO_PIN_LNIB = ((u8)0x0F), /*!< Low nibble pins selected */

 GPIO_PIN_HNIB = ((u8)0xF0), /*!< High nibble pins selected */

 GPIO_PIN_ALL = ((u8)0xFF) /*!< All pins selected */

}GPIO_Pin_TypeDef;


Then when calling GPIO_Pin_TypeDef, if more parameters are passed, a red font prompt will appear. Although it will not have any effect, it looks awkward.


Such as the function void GPIO_WriteBit(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, BitAction GPIO_BitVal)


Operation void GPIO_WriteBit(GPIOA, GPIO_PIN_0 , BitAction GPIO_BitVal) //No alarm will be prompted


Operation void GPIO_WriteBit(GPIOA, GPIO_PIN_0|PIO_PIN_1, BitAction GPIO_BitVal) //will prompt an alarm


Warning[Pe188]: enumerated type mixed with another type C:Program FilesIAR SystemsEmbedded Workbench 6.0stm8examplesST-LINKCopySTM8S105C6-BoardProjectDiscoversrcmain.c 215 


Therefore, I defined the macro as follows, and when I passed multiple parameters again, there was no warning prompt.


#define GPIO_PIN_0 ((u8)0x01) /*!< Pin 0 selected */

#define GPIO_PIN_1 ((u8)0x02) /*!< Pin 1 selected */

#define GPIO_PIN_2 ((u8)0x04) /*!< Pin 2 selected */

#define GPIO_PIN_3 ((u8)0x08) /*!< Pin 3 selected */

#define GPIO_PIN_4 ((u8)0x10) /*!< Pin 4 selected */

#define GPIO_PIN_5 ((u8)0x20) /*!< Pin 5 selected */

#define GPIO_PIN_6 ((u8)0x40) /*!< Pin 6 selected */

#define GPIO_PIN_7 ((u8)0x80) /*!< Pin 7 selected */

#define GPIO_PIN_LNIB ((u8)0x0F)

#define GPIO_PIN_HNIB ((u8)0xF0)

#define GPIO_PIN_ALL ((u8)0xFF)

Reference address:IAR compiles STM8S pin operation to modify the library function

Previous article:STM8S AD conversion
Next article:STM8S TIM4 library function application

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号