-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
The interrupt handler can be made more efficient in the NRF52TouchSensor class.
Major improvement
The innocuous looking Evt with default construction gets initialised with a timestamp using system_timer_current_time_us() which is far more heavyweight than it sounds.
From https://github.com/lancaster-university/codal-nrf52/blob/master/source/NRF52TouchSensor.cpp#L33-L39
static void touch_sense_irq(uint16_t mask)
{
if (instance) {
Event evt;
instance->onSampleEvent(evt);
}
}
This event isn't used by onSampleEvent() so could be replaced with something more efficient like.
Event unused_evt(0, 0,0, CREATE_ONLY);
instance->onSampleEvent(unused_evt);
I've tested that and it improves lancaster-university/codal-microbit-v2#475 (comment)
Minor improvement
Is this disable/enable of interrupts required?
codal-nrf52/source/NRF52TouchSensor.cpp
Lines 143 to 151 in 6a7a5bb
| // Reset the timer, and enable the pin input event, unless we're leaving a timeslot for a single channel to charge. | |
| target_disable_irq(); | |
| timer.timer->TASKS_CLEAR = 1; | |
| if (channel >= 0) | |
| NRF_GPIOTE->CONFIG[NRF52_TOUCH_SENSOR_GPIOTE_CHANNEL] = 0x00010001 | (buttons[channel]->_pin.name << 8); | |
| target_enable_irq(); |
Metadata
Metadata
Assignees
Labels
No labels