This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/17478 ) Change subject: pio_it.c: Permit repeated calls to PIO_ConfigureIt() ...................................................................... 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 --- M firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_it.c M hardware/board_gpio.gnumeric 2 files changed, 19 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/78/17478/1 diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_it.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_it.c index 7feccd1..781b914 100644 --- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_it.c +++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_it.c @@ -211,6 +211,16 @@ 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 * change. The provided interrupt handler will be called with the triggering @@ -228,15 +238,17 @@ assert( pPin ) ; pio = pPin->pio ; - assert( _dwNumSources < MAX_INTERRUPT_SOURCES ) ; - /* Define new source */ - TRACE_DEBUG( "PIO_ConfigureIt: Defining new source #%" PRIu32 ".\n\r", _dwNumSources ) ; - - pSource = &(_aIntSources[_dwNumSources]) ; - pSource->pPin = pPin ; + pSource = find_intsource4pin(pPin); + if (!pSource) { + /* Define new source */ + TRACE_DEBUG( "PIO_ConfigureIt: Defining new source #%" PRIu32 ".\n\r", _dwNumSources ) ; + assert( _dwNumSources < MAX_INTERRUPT_SOURCES ) ; + pSource = &(_aIntSources[_dwNumSources]) ; + pSource->pPin = pPin ; + _dwNumSources++ ; + } pSource->handler = handler ; - _dwNumSources++ ; /* PIO3 with additional interrupt support * Configure additional interrupt mode registers */ diff --git a/hardware/board_gpio.gnumeric b/hardware/board_gpio.gnumeric index 1ec9ff6..0e4893d 100644 --- a/hardware/board_gpio.gnumeric +++ b/hardware/board_gpio.gnumeric Binary files differ -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/17478 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I0c46d4b51eeebd58a8786d65e31e7a84e65b6a8e Gerrit-Change-Number: 17478 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200313/978366a5/attachment.htm>