nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Button Debounce Example Application main file. More...

Macros

#define DEBOUNCE_TIME_IN_MS   (50U)
 
#define DEBOUNCE_INPUT_SAMPLING_FREQ   (60U)
 
#define TIMER0_PRESCALER   (9UL)
 
#define TIMER0_CLOCK   (SystemCoreClock >> TIMER0_PRESCALER)
 
#define MS_TO_TIMER0_TICKS(ms)   ((1000000UL * ms) / (TIMER0_CLOCK))
 
#define MAX_BUTTONS   (8U)
 

Functions

void TIMER0_IRQHandler (void)
 Interrupt handler function for the Timer 0 peripheral.
 
static void timer0_init (void)
 Function for initializing Timer 0.
 
int main (void)
 Function for application main entry.
 

Variables

static uint_fast16_t timer0_cc0_period
 
static deb_t button [MAX_BUTTONS]
 

Detailed Description

This file contains the source code for a sample application using button debouncing.

example_board_setup_a.jpg
Use board setup A for this example.

Macro Definition Documentation

#define DEBOUNCE_TIME_IN_MS   (50U)

Debounce timer in milliseconds

#define DEBOUNCE_INPUT_SAMPLING_FREQ   (60U)

Input sampling frequency in Hertz

#define TIMER0_PRESCALER   (9UL)

Timer 0 prescaler

#define TIMER0_CLOCK   (SystemCoreClock >> TIMER0_PRESCALER)

Timer clock frequency

#define MS_TO_TIMER0_TICKS (   ms)    ((1000000UL * ms) / (TIMER0_CLOCK))

Converts milliseconds to timer ticks

#define MAX_BUTTONS   (8U)

Maximum number of buttons in use

Variable Documentation

uint_fast16_t timer0_cc0_period
static

Period between debouncer input reads.

deb_t button[MAX_BUTTONS]
static

Debounced button state holder