want to add command mode and data mode in DSPS sdk.

Hi Team,

Iam using DSPS sdk: 6.150.6.77, DA14531MOD.

As per my requirement i have to use DSPS sdk for high data flow.

So, further i want to add other feature like,

1. when BT module not connected to host Application it should be set to command mode.

2. when BT module connected to host Application it should be in data mode.

please let me know at which piece of code App connection and disconnection flags are placed.

Regards,

Laxmi Narayana.

  • Hi Laxmi,

    Thank you for the reply.
    Please keep in mind that the SPS SDK was not designed to have the UART enabled all the time. You can test this on your side.
    UART is initialized when we establish a connection, please refer on the user_on_connect callback function

    You can see that we call the dma_uart_on_connect function:

    void dma_uart_on_connect(void){
        dma_uart.tx_size = DEFAULT_TX_SIZE;
        if( app_default_sleep_mode == ARCH_SLEEP_OFF ){
            dma_uart_sps_init(cfg_uart_sps_baudrate, 3);
            dma_uart_rx_activate();
            dma_uart_assert_rts();
        }   
    }


    You could try to remove the dma_uart_on_connect function from the user_on_connection callback and set it on app_on_init callback function. 
    You should keep in mind that when we disconnect the UART will be disabled as well.


    Best Regards,
    OV_Renesas

  • Hi OV,

    Thank you for reply,

    You could try to remove the dma_uart_on_connect function from the user_on_connection callback and set it on app_on_init callback function. 

    I Tried the same, still not able to establish UART communication which App is disconnected.

    Can you help me in this implementation?

    Regards,

    Laxmi Narayana 

  • Hi Laxmi,

    Thank you for the reply.

    Please take above implementation as reference. You can use this to keep UART initialized when you are not connected. On user_on_connection you can disable the UART and let dma_uart_on_connect to initialize it correctly for the Serial Port Service feature.

    Best Regards,
    OV_Renesas

  • Hi OV,

    Thank you for supporting, 

    when Application not connected to BT module i enabled uart in function periph_init() as shown in below 

    Initially i tried to do loopback test to verify UART Tx and Rx. but it didn't worked for me.

    So, I tried to send fixed string ACK. which i able receive the string for first 3 times and further receiving junk bytes continuously as shown below.

     

    Please help me in fixing this issue.

    Regards,

    Laxmi Narayana.

  • Hi Laxmi,

    Thank you for the reply.
    Are you sure you have completed removed the Extended Sleep from your device?
    The SPS SDK will use UART HW Flowcontrol (RTS/CTS) to control the Extended Sleep mode as well.
    On the implementation I shared, we briefly initialize the UART (2-wire) to send some data and then turn it off. 
    The SPS SDK will constantly check (every advertising interval) for the sleep mode via the RTS which has been reconfigured as a normal GPIO.
    This might be the issue that you are facing with the UART transmission.

    I have also not understood if you want to have UART with DMA, with Interrupts or Blocking on your project.

    Best Regards,
    OV_Renesas

  • Hi OV,

    Thank you for quick response,

    Are you sure you have completed removed the Extended Sleep from your device?

    Iam not sure, I followed the printme() function procedure in my implementation.

    As i want to use 2 wire uart when App not connected mode I  calling arch_set_sleep_mode(ARCH_SLEEP_OFF); function. 

    Does this means removing Extended Sleep from device? 

    The SPS SDK will constantly check (every advertising interval) for the sleep mode via the RTS which has been reconfigured as a normal GPIO.

    So, should we use RTS GPIO also?

    I have also not understood if you want to have UART with DMA, with Interrupts or Blocking on your project.

    As i want to use UART communication with interrupt when App is not connected to BT module.

    Regards,

    Laxmi Narayana 

  • Hi OV,

    Can you please update on above point.

    Regards,

    Laxmi Narayana.

  • Hi Laxmi,

    Thank you for the reply.
    Let me clarify:
    The DSPS SDK is supported with Extended Sleep enabled and 4-wire UART with Flow Control enabled when we have a BLE Connection.
    What you are trying to do has not been tested by us and is not supported. 

    I would suggest you try with 4-Wire UART even when not connected. 
    Even if you use the arch_set_sleep_mode API we constantly check the DA14531 state in user_sps_schedule_dma.c file. 
    The Extended sleep mode will be enalbed by the user_on_ble_powered callback function as well.
    The RTS/CTS are also handled there that is why I suggest 4-Wire UART.

    I would suggest you try something similar to the following:

    uint8_t cmd_buffer_single_char[1]= {0};
    
    uint8_t cmd_buffer_send_char[1]= {0};
    void uart_rx_cb(uint16_t status)
    {
    	arch_set_sleep_mode(ARCH_SLEEP_OFF);
    	
    	for(int i=0; i < sizeof(cmd_buffer_single_char); i++)
    	{
    		uart_write_byte(UART1, cmd_buffer_single_char[i]);
    	}
    
        uart_receive(UART1,cmd_buffer_single_char,4,UART_OP_INTR);
    		
    }
    
    
    
    void enable_uart1()
    {
    	
    		arch_set_sleep_mode(ARCH_SLEEP_OFF);
    		//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, OUTPUT, PID_GPIO, true);
        GPIO_ConfigurePin(gpio_uart1_cts.port, gpio_uart1_cts.pin, INPUT_PULLUP, PID_UART1_CTSN, false);
    	
    		//Uart Configuration
        uart_cfg_t uart_cfg = {
    			  .uart_rx_cb = uart_rx_cb,
            .baud_rate = UART_BAUDRATE_921600,
            .data_bits = UART_DATABITS_8,
            .parity = UART_PARITY_NONE,
            .stop_bits = UART_STOPBITS_1,
            .auto_flow_control = UART_AFCE_EN,
            .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,
        };
    
    		   
        uart_receive(UART1,cmd_buffer_single_char,1,UART_OP_INTR);
    		uart_send(UART1, (uint8_t*) cmd_buffer_send_char, 1, UART_OP_BLOCKING);
            
    		
    	
    }
    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);	
    }


    Unfortunately, we cannot provide any further support as the SPS SDK is supported as given, with 4-Wire UART (when connected) and Extended Sleep mode on.

    Best Regards,
    OV_Renesas