Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
stmesp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_MISC_CORESIGHT_STMESP_H_
8#define ZEPHYR_INCLUDE_DRIVERS_MISC_CORESIGHT_STMESP_H_
9
10#include <zephyr/devicetree.h>
11
19#ifdef __cplusplus
20extern "C" {
21#endif
22
26typedef struct {
27 volatile uint32_t G_DMTS[2];
28 volatile uint32_t G_DM[2];
29 volatile uint32_t G_DTS[2];
30 volatile uint32_t G_D[2];
31 volatile uint32_t RESERVED0[16];
32 volatile uint32_t G_FLAGTS[2];
33 volatile uint32_t G_FLAG[2];
34 volatile uint32_t G_TRIGTS[2];
35 volatile uint32_t G_TRIG[2];
36 volatile uint32_t I_DMTS[2];
37 volatile uint32_t I_DM[2];
38 volatile uint32_t I_DTS[2];
39 volatile uint32_t I_D[2];
40 volatile uint32_t RESERVED1[16];
41 volatile uint32_t I_FLAGTS[2];
42 volatile uint32_t I_FLAG[2];
43 volatile uint32_t I_TRIGTS[2];
44 volatile uint32_t I_TRIG[2];
45} STMESP_Type;
46
56static inline volatile void *_stmesp_get_data_reg(STMESP_Type *reg, bool ts,
57 bool marked, bool guaranteed)
58{
59 if (ts) {
60 if (guaranteed) {
61 if (marked) {
62 return &reg->G_DMTS[0];
63 } else {
64 return &reg->G_DTS[0];
65 }
66 } else {
67 if (marked) {
68 return &reg->I_DMTS[0];
69 } else {
70 return &reg->I_DTS[0];
71 }
72 }
73 } else {
74 if (guaranteed) {
75 if (marked) {
76 return &reg->G_DM[0];
77 } else {
78 return &reg->G_D[0];
79 }
80 } else {
81 if (marked) {
82 return &reg->I_DM[0];
83 } else {
84 return &reg->I_D[0];
85 }
86 }
87 }
88}
89
99static inline void stmesp_flag(STMESP_Type *reg, uint32_t data, bool ts, bool guaranteed)
100{
101 if (ts) {
102 if (guaranteed) {
103 reg->G_FLAGTS[0] = data;
104 } else {
105 reg->I_FLAGTS[0] = data;
106 }
107 } else {
108 if (guaranteed) {
109 reg->G_FLAG[0] = data;
110 } else {
111 reg->I_FLAG[0] = data;
112 }
113 }
114}
115
124static inline void stmesp_data8(STMESP_Type *reg, uint8_t data, bool ts,
125 bool marked, bool guaranteed)
126{
127 *(volatile uint8_t *)_stmesp_get_data_reg(reg, ts, marked, guaranteed) = data;
128}
129
138static inline void stmesp_data16(STMESP_Type *reg, uint16_t data, bool ts,
139 bool marked, bool guaranteed)
140{
141 *(volatile uint16_t *)_stmesp_get_data_reg(reg, ts, marked, guaranteed) = data;
142}
143
152static inline void stmesp_data32(STMESP_Type *reg, uint32_t data, bool ts,
153 bool marked, bool guaranteed)
154{
155 *(volatile uint32_t *)_stmesp_get_data_reg(reg, ts, marked, guaranteed) = data;
156}
157
169static inline int stmesp_get_port(uint32_t idx, STMESP_Type **port)
170
171{
172 /* Check if index is within STM ports */
173 if ((port == NULL) ||
174 (idx >= (DT_REG_SIZE(DT_NODELABEL(stmesp)) / sizeof(STMESP_Type)))) {
175 return -EINVAL;
176 }
177
178 STMESP_Type *const base = (STMESP_Type *const)DT_REG_ADDR(DT_NODELABEL(stmesp));
179
180 *port = &base[idx];
181
182 return 0;
183}
184
185#ifdef __cplusplus
186}
187#endif
188
193#endif /* ZEPHYR_INCLUDE_DRIVERS_MISC_CORESIGHT_STMESP_H_ */
Devicetree main header.
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition: devicetree.h:200
#define DT_REG_ADDR(node_id)
Get a node's (only) register block address.
Definition: devicetree.h:2235
#define DT_REG_SIZE(node_id)
Get a node's (only) register block size.
Definition: devicetree.h:2256
static void stmesp_flag(STMESP_Type *reg, uint32_t data, bool ts, bool guaranteed)
Write flag to STMESP.
Definition: stmesp.h:99
static int stmesp_get_port(uint32_t idx, STMESP_Type **port)
Return address of a STM extended stimulus port.
Definition: stmesp.h:169
static void stmesp_data8(STMESP_Type *reg, uint8_t data, bool ts, bool marked, bool guaranteed)
Write 8 bit data to STMESP.
Definition: stmesp.h:124
static void stmesp_data32(STMESP_Type *reg, uint32_t data, bool ts, bool marked, bool guaranteed)
Write 32 bit data to STMESP.
Definition: stmesp.h:152
static void stmesp_data16(STMESP_Type *reg, uint16_t data, bool ts, bool marked, bool guaranteed)
Write 16 bit data to STMESP.
Definition: stmesp.h:138
#define EINVAL
Invalid argument.
Definition: errno.h:61
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89