Announcements

Ever wondered how you could shape the future in collaboration with others? Join us at OktoberTech Asia Pacific and get inspired. Click here to sign up FREE of charge.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

DaGa_4352226
Level 2
10 questions asked 5 replies posted 5 questions asked
Level 2

Hello community,

I am working with the CYBLE-416045-02 chip (with CY8CPROTO-063-BLE KIT) but i am declaring a function in my .h file as the following:

uint8_t WriteCommandPacket(uint16_t cmd);

and the user can send differents commands:

#define CMD_WATER (0x3608)
#define CMD_ALCOHOL (0x3615)
#define CMD_STOP_MEASUREMENT (0x3FF9)
#define CMD_SOFT_RESET (0x0006)
#define CMD_READ_I (0x367C)
#define CMD_READ_II (0xE102)

 

it is why i am using the uint16_t type to send this command. But the PSoC Creattor 4.4 is telling me the following error:

masterI2C.h:68:9: error: conflicting types for 'WriteCommandPacket'
uint8_t WriteCommandPacket(uint16_t cmd);

 

The strage thing that i can use this type inside of the functions

Can someone help me out?

Regards

David!

 

0 Likes
1 Solution
DaGa_4352226
Level 2
10 questions asked 5 replies posted 5 questions asked
Level 2

i do have the project head file and i added the U to the macro but the error was there. What I have done it was to rename the function and that solved the problem... I do not why but it works!

But thanks for your help!

View solution in original post

0 Likes
2 Replies
KyTr_1955226
Level 6
50 solutions authored 250 replies posted 100 replies posted
Level 6

 

I can think of a couple things to check:

Firstly, if it's complaining specifically that the prototype in the header does not match the definition in the source file, check the order in which you are including your headers.  I believe uint16_t is defined in stdint.h, which iirc is included as part of the project.h generated by PSoC Creator on build.  Make sure you are including "project.h" before masterI2C.h. to ensure uint16_t is properly defined before it is used.  Alternatively, you could include <stdint.h> inside masterI2C.h, but I'm not sure if that's strictly "Good C Practice" including headers in other headers.

Does the error specifically occur when you attempt to call the function using one of those macro constants as an argument?  If so, does adding an 'u' or 'U' to the #define macro constant solve the issue?

I.E.

#define CMD_WATER (0x3608u)

I suspect maybe the compiler could possibly be treating the constant as int16_t without the u to specify it is unsigned.

 

 

0 Likes
DaGa_4352226
Level 2
10 questions asked 5 replies posted 5 questions asked
Level 2

i do have the project head file and i added the U to the macro but the error was there. What I have done it was to rename the function and that solved the problem... I do not why but it works!

But thanks for your help!

0 Likes