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.

SCE scTaskAlertCallback how to trigger?

Hello there,

I am integrating LED Blinker project into simpleBLEPeripheral project, and have created task file by myself. Based on TI-RTOS enabled SCS code.

But somehow, scTaskAlertCallback() seems never be triggered by any button pressing actions on smartRF06. Not sure if I did it right, specially for the GPIO buttons code, since they are copied from main.c from SCS pre-existed code. Not sure if they are enough, or i still need to add PIN_open stuff? I will try to add those code to test, but it is better that somewhere I can find a guide or sample code.

Thanks!

Below is snap of my code:

void scTaskAlertCallback(void) {

    // Wake up the OS task
    Semaphore_post(Semaphore_handle(&semScTaskAlert));

} // scTaskAlertCallback


void taskFxn(UArg a0, UArg a1) {

    // Enable power domains
    PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);
    PRCMLoadSet();
    while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) != PRCM_DOMAIN_POWER_ON);

    // Enable the GPIO module
    PRCMPeripheralRunEnable(PRCM_PERIPH_GPIO);
    PRCMPeripheralSleepEnable(PRCM_PERIPH_GPIO);
    PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_GPIO);
    PRCMLoadSet();
    while (!PRCMLoadGet());

    // Setup GPIOs for LEDs and buttons
    HWREG(GPIO_BASE + GPIO_O_DOE31_0) &= ~(BV(IOID_KEY_LEFT) | BV(IOID_KEY_RIGHT) | BV(IOID_KEY_UP) | BV(IOID_KEY_DOWN));
    HWREG(GPIO_BASE + GPIO_O_DOE31_0) |= BV(IOID_LED_1) | BV(IOID_LED_2);
    HWREG(IOC_BASE + IOC_O_IOCFG(IOID_LED_1))             = IOC_STD_OUTPUT | IOC_PORT_GPIO;
    HWREG(IOC_BASE + IOC_O_IOCFG(IOID_LED_2))             = IOC_STD_OUTPUT | IOC_PORT_GPIO;
    HWREG(IOC_BASE + IOC_O_IOCFG(IOID_KEY_LEFT))          = ((IOC_STD_INPUT & ~IOC_NO_IOPULL) | IOC_IOPULL_UP) | IOC_PORT_GPIO;
    HWREG(IOC_BASE + IOC_O_IOCFG(IOID_KEY_RIGHT))         = ((IOC_STD_INPUT & ~IOC_NO_IOPULL) | IOC_IOPULL_UP) | IOC_PORT_GPIO;
    HWREG(IOC_BASE + IOC_O_IOCFG(IOID_KEY_UP))            = ((IOC_STD_INPUT & ~IOC_NO_IOPULL) | IOC_IOPULL_UP) | IOC_PORT_GPIO;
    HWREG(IOC_BASE + IOC_O_IOCFG(IOID_KEY_DOWN))          = ((IOC_STD_INPUT & ~IOC_NO_IOPULL) | IOC_IOPULL_UP) | IOC_PORT_GPIO;

    // In this example, we keep the AUX domain access permanently enabled
    //scifOsalEnableAuxDomainAccess();

    // Initialize and start the Sensor Controller
    scifOsalInit();
    scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback);
    scifOsalRegisterTaskAlertCallback(scTaskAlertCallback);
    scifInit(&scifDriverSetup);
    scifStartRtcTicks(0x00000080, 0x00000200);
    IntMasterEnable();
    AONRTCEnable();

  • Hello Yan,
    Use the PIN (TI-RTOS) driver which is included in the BLE project to set up the GPIOs for LEDs and buttons and remove all the HWREG operations on the GPIO/IOC. Ther should be some example on how to set it up. For example check out Board_keyCallback in the SimpleBLECentral project.
  • Hi Yan,

    This code should not be used with TI RTOS as it is now.

    The following code should be replaced with PIN_init():

     PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);
        PRCMLoadSet();
        while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) != PRCM_DOMAIN_POWER_ON);
    
        // Enable the GPIO module
        PRCMPeripheralRunEnable(PRCM_PERIPH_GPIO);
        PRCMPeripheralSleepEnable(PRCM_PERIPH_GPIO);
        PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_GPIO);
        PRCMLoadSet();
        while (!PRCMLoadGet());
    
        // Setup GPIOs for LEDs and buttons
        HWREG(GPIO_BASE + GPIO_O_DOE31_0) &= ~(BV(IOID_KEY_LEFT) | BV(IOID_KEY_RIGHT) | BV(IOID_KEY_UP) | BV(IOID_KEY_DOWN));
        HWREG(GPIO_BASE + GPIO_O_DOE31_0) |= BV(IOID_LED_1) | BV(IOID_LED_2);
        HWREG(IOC_BASE + IOC_O_IOCFG(IOID_LED_1))             = IOC_STD_OUTPUT | IOC_PORT_GPIO;
        HWREG(IOC_BASE + IOC_O_IOCFG(IOID_LED_2))             = IOC_STD_OUTPUT | IOC_PORT_GPIO;
        HWREG(IOC_BASE + IOC_O_IOCFG(IOID_KEY_LEFT))          = ((IOC_STD_INPUT & ~IOC_NO_IOPULL) | IOC_IOPULL_UP) | IOC_PORT_GPIO;
        HWREG(IOC_BASE + IOC_O_IOCFG(IOID_KEY_RIGHT))         = ((IOC_STD_INPUT & ~IOC_NO_IOPULL) | IOC_IOPULL_UP) | IOC_PORT_GPIO;
        HWREG(IOC_BASE + IOC_O_IOCFG(IOID_KEY_UP))            = ((IOC_STD_INPUT & ~IOC_NO_IOPULL) | IOC_IOPULL_UP) | IOC_PORT_GPIO;
        HWREG(IOC_BASE + IOC_O_IOCFG(IOID_KEY_DOWN))          = ((IOC_STD_INPUT & ~IOC_NO_IOPULL) | IOC_IOPULL_UP) | IOC_PORT_GPIO;

    scifStartRtcTicks should ideally be scifStartRtcTicksNow since the RTC has already started.

    The following code should be removed, this is handled by TI RTOS:
    IntMasterEnable();
    AONRTCEnable();

    Regards,

    Svend

  • Thank you both Eirik & Svend,

    I have figured out how this works:)

    seems scTaskAlertCallback() is called by SCE while counter to certain numbers, very simple, not like i thought before.

    now LEDs and buttons are both working fine:)