Need help understanding CDE's User Types editor

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help understanding CDE's User Types editor

Jump to solution
822 Views
joeplanisky
Contributor I

Hi everyone,

I'm relatively new to Processor Expert and CodeWarrior MCU and have some questions about creating a new component with the Component Development Environment.  I'm using CW MCU Professional Suite 10.6. I've read through the CDE Getting Started and User Guides.

To keep things simple for now, I want to create a simple software-only component.  That is, a component that just does some operations on some data without accessing any MCU features. 

I have many questions, but for now, I'll limit it to questions about the User Types editor.

1. In the list of user-defined types (i.e. the "This defines:" field), is "Alias" essentially the same as a typedef of a simple type?  For example, if I set "Type Name" to "INDEX" and "Is type" to "int", is that the same as having "typedef int INDEX;" somewhere in my code?

2. If my understanding of #1 is correct, how does that affect the generated code?  That is, does PEX generate the "typedef" for me somewhere?  Or do I have to manually add it myself somewhere?  And if so, where?

3. Is the type "Record" just a C struct? 

4. Same as above, does PEX generate the struct definition for me, or do I have to put it in somewhere?  (If it DOESN'T generate the code, why does it need to know about the fields of the struct?)

5. The type "User" seems to be a catch-all for anything that doesn't quite fit any of the other types.  However, the examples given in the User Guide ("typedef int *TIntPtr;" and "typedef struct { float real; float imaginary; } TComplex") seem like they would be handled by "Alias" and "Record" types if my understanding of them is correct, which makes me think my understanding ISN'T correct.  So what is the point of the "User" type?

6. I don't seem to understand what the "Generate to driver" option does.  The User Guide says "If the declaration is generated in the drivers", which makes me think it means that PEX will insert the declarations for me.  But that doesn't seem to be happening.  When I generate code for my component in a project, I don't see the declarations of my structs anywhere.  That makes me think I don't understand what this checkbox is supposed to do.

That's all my questions for now.  I greatly appreciate any help.

--

Joe

Labels (1)
Tags (2)
0 Kudos
1 Solution
537 Views
Petr_H
NXP Employee
NXP Employee

Hi,

Your expecations are mostly correct, unfortunately, there is a known defect in the CDE that doesn't put the typedef to the driver properly, so the code is not generate for the types.

It has been fixed and the fix will be published in the upcoming Driver Suite 10.4.1 update. We appologize for the inconvenience.

Here are comments to your questions:

1. In the list of user-defined types (i.e. the "This defines:" field), is "Alias" essentially the same as a typedef of a simple type?  For example, if I set "Type Name" to "INDEX" and "Is type" to "int", is that the same as having "typedef int INDEX;" somewhere in my code?

Yes, this is true.

2. If my understanding of #1 is correct, how does that affect the generated code?  That is, does PEX generate the "typedef" for me somewhere?  Or do I have to manually add it myself somewhere?  And if so, where?

Yes, the "typedef" should appear in the generated .h file for the component. However, there is a bug at the moment.

3. Is the type "Record" just a C struct?

Yes, the "record" is a "struct" in C.

4. Same as above, does PEX generate the struct definition for me, or do I have to put it in somewhere?  (If it DOESN'T generate the code, why does it need to know about the fields of the struct?)

Yes, PEx should generate it for you, but there is the already mentioned known problem so it doesn't now.

5. The type "User" seems to be a catch-all for anything that doesn't quite fit any of the other types.  However, the examples given in the User Guide ("typedef int *TIntPtr;" and "typedef struct { float real; float imaginary; } TComplex") seem like they would be handled by "Alias" and "Record" types if my understanding of them is correct, which makes me think my understanding ISN'T correct.  So what is the point of the "User" type?

The User type means that you type the whole "typedef" definition yourself and it's generated into .h

Best regards

Petr Hradsky

View solution in original post

0 Kudos
4 Replies
537 Views
joeplanisky
Contributor I

Let me try something more specific.

One of the methods of a component I'm creating takes a parameter that is a pointer to a custom struct.  How can I get PE to generate the code for that struct in the generated .h file?

In other words, when the user generates code for my component, I want to see this:

Comp1.h

...

typedef struct MyStruct {

    int value1;

    int value2;

} MyStruct;

void Comp1_doWork(MyStruct *pArg);

Comp1.c

void Comp1_doWork(MyStruct *pArg) {

    ...

}

Nothing I've tried so far will give me that generated code.  What do I need to do in the CDE to make it so?

--

Joe

0 Kudos
538 Views
Petr_H
NXP Employee
NXP Employee

Hi,

Your expecations are mostly correct, unfortunately, there is a known defect in the CDE that doesn't put the typedef to the driver properly, so the code is not generate for the types.

It has been fixed and the fix will be published in the upcoming Driver Suite 10.4.1 update. We appologize for the inconvenience.

Here are comments to your questions:

1. In the list of user-defined types (i.e. the "This defines:" field), is "Alias" essentially the same as a typedef of a simple type?  For example, if I set "Type Name" to "INDEX" and "Is type" to "int", is that the same as having "typedef int INDEX;" somewhere in my code?

Yes, this is true.

2. If my understanding of #1 is correct, how does that affect the generated code?  That is, does PEX generate the "typedef" for me somewhere?  Or do I have to manually add it myself somewhere?  And if so, where?

Yes, the "typedef" should appear in the generated .h file for the component. However, there is a bug at the moment.

3. Is the type "Record" just a C struct?

Yes, the "record" is a "struct" in C.

4. Same as above, does PEX generate the struct definition for me, or do I have to put it in somewhere?  (If it DOESN'T generate the code, why does it need to know about the fields of the struct?)

Yes, PEx should generate it for you, but there is the already mentioned known problem so it doesn't now.

5. The type "User" seems to be a catch-all for anything that doesn't quite fit any of the other types.  However, the examples given in the User Guide ("typedef int *TIntPtr;" and "typedef struct { float real; float imaginary; } TComplex") seem like they would be handled by "Alias" and "Record" types if my understanding of them is correct, which makes me think my understanding ISN'T correct.  So what is the point of the "User" type?

The User type means that you type the whole "typedef" definition yourself and it's generated into .h

Best regards

Petr Hradsky

0 Kudos
537 Views
joeplanisky
Contributor I

Thank you very much for your reply, Petr.  While the bug is unfortunate, it's good to know that I was on the right track.  Can you give me a rough idea of when the 10.4.1 driver suite update will be available?

Thanks again.

--

Joe

0 Kudos
537 Views
Petr_H
NXP Employee
NXP Employee

You are welcome. According to the information I have, the update should be released in 2-3 weeks from now.

Best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos