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/CC1350: Add new pin driver

Part Number: CC1350
Other Parts Discussed in Thread: LAUNCHXL-CC1310

Tool/software: TI-RTOS

I need some help with applying the example provided in chapter 8 "Peripherals and Drivers" in Embedded developer's Guide.

I don't know how to apply steps 2 and 3. (where to add these codes?)

The Example provided in the Embedded developer's Guide:-

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

The following sensor-specific functions, ssf.c, and code modifications are required:
1. Include PIN driver files:
#include <ti/drivers/pin/PIN.h>
2. Declare the pin configuration table and pin state and handle variables to be used by the
sensor_cc13x0lp task:

static PIN_Config SSF_configTable[] =
{
Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_BUTTON0 | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
PIN_TERMINATE
};
static PIN_State ssfPins;
static PIN_Handle hSsfPins;


3. Declare the ISR to be performed in the hwi context. This sets an event in the application task and
wakes it up, to minimize processing in the hwi context.

static void buttonHwiFxn (PIN_Handle hPin, PIN_Id pinId)
{
// set event in SSF task to process outside of hwi context
events |= SSF_BTN_EVT;
// Wake up the application.
Semaphore_post(sem);
}

4. Define the event and related processing (in Sensor_process()) to handle the event from Step 3.

#define SSF_BTN_EVT 0x0001
if (events & SSF_BTN_EVT)
{
events &= ~SSF_BTN_EVT; //clear event
//toggle LED0
if (LED_value)
{
PIN_setOutputValue(hSsfPins, Board_LED0, LED_value--);
}
else
{
PIN_setOutputValue(hSsfPins, Board_LED0, LED_value++);
}
}


5. In Sensor_init(), open the pins for use and configure the interrupt:

// Open pin structure for use
hSsfPins = PIN_open(&ssfPins, SSF_configTable);
// Register ISR
PIN_registerIntCb(hSsfPins, buttonHwiFxn);
// Configure interrupt
PIN_setConfig(hSsfPins, PIN_BM_IRQ, Board_BUTTON0 | PIN_IRQ_NEGEDGE);
// Enable wakeup
PIN_setConfig(hSsfPins, PINCC26XX_BM_WAKEUP, Board_BUTTON0|PINCC26XX_WAKEUP_NEGEDGE);


6. Compile, download, and run. Pushing the Up button on the LaunchPad toggles the red LED. There is
no debouncing implemented here.

  • I don't see your steps in chapter 8 "Peripherals and Drivers" in Embedded developer's Guide. Anyway, the followings are my steps to add a PIN as GPI button for your reference.

    1. Add your Board key Board_XXX to keyPinTable[] in board_key.c and you have to map Board_XXX in Board.h.

    2. Add your "else if(keyPinId == Board_XXX) {...}" in board_key_keyFxn() in board_key.c to OR key event to you Board key.

    3. Handle you key event in Ssf_processEvents() in ssf.c

  • Thanks a lot for ur great help, one last question plz

    i only have now to select an available pin, what are the pins of boosterpack generic are used for?

    /* Mapping of pins to board signals using general board aliases
     *      <board signal alias>        <pin mapping>   <comments>
     */
    
    /* Discrete outputs */
    #define Board_RLED                  IOID_6
    #define Board_GLED                  IOID_7
    #define Board_LED_ON                1
    #define Board_LED_OFF               0
    
    /* Discrete inputs */
    #define Board_BTN1                  IOID_13
    #define Board_BTN2                  IOID_14
    /* #define Board_Power              IOID_11
    
    /* UART Board */
    #define Board_UART_RX               IOID_2          /* RXD  */
    #define Board_UART_TX               IOID_3          /* TXD  */
    #define Board_UART_CTS              IOID_19         /* CTS  */
    #define Board_UART_RTS              IOID_18         /* RTS */
    
    /* SPI Board */
    #define Board_SPI0_MISO             IOID_8          /* RF1.20 */
    #define Board_SPI0_MOSI             IOID_9          /* RF1.18 */
    #define Board_SPI0_CLK              IOID_10         /* RF1.16 */
    #define Board_SPI0_CSN              PIN_UNASSIGNED
    #define Board_SPI1_MISO             PIN_UNASSIGNED
    #define Board_SPI1_MOSI             PIN_UNASSIGNED
    #define Board_SPI1_CLK              PIN_UNASSIGNED
    #define Board_SPI1_CSN              PIN_UNASSIGNED
    
    /* I2C */
    #define Board_I2C0_SCL0             IOID_4
    #define Board_I2C0_SDA0             IOID_5
    
    /* SPI */
    #define Board_SPI_FLASH_CS          IOID_20
    #define Board_FLASH_CS_ON           0
    #define Board_FLASH_CS_OFF          1
    
    /* Booster pack generic */
    #define Board_DIO0                  IOID_0
    #define Board_DIO1_RFSW             IOID_1
    #define Board_DIO12                 IOID_12
    #define Board_DIO15                 IOID_15
    #define Board_DIO16_TDO             IOID_16
    #define Board_DIO17_TDI             IOID_17
    #define Board_DIO21                 IOID_21
    #define Board_DIO22                 IOID_22
    #define Board_DIO30_SWPWR           IOID_30
    
    #define Board_DIO23_ANALOG          IOID_23
    #define Board_DIO24_ANALOG          IOID_24
    #define Board_DIO25_ANALOG          IOID_25
    #define Board_DIO26_ANALOG          IOID_26
    #define Board_DIO27_ANALOG          IOID_27
    #define Board_DIO28_ANALOG          IOID_28
    #define Board_DIO29_ANALOG          IOID_29
    #define Board_DIO30_ANALOG          IOID_30
    
    /* Booster pack LCD (430BOOST - Sharp96 Rev 1.1) */
    #define Board_LCD_CS                IOID_24 // SPI chip select
    #define Board_LCD_EXTCOMIN          IOID_12 // External COM inversion
    #define Board_LCD_ENABLE            IOID_22 // LCD enable
    #define Board_LCD_POWER             IOID_23 // LCD power control
    #define Board_LCD_CS_ON             1
    #define Board_LCD_CS_OFF            0
    
    /* PWM outputs */
    #define Board_PWMPIN0                       Board_RLED
    #define Board_PWMPIN1                       Board_GLED
    #define Board_PWMPIN2                       PIN_UNASSIGNED
    #define Board_PWMPIN3                       PIN_UNASSIGNED
    #define Board_PWMPIN4                       PIN_UNASSIGNED
    #define Board_PWMPIN5                       PIN_UNASSIGNED
    #define Board_PWMPIN6                       PIN_UNASSIGNED
    #define Board_PWMPIN7                       PIN_UNASSIGNED
    

  • I couldn't understand "what are the pins of boosterpack generic are used for"? Can you elaborate?
  • okay, i can understand what digital inputs,outputs,SPI,I2C,... i know their meaning , but i couldn't understand what is the meaning of "boosterpack generic",
    Anyway to elaborate my question,, i just need now to map Board_XXX as u said, how to?
  • 1. For example, if we want add IOID_15 as new button 3, you can add Board_BUTTON3 into keyPinTable, add "#define Board_BUTTON3 Board_BTN3" in board.h, and add "#define Board_BTN3 IOID_15" in CC1350_LAUNCHXL.h.
    2. "Booster pack generic" defines generic IO pins on LAUNCHXL-CC1310 booster pack.
  • That's it , thnx a lot :D
  • You are welcome.