mirror of https://github.com/ARMmbed/mbed-os.git
update definitions for us_ticker_set_interrupt() across all platforms to use timestamp_t
parent
01bc4de3ab
commit
c8f896d708
|
@ -135,8 +135,8 @@ static void ticker_isr(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
int delta = (int)(timestamp - us_ticker_read());
|
int delta = (int)((uint32_t)timestamp - us_ticker_read());
|
||||||
if (delta <= 0) {
|
if (delta <= 0) {
|
||||||
// This event was in the past:
|
// This event was in the past:
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
|
|
|
@ -167,8 +167,8 @@ static void lptmr_isr(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
int delta = (int)(timestamp - us_ticker_read());
|
int delta = (int)((uint32_t)timestamp - us_ticker_read());
|
||||||
if (delta <= 0) {
|
if (delta <= 0) {
|
||||||
// This event was in the past:
|
// This event was in the past:
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
|
|
|
@ -133,8 +133,8 @@ static void lptmr_isr(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
int delta = (int)(timestamp - us_ticker_read());
|
int delta = (int)((uint32_t)timestamp - us_ticker_read());
|
||||||
if (delta <= 0) {
|
if (delta <= 0) {
|
||||||
// This event was in the past:
|
// This event was in the past:
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
|
|
|
@ -46,9 +46,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->MR0 = timestamp;
|
US_TICKER_TIMER->MR0 = (uint32_t)timestamp;
|
||||||
// enable match interrupt
|
// enable match interrupt
|
||||||
US_TICKER_TIMER->MCR |= 1;
|
US_TICKER_TIMER->MCR |= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->MR0 = timestamp;
|
US_TICKER_TIMER->MR0 = (uint32_t)timestamp;
|
||||||
// enable match interrupt
|
// enable match interrupt
|
||||||
US_TICKER_TIMER->MCR |= 1;
|
US_TICKER_TIMER->MCR |= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->MR0 = timestamp;
|
US_TICKER_TIMER->MR0 = (uint32_t)timestamp;
|
||||||
// enable match interrupt
|
// enable match interrupt
|
||||||
US_TICKER_TIMER->MCR |= 1;
|
US_TICKER_TIMER->MCR |= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->MR0 = timestamp;
|
US_TICKER_TIMER->MR0 = (uint32_t)timestamp;
|
||||||
// enable match interrupt
|
// enable match interrupt
|
||||||
US_TICKER_TIMER->MCR |= 1;
|
US_TICKER_TIMER->MCR |= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ uint32_t us_ticker_read() {
|
||||||
return (uint32_t)temp;
|
return (uint32_t)temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
uint64_t temp = ((uint64_t)timestamp * (SystemCoreClock/1000000));
|
uint64_t temp = ((uint64_t)timestamp * (SystemCoreClock/1000000));
|
||||||
LPC_RIT->COMPVAL = (temp & 0xFFFFFFFFL);
|
LPC_RIT->COMPVAL = (temp & 0xFFFFFFFFL);
|
||||||
LPC_RIT->COMPVAL_H = ((temp >> 32)& 0x0000FFFFL);
|
LPC_RIT->COMPVAL_H = ((temp >> 32)& 0x0000FFFFL);
|
||||||
|
|
|
@ -48,9 +48,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->MR0 = timestamp;
|
US_TICKER_TIMER->MR0 = (uint32_t)timestamp;
|
||||||
// enable match interrupt
|
// enable match interrupt
|
||||||
US_TICKER_TIMER->MCR |= 1;
|
US_TICKER_TIMER->MCR |= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->MR0 = timestamp;
|
US_TICKER_TIMER->MR0 = (uint32_t)timestamp;
|
||||||
// enable match interrupt
|
// enable match interrupt
|
||||||
US_TICKER_TIMER->MCR |= 1;
|
US_TICKER_TIMER->MCR |= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->MR0 = timestamp;
|
US_TICKER_TIMER->MR0 = (uint32_t)timestamp;
|
||||||
// enable match interrupt
|
// enable match interrupt
|
||||||
US_TICKER_TIMER->MCR |= 1;
|
US_TICKER_TIMER->MCR |= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->TC;
|
return US_TICKER_TIMER->TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->MR[0] = timestamp;
|
US_TICKER_TIMER->MR[3] = (uint32_t)timestamp;
|
||||||
// enable match interrupt
|
// enable match interrupt
|
||||||
US_TICKER_TIMER->MCR |= 1;
|
US_TICKER_TIMER->MCR |= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,13 +55,13 @@ uint32_t us_ticker_read() {
|
||||||
return LPC_SCT->COUNT_U;
|
return LPC_SCT->COUNT_U;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// halt the counter:
|
// halt the counter:
|
||||||
// - setting bit 2 of the CTRL register
|
// - setting bit 2 of the CTRL register
|
||||||
LPC_SCT->CTRL_L |= (1 << 2);
|
LPC_SCT->CTRL_L |= (1 << 2);
|
||||||
|
|
||||||
// set timestamp in compare register
|
// set timestamp in compare register
|
||||||
LPC_SCT->MATCH[0].U = timestamp;
|
LPC_SCT->MATCH[0].U = (uint32_t)timestamp;
|
||||||
|
|
||||||
// unhalt the counter:
|
// unhalt the counter:
|
||||||
// - clearing bit 2 of the CTRL register
|
// - clearing bit 2 of the CTRL register
|
||||||
|
|
|
@ -90,7 +90,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
|
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
||||||
|
@ -131,8 +131,8 @@ uint32_t us_ticker_read() {
|
||||||
return counter2;
|
return counter2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
int delta = (int)(timestamp - us_ticker_read());
|
int delta = (int)((uint32_t)timestamp - us_ticker_read());
|
||||||
uint16_t cval = TIM_MST->CNT;
|
uint16_t cval = TIM_MST->CNT;
|
||||||
|
|
||||||
if (delta <= 0) { // This event was in the past
|
if (delta <= 0) { // This event was in the past
|
||||||
|
|
|
@ -92,7 +92,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
|
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
||||||
|
@ -133,8 +133,8 @@ uint32_t us_ticker_read() {
|
||||||
return counter2;
|
return counter2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
int delta = (int)(timestamp - us_ticker_read());
|
int delta = (int)((uint32_t)timestamp - us_ticker_read());
|
||||||
uint16_t cval = TIM_MST->CNT;
|
uint16_t cval = TIM_MST->CNT;
|
||||||
|
|
||||||
if (delta <= 0) { // This event was in the past
|
if (delta <= 0) { // This event was in the past
|
||||||
|
|
|
@ -48,7 +48,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
|
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
||||||
|
@ -65,9 +65,9 @@ uint32_t us_ticker_read() {
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
TIM_SetCompare1(TIM_MST, timestamp);
|
TIM_SetCompare1(TIM_MST, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
TIM_ITConfig(TIM_MST, TIM_IT_CC1, ENABLE);
|
TIM_ITConfig(TIM_MST, TIM_IT_CC1, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
|
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
||||||
|
@ -131,8 +131,8 @@ uint32_t us_ticker_read() {
|
||||||
return counter2;
|
return counter2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
int delta = (int)(timestamp - us_ticker_read());
|
int delta = (int)((uint32_t)timestamp - us_ticker_read());
|
||||||
uint16_t cval = TIM_MST->CNT;
|
uint16_t cval = TIM_MST->CNT;
|
||||||
|
|
||||||
if (delta <= 0) { // This event was in the past
|
if (delta <= 0) { // This event was in the past
|
||||||
|
|
|
@ -50,7 +50,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
@ -68,9 +68,9 @@ uint32_t us_ticker_read() {
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, timestamp);
|
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
|
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
||||||
|
@ -121,8 +121,8 @@ uint32_t us_ticker_read() {
|
||||||
return counter2;
|
return counter2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
int delta = (int)(timestamp - us_ticker_read());
|
int delta = (int)((uint32_t)timestamp - us_ticker_read());
|
||||||
uint16_t cval = TIM_MST->CNT;
|
uint16_t cval = TIM_MST->CNT;
|
||||||
|
|
||||||
if (delta <= 0) { // This event was in the past
|
if (delta <= 0) { // This event was in the past
|
||||||
|
|
|
@ -48,7 +48,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
|
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
||||||
|
@ -65,9 +65,9 @@ uint32_t us_ticker_read() {
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
TIM_SetCompare1(TIM_MST, timestamp);
|
TIM_SetCompare1(TIM_MST, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
TIM_ITConfig(TIM_MST, TIM_IT_CC1, ENABLE);
|
TIM_ITConfig(TIM_MST, TIM_IT_CC1, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ void us_ticker_init(void)
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
@ -70,10 +70,10 @@ uint32_t us_ticker_read()
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp)
|
void us_ticker_set_interrupt(timestamp_t timestamp)
|
||||||
{
|
{
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, timestamp);
|
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ uint32_t us_ticker_read() {
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, timestamp);
|
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,10 @@ uint32_t us_ticker_read()
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp)
|
void us_ticker_set_interrupt(timestamp_t timestamp)
|
||||||
{
|
{
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, timestamp);
|
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFF;
|
TimMasterHandle.Init.Period = 0xFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
HAL_TIM_Base_Init(&TimMasterHandle);
|
HAL_TIM_Base_Init(&TimMasterHandle);
|
||||||
|
@ -123,8 +123,8 @@ uint32_t us_ticker_read() {
|
||||||
return counter2;
|
return counter2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
int delta = (int)(timestamp - us_ticker_read());
|
int delta = (int)((uint32_t)timestamp - us_ticker_read());
|
||||||
uint16_t cval = TIM_MST->CNT;
|
uint16_t cval = TIM_MST->CNT;
|
||||||
|
|
||||||
if (delta <= 0) { // This event was in the past
|
if (delta <= 0) { // This event was in the past
|
||||||
|
|
|
@ -48,7 +48,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
|
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
||||||
|
@ -65,9 +65,9 @@ uint32_t us_ticker_read() {
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
TIM_SetCompare1(TIM_MST, timestamp);
|
TIM_SetCompare1(TIM_MST, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
TIM_ITConfig(TIM_MST, TIM_IT_CC1, ENABLE);
|
TIM_ITConfig(TIM_MST, TIM_IT_CC1, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||||
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
|
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM_MST, &TIM_TimeBaseStructure);
|
||||||
|
@ -65,9 +65,9 @@ uint32_t us_ticker_read() {
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
TIM_SetCompare1(TIM_MST, timestamp);
|
TIM_SetCompare1(TIM_MST, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
TIM_ITConfig(TIM_MST, TIM_IT_CC1, ENABLE);
|
TIM_ITConfig(TIM_MST, TIM_IT_CC1, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ uint32_t us_ticker_read() {
|
||||||
return TIM_MST->CNT;
|
return TIM_MST->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// Set new output compare value
|
// Set new output compare value
|
||||||
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, timestamp);
|
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp);
|
||||||
// Enable IT
|
// Enable IT
|
||||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,9 @@ uint32_t us_ticker_read() {
|
||||||
return US_TICKER_TIMER->CNT;
|
return US_TICKER_TIMER->CNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void us_ticker_set_interrupt(unsigned int timestamp) {
|
void us_ticker_set_interrupt(timestamp_t timestamp) {
|
||||||
// set match value
|
// set match value
|
||||||
US_TICKER_TIMER->CCR1 = timestamp;
|
US_TICKER_TIMER->CCR1 = (uint32_t)timestamp;
|
||||||
// enable compare interrupt
|
// enable compare interrupt
|
||||||
US_TICKER_TIMER->DIER |= TIM_DIER_CC1IE;
|
US_TICKER_TIMER->DIER |= TIM_DIER_CC1IE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue