This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Separate Code from main.c for Nordic Development (separate c file for initialization)

hello,

Every example of nordic is done with only one main.c file , i want to have a separtate new.c and new.h file and take all the code from main.c and put it to the new.c and new.h , In the main file i just want to call only one initialization function this initialization call function will be in the new.c and new.h file

but i was not able to do it i get error , can some one post a sample code for this it will make code clean for me. thanks

looking for ward to answers , with examples would be great

  • This is very easy to do if you format your files properly and include the correct header files. Its always best to modulate your code as much as possible (though C does make this a bit for difficult than an OOP)

  • "Modulate"? I think you mean "modularise"

  • Dividing a 'C' program into separate files has nothing to do with Nordic; the principles are the same for any host system - so any 'C' textbook or reference should help.

    Here are some 'C' learning & reference resources: blog.antronics.co.uk/.../

    What error, exactly, are you getting?

  • I think all of the Nordic examples consist of multiple files?

    Again, it is nothing special or specific to Nordic - it's all standard 'C' stuff.

  • There are several things that must be done correctly and that could go wrong when moving code between files. the question is very general. What errors do you get?