How to add drivers and some code at MCUXpresso for VSC v.26.2

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

How to add drivers and some code at MCUXpresso for VSC v.26.2

447 Views
KNagai-Private
Contributor II

Hello,

I'm using MCUXpresso for VSC v.26.2.

I want to add drivers and some application code but I could not find any useful document at NXP's web site. 

Could you tell me any documents and/or tutorial, please?

Best regards,

Toshi

Tags (3)
0 Kudos
Reply
3 Replies

419 Views
ErichStyger
Specialist I

The way proposed in MCUXpresso SDK Projects with NXP CMake Format — MCUXpresso SDK Documentation has several disadvantages: it depends on custom/proprietary NXP CMake extension, and you only can add files one by one, plus it it ignores the standard CMake way of doing things, e.g. global options are not honored.

A much easier way and what is using standard CMake files and rules is what I prefer, and what I'm using.

For example:

- create in the project root directory a folder for your sources, e.g. name it 'src'

- place all your .c and .h files into that src folder.

- Add the attached CMakeLists.txt into that src folder. It will build a library with all the sources name 'srcLib'

- in your SDK root CMakeLists.txt, you have to add the following line to reference the CMakeLists.txt:

add_subdirectory(./src  src)
- add the following lines to the root CMakeLists.txt to link with your library:
target_link_libraries(
  ${MCUX_SDK_PROJECT_NAME}
    PUBLIC
    srcLib    # library of src folder
  )

 

That's it: that way you add your own source files to the SDK, and have full control over it with standard CMake features, and do not depend on any CMake extensions.

 

I hope this helps,

Erich

-

 

0 Kudos
Reply

374 Views
KNagai-Private
Contributor II

Hi @ErichStyger and @Harry_Zhang ,

Thank you very much for your advice!

It helps me so much.

I hope it would be good if the documentation on the web will be updated to reflect the most useful content.

Best regards,

Toshi

Tags (3)
0 Kudos
Reply

428 Views
Harry_Zhang
NXP Employee
NXP Employee
0 Kudos
Reply