This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1352R: How to disable and remove uart in latest cc13x2 3.30.00.03 sdk sensor_oad_offchip_secure example

Part Number: CC1352R
Other Parts Discussed in Thread: SYSCONFIG

Hi,

I'm trying to disable and remove uart in the latest sensor_oad_offchip_secure example.

In cui.h I read the following:

    By calling CUI_paramsInit() you are setting the cuiParams to their default
    values.

        cuiParams.manageBtns = true
        cuiParams.manageLeds = true
        cuiParams.manageUart = true

    If your application requires special management of buttons, leds, or uart
    the developer can set the parameters appropriately before calling CUI_init()

I then found the following in cui.c:

void CUI_paramsInit(CUI_params_t* _pParams)
{
    _pParams->manageBtns = true;
    _pParams->manageLeds = true;
    _pParams->manageUart = true;
}

But when I change manageUart to false and remove the uart interface in sensor.syscfg, I get compile errors.

I would have thought setting it to false would skip the part below:

 if (_pParams->manageUart)
        {
            gManageUart = true;

            // UART semaphore setup
            Semaphore_construct(&gUartSemStruct, 1, &gSemParams);
            gUartSem = Semaphore_handle(&gUartSemStruct);
            Semaphore_construct(&gMenuSemStruct, 1, &gSemParams);
            gMenuSem = Semaphore_handle(&gMenuSemStruct);

            {
                // General UART setup
                UART_init();
                UART_Params_init(&gUartParams);
                gUartParams.baudRate = 115200;
                gUartParams.writeMode     = UART_MODE_CALLBACK;
                gUartParams.writeDataMode = UART_DATA_BINARY;
                gUartParams.writeCallback = UartWriteCallback;
                gUartParams.readMode      = UART_MODE_CALLBACK;
                gUartParams.readDataMode  = UART_DATA_BINARY;
                gUartParams.readCallback  = UartReadCallback;
                gUartHandle = UART_open(CONFIG_DISPLAY_UART, &gUartParams);
                if (NULL == gUartHandle)
                {
                    return CUI_FAILURE;
                }
                else
                {
                    UART_read(gUartHandle, gUartRxBuffer, sizeof(gUartRxBuffer));
                    UART_control(gUartHandle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL);

                    gUartWriteComplete = true;

                    strncpy(menuBuff, CUI_ESC_CLR CUI_ESC_TRM_MODE CUI_ESC_CUR_HIDE, sizeof(menuBuff));
                    if (CUI_SUCCESS != CUI_writeString(menuBuff, strlen(menuBuff)))
                    {
                        UART_close(gUartHandle);
                        return CUI_FAILURE;
                    }

                    memset(menuBuff, 0, sizeof(menuBuff));
                }
            }

            // Multi Menu Initialization
            {
                memset(gMenuResources, 0, sizeof(gMenuResources) / sizeof(gMenuResources[0]));
                /*
                 *  No additional initialization is needed in the case of a single
                 * menu being registered to the CUI module. In the case of 2 or more
                 * menus being registered the global cuiMultiMenu object will
                 * be used as the top level menu and every registered menu will be a
                 * sub menu of the cuiMultiMenu instead.
                 */
                for (int i = 0; i < MAX_REGISTERED_MENUS + 1; i++)
                {
                    memset(&cuiMultiMenu.menuItems[i], 0, sizeof(cuiMultiMenu.menuItems[i]));
                }
            }

            // Status Lines Setup
            {
                Semaphore_construct(&gStatusSemStruct, 1, &gSemParams);
                gStatusSem = Semaphore_handle(&gStatusSemStruct);
            }
        }

I also tried removing the param from cui.h:

typedef struct {
    bool manageBtns;
    bool manageLeds;
    bool manageUart;
} CUI_params_t;


I would like to be able to disable and remove the led's, buttons and uart without changing a lot of code

  • Hi Jorick,

    Have you tried defining POWER_MEAS inside application/defines/sensor.opts or the Predefined Symbols Project Properties?  This should take care of all LED/BTN/UART initialization that occurs in ssf.c, or at least give you an idea of where to look.  Be sure to clean and rebuild the project after making changes.

    Regards,
    Ryan

  • I know about that, but we have a need to control leds, buttons and uart independently.

    In the previous versions we added predefined symbols with LED_ENABLED etc. and put some if then else statements in the code.

    But I thought with the new cui and manage* parameters we could avoid that and just use true/false.

    As the code is structured now true/false appears to do nothing at all.

  • I did not experience any build errors when _pParams->manageUart = false; in CUI_paramsInit and removing UART initialization from ssf.c, this should disable UART entirely except for pin initialization from sensor.sysconfig which should have a minimal effect on power consumption.

    Regards,
    Ryan

  • Thanks for the answer. I expected the uart initialization would be skipped when setting manageUart to false.

    I will add some code to disable that.