Solaris Software
Toggle main menu visibility
Loading...
Searching...
No Matches
maxm10m20b.c
Go to the documentation of this file.
1
/**
2
* @file MAX-M10M-20B_service.c
3
* @brief Ublox GNSS (MAX-M10M-20B) driver + SPP service implementation.
4
*/
5
6
#include "
spp/services/maxm10m20b/maxm10m20b.h
"
7
8
#include "
spp/hal/uart/uart.h
"
9
#include "
spp/hal/time/time.h
"
10
#include "
spp/services/log/log.h
"
11
#include "
spp/services/databank/databank.h
"
12
#include "
spp/core/packet.h
"
13
#include "
spp/core/pubsub/pubsub.h
"
14
#include "
spp/services/fsm/fsm.h
"
15
16
17
#include <string.h>
18
19
/* ----------------------------------------------------------------
20
* CONSTANTS
21
* ---------------------------------------------------------------- */
22
#define K_M10M_TAG "MAX-M10M-20B"
23
24
25
/* ----------------------------------------------------------------
26
* STATIC FUNCTIONS DECLARATIONS
27
* ---------------------------------------------------------------- */
28
static
SPP_RetVal_t
SPP_SERVICES_M10M_init
(
void
);
29
static
SPP_RetVal_t
SPP_SERVICES_M10M_acquireData
(
SPP_Kpid_t
kpid);
30
/* ----------------------------------------------------------------
31
* VARIABLES
32
* ---------------------------------------------------------------- */
33
static
const
SPP_SERVICE_ProducerContract_t
g_m10mProducerContract
= {.p_nameProducer =
"GNSS (UBLOX MAX-M10M-20B)"
,
34
.tiemoutMs =
K_M10M_TIMEOUT_MS
,
35
.init =
SPP_SERVICES_M10M_init
,
36
.acquireData = NULL};
37
static
spp_uint8_t
s_M10M_id
[18] = {};
38
static
spp_uint8_t
s_M10M_dynModel
[17] = {};
39
static
spp_uint8_t
s_M10M_dynModel_ack
[10] = {};
40
static
spp_uint32_t
s_readBytes
= 0;
41
42
/* ----------------------------------------------------------------
43
* PUBLIC FUNCTIONS
44
* ---------------------------------------------------------------- */
45
const
SPP_SERVICE_ProducerContract_t
*
SPP_SERVICES_M10M_getProducerContract
(
void
)
46
{
47
return
&
g_m10mProducerContract
;
48
}
49
50
/* ----------------------------------------------------------------
51
* STATIC FUNCTIONS
52
* ---------------------------------------------------------------- */
53
static
SPP_RetVal_t
SPP_SERVICES_M10M_init
(
void
)
54
{
55
FsmErrors_t
*p_fsmErrors =
SPP_CORE_FSM_getErrorsBit
();
56
SPP_RetVal_t
ret =
SPP_HAL_UART_transmit
(K_M10M_CTRL_RST_CMD,
sizeof
(K_M10M_CTRL_RST_CMD));
57
if
(ret !=
K_SPP_OK
)
58
{
59
p_fsmErrors->m10mInitError = 1;
60
return
K_SPP_ERROR
;
61
}
62
63
SPP_HAL_TIME_delayMs
(200);
64
65
ret =
SPP_HAL_UART_transmit
(K_M10M_ID_OUT,
sizeof
(K_M10M_ID_OUT));
66
if
(ret !=
K_SPP_OK
)
67
{
68
p_fsmErrors->m10mInitError = 1;
69
return
K_SPP_ERROR
;
70
}
71
72
ret =
SPP_HAL_UART_read
(
s_M10M_id
,
sizeof
(
s_M10M_id
), &
s_readBytes
);
73
if
(ret !=
K_SPP_OK
||
s_readBytes
!=
sizeof
(
s_M10M_id
))
74
{
75
p_fsmErrors->m10mInitError = 1;
76
return
K_SPP_ERROR
;
77
}
78
79
ret =
SPP_HAL_UART_transmit
(K_M10M_AIR4_DYNMODEL_SET,
sizeof
(K_M10M_AIR4_DYNMODEL_SET));
80
if
(ret !=
K_SPP_OK
)
81
{
82
p_fsmErrors->m10mInitError = 1;
83
return
K_SPP_ERROR
;
84
}
85
86
ret =
SPP_HAL_UART_read
(
s_M10M_dynModel_ack
,
sizeof
(
s_M10M_dynModel_ack
), &
s_readBytes
);
87
if
(ret !=
K_SPP_OK
||
s_readBytes
!=
sizeof
(
s_M10M_dynModel_ack
))
88
{
89
p_fsmErrors->m10mInitError = 1;
90
return
K_SPP_ERROR
;
91
}
92
93
spp_int16_t
comp = memcmp(
s_M10M_dynModel_ack
, K_M10M_DYNMODEL_ACK_OUT,
sizeof
(K_M10M_DYNMODEL_ACK_OUT));
94
if
(comp != 0)
95
{
96
p_fsmErrors->m10mInitError = 1;
97
return
K_SPP_ERROR
;
98
}
99
100
ret =
SPP_HAL_UART_transmit
(K_M10M_AIR4_DYNMODEL_GET,
sizeof
(K_M10M_AIR4_DYNMODEL_GET));
101
if
(ret !=
K_SPP_OK
)
102
{
103
p_fsmErrors->m10mInitError = 1;
104
return
K_SPP_ERROR
;
105
}
106
107
ret =
SPP_HAL_UART_read
(
s_M10M_dynModel
,
sizeof
(
s_M10M_dynModel
), &
s_readBytes
);
108
if
(ret !=
K_SPP_OK
|| (
s_M10M_dynModel
[14] != 0x08))
109
{
110
p_fsmErrors->m10mInitError = 1;
111
return
K_SPP_ERROR
;
112
}
113
114
return
K_SPP_OK
;
115
}
databank.h
Static packet pool manager.
SPP_CORE_FSM_getErrorsBit
spp_uint16_t * SPP_CORE_FSM_getErrorsBit(void)
Get the pointer to the FSM errors bit.
Definition
fsm.c:33
fsm.h
Finite State Machine (FSM) module for the SPP core.
log.h
SPP logging service.
s_M10M_dynModel_ack
static spp_uint8_t s_M10M_dynModel_ack[10]
Definition
maxm10m20b.c:39
SPP_SERVICES_M10M_getProducerContract
const SPP_SERVICE_ProducerContract_t * SPP_SERVICES_M10M_getProducerContract(void)
Definition
maxm10m20b.c:45
s_readBytes
static spp_uint32_t s_readBytes
Definition
maxm10m20b.c:40
g_m10mProducerContract
static const SPP_SERVICE_ProducerContract_t g_m10mProducerContract
Definition
maxm10m20b.c:33
s_M10M_id
static spp_uint8_t s_M10M_id[18]
Definition
maxm10m20b.c:37
s_M10M_dynModel
static spp_uint8_t s_M10M_dynModel[17]
Definition
maxm10m20b.c:38
SPP_SERVICES_M10M_acquireData
static SPP_RetVal_t SPP_SERVICES_M10M_acquireData(SPP_Kpid_t kpid)
SPP_SERVICES_M10M_init
static SPP_RetVal_t SPP_SERVICES_M10M_init(void)
Definition
maxm10m20b.c:53
maxm10m20b.h
K_M10M_TIMEOUT_MS
#define K_M10M_TIMEOUT_MS
Definition
maxm10m20b.h:20
packet.h
Solaris Packet Protocol (SPP) packet structure definitions.
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_HAL_TIME_delayMs
void SPP_HAL_TIME_delayMs(spp_uint32_t ms)
Block for the requested number of milliseconds.
Definition
time.c:37
time.h
SPP HAL time API — dispatches through the registered HAL port.
spp_uint32_t
uint32_t spp_uint32_t
Definition
types.h:31
spp_uint8_t
uint8_t spp_uint8_t
Definition
types.h:27
spp_int16_t
int16_t spp_int16_t
Definition
types.h:30
SPP_HAL_UART_transmit
SPP_RetVal_t SPP_HAL_UART_transmit(const void *p_data, spp_uint16_t len)
Perform UART transaction.
Definition
uart.c:44
SPP_HAL_UART_read
SPP_RetVal_t SPP_HAL_UART_read(void *p_data, spp_uint32_t len, spp_uint32_t *p_readBytes)
Perform UART read.
Definition
uart.c:76
uart.h
SPP UART HAL API — dispatches through the registered HAL port.
FsmErrors_t
Definition
custom.h:23
SPP_Kpid_t
Definition
kpid.h:24
solaris-v2
spp
services
maxm10m20b
maxm10m20b.c
Generated by
1.18.0