Skip to content

Commit bd3801c

Browse files
author
BlueAndi
committed
Update to vscp-framework v0.6.0
1 parent 8f907b7 commit bd3801c

File tree

12 files changed

+204
-14
lines changed

12 files changed

+204
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## 0.4.1 (unreleased)
1+
## 0.5.0
22

33
- The VSCP framework returned the wrong number of used pages.
4+
- Update to VSCP framework v0.6.0, please see the ![changelog](https://github.com/BlueAndi/vscp-framework/releases/tag/v0.6.0) there.
45

56
## 0.4.0
67

VSCP/library.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name=VSCP
2-
version=0.4.0
2+
version=0.5.0
33
author=Andreas Merkle
44
maintainer=Andreas Merkle <vscp@blue-andi.de>
55
sentence=Very Simple Control Protocol L1 framework for all Arduino boards.
66
paragraph=
7+
category=Communication
78
url=http://github.com/BlueAndi/vscp-arduino
89
architectures=avr

VSCP/src/framework/vscp_config.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ extern "C"
146146

147147
#ifndef VSCP_CONFIG_ENABLE_DM
148148

149-
/** Enable decision matrix special paged feature. */
149+
/** Enable decision matrix (standard). */
150150
#define VSCP_CONFIG_ENABLE_DM VSCP_CONFIG_BASE_ENABLED
151151

152152
#endif /* Undefined VSCP_CONFIG_ENABLE_DM */
@@ -264,9 +264,23 @@ extern "C"
264264

265265
#if VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM_NEXT_GENERATION )
266266

267-
/** Maximum size in bytes of a rule set. */
267+
#ifndef VSCP_CONFIG_DM_NG_PAGE
268+
269+
/** Decision matrix next generation: Location in the application register space.
270+
* Note that the dm ng always starts at the begin of the page! This design
271+
* decision was just for simplification, nothing else.
272+
*/
273+
#define VSCP_CONFIG_DM_NG_PAGE 2
274+
275+
#endif /* Undefined VSCP_CONFIG_DM_NG_PAGE */
276+
277+
#ifndef VSCP_CONFIG_DM_NG_RULE_SET_SIZE
278+
279+
/** Decision matrix next generation: Maximum size in bytes of a rule set. */
268280
#define VSCP_CONFIG_DM_NG_RULE_SET_SIZE 80
269281

282+
#endif /* VSCP_CONFIG_DM_NG_RULE_SET_SIZE */
283+
270284
#endif /* VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM_NEXT_GENERATION ) */
271285

272286
#if VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_LOOPBACK )

VSCP/src/framework/vscp_core.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ static void vscp_core_writeNicknameId(uint8_t nickname)
671671

672672
/**
673673
* This function checks the persistent memory.
674-
* If the persistent memory is not initialized, it will return @FALSE.
674+
* If the persistent memory is not initialized, it will return FALSE.
675675
* The check is done by checking the node control flags,
676676
* especially the start up control. Because the start up control bits can
677677
* be only 01b or 10b.
@@ -1890,13 +1890,23 @@ static uint8_t vscp_core_readRegister(uint16_t page, uint8_t addr)
18901890
break;
18911891
}
18921892
}
1893+
18931894
#if VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM )
1894-
/* Is register part of the decision matrix? */
1895+
/* Is the addressed register part of the decision matrix? */
18951896
else if (FALSE != vscp_dm_isDecisionMatrix(page, addr))
18961897
{
18971898
ret = vscp_dm_readRegister(page, addr);
18981899
}
18991900
#endif /* VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM ) */
1901+
1902+
#if VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM_NEXT_GENERATION )
1903+
/* Is the addressed register part of the decision matrix NG? */
1904+
else if (FALSE != vscp_dm_ng_isDecisionMatrix(page, addr))
1905+
{
1906+
ret = vscp_dm_ng_readRegister(page, addr);
1907+
}
1908+
#endif /* VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM_NEXT_GENERATION ) */
1909+
19001910
else
19011911
/* Application specific register */
19021912
{
@@ -2111,14 +2121,25 @@ static uint8_t vscp_core_writeRegister(uint16_t page, uint8_t addr, uint8_t val
21112121
/* Write protection disabled? */
21122122
else if (0 != vscp_core_getRegAppWriteProtect())
21132123
{
2124+
21142125
#if VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM )
2115-
/* Is register part of the decision matrix? */
2126+
/* Is the addressed register part of the decision matrix? */
21162127
if (FALSE != vscp_dm_isDecisionMatrix(page, addr))
21172128
{
21182129
ret = vscp_dm_writeRegister(page, addr, value);
21192130
}
21202131
else
21212132
#endif /* VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM ) */
2133+
2134+
#if VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM_NEXT_GENERATION )
2135+
/* Is the addressed register part of the decision matrix NG? */
2136+
if (FALSE != vscp_dm_ng_isDecisionMatrix(page, addr))
2137+
{
2138+
ret = vscp_dm_ng_writeRegister(page, addr, value);
2139+
}
2140+
else
2141+
#endif /* VSCP_CONFIG_BASE_IS_ENABLED( VSCP_CONFIG_ENABLE_DM_NEXT_GENERATION ) */
2142+
21222143
/* Application specific registers */
21232144
{
21242145
ret = vscp_app_reg_writeRegister(page, addr, value);

VSCP/src/framework/vscp_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ extern "C"
103103
#define VSCP_CORE_VERSION_STR "v1.10.16"
104104

105105
/** VSCP framework version string */
106-
#define VSCP_CORE_FRAMEWORK_VERSION "v0.5.0"
106+
#define VSCP_CORE_FRAMEWORK_VERSION "v0.6.0"
107107

108108
/*******************************************************************************
109109
MACROS

VSCP/src/framework/vscp_dev_data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ extern uint8_t vscp_dev_data_getGUID(uint8_t index)
266266

267267
#else /* VSCP_CONFIG_BASE_IS_DISABLED( VSCP_DEV_DATA_CONFIG_ENABLE_GUID_STORAGE_PS ) */
268268

269-
uint8_t value = 0;
269+
uint8_t value = 0;
270270

271271
if (VSCP_UTIL_ARRAY_NUM(vscp_dev_data_container.guid) > index)
272272
{

VSCP/src/framework/vscp_dm.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static inline BOOL vscp_dm_isDecisionMatrixStd(uint16_t page, uint8_t addr)
761761
/* Decision matrix is not empty? */
762762
if (0 < VSCP_DM_ROWS)
763763
{
764-
/* Page is equal to the first VSCP decision matrix page? */
764+
/* Page is equal to the first decision matrix page? */
765765
if (VSCP_DM_START_PAGE == page)
766766
{
767767
/* Address is greater or equal than the decision matrix offset? */
@@ -781,7 +781,7 @@ static inline BOOL vscp_dm_isDecisionMatrixStd(uint16_t page, uint8_t addr)
781781
}
782782
}
783783
}
784-
/* Page is equal to the last VSCP decision matrix page? */
784+
/* Page is equal to the last decision matrix page? */
785785
else if (VSCP_DM_LAST_PAGE == page)
786786
{
787787
/* Address is lower or equal than the last decision matrix offset? */
@@ -844,6 +844,9 @@ static inline uint8_t vscp_dm_writeRegisterStd(uint16_t page, uint8_t addr, ui
844844
uint16_t index = ((uint16_t)rowIndex) * sizeof(vscp_dm_MatrixRow) + (uint16_t)rowOffset;
845845

846846
vscp_ps_writeDM(index, value);
847+
848+
/* Read value back */
849+
value = vscp_ps_readDM(index);
847850
}
848851

849852
return value;

VSCP/src/framework/vscp_dm_ng.c

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@
7070
/** Maximum size of a single rule in bytes */
7171
#define VSCP_DM_NG_RULE_MAX_SIZE 40
7272

73+
/** Decision matrix NG location: Page */
74+
#define VSCP_DM_NG_START_PAGE VSCP_CONFIG_DM_NG_PAGE
75+
76+
/** Number of pages which are overspaned by the decision matrix NG, without considering the offset. */
77+
#define VSCP_DM_NG_PAGES (VSCP_CONFIG_DM_NG_RULE_SET_SIZE / 256)
78+
79+
/** Last page of the decision matrix NG */
80+
#define VSCP_DM_NG_LAST_PAGE (VSCP_DM_NG_START_PAGE + VSCP_DM_NG_PAGES)
81+
82+
/** Last offset in the last page of the decision matrix NG. */
83+
#define VSCP_DM_NG_LAST_PAGE_OFFSET ((0 < (VSCP_CONFIG_DM_NG_RULE_SET_SIZE % 256)) ? (VSCP_CONFIG_DM_NG_RULE_SET_SIZE % 256 - 1) : 255)
84+
7385
/*******************************************************************************
7486
MACROS
7587
*******************************************************************************/
@@ -188,7 +200,7 @@ extern void vscp_dm_ng_init(void)
188200
*/
189201
extern void vscp_dm_ng_restoreFactoryDefaultSettings(void)
190202
{
191-
uint8_t index = 0;
203+
uint16_t index = 0;
192204

193205
/* Clear decision matrix next generation */
194206
for(index = 0; index < VSCP_CONFIG_DM_NG_RULE_SET_SIZE; ++index)
@@ -199,6 +211,94 @@ extern void vscp_dm_ng_restoreFactoryDefaultSettings(void)
199211
return;
200212
}
201213

214+
/**
215+
* This function check if the given page and address are part of the
216+
* decision matrix.
217+
*
218+
* @param[in] page Page
219+
* @param[in] addr Register address
220+
* @return Is part of the decision matrix or not.
221+
* @retval FALSE Is not part of the decision matrix.
222+
* @retval TRUE Is part of the decision matrix.
223+
*/
224+
extern BOOL vscp_dm_ng_isDecisionMatrix(uint16_t page, uint8_t addr)
225+
{
226+
BOOL status = FALSE;
227+
228+
/* Decision matrix NG is not empty? */
229+
if (0 < VSCP_CONFIG_DM_NG_RULE_SET_SIZE)
230+
{
231+
/* Page is inside? */
232+
if ((VSCP_DM_NG_START_PAGE <= page) &&
233+
(VSCP_DM_NG_LAST_PAGE >= page))
234+
{
235+
/* Page is equal to the last decision matrix NG page? */
236+
if (VSCP_DM_NG_LAST_PAGE == page)
237+
{
238+
/* Address is lower or equal than the last decision matrix NG offset? */
239+
if (VSCP_DM_NG_LAST_PAGE_OFFSET >= addr)
240+
{
241+
status = TRUE;
242+
}
243+
}
244+
/* Address is inside */
245+
else
246+
{
247+
status = TRUE;
248+
}
249+
}
250+
}
251+
252+
return status;
253+
}
254+
255+
/**
256+
* Read register and return its value.
257+
*
258+
* @param[in] page Page
259+
* @param[in] addr Register address
260+
* @return Register value
261+
*/
262+
extern uint8_t vscp_dm_ng_readRegister(uint16_t page, uint8_t addr)
263+
{
264+
uint8_t value = 0;
265+
uint8_t index = 0;
266+
267+
if (VSCP_DM_NG_START_PAGE <= page)
268+
{
269+
index = (page - VSCP_DM_NG_START_PAGE) * 256 + addr;
270+
271+
value = vscp_ps_readDMNextGeneration(index);
272+
}
273+
274+
return value;
275+
}
276+
277+
/**
278+
* Write to register.
279+
*
280+
* @param[in] page Page
281+
* @param[in] addr Register address
282+
* @param[in] value Value to write
283+
* @return Register value
284+
*/
285+
extern uint8_t vscp_dm_ng_writeRegister(uint16_t page, uint8_t addr, uint8_t value)
286+
{
287+
uint8_t index = 0;
288+
289+
if (VSCP_DM_NG_START_PAGE <= page)
290+
{
291+
index = (page - VSCP_DM_NG_START_PAGE) * 256 + addr;
292+
293+
vscp_ps_writeDMNextGeneration(index, value);
294+
295+
/* Read value back */
296+
value = vscp_ps_readDMNextGeneration(index);
297+
}
298+
299+
return value;
300+
}
301+
202302
/**
203303
* This function process all configured rules and if any action regarding the
204304
* received message takes place, it will call the corresponding action.

VSCP/src/framework/vscp_dm_ng.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ This module contains the VSCP decision matrix next generation.
5656
* Supported compile switches:
5757
* - VSCP_CONFIG_ENABLE_DM_NEXT_GENERATION
5858
*
59-
* @todo Bind it to the application register apce
60-
*
6159
* @{
6260
*/
6361

@@ -182,6 +180,37 @@ extern void vscp_dm_ng_init(void);
182180
*/
183181
extern void vscp_dm_ng_restoreFactoryDefaultSettings(void);
184182

183+
/**
184+
* This function check if the given page and address are part of the
185+
* decision matrix.
186+
*
187+
* @param[in] page Page
188+
* @param[in] addr Register address
189+
* @return Is part of the decision matrix or not.
190+
* @retval FALSE Is not part of the decision matrix.
191+
* @retval TRUE Is part of the decision matrix.
192+
*/
193+
extern BOOL vscp_dm_ng_isDecisionMatrix(uint16_t page, uint8_t addr);
194+
195+
/**
196+
* Read register and return its value.
197+
*
198+
* @param[in] page Page
199+
* @param[in] addr Register address
200+
* @return Register value
201+
*/
202+
extern uint8_t vscp_dm_ng_readRegister(uint16_t page, uint8_t addr);
203+
204+
/**
205+
* Write to register.
206+
*
207+
* @param[in] page Page
208+
* @param[in] addr Register address
209+
* @param[in] value Value to write
210+
* @return Register value
211+
*/
212+
extern uint8_t vscp_dm_ng_writeRegister(uint16_t page, uint8_t addr, uint8_t value);
213+
185214
/**
186215
* This function process all configured rules and if any action regarding the
187216
* received message takes place, it will call the corresponding action.

VSCP/src/framework/vscp_type_alarm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ extern "C"
9797
/** VSCP class 1 alarm type: Emergency Resume */
9898
#define VSCP_TYPE_ALARM_EMERGENCY_RESUME 9
9999

100+
/** VSCP class 1 alarm type: Issued after an alarm system has been armed. */
101+
#define VSCP_TYPE_ALARM_EMERGENCY_ARM 10
102+
103+
/** VSCP class 1 alarm type: Issued after an alarm system has been disarmed. */
104+
#define VSCP_TYPE_ALARM_EMERGENCY_DISARM 11
105+
100106
/*******************************************************************************
101107
MACROS
102108
*******************************************************************************/

0 commit comments

Comments
 (0)