Skip to content

Commit d165348

Browse files
committed
Freescale MCUXpresso: optimize us_ticker
Provide new optimizations for us_ticker and wait_us.
1 parent c2c80f9 commit d165348

File tree

21 files changed

+332
-20
lines changed

21 files changed

+332
-20
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/us_ticker.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <stddef.h>
1717
#include "us_ticker_api.h"
18+
#include "us_ticker_defines.h"
1819
#include "PeripheralNames.h"
1920
#include "fsl_pit.h"
2021
#include "fsl_clock_config.h"
@@ -81,9 +82,9 @@ void us_ticker_init(void)
8182
*
8283
* @return The current timer's counter value in ticks
8384
*/
84-
uint32_t us_ticker_read()
85+
uint32_t (us_ticker_read)()
8586
{
86-
return ~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1));
87+
return us_ticker_read();
8788
}
8889

8990
/** Disable us ticker interrupt
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef _FSL_US_TICKER_DEFINES_H_
18+
#define _FSL_US_TICKER_DEFINES_H_
19+
20+
#include "fsl_pit.h"
21+
22+
#define US_TICKER_PERIOD_NUM 1
23+
#define US_TICKER_PERIOD_DEN 1
24+
25+
#define US_TICKER_MASK 0xFFFFFFFF
26+
27+
/* Macro-optimised form of us_ticker_read */
28+
#define us_ticker_read() (~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1)))
29+
30+
#endif /* _FSL_US_TICKER_DEFINES_H_ */

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/us_ticker.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <stddef.h>
1717
#include "us_ticker_api.h"
18+
#include "us_ticker_defines.h"
1819
#include "PeripheralNames.h"
1920
#include "fsl_pit.h"
2021
#include "fsl_clock_config.h"
@@ -81,9 +82,9 @@ void us_ticker_init(void)
8182
*
8283
* @return The current timer's counter value in ticks
8384
*/
84-
uint32_t us_ticker_read()
85+
uint32_t (us_ticker_read)()
8586
{
86-
return ~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1));
87+
return us_ticker_read();
8788
}
8889

8990
/** Disable us ticker interrupt
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef _FSL_US_TICKER_DEFINES_H_
18+
#define _FSL_US_TICKER_DEFINES_H_
19+
20+
#include "fsl_pit.h"
21+
22+
#define US_TICKER_PERIOD_NUM 1
23+
#define US_TICKER_PERIOD_DEN 1
24+
25+
#define US_TICKER_MASK 0xFFFFFFFF
26+
27+
/* Macro-optimised form of us_ticker_read */
28+
#define us_ticker_read() (~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1)))
29+
30+
#endif /* _FSL_US_TICKER_DEFINES_H_ */

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/us_ticker.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <stddef.h>
1717
#include "us_ticker_api.h"
18+
#include "us_ticker_defines.h"
1819
#include "PeripheralNames.h"
1920
#include "fsl_pit.h"
2021
#include "fsl_tpm.h"
@@ -95,9 +96,9 @@ void us_ticker_init(void)
9596
}
9697

9798

98-
uint32_t us_ticker_read()
99+
uint32_t (us_ticker_read)()
99100
{
100-
return ~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1));
101+
return us_ticker_read();
101102
}
102103

103104
void us_ticker_disable_interrupt(void)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef _FSL_US_TICKER_DEFINES_H_
18+
#define _FSL_US_TICKER_DEFINES_H_
19+
20+
#include "fsl_pit.h"
21+
22+
#define US_TICKER_PERIOD_NUM 1
23+
#define US_TICKER_PERIOD_DEN 1
24+
25+
#define US_TICKER_MASK 0xFFFFFFFF
26+
27+
/* Macro-optimised form of us_ticker_read */
28+
#define us_ticker_read() (~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1)))
29+
30+
#endif /* _FSL_US_TICKER_DEFINES_H_ */

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/us_ticker.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <stddef.h>
1717
#include "us_ticker_api.h"
18+
#include "us_ticker_defines.h"
1819
#include "PeripheralNames.h"
1920
#include "fsl_pit.h"
2021
#include "fsl_tpm.h"
@@ -95,9 +96,9 @@ void us_ticker_init(void)
9596
}
9697

9798

98-
uint32_t us_ticker_read()
99+
uint32_t (us_ticker_read)()
99100
{
100-
return ~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1));
101+
return us_ticker_read();
101102
}
102103

103104
void us_ticker_disable_interrupt(void)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef _FSL_US_TICKER_DEFINES_H_
18+
#define _FSL_US_TICKER_DEFINES_H_
19+
20+
#include "fsl_pit.h"
21+
22+
#define US_TICKER_PERIOD_NUM 1
23+
#define US_TICKER_PERIOD_DEN 1
24+
25+
#define US_TICKER_MASK 0xFFFFFFFF
26+
27+
/* Macro-optimised form of us_ticker_read */
28+
#define us_ticker_read() (~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1)))
29+
30+
#endif /* _FSL_US_TICKER_DEFINES_H_ */

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/us_ticker.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <stddef.h>
1717
#include "us_ticker_api.h"
18+
#include "us_ticker_defines.h"
1819
#include "PeripheralNames.h"
1920
#include "fsl_pit.h"
2021
#include "fsl_clock_config.h"
@@ -81,9 +82,9 @@ void us_ticker_init(void)
8182
*
8283
* @return The current timer's counter value in ticks
8384
*/
84-
uint32_t us_ticker_read()
85+
uint32_t (us_ticker_read)()
8586
{
86-
return ~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1));
87+
return us_ticker_read();
8788
}
8889

8990
/** Disable us ticker interrupt
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef _FSL_US_TICKER_DEFINES_H_
18+
#define _FSL_US_TICKER_DEFINES_H_
19+
20+
#include "fsl_pit.h"
21+
22+
#define US_TICKER_PERIOD_NUM 1
23+
#define US_TICKER_PERIOD_DEN 1
24+
25+
#define US_TICKER_MASK 0xFFFFFFFF
26+
27+
/* Macro-optimised form of us_ticker_read */
28+
#define us_ticker_read() (~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1)))
29+
30+
#endif /* _FSL_US_TICKER_DEFINES_H_ */

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/us_ticker.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <stddef.h>
1717
#include "us_ticker_api.h"
18+
#include "us_ticker_defines.h"
1819
#include "PeripheralNames.h"
1920
#include "fsl_pit.h"
2021
#include "fsl_clock_config.h"
@@ -81,9 +82,9 @@ void us_ticker_init(void)
8182
*
8283
* @return The current timer's counter value in ticks
8384
*/
84-
uint32_t us_ticker_read()
85+
uint32_t (us_ticker_read)()
8586
{
86-
return ~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1));
87+
return us_ticker_read();
8788
}
8889

8990
/** Disable us ticker interrupt
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef _FSL_US_TICKER_DEFINES_H_
18+
#define _FSL_US_TICKER_DEFINES_H_
19+
20+
#include "fsl_pit.h"
21+
22+
#define US_TICKER_PERIOD_NUM 1
23+
#define US_TICKER_PERIOD_DEN 1
24+
25+
#define US_TICKER_MASK 0xFFFFFFFF
26+
27+
/* Macro-optimised form of us_ticker_read */
28+
#define us_ticker_read() (~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1)))
29+
30+
#endif /* _FSL_US_TICKER_DEFINES_H_ */

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/us_ticker.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <stddef.h>
1717
#include "us_ticker_api.h"
18+
#include "us_ticker_defines.h"
1819
#include "PeripheralNames.h"
1920
#include "fsl_pit.h"
2021
#include "fsl_tpm.h"
@@ -95,9 +96,9 @@ void us_ticker_init(void)
9596
}
9697

9798

98-
uint32_t us_ticker_read()
99+
uint32_t (us_ticker_read)()
99100
{
100-
return ~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1));
101+
return us_ticker_read();
101102
}
102103

103104
void us_ticker_disable_interrupt(void)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef _FSL_US_TICKER_DEFINES_H_
18+
#define _FSL_US_TICKER_DEFINES_H_
19+
20+
#include "fsl_pit.h"
21+
22+
#define US_TICKER_PERIOD_NUM 1
23+
#define US_TICKER_PERIOD_DEN 1
24+
25+
#define US_TICKER_MASK 0xFFFFFFFF
26+
27+
/* Macro-optimised form of us_ticker_read */
28+
#define us_ticker_read() (~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1)))
29+
30+
#endif /* _FSL_US_TICKER_DEFINES_H_ */

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/us_ticker.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include <stddef.h>
1717
#include "us_ticker_api.h"
18+
#include "us_ticker_defines.h"
1819
#include "PeripheralNames.h"
1920
#include "fsl_pit.h"
2021
#include "fsl_clock_config.h"
@@ -81,9 +82,9 @@ void us_ticker_init(void)
8182
*
8283
* @return The current timer's counter value in ticks
8384
*/
84-
uint32_t us_ticker_read()
85+
uint32_t (us_ticker_read)()
8586
{
86-
return ~(PIT_GetCurrentTimerCount(PIT, kPIT_Chnl_1));
87+
return us_ticker_read();
8788
}
8889

8990
/** Disable us ticker interrupt

0 commit comments

Comments
 (0)