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 CCS Technical Support

How to define a function to port

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



Joined: 30 Jan 2008
Posts: 197

View user's profile Send private message

How to define a function to port
PostPosted: Wed Oct 07, 2020 9:46 am     Reply with quote

Hi, how can I define a function that monitors the logical state of an input already defined?

here I define the port:
Code:
#define btonPANIC   input(PIN_B0)
#define pulsosRTC   PIN_B1
#define btonTEST   input(PIN_B2)


here I want to define the function but how do I relate it to the port?
Code:
void debounce(btonPANIC ????????, char flag){

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19554

View user's profile Send private message

PostPosted: Wed Oct 07, 2020 9:58 am     Reply with quote

How old is your compiler?.
On old compilers, pin numbers have to be a constant, so can't be passed
like this (well can be using some old code that was posted here, but
not using the standard functions). On newer compilers the value can
be a variable:

Code:

void debounce(int16 pin_to_use, char flag){
   x=input(pin_to_use);
   //will then access the specified pin.
}   


However _beware_ it takes dozens of instructions to access a pin declared
as a variable, against just a couple for direct access. So if you want real
speed 'think again'....
temtronic



Joined: 01 Jul 2010
Posts: 9248
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Oct 07, 2020 2:03 pm     Reply with quote

Someone converted the 'button.c' function from PBasic(?) years ago. I think it's in the 'code' forum, well, pretty sure...
Old brain matter isn't um, ah, what it, er, used to be....

Jay
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