Solaris Software
Toggle main menu visibility
Loading...
Searching...
No Matches
bmp390_sim.c
Go to the documentation of this file.
1
/**
2
* @file bmp390_dummy.c
3
* @brief Minimal BMP390 dummy producer for SPP performance measurements.
4
*
5
* Drop-in replacement for bmp390.c. Implements the same
6
* SPP_SERVICE_ProducerContract_t interface without using GPIO, SPI,
7
* interrupts or physical hardware.
8
*
9
* The dummy publishes a constant payload equivalent to the real BMP390
10
* service so the SPP Core path can be measured independently from the
11
* sensor service and HAL overhead.
12
*/
13
14
15
/* ----------------------------------------------------------------
16
* INCLUDES
17
* ---------------------------------------------------------------- */
18
#include "
spp/services/bmp390/bmp390.h
"
19
20
#include "
spp/services/databank/databank.h
"
21
#include "
spp/core/pubsub/pubsub.h
"
22
23
24
/* ----------------------------------------------------------------
25
* CONSTANTS
26
* ---------------------------------------------------------------- */
27
#define K_BMP390_DUMMY_TASK_TIMEOUT_MS (5000U)
28
29
30
/* ----------------------------------------------------------------
31
* STATIC FUNCTIONS DECLARATIONS
32
* ---------------------------------------------------------------- */
33
static
SPP_RetVal_t
SPP_SERVICES_BMP390_DUMMY_init
(
void
);
34
static
SPP_RetVal_t
SPP_SERVICES_BMP390_DUMMY_acquireData
(
SPP_Kpid_t
kpid);
35
36
37
/* ----------------------------------------------------------------
38
* VARIABLES
39
* ---------------------------------------------------------------- */
40
static
const
SPP_SERVICE_ProducerContract_t
g_bmp390ProducerContract
= {
41
.p_nameProducer =
"bmp390_dummy"
,
42
.tiemoutMs =
K_BMP390_DUMMY_TASK_TIMEOUT_MS
,
43
.init =
SPP_SERVICES_BMP390_DUMMY_init
,
44
.acquireData =
SPP_SERVICES_BMP390_DUMMY_acquireData
,
45
};
46
47
static
const
spp_float32_t
s_payload
[3] = {
48
0.0f,
49
101325.0f,
50
25.0f,
51
};
52
53
static
spp_uint16_t
s_seq
= 0U;
54
55
56
/* ----------------------------------------------------------------
57
* PUBLIC FUNCTIONS
58
* ---------------------------------------------------------------- */
59
const
SPP_SERVICE_ProducerContract_t
*
SPP_SERVICES_BMP390_getProducerContract
(
void
)
60
{
61
return
&
g_bmp390ProducerContract
;
62
}
63
64
65
/* ----------------------------------------------------------------
66
* STATIC FUNCTIONS
67
* ---------------------------------------------------------------- */
68
69
/**
70
* @brief Initialise the dummy BMP390 producer.
71
*
72
* Resets the packet sequence counter. No hardware is initialised.
73
*
74
* @return K_SPP_OK always.
75
*/
76
static
SPP_RetVal_t
SPP_SERVICES_BMP390_DUMMY_init
(
void
)
77
{
78
s_seq
= 0U;
79
80
return
K_SPP_OK
;
81
}
82
83
84
/**
85
* @brief Publish a constant BMP390-equivalent packet.
86
*
87
* Exercises the normal DataBank and PubSub path without performing
88
* sensor calculations, GPIO handling, SPI transactions or HAL calls.
89
*
90
* @param kpid Producer KPID assigned by PubSub.
91
*
92
* @return K_SPP_OK on success or the error returned by DataBank.
93
*/
94
static
SPP_RetVal_t
SPP_SERVICES_BMP390_DUMMY_acquireData
(
SPP_Kpid_t
kpid)
95
{
96
SPP_Packet_t
*p_packet =
SPP_SERVICES_DATABANK_getPacket
();
97
if
(p_packet == NULL)
98
{
99
return
K_SPP_ERROR
;
100
}
101
102
SPP_RetVal_t
ret =
103
SPP_SERVICES_DATABANK_packetData
(p_packet, kpid.
value
,
s_seq
++,
s_payload
, (
spp_uint16_t
)
sizeof
(
s_payload
));
104
if
(ret !=
K_SPP_OK
)
105
{
106
(void)
SPP_SERVICES_DATABANK_returnPacket
(p_packet);
107
return
ret;
108
}
109
110
(void)
SPP_SERVICES_PUBSUB_publish
(p_packet);
111
112
return
K_SPP_OK
;
113
}
g_bmp390ProducerContract
static const SPP_SERVICE_ProducerContract_t g_bmp390ProducerContract
Definition
bmp390.c:74
SPP_SERVICES_BMP390_getProducerContract
const SPP_SERVICE_ProducerContract_t * SPP_SERVICES_BMP390_getProducerContract(void)
Definition
bmp390.c:87
bmp390.h
BMP390 barometric pressure sensor driver and service.
SPP_SERVICES_BMP390_DUMMY_acquireData
static SPP_RetVal_t SPP_SERVICES_BMP390_DUMMY_acquireData(SPP_Kpid_t kpid)
Publish a constant BMP390-equivalent packet.
Definition
bmp390_sim.c:94
SPP_SERVICES_BMP390_DUMMY_init
static SPP_RetVal_t SPP_SERVICES_BMP390_DUMMY_init(void)
Initialise the dummy BMP390 producer.
Definition
bmp390_sim.c:76
s_seq
static spp_uint16_t s_seq
Definition
bmp390_sim.c:53
s_payload
static const spp_float32_t s_payload[3]
Definition
bmp390_sim.c:47
K_BMP390_DUMMY_TASK_TIMEOUT_MS
#define K_BMP390_DUMMY_TASK_TIMEOUT_MS
Definition
bmp390_sim.c:27
SPP_SERVICES_DATABANK_getPacket
SPP_Packet_t * SPP_SERVICES_DATABANK_getPacket(void)
Acquire a free packet from the pool.
Definition
databank.c:53
SPP_SERVICES_DATABANK_returnPacket
SPP_RetVal_t SPP_SERVICES_DATABANK_returnPacket(SPP_Packet_t *p_packet)
Return a packet to the pool after processing.
Definition
databank.c:64
SPP_SERVICES_DATABANK_packetData
SPP_RetVal_t SPP_SERVICES_DATABANK_packetData(SPP_Packet_t *p_packet, spp_uint16_t apid, spp_uint16_t seq, const void *p_data, spp_uint16_t dataLen)
Fill a packet with data and compute its CRC.
Definition
databank.c:117
databank.h
Static packet pool manager.
SPP_Packet_t
SPP_Packet_t
Definition
packet.h:79
SPP_SERVICES_PUBSUB_publish
SPP_RetVal_t SPP_SERVICES_PUBSUB_publish(SPP_Packet_t *p_pkt)
Copies a packet into the internal buffer and returns it to the databank.
Definition
pubsub.c:128
pubsub.h
Publish-subscribe packet router.
SPP_RetVal_t
SPP_RetVal_t
Unified return type for all SPP API functions.
Definition
returnTypes.h:24
K_SPP_OK
@ K_SPP_OK
Definition
returnTypes.h:25
K_SPP_ERROR
@ K_SPP_ERROR
Definition
returnTypes.h:26
SPP_SERVICE_ProducerContract_t
Describes the contract of a producer module. This module needs to have:
Definition
service.h:28
spp_uint16_t
uint16_t spp_uint16_t
Definition
types.h:29
spp_float32_t
float spp_float32_t
Definition
types.h:35
SPP_Kpid_t
Definition
kpid.h:24
SPP_Kpid_t::value
spp_uint16_t value
Definition
kpid.h:25
solaris-v2
spp
services
bmp390
bmp390_sim.c
Generated by
1.18.0