Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stm32_libraries
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
humanoides
tools
stm32_libraries
Commits
beba5872
Commit
beba5872
authored
7 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added a pointer to the associated module in the TMemModule structure.
This new pointer is passed to all callback functions.
parent
ad7de303
No related branches found
No related tags found
1 merge request
!6
Dynamixel manager
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
memory/include/mem_module.h
+3
-2
3 additions, 2 deletions
memory/include/mem_module.h
memory/include/memory.h
+6
-2
6 additions, 2 deletions
memory/include/memory.h
memory/src/mem_module.c
+1
-0
1 addition, 0 deletions
memory/src/mem_module.c
memory/src/memory.c
+5
-5
5 additions, 5 deletions
memory/src/memory.c
with
15 additions
and
9 deletions
memory/include/mem_module.h
+
3
−
2
View file @
beba5872
...
...
@@ -15,8 +15,9 @@ typedef struct
TMemSegment
ram_segments
[
MAX_NUM_SEGMENTS
];
unsigned
char
num_eeprom_segments
;
TMemSegment
eeprom_segments
[
MAX_NUM_SEGMENTS
];
void
(
*
write_cmd
)(
unsigned
short
int
address
,
unsigned
short
int
length
,
unsigned
char
*
data
);
void
(
*
read_cmd
)(
unsigned
short
int
address
,
unsigned
short
int
length
,
unsigned
char
*
data
);
void
(
*
write_cmd
)(
void
*
module
,
unsigned
short
int
address
,
unsigned
short
int
length
,
unsigned
char
*
data
);
void
(
*
read_cmd
)(
void
*
module
,
unsigned
short
int
address
,
unsigned
short
int
length
,
unsigned
char
*
data
);
void
*
data
;
}
TMemModule
;
void
mem_module_init
(
TMemModule
*
module
);
...
...
This diff is collapsed.
Click to expand it.
memory/include/memory.h
+
6
−
2
View file @
beba5872
...
...
@@ -4,8 +4,12 @@
#include
"mem_module.h"
#define MAX_NUM_MEM_MODULES 16
#define EEPROM_SIZE 32
#define RAM_SIZE 256
#ifndef EEPROM_SIZE
#define EEPROM_SIZE 32
#endif
#ifndef RAM_SIZE
#define RAM_SIZE 256
#endif
typedef
struct
{
...
...
This diff is collapsed.
Click to expand it.
memory/src/mem_module.c
+
1
−
0
View file @
beba5872
...
...
@@ -17,6 +17,7 @@ void mem_module_init(TMemModule *module)
}
module
->
write_cmd
=
0x00000000
;
module
->
read_cmd
=
0x00000000
;
module
->
data
=
0x00000000
;
}
unsigned
char
mem_module_add_ram_segment
(
TMemModule
*
module
,
unsigned
short
int
start_address
,
unsigned
short
int
length
)
...
...
This diff is collapsed.
Click to expand it.
memory/src/memory.c
+
5
−
5
View file @
beba5872
...
...
@@ -66,7 +66,7 @@ void mem_initialize_data(TMemory *memory)
actual_length
=
EEPROM_SIZE
-
mem_module
->
eeprom_segments
[
j
].
start_address
;
if
((
actual_address
+
actual_length
)
>
(
mem_module
->
eeprom_segments
[
j
].
start_address
+
mem_module
->
eeprom_segments
[
j
].
length
))
actual_length
-=
((
actual_address
+
actual_length
)
-
(
mem_module
->
eeprom_segments
[
j
].
start_address
+
mem_module
->
eeprom_segments
[
j
].
length
));
mem_module
->
write_cmd
(
actual_address
,
actual_length
,
&
eeprom_data
[
actual_address
]);
mem_module
->
write_cmd
(
mem_module
->
data
,
actual_address
,
actual_length
,
&
eeprom_data
[
actual_address
]);
}
}
}
...
...
@@ -171,7 +171,7 @@ void mem_do_write(TMemory *memory,unsigned short int start_address,unsigned shor
}
if
((
actual_address
+
actual_length
)
>
(
mem_module
->
ram_segments
[
j
].
start_address
+
mem_module
->
ram_segments
[
j
].
length
))
actual_length
-=
((
actual_address
+
actual_length
)
-
(
mem_module
->
ram_segments
[
j
].
start_address
+
mem_module
->
ram_segments
[
j
].
length
));
mem_module
->
write_cmd
(
actual_address
,
actual_length
,
&
data
[
actual_address
-
start_address
]);
mem_module
->
write_cmd
(
mem_module
->
data
,
actual_address
,
actual_length
,
&
data
[
actual_address
-
start_address
]);
}
}
}
...
...
@@ -192,7 +192,7 @@ void mem_do_write(TMemory *memory,unsigned short int start_address,unsigned shor
if
((
actual_address
+
actual_length
)
>
(
mem_module
->
eeprom_segments
[
j
].
start_address
+
mem_module
->
eeprom_segments
[
j
].
length
))
actual_length
-=
((
actual_address
+
actual_length
)
-
(
mem_module
->
eeprom_segments
[
j
].
start_address
+
mem_module
->
eeprom_segments
[
j
].
length
));
if
(
mem_module
->
write_cmd
!=
0x00000000
)
mem_module
->
write_cmd
(
actual_address
,
actual_length
,
&
data
[
actual_address
-
start_address
]);
mem_module
->
write_cmd
(
mem_module
->
data
,
actual_address
,
actual_length
,
&
data
[
actual_address
-
start_address
]);
if
(
memory
->
eeprom_write_data
!=
0x00000000
)
for
(
k
=
actual_address
;
k
<
(
actual_address
+
actual_length
);
k
++
)
memory
->
eeprom_write_data
(
k
,
data
[
k
-
start_address
]);
...
...
@@ -228,7 +228,7 @@ void mem_do_read(TMemory *memory,unsigned short int start_address,unsigned short
}
if
((
actual_address
+
actual_length
)
>
(
mem_module
->
ram_segments
[
j
].
start_address
+
mem_module
->
ram_segments
[
j
].
length
))
actual_length
-=
((
actual_address
+
actual_length
)
-
(
mem_module
->
ram_segments
[
j
].
start_address
+
mem_module
->
ram_segments
[
j
].
length
));
mem_module
->
read_cmd
(
actual_address
,
actual_length
,
&
data
[
actual_address
-
start_address
]);
mem_module
->
read_cmd
(
mem_module
->
data
,
actual_address
,
actual_length
,
&
data
[
actual_address
-
start_address
]);
}
}
}
...
...
@@ -250,7 +250,7 @@ void mem_do_read(TMemory *memory,unsigned short int start_address,unsigned short
}
if
((
actual_address
+
actual_length
)
>
(
mem_module
->
eeprom_segments
[
j
].
start_address
+
mem_module
->
eeprom_segments
[
j
].
length
))
actual_length
-=
((
actual_address
+
actual_length
)
-
(
mem_module
->
eeprom_segments
[
j
].
start_address
+
mem_module
->
eeprom_segments
[
j
].
length
));
mem_module
->
read_cmd
(
actual_address
,
actual_length
,
&
data
[
actual_address
-
start_address
]);
mem_module
->
read_cmd
(
mem_module
->
data
,
actual_address
,
actual_length
,
&
data
[
actual_address
-
start_address
]);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment