/**@brief Function for initializing the button module. */ static void buttons_init(void) { static app_button_cfg_t buttons[] = { {SEND_MEAS_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler}, {BOND_DELETE_ALL_BUTTON_ID, false, BUTTON_PULL, NULL} }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false); }
/**@brief Initialize button handler module. */ static void buttons_init(void) { static app_button_cfg_t buttons[] = { {KEY_PRESS_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, {BONDMNGR_DELETE_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, NULL} }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true); }
/**@brief Function for initializing the button handler module. */ static void buttons_init(void) { // Note: Array must be static because a pointer to it will be saved in the Button handler // module. static app_button_cfg_t buttons[] = { {WAKEUP_BUTTON_PIN, false, BUTTON_PULL, NULL}, {LEDBUTTON_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler} }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true); }
/**@brief Function for initializing the button handler module. */ static void buttons_init(void) { static app_button_cfg_t buttons[] = { {WAKEUP_BUTTON_PIN, false, NRF_GPIO_PIN_NOPULL, NULL}, {BONDMNGR_DELETE_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, NULL}, {DISPLAY_MESSAGE_BUTTON_PIN, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, {SCROLL_ONE_BUTTON_PIN, false, NRF_GPIO_PIN_NOPULL, button_event_handler} }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false); }
/**@brief Initialize button handler module. */ static void buttons_init(void) { // Configure HR_INC_BUTTON_PIN_NO and HR_DEC_BUTTON_PIN_NO as wake up buttons and also configure // for 'pull up' because the eval board does not have external pull up resistors connected to // the buttons. static app_button_cfg_t buttons[] = { {HR_INC_BUTTON_PIN_NO, false, NRF_GPIO_PIN_PULLUP, button_event_handler}, {HR_DEC_BUTTON_PIN_NO, false, NRF_GPIO_PIN_PULLUP, button_event_handler} // Note: This pin is also BONDMNGR_DELETE_BUTTON_PIN_NO }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false); }
void boardInit(void) { uint32_t error; static app_button_cfg_t button_cfg[BOARD_BUTTON_NUM]; /* Configure and enable the timer app */ APP_TIMER_INIT(CFG_TIMER_PRESCALER, CFG_TIMER_MAX_INSTANCE, CFG_TIMER_OPERATION_QUEUE_SIZE, CFG_SCHEDULER_ENABLE); /* Initialise GPIOTE */ APP_GPIOTE_INIT(CFG_GPIOTE_MAX_USERS); /* LED Settings */ for(uint8_t i=0; i<BOARD_LED_NUM; i++) { nrf_gpio_cfg_output( led_gpio[i] ); } /* Button Settings */ for(uint8_t i=0; i<BOARD_BUTTON_NUM; i++) { /* Pins are configued with pullups since none are present on the PCB */ button_cfg[i] = (app_button_cfg_t) { .pin_no = button_gpio[i], .active_state = BOARD_BUTTON_ACTIVE_STATE ? true : false, .pull_cfg = NRF_GPIO_PIN_PULLUP, .button_handler = button_event_handler }; }; APP_BUTTON_INIT(button_cfg, BOARD_BUTTON_NUM, APP_TIMER_TICKS(BOARD_BUTTON_DETECTION_INTERVAL_MS, CFG_TIMER_PRESCALER), false); /* UART Settings */ app_uart_comm_params_t para_uart = { .rx_pin_no = BOARD_UART_RXD_PIN, .tx_pin_no = BOARD_UART_TXD_PIN, .rts_pin_no = BOARD_UART_RTS_PIN, .cts_pin_no = BOARD_UART_CTS_PIN, .flow_control = APP_UART_FLOW_CONTROL_ENABLED, .use_parity = false, .baud_rate = get_baudrate(CFG_UART_BAUDRATE) }; /* Initialise the UART FIFO */ APP_UART_FIFO_INIT( ¶_uart, CFG_UART_BUFSIZE, CFG_UART_BUFSIZE, board_uart_event_handler, APP_IRQ_PRIORITY_LOW, error); ASSERT_STATUS_RET_VOID( (error_t) error ); }
/**@brief Function for initializing the button module. */ static void buttons_init(void) { uint32_t err_code; // Configure HR_INC_BUTTON_PIN_NO and HR_DEC_BUTTON_PIN_NO as wake up buttons and also configure // for 'pull up' because the eval board does not have external pull up resistors connected to // the buttons. static app_button_cfg_t buttons[] = { {BUTTON_CLEAN_LIST, false, BUTTON_PULL, button_event_handler} // Note: This pin is also BONDMNGR_DELETE_BUTTON_PIN_NO }; APP_BUTTON_INIT(buttons, sizeof (buttons) / sizeof (buttons[0]), BUTTON_DETECTION_DELAY, false); err_code = app_button_enable(); APP_ERROR_CHECK(err_code); }
/**@brief Function for initializing the button handler module. */ static void buttons_init(void) { // Note: Array must be static because a pointer to it will be saved in the Button handler // module. static app_button_cfg_t buttons[] = { {WAKEUP_BUTTON_PIN, APP_BUTTON_ACTIVE_LOW, BUTTON_PULL, NULL}, // YOUR_JOB: Add other buttons to be used: // {MY_BUTTON_PIN, false, BUTTON_PULL, button_event_handler} }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true); // Note: If the only use of buttons is to wake up, the app_button module can be omitted, and // the wakeup button can be configured by // GPIO_WAKEUP_BUTTON_CONFIG(WAKEUP_BUTTON_PIN); }
/**@brief Function for initializing the button handler module. */ void buttons_init(void) { uint32_t err_code; // Configure buttons. static app_button_cfg_t buttons[] = { {BLE_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler}, {GZLL_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler} }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false); // Start handling button presses immediately. err_code = app_button_enable(); APP_ERROR_CHECK(err_code); }
/**@brief Initialize button handler module. */ static void buttons_init(void) { // Configure the button used to send alert to the peer. Configure it as wake up button too. // Configure Buttons. Buttons are used for: // - Clearing of Alerts // - Configuration of Alerts (CCCD) // - Wake-up application static app_button_cfg_t buttons[] = { {WAKEUP_BUTTON_PIN, false, NRF_GPIO_PIN_NOPULL, NULL}, {BONDMNGR_DELETE_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, NULL}, {CLEAR_NEW_ALERT_BUTTON_PIN, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, {CLEAR_UNREAD_ALERT_BUTTON_PIN, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, {NOTIFY_ALL_ALERTS_BUTTON_PIN, false, NRF_GPIO_PIN_NOPULL, button_event_handler} }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false); }
/**@brief Function for application main entry, does not return. */ int main(void) { uint32_t err_code; #ifdef TRACE_UART // Configure and make UART ready for usage. const app_uart_comm_params_t comm_params = { RX_PIN_NUMBER, TX_PIN_NUMBER, RTS_PIN_NUMBER, CTS_PIN_NUMBER, APP_UART_FLOW_CONTROL_DISABLED, false, UART_BAUDRATE_BAUDRATE_Baud38400 }; APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_error_handle, APP_IRQ_PRIORITY_LOW, err_code); APP_ERROR_CHECK(err_code); #endif // Initialize timer module. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); // Initialize GPIOTE module. APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); // Initialize and enable button handler module. static app_button_cfg_t buttons[] = { {BUTTON_0, false, BUTTON_PULL, button_event_handler}, {BUTTON_1, false, BUTTON_PULL, button_event_handler}, }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false); softdevice_setup(); const antfs_params_t params = { ANTFS_CLIENT_SERIAL_NUMBER, ANTFS_CLIENT_DEV_TYPE, ANTFS_CLIENT_MANUF_ID, ANTFS_LINK_FREQ, ANTFS_DEFAULT_BEACON | DATA_AVAILABLE_FLAG_MASK, m_pass_key, m_friendly_name }; antfs_init(¶ms); antfs_channel_setup(); m_pairing_state = PAIRING_OFF; uint8_t event; uint8_t ant_channel; uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE]; bool allow_sleep; for (;;) { allow_sleep = true; // Process ANT-FS event queue. if (antfs_event_extract(&m_antfs_event)) { antfs_event_process(&m_antfs_event); allow_sleep = false; } // Process ANT event queue. if (sd_ant_event_get(&ant_channel, &event, event_message_buffer) == NRF_SUCCESS) { antfs_message_process(event_message_buffer); allow_sleep = false; } // Process user feedback for pairing authentication request. if (m_pairing_state != PAIRING_OFF) { pairing_user_feedback_handle(); // Reset to default state as been processed. m_pairing_state = PAIRING_OFF; allow_sleep = false; } // Sleep if allowed. if (allow_sleep) { err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); } } }