'unsigned int' can't convert to 'ADC_Type *' pointer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

'unsigned int' can't convert to 'ADC_Type *' pointer

1,257 次查看
daich
Contributor I
I am using S32K144,and the driver have below code:
#define ADC0_BASE                                (0x4003B000u)
/** Peripheral ADC0 base pointer */
#define ADC0                                     ((ADC_Type *)ADC0_BASE)
but when i use parasoft to check MISRA C 2012, it post "'unsigned int' can't convert to 'ADC_Type *' pointer" ,so how to solve this problem?
thank you very much!
0 项奖励
回复
1 回复

1,217 次查看
jiri_kral
NXP Employee
NXP Employee

Hi, 

 

I'm not familiar with MISRA rules, but I think that definition of address as a macro and casting pointer to different type by this way is against MISRA rules. You can try to define ADC as a pointer and assign the address in it. Something like 

unsigned int adc0*;

adc0=0x4003B000;

 

Jiri

0 项奖励
回复