工具/软件:Code Composer Studio
您好,
编译以下宏时,我从CCS 6.2 .0.0.005万 收到“#43-D操作数类型不兼容”警告:
#define REINTERPRETER(端口)((( UINT32_t )端口%2)? ( DIO_PORT_OD_Interruptable_Type *)端口:( DIO_PORT_EVENT_Interruptable_Type *)端口)
我的代码按预期工作,但我更喜欢消除此警告。 你们能帮我实现这一目标吗?
提前感谢!
亚历山大·科斯塔
=============================================================================================================================================
/* * GPIO。c * 创建时间:2017年1月27日 * 作者:Alexandre.Costa */ #include "gPIO.h"
#define set_bit(value, bit)( value |=(1 << bit ))
#define clr_bit(value, bit)( value &=~(1 << bit ))
#define Get_bit(value, bit)(( value >> bit)& 0x1)
#define REINTERPRETER(端口)((( UINT32_t )端口%2)? ( DIO_PORT_OD_Interruptable_Type *)端口:( DIO_PORT_EVENT_Interruptable_Type *)端口) void gPIO_Init ( gPIO_Config * config ) { /*选择了通用I/O */ CLR_BIT ( REINTERPRETER ( CONFIG ->端口)-> SEL0,CONFIG -> Pin ); CLR_BIT ( REINTERPRETER ( CONFIG ->端口)-> SEL1,CONFIG ->引脚); /*将通用I/O配置为输入或输出*/ 如果( config -> AsInput ) CLR_BIT ( REINTERPRETER ( CONFIG ->端口)-> DIR,CONFIG ->引脚); 否则 set_bit ( REINTERPRETER ( config -> Port )-> DIR,config -> Pin ); /*配置上拉或下拉电阻器*/ GPIO_ResistorConfig ( config ); :P1 /*获取或设置pin值*/ GPIO更新值( config ); } void GPIO ResistorConfig ( GPIO配置*配置){ /*上拉或下拉电阻器启用寄存器*/ 如果( config -> AsInput ) { 如果( config ->阻器_配置==不带电阻器) CLR_BIT ( REINTERPRETER ( CONFIG ->端口)-> REN,CONFIG ->引脚); 否则 { set_bit ( REINTERPRETER ( config -> Port )-> REN,config -> Pin ); 如果( config -> Resister_Config == a_pulldown ) CLR_BIT ( REINTERPRETER ( config ->端口)->输出,config ->引脚); 否则,如果( config ->阻器_配置== a_pullup ) set_bit ( REINTERPRETER ( config -> Port )-> Out,config -> Pin ); } } } 作废GPIO _UpdateValue ( GPIO配置*配置){ 如果( config -> AsInput ) config -> value = Get_bit ( REINTERPRETER ( config -> Port )-> In,config -> Pin ); 否则 { 如果( config -> value ) set_bit ( REINTERPRETER ( config -> Port )-> Out,config -> Pin ); 否则 CLR_BIT ( REINTERPRETER ( config -> Port )-> Out,config -> Pin ); } }