Hi,
can we implement DA14531 sending BD address after receiving certain command or custom string in serial port service.
if yes where to call uart_send?
Hi Sanket,Thank you for posting your question online.It would require a lot of development to create a certain command on the SPS SDK.Please refer on the UM-B-088: DA1453x/DA1458x Serial Port Service Reference Application (renesas.com)On SPS, UART is enabled only when there is a BLE connection.In order to implement what you described I did the following:I worked on the SPS SDK v6.150.6.77 with Security enabled.At the top of the user_sps_device_dma.c file I added the following functions:
#include "user_periph_setup.h" #include "uart.h" uint8_t addr2[BD_ADDR_LEN] = {0}; static void enable_uart1() { //Configure UART pins for 2-Wire UART GPIO_ConfigurePin(gpio_uart1_tx.port, gpio_uart1_tx.pin, OUTPUT, PID_UART1_TX, false); GPIO_ConfigurePin(gpio_uart1_rx.port, gpio_uart1_rx.pin, INPUT_PULLUP, PID_UART1_RX, false); GPIO_ConfigurePin(gpio_uart1_rts.port, gpio_uart1_rts.pin, INPUT_PULLUP, PID_GPIO, false); GPIO_ConfigurePin(gpio_uart1_cts.port, gpio_uart1_cts.pin, INPUT_PULLUP, PID_GPIO, false); //Uart Configuration uart_cfg_t uart_cfg = { .baud_rate = UART_BAUDRATE_921600, .data_bits = UART_DATABITS_8, .parity = UART_PARITY_NONE, .stop_bits = UART_STOPBITS_1, .auto_flow_control = UART_AFCE_DIS, .use_fifo = UART_FIFO_EN, .tx_fifo_tr_lvl = UART_TX_FIFO_LEVEL_0, .rx_fifo_tr_lvl = UART_RX_FIFO_LEVEL_0, .intr_priority = 0, }; //Iniitialize UART1 uart_initialize(UART1, &uart_cfg); } static void disable_uart1() { uart_disable(UART1); //Reconfigure UART pins for 4-Wire UART GPIO_ConfigurePin(gpio_uart1_tx.port, gpio_uart1_tx.pin, OUTPUT, PID_UART1_TX, false); GPIO_ConfigurePin(gpio_uart1_rx.port, gpio_uart1_rx.pin, INPUT_PULLUP, PID_UART1_RX, false); GPIO_ConfigurePin(gpio_uart1_rts.port, gpio_uart1_rts.pin, OUTPUT, PID_GPIO, true); GPIO_ConfigurePin(gpio_uart1_cts.port, gpio_uart1_cts.pin, INPUT_PULLUP, PID_UART1_CTSN, false); } static void print_me(void) { arch_set_sleep_mode(ARCH_SLEEP_OFF); //Initialize UART1 enable_uart1(); #if USER_CFG_ADDRESS_MODE == APP_CFG_ADDR_STATIC // Send the BDA uart_send(UART1, addr2, (sizeof(addr2)+ 2), UART_OP_BLOCKING); #else uint32_t bdaddr_msb = (GetWord32(BLE_BDADDRU_REG))&0x1FFFF; uint32_t bdaddr_lsb = (GetWord32(BLE_BDADDRL_REG)); uint8_t addr[6]; memcpy(&addr2, &bdaddr_lsb, 4); memcpy(&addr2[4], &bdaddr_msb, 2); uart_send(UART1, addr2, (sizeof(addr2)+ 2), UART_OP_BLOCKING); #endif //Disable UART1 and reconfigure the UART pins for 4-Wire UART disable_uart1(); arch_set_sleep_mode(app_default_sleep_mode); }
extern uint8_t addr2[BD_ADDR_LEN]; void default_app_generate_static_random_addr(struct bd_addr *addr) { // Check if the static random address is already generated. // If it is already generated the two MSB are equal to '1' if (!(addr->addr[BD_ADDR_LEN - 1] & GAP_STATIC_ADDR)) { // Generate static random address, 48-bits co_write32p(&addr->addr[0], co_rand_word()); co_write16p(&addr->addr[4], co_rand_hword()); // The two MSB shall be equal to '1' addr->addr[BD_ADDR_LEN - 1] |= GAP_STATIC_ADDR; } memcpy(&addr2, &addr->addr, BD_ADDR_LEN); }
In order for the project to be able to compile, you will have to change the value of the MSG_HEAP_SZ on the da14531_config_advanced.h file:#define MSG_HEAP_SZ (4020)
Finally, you can call the print_me function whenever you want inside the user_sps_device_dma.c file.I called it inside the user_advertise_operation(void). Each time we start advertising, we will initialize briefly UART1 and send the BDA to the Host MCU. The Host MCU should handle the BDA and save it on his side.Please also refer on the dsps_uart1_bda.mp4 video as well.
Note: The implementation could change depending on the value of the USER_CFG_ADDRESS_MODE macro.Best Regards,OV_Renesas
Hello,
I'm doing something similar with the DA14531 as a BLE chip connected to another host MCU. The only communication between the host MCU and the DA14531 is through the DMA UART used in the SPS example.
I've successfully built and run the SPS example, and it works as expected, sending data to the BLE app and vice versa.
Since the UART is the only communication channel between the host MCU and the DA14531, the host MCU sends me commands and data, such as a serial number that needs to be added to the advertising packet. I've managed to capture all data coming to the UART and store it in my RX buffer so I can parse those commands.
The problem I'm facing is responding to the host MCU. What is the easiest way for me to send a message to the host MCU from the DA14531 using that one DMA UART?
Hi There,Thank you for posting your question online.Could you please raise a new thread? This thread is 2 months old.You can add the link of this thread on the new one so we can refer here as well.Best Regards,OV_Renesas
Hello,I've raised a new thread here:https://community.renesas.com/wireles-connectivity/f/bluetooth-low-energy/39062/da14531-sps-example-how-to-send-custom-data-to-dma-uartThank you