mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
pio_it.c: Permit repeated calls to PIO_ConfigureIt()
The original code assumes that calls to PIO_ConfigureIt() are only made once e.g. during board start-up. Hoewever, we call those at USB SetConfiguration time, when we know which particular hardware function we are supposed to perform. This means that after the host has issued SetConfiguration more than a given number of times, the code will assert() due to overflow of the static array. Let's check if we already have allocated an array slot for a given pin and reuse that allocated array bucket rather than allocating new ones for the same pin. Change-Id: I0c46d4b51eeebd58a8786d65e31e7a84e65b6a8e Related: OS#4454
This commit is contained in:
@@ -211,6 +211,16 @@ extern void PIO_InitializeInterrupts( uint32_t dwPriority )
|
|||||||
NVIC_EnableIRQ( PIOC_IRQn ) ;
|
NVIC_EnableIRQ( PIOC_IRQn ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static InterruptSource *find_intsource4pin(const Pin *pPin)
|
||||||
|
{
|
||||||
|
unsigned int i ;
|
||||||
|
for (i = 0; i < _dwNumSources; i++) {
|
||||||
|
if (_aIntSources[i].pPin == pPin)
|
||||||
|
return &_aIntSources[i];
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures a PIO or a group of PIO to generate an interrupt on status
|
* Configures a PIO or a group of PIO to generate an interrupt on status
|
||||||
* change. The provided interrupt handler will be called with the triggering
|
* change. The provided interrupt handler will be called with the triggering
|
||||||
@@ -228,15 +238,17 @@ extern void PIO_ConfigureIt( const Pin *pPin, void (*handler)( const Pin* ) )
|
|||||||
|
|
||||||
assert( pPin ) ;
|
assert( pPin ) ;
|
||||||
pio = pPin->pio ;
|
pio = pPin->pio ;
|
||||||
assert( _dwNumSources < MAX_INTERRUPT_SOURCES ) ;
|
|
||||||
|
|
||||||
/* Define new source */
|
pSource = find_intsource4pin(pPin);
|
||||||
TRACE_DEBUG( "PIO_ConfigureIt: Defining new source #%" PRIu32 ".\n\r", _dwNumSources ) ;
|
if (!pSource) {
|
||||||
|
/* Define new source */
|
||||||
pSource = &(_aIntSources[_dwNumSources]) ;
|
TRACE_DEBUG( "PIO_ConfigureIt: Defining new source #%" PRIu32 ".\n\r", _dwNumSources ) ;
|
||||||
pSource->pPin = pPin ;
|
assert( _dwNumSources < MAX_INTERRUPT_SOURCES ) ;
|
||||||
|
pSource = &(_aIntSources[_dwNumSources]) ;
|
||||||
|
pSource->pPin = pPin ;
|
||||||
|
_dwNumSources++ ;
|
||||||
|
}
|
||||||
pSource->handler = handler ;
|
pSource->handler = handler ;
|
||||||
_dwNumSources++ ;
|
|
||||||
|
|
||||||
/* PIO3 with additional interrupt support
|
/* PIO3 with additional interrupt support
|
||||||
* Configure additional interrupt mode registers */
|
* Configure additional interrupt mode registers */
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user