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.

SIMPLELINK-CC2640R2-SDK: ADC | Battery monitor issue

Part Number: SIMPLELINK-CC2640R2-SDK
Other Parts Discussed in Thread: CC2640R2F, CC2640

Hi Team,

TI Part no: CC2640R2
IDE: Code Composer Studio

I want to monitor the battery voltage(Which is connected Externally ). In SIMPLELINK-CC2640R2-SDK there is one ADC example given "simplelink_cc2640r2_sdk_2_30_00_28/examples/rtos/CC2640R2_LAUNCHXL/drivers/adcsinglechannel" at this location. which I tried. with this example when I call Adc_init() function board reboot.
so can you please tell why this is happening? am i missing any file to link or anything else?
can you suggest any example for battery_monitor?

Best regards,
Mayur Shankariya

  • -Which board are you using?
    - If you are not running the code on the launchpad, have you done any changes to the code? If yes, what are the changes?
    - If a custom board, on which pin have you connected the battery?
  • Thanks for reply TER,

    1) CC2640R2F board
    2) No changes had done.
    3) yes, using custom board. battery is connected to DIO_30 pin(for ADC_input).

    Best regards,
    Mayur Shankariya
  • The example does not use DIO30 by default.

    Did you step into the adc_init() to see if you could pinpoint the exact line of failure?

    Have you tested some of the other examples, it could be a hardware issue.
  • If I remember correctly, ADC example uses DIO23 as ADC 0 and DIO24 is ADC1. You can try to input different voltage to DIO23 and 24 to see if it works first.
  • Thanks for reply YiKai Chen,

    I have changed the mapping as per our custom board design. see below changes in ''simplelink_cc2640r2_sdk_2_30_00_28/source/ti/blestack/boards/CC2640R2_LAUNCHXL/CC2640R2_LAUNCHXL.h".

    #define CC2640R2_LAUNCHXL_DIO30_ANALOG          IOID_30//IOID_23

    ----------------------------------------

    Also, i checked with Multimeter and getting voltage on ADC Pin DIO_30, so maybe there is no HW problem. will explain what m exactly doing by Software side.

    1) put logs before and after during call to ADC_init(). file location:- simple_peripheral_cc2640r2lp_oad_offchip_app/Application/peripheral_bidirectional_audio.c
              function_name: static void PeripheralAudio_init(void){

    Display_printf(dispHandle_p, 0, 0, "Before ADC_init()\r\n\n\r\n");

    ADC_init();

    Display_printf(dispHandle_p, 0, 0, "After ADC_init()\r\n\n\r\n");

    }

    /*
    * ======== ADC_init ========

    File location:- simple_peripheral_cc2640r2lp_oad_offchip_app/Drivers/adc.c
    */
    void ADC_init(void)
    {
    uint_least8_t i;
    uint_fast32_t key;

    key = HwiP_disable();

    if (!isInitialized) {
    isInitialized = (bool) true;

    /* Call each driver's init function */
    for (i = 0; i < ADC_count; i++) {
    ADC_config[i].fxnTablePtr->initFxn((ADC_Handle)&(ADC_config[i]));
    }
    }

    HwiP_restore(key);
    }

    OUTPUT:- Board will not start.

  • I don’t see where your code output “OUTPUT:- Board will not start.“
  • I mean after adding ADC changes, flash hex into cc2640 chip then the board will not start(boot). This is happening because of ADC_init() call.

  • Did you try to step into ADC_init and see if the code crashes at a given line?

    Not sure if you have mapped the correct ADC pin, have you gone through dev.ti.com/.../ti_drivers_config.html ?
  • I have stepped out and found a problem in for loop of  ADC_init() . please find attached customize board.h, CC2640R

    3808.CC2640R2_LAUNCHXL.c
    /*
     * Copyright (c) 2016-2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ====================== CC2640R2_LAUNCHXL.c =================================
     *  This board file is made for the 7x7 mm QFN package, to convert this board
     *  file to use for other smaller device packages please refer to the table
     *  below which lists the max IOID values supported by each package. All other
     *  unused pins should be set to IOID_UNUSED.
     *
     *  Furthermore the board file is also used
     *  to define a symbol that configures the RF front end and bias.
     *  See the comments below for more information.
     *  For an in depth tutorial on how to create a custom board file, please refer
     *  to the section "Running the SDK on Custom Boards" with in the Software
     *  Developer's Guide.
     *
     *  Refer to the datasheet for all the package options and IO descriptions:
     *  http://www.ti.com/lit/ds/symlink/cc2640r2f.pdf
     *
     *  +-----------------------+------------------+-----------------------+
     *  |     Package Option    |  Total GPIO Pins |   MAX IOID            |
     *  +=======================+==================+=======================+
     *  |     7x7 mm QFN        |     31           |   IOID_30             |
     *  +-----------------------+------------------+-----------------------+
     *  |     5x5 mm QFN        |     15           |   IOID_14             |
     *  +-----------------------+------------------+-----------------------+
     *  |     4x4 mm QFN        |     10           |   IOID_9              |
     *  +-----------------------+------------------+-----------------------+
     *  |     2.7 x 2.7 mm WCSP |     14           |   IOID_13             |
     *  +-----------------------+------------------+-----------------------+
     *  ============================================================================
     */
    
    #include <stdbool.h>
    #include <stddef.h>
    #include <stdint.h>
    
    #include <ti/devices/cc26x0r2/driverlib/ioc.h>
    #include <ti/devices/cc26x0r2/driverlib/udma.h>
    #include <ti/devices/cc26x0r2/inc/hw_ints.h>
    #include <ti/devices/cc26x0r2/inc/hw_memmap.h>
    
    #include "CC2640R2_LAUNCHXL.h"
    
    /*
     *  =============================== ADCBuf ===============================
     */
    #include <ti/drivers/ADCBuf.h>
    #include <ti/drivers/adcbuf/ADCBufCC26XX.h>
    
    ADCBufCC26XX_Object adcBufCC26xxObjects[CC2640R2_LAUNCHXL_ADCBUFCOUNT];
    
    /*
     *  This table converts a virtual adc channel into a dio and internal analogue
     *  input signal. This table is necessary for the functioning of the adcBuf
     *  driver. Comment out unused entries to save flash. Dio and internal signal
     *  pairs are hardwired. Do not remap them in the table. You may reorder entire
     *  entries. The mapping of dio and internal signals is package dependent.
     */
    #ifdef FLEU_HANDSET
    const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[CC2640R2_LAUNCHXL_ADCBUF0CHANNELCOUNT] = {
        {CC2640R2_LAUNCHXL_DIO30_ANALOG, ADC_COMPB_IN_AUXIO7},
        {PIN_UNASSIGNED, ADC_COMPB_IN_VDDS},
        {PIN_UNASSIGNED, ADC_COMPB_IN_DCOUPL},
        {PIN_UNASSIGNED, ADC_COMPB_IN_VSS},
    };
    #else
    #ifndef FLEU_BASEBRD
    const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[CC2640R2_LAUNCHXL_ADCBUF0CHANNELCOUNT] = {
        {CC2640R2_LAUNCHXL_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7},
        {CC2640R2_LAUNCHXL_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6},
        {CC2640R2_LAUNCHXL_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5},
        {CC2640R2_LAUNCHXL_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4},
        {CC2640R2_LAUNCHXL_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3},
        {CC2640R2_LAUNCHXL_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2},
        {CC2640R2_LAUNCHXL_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1},
        {CC2640R2_LAUNCHXL_DIO30_ANALOG, ADC_COMPB_IN_AUXIO0},
        {PIN_UNASSIGNED, ADC_COMPB_IN_VDDS},
        {PIN_UNASSIGNED, ADC_COMPB_IN_DCOUPL},
        {PIN_UNASSIGNED, ADC_COMPB_IN_VSS},
    };
    #endif
    #endif
    #ifndef FLEU_BASEBRD
    const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCBUFCOUNT] = {
        {
            .intPriority       = ~0,
            .swiPriority       = 0,
            .adcChannelLut     = ADCBufCC26XX_adcChannelLut,
            .gpTimerUnit       = CC2640R2_LAUNCHXL_GPTIMER0A,
            .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A,
        }
    };
    
    const ADCBuf_Config ADCBuf_config[CC2640R2_LAUNCHXL_ADCBUFCOUNT] = {
        {
            &ADCBufCC26XX_fxnTable,
            &adcBufCC26xxObjects[CC2640R2_LAUNCHXL_ADCBUF0],
            &adcBufCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCBUF0]
        },
    };
    
    const uint_least8_t ADCBuf_count = CC2640R2_LAUNCHXL_ADCBUFCOUNT;
    #endif
    /*
     *  =============================== ADC ===============================
     */
    #include <ti/drivers/ADC.h>
    #include <ti/drivers/adc/ADCCC26XX.h>
    
    ADCCC26XX_Object adcCC26xxObjects[CC2640R2_LAUNCHXL_ADCCOUNT];
    
    #ifdef FLEU_HANDSET
    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCCOUNT] = {
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO30_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO0,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        }
    };
    const ADC_Config ADC_config[CC2640R2_LAUNCHXL_ADCCOUNT] = {
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC0], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC0]}
    };
    
    //const uint_least8_t ADC_count = CC2640R2_LAUNCHXL_ADCCOUNT;
    const uint_least8_t ADC_count = 1;//MAYUR_DEBUG
    #else
    #ifndef FLEU_BASEBRD
    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCCOUNT] = {
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO23_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO7,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO24_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO6,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO25_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO5,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO26_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO4,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO27_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO3,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO28_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO2,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO29_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO1,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = CC2640R2_LAUNCHXL_DIO30_ANALOG,
            .adcCompBInput       = ADC_COMPB_IN_AUXIO0,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_10P9_MS,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = PIN_UNASSIGNED,
            .adcCompBInput       = ADC_COMPB_IN_DCOUPL,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = PIN_UNASSIGNED,
            .adcCompBInput       = ADC_COMPB_IN_VSS,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        },
        {
            .adcDIO              = PIN_UNASSIGNED,
            .adcCompBInput       = ADC_COMPB_IN_VDDS,
            .refSource           = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration    = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource       = ADCCC26XX_TRIGGER_MANUAL,
            .returnAdjustedVal   = false
        }
    };
    
    const ADC_Config ADC_config[CC2640R2_LAUNCHXL_ADCCOUNT] = {
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC0], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC0]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC1], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC1]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC2], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC2]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC3], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC3]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC4], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC4]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC5], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC5]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC6], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC6]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADC7], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADC7]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADCDCOUPL], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCDCOUPL]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADCVSS], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCVSS]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2640R2_LAUNCHXL_ADCVDDS], &adcCC26xxHWAttrs[CC2640R2_LAUNCHXL_ADCVDDS]},
    };
    
    const uint_least8_t ADC_count = CC2640R2_LAUNCHXL_ADCCOUNT;
    #endif
    #endif
    /*
     *  =============================== Crypto ===============================
     */
    #include <ti/drivers/crypto/CryptoCC26XX.h>
    
    CryptoCC26XX_Object cryptoCC26XXObjects[CC2640R2_LAUNCHXL_CRYPTOCOUNT];
    
    const CryptoCC26XX_HWAttrs cryptoCC26XXHWAttrs[CC2640R2_LAUNCHXL_CRYPTOCOUNT] = {
        {
            .baseAddr       = CRYPTO_BASE,
            .powerMngrId    = PowerCC26XX_PERIPH_CRYPTO,
            .intNum         = INT_CRYPTO_RESULT_AVAIL_IRQ,
            .intPriority    = ~0,
        }
    };
    
    const CryptoCC26XX_Config CryptoCC26XX_config[CC2640R2_LAUNCHXL_CRYPTOCOUNT] = {
        {
             .object  = &cryptoCC26XXObjects[CC2640R2_LAUNCHXL_CRYPTO0],
             .hwAttrs = &cryptoCC26XXHWAttrs[CC2640R2_LAUNCHXL_CRYPTO0]
        },
    };
    
    /*
     *  =============================== Display ===============================
     */
    #include <ti/display/Display.h>
    #include <ti/display/DisplayUart.h>
    #include <ti/display/DisplaySharp.h>
    
    #ifndef BOARD_DISPLAY_UART_STRBUF_SIZE
    #define BOARD_DISPLAY_UART_STRBUF_SIZE    128
    #endif
    
    #ifndef BOARD_DISPLAY_SHARP_SIZE
    #define BOARD_DISPLAY_SHARP_SIZE    96
    #endif
    
    DisplayUart_Object     displayUartObject;
    #if !defined(FLEU_HANDSET) && !defined (FLEU_BASEBRD)
    DisplaySharp_Object    displaySharpObject;
    static uint_least8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8];
    #endif
    static char uartStringBuf[BOARD_DISPLAY_UART_STRBUF_SIZE];
    
    const DisplayUart_HWAttrs displayUartHWAttrs = {
        .uartIdx      = CC2640R2_LAUNCHXL_UART0,
        .baudRate     = 115200,
        .mutexTimeout = (unsigned int)(-1),
        .strBuf       = uartStringBuf,
        .strBufLen    = BOARD_DISPLAY_UART_STRBUF_SIZE,
    };
    #if !defined(FLEU_HANDSET) && !defined (FLEU_BASEBRD)
    const DisplaySharp_HWAttrsV1 displaySharpHWattrs = {
        .spiIndex    = CC2640R2_LAUNCHXL_SPI0,
        .csPin       = CC2640R2_LAUNCHXL_GPIO_LCD_CS,
        .powerPin    = CC2640R2_LAUNCHXL_GPIO_LCD_POWER,
        .enablePin   = CC2640R2_LAUNCHXL_GPIO_LCD_ENABLE,
        .pixelWidth  = BOARD_DISPLAY_SHARP_SIZE,
        .pixelHeight = BOARD_DISPLAY_SHARP_SIZE,
        .displayBuf  = sharpDisplayBuf,
    };
    #endif
    #ifndef BOARD_DISPLAY_USE_UART
    #define BOARD_DISPLAY_USE_UART 1
    #endif
    #ifndef BOARD_DISPLAY_USE_UART_ANSI
    #define BOARD_DISPLAY_USE_UART_ANSI 0
    #endif
    #ifndef BOARD_DISPLAY_USE_LCD
    #define BOARD_DISPLAY_USE_LCD 0
    #endif
    
    /*
     * This #if/#else is needed to workaround a problem with the
     * IAR compiler. The IAR compiler doesn't like the empty array
     * initialization. (IAR Error[Pe1345])
     */
    #if (BOARD_DISPLAY_USE_UART || BOARD_DISPLAY_USE_LCD)
    
    const Display_Config Display_config[] = {
    #if (BOARD_DISPLAY_USE_UART)
        {
    #  if (BOARD_DISPLAY_USE_UART_ANSI)
            .fxnTablePtr = &DisplayUartAnsi_fxnTable,
    #  else /* Default to minimal UART with no cursor placement */
            .fxnTablePtr = &DisplayUartMin_fxnTable,
    #  endif
            .object      = &displayUartObject,
            .hwAttrs     = &displayUartHWAttrs,
        },
    #endif
    #if (BOARD_DISPLAY_USE_LCD)
        {
            .fxnTablePtr = &DisplaySharp_fxnTable,
            .object      = &displaySharpObject,
            .hwAttrs     = &displaySharpHWattrs
        },
    #endif
    };
    
    const uint_least8_t Display_count = sizeof(Display_config) / sizeof(Display_Config);
    
    #else
    
    const Display_Config *Display_config = NULL;
    const uint_least8_t Display_count = 0;
    
    #endif /* (BOARD_DISPLAY_USE_UART || BOARD_DISPLAY_USE_LCD) */
    
    #if !defined(FLEU_HANDSET) && !defined (FLEU_BASEBRD)
    /*
     *  =============================== GPIO ===============================
     */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/gpio/GPIOCC26XX.h>
    
    /*
     * Array of Pin configurations
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in CC2640R2_LAUNCHXL.h
     * NOTE: Pins not used for interrupts should be placed at the end of the
     *       array. Callback entries can be omitted from callbacks array to
     *       reduce memory usage.
     */
    GPIO_PinConfig gpioPinConfigs[] = {
        /* Input pins */
        GPIOCC26XX_DIO_13 | GPIO_DO_NOT_CONFIG,  /* Button 0 */
        GPIOCC26XX_DIO_14 | GPIO_DO_NOT_CONFIG,  /* Button 1 */
    
        GPIOCC26XX_DIO_15 | GPIO_DO_NOT_CONFIG,  /* CC2640R2_LAUNCHXL_SPI_MASTER_READY */
        GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,  /* CC2640R2_LAUNCHXL_SPI_SLAVE_READY */
        /* Output pins */
        GPIOCC26XX_DIO_07 | GPIO_DO_NOT_CONFIG,  /* Green LED */
        GPIOCC26XX_DIO_06 | GPIO_DO_NOT_CONFIG,  /* Red LED */
    
        /* SPI Flash CSN */
        GPIOCC26XX_DIO_20 | GPIO_DO_NOT_CONFIG,
    
        /* SD CS */
        GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,
    
        /* Sharp Display - GPIO configurations will be done in the Display files */
        GPIOCC26XX_DIO_24 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
        GPIOCC26XX_DIO_22 | GPIO_DO_NOT_CONFIG, /* LCD power control */
        GPIOCC26XX_DIO_23 | GPIO_DO_NOT_CONFIG, /*LCD enable */
    };
    
    /*
     * Array of callback function pointers
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in CC2640R2_LAUNCH.h
     * NOTE: Pins not used for interrupts can be omitted from callbacks array to
     *       reduce memory usage (if placed at end of gpioPinConfigs array).
     */
    GPIO_CallbackFxn gpioCallbackFunctions[] = {
        NULL,  /* Button 0 */
        NULL,  /* Button 1 */
        NULL,  /* CC2640R2_LAUNCHXL_SPI_MASTER_READY */
        NULL,  /* CC2640R2_LAUNCHXL_SPI_SLAVE_READY */
    };
    
    const GPIOCC26XX_Config GPIOCC26XX_config = {
        .pinConfigs         = (GPIO_PinConfig *)gpioPinConfigs,
        .callbacks          = (GPIO_CallbackFxn *)gpioCallbackFunctions,
        .numberOfPinConfigs = CC2640R2_LAUNCHXL_GPIOCOUNT,
        .numberOfCallbacks  = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
        .intPriority        = (~0)
    };
    
    /*
     *  =============================== GPTimer ===============================
     *  Remove unused entries to reduce flash usage both in Board.c and Board.h
     */
    #include <ti/drivers/timer/GPTimerCC26XX.h>
    
    GPTimerCC26XX_Object gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMERCOUNT];
    
    const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMERPARTSCOUNT] = {
        { .baseAddr = GPT0_BASE, .intNum = INT_GPT0A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0A, },
        { .baseAddr = GPT0_BASE, .intNum = INT_GPT0B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0B, },
        { .baseAddr = GPT1_BASE, .intNum = INT_GPT1A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1A, },
        { .baseAddr = GPT1_BASE, .intNum = INT_GPT1B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1B, },
        { .baseAddr = GPT2_BASE, .intNum = INT_GPT2A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2A, },
        { .baseAddr = GPT2_BASE, .intNum = INT_GPT2B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2B, },
        { .baseAddr = GPT3_BASE, .intNum = INT_GPT3A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3A, },
        { .baseAddr = GPT3_BASE, .intNum = INT_GPT3B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3B, },
    };
    
    const GPTimerCC26XX_Config GPTimerCC26XX_config[CC2640R2_LAUNCHXL_GPTIMERPARTSCOUNT] = {
        { &gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMER0A], GPT_A },
        { &gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMER0B], GPT_B },
        { &gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMER1A], GPT_A },
        { &gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMER1B], GPT_B },
        { &gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMER2A], GPT_A },
        { &gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMER2B], GPT_B },
        { &gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMER3A], GPT_A },
        { &gptimerCC26XXObjects[CC2640R2_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_GPTIMER3B], GPT_B },
    };
    #endif
    #ifndef FLEU_BASEBRD
    /*
     *  =============================== I2C ===============================
    */
    #include <ti/drivers/I2C.h>
    #include <ti/drivers/i2c/I2CCC26XX.h>
    
    I2CCC26XX_Object i2cCC26xxObjects[CC2640R2_LAUNCHXL_I2CCOUNT];
    
    const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC2640R2_LAUNCHXL_I2CCOUNT] = {
        {
            .baseAddr    = I2C0_BASE,
            .powerMngrId = PowerCC26XX_PERIPH_I2C0,
            .intNum      = INT_I2C_IRQ,
            .intPriority = ~0,
            .swiPriority = 0,
            .sdaPin      = CC2640R2_LAUNCHXL_I2C0_SDA0,
            .sclPin      = CC2640R2_LAUNCHXL_I2C0_SCL0,
        }
    };
    
    const I2C_Config I2C_config[CC2640R2_LAUNCHXL_I2CCOUNT] = {
        {
            .fxnTablePtr = &I2CCC26XX_fxnTable,
            .object      = &i2cCC26xxObjects[CC2640R2_LAUNCHXL_I2C0],
            .hwAttrs     = &i2cCC26xxHWAttrs[CC2640R2_LAUNCHXL_I2C0]
        },
    };
    
    const uint_least8_t I2C_count = CC2640R2_LAUNCHXL_I2CCOUNT;
    #endif
    /*
     *  =============================== NVS ===============================
     */
    #include <ti/drivers/NVS.h>
    #include <ti/drivers/nvs/NVSSPI25X.h>
    #include <ti/drivers/nvs/NVSCC26XX.h>
    
    #define NVS_REGIONS_BASE 0x1A000
    #define SECTORSIZE       0x1000
    #define REGIONSIZE       (SECTORSIZE * 4)
    
    #ifndef Board_EXCLUDE_NVS_INTERNAL_FLASH
    
    /*
     * Reserve flash sectors for NVS driver use by placing an uninitialized byte
     * array at the desired flash address.
     */
    #if defined(__TI_COMPILER_VERSION__)
    
    /*
     * Place uninitialized array at NVS_REGIONS_BASE
     */
    #pragma LOCATION(flashBuf, NVS_REGIONS_BASE);
    #pragma NOINIT(flashBuf);
    static char flashBuf[REGIONSIZE];
    
    #elif defined(__IAR_SYSTEMS_ICC__)
    
    /*
     * Place uninitialized array at NVS_REGIONS_BASE
     */
    static __no_init char flashBuf[REGIONSIZE] @ NVS_REGIONS_BASE;
    
    #elif defined(__GNUC__)
    
    /*
     * Place the flash buffers in the .nvs section created in the gcc linker file.
     * The .nvs section enforces alignment on a sector boundary but may
     * be placed anywhere in flash memory.  If desired the .nvs section can be set
     * to a fixed address by changing the following in the gcc linker file:
     *
     * .nvs (FIXED_FLASH_ADDR) (NOLOAD) : AT (FIXED_FLASH_ADDR) {
     *      *(.nvs)
     * } > REGION_TEXT
     */
    __attribute__ ((section (".nvs")))
    static char flashBuf[REGIONSIZE];
    
    #endif
    
    /* Allocate objects for NVS Internal Regions */
    NVSCC26XX_Object nvsCC26xxObjects[1];
    
    /* Hardware attributes for NVS Internal Regions */
    const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = {
        {
            .regionBase = (void *)flashBuf,
            .regionSize = REGIONSIZE,
        },
    };
    
    #endif /* Board_EXCLUDE_NVS_INTERNAL_FLASH */
    
    #ifndef Board_EXCLUDE_NVS_EXTERNAL_FLASH
    
    #define SPISECTORSIZE    0x1000
    #define SPIREGIONSIZE    (SPISECTORSIZE * 32)
    #define VERIFYBUFSIZE    64
    
    static uint8_t verifyBuf[VERIFYBUFSIZE];
    
    /* Allocate objects for NVS External Regions */
    NVSSPI25X_Object nvsSPI25XObjects[1];
    
    /* Hardware attributes for NVS External Regions */
    const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = {
        {
            .regionBaseOffset = 0,
            .regionSize = SPIREGIONSIZE,
            .sectorSize = SPISECTORSIZE,
            .verifyBuf = verifyBuf,
            .verifyBufSize = VERIFYBUFSIZE,
            .spiHandle = NULL,
            .spiIndex = 0,
            .spiBitRate = 4000000,
            .spiCsnGpioIndex = CC2640R2_LAUNCHXL_GPIO_SPI_FLASH_CS,
        },
    };
    
    #endif /* Board_EXCLUDE_NVS_EXTERNAL_FLASH */
    
    /* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */
    const NVS_Config NVS_config[CC2640R2_LAUNCHXL_NVSCOUNT] = {
    #ifndef Board_EXCLUDE_NVS_INTERNAL_FLASH
        {
            .fxnTablePtr = &NVSCC26XX_fxnTable,
            .object = &nvsCC26xxObjects[0],
            .hwAttrs = &nvsCC26xxHWAttrs[0],
        },
    #endif
    #ifndef Board_EXCLUDE_NVS_EXTERNAL_FLASH
        {
            .fxnTablePtr = &NVSSPI25X_fxnTable,
            .object = &nvsSPI25XObjects[0],
            .hwAttrs = &nvsSPI25XHWAttrs[0],
        },
    #endif
    };
    
    const uint_least8_t NVS_count = CC2640R2_LAUNCHXL_NVSCOUNT;
    
    /*
     *  =============================== PIN ===============================
     */
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    
    const PIN_Config BoardGpioInitTable[] = {
    #ifdef FLEU_HANDSET
         CC2640R2_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off */
         CC2640R2_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off */
         CC2640R2_LAUNCHXL_PIN_BTN0 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN3 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN4 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN5 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN6 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN7 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN8 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN9 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN_CALL | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN_STAR | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_PIN_BTN_HASH | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,  /* External flash chip select */
         CC2640R2_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
         CC2640R2_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,                        /* UART TX via debugger back channel */
         CC2640R2_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master out - slave in */
         CC2640R2_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master in - slave out */
         CC2640R2_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,                                             /* SPI clock */
    #else
    #ifdef FLEU_BASEBRD
         CC2640R2_LAUNCHXL_PIN_BTN0 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
         CC2640R2_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,  /* External flash chip select */
         CC2640R2_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
         CC2640R2_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,                        /* UART TX via debugger back channel */
         CC2640R2_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master out - slave in */
         CC2640R2_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master in - slave out */
         CC2640R2_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,                                             /* SPI clock */
    #else
        CC2640R2_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off */
        CC2640R2_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off */
        CC2640R2_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
        CC2640R2_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low */
        CC2640R2_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,  /* External flash chip select */
        CC2640R2_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
        CC2640R2_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,                        /* UART TX via debugger back channel */
        CC2640R2_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master out - slave in */
        CC2640R2_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master in - slave out */
        CC2640R2_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,                                             /* SPI clock */
    #endif
    #endif
        PIN_TERMINATE
    };
    
    const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
        .intPriority = ~0,
        .swiPriority = 0
    };
    
    /*
     *  =============================== Power ===============================
     */
    #include <ti/drivers/Power.h>
    #include <ti/drivers/power/PowerCC26XX.h>
    
    const PowerCC26XX_Config PowerCC26XX_config = {
        .policyInitFxn      = NULL,
        .policyFxn          = &PowerCC26XX_standbyPolicy,
        .calibrateFxn       = &PowerCC26XX_calibrate,
        .enablePolicy       = true,
    #ifdef USE_RCOSC
        .calibrateRCOSC_LF  = true,
    #else
        .calibrateRCOSC_LF  = false,
    #endif
        .calibrateRCOSC_HF  = true,
    };
    
    #ifndef FLEU_HANDSET
    #ifndef FLEU_BASEBRD
    
    /*
     *  =============================== PWM ===============================
     *  Remove unused entries to reduce flash usage both in Board.c and Board.h
     */
    #include <ti/drivers/PWM.h>
    #include <ti/drivers/pwm/PWMTimerCC26XX.h>
    
    PWMTimerCC26XX_Object pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWMCOUNT];
    
    const PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWMCOUNT] = {
        { .pwmPin = CC2640R2_LAUNCHXL_PWMPIN0, .gpTimerUnit = CC2640R2_LAUNCHXL_GPTIMER0A },
        { .pwmPin = CC2640R2_LAUNCHXL_PWMPIN1, .gpTimerUnit = CC2640R2_LAUNCHXL_GPTIMER0B },
        { .pwmPin = CC2640R2_LAUNCHXL_PWMPIN2, .gpTimerUnit = CC2640R2_LAUNCHXL_GPTIMER1A },
        { .pwmPin = CC2640R2_LAUNCHXL_PWMPIN3, .gpTimerUnit = CC2640R2_LAUNCHXL_GPTIMER1B },
        { .pwmPin = CC2640R2_LAUNCHXL_PWMPIN4, .gpTimerUnit = CC2640R2_LAUNCHXL_GPTIMER2A },
        { .pwmPin = CC2640R2_LAUNCHXL_PWMPIN5, .gpTimerUnit = CC2640R2_LAUNCHXL_GPTIMER2B },
        { .pwmPin = CC2640R2_LAUNCHXL_PWMPIN6, .gpTimerUnit = CC2640R2_LAUNCHXL_GPTIMER3A },
        { .pwmPin = CC2640R2_LAUNCHXL_PWMPIN7, .gpTimerUnit = CC2640R2_LAUNCHXL_GPTIMER3B },
    };
    
    const PWM_Config PWM_config[CC2640R2_LAUNCHXL_PWMCOUNT] = {
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWM0], &pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWM0] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWM1], &pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWM1] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWM2], &pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWM2] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWM3], &pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWM3] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWM4], &pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWM4] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWM5], &pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWM5] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWM6], &pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWM6] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2640R2_LAUNCHXL_PWM7], &pwmtimerCC26xxHWAttrs[CC2640R2_LAUNCHXL_PWM7] },
    };
    
    const uint_least8_t PWM_count = CC2640R2_LAUNCHXL_PWMCOUNT;
    #endif
    #endif
    /*
     *  =============================== RF Driver ===============================
     */
    #include <ti/drivers/rf/RF.h>
    
    const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
        .hwiPriority        = ~0,       /* Lowest HWI priority */
        .swiPriority        = 0,        /* Lowest SWI priority */
        .xoscHfAlwaysNeeded = true,     /* Keep XOSC dependency while in stanby */
        .globalCallback     = NULL,     /* No board specific callback */
        .globalEventMask    = 0         /* No events subscribed to */
    };
    
    #if !defined(FLEU_HANDSET) && !defined (FLEU_BASEBRD)
    /*
     *  =============================== SD ===============================
     */
    #include <ti/drivers/SD.h>
    #include <ti/drivers/sd/SDSPI.h>
    
    SDSPI_Object sdspiObjects[CC2640R2_LAUNCHXL_SDCOUNT];
    
    const SDSPI_HWAttrs sdspiHWAttrs[CC2640R2_LAUNCHXL_SDCOUNT] = {
        {
            .spiIndex = CC2640R2_LAUNCHXL_SPI0,
            .spiCsGpioIndex = CC2640R2_LAUNCHXL_SDSPI_CS
        }
    };
    
    const SD_Config SD_config[CC2640R2_LAUNCHXL_SDCOUNT] = {
        {
            .fxnTablePtr = &SDSPI_fxnTable,
            .object = &sdspiObjects[CC2640R2_LAUNCHXL_SDSPI0],
            .hwAttrs = &sdspiHWAttrs[CC2640R2_LAUNCHXL_SDSPI0]
        },
    };
    
    const uint_least8_t SD_count = CC2640R2_LAUNCHXL_SDCOUNT;
    #endif
    /*
     *  =============================== SPI DMA ===============================
     */
    #include <ti/drivers/SPI.h>
    #include <ti/drivers/spi/SPICC26XXDMA.h>
    
    SPICC26XXDMA_Object spiCC26XXDMAObjects[CC2640R2_LAUNCHXL_SPICOUNT];
    
    /*
     * NOTE: The SPI instances below can be used by the SD driver to communicate
     * with a SD card via SPI.  The 'defaultTxBufValue' fields below are set to 0xFF
     * to satisfy the SDSPI driver requirement.
     */
    const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC2640R2_LAUNCHXL_SPICOUNT] = {
        {
            .baseAddr           = SSI0_BASE,
            .intNum             = INT_SSI0_COMB,
            .intPriority        = ~0,
            .swiPriority        = 0,
            .powerMngrId        = PowerCC26XX_PERIPH_SSI0,
            .defaultTxBufValue  = 0xFF,
            .rxChannelBitMask   = 1<<UDMA_CHAN_SSI0_RX,
            .txChannelBitMask   = 1<<UDMA_CHAN_SSI0_TX,
            .mosiPin            = CC2640R2_LAUNCHXL_SPI0_MOSI,
            .misoPin            = CC2640R2_LAUNCHXL_SPI0_MISO,
            .clkPin             = CC2640R2_LAUNCHXL_SPI0_CLK,
            .csnPin             = CC2640R2_LAUNCHXL_SPI0_CSN,
            .minDmaTransferSize = 10
        }
    #if !defined(FLEU_HANDSET) && !defined (FLEU_BASEBRD)
        ,
        {
            .baseAddr           = SSI1_BASE,
            .intNum             = INT_SSI1_COMB,
            .intPriority        = ~0,
            .swiPriority        = 0,
            .powerMngrId        = PowerCC26XX_PERIPH_SSI1,
            .defaultTxBufValue  = 0xFF,
            .rxChannelBitMask   = 1<<UDMA_CHAN_SSI1_RX,
            .txChannelBitMask   = 1<<UDMA_CHAN_SSI1_TX,
            .mosiPin            = CC2640R2_LAUNCHXL_SPI1_MOSI,
            .misoPin            = CC2640R2_LAUNCHXL_SPI1_MISO,
            .clkPin             = CC2640R2_LAUNCHXL_SPI1_CLK,
            .csnPin             = CC2640R2_LAUNCHXL_SPI1_CSN,
            .minDmaTransferSize = 10
        }
    #endif
    };
    
    const SPI_Config SPI_config[CC2640R2_LAUNCHXL_SPICOUNT] = {
        {
             .fxnTablePtr = &SPICC26XXDMA_fxnTable,
             .object      = &spiCC26XXDMAObjects[CC2640R2_LAUNCHXL_SPI0],
             .hwAttrs     = &spiCC26XXDMAHWAttrs[CC2640R2_LAUNCHXL_SPI0]
        }
    #if !defined(FLEU_HANDSET) && !defined (FLEU_BASEBRD)
        ,
        {
             .fxnTablePtr = &SPICC26XXDMA_fxnTable,
             .object      = &spiCC26XXDMAObjects[CC2640R2_LAUNCHXL_SPI1],
             .hwAttrs     = &spiCC26XXDMAHWAttrs[CC2640R2_LAUNCHXL_SPI1]
        }
    #endif
    };
    
    const uint_least8_t SPI_count = CC2640R2_LAUNCHXL_SPICOUNT;
    
    /*
     *  =============================== UART ===============================
     */
    #include <ti/drivers/UART.h>
    #include <ti/drivers/uart/UARTCC26XX.h>
    
    UARTCC26XX_Object uartCC26XXObjects[CC2640R2_LAUNCHXL_UARTCOUNT];
    
    uint8_t uartCC26XXRingBuffer[CC2640R2_LAUNCHXL_UARTCOUNT][32];
    
    const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC2640R2_LAUNCHXL_UARTCOUNT] = {
        {
            .baseAddr       = UART0_BASE,
            .powerMngrId    = PowerCC26XX_PERIPH_UART0,
            .intNum         = INT_UART0_COMB,
            .intPriority    = ~0,
            .swiPriority    = 0,
            .txPin          = CC2640R2_LAUNCHXL_UART_TX,
            .rxPin          = CC2640R2_LAUNCHXL_UART_RX,
            .ctsPin         = PIN_UNASSIGNED,
            .rtsPin         = PIN_UNASSIGNED,
            .ringBufPtr     = uartCC26XXRingBuffer[CC2640R2_LAUNCHXL_UART0],
            .ringBufSize    = sizeof(uartCC26XXRingBuffer[CC2640R2_LAUNCHXL_UART0]),
            .txIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_1_8,
            .rxIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_4_8,
            .errorFxn       = NULL
        }
    };
    
    const UART_Config UART_config[CC2640R2_LAUNCHXL_UARTCOUNT] = {
        {
            .fxnTablePtr = &UARTCC26XX_fxnTable,
            .object      = &uartCC26XXObjects[CC2640R2_LAUNCHXL_UART0],
            .hwAttrs     = &uartCC26XXHWAttrs[CC2640R2_LAUNCHXL_UART0]
        },
    };
    
    const uint_least8_t UART_count = CC2640R2_LAUNCHXL_UARTCOUNT;
    
    /*
     *  =============================== UDMA ===============================
     */
    #include <ti/drivers/dma/UDMACC26XX.h>
    
    UDMACC26XX_Object udmaObjects[CC2640R2_LAUNCHXL_UDMACOUNT];
    
    const UDMACC26XX_HWAttrs udmaHWAttrs[CC2640R2_LAUNCHXL_UDMACOUNT] = {
        {
            .baseAddr    = UDMA0_BASE,
            .powerMngrId = PowerCC26XX_PERIPH_UDMA,
            .intNum      = INT_DMA_ERR,
            .intPriority = ~0
        }
    };
    
    const UDMACC26XX_Config UDMACC26XX_config[CC2640R2_LAUNCHXL_UDMACOUNT] = {
        {
             .object  = &udmaObjects[CC2640R2_LAUNCHXL_UDMA0],
             .hwAttrs = &udmaHWAttrs[CC2640R2_LAUNCHXL_UDMA0]
        },
    };
    
    
    
    /*
     *  =============================== Watchdog ===============================
     */
    #include <ti/drivers/Watchdog.h>
    #include <ti/drivers/watchdog/WatchdogCC26XX.h>
    
    WatchdogCC26XX_Object watchdogCC26XXObjects[CC2640R2_LAUNCHXL_WATCHDOGCOUNT];
    
    const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC2640R2_LAUNCHXL_WATCHDOGCOUNT] = {
        {
            .baseAddr    = WDT_BASE,
            .reloadValue = 6000 /* Reload value in milliseconds */
        },
    };
    
    const Watchdog_Config Watchdog_config[CC2640R2_LAUNCHXL_WATCHDOGCOUNT] = {
        {
            .fxnTablePtr = &WatchdogCC26XX_fxnTable,
            .object      = &watchdogCC26XXObjects[CC2640R2_LAUNCHXL_WATCHDOG0],
            .hwAttrs     = &watchdogCC26XXHWAttrs[CC2640R2_LAUNCHXL_WATCHDOG0]
        },
    };
    
    const uint_least8_t Watchdog_count = CC2640R2_LAUNCHXL_WATCHDOGCOUNT;
    
    /*
     *  ========================= TRNG begin ====================================
     */
    #include <TRNGCC26XX.h>
    
    /* TRNG objects */
    TRNGCC26XX_Object trngCC26XXObjects[CC2640R2_LAUNCHXL_TRNGCOUNT];
    
    /* TRNG configuration structure, describing which pins are to be used */
    const TRNGCC26XX_HWAttrs TRNGCC26XXHWAttrs[CC2640R2_LAUNCHXL_TRNGCOUNT] = {
        {
            .powerMngrId    = PowerCC26XX_PERIPH_TRNG,
        }
    };
    
    /* TRNG configuration structure */
    const TRNGCC26XX_Config TRNGCC26XX_config[] = {
        {
             .object  = &trngCC26XXObjects[0],
             .hwAttrs = &TRNGCC26XXHWAttrs[0]
        },
        {NULL, NULL}
    };
    
    /*
     *  ========================= TRNG end ====================================
     */
    extern void Board_initHook(void);
    
    /*
     *  ======== CC2640R2_LAUNCHXL_initGeneral ========
     */
    void CC2640R2_LAUNCHXL_initGeneral(void)
    {
        Power_init();
    
        if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
            /* Error with PIN_init */
            while (1);
        }
    
        /* Perform board-specific initialization */
        Board_initHook();
    }
    
    8688.CC2640R2_LAUNCHXL.h2_LAUNCHXL.c and CC2640R2_LAUNCHXL.h file6131.Board.h

    /*
    * ======== ADC_init ========
    */
    void ADC_init(void)
    {
    uint_least8_t i;
    uint_fast32_t key;

    key = HwiP_disable();

    if (!isInitialized) {
    isInitialized = (bool) true;

    /* Call each driver's init function */
    for (i = 0; i < ADC_count; i++) {
          ADC_config[i].fxnTablePtr->initFxn((ADC_Handle)&(ADC_config[i]));      //Getting problem with this line number.
    }

    }

    HwiP_restore(key);
    }

    -----------------------This function is used for reading battery status  (made by using adcsinglechannel example)----------------------

    static ADC_Handle adc;

    void PeripheralAudio_sendBattEvent(void)

    {

    int_fast16_t res;
    uint32_t adcMicroVolt;
    uint16_t adcValue;
    ADC_Params params;
    uint8_t BattPercnt;
    uint16_t connectionHandle = AudioDuplex_getConnectionHandle();

    if(adc == NULL)
    {
        ADC_Params_init(&params);
        adc = ADC_open(Board_ADC0, &params);
       if(adc == NULL)
       {
            Display_printf(dispHandle_p, 0, 0, "adc failed \n");
       }else
       {
             Display_printf(dispHandle_p, 0, 0, "adc success \n");
        }
    }
    else
    {
        res = ADC_convert(adc, &adcValue);
        if (res == ADC_STATUS_SUCCESS)
        {
             adcMicroVolt = ADC_convertRawToMicroVolts(adc, adcValue);
             BattPercnt = (uint8_t)( (uint32_t)(adcMicroVolt * 100) / (uint32_t) 3399999 );

             Display_printf(dispHandle_p, 0, 0, "batt per : %d \n",BattPercnt);
             if(connectionHandle != INVALID_CONNHANDLE && linkDB_Up(connectionHandle))
             {
                   Audio_SetParameter(AUDIOPROFILE_AUDIO_BATTEVT,AUDIOPROFILE_CMD_LEN,&BattPercnt);
                   Display_printf(dispHandle_p, 2, 0, "batt Evt Send : %d \n",BattPercnt);
              }
        }
    }

    }

  • For which value of i? Did you step into the functions called in the for loop?

    Is DIO30 defined twice, the last #else is used if #ifdef FLEU_BASEBRD is false?
  • Just ignore #ifdef FLEU_BASEBRD.
    consider only #ifdef FLEU_HANDSET.

    in for loop const uint_least8_t ADC_count = CC2640R2_LAUNCHXL_ADCCOUNT;
    i changed CC2640R2_LAUNCHXL_ADCCOUNT=1(because i want to use BOARD_ADC0 only);

    ADC_init() {
    ADC_config[i].fxnTablePtr->initFxn((ADC_Handle)&(ADC_config[i])); //This line changes is also Okay you can check in CC2640R2_LAUNCHXL.c.
    }
    can you please give any other suggestion?
  • It should not be possible to get the program to crash in ADC_init...

    Would you be able to make an example running on the CC2640R2 LP that does the same?
  • Any progress?
  • I try only ADC example, getting endian errors.
    So now I will Run only ADC example on cc2640r2f LAUNCHPAD. Then Let you know!