> Why don't you pass the port as an argument to the functions? > Instead of duplicating a lot of code, just duplicate and select between > the code that access the hardware? > > Or you could do as in desktop systems, OpenSPI takes the port number and > returns a handle which must be passed to the other functions or -1 if it > fails? > > This way you could share the SPI ports between threads (if you are using > a RTOS). I do it this way in my designs, for SPI, USART, etc. > > > Isaac > Hi Isaac, Thanks for the reply... Sorry to sound stupid, but you've lost me altogether with "pass the port as an argument to the functions", and "duplicate and select between the code that accesses the hardware" confuses me. Can you suggest an example please? Referring to http://en.wikipedia.org/wiki/Function_prototype , I understand that prototyping functions before using them helps to make the compiler's job easier and prevents confusing errors. I'm not multithreading or using a RTOS here, just trying to configure things politely in C so that I can make use of C's more elegant operators when it comes to data manipulation and processing. NB. I've been using PIC assembly for years, so I'm not familiar with some of the higher-minded C concepts yet! Best regards, Matt. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist