Solaris Software
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 * ---------------------------------------------------------------- */
19
22
23
24/* ----------------------------------------------------------------
25 * CONSTANTS
26 * ---------------------------------------------------------------- */
27#define K_BMP390_DUMMY_TASK_TIMEOUT_MS (5000U)
28
29
30/* ----------------------------------------------------------------
31 * STATIC FUNCTIONS DECLARATIONS
32 * ---------------------------------------------------------------- */
35
36
37/* ----------------------------------------------------------------
38 * VARIABLES
39 * ---------------------------------------------------------------- */
41 .p_nameProducer = "bmp390_dummy",
45};
46
47static const spp_float32_t s_payload[3] = {
48 0.0f,
49 101325.0f,
50 25.0f,
51};
52
53static spp_uint16_t s_seq = 0U;
54
55
56/* ----------------------------------------------------------------
57 * PUBLIC FUNCTIONS
58 * ---------------------------------------------------------------- */
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 */
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 */
95{
97 if (p_packet == NULL)
98 {
99 return K_SPP_ERROR;
100 }
101
102 SPP_RetVal_t ret =
104 if (ret != K_SPP_OK)
105 {
107 return ret;
108 }
109
110 (void)SPP_SERVICES_PUBSUB_publish(p_packet);
111
112 return K_SPP_OK;
113}
static const SPP_SERVICE_ProducerContract_t g_bmp390ProducerContract
Definition bmp390.c:74
const SPP_SERVICE_ProducerContract_t * SPP_SERVICES_BMP390_getProducerContract(void)
Definition bmp390.c:87
BMP390 barometric pressure sensor driver and service.
static SPP_RetVal_t SPP_SERVICES_BMP390_DUMMY_acquireData(SPP_Kpid_t kpid)
Publish a constant BMP390-equivalent packet.
Definition bmp390_sim.c:94
static SPP_RetVal_t SPP_SERVICES_BMP390_DUMMY_init(void)
Initialise the dummy BMP390 producer.
Definition bmp390_sim.c:76
static spp_uint16_t s_seq
Definition bmp390_sim.c:53
static const spp_float32_t s_payload[3]
Definition bmp390_sim.c:47
#define K_BMP390_DUMMY_TASK_TIMEOUT_MS
Definition bmp390_sim.c:27
SPP_Packet_t * SPP_SERVICES_DATABANK_getPacket(void)
Acquire a free packet from the pool.
Definition databank.c:53
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_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
Static packet pool manager.
SPP_Packet_t
Definition packet.h:79
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
Publish-subscribe packet router.
SPP_RetVal_t
Unified return type for all SPP API functions.
Definition returnTypes.h:24
@ K_SPP_OK
Definition returnTypes.h:25
@ K_SPP_ERROR
Definition returnTypes.h:26
Describes the contract of a producer module. This module needs to have:
Definition service.h:28
uint16_t spp_uint16_t
Definition types.h:29
float spp_float32_t
Definition types.h:35
spp_uint16_t value
Definition kpid.h:25