Merge pull request #8771 from jeromecoutant/PR_LPTICKER_LPTIM

STM32 LPTICKER with LPTIM optimisation
pull/8951/head
Martin Kojtal 2018-11-30 14:31:52 +01:00 committed by GitHub
commit fa858a58ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 4 deletions

View File

@ -38,6 +38,10 @@
#include "lp_ticker_api.h"
#include "mbed_error.h"
#if !defined(LPTICKER_DELAY_TICKS) || (LPTICKER_DELAY_TICKS < 3)
#warning "lpticker_delay_ticks value should be set to 3"
#endif
LPTIM_HandleTypeDef LptimHandle;
const ticker_info_t *lp_ticker_get_info()
@ -155,6 +159,12 @@ void lp_ticker_init(void)
__HAL_LPTIM_ENABLE_IT(&LptimHandle, LPTIM_IT_CMPM);
HAL_LPTIM_Counter_Start(&LptimHandle, 0xFFFF);
/* Need to write a compare value in order to get LPTIM_FLAG_CMPOK in set_interrupt */
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK);
__HAL_LPTIM_COMPARE_SET(&LptimHandle, 0);
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
}
}
static void LPTIM1_IRQHandler(void)
@ -201,12 +211,12 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
LptimHandle.Instance = LPTIM1;
irq_handler = (void (*)(void))lp_ticker_irq_handler;
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK);
__HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp);
/* CMPOK is set by hardware to inform application that the APB bus write operation to the LPTIM_CMP register has been successfully completed */
/* Any successive write before the CMPOK flag be set, will lead to unpredictable results */
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) {
}
/* LPTICKER_DELAY_TICKS value prevents OS to call this set interrupt function before CMPOK */
MBED_ASSERT(__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == SET);
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK);
__HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp);
lp_ticker_clear_interrupt();

View File

@ -2338,6 +2338,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0744"],
"device_has_add": [
"ANALOGOUT",
@ -2509,6 +2510,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0743"],
"macros_add": ["USB_STM_HAL", "USBHOST_OTHER"],
"device_has_add": [
@ -2546,6 +2548,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0743"],
"macros_add": ["USB_STM_HAL", "USBHOST_OTHER"],
"device_has_add": [
@ -2767,6 +2770,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"macros_add": ["USBHOST_OTHER"],
"supported_form_factors": ["ARDUINO"],
"detect_code": ["0816"],
@ -2813,6 +2817,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"macros_add": [
"TRANSACTION_QUEUE_SIZE_SPI=2",
"USBHOST_OTHER",
@ -2866,6 +2871,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"supported_form_factors": ["ARDUINO"],
"macros_add": ["USBHOST_OTHER"],
"detect_code": ["0818"],
@ -3034,6 +3040,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0770"],
"device_has_add": [
"ANALOGOUT",
@ -3065,6 +3072,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0779"],
"device_has_add": [
"ANALOGOUT",
@ -3125,6 +3133,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0765"],
"macros_add": ["USBHOST_OTHER", "TWO_RAM_REGIONS"],
"device_has_add": [
@ -3184,6 +3193,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0827"],
"macros_add": [
"USBHOST_OTHER",
@ -3617,6 +3627,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0815"],
"macros_add": ["USB_STM_HAL", "USBHOST_OTHER"],
"device_has_add": [
@ -3662,6 +3673,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0817"],
"macros_add": ["USB_STM_HAL", "USBHOST_OTHER"],
"device_has_add": [
@ -3696,6 +3708,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"supported_form_factors": ["ARDUINO"],
"detect_code": ["0764"],
"macros_add": ["USBHOST_OTHER", "TWO_RAM_REGIONS"],
@ -3728,6 +3741,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0820"],
"macros_add": ["USBHOST_OTHER", "TWO_RAM_REGIONS"],
"device_has_add": [
@ -7089,6 +7103,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0822"],
"device_has_add": [
"ANALOGOUT",
@ -7120,6 +7135,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0823"],
"device_has_add": [
"ANALOGOUT",
@ -7155,6 +7171,7 @@
"value": 1
}
},
"overrides": { "lpticker_delay_ticks": 3 },
"detect_code": ["0776"],
"device_has_add": [
"ANALOGOUT",