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.

gpio map tms320c6678

Hi, I do not understand how the mechanism map. I'm trying to make map gpio interrupt. But nothing works. where to get the numbers host interrupt and how to select the channel number?Help please.

GPIO8 connected to the FPGA, which generates an interrupt

CSL_IntcEventHandlerRecord  EvtHdlrRecord[2];
CSL_IntcObj                 IntcObj;
CSL_IntcHandle              IntcHnd;
CSL_IntcContext             IntcContext;
CSL_CPINTC_Handle           hnd;

#define INTC_OUTPUT 82

int conter=0;

static void GPIO_Isr(void* handle)
{
        Uint32  rawStatus;
        Uint32  sysIntr = 0;

        CSL_CPINTC_getRawInterruptStatus(hnd, 0, &rawStatus);
        if (rawStatus != 0)
        {
            while (rawStatus != 0)
            {
                if (rawStatus & 0x1)
                {    
                    printf("int!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
                    conter++;
                    CSL_CPINTC_clearSysInterrupt(hnd, sysIntr);                
                }
                rawStatus = rawStatus >> 1;
            }
        }
}


/*****************************************************************************
 * Настраиваем INTC в CorePac.
 ****************************************************************************/
static int InitCoreIntc (void)
{
  CSL_IntcGlobalEnableState   state;

  /* INTC инициализация */
  IntcContext.eventhandlerRecord = EvtHdlrRecord;
  IntcContext.numEvtEntries      = 2;
  if (CSL_intcInit (&IntcContext) != CSL_SOK)
    return -1;

  /*Включаем NMIs */
  if (CSL_intcGlobalNmiEnable () != CSL_SOK)
    return -1;

  /*Включаем глобальные прерывания */
  if (CSL_intcGlobalEnable (&state) != CSL_SOK)
    return -1;

  printf("INTC has been initialized successfully.\n");
  return 0;
}

/*****************************************************************************
 * Настраиваем INTC в chip level
 ****************************************************************************/
static int InitChipIntc (void)
{
  CSL_CPINTC_Handle hnd;

  hnd = CSL_CPINTC_open (CSL_CP_INTC_2);
  if (!hnd)
  {
    return -1;
  }
  /* Отключим host interrupts. */
  CSL_CPINTC_disableAllHostInterrupt(hnd);

  /* Configure no nesting support in the CPINTC Module. */
  CSL_CPINTC_setNestingMode (hnd, CPINTC_NO_NESTING);

  /* Очищаем CSL_INTC2_GPINT8 в INTC2*/
  CSL_CPINTC_clearSysInterrupt (hnd, CSL_INTC2_GPINT8);
  /*Включаем */
  CSL_CPINTC_enableSysInterrupt (hnd, CSL_INTC2_GPINT8);
  CSL_CPINTC_mapSystemIntrToChannel (hnd, CSL_INTC2_GPINT8, CSL_GEM_GPINT8);

  /* Enable it */
  CSL_CPINTC_enableHostInterrupt (hnd, CSL_GEM_GPINT8);

  CSL_CPINTC_enableAllHostInterrupt(hnd);

  return 0;
}

/*****************************************************************************
 * Install the interrupt service routine
 ****************************************************************************/
int InitVec()
{
  CSL_IntcParam vectId = CSL_INTC_VECTID_4;
  Int16         eventId = CSL_GEM_GPINT8;

   IntcHnd = CSL_intcOpen (&IntcObj, eventId, &vectId, NULL);
  if (! IntcHnd)
  {
    return 0;
  }

  EvtHdlrRecord[0].handler = &GPIO_Isr;
  EvtHdlrRecord[0].arg     = 0;
  CSL_intcPlugEventHandler(IntcHnd, EvtHdlrRecord);
  CSL_intcHwControl(IntcHnd, CSL_INTC_CMD_EVTCLEAR, NULL);
  CSL_intcHwControl(IntcHnd, CSL_INTC_CMD_EVTENABLE, NULL);
  return 0;
}

void main ()
{
     /* устанавливаем настройки контроллера прерывания INTC для ядра*/
     if (InitCoreIntc())
     {
       printf ("Failed to set up CorePac INTC\n");
     }

     /* Подключаем common interrupt к CorePac event */
     if (InitChipIntc())
     {
       printf ("Failed to set up Chip INTC\n");
     }

     /* Connect the CorePac event to a vector */
     if (InitVec())
     {
       printf ("Failed to set up interrupt vector\n");
     }
    while(1);
}