Skip to content

Commit b02af19

Browse files
theotherjimmyurutva
authored andcommitted
Build ThreadX into the MPS3-AN524 example
This is a rollup of the following changes: * Use ThreadX and threads in the example. * Build ThreadX. * Use the threadx cortex_m33.cmake build file instead of the one in this repo to avoid falling out of sync with upstream. * Update the tfm submodule reference to point to linaro/lite-azure-threadx. Signed-off-by: Jimmy Brisson <[email protected]> Signed-off-by: Kevin Townsend <[email protected]>
1 parent 7dc25fc commit b02af19

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

Arm/MPS3_AN524/app/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ add_executable(${PROJECT_NAME} ${SOURCES})
1414

1515
target_link_libraries(${PROJECT_NAME}
1616
PUBLIC
17-
# azrtos::threadx
18-
# azrtos::netxduo
17+
azrtos::threadx
1918

2019
# app_common
2120
# jsmn

Arm/MPS3_AN524/app/main.c

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,61 @@
22

33
#include <stdio.h>
44

5+
#include "tx_api.h"
6+
57
#include "board_init.h"
8+
#include "cmsis.h"
9+
10+
#define AZURE_THREAD_STACK_SIZE 4096
11+
#define AZURE_THREAD_PRIORITY 4
12+
13+
static __inline void systick_interval_set(uint32_t ticks)
14+
{
15+
// 1. Disable the counter
16+
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
17+
18+
// 2. Update the Systick timer period
19+
SysTick->LOAD = SystemCoreClock / ticks - 1;
20+
21+
// 3. Clear the current value
22+
SysTick->VAL = 0;
23+
24+
// 4. Enable the counter
25+
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
26+
}
27+
28+
TX_THREAD azure_thread;
29+
ULONG azure_thread_stack[AZURE_THREAD_STACK_SIZE / sizeof(ULONG)];
30+
31+
void azure_thread_entry(ULONG parameter);
32+
void tx_application_define(void* first_unused_memory);
33+
34+
void azure_thread_entry(ULONG parameter)
35+
{
36+
printf("\r\nStarting Azure thread\r\n\r\n");
37+
}
38+
39+
void tx_application_define(void* first_unused_memory)
40+
{
41+
systick_interval_set(TX_TIMER_TICKS_PER_SECOND);
42+
43+
// Create Azure thread
44+
UINT status = tx_thread_create(&azure_thread,
45+
"Azure Thread",
46+
azure_thread_entry,
47+
0,
48+
azure_thread_stack,
49+
AZURE_THREAD_STACK_SIZE,
50+
AZURE_THREAD_PRIORITY,
51+
AZURE_THREAD_PRIORITY,
52+
TX_NO_TIME_SLICE,
53+
TX_AUTO_START);
54+
55+
if (status != TX_SUCCESS)
56+
{
57+
printf("Azure IoT thread creation failed\r\n");
58+
}
59+
}
660

761
int main(void)
862
{
@@ -12,7 +66,7 @@ int main(void)
1266
printf("Azure RTOS running on MPS3 board\n");
1367

1468

15-
/* tx_kernel_enter(); */
69+
tx_kernel_enter();
1670

1771
return 0;
1872
}

Arm/MPS3_AN524/lib/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set(THREADX_TOOLCHAIN "gnu")
99
set(TX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/threadx/tx_user.h" CACHE STRING "Enable TX user configuration")
1010

1111
# Core libraries
12-
# add_subdirectory(${CORE_LIB_DIR}/threadx threadx)
12+
add_subdirectory(${CORE_LIB_DIR}/threadx threadx)
13+
#add_subdirectory(${CORE_LIB_DIR}/netxduo netxduo)
14+
#add_subdirectory(${CORE_LIB_DIR}/jsmn jsmn)
1315

1416
add_subdirectory(AN524)

0 commit comments

Comments
 (0)