lib
xspublic
xscommon
fwupdate.h
Go to the documentation of this file.
1
2
// Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without modification,
6
// are permitted provided that the following conditions are met:
7
//
8
// 1. Redistributions of source code must retain the above copyright notice,
9
// this list of conditions, and the following disclaimer.
10
//
11
// 2. Redistributions in binary form must reproduce the above copyright notice,
12
// this list of conditions, and the following disclaimer in the documentation
13
// and/or other materials provided with the distribution.
14
//
15
// 3. Neither the names of the copyright holders nor the names of their contributors
16
// may be used to endorse or promote products derived from this software without
17
// specific prior written permission.
18
//
19
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
// THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
// SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28
// SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29
// OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30
// ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31
//
32
33
34
// Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35
// All rights reserved.
36
//
37
// Redistribution and use in source and binary forms, with or without modification,
38
// are permitted provided that the following conditions are met:
39
//
40
// 1. Redistributions of source code must retain the above copyright notice,
41
// this list of conditions, and the following disclaimer.
42
//
43
// 2. Redistributions in binary form must reproduce the above copyright notice,
44
// this list of conditions, and the following disclaimer in the documentation
45
// and/or other materials provided with the distribution.
46
//
47
// 3. Neither the names of the copyright holders nor the names of their contributors
48
// may be used to endorse or promote products derived from this software without
49
// specific prior written permission.
50
//
51
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54
// THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55
// SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60
// SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61
// OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62
// ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63
//
64
65
#ifndef FWUPDATE_H
66
#define FWUPDATE_H
67
68
#include "
xbus.h
"
69
70
#ifdef __cplusplus
71
extern
"C"
{
72
#endif
73
74
#define FWU_REQUIRED_TXBUFFER_SIZE 300
75
78
typedef
enum
79
{
80
FWU_Success
,
81
FWU_Failed
82
}
FWU_Result
;
83
84
87
typedef
struct
88
{
89
uint32_t
m_globalId
;
90
uint32_t
m_sectionSize
;
91
uint8_t m_firmwareRevision[3];
92
uint8_t m_xffVersion[2];
93
uint8_t
m_chipId
;
94
uint8_t
m_numberOfSections
;
95
uint8_t
m_addressLength
;
96
uint16_t
m_pageSize
;
97
uint16_t
m_sliceSize
;
98
uint8_t m_hardwareVersion[2];
99
char
m_productCode[20];
100
uint32_t
m_productVariant
;
101
}
XffHeader
;
102
103
106
typedef
enum
107
{
108
STATE_Idle
,
109
STATE_Start
,
110
STATE_WaitReady
,
111
STATE_WaitHeaderResult
,
112
STATE_WaitSliceReady
,
113
STATE_WaitPageOk
,
114
STATE_WaitPageReady
115
}
FWU_State
;
116
117
118
121
typedef
struct
122
{
123
/* External dependencies. Host should fill in these members */
124
131
uint32_t
(*m_readXffData)(uint8_t* buffer,
uint32_t
offset,
uint32_t
length
);
132
136
void (*m_sendXbusMessage)(uint8_t
const
* xbusMessage);
137
141
void (*m_readyHandler)(
FWU_Result
result);
142
146
uint8_t*
m_txBuffer
;
147
148
/* State variables for internal use (the user must not touch these) */
149
FWU_State
m_state
;
150
XffHeader
m_xffHeader
;
151
uint32_t
m_nofPages
;
152
uint32_t
m_nofSlicesPerPage
;
153
uint32_t
m_pageCounter
;
154
uint32_t
m_sliceCounter
;
155
uint32_t
m_readIndex
;
156
uint8_t
m_endOfFile
;
157
}
FwUpdate
;
158
159
160
void
FwUpdate_init
(
FwUpdate
* thisPtr);
161
162
void
FwUpdate_start
(
FwUpdate
* thisPtr);
163
164
void
FwUpdate_handleXbus
(
FwUpdate
* thisPtr, uint8_t
const
* xbusMessage);
165
166
167
#ifdef __cplusplus
168
}
169
#endif
/* extern "C" */
170
171
172
#endif
FwUpdate::m_nofSlicesPerPage
uint32_t m_nofSlicesPerPage
Definition:
fwupdate.h:152
FwUpdate::m_endOfFile
uint8_t m_endOfFile
Definition:
fwupdate.h:156
XffHeader::m_addressLength
uint8_t m_addressLength
Definition:
fwupdate.h:95
FwUpdate_handleXbus
void FwUpdate_handleXbus(FwUpdate *thisPtr, uint8_t const *xbusMessage)
Handle xbus message coming from the module.
Definition:
fwupdate.c:382
STATE_WaitPageReady
@ STATE_WaitPageReady
Definition:
fwupdate.h:114
XffHeader::m_productVariant
uint32_t m_productVariant
Definition:
fwupdate.h:100
FwUpdate
FwUpdate object definition.
Definition:
fwupdate.h:121
XffHeader::m_sectionSize
uint32_t m_sectionSize
Definition:
fwupdate.h:90
XffHeader::m_sliceSize
uint16_t m_sliceSize
Definition:
fwupdate.h:97
XffHeader::m_numberOfSections
uint8_t m_numberOfSections
Definition:
fwupdate.h:94
STATE_WaitSliceReady
@ STATE_WaitSliceReady
Definition:
fwupdate.h:112
FWU_Result
FWU_Result
Result value.
Definition:
fwupdate.h:78
XffHeader::m_chipId
uint8_t m_chipId
Definition:
fwupdate.h:93
xbus.h
STATE_Start
@ STATE_Start
Definition:
fwupdate.h:109
uint32_t
unsigned int uint32_t
Definition:
pstdint.h:485
STATE_Idle
@ STATE_Idle
Definition:
fwupdate.h:108
FwUpdate::m_state
FWU_State m_state
Definition:
fwupdate.h:149
FwUpdate::m_pageCounter
uint32_t m_pageCounter
Definition:
fwupdate.h:153
FwUpdate::m_readIndex
uint32_t m_readIndex
Definition:
fwupdate.h:155
STATE_WaitHeaderResult
@ STATE_WaitHeaderResult
Definition:
fwupdate.h:111
XffHeader
Definition of a xff section header.
Definition:
fwupdate.h:87
FwUpdate::m_nofPages
uint32_t m_nofPages
Definition:
fwupdate.h:151
FwUpdate_init
void FwUpdate_init(FwUpdate *thisPtr)
Initialize a FwUpdate instance.
Definition:
fwupdate.c:352
STATE_WaitReady
@ STATE_WaitReady
Definition:
fwupdate.h:110
FWU_Success
@ FWU_Success
Definition:
fwupdate.h:80
FwUpdate::m_sliceCounter
uint32_t m_sliceCounter
Definition:
fwupdate.h:154
FwUpdate::m_txBuffer
uint8_t * m_txBuffer
Memory needed by the FwUpdate. Host must allocate a block of memory of size FWU_REQUIRED_TXBUFFER_SIZ...
Definition:
fwupdate.h:146
FWU_State
FWU_State
Internal state.
Definition:
fwupdate.h:106
XffHeader::m_globalId
uint32_t m_globalId
Definition:
fwupdate.h:89
length
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
FwUpdate_start
void FwUpdate_start(FwUpdate *thisPtr)
Start a firmware update.
Definition:
fwupdate.c:361
STATE_WaitPageOk
@ STATE_WaitPageOk
Definition:
fwupdate.h:113
FwUpdate::m_xffHeader
XffHeader m_xffHeader
Definition:
fwupdate.h:150
XffHeader::m_pageSize
uint16_t m_pageSize
Definition:
fwupdate.h:96
FWU_Failed
@ FWU_Failed
Definition:
fwupdate.h:81
xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20