CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Function with pin in parameter

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Franck26



Joined: 29 Dec 2007
Posts: 122
Location: Ireland

View user's profile Send private message

Function with pin in parameter
PostPosted: Wed Mar 05, 2008 3:51 am     Reply with quote

Hello everybody,
I was wondering what is the best way to have a function with a pin in parameter.
for example:
Code:
DoSomethingWithPin(Pin);


I was thinking to have for parameters a pointer on the port and the number of the pin like that:
Code:
DoSomethingWithPin(unsigned int* Port, unsigned int PinNumber);


But in this case I have 2 parameters...
Is it possible to do it with just one parameter like an unsigned int?

Thanks for any help.
Franck.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 05, 2008 12:16 pm     Reply with quote

Use the CCS pin numbers. These numbers encode the port address
and the bit position of the pin in one number. Use the constants that
are listed in the .H file for your PIC, such as PIN_B1, etc.

The pin numbers consists of the bit position in the lower 3 bits, and
the port address in the upper bits (shifted left by 3 bits).
Franck26



Joined: 29 Dec 2007
Posts: 122
Location: Ireland

View user's profile Send private message

PostPosted: Wed Mar 05, 2008 2:32 pm     Reply with quote

Thanks,
It's exactly what I need.
I knew that CCS is encoding the pin with just one integer, but I was not able to understand the code Embarassed .
Thanks a lot,
Franck.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group