Possibility to add an additional code generator?

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

Possibility to add an additional code generator?

Jump to solution
1,879 Views
The0
Contributor I

Hi 

I was wondering whether it is possible to generate additional .c/.h files with the MCUXpresso Config Tool?

So what I have in mind, the MCUXpresso Config Tool already generates very nice pin_mux.h header files including all the symbols for PORTs and GPIOs. E.g. for the GPIO where my red LED is connected to:

#define BOARD_INITPINS_LED_RED_GPIO GPIO0  /*!<@brief GPIO peripheral base pointer */

With that I would like to generate an additional header file containing same symbols as in pin_mux.h, but with a typecast:

#define LED_RED_PORT (GPIO::Port*)BOARD_INITPINS_LED_RED_GPIO

I fear MCUXpresso Config Tool isn't that flexible. But what do you think, are there any other good approaches/tools to generate such header files each time I run the code generator in MCUXpresso Config Tool?

Best,
THE0

 

 

 

0 Kudos
Reply
1 Solution
1,850 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @The0 

You’re right that the MCUXpresso Config Tool doesn’t have built-in flexibility to generate additional customized .c or .h files with the kind of modifications you’re describing, such as adding typecasts or additional symbols based on the ones in pin_mux.h. However, you can still achieve this by setting up a custom post-processing script that runs after the code generation.

After running the MCUXpresso Config Tool, use a script (Python, Bash, etc.) to read the generated pin_mux.h file, extract the relevant symbols, and create your additional header file (custom_pin_mux.h or similar).

BR

Hang

View solution in original post

0 Kudos
Reply
2 Replies
1,851 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @The0 

You’re right that the MCUXpresso Config Tool doesn’t have built-in flexibility to generate additional customized .c or .h files with the kind of modifications you’re describing, such as adding typecasts or additional symbols based on the ones in pin_mux.h. However, you can still achieve this by setting up a custom post-processing script that runs after the code generation.

After running the MCUXpresso Config Tool, use a script (Python, Bash, etc.) to read the generated pin_mux.h file, extract the relevant symbols, and create your additional header file (custom_pin_mux.h or similar).

BR

Hang

0 Kudos
Reply
1,843 Views
The0
Contributor I

Hi @Harry_Zhang 

Thank you very much for your feedback. I think the approach using a post-processing script should work well.

BR
The0

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1978927%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPossibility%20to%20add%20an%20additional%20code%20generator%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1978927%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3C%2FP%3E%3CP%3EI%20was%20wondering%20whether%20it%20is%20possible%20to%20generate%20additional%20.c%2F.h%20files%20with%20the%20MCUXpresso%20Config%20Tool%3F%3C%2FP%3E%3CP%3ESo%20what%20I%20have%20in%20mind%2C%20the%20MCUXpresso%20Config%20Tool%20already%20generates%20very%20nice%20pin_mux.h%20header%20files%20including%20all%20the%20symbols%20for%20PORTs%20and%20GPIOs.%20E.g.%20for%20the%20GPIO%20where%20my%20red%20LED%20is%20connected%20to%3A%3C%2FP%3E%3CP%3E%3CEM%3E%23define%20BOARD_INITPINS_LED_RED_GPIO%20GPIO0%26nbsp%3B%26nbsp%3B%2F*!%26lt%3B%40brief%20GPIO%20peripheral%20base%20pointer%20*%2F%3C%2FEM%3E%3C%2FP%3E%3CP%3EWith%20that%20I%20would%20like%20to%20generate%20an%20additional%20header%20file%20containing%20same%20symbols%20as%20in%20pin_mux.h%2C%20but%20with%20a%20typecast%3A%3C%2FP%3E%3CP%3E%3CEM%3E%23define%20LED_RED_PORT%20(GPIO%3A%3APort*)BOARD_INITPINS_LED_RED_GPIO%3C%2FEM%3E%3C%2FP%3E%3CP%3EI%20fear%20MCUXpresso%20Config%20Tool%20isn't%20that%20flexible.%20But%20what%20do%20you%20think%2C%20are%20there%20any%20other%20good%20approaches%2Ftools%20to%20generate%20such%20header%20files%20each%20time%20I%20run%20the%20code%20generator%20in%26nbsp%3BMCUXpresso%20Config%20Tool%3F%3C%2FP%3E%3CP%3EBest%2C%3CBR%20%2F%3ETHE0%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1980038%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Possibility%20to%20add%20an%20additional%20code%20generator%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1980038%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F229957%22%20target%3D%22_blank%22%3E%40Harry_Zhang%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EThank%20you%20very%20much%20for%20your%20feedback.%20I%20think%20the%20approach%20using%20a%20post-processing%20script%20should%20work%20well.%3C%2FP%3E%3CP%3EBR%3CBR%20%2F%3EThe0%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1980032%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Possibility%20to%20add%20an%20additional%20code%20generator%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1980032%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F242345%22%20target%3D%22_blank%22%3E%40The0%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%E2%80%99re%20right%20that%20the%20MCUXpresso%20Config%20Tool%20doesn%E2%80%99t%20have%20built-in%20flexibility%20to%20generate%20additional%20customized%20.c%20or%20.h%20files%20with%20the%20kind%20of%20modifications%20you%E2%80%99re%20describing%2C%20such%20as%20adding%20typecasts%20or%20additional%20symbols%20based%20on%20the%20ones%20in%20pin_mux.h.%20However%2C%20you%20can%20still%20achieve%20this%20by%20setting%20up%20a%20custom%20post-processing%20script%20that%20runs%20after%20the%20code%20generation.%3C%2FP%3E%0A%3CP%3EAfter%20running%20the%20MCUXpresso%20Config%20Tool%2C%20use%20a%20script%20(Python%2C%20Bash%2C%20etc.)%20to%20read%20the%20generated%20pin_mux.h%20file%2C%20extract%20the%20relevant%20symbols%2C%20and%20create%20your%20additional%20header%20file%20(custom_pin_mux.h%20or%20similar).%3C%2FP%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EHang%3C%2FP%3E%3C%2FLINGO-BODY%3E