Hi .
SDK0806
1. When only # define GPIO_ BANK1
has 2 GPIOs that can generate independent interrupts.
2 .When only # define GPIO0_ 2_5
GPIO0_2 GPIO2_5 can generate independent interrupts.
3 .When only #define GPIO0_49_50
gpio0_ 49 gpio0_ 50 can generate independent interrupts.
4. When
#define GPIO0_49_50
#define GPIO0_2_5
#define GPIO_BANK1
only has GPIO0_ 49 GPIO0_ 50 can generate independent interrupts
#include <utils/console_io/include/app_log.h> #include <ti/csl/arch/csl_arch.h> #include <ti/csl/soc.h> #include <ti/csl/cslr.h> #include <ti/osal/osal.h> #include <ti/osal/TaskP.h> #include <ti/board/src/j721s2_evm/include/board_internal.h> #include <ti/board/src/j721s2_evm/J721S2_pinmux.h> #include <string.h> #include <ti/csl/csl_utils.h> #include <ti/csl/soc/j721s2/src/cslr_soc.h> #include <ti/csl/csl_types.h> #include <ti/csl/hw_types.h> #include <ti/csl/soc.h> #include <ti/csl/arch/csl_arch.h> #include <ti/drv/gpio/soc/GPIO_soc.h> #include <ti/drv/sciclient/sciclient.h> #include <ti/csl/csl_clec.h> typedef unsigned int uintptr_t; typedef unsigned int uint32; //#define GPIO_PIN_NUM 2 //49 //GPIO0_51 //#define GPIO_PIN_NUM 51 //GPIO0_51 #define GPIO_17_PIN_NUM 17 //GPIO0_17 #define GPIO_23_PIN_NUM 23 //GPIO0_23 #define GPIO_19_PIN_NUM 19 //GPIO0_19 #define GPIO_50_PIN_NUM 50 //GPIO0_50 #define GPIO_5_PIN_NUM 5 //GPIO0_5 #define GPIO_26_PIN_NUM 26 //GPIO0_26 #define GPIO_24_PIN_NUM 24 //GPIO0_24 #define GPIO_49_PIN_NUM 49 //GPIO0_28 #define GPIO_28_PIN_NUM 28 //GPIO0_28 #define GPIO_30_PIN_NUM 30 //GPIO0_30 #define GPIO_31_PIN_NUM 31 //GPIO0_31 #define GPIO_2_PIN_NUM 2 //GPIO0_2 //uint32_t INTR_OFFSET = 8u; uint32_t INTR_OFFSET = 0u; //#define GPIOMUX_INTRTR0_OUTP_START_R5FSS0 (16u + INTR_OFFSET) #define GPIOMUX_INTRTR0_OUTP_START_R5FSS0 (16 + INTR_OFFSET) #define GPIO_START (37) #define GPIO0_2_5 #define GPIO_BANK1 #define GPIO0_49_50 #ifdef GPIO_BANK1 #define APP_NUM_CH 2 #endif #ifdef GPIO0_2_5 #define APP_NUM_CH 2 #endif #ifdef GPIO0_49_50 #define APP_NUM_CH 2 #endif #if defined(GPIO_BANK1) && defined(GPIO0_2_5) #define APP_NUM_CH 4 #endif #if defined(GPIO_BANK1) && defined(GPIO0_49_50) #define APP_NUM_CH 4 #endif #if defined(GPIO0_2_5) && defined(GPIO0_49_50) #define APP_NUM_CH 4 #endif #if defined(GPIO_BANK1) && defined(GPIO0_2_5) && defined(GPIO0_49_50) #define APP_NUM_CH 6 #endif #define FLS_I 2 #define RLC_I 5 #define RRS_I 17 // // GPIO0_17 #define RRM_I 19 // #define FRC_I 49 #define RLM_I 50 static volatile uint32_t gIntAggrLeviEvtId[16] = { 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131}; static uint8_t gpio_input[APP_NUM_CH] = { #ifdef GPIO0_2_5 FLS_I, RLC_I, #endif #ifdef GPIO_BANK1 RRS_I, RRM_I, #endif #ifdef GPIO0_49_50 FRC_I, RLM_I, #endif }; void gpio_callback_isr_2(uintptr_t arg) { appLogPrintf(" interrupt...GPIO_PIN_NUM %d\n",GPIO_2_PIN_NUM); } void gpio_callback_isr_5(uintptr_t arg) { appLogPrintf(" interrupt...GPIO_PIN_NUM %d\n",GPIO_5_PIN_NUM); } void gpio_callback_isr_17(uintptr_t arg) { appLogPrintf(" interrupt...GPIO_PIN_NUM %d\n",GPIO_17_PIN_NUM); } void gpio_callback_isr_19(uintptr_t arg) { appLogPrintf(" interrupt...GPIO_PIN_NUM %d\n",GPIO_19_PIN_NUM); } void gpio_callback_isr_49(uintptr_t arg) { appLogPrintf(" interrupt...GPIO_PIN_NUM %d\n",GPIO_49_PIN_NUM); } void gpio_callback_isr_50(uintptr_t arg) { appLogPrintf(" interrupt...GPIO_PIN_NUM %d\n",GPIO_50_PIN_NUM); } static void gpio_pinmux(void) { uint32 regVal = 0U; /* Pinmux for GPIO0_51 */ // regVal = (PIN_MODE(7U) | ((PIN_PULL_DISABLE) & (~PIN_PULL_DIRECTION & PIN_INPUT_ENABLE))); regVal = 0x50007; HW_WR_REG32(0x11c008, regVal); //AC24 gpio0—2 HW_WR_REG32(0x11c014, regVal); //AD25 gpio0—5 HW_WR_REG32(0x11c044, regVal); //Y26 gpio0—17 HW_WR_REG32(0x11c04c, regVal); //V26 gpio0—19 HW_WR_REG32(0x11c0C4, regVal); //AB26 gpio0—49 HW_WR_REG32(0x11c0C8, regVal); //AD28 gpio0—50 } static void initGpioisIntrrput(uint32_t gpio_id) { uint32_t chIdx, bitpos, bank_id; bitpos = gpio_id % 32; bank_id = gpio_id / 16; // *(volatile uint32_t *)0x00600044 = (1u << bitpos); // *(volatile uint32_t *)0x00600038 &= ~(1u << bitpos); if(bank_id<2) { *(volatile uint32_t *)0x00600024 = (1u << bitpos); // Writing 1 clears rising edge detection for GPIO bank 3 or 2 bits *(volatile uint32_t *)0x0060002c = (1u << bitpos); // Writing 1 enables falling edge detection for for GPIO bank 3 or 2 bits *(volatile uint32_t *)0x00600034 = (1u << bitpos); // *(volatile uint32_t *)0x00600044 = (1u << bitpos); // *(volatile uint32_t *)0x00600038 &= ~(1u << bitpos); *(volatile uint32_t *)0x00600008 = (1u << bank_id); } else { *(volatile uint32_t *)0x0060004C = (1u << bitpos); // Writing 1 clears rising edge detection for GPIO bank 3 or 2 bits *(volatile uint32_t *)0x00600054 = (1u << bitpos); // Writing 1 enables falling edge detection for for GPIO bank 3 or 2 bits *(volatile uint32_t *)0x0060005C = (1u << bitpos); // *(volatile uint32_t *)0x00600044 = (1u << bitpos); // *(volatile uint32_t *)0x00600038 &= ~(1u << bitpos); *(volatile uint32_t *)0x00600008 = (1u << bank_id); // *(volatile uint32_t *)0x0060004C = (1u << bitpos); // *(volatile uint32_t *)0x00600054 = (1u << bitpos); } } static void App_setupGpioMuxIr() { int32_t status; uint32_t chIdx; struct tisci_msg_rm_irq_set_req rmIrqReq; struct tisci_msg_rm_irq_set_resp rmIrqResp; //int32_t i; memset(&rmIrqReq, 0x0, sizeof(rmIrqReq)); memset(&rmIrqResp, 0x0, sizeof(rmIrqResp)); rmIrqReq.valid_params = 0U; rmIrqReq.global_event = 0U; rmIrqReq.src_id = 0U; rmIrqReq.src_index = 0U; rmIrqReq.dst_id = 0U; rmIrqReq.dst_host_irq = 0U; rmIrqReq.ia_id = 0U; rmIrqReq.vint = 0U; rmIrqReq.vint_status_bit_index = 0U; rmIrqReq.secondary_host = TISCI_MSG_VALUE_RM_UNUSED_SECONDARY_HOST; rmIrqReq.secondary_host = TISCI_MSG_VALUE_RM_UNUSED_SECONDARY_HOST; for(chIdx = 0U; chIdx < APP_NUM_CH; chIdx++) { rmIrqReq.src_id = TISCI_DEV_GPIOMUX_INTRTR0; //rmIrqReq.src_index = GPIO_START + chIdx; rmIrqReq.src_index = gpio_input[chIdx]; /* Set the destination based on the core */ rmIrqReq.dst_id = TISCI_DEV_GPIOMUX_INTRTR0; rmIrqReq.dst_host_irq = GPIOMUX_INTRTR0_OUTP_START_R5FSS0 + chIdx; /* Set the destination interrupt */ rmIrqReq.valid_params |= TISCI_MSG_VALUE_RM_DST_ID_VALID; rmIrqReq.valid_params |= TISCI_MSG_VALUE_RM_DST_HOST_IRQ_VALID; appLogPrintf("gpio_int [%s:%d] src_id=%d\n",__func__, __LINE__,rmIrqReq.src_id); appLogPrintf("gpio_int [%s:%d] src_index=%d\n",__func__, __LINE__,rmIrqReq.src_index); appLogPrintf("gpio_int [%s:%d] dst_id=%d\n",__func__, __LINE__,rmIrqReq.dst_id); appLogPrintf("dst_host_irq=%d \n", rmIrqReq.dst_host_irq); status = Sciclient_rmIrqSetRaw( (const struct tisci_msg_rm_irq_set_req *)&rmIrqReq, &rmIrqResp, SCICLIENT_SERVICE_WAIT_FOREVER); if(status == CSL_PASS) { appLogPrintf ("Sciclient_rmIrqSetRaw Worked fine \n"); } else { appLogPrintf("Sciclient_rmIrqSetRaw Failed :%d\n", status); } } } void register_isr_fun(int intNum,Osal_IsrRoutine routine) { OsalRegisterIntrParams_t intrPrms; HwiP_Handle hwiHandle; OsalInterruptRetCode_e osalRetVal; Osal_RegisterInterrupt_initParams(&intrPrms); intrPrms.corepacConfig.arg = (uintptr_t)NULL; intrPrms.corepacConfig.isrRoutine = routine; intrPrms.corepacConfig.priority = 1U; intrPrms.corepacConfig.corepacEventNum = 0U; /* NOT USED ? */ intrPrms.corepacConfig.intVecNum = intNum; osalRetVal = Osal_RegisterInterrupt(&intrPrms, &hwiHandle); appLogPrintf("[%s:%d] Osal_RegisterInterrupt intNum=%d osalRetVal=%d\n",__func__, __LINE__,intNum,osalRetVal); if(OSAL_INT_SUCCESS != osalRetVal) { appLogPrintf ("Osal_RegisterInterrupt fail \n"); }else{ appLogPrintf ("Osal_RegisterInterrupt fine \n"); } } void initAllGpioisIntrrput(void) { #ifdef GPIO0_2_5 initGpioisIntrrput(GPIO_5_PIN_NUM); initGpioisIntrrput(GPIO_2_PIN_NUM); #endif #ifdef GPIO_BANK1 initGpioisIntrrput(GPIO_17_PIN_NUM); initGpioisIntrrput(GPIO_19_PIN_NUM); #endif #ifdef GPIO0_49_50 initGpioisIntrrput(GPIO_49_PIN_NUM); initGpioisIntrrput(GPIO_50_PIN_NUM); #endif } void mcu30test_gpio_interrupt(void) { // int32_t i = 0; gpio_pinmux(); initAllGpioisIntrrput(); App_setupGpioMuxIr(); #if defined(GPIO_BANK1) && defined(GPIO0_2_5) && defined(GPIO0_49_50) appLogPrintf ("GPIO0_2_5 17 19 49 50 \n"); register_isr_fun(176,&gpio_callback_isr_2); register_isr_fun(177,&gpio_callback_isr_5); register_isr_fun(178,&gpio_callback_isr_17); register_isr_fun(179,&gpio_callback_isr_19); register_isr_fun(180,&gpio_callback_isr_49); register_isr_fun(181,&gpio_callback_isr_50); #elif defined(GPIO0_2_5) register_isr_fun(176,&gpio_callback_isr_2); register_isr_fun(177,&gpio_callback_isr_5); #elif defined(GPIO_BANK1) appLogPrintf ("GPIO0_17 19 \n"); register_isr_fun(176,&gpio_callback_isr_17); register_isr_fun(177,&gpio_callback_isr_19); #elif defined(GPIO0_49_50) appLogPrintf ("GPIO0_49_50 \n"); register_isr_fun(176,&gpio_callback_isr_49); register_isr_fun(177,&gpio_callback_isr_50); #endif }