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.

Compiler/CC2541: Stopwatch

Part Number: CC2541

Tool/software: TI C/C++ Compiler

Hi All,

I am using BLE Stack 1.5.1.1 with CC2541. 

I have a question. Is it possible to create stopwatch kinda thing in CC2541 ?? Like I want to create the timer inside the firmware using CC2541 which will act as a stopwatch. If I pause the timer it will pause and when I resume it, it will resume where it got paused.

Regards,

Yatin Baluja

  • I suppose you can use APIs in OSAL_Timers.c to implement this.

  • Hi YK, 

    I created one event for the same. 

    //********************************************
    if (events & SBP_TIMER_EVT)
    {
    Execution_time1++;
    int i =40000;
    if (Execution_time1>40000)
    {
    LED_OFF();
    }
    osal_stop_timerEx( simpleBLETaskId, SBP_TIMER_EVT);
    return (events ^ SBP_TIMER_EVT);

    if (Execution_time1>0 && Execution_time1<40000)
    {

    }
    osal_start_timerEx( simpleBLETaskId, SBP_TIMER_EVT,40000);
    return (events ^ SBP_TIMER_EVT);

    if ( i >0)
    {
    int new_remaining_time = i-1;
    set_remaining_time(new_remaining_time);
    set_remaining_time(Execution_time1);
    osal_start_timerEx( simpleBLETaskId, SBP_TIMER_EVT,Execution_time1);
    return (events ^ SBP_TIMER_EVT);
    }
    }

    where Execution_time1 = 0; and i =40000;

  • What's you question?

  • okay. Let me explain. I have a device with CC2541 which is APP controlled. In the APP I have 40 seconds of timer. So, when I start the process that 40 seconds timer will start. 

    I want to sync that 40 Seconds timer in the Firmware with CC2541 so that if th ebluetooth got disconnects or APP crashes, Firmware timer will run for the 40 seconds and completes the session. 

    There is also one point which is, when i press the pause button inside the APP which will pause the timer so at the same time timer will get pause inside the Firmware and when i press the play button then timer will start from the remaining time left. 

    So, basically synch the 40 seconds timer between the APP and the CC2541.

    Yatin Baluja 

  • Your code doesn't look like it would work as you expect. I suppose you should do the following logic to make it.

    1. Use osal_start_timerEx to start a 40 seconds timer event.

    2. If APP pause the timer and device receive it, use osal_get_timeoutEx to get the time left for the timer event start in step 1 and keep the time.

    3. If APP press the play button and device receive it, call osal_start_timerEx with the left time kept in step 2 to start the timer again.

    4. When time is up and event is triggered, do whatever your application wants to do.

  • Okay. I will try to use this method and update you. 

    I have one more doubt regarding the battery level indicator as I'm getting the constant 64 value whether the battery is giving 3V or 3.9V or below 3V. 

    adc = (v/3)*2048;
    percent = ((adc - 1250) * 10) + 33 / 35; 

    my formula and I'm using 12-bit resolution and HAL_ADC_CHN_AIN7.

    Regards,

    Yatin Baluja 

  • For ADC, you can refer to

  • Hi YK, 

    I checked that link and I modified my equation as 

    adc = 1.15*889/2047;
    percent = ((adc - 1250) * 10) + 33 / 35;  

    where 1250 is the lowest ADC level.

    as I'm using the 12-bit and AIN7 channel and I tested the firmware but again I'm getting "64" value in result. 

    I'm also attaching the battservice.c file 

    /******************************************************************************
    
     @file  battservice.c
    
     @brief This file contains the Battery service.
    
     Group: WCS, BTS
     Target Device: CC2540, CC2541
    
     ******************************************************************************
     
     Copyright (c) 2012-2020, Texas Instruments Incorporated
     All rights reserved.
    
     IMPORTANT: Your use of this Software is limited to those specific rights
     granted under the terms of a software license agreement between the user
     who downloaded the software, his/her employer (which must be your employer)
     and Texas Instruments Incorporated (the "License"). You may not use this
     Software unless you agree to abide by the terms of the License. The License
     limits your use, and you acknowledge, that the Software may not be modified,
     copied or distributed unless embedded on a Texas Instruments microcontroller
     or used solely and exclusively in conjunction with a Texas Instruments radio
     frequency transceiver, which is integrated into your product. Other than for
     the foregoing purpose, you may not use, reproduce, copy, prepare derivative
     works of, modify, distribute, perform, display or sell this Software and/or
     its documentation for any purpose.
    
     YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
     PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
     INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
     NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
     TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
     NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
     LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
     INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
     OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
     OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
     (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
     Should you have any questions regarding your right to use this Software,
     contact Texas Instruments Incorporated at www.TI.com.
    
     ******************************************************************************
     Release Name: ble_sdk_1.5.1.1
     Release Date: 2020-01-30 19:28:56
     *****************************************************************************/
    
    /*********************************************************************
     * INCLUDES
     */
    #include "bcomdef.h"
    #include "OSAL.h"
    #include "hal_adc.h"
    #include "linkdb.h"
    #include "att.h"
    #include "gatt.h"
    #include "gatt_uuid.h"
    #include "gatt_profile_uuid.h"
    #include "gattservapp.h"
    #include "hiddev.h"
    #include "battservice.h"
    
    
    /*********************************************************************
     * MACROS
     */
    
    /*********************************************************************
     * CONSTANTS
     */
    
    // ADC voltage levels
    #define BATT_ADC_LEVEL_4V           1700
    #define BATT_ADC_LEVEL_2V           1250
    
    #define BATT_LEVEL_VALUE_IDX        2 // Position of battery level in attribute array
    #define BATT_LEVEL_VALUE_CCCD_IDX   3 // Position of battery level CCCD in attribute array
    
    #define BATT_LEVEL_VALUE_LEN        1
    
    /**
     * GATT Characteristic Descriptions
     */
    #define GATT_DESC_LENGTH_UUID            0x3111 // Used with Unit percent
    uint16 v=0;
    
    /*********************************************************************
     * TYPEDEFS
     */
    
    /*********************************************************************
     * GLOBAL VARIABLES
     */
    // Battery service
    CONST uint8 battServUUID[ATT_BT_UUID_SIZE] =
    {
      LO_UINT16(BATT_SERV_UUID), HI_UINT16(BATT_SERV_UUID)
    };
    
    // Battery level characteristic
    CONST uint8 battLevelUUID[ATT_BT_UUID_SIZE] =
    {
      LO_UINT16(BATT_LEVEL_UUID), HI_UINT16(BATT_LEVEL_UUID)
    };
    
    /*********************************************************************
     * EXTERNAL VARIABLES
     */
    
    /*********************************************************************
     * EXTERNAL FUNCTIONS
     */
    
    /*********************************************************************
     * LOCAL VARIABLES
     */
    
    // Application callback
    static battServiceCB_t battServiceCB;
    
    // Measurement setup callback
    static battServiceSetupCB_t battServiceSetupCB = NULL;
    
    // Measurement teardown callback
    static battServiceTeardownCB_t battServiceTeardownCB = NULL;
    
    // Measurement calculation callback
    static battServiceCalcCB_t battServiceCalcCB = NULL;
    
    static uint16 battMinLevel = BATT_ADC_LEVEL_2V; // For VDD/3 measurements
    static uint16 battMaxLevel = BATT_ADC_LEVEL_4V; // For VDD/3 measurements
    
    // Critical battery level setting
    static uint8 battCriticalLevel;
    
    // ADC channel to be used for reading
    static uint8 battServiceAdcCh = HAL_ADC_CHN_AIN7;
    
    /*********************************************************************
     * Profile Attributes - variables
     */
    
    // Battery Service attribute
    static CONST gattAttrType_t battService = { ATT_BT_UUID_SIZE, battServUUID };
    
    // Battery level characteristic
    static uint8 battLevelProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
    static uint8 battLevel = 100;
    static gattCharCfg_t *battLevelClientCharCfg;
    
    // Characteristic Presentation Format of the Battery Level Characteristic.
    static gattCharFormat_t battLevelPresentation = {
      GATT_FORMAT_UINT8,           /* format */
      0,                           /* exponent */
      GATT_UNIT_PERCENTAGE_UUID,   /* unit */
      GATT_NS_BT_SIG,              /* name space */
      GATT_DESC_LENGTH_UUID        /* desc */
    };
    
    // HID Report Reference characteristic descriptor, battery level
    static uint8 hidReportRefBattLevel[HID_REPORT_REF_LEN] =
                 { HID_RPT_ID_BATT_LEVEL_IN, HID_REPORT_TYPE_INPUT };
    
    /*********************************************************************
     * Profile Attributes - Table
     */
    
    static gattAttribute_t battAttrTbl[] =
    {
      // Battery Service
      {
        { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
        GATT_PERMIT_READ,                         /* permissions */
        0,                                        /* handle */
        (uint8 *)&battService                     /* pValue */
      },
    
        // Battery Level Declaration
        {
          { ATT_BT_UUID_SIZE, characterUUID },
          GATT_PERMIT_READ,
          0,
          &battLevelProps
        },
    
          // Battery Level Value
          {
            { ATT_BT_UUID_SIZE, battLevelUUID },
            GATT_PERMIT_READ,
            0,
            &battLevel
          },
    
          // Battery Level Client Characteristic Configuration
          {
            { ATT_BT_UUID_SIZE, clientCharCfgUUID },
            GATT_PERMIT_READ | GATT_PERMIT_WRITE,
            0,
            (uint8 *)&battLevelClientCharCfg
          },
    
          // HID Report Reference characteristic descriptor, batter level input
          {
            { ATT_BT_UUID_SIZE, reportRefUUID },
            GATT_PERMIT_READ,
            0,
            hidReportRefBattLevel
          },
          
          // Characteristic Presentation format
          {
            { ATT_BT_UUID_SIZE, charFormatUUID },
            GATT_PERMIT_READ,
            0,
            (uint8 *)&battLevelPresentation
          },
    };
    
    
    /*********************************************************************
     * LOCAL FUNCTIONS
     */
    static bStatus_t battReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                     uint8 *pValue, uint8 *pLen, uint16 offset,
                                     uint8 maxLen, uint8 method );
    static bStatus_t battWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                      uint8 *pValue, uint8 len, uint16 offset,
                                      uint8 method );
    
    static void battNotifyCB( linkDBItem_t *pLinkItem );
    static uint8 battMeasure( void );
    static void battNotifyLevel( void );
    
    /*********************************************************************
     * PROFILE CALLBACKS
     */
    // Battery Service Callbacks
    CONST gattServiceCBs_t battCBs =
    {
      battReadAttrCB,  // Read callback function pointer
      battWriteAttrCB, // Write callback function pointer
      NULL             // Authorization callback function pointer
    };
    
    /*********************************************************************
     * PUBLIC FUNCTIONS
     */
    
    /*********************************************************************
     * @fn      Batt_AddService
     *
     * @brief   Initializes the Battery Service by registering
     *          GATT attributes with the GATT server.
     *
     * @return  Success or Failure
     */
    bStatus_t Batt_AddService( void )
    {
      uint8 status;
    
      // Allocate Client Characteristic Configuration table
      battLevelClientCharCfg = (gattCharCfg_t *)osal_mem_alloc( sizeof ( gattCharCfg_t ) * 
                                                                linkDBNumConns );
      if ( battLevelClientCharCfg == NULL )
      {
        return ( bleMemAllocError );
      }
      
      // Initialize Client Characteristic Configuration attributes
      GATTServApp_InitCharCfg( INVALID_CONNHANDLE, battLevelClientCharCfg );
    
      // Register GATT attribute list and CBs with GATT Server App
      status = GATTServApp_RegisterService( battAttrTbl,
                                            GATT_NUM_ATTRS( battAttrTbl ),
                                            GATT_MAX_ENCRYPT_KEY_SIZE,
                                            &battCBs );
    
      return ( status );
    }
    
    /*********************************************************************
     * @fn      Batt_Register
     *
     * @brief   Register a callback function with the Battery Service.
     *
     * @param   pfnServiceCB - Callback function.
     *
     * @return  None.
     */
    extern void Batt_Register( battServiceCB_t pfnServiceCB )
    {
      battServiceCB = pfnServiceCB;
    }
    
    /*********************************************************************
     * @fn      Batt_SetParameter
     *
     * @brief   Set a Battery Service parameter.
     *
     * @param   param - Profile parameter ID
     * @param   len - length of data to right
     * @param   value - pointer to data to write.  This is dependent on
     *          the parameter ID and WILL be cast to the appropriate
     *          data type (example: data type of uint16 will be cast to
     *          uint16 pointer).
     *
     * @return  bStatus_t
     */
    bStatus_t Batt_SetParameter( uint8 param, uint8 len, void *value )
    {
      bStatus_t ret = SUCCESS;
    
      switch ( param )
      {
        case BATT_PARAM_CRITICAL_LEVEL:
          battCriticalLevel = *((uint8*)value);
    
          // If below the critical level and critical state not set, notify it
          if ( battLevel < battCriticalLevel )
          {
            battNotifyLevel();
          }
          break;
    
        default:
          ret = INVALIDPARAMETER;
          break;
      }
    
      return ( ret );
    }
    
    /*********************************************************************
     * @fn      Batt_GetParameter
     *
     * @brief   Get a Battery Service parameter.
     *
     * @param   param - Profile parameter ID
     * @param   value - pointer to data to get.  This is dependent on
     *          the parameter ID and WILL be cast to the appropriate
     *          data type (example: data type of uint16 will be cast to
     *          uint16 pointer).
     *
     * @return  bStatus_t
     */
    bStatus_t Batt_GetParameter( uint8 param, void *value )
    {
      bStatus_t ret = SUCCESS;
      switch ( param )
      {
        case BATT_PARAM_LEVEL:
          *((uint8*)value) = battLevel;
          break;
    
        case BATT_PARAM_CRITICAL_LEVEL:
          *((uint8*)value) = battCriticalLevel;
          break;
    
        case BATT_PARAM_SERVICE_HANDLE:
          *((uint16*)value) = GATT_SERVICE_HANDLE( battAttrTbl );
          break;
    
        case BATT_PARAM_BATT_LEVEL_IN_REPORT:
          {
            hidRptMap_t *pRpt = (hidRptMap_t *)value;
    
            pRpt->id = hidReportRefBattLevel[0];
            pRpt->type = hidReportRefBattLevel[1];
            pRpt->handle = battAttrTbl[BATT_LEVEL_VALUE_IDX].handle;
            pRpt->pCccdAttr = &battAttrTbl[BATT_LEVEL_VALUE_CCCD_IDX];
            pRpt->mode = HID_PROTOCOL_MODE_REPORT;
          }
          break;
    
        default:
          ret = INVALIDPARAMETER;
          break;
      }
    
      return ( ret );
    }
    
    /*********************************************************************
     * @fn          Batt_MeasLevel
     *
     * @brief       Measure the battery level and update the battery
     *              level value in the service characteristics.  If
     *              the battery level-state characteristic is configured
     *              for notification and the battery level has changed
     *              since the last measurement, then a notification
     *              will be sent.
     *
     * @return      Success
     */
    bStatus_t Batt_MeasLevel( void )
    {
      uint8 level;
    
      level = battMeasure();
    
      // If level has gone down
      if (level<battLevel)
      {
        // Update level
        battLevel = level;
    
        // Send a notification
        battNotifyLevel();
      }
    
      return SUCCESS;
    }
    
    /*********************************************************************
     * @fn      Batt_Setup
     *
     * @brief   Set up which ADC source is to be used. Defaults to VDD/3.
     *
     * @param   adc_ch - ADC Channel, e.g. HAL_ADC_CHN_AIN6
     * @param   minVal - max battery level
     * @param   maxVal - min battery level
     * @param   sCB - HW setup callback
     * @param   tCB - HW tear down callback
     * @param   cCB - percentage calculation callback
     *
     * @return  none.
     */
    void Batt_Setup( uint8 adc_ch, uint16 minVal, uint16 maxVal,
                     battServiceSetupCB_t sCB, battServiceTeardownCB_t tCB,
                     battServiceCalcCB_t cCB )
    {
      battServiceAdcCh = adc_ch;
      battMinLevel = minVal;
      battMaxLevel = maxVal;
    
      battServiceSetupCB = sCB;
      battServiceTeardownCB = tCB;
      battServiceCalcCB = cCB;
    }
    
    /*********************************************************************
     * @fn          battReadAttrCB
     *
     * @brief       Read an attribute.
     *
     * @param       connHandle - connection message was received on
     * @param       pAttr - pointer to attribute
     * @param       pValue - pointer to data to be read
     * @param       pLen - length of data to be read
     * @param       offset - offset of the first octet to be read
     * @param       method - type of read message 
     *
     * @return      SUCCESS, blePending or Failure
     */
    static bStatus_t battReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                     uint8 *pValue, uint8 *pLen, uint16 offset,
                                     uint8 maxLen, uint8 method )
    {
      bStatus_t status = SUCCESS;
    
      // Make sure it's not a blob operation (no attributes in the profile are long)
      if ( offset > 0 )
      {
        return ( ATT_ERR_ATTR_NOT_LONG );
      }
    
      uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1] );
    
      // Measure battery level if reading level
      if ( uuid == BATT_LEVEL_UUID )
      {
        uint8 level;
    
        level = battMeasure();
    
        // If level has gone down
        if (level<battLevel)
        {
          // Update level
          battLevel = level;
        }
    
        *pLen = 1;
        pValue[0] = battLevel;
      }
      else if ( uuid == GATT_REPORT_REF_UUID )
      {
        *pLen = HID_REPORT_REF_LEN;
        osal_memcpy( pValue, pAttr->pValue, HID_REPORT_REF_LEN );
      }
      else
      {
        status = ATT_ERR_ATTR_NOT_FOUND;
      }
    
      return ( status );
    }
    
    /*********************************************************************
     * @fn      battWriteAttrCB
     *
     * @brief   Validate attribute data prior to a write operation
     *
     * @param   connHandle - connection message was received on
     * @param   pAttr - pointer to attribute
     * @param   pValue - pointer to data to be written
     * @param   len - length of data
     * @param   offset - offset of the first octet to be written
     * @param   method - type of write message 
     *
     * @return  SUCCESS, blePending or Failure
     */
    static bStatus_t battWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                      uint8 *pValue, uint8 len, uint16 offset,
                                      uint8 method )
    {
      bStatus_t status = SUCCESS;
    
      uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
      switch ( uuid )
      {
        case GATT_CLIENT_CHAR_CFG_UUID:
          status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                                   offset, GATT_CLIENT_CFG_NOTIFY );
          if ( status == SUCCESS )
          {
            uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
    
            if ( battServiceCB )
            {
              (*battServiceCB)( (charCfg == GATT_CFG_NO_OPERATION) ?
                                BATT_LEVEL_NOTI_DISABLED :
                                BATT_LEVEL_NOTI_ENABLED);
            }
          }
          break;
    
        default:
          status = ATT_ERR_ATTR_NOT_FOUND;
          break;
      }
    
      return ( status );
    }
    
    /*********************************************************************
     * @fn          battNotifyCB
     *
     * @brief       Send a notification of the level state characteristic.
     *
     * @param       connHandle - linkDB item
     *
     * @return      None.
     */
    static void battNotifyCB( linkDBItem_t *pLinkItem )
    {
      if ( pLinkItem->stateFlags & LINK_CONNECTED )
      {
        uint16 value = GATTServApp_ReadCharCfg( pLinkItem->connectionHandle,
                                                battLevelClientCharCfg );
        if ( value & GATT_CLIENT_CFG_NOTIFY )
        {
          attHandleValueNoti_t noti;
              
          noti.pValue = GATT_bm_alloc( pLinkItem->connectionHandle,
                                       ATT_HANDLE_VALUE_NOTI, 
                                       BATT_LEVEL_VALUE_LEN, NULL );
          if ( noti.pValue != NULL )
          {
            noti.handle = battAttrTbl[BATT_LEVEL_VALUE_IDX].handle;
            noti.len = BATT_LEVEL_VALUE_LEN;
            noti.pValue[0] = battLevel;
    
            if ( GATT_Notification( pLinkItem->connectionHandle, &noti, FALSE ) != SUCCESS )
            {
              GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
            }
          }
        }
      }
    }
    
    /*********************************************************************
     * @fn      battMeasure
     *
     * @brief   Measure the battery level with the ADC and return
     *          it as a percentage 0-100%.
     *
     * @return  Battery level.
     */
    static uint8 battMeasure( void )
    {
      uint16 adc = 0;
      uint8 percent;
    
      /**
       * Battery level conversion from ADC to a percentage:
       *
       * The maximum ADC value for the battery voltage level is 511 for a
       * 10-bit conversion.  The ADC value is references vs. 1.25v and
       * this maximum value corresponds to a voltage of 3.75v.
       *
       * For a coin cell battery 3.0v = 100%.  The minimum operating
       * voltage of the CC2540 is 2.0v so 2.0v = 0%.
       *
       * To convert a voltage to an ADC value use:
       *
       *   (v/3)/1.25 * 511 = adc
       *
       * 3.0v = 409 ADC
       * 2.0v = 273 ADC
       *
       * We need to map ADC values from 409-273 to 100%-0%.
       *
       * Normalize the ADC values to zero:
       *
       * 409 - 273 = 136
       *
       * And convert ADC range to percentage range:
       *
       * percent/adc = 100/136 = 25/34
       *
       * Resulting in the final equation, with round:
       *
       * percent = ((adc - 273) * 25) + 33 / 34
       */
       adc = 1.15*889/2047;
       percent = ((adc - 1250) * 10) + 33 / 35;
      // Call measurement setup callback
      if (battServiceSetupCB != NULL)
      {
        battServiceSetupCB();
      }
    
      // Configure ADC and perform a read
      HalAdcSetReference( HAL_ADC_REF_AIN7 );
      adc = HalAdcRead( battServiceAdcCh, HAL_ADC_RESOLUTION_12);
    
      // Call measurement teardown callback
      if (battServiceTeardownCB != NULL)
      {
        battServiceTeardownCB();
      }
    
      if (adc >= battMaxLevel)
      {
        percent = 100;
      }
      else if (adc <= battMinLevel)
      {
        percent = 0;
      }
      else
      {
        if (battServiceCalcCB != NULL)
        {
          percent = battServiceCalcCB(adc);
        }
        else
        {
          uint16 range =  battMaxLevel - battMinLevel + 1;
    
          // optional if you want to keep it even, otherwise just take floor of divide
          // range += (range & 1);
          range >>= 2; // divide by 4
    
          percent = (uint8) ((((adc - battMinLevel) * 25) + (range - 1)) / range);
        }
      }
    
      return percent;
    }
    
    /*********************************************************************
     * @fn      battNotifyLevelState
     *
     * @brief   Send a notification of the battery level state
     *          characteristic if a connection is established.
     *
     * @return  None.
     */
    static void battNotifyLevel( void )
    {
      // Execute linkDB callback to send notification
      linkDB_PerformFunc( battNotifyCB );
    }
    
    
    /*********************************************************************
    *********************************************************************/
    

  • I suggest you to test the example codes in the link first.

  • You mean this link:

    https://sunmaysky.blogspot.com/search/label/ADC

    Regards,

    Yatin Baluja 

  • My given link is

  • I will test it tomorrow and update you.

    Regards,

    Yatin Baluja