aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32-wpan/src/wba/mac_sys_if.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-stm32-wpan/src/wba/mac_sys_if.rs')
-rw-r--r--embassy-stm32-wpan/src/wba/mac_sys_if.rs188
1 files changed, 188 insertions, 0 deletions
diff --git a/embassy-stm32-wpan/src/wba/mac_sys_if.rs b/embassy-stm32-wpan/src/wba/mac_sys_if.rs
new file mode 100644
index 000000000..273399a19
--- /dev/null
+++ b/embassy-stm32-wpan/src/wba/mac_sys_if.rs
@@ -0,0 +1,188 @@
1#![cfg(feature = "wba")]
2#![allow(non_snake_case)]
3
4//
5// /* USER CODE BEGIN Header */
6// /**
7// ******************************************************************************
8// * @file mac_sys_if.c
9// * @author MCD Application Team
10// * @brief Source file for using MAC Layer with a RTOS
11// ******************************************************************************
12// * @attention
13// *
14// * Copyright (c) 2025 STMicroelectronics.
15// * All rights reserved.
16// *
17// * This software is licensed under terms that can be found in the LICENSE file
18// * in the root directory of this software component.
19// * If no LICENSE file comes with this software, it is provided AS-IS.
20// *
21// ******************************************************************************
22// */
23// /* USER CODE END Header */
24//
25// #include "main.h"
26// #include "app_common.h"
27// #include "app_conf.h"
28// #include "log_module.h"
29// #include "stm32_rtos.h"
30// #include "st_mac_802_15_4_sys.h"
31//
32// extern void mac_baremetal_run(void);
33//
34// /* Private defines -----------------------------------------------------------*/
35// /* USER CODE BEGIN PD */
36//
37// /* USER CODE END PD */
38//
39// /* Private macros ------------------------------------------------------------*/
40// /* USER CODE BEGIN PM */
41//
42// /* USER CODE END PM */
43//
44// /* Private variables ---------------------------------------------------------*/
45// /* USER CODE BEGIN PV */
46//
47// /* USER CODE END PV */
48//
49// /* Global variables ----------------------------------------------------------*/
50// /* USER CODE BEGIN GV */
51//
52// /* USER CODE END GV */
53//
54// /* Functions Definition ------------------------------------------------------*/
55//
56// /**
57// * @brief Mac Layer Initialisation
58// * @param None
59// * @retval None
60// */
61// void MacSys_Init(void)
62// {
63// /* Register tasks */
64// UTIL_SEQ_RegTask( TASK_MAC_LAYER, UTIL_SEQ_RFU, mac_baremetal_run);
65// }
66//
67// /**
68// * @brief Mac Layer Resume
69// * @param None
70// * @retval None
71// */
72// void MacSys_Resume(void)
73// {
74// UTIL_SEQ_ResumeTask( TASK_MAC_LAYER );
75// }
76//
77// /**
78// * @brief MAC Layer set Task.
79// * @param None
80// * @retval None
81// */
82// void MacSys_SemaphoreSet(void)
83// {
84// UTIL_SEQ_SetTask( TASK_MAC_LAYER, TASK_PRIO_MAC_LAYER );
85// }
86//
87// /**
88// * @brief MAC Layer Task wait.
89// * @param None
90// * @retval None
91// */
92// void MacSys_SemaphoreWait( void )
93// {
94// /* Not used */
95// }
96//
97// /**
98// * @brief MAC Layer set Event.
99// * @param None
100// * @retval None
101// */
102// void MacSys_EventSet( void )
103// {
104// UTIL_SEQ_SetEvt( EVENT_MAC_LAYER );
105// }
106//
107// /**
108// * @brief MAC Layer wait Event.
109// * @param None
110// * @retval None
111// */
112// void MacSys_EventWait( void )
113// {
114// UTIL_SEQ_WaitEvt( EVENT_MAC_LAYER );
115// }
116//
117
118use super::util_seq;
119use crate::bindings::mac;
120
121/// Placeholder value used by the original ST middleware when registering tasks.
122const UTIL_SEQ_RFU: u32 = 0;
123
124/// Bit mask identifying the MAC layer task within the sequencer.
125const TASK_MAC_LAYER_MASK: u32 = 1 << mac::CFG_TASK_ID_T_CFG_TASK_MAC_LAYER;
126
127/// Sequencer priority assigned to the MAC layer task.
128const TASK_PRIO_MAC_LAYER: u32 = mac::CFG_SEQ_PRIO_ID_T_CFG_SEQ_PRIO_0 as u32;
129
130/// Event flag consumed by the MAC task while waiting on notifications.
131const EVENT_MAC_LAYER_MASK: u32 = 1 << 0;
132
133/// Registers the MAC bare-metal runner with the lightweight sequencer.
134///
135/// Mirrors the behaviour of the reference implementation:
136/// `UTIL_SEQ_RegTask(TASK_MAC_LAYER, UTIL_SEQ_RFU, mac_baremetal_run);`
137#[unsafe(no_mangle)]
138pub unsafe extern "C" fn MacSys_Init() {
139 util_seq::UTIL_SEQ_RegTask(TASK_MAC_LAYER_MASK, UTIL_SEQ_RFU, Some(mac::mac_baremetal_run));
140}
141
142/**
143 * @brief Mac Layer Resume
144 * @param None
145 * @retval None
146 */
147#[unsafe(no_mangle)]
148pub unsafe extern "C" fn MacSys_Resume() {
149 util_seq::UTIL_SEQ_ResumeTask(TASK_MAC_LAYER_MASK);
150}
151
152/**
153 * @brief MAC Layer set Task.
154 * @param None
155 * @retval None
156 */
157#[unsafe(no_mangle)]
158pub unsafe extern "C" fn MacSys_SemaphoreSet() {
159 util_seq::UTIL_SEQ_SetTask(TASK_MAC_LAYER_MASK, TASK_PRIO_MAC_LAYER);
160}
161
162/**
163 * @brief MAC Layer Task wait.
164 * @param None
165 * @retval None
166 */
167#[unsafe(no_mangle)]
168pub unsafe extern "C" fn MacSys_SemaphoreWait() {}
169
170/**
171 * @brief MAC Layer set Event.
172 * @param None
173 * @retval None
174 */
175#[unsafe(no_mangle)]
176pub unsafe extern "C" fn MacSys_EventSet() {
177 util_seq::UTIL_SEQ_SetEvt(EVENT_MAC_LAYER_MASK);
178}
179
180/**
181 * @brief MAC Layer wait Event.
182 * @param None
183 * @retval None
184 */
185#[unsafe(no_mangle)]
186pub unsafe extern "C" fn MacSys_EventWait() {
187 util_seq::UTIL_SEQ_WaitEvt(EVENT_MAC_LAYER_MASK);
188}