Skip to content

Commit

Permalink
added support for 2nd bind button / modified bind button pos on tinyfish
Browse files Browse the repository at this point in the history
  • Loading branch information
fishpepper committed Jan 15, 2017
1 parent 58c4e8a commit fcaae4f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 21 additions & 5 deletions arch/cc251x/hal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,30 @@ void hal_io_init(void) {
PORT2DIR(BIND_PORT) &= ~(1<<BIND_PIN);
//set pullup/down
PORT2INP(BIND_PORT) &= ~(1<<BIND_PIN);

#ifdef BIND2_PORT
//this board allows two bind buttons, both will work
//set bind2 pin as input
PORT2DIR(BIND2_PORT) &= ~(1<<BIND2_PIN);
//set pullup/down
PORT2INP(BIND2_PORT) &= ~(1<<BIND2_PIN);
#endif
}

uint8_t hal_io_bind_request(void){
if (BIND_PORT & (1<<BIND_PIN)){
//HIGH -> button released
return 0;
}else{
//LOW -> button pressed
//test bind button
if (!(BIND_PORT & (1<<BIND_PIN))){
//LOW -> button pressed
return 1;
}

#ifdef BIND2_PORT
if (!(BIND2_PORT & (1<<BIND2_PIN))){
//LOW -> button2 pressed
return 1;
}
#endif

//no button pressed...
return 0;
}
4 changes: 4 additions & 0 deletions board/tinyfish/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#define BIND_PORT P0
#define BIND_PIN 3

#define BIND2_PORT P2
#define BIND2_PIN 0


//LEDS
#define LED_GREEN_PORT P0
#define LED_GREEN_PIN 4
Expand Down

0 comments on commit fcaae4f

Please sign in to comment.