Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
tz-radio.h
1
/*
2
* Copyright (c) 2026, RISE Research Institutes of Sweden
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
*
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
*
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
*
16
* 3. Neither the name of the copyright holder nor the names of its
17
* contributors may be used to endorse or promote products derived
18
* from this software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31
* OF THE POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34
/*
35
* \file
36
* TrustZone radio API for secure radio access from the normal world.
37
* \author
38
* Nicolas Tsiftes <nicolas.tsiftes@ri.se>
39
*/
40
41
#ifndef TZ_RADIO_H_
42
#define TZ_RADIO_H_
43
44
#include "
dev/radio.h
"
45
#include "trustzone/tz-api.h"
46
47
#include <stdbool.h>
48
#include <stddef.h>
49
#include <stdint.h>
50
51
/**
52
* \brief Initialize the radio via the secure world.
53
* \return 1 on success, 0 on failure.
54
*/
55
int
tz_radio_init(
void
);
56
57
/**
58
* \brief Prepare a frame for transmission.
59
* \param payload Pointer to the frame data.
60
* \param payload_len Length of the frame data.
61
* \return 0 on success, non-zero on failure.
62
*/
63
int
tz_radio_prepare(
const
void
*payload,
unsigned
short
payload_len);
64
65
/**
66
* \brief Transmit the previously prepared frame.
67
* \param transmit_len Length of the frame to transmit.
68
* \return RADIO_TX_OK on success, or a RADIO_TX_* error code.
69
*/
70
int
tz_radio_transmit(
unsigned
short
transmit_len);
71
72
/**
73
* \brief Prepare and transmit a frame in one operation.
74
* \param payload Pointer to the frame data.
75
* \param payload_len Length of the frame data.
76
* \return RADIO_TX_OK on success, or a RADIO_TX_* error code.
77
*/
78
int
tz_radio_send(
const
void
*payload,
unsigned
short
payload_len);
79
80
/**
81
* \brief Read a received frame from the secure world.
82
* \param buf Buffer to copy the frame into.
83
* \param buf_len Maximum number of bytes to read.
84
* \return Number of bytes read, or 0 if no frame available.
85
*/
86
int
tz_radio_read(
void
*buf,
unsigned
short
buf_len);
87
88
/**
89
* \brief Perform Clear Channel Assessment.
90
* \return 1 if channel is clear, 0 otherwise.
91
*/
92
int
tz_radio_channel_clear(
void
);
93
94
/**
95
* \brief Check whether the radio is currently receiving a frame.
96
* \return 1 if receiving, 0 otherwise.
97
*/
98
int
tz_radio_receiving_packet(
void
);
99
100
/**
101
* \brief Check whether a received frame is pending.
102
* \return 1 if a frame is pending, 0 otherwise.
103
*/
104
int
tz_radio_pending_packet(
void
);
105
106
/**
107
* \brief Turn the radio on.
108
* \return 1 on success, 0 on failure.
109
*/
110
int
tz_radio_on(
void
);
111
112
/**
113
* \brief Turn the radio off.
114
* \return 1 on success, 0 on failure.
115
*/
116
int
tz_radio_off(
void
);
117
118
/**
119
* \brief Get a radio parameter value.
120
* \param param The parameter to get.
121
* \param value Pointer to store the value.
122
* \return RADIO_RESULT_OK on success, or a radio_result_t error.
123
*/
124
radio_result_t
tz_radio_get_value(radio_param_t param,
radio_value_t
*
value
);
125
126
/**
127
* \brief Set a radio parameter value.
128
* \param param The parameter to set.
129
* \param value The value to set.
130
* \return RADIO_RESULT_OK on success, or a radio_result_t error.
131
*/
132
radio_result_t
tz_radio_set_value(radio_param_t param,
radio_value_t
value
);
133
134
/**
135
* \brief Get a radio parameter object.
136
* \param param The parameter to get.
137
* \param dest Buffer to store the object.
138
* \param size Size of the buffer.
139
* \return RADIO_RESULT_OK on success, or a radio_result_t error.
140
*/
141
radio_result_t
tz_radio_get_object(radio_param_t param,
142
void
*dest,
size_t
size);
143
144
/**
145
* \brief Set a radio parameter object.
146
* \param param The parameter to set.
147
* \param src Pointer to the object data.
148
* \param size Size of the object data.
149
* \return RADIO_RESULT_OK on success, or a radio_result_t error.
150
*/
151
radio_result_t
tz_radio_set_object(radio_param_t param,
152
const
void
*src,
size_t
size);
153
154
/**
155
* \brief Get RSSI and LQI for the last received frame.
156
* \param rssi Pointer to store the RSSI value.
157
* \param lqi Pointer to store the LQI value.
158
* \return true on success, false on failure.
159
*/
160
bool
tz_radio_get_rx_attributes(int8_t *rssi, uint8_t *lqi);
161
162
/**
163
* Callback type for requesting a poll from the normal world
164
* when the secure world has received a radio frame.
165
*/
166
typedef
bool (*tz_radio_ns_rx_callback_t)(void)
167
#ifdef TRUSTZONE_SECURE
168
CC_TRUSTZONE_NONSECURE_CALL
169
#endif
170
;
171
172
/**
173
* \brief Register a normal-world callback for RX notification.
174
* \param callback Function pointer in the normal world to call
175
* when a frame is received.
176
* \return true on success, false on failure.
177
*/
178
bool
tz_radio_register_rx_callback(tz_radio_ns_rx_callback_t callback);
179
180
/**
181
* \brief Read the FICR device ID from the secure world.
182
*
183
* The nRF5340 FICR is only accessible from the secure
184
* world. The normal world calls this NSC function to
185
* obtain the unique device address for the link layer.
186
*
187
* \param id0 Pointer to store FICR DEVICEID[0].
188
* \param id1 Pointer to store FICR DEVICEID[1].
189
* \return true on success, false on failure.
190
*/
191
bool
tz_radio_get_device_id(uint32_t *id0, uint32_t *id1);
192
193
#ifdef TRUSTZONE_SECURE
194
195
/**
196
* \brief Notify the normal world that a frame has been received.
197
*
198
* Called from the secure world's ipc_radio_process when
199
* a frame is pulled from shared memory.
200
*
201
* \param rssi RSSI of the received frame.
202
* \param lqi LQI of the received frame.
203
*/
204
void
tz_radio_notify_rx(int8_t rssi, uint8_t lqi);
205
206
#endif
/* TRUSTZONE_SECURE */
207
208
/**
209
* The normal-world radio driver proxy.
210
*/
211
extern
const
struct
radio_driver
tz_radio_driver;
212
213
#endif
/* TZ_RADIO_H_ */
value
static int value(int type)
Definition
cc2538-temp-sensor.c:49
radio_result_t
enum radio_result_e radio_result_t
Radio return values when setting or getting radio parameters.
radio_value_t
int radio_value_t
Each radio has a set of parameters that designate the current configuration and state of the radio.
Definition
radio.h:88
radio.h
Header file for the radio API.
radio_driver
The structure of a Contiki-NG radio device driver.
Definition
radio.h:534
arch
cpu
arm
cortex-m
trustzone
tz-radio.h
Generated on
for Contiki-NG by
1.17.0