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.

RTOS/CC1312R: Tasks are getting blocked after first execution and gpio interrupt is not detecting

Part Number: CC1312R

Tool/software: TI-RTOS

Hello,

           I am using LAUNCHXL-CC1312R1 for my project. I have three tasks - one init task which initializes UART,SPI ,I2C and RTC . Other two tasks are RF RX and RF TX which share one semaphore in between them.

I am also using multiple GPIO interrupt callbacks to detect any state changes. My working should be that CC1312R will always stay in RF Rx task and it will TX only if it receives some data and get back to RX task.

However I am noticing that after initial executions of all tasks , all tasks are getting blocked and debugger stops at Task_allBlockedFunction(). Maybe beacuse of this my gpio interrupts are not getting detected as this function is disabling all hwi interrupts.

Kindly suggest the way and let me know if more information is required.

Regards,

Omkar

  • Hi Omkar,

    Could you elaborate on what you mean by:

    "Maybe beacuse of this my gpio interrupts are not getting detected as this function is disabling all hwi interrupts."?

    How do you setup the GPIO in your code and have you verified that your GPIO interrupts work if you only run this task?

    Also, could you tell me how you initialize the RTC in your first task? The RTC module is used and configured by TI-RTOS at boot and should not be re-configured by user later in the application as this can have severe effects on the whole RTOS environment.
  • Hi M-W,

     "Maybe beacuse of this my gpio interrupts are not getting detected as this function is disabling all hwi interrupts."?

    Here, whenever I pause the debugging , my projects stops at  Task_allBlockedFunction() , where it disables the hwi in the function . Please correct me if I have misunderstood it.

    How do you setup the GPIO in your code and have you verified that your GPIO interrupts work if you only run this task?

    1. I have used  GPIO driver for setting up GPIOs with the reference from gpiointerrupt example. 

    2. GPIO interrupts callbacks work only initially at reset as I have put breakpoint in them.

     Also, could you tell me how you initialize the RTC in your first task? 

    To initialize RTC, I meant to say that I use following code to set the seconds -

    
    
     t = mktime(&ltm);                          // conert time structure into number of seconds
    
        Seconds_set(t);                         //    set RTC seconds
    

    Regards,

    Omkar

  • Hi Omkar,

    Thanks for the clarification on RTC. Regarding the Hwi disabled, this function does not disable interrupts indefinitely and will still allow interrupts to invoke ISRs in the system.

    I would suggest you try out the GPIO code in a separate project to verify it works as you intend. If you are depending on GPIO interrupts to ready task, if this does not work then they will of course remain blocked.

    If they work during reset, the question is why they do not work after that. If you could share code on how you setup and use the GPIOs I could have a look on it and see if I can spot something.

  • Hello M-W,

                   I will try gpiointerrupt in separate project and let you know.

    My intention is to keep the CC1312R in RF Rx task always and only when it receives data , it switches to RF TX task.

    My intention to use GPIO interrupt is to update the flag status when some switch is pressed/ released and send the status over UART to cellular module.

    Please let me know if more information is required.

    Thanks ,

    Omkar

    /*
     * gpio.c
     *
     *  Created on: Apr 23, 2018
     *      Author: Omkar
     */
    
    #include "gpio.h"
    #include "Board.h"
    #include "RF_application.h"
    #include <ti/drivers/Power.h>
    
    /* Pin driver handles */
    //static PIN_Handle buttonPinHandle;
    
    
    /* Global memory storage for a PIN_Config table */
    //static PIN_State buttonPinState;
    static PIN_State PinState;
    uint8_t delete_sensors_start = 0;
    uint8_t delete_counter = 0;
    uint8_t delete_flash_flag = 0;
    uint8_t delete_measurement_flag = 0;
    uint8_t disable_filter_flag  = 0;
    
    uint8_t tamp_flag = 0;
    uint8_t pair_flag = 0;
    uint8_t FLT_OUT_flag = 0;
    uint8_t pairing_ok_flag = 0;
    
    uint8_t reset_module_flag = 0;
    
    uint8_t falling = FALSE;
    uint8_t falling_tamp = FALSE;
    uint8_t buzzer_flag = 0;
    uint8_t buzzer_counter = 0;
    
    PWM_Handle pwm1 = NULL;
    /*
     * Initial LED pin configuration table
     *   - LEDs Board_PIN_LED0 is on.
     *   - LEDs Board_PIN_LED1 is off.
     */
    PIN_Config gpiotable[] = {
        //Board_PIN_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        //Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PGOOD          | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_NEGEDGE,
        CHG            | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_NEGEDGE,
        CC1312R1_LAUNCHXL_GPIO_LCD_POWER    | PIN_INPUT_EN  | PIN_PULLUP    | PIN_IRQ_BOTHEDGES,
        RI             | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_NEGEDGE,
        ALERT          | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_NEGEDGE,
        SLP_STAT       | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_NEGEDGE,
        PAIR           | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_BOTHEDGES,
        TAMP           | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_BOTHEDGES ,
        STATUS         | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_BOTHEDGES,
        //CC1312R1_LAUNCHXL_GPIO_S1 | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_BOTHEDGES,
        SYSOFF         | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        DTR            | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        WAKE_LTE       | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        ON_OFF_LTE     | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL| PIN_DRVSTR_MAX,
        CODEC_EN       | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        LED1           | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        BUZZER         | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        RELAY          | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        ISD_CS         | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_INPUT_DIS | PIN_DRVSTR_MED,
     //   CC1312R1_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
      //  CC1312R1_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
     //   CC1312R1_LAUNCHXL_UART1_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
     //   CC1312R1_LAUNCHXL_UART1_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
        MOSI | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL |PIN_INPUT_DIS | PIN_DRVSTR_MED,
        MISO | PIN_INPUT_EN | PIN_PULLDOWN,
        SCLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL |PIN_INPUT_DIS | PIN_DRVSTR_MED,
        PIN_TERMINATE
    };
    
    /*
     * Application button pin configuration table:
     *   - Buttons interrupts are configured to trigger on falling edge.
     */
    PIN_Config buttonPinTable[] = {
        Board_PIN_BUTTON0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
        Board_PIN_BUTTON1  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
        PIN_TERMINATE
    };
    
    
    /*void gpio_callback(uint_least8_t index)
    {
        switch (index) {
            /*case Board_PIN_BUTTON0:
                currVal =  PIN_getOutputValue(Board_PIN_LED0);
                PIN_setOutputValue(gpioHandle, Board_PIN_LED0, !currVal);
                break;
    
           /* case Board_PIN_BUTTON1:
                /*currVal =  PIN_getOutputValue(Board_PIN_LED1);
                PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !currVal);
                break;*/
    
     /*       case PAIR:
                if((PIN_getInputValue(PAIR) == GPIO_PIN_RESET) && (falling == FALSE))
                {
                    falling = TRUE;
    
                    set_pair_flag(1);
                    set_pairing_done_flag(0);                                          // set panel in pairing mode as pair button pressed is detected
                    delete_sensors_start = 1;
                    delete_counter = 0;
                    delete_measurement_flag = 1;
                }
                else if((falling == TRUE) && (get_del_flash_flag() == 0))            // if pair button is released within 10 seconds clear delete flash flag
                {
                    delete_counter = 0;
                    delete_sensors_start = 0;
                    delete_measurement_flag = 0;
                    falling = FALSE;
                }
                break;
    
            case PGOOD:
                break;
    
            case CHG:
                break;
    
            case RDY:
                break;
    
           // case RI:
           //     break;
    
            case ALERT:
                break;
    
            case SLP_STAT:
                 break;
    
            case TAMP:
               /* if( (PIN_getInputValue(TAMP) == GPIO_PIN_RESET) && (falling_tamp == FALSE))
                {
                    if(sensor_tamper_flag == 0)                                             // if only no sensor is tampered then relay off
                    {
                        //relay_off(TAMP_OUT);
                    }
    
                    set_tamp_flag(0);
                    falling_tamp = TRUE;
                }
                else
                {
                    //relay_on(TAMP_OUT);                                       // tamper relay ON as tamper switch is released
                    set_tamp_flag(1);
                    falling_tamp = FALSE;
                }*/
    
    /*             break;
    
            case STATUS:
                 break;
    
            default:
                /* Do nothing */
    /*            break;
        }
    }*/
    
    void chg_status_callback(uint_least8_t index)
    {
    
    }
    
    void lte_ready_status_callback(uint_least8_t index)
    {
    
    }
    
    void batt_alert_callback(uint_least8_t index)
    {
    
    }
    
    void sleep_stat_callback(uint_least8_t index)
    {
    
    }
    
    void pair_callback(uint_least8_t index)
    {
    
    }
    
    void tamp_callback(uint_least8_t index)
    {
        //
        if( (GPIO_read(TAMP) == GPIO_PIN_RESET) && (falling_tamp == FALSE))
        {
            if(sensor_tamper_flag == 0)                                             // if only no sensor is tampered then relay off
            {
                //relay_off(TAMP_OUT);
            }
    
            set_tamp_flag(0);
            falling_tamp = TRUE;
        }
        else
        {
            //relay_on(TAMP_OUT);                                       // tamper relay ON as tamper switch is released
            set_tamp_flag(1);
            falling_tamp = FALSE;
        }
       // GPIO_clearInt(index);
       // GPIO_enableInt(TAMP);
    }
    
    void status_callback(uint_least8_t index)
    {
        falling_tamp = FALSE;
    }
    
    void power_stat_callback(uint_least8_t index)
    {
    
    }
    
    void ri_callback(uint_least8_t index)
    {
    
    }
    
    void button_callback(uint_least8_t index)
    {
        falling_tamp = FALSE;
    }
    /*
     *  ======== buttonCallbackFxn ========
     *  Pin interrupt Callback function board buttons configured in the pinTable.
     *  If Board_PIN_LED3 and Board_PIN_LED4 are defined, then we'll add them to the PIN
     *  callback function.
     */
    void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
        uint32_t currVal = 0;
    
        /* Debounce logic, only toggle if the button is still pushed (low) */
        CPUdelay(8000*50);
       // if (!PIN_getInputValue(pinId)) {
            /* Toggle LED based on the button pressed */
            switch (pinId) {
                case Board_PIN_BUTTON0:
                    currVal =  PIN_getOutputValue(Board_PIN_LED0);
                    PIN_setOutputValue(gpioHandle, Board_PIN_LED0, !currVal);
                    break;
    
               /* case Board_PIN_BUTTON1:
                    /*currVal =  PIN_getOutputValue(Board_PIN_LED1);
                    PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !currVal);
                    break;*/
    
                case PAIR:
                    if((PIN_getInputValue(PAIR) == GPIO_PIN_RESET) && (falling == FALSE))
                    {
                        falling = TRUE;
    
                        set_pair_flag(1);
                        set_pairing_done_flag(0);                                          // set panel in pairing mode as pair button pressed is detected
                        delete_sensors_start = 1;
                        delete_counter = 0;
                        delete_measurement_flag = 1;
                    }
                    else if((falling == TRUE) && (get_del_flash_flag() == 0))            // if pair button is released within 10 seconds clear delete flash flag
                    {
                        delete_counter = 0;
                        delete_sensors_start = 0;
                        delete_measurement_flag = 0;
                        falling = FALSE;
                    }
                    break;
    
                case PGOOD:
                    break;
    
                case CHG:
                    break;
    
                case RDY:
                    break;
    
               // case RI:
               //     break;
    
                case ALERT:
                    break;
    
                case SLP_STAT:
                     break;
    
                case TAMP:
                    if( (PIN_getInputValue(TAMP) == GPIO_PIN_RESET) && (falling_tamp == FALSE))
                    {
                        if(sensor_tamper_flag == 0)                                             // if only no sensor is tampered then relay off
                        {
                            //relay_off(TAMP_OUT);
                        }
    
                        set_tamp_flag(0);
                        falling_tamp = TRUE;
                    }
                    else
                    {
                        //relay_on(TAMP_OUT);                                       // tamper relay ON as tamper switch is released
                        set_tamp_flag(1);
                        falling_tamp = FALSE;
                    }
    
                     break;
    
              /*  case STATUS:
                     break;*/
    
                default:
                    /* Do nothing */
                    break;
            }
       // }
    }
    
    void board_init(void)
    {
        Power_init();
            /* Open LED pins */
            //GPIO_init();
        if(PIN_init(gpiotable) != PIN_SUCCESS)
        {
            while(1);
        }
    }
    void gpio_init(void)
    {
    
        GPIO_init();
    
        GPIO_setConfig(ISD_CS, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
        GPIO_setConfig(SYSOFF, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
        GPIO_setConfig(DTR, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
        GPIO_setConfig(WAKE_LTE, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
        GPIO_setConfig(CC1312R1_LAUNCHXL_SPI_MASTER_READY, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
        GPIO_setConfig(CODEC_EN, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
        GPIO_setConfig(LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
        GPIO_setConfig(BUZZER, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
        GPIO_setConfig(RELAY, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        GPIO_setConfig(PGOOD, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(PGOOD,power_stat_callback);
    
        GPIO_setConfig(CHG, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(CHG,chg_status_callback);
    
        GPIO_setConfig(CC1312R1_LAUNCHXL_GPIO_LCD_POWER, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(CC1312R1_LAUNCHXL_GPIO_LCD_POWER,lte_ready_status_callback);
    
        GPIO_setConfig(RI, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(RI,ri_callback);
    
        GPIO_setConfig(SLP_STAT, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(SLP_STAT,sleep_stat_callback);
    
        GPIO_setConfig(PAIR, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(PAIR,pair_callback);
    
        GPIO_setConfig(TAMP, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(TAMP,tamp_callback);
    
        GPIO_setConfig(STATUS, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(STATUS,status_callback);
    
        GPIO_setConfig(ALERT, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_BOTH_EDGES);
        GPIO_setCallback(ALERT,batt_alert_callback);
    
    
    
        GPIO_enableInt(PGOOD);
        GPIO_enableInt(CHG);
        GPIO_enableInt(CC1312R1_LAUNCHXL_GPIO_LCD_POWER);
        GPIO_enableInt(RI);
        GPIO_enableInt(SLP_STAT);
        GPIO_enableInt(PAIR);
        GPIO_enableInt(TAMP);
        GPIO_enableInt(STATUS);
        GPIO_enableInt(ALERT);
    
    
      /*  gpioHandle = PIN_open(&PinState, gpiotable);
        if(!gpioHandle) {
            /* Error initializing board LED pins */
       //     while(1);
       // }
    
        //GPIO_setConfig(ON_OFF_LTE,GPIO_CFG_OUT_STD|GPIO_CFG_OUT_LOW);
    
        //GPIO_write(ON_OFF_LTE, 1);
    
     //  if (PIN_registerIntCb(gpioHandle, &buttonCallbackFxn) != 0) {
                /* Error registering button callback function */
       /*         while(1);
            }
        /*buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
        if(!buttonPinHandle) {
            /* Error initializing button pins */
         /*   while(1);
        }*/
    
        /* Setup callback for button pins */
    
    }
    
    /**:
    * @brief This function set/resets the delete flash flag
    * @param del_flash_val_flag is the value of the flag : 1 - set , 0- reset
    * @return None
    */
    void set_del_flash_flag(uint8_t del_flash_val_flag)
    {
        delete_flash_flag = del_flash_val_flag;
    }
    
    /**:
    * @brief This function returns the latest status of the delete flash flag
    * @param None
    * @return 1 if flag was set else return 0 if flag was reset
    */
    
    uint8_t get_del_flash_flag(void)
    {
        uint8_t temp_del_flash_flag;
        temp_del_flash_flag = delete_flash_flag;
        return temp_del_flash_flag;
    
    }
    
    /**:
    * @brief This function set/resets the delete flash flag
    * @param del_flash_val_flag is the value of the flag : 1 - set , 0- reset
    * @return None
    */
    void set_pair_flag(uint8_t pair_val_flag)
    {
        pair_flag = pair_val_flag;
    }
    
    /**:
    * @brief This function returns the latest status of the pair_flag
    * @param None
    * @return 1 if flag was set else return 0 if flag was reset
    */
    uint8_t get_pair_flag(void)
    {
        uint8_t temp_pair_flag;
        temp_pair_flag = pair_flag;
        return temp_pair_flag;
    }
    
    /**:
    * @brief This function set/resets the delete flash flag
    * @param del_flash_val_flag is the value of the flag : 1 - set , 0- reset
    * @return None
    */
    void set_tamp_flag(uint8_t tamp_val_flag)
    {
        tamp_flag = tamp_val_flag;
    }
    
    /**:
    * @brief This function returns the latest status of the tamp_flag
    * @param None
    * @return 1 if flag was set else return 0 if flag was reset
    */
    uint8_t get_tamp_flag(void)
    {
        uint8_t temp_tamp_flag;
        temp_tamp_flag = tamp_flag;
        return temp_tamp_flag;
    }
    
    /**:
    * @brief This function set/resets the set_pairing_done_flag
    * @param pairing_done_val_flag is the value of the flag : 1 - set , 0- reset
    * @return None
    */
    
    void set_pairing_done_flag(uint8_t pairing_done_val_flag)
    {
            pairing_ok_flag = pairing_done_val_flag;
    }
    
    /**:
    * @brief This function returns the latest status of the pairing_done_flag
    * @param None
    * @return 1 if flag was set else return 0 if flag was reset
    */
    uint8_t get_pairing_done_flag(void)
    {
            uint8_t temp_pairing_done_flag;
            temp_pairing_done_flag = pairing_ok_flag;
            return temp_pairing_done_flag;
    }
    
    void buzzer_on(void)
    {
        PWM_init();
        PWM_Params params;
    
        PWM_Params_init(&params);
        params.dutyUnits = PWM_DUTY_US;
        params.dutyValue = BUZZER_DUTY_CYCLE;
        params.periodUnits = PWM_PERIOD_US;
        params.periodValue = BUZZER_PERIOD;
        if(!pwm1)
        {
            pwm1 = PWM_open(Board_PWM0, &params);
        }
        buzzer_flag = 1;
        PWM_start(pwm1);
    }
    
    void buzzer_off(void)
    {
        buzzer_flag = 0;
        PWM_stop(pwm1);
        //PWM_close(pwm1);
    }
    

    /*
     * Copyright (c) 2015-2018, 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.
     */
    
    /*
     *  ====================== CC1312R1_LAUNCHXL.c ===================================
     *  This file is responsible for setting up the board specific items for the
     *  CC1312R1_LAUNCHXL board.
     */
    
    #include <stdbool.h>
    #include <stddef.h>
    #include <stdint.h>
    
    #include <ti/devices/cc13x2_cc26x2_v1/driverlib/ioc.h>
    #include <ti/devices/cc13x2_cc26x2_v1/driverlib/udma.h>
    #include <ti/devices/cc13x2_cc26x2_v1/inc/hw_ints.h>
    #include <ti/devices/cc13x2_cc26x2_v1/inc/hw_memmap.h>
    
    #include "CC1312R1_LAUNCHXL.h"
    #include "gpio.h"
    #include "Board.h"
    
    /*
     *  =============================== ADCBuf ===============================
     */
    #include <ti/drivers/ADCBuf.h>
    #include <ti/drivers/adcbuf/ADCBufCC26X2.h>
    
    ADCBufCC26X2_Object adcBufCC26xxObjects[CC1312R1_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.
     */
    const ADCBufCC26X2_AdcChannelLutEntry ADCBufCC26X2_adcChannelLut[CC1312R1_LAUNCHXL_ADCBUF0CHANNELCOUNT] = {
        {CC1312R1_LAUNCHXL_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7},
        {CC1312R1_LAUNCHXL_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6},
        {CC1312R1_LAUNCHXL_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5},
        {CC1312R1_LAUNCHXL_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4},
        {CC1312R1_LAUNCHXL_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3},
        {CC1312R1_LAUNCHXL_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2},
        {CC1312R1_LAUNCHXL_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1},
        {CC1312R1_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},
    };
    
    const ADCBufCC26X2_HWAttrs adcBufCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADCBUFCOUNT] = {
        {
            .intPriority       = ~0,
            .swiPriority       = 0,
            .adcChannelLut     = ADCBufCC26X2_adcChannelLut,
            .gpTimerUnit       = CC1312R1_LAUNCHXL_GPTIMER0A,
        }
    };
    
    const ADCBuf_Config ADCBuf_config[CC1312R1_LAUNCHXL_ADCBUFCOUNT] = {
        {
            &ADCBufCC26X2_fxnTable,
            &adcBufCC26xxObjects[CC1312R1_LAUNCHXL_ADCBUF0],
            &adcBufCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADCBUF0]
        },
    };
    
    const uint_least8_t ADCBuf_count = CC1312R1_LAUNCHXL_ADCBUFCOUNT;
    
    /*
     *  =============================== ADC ===============================
     */
    #include <ti/drivers/ADC.h>
    #include <ti/drivers/adc/ADCCC26XX.h>
    
    ADCCC26XX_Object adcCC26xxObjects[CC1312R1_LAUNCHXL_ADCCOUNT];
    
    
    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADCCOUNT] = {
        {
            .adcDIO              = CC1312R1_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              = CC1312R1_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              = CC1312R1_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              = CC1312R1_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              = CC1312R1_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              = CC1312R1_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              = CC1312R1_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              = CC1312R1_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[CC1312R1_LAUNCHXL_ADCCOUNT] = {
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADC0], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADC0]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADC1], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADC1]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADC2], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADC2]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADC3], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADC3]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADC4], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADC4]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADC5], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADC5]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADC6], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADC6]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADC7], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADC7]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADCDCOUPL], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADCDCOUPL]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADCVSS], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADCVSS]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1312R1_LAUNCHXL_ADCVDDS], &adcCC26xxHWAttrs[CC1312R1_LAUNCHXL_ADCVDDS]},
    };
    
    const uint_least8_t ADC_count = CC1312R1_LAUNCHXL_ADCCOUNT;
    
    /*
     *  =============================== ECDH ===============================
     */
    #include <ti/drivers/ECDH.h>
    #include <ti/drivers/ecdh/ECDHCC26X2.h>
    
    ECDHCC26X2_Object ecdhCC26X2Objects[CC1312R1_LAUNCHXL_ECDHCOUNT];
    
    const ECDHCC26X2_HWAttrs ecdhCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECDHCOUNT] = {
        {
            .intPriority       = ~0,
            .swiPriority       = 0,
        }
    };
    
    const ECDH_Config ECDH_config[CC1312R1_LAUNCHXL_ECDHCOUNT] = {
        {
             .object  = &ecdhCC26X2Objects[CC1312R1_LAUNCHXL_ECDH0],
             .hwAttrs = &ecdhCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECDH0]
        },
    };
    
    const uint_least8_t ECDH_count = CC1312R1_LAUNCHXL_ECDHCOUNT;
    
    /*
     *  =============================== ECDSA ===============================
     */
    #include <ti/drivers/ECDSA.h>
    #include <ti/drivers/ecdsa/ECDSACC26X2.h>
    
    ECDSACC26X2_Object ecdsaCC26X2Objects[CC1312R1_LAUNCHXL_ECDSACOUNT];
    
    const ECDSACC26X2_HWAttrs ecdsaCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECDSACOUNT] = {
        {
            .intPriority       = ~0,
            .swiPriority       = 0,
        }
    };
    
    const ECDSA_Config ECDSA_config[CC1312R1_LAUNCHXL_ECDSACOUNT] = {
        {
             .object  = &ecdsaCC26X2Objects[CC1312R1_LAUNCHXL_ECDSA0],
             .hwAttrs = &ecdsaCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECDSA0]
        },
    };
    
    const uint_least8_t ECDSA_count = CC1312R1_LAUNCHXL_ECDSACOUNT;
    
    /*
     *  =============================== ECJPAKE ===============================
     */
    #include <ti/drivers/ECJPAKE.h>
    #include <ti/drivers/ecjpake/ECJPAKECC26X2.h>
    
    ECJPAKECC26X2_Object ecjpakeCC26X2Objects[CC1312R1_LAUNCHXL_ECJPAKECOUNT];
    
    const ECJPAKECC26X2_HWAttrs ecjpakeCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECJPAKECOUNT] = {
        {
            .intPriority       = ~0,
            .swiPriority       = 0,
        }
    };
    
    const ECJPAKE_Config ECJPAKE_config[CC1312R1_LAUNCHXL_ECJPAKECOUNT] = {
        {
             .object  = &ecjpakeCC26X2Objects[CC1312R1_LAUNCHXL_ECJPAKE0],
             .hwAttrs = &ecjpakeCC26X2HWAttrs[CC1312R1_LAUNCHXL_ECJPAKE0]
        },
    };
    
    const uint_least8_t ECJPAKE_count = CC1312R1_LAUNCHXL_ECJPAKECOUNT;
    
    
    /*
     *  =============================== SHA2 ===============================
     */
    #include <ti/drivers/SHA2.h>
    #include <ti/drivers/sha2/SHA2CC26X2.h>
    
    SHA2CC26X2_Object sha2CC26X2Objects[CC1312R1_LAUNCHXL_SHA2COUNT];
    
    const SHA2CC26X2_HWAttrs sha2CC26X2HWAttrs[CC1312R1_LAUNCHXL_SHA2COUNT] = {
        {
            .intPriority       = ~0,
            .swiPriority       = 0,
        }
    };
    
    const SHA2_Config SHA2_config[CC1312R1_LAUNCHXL_SHA2COUNT] = {
        {
             .object  = &sha2CC26X2Objects[CC1312R1_LAUNCHXL_SHA20],
             .hwAttrs = &sha2CC26X2HWAttrs[CC1312R1_LAUNCHXL_SHA20]
        },
    };
    
    const uint_least8_t SHA2_count = CC1312R1_LAUNCHXL_SHA2COUNT;
    
    /*
     *  =============================== AESCCM ===============================
     */
    #include <ti/drivers/AESCCM.h>
    #include <ti/drivers/aesccm/AESCCMCC26XX.h>
    
    AESCCMCC26XX_Object aesccmCC26XXObjects[CC1312R1_LAUNCHXL_AESCCMCOUNT];
    
    const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESCCMCOUNT] = {
        {
            .intPriority       = ~0,
            .swiPriority       = 0,
        }
    };
    
    const AESCCM_Config AESCCM_config[CC1312R1_LAUNCHXL_AESCCMCOUNT] = {
        {
             .object  = &aesccmCC26XXObjects[CC1312R1_LAUNCHXL_AESCCM0],
             .hwAttrs = &aesccmCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESCCM0]
        },
    };
    
    const uint_least8_t AESCCM_count = CC1312R1_LAUNCHXL_AESCCMCOUNT;
    
    /*
     *  =============================== AESECB ===============================
     */
    #include <ti/drivers/AESECB.h>
    #include <ti/drivers/aesecb/AESECBCC26XX.h>
    
    AESECBCC26XX_Object aesecbCC26XXObjects[CC1312R1_LAUNCHXL_AESECBCOUNT];
    
    const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESECBCOUNT] = {
        {
            .intPriority       = ~0,
            .swiPriority       = 0,
        }
    };
    
    const AESECB_Config AESECB_config[CC1312R1_LAUNCHXL_AESECBCOUNT] = {
        {
             .object  = &aesecbCC26XXObjects[CC1312R1_LAUNCHXL_AESECB0],
             .hwAttrs = &aesecbCC26XXHWAttrs[CC1312R1_LAUNCHXL_AESECB0]
        },
    };
    
    const uint_least8_t AESECB_count = CC1312R1_LAUNCHXL_AESECBCOUNT;
    
    /*
     *  =============================== 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;
    DisplaySharp_Object    displaySharpObject;
    
    static char uartStringBuf[BOARD_DISPLAY_UART_STRBUF_SIZE];
    static uint_least8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8];
    
    const DisplayUart_HWAttrs displayUartHWAttrs = {
        .uartIdx      = CC1312R1_LAUNCHXL_UART0,
        .baudRate     = 115200,
        .mutexTimeout = (unsigned int)(-1),
        .strBuf       = uartStringBuf,
        .strBufLen    = BOARD_DISPLAY_UART_STRBUF_SIZE,
    };
    
    /*const DisplaySharp_HWAttrsV1 displaySharpHWattrs = {
        .spiIndex    = CC1312R1_LAUNCHXL_SPI0,
        .csPin       = CC1312R1_LAUNCHXL_GPIO_LCD_CS,
        .powerPin    = CC1312R1_LAUNCHXL_GPIO_LCD_POWER,
        .enablePin   = CC1312R1_LAUNCHXL_GPIO_LCD_ENABLE,
        .pixelWidth  = BOARD_DISPLAY_SHARP_SIZE,
        .pixelHeight = BOARD_DISPLAY_SHARP_SIZE,
        .displayBuf  = sharpDisplayBuf,
    };*/
    
    #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) */
    
    /*
     *  =============================== 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 CC1312R1_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[] = {
        PGOOD  | GPIO_DO_NOT_CONFIG,
        CHG    | GPIO_DO_NOT_CONFIG,
        GPIOCC26XX_DIO_22 | GPIO_DO_NOT_CONFIG, /* LCD power control */
        //RDY    | GPIO_DO_NOT_CONFIG,
        ALERT  | GPIO_DO_NOT_CONFIG,
        SLP_STAT | GPIO_DO_NOT_CONFIG,
        PAIR | GPIO_DO_NOT_CONFIG,
        TAMP | GPIO_DO_NOT_CONFIG,
        STATUS | GPIO_DO_NOT_CONFIG,
        RI | GPIO_DO_NOT_CONFIG,
    
        /* 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,  /* CC1312R1_LAUNCHXL_SPI_MASTER_READY */
        //GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,  /* CC1312R1_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_23 | GPIO_DO_NOT_CONFIG, /*LCD enable */
        //input pins
    
        // output pins
        ISD_CS | GPIO_DO_NOT_CONFIG,
        SYSOFF | GPIO_DO_NOT_CONFIG,
        DTR    | GPIO_DO_NOT_CONFIG,
        WAKE_LTE | GPIO_DO_NOT_CONFIG,
        //ON_OFF_LTE | GPIO_DO_NOT_CONFIG,
        CODEC_EN | GPIO_DO_NOT_CONFIG,
        LED1 | GPIO_DO_NOT_CONFIG,
        BUZZER | GPIO_DO_NOT_CONFIG,
        RELAY | GPIO_DO_NOT_CONFIG,
    };
    
    /*
     * Array of callback function pointers
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in CC1312R1_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,
        NULL,
        NULL,  /* Button 0 */
        NULL,  /* Button 1 */
        NULL,  /* CC1312R1_LAUNCHXL_SPI_MASTER_READY */
        NULL,  /* CC1312R1_LAUNCHXL_SPI_SLAVE_READY */
        NULL,
        NULL,
        NULL,
    
    };
    
    const GPIOCC26XX_Config GPIOCC26XX_config = {
        .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
        .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
        .numberOfPinConfigs = CC1312R1_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[CC1312R1_LAUNCHXL_GPTIMERCOUNT];
    
    const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[CC1312R1_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[CC1312R1_LAUNCHXL_GPTIMERPARTSCOUNT] = {
        { &gptimerCC26XXObjects[CC1312R1_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_GPTIMER0A], GPT_A },
        { &gptimerCC26XXObjects[CC1312R1_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_GPTIMER0B], GPT_B },
        { &gptimerCC26XXObjects[CC1312R1_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_GPTIMER1A], GPT_A },
        { &gptimerCC26XXObjects[CC1312R1_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_GPTIMER1B], GPT_B },
        { &gptimerCC26XXObjects[CC1312R1_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_GPTIMER2A], GPT_A },
        { &gptimerCC26XXObjects[CC1312R1_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_GPTIMER2B], GPT_B },
        { &gptimerCC26XXObjects[CC1312R1_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_GPTIMER3A], GPT_A },
        { &gptimerCC26XXObjects[CC1312R1_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_GPTIMER3B], GPT_B },
    };
    
    /*
     *  =============================== I2C ===============================
    */
    #include <ti/drivers/I2C.h>
    #include <ti/drivers/i2c/I2CCC26XX.h>
    
    I2CCC26XX_Object i2cCC26xxObjects[CC1312R1_LAUNCHXL_I2CCOUNT];
    
    const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC1312R1_LAUNCHXL_I2CCOUNT] = {
        {
            .baseAddr    = I2C0_BASE,
            .powerMngrId = PowerCC26XX_PERIPH_I2C0,
            .intNum      = INT_I2C_IRQ,
            .intPriority = ~0,
            .swiPriority = 0,
            .sdaPin      = CC1312R1_LAUNCHXL_I2C0_SDA0,
            .sclPin      = CC1312R1_LAUNCHXL_I2C0_SCL0,
        }
    };
    
    const I2C_Config I2C_config[CC1312R1_LAUNCHXL_I2CCOUNT] = {
        {
            .fxnTablePtr = &I2CCC26XX_fxnTable,
            .object      = &i2cCC26xxObjects[CC1312R1_LAUNCHXL_I2C0],
            .hwAttrs     = &i2cCC26xxHWAttrs[CC1312R1_LAUNCHXL_I2C0]
        }
    };
    
    const uint_least8_t I2C_count = CC1312R1_LAUNCHXL_I2CCOUNT;
    
    /*
     *  =============================== NVS ===============================
     */
    #include <ti/drivers/NVS.h>
    #include <ti/drivers/nvs/NVSSPI25X.h>
    #include <ti/drivers/nvs/NVSCC26XX.h>
    
    #define NVS_REGIONS_BASE 0x48000
    #define SECTORSIZE       0x2000
    #define REGIONSIZE       (SECTORSIZE * 4)
    #define SPISECTORSIZE    0x1000
    #define SPIREGIONSIZE    (SPISECTORSIZE * 32)
    #define VERIFYBUFSIZE    64
    
    static uint8_t verifyBuf[VERIFYBUFSIZE];
    
    /*
     * 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 and NVS SPI */
    NVSCC26XX_Object nvsCC26xxObjects[1];
    NVSSPI25X_Object nvsSPI25XObjects[1];
    
    /* Hardware attributes for NVS */
    const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = {
        {
            .regionBase = (void *)flashBuf,
            .regionSize = REGIONSIZE,
        },
    };
    
    /* Hardware attributes for NVS SPI */
    /*const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = {
        {
            .regionBaseOffset = 0,
            .regionSize = SPIREGIONSIZE,
            .sectorSize = SPISECTORSIZE,
            .verifyBuf = verifyBuf,
            .verifyBufSize = VERIFYBUFSIZE,
            .spiHandle = NULL,
            .spiIndex = 0,
            .spiBitRate = 4000000,
            .spiCsnGpioIndex = CC1312R1_LAUNCHXL_GPIO_SPI_FLASH_CS,
        },
    };
    */
    /* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */
    /*const NVS_Config NVS_config[CC1312R1_LAUNCHXL_NVSCOUNT] = {
        {
            .fxnTablePtr = &NVSCC26XX_fxnTable,
            .object = &nvsCC26xxObjects[0],
            .hwAttrs = &nvsCC26xxHWAttrs[0],
        },
        {
            .fxnTablePtr = &NVSSPI25X_fxnTable,
            .object = &nvsSPI25XObjects[0],
            .hwAttrs = &nvsSPI25XHWAttrs[0],
        },
    };
    
    const uint_least8_t NVS_count = CC1312R1_LAUNCHXL_NVSCOUNT;
    
    /*
     *  =============================== PIN ===============================
     */
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    
    const PIN_Config BoardGpioInitTable[] = {
    
        CC1312R1_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off          */
        CC1312R1_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off          */
        CC1312R1_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low       */
        CC1312R1_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low       */
        CC1312R1_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,  /* External flash chip select */
        CC1312R1_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
        CC1312R1_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,                        /* UART TX via debugger back channel */
        CC1312R1_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master out - slave in */
        CC1312R1_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master in - slave out */
        CC1312R1_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,                                             /* SPI clock */
    
        PIN_TERMINATE
    };
    
    const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
        .intPriority = ~0,
        .swiPriority = 0
    };
    
    /*
     *  =============================== Power ===============================
     */
    #include <ti/drivers/Power.h>
    #include <ti/drivers/power/PowerCC26X2.h>
    
    const PowerCC26X2_Config PowerCC26X2_config = {
        .policyInitFxn      = NULL,
        .policyFxn          = &PowerCC26XX_standbyPolicy,
        .calibrateFxn       = &PowerCC26XX_calibrate,
        .enablePolicy       = true,
        .calibrateRCOSC_LF  = true,
        .calibrateRCOSC_HF  = true,
    };
    
    /*
     *  =============================== 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[CC1312R1_LAUNCHXL_PWMCOUNT];
    
    const PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWMCOUNT] = {
        { .pwmPin = CC1312R1_LAUNCHXL_PWMPIN0, .gpTimerUnit = CC1312R1_LAUNCHXL_GPTIMER0A },
        { .pwmPin = CC1312R1_LAUNCHXL_PWMPIN1, .gpTimerUnit = CC1312R1_LAUNCHXL_GPTIMER0B },
        { .pwmPin = CC1312R1_LAUNCHXL_PWMPIN2, .gpTimerUnit = CC1312R1_LAUNCHXL_GPTIMER1A },
        { .pwmPin = CC1312R1_LAUNCHXL_PWMPIN3, .gpTimerUnit = CC1312R1_LAUNCHXL_GPTIMER1B },
        { .pwmPin = CC1312R1_LAUNCHXL_PWMPIN4, .gpTimerUnit = CC1312R1_LAUNCHXL_GPTIMER2A },
        { .pwmPin = CC1312R1_LAUNCHXL_PWMPIN5, .gpTimerUnit = CC1312R1_LAUNCHXL_GPTIMER2B },
        { .pwmPin = CC1312R1_LAUNCHXL_PWMPIN6, .gpTimerUnit = CC1312R1_LAUNCHXL_GPTIMER3A },
        { .pwmPin = CC1312R1_LAUNCHXL_PWMPIN7, .gpTimerUnit = CC1312R1_LAUNCHXL_GPTIMER3B },
    };
    
    const PWM_Config PWM_config[CC1312R1_LAUNCHXL_PWMCOUNT] = {
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1312R1_LAUNCHXL_PWM0], &pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWM0] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1312R1_LAUNCHXL_PWM1], &pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWM1] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1312R1_LAUNCHXL_PWM2], &pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWM2] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1312R1_LAUNCHXL_PWM3], &pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWM3] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1312R1_LAUNCHXL_PWM4], &pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWM4] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1312R1_LAUNCHXL_PWM5], &pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWM5] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1312R1_LAUNCHXL_PWM6], &pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWM6] },
        { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1312R1_LAUNCHXL_PWM7], &pwmtimerCC26xxHWAttrs[CC1312R1_LAUNCHXL_PWM7] },
    };
    
    const uint_least8_t PWM_count = CC1312R1_LAUNCHXL_PWMCOUNT;
    
    /*
     *  =============================== 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 */
    };
    
    /*
     *  =============================== SD ===============================
     */
    #include <ti/drivers/SD.h>
    #include <ti/drivers/sd/SDSPI.h>
    
    SDSPI_Object sdspiObjects[CC1312R1_LAUNCHXL_SDCOUNT];
    
    /*const SDSPI_HWAttrs sdspiHWAttrs[CC1312R1_LAUNCHXL_SDCOUNT] = {
        {
            .spiIndex = CC1312R1_LAUNCHXL_SPI0,
            .spiCsGpioIndex = CC1312R1_LAUNCHXL_SDSPI_CS
        }
    };*/
    
    /*const SD_Config SD_config[CC1312R1_LAUNCHXL_SDCOUNT] = {
        {
            .fxnTablePtr = &SDSPI_fxnTable,
            .object = &sdspiObjects[CC1312R1_LAUNCHXL_SDSPI0],
            .hwAttrs = &sdspiHWAttrs[CC1312R1_LAUNCHXL_SDSPI0]
        },
    };
    */
    const uint_least8_t SD_count = CC1312R1_LAUNCHXL_SDCOUNT;
    
    /*
     *  =============================== SPI DMA ===============================
     */
    #include <ti/drivers/SPI.h>
    #include <ti/drivers/spi/SPICC26XXDMA.h>
    
    SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1312R1_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[CC1312R1_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            = MOSI,
            .misoPin            = MISO,
            .clkPin             = SCLK,
            .csnPin             = ISD_CS,
            .minDmaTransferSize = 10
        },
        {
            .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            = CC1312R1_LAUNCHXL_SPI1_MOSI,
            .misoPin            = CC1312R1_LAUNCHXL_SPI1_MISO,
            .clkPin             = CC1312R1_LAUNCHXL_SPI1_CLK,
            .csnPin             = CC1312R1_LAUNCHXL_SPI1_CSN,
            .minDmaTransferSize = 10
        }
    };
    
    const SPI_Config SPI_config[CC1312R1_LAUNCHXL_SPICOUNT] = {
        {
             .fxnTablePtr = &SPICC26XXDMA_fxnTable,
             .object      = &spiCC26XXDMAObjects[CC1312R1_LAUNCHXL_SPI0],
             .hwAttrs     = &spiCC26XXDMAHWAttrs[CC1312R1_LAUNCHXL_SPI0]
        },
        {
             .fxnTablePtr = &SPICC26XXDMA_fxnTable,
             .object      = &spiCC26XXDMAObjects[CC1312R1_LAUNCHXL_SPI1],
             .hwAttrs     = &spiCC26XXDMAHWAttrs[CC1312R1_LAUNCHXL_SPI1]
        },
    };
    
    const uint_least8_t SPI_count = CC1312R1_LAUNCHXL_SPICOUNT;
    
    /*
     *  =============================== UART ===============================
     */
    #include <ti/drivers/UART.h>
    #include <ti/drivers/uart/UARTCC26XX.h>
    
    UARTCC26XX_Object uartCC26XXObjects[CC1312R1_LAUNCHXL_UARTCOUNT];
    
    uint8_t uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UARTCOUNT][32];
    
    const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UARTCOUNT] = {
        {
            .baseAddr       = UART0_BASE,
            .powerMngrId    = PowerCC26XX_PERIPH_UART0,
            .intNum         = INT_UART0_COMB,
            .intPriority    = ~0,
            .swiPriority    = 0,
            .txPin          = CC1312R1_LAUNCHXL_UART_TX,
            .rxPin          = CC1312R1_LAUNCHXL_UART_RX,
            .ctsPin         = PIN_UNASSIGNED,
            .rtsPin         = PIN_UNASSIGNED,
            .ringBufPtr     = uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART0],
            .ringBufSize    = sizeof(uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART0]),
            .txIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_1_8,
            .rxIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_4_8,
            .errorFxn       = NULL
        },
    
        {
                .baseAddr       = UART1_BASE,
                .powerMngrId    = PowerCC26X2_PERIPH_UART1,
                .intNum         = INT_UART1_COMB,
                .intPriority    = ~0,
                .swiPriority    = 0,
                .txPin          = CC1312R1_LAUNCHXL_UART1_TX,
                .rxPin          = CC1312R1_LAUNCHXL_UART1_RX,
                .ctsPin         = PIN_UNASSIGNED,
                .rtsPin         = PIN_UNASSIGNED,
                .ringBufPtr     = uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART1],
                .ringBufSize    = sizeof(uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART1]),
                .txIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_1_8,
                .rxIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_4_8,
                .errorFxn       = NULL
            }
    };
    
    const UART_Config UART_config[CC1312R1_LAUNCHXL_UARTCOUNT] = {
        {
            .fxnTablePtr = &UARTCC26XX_fxnTable,
            .object      = &uartCC26XXObjects[CC1312R1_LAUNCHXL_UART0],
            .hwAttrs     = &uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UART0]
        },
        {
            .fxnTablePtr = &UARTCC26XX_fxnTable,
            .object      = &uartCC26XXObjects[CC1312R1_LAUNCHXL_UART1],
            .hwAttrs     = &uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UART1]
        }
    };
    
    const uint_least8_t UART_count = CC1312R1_LAUNCHXL_UARTCOUNT;
    
    /*
     *  =============================== UDMA ===============================
     */
    #include <ti/drivers/dma/UDMACC26XX.h>
    
    UDMACC26XX_Object udmaObjects[CC1312R1_LAUNCHXL_UDMACOUNT];
    
    const UDMACC26XX_HWAttrs udmaHWAttrs[CC1312R1_LAUNCHXL_UDMACOUNT] = {
        {
            .baseAddr    = UDMA0_BASE,
            .powerMngrId = PowerCC26XX_PERIPH_UDMA,
            .intNum      = INT_DMA_ERR,
            .intPriority = ~0
        }
    };
    
    const UDMACC26XX_Config UDMACC26XX_config[CC1312R1_LAUNCHXL_UDMACOUNT] = {
        {
             .object  = &udmaObjects[CC1312R1_LAUNCHXL_UDMA0],
             .hwAttrs = &udmaHWAttrs[CC1312R1_LAUNCHXL_UDMA0]
        },
    };
    
    /*
     *  =============================== Watchdog ===============================
     */
    #include <ti/drivers/Watchdog.h>
    #include <ti/drivers/watchdog/WatchdogCC26XX.h>
    
    WatchdogCC26XX_Object watchdogCC26XXObjects[CC1312R1_LAUNCHXL_WATCHDOGCOUNT];
    
    const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC1312R1_LAUNCHXL_WATCHDOGCOUNT] = {
        {
            .baseAddr    = WDT_BASE,
            .reloadValue = 1000 /* Reload value in milliseconds */
        },
    };
    
    const Watchdog_Config Watchdog_config[CC1312R1_LAUNCHXL_WATCHDOGCOUNT] = {
        {
            .fxnTablePtr = &WatchdogCC26XX_fxnTable,
            .object      = &watchdogCC26XXObjects[CC1312R1_LAUNCHXL_WATCHDOG0],
            .hwAttrs     = &watchdogCC26XXHWAttrs[CC1312R1_LAUNCHXL_WATCHDOG0]
        },
    };
    
    const uint_least8_t Watchdog_count = CC1312R1_LAUNCHXL_WATCHDOGCOUNT;
    
    /*
     *  ======== CC1312R1_LAUNCHXL_wakeUpExtFlash ========
     */
    void CC1312R1_LAUNCHXL_wakeUpExtFlash(void)
    {
        PIN_Config extFlashPinTable[] = {
            CC1312R1_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_INPUT_DIS | PIN_DRVSTR_MED,
            PIN_TERMINATE
        };
        PIN_State extFlashPinState;
        PIN_Handle extFlashPinHandle = PIN_open(&extFlashPinState, extFlashPinTable);
    
        /*
         *  To wake up we need to toggle the chip select at
         *  least 20 ns and ten wait at least 35 us.
         */
    
        /* Toggle chip select for ~20ns to wake ext. flash */
        PIN_setOutputValue(extFlashPinHandle, CC1312R1_LAUNCHXL_SPI_FLASH_CS, 0);
        /* 3 cycles per loop: 1 loop @ 48 Mhz ~= 62 ns */
        CPUdelay(1);
        PIN_setOutputValue(extFlashPinHandle, CC1312R1_LAUNCHXL_SPI_FLASH_CS, 1);
        /* 3 cycles per loop: 560 loops @ 48 Mhz ~= 35 us */
        CPUdelay(560);
    
        PIN_close(extFlashPinHandle);
    }
    
    /*
     *  ======== CC1312R1_LAUNCHXL_sendExtFlashByte ========
     */
    void CC1312R1_LAUNCHXL_sendExtFlashByte(PIN_Handle pinHandle, uint8_t byte)
    {
        uint8_t i;
    
        PIN_setOutputValue(pinHandle, CC1312R1_LAUNCHXL_SPI_FLASH_CS, 0);
    
        for (i = 0; i < 8; i++) {
            PIN_setOutputValue(pinHandle, CC1312R1_LAUNCHXL_SPI0_CLK, 0);
            PIN_setOutputValue(pinHandle, CC1312R1_LAUNCHXL_SPI0_MOSI, (byte >> (7 - i)) & 0x01);
            PIN_setOutputValue(pinHandle, CC1312R1_LAUNCHXL_SPI0_CLK, 1);
    
            /*
             * Waste a few cycles to keep the CLK high for at
             * least 45% of the period.
             * 3 cycles per loop: 8 loops @ 48 Mhz = 0.5 us.
             */
            CPUdelay(8);
        }
    
        PIN_setOutputValue(pinHandle, CC1312R1_LAUNCHXL_SPI0_CLK, 0);
        PIN_setOutputValue(pinHandle, CC1312R1_LAUNCHXL_SPI_FLASH_CS, 1);
    
        /*
         * Keep CS high atleast 40 us
         * 3 cycles per loop: 700 loops @ 48 Mhz ~= 44 us
         */
        CPUdelay(700);
    }
    
    /*
     *  ======== CC1312R1_LAUNCHXL_shutDownExtFlash ========
     */
    void CC1312R1_LAUNCHXL_shutDownExtFlash(void)
    {
        /* To be sure we are putting the flash into sleep and not waking it, we first have to make a wake up call */
        CC1312R1_LAUNCHXL_wakeUpExtFlash();
    
        PIN_Config extFlashPinTable[] = {
            CC1312R1_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_INPUT_DIS | PIN_DRVSTR_MED,
            CC1312R1_LAUNCHXL_SPI0_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_INPUT_DIS | PIN_DRVSTR_MED,
            CC1312R1_LAUNCHXL_SPI0_MOSI | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_INPUT_DIS | PIN_DRVSTR_MED,
            CC1312R1_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,
            PIN_TERMINATE
        };
        PIN_State extFlashPinState;
        PIN_Handle extFlashPinHandle = PIN_open(&extFlashPinState, extFlashPinTable);
    
        uint8_t extFlashShutdown = 0xB9;
    
        CC1312R1_LAUNCHXL_sendExtFlashByte(extFlashPinHandle, extFlashShutdown);
    
        PIN_close(extFlashPinHandle);
    }
    
    /*
     *  ======== CC1312R1_LAUNCHXL_initGeneral ========
     */
    void CC1312R1_LAUNCHXL_initGeneral(void)
    {
        Power_init();
    
        if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
            /* Error with PIN_init */
            while (1);
        }
    
        /* Shut down external flash as default */
        CC1312R1_LAUNCHXL_shutDownExtFlash();
    }
    

    CC1312R1_LAUNCHXL.h

  • Hi Omkar,

    Seems to me there might be some confusion in the GPIO setup you use. You seem to use the "CC1312R1_LAUNCHXL_GPIOName" enum correctly, setting up your "GPIO" name for each pin.

    In the "gpioPinConfigs" table, you then seem to mix enums and IOID numbers. For example your first entry here is "PGOOD" with is a enumerator while it should be the IOID number of the pin you want to connect to "PGOOD".
    On some places in this struct you do give the IOID number like in the case of "CC1312R1_LAUNCHXL_GPIO_S1".

    I would suggest you look over the board files and make sure the GPIO tables are setup as intended as your setup would only work if the pins you meant to assign is 0, 1, 2 ,3 etc. starting from PGOOD (maybe this is your plan?).
  • Hello M-W,

    Thank you for your reply!

                   If I have understood you correctly, then I have to mention only IOID numbers in "gpioPinConfigs" table and in "CC1312R1_LAUNCHXL_GPIOName"  enum I can give any name I would want as in my case like "PGOOD"  and order of enum and configtable array should match as I intended. 

    Please correct me if I am wrong.

    regards,

    Omkar

  • Hi Omkar,

    You have understood me correctly, basically the "gpioPinConfigs" table contains the actual hardware configuration (IOID, mode, etc) while the enum is used as the index of the array (which is why the should match in order).
  • Hello M-W,
    It is working now. What I did is to make the new "gpioPinConfigs" table in gpiointerrupt project as per my need and enum in the same order. I copied this same configuration in my project and now gpio callbacks are working as I expected.
    Thank you for your help!

    regards,
    Omkar