This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Understanding the Ble Uart example

So, I'm trying to work around the Ble Uart example, using the PCA10003 Board. The example uses one of the buttons as a "Wakeup" source, but during the bsp_init() call, the button is not really assigned to any event. I've also been looking at the Blinky example, and it seems like that buttons and gpio are handled in very different ways during the two examples.

My real question, is how is the Button really assigned as a wakeup source? Is it just the fact that it is set-up to be "scanned" by the bsp_buttons_enable() call?

In addition, should the two ways of dealing with buttons LEDs be kept separate, or can I use the same technique as the Blinky example to set up a button interrupt to transmit data?

It also seems strange to send data using printf, am I confused, or is printf the "proper" way of sending data to the bluetooth module?

Parents
  • Hi Kjern,

    When calling bsp_buttons_enable() the button will be set with Sense mechanism on (using NRF_GPIO->PIN_CNF). When a pin is set with sense mechanism, I can raise the DETECT signal that can wake the CPU up from system off. You don't need to use any button handler for that. When waking up from system off, the device automatically reset. You can find where we put the device to system off after advertising timeout in BLE_GAP_EVT_TIMEOUT event in on_ble_evt event in main.c

    If you want to set-up a button to trigger a command, you would need to add the handle for button press when calling bsp_init() you can have a look at the ble_app_proximity where we handle button press.

    Regarding printf, it's a way to send data to UART, not to BLE. If you have a look at retarget.c, you can find fputc and __write is the wrap-over for app_uart_put().

Reply
  • Hi Kjern,

    When calling bsp_buttons_enable() the button will be set with Sense mechanism on (using NRF_GPIO->PIN_CNF). When a pin is set with sense mechanism, I can raise the DETECT signal that can wake the CPU up from system off. You don't need to use any button handler for that. When waking up from system off, the device automatically reset. You can find where we put the device to system off after advertising timeout in BLE_GAP_EVT_TIMEOUT event in on_ble_evt event in main.c

    If you want to set-up a button to trigger a command, you would need to add the handle for button press when calling bsp_init() you can have a look at the ble_app_proximity where we handle button press.

    Regarding printf, it's a way to send data to UART, not to BLE. If you have a look at retarget.c, you can find fputc and __write is the wrap-over for app_uart_put().

Children
No Data
Related