follow up to PR #77
This commit is contained in:
		
							
								
								
									
										10
									
								
								src/boards.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/boards.c
									
									
									
									
									
								
							@@ -42,16 +42,20 @@
 | 
				
			|||||||
//------------- IMPLEMENTATION -------------//
 | 
					//------------- IMPLEMENTATION -------------//
 | 
				
			||||||
void button_init(uint32_t pin)
 | 
					void button_init(uint32_t pin)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN) {
 | 
					  if ( BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN )
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
    nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_HIGH);
 | 
					    nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_HIGH);
 | 
				
			||||||
  } else {
 | 
					  }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
    nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
 | 
					    nrf_gpio_cfg_sense_input(pin, BUTTON_PULL, NRF_GPIO_PIN_SENSE_LOW);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool button_pressed(uint32_t pin)
 | 
					bool button_pressed(uint32_t pin)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return (nrf_gpio_pin_read(pin) == BUTTON_DIR) ? true : false;
 | 
					  uint32_t const active_state = (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN ? 1 : 0);
 | 
				
			||||||
 | 
					  return nrf_gpio_pin_read(pin) == active_state;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void board_init(void)
 | 
					void board_init(void)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,16 +35,10 @@
 | 
				
			|||||||
#ifndef BUTTON_DFU
 | 
					#ifndef BUTTON_DFU
 | 
				
			||||||
#define BUTTON_DFU      BUTTON_1
 | 
					#define BUTTON_DFU      BUTTON_1
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef BUTTON_FRESET
 | 
					#ifndef BUTTON_FRESET
 | 
				
			||||||
#define BUTTON_FRESET   BUTTON_2
 | 
					#define BUTTON_FRESET   BUTTON_2
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifndef BUTTON_DIR
 | 
					 | 
				
			||||||
#if BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN
 | 
					 | 
				
			||||||
  #define BUTTON_DIR   1
 | 
					 | 
				
			||||||
#elif BUTTON_PULL == NRF_GPIO_PIN_PULLUP
 | 
					 | 
				
			||||||
  #define BUTTON_DIR   0
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// The primary LED is usually Red but not in all cases.
 | 
					// The primary LED is usually Red but not in all cases.
 | 
				
			||||||
#define LED_PRIMARY 0
 | 
					#define LED_PRIMARY 0
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user