Hi!,
UART works fine with nrf-ble-tutorial-characteristic-CompletedCode in my nRF51-DK but I'm trying to implement in my application but not works.
These are my includes:
#include <app_error.h>
#include <app_timer.h>
#include <app_uart.h>
#include <app_util.h>
#include <app_util_platform.h>
#include <ble.h>
#include <ble_advdata.h>
#include <ble_advertising.h>
#include <ble_conn_params.h>
#include <ble_gap.h>
#include <ble_gatt.h>
#include <ble_hci.h>
#include <ble_stack_handler_types.h>
#include <ble_types.h>
#include <boards.h>
#include <bsp.h>
#include <bsp_btn_ble.h>
#include <device_manager.h>
#include <nrf_error.h>
#include <nrf_sdm.h>
#include <nrf_soc.h>
#include <nrf52_bitfields.h>
#include <pca10040.h>
#include <pstorage.h>
#include <pstorage_platform.h>
#include <sdk_errors.h>
#include <softdevice_handler.h>
#include <stdbool.h>
#include <string.h>
#include <sys/_stdint.h>
#include "custom_service.h"
static void uart_events_handler(app_uart_evt_t * p_event)
{
switch (p_event->evt_type)
{
case APP_UART_COMMUNICATION_ERROR:
APP_ERROR_HANDLER(p_event->data.error_communication);
break;
case APP_UART_FIFO_ERROR:
APP_ERROR_HANDLER(p_event->data.error_code);
break;
default:
break;
}
}
/**
* @brief Inicialización UART.
*
*/
static void uart_config(void)
{
uint32_t err_code;
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_events_handler,
APP_IRQ_PRIORITY_LOW,
err_code);
APP_ERROR_CHECK(err_code);
}
And my main thread:
int main(void)
{
uint32_t err_code;
bool erase_bonds;
uart_config();
printf("\033[2J\033[;HTest UART on NRF51\r\n");
// Inicializa.
timers_init();
buttons_leds_init(&erase_bonds);
ble_stack_init();
device_manager_init(erase_bonds);
gap_params_init();
servicios_init();
advertising_init();
conn_params_init();
// Inicia ejecución.
application_timers_start();
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
// Entra en el loop principal.
for (;;)
{
power_manage();
}
}
Baud rate of minicom is 38400.
Can you say me where is the error? Thanks.
Regards