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)
Previous article:STM8S AD conversion
Next article:STM8S TIM4 library function application
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- Methods for reducing board size and battery consumption in low voltage H-bridge applications
- When the LSM6DS3TR-C is configured with the I2C address, the power consumption is high when the SA0 pin is connected to GND.
- Regarding MCU, here are some ideas for R&D!
- [Erha image recognition artificial intelligence visual sensor] 2: Erha visual sensor and host computer serial port communication experiment
- Has anyone received the GD32E230 board?
- ZigBee transmission based on self-powered switch
- Data searchRSL10-SENSE-DB-GEVK
- KiCad-FPGA programmable logic device chip XC7Z030-2FBG676I motherboard 12-layer PCB file
- MSP430FR2311 LaunchPad Development Kit
- BlueNRG-2 Bluetooth low energy wireless single chip related information