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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

1,170件の閲覧回数
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,130件の閲覧回数
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 件の賞賛
返信