Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet_Pico_ordi_B6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Man hing Ling
Projet_Pico_ordi_B6
Commits
7a79a977
Commit
7a79a977
authored
1 year ago
by
root
Browse files
Options
Downloads
Patches
Plain Diff
avancee fonction ecriture et lecture pico ordi
parent
cd35b56c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
SD/picofs.c
+104
-102
104 additions, 102 deletions
SD/picofs.c
with
104 additions
and
102 deletions
SD/picofs.c
+
104
−
102
View file @
7a79a977
...
@@ -23,21 +23,35 @@
...
@@ -23,21 +23,35 @@
#define FIRST_DATA_BLOCK 1040
#define FIRST_DATA_BLOCK 1040
void
readBlock
(
SD_info
*
sd
,
unsigned
int
num
,
int
offset
,
unsigned
char
*
storage
,
int
size
)
{
void
readBlock
(
SD_info
*
sd
,
unsigned
int
num
Block
,
int
offset
,
unsigned
char
*
storage
,
int
size
)
{
//lire à un endroit spécifique du bloc de la carte SD
//lire à un endroit spécifique du bloc de la carte SD
//
uint8_t * buffer_
storage
;
uint8_t
*
buffer_
read
=
malloc
(
sizeof
(
char
)
*
BLOCK_SIZE
)
;
//
readData(sd,num,offset, size, buffer_
storage
);
readData
(
sd
,
num
Block
,
offset
,
size
,
buffer_
read
);
//
storage
=
(unsigned char *)buffer_
storage
;
strcpy
(
storage
,
(
unsigned
char
*
)
buffer_
read
)
;
free
(
buffer_read
);
}
}
void
writeBlock
(
SD_info
*
sd
,
unsigned
int
num
,
int
offset
,
const
unsigned
char
*
s
torag
e
,
int
size
)
{
void
writeBlock
(
SD_info
*
sd
,
unsigned
int
num
Block
,
int
offset
,
unsigned
char
*
s
ourc
e
,
int
size
)
{
//écrire à un endroit spécifique du bloc de la carte SD
//écrire à un endroit spécifique du bloc de la carte SD
// writeBlockSD(sd,num,offset,size, (uint8_t *)storage);
uint8_t
*
buffer_write
=
malloc
(
sizeof
(
char
)
*
BLOCK_SIZE
);
//sauve les données du bloc
if
(
buffer_write
==
NULL
)
printf
(
"erreur malloc write"
);
readData
(
sd
,
numBlock
,
0
,
size
,
buffer_write
);
if
(
offset
+
size
>
512
)
{
printf
(
"data to write is too big"
);
return
;
}
for
(
int
i
=
size
-
1
;
i
>=
0
;
i
--
)
{
source
[
i
+
offset
]
=
source
[
i
];
}
// Ajouter les zéros au début de la chaîne
for
(
int
j
=
0
;
j
<
offset
;
j
++
)
{
source
[
j
]
=
buffer_write
[
j
];
}
writeBlockSD
(
sd
,
numBlock
,
(
uint8_t
*
)
source
);
free
(
buffer_write
);
}
}
void
LS
(
SD_info
*
sd
)
{
void
LS
(
SD_info
*
sd
)
{
unsigned
char
buffer
[
MAX_FILENAME_LENGTH
];
unsigned
char
buffer
[
MAX_FILENAME_LENGTH
];
...
@@ -468,43 +482,31 @@ void CP(SD_info *sd, const char *source_filename, const char *destination_filena
...
@@ -468,43 +482,31 @@ void CP(SD_info *sd, const char *source_filename, const char *destination_filena
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
#ifdef TEST_WRITE
char
user_data
;
uint8_t
blocW
[
BLOCK_SIZE
]
=
{
0xaa
,
0xbb
,
0xcc
};
#endif
#ifdef TEST_READ
uint8_t
blocR
[
BLOCK_SIZE
];
#endif
#ifdef DEBUG
init_printf
();
#endif
SD_info
sd
;
SD_info
sd
;
init_printf
();
spi_init
();
spi_init
();
uint8_t
result
=
sd_init
(
&
sd
);
uint8_t
result
=
sd_init
(
&
sd
);
#ifdef DEBUG
printf
(
"result=%x
\n
"
,
result
);
printf
(
"result=%x
\n
"
,
result
);
printf
(
"status=%x
\n
"
,
sd
.
status_
);
printf
(
"status=%x
\n
"
,
sd
.
status_
);
printf
(
"erreur=%x
\n
"
,
sd
.
errorCode_
);
printf
(
"erreur=%x
\n
"
,
sd
.
errorCode_
);
printf
(
"type=%x
\n
"
,
sd
.
type_
);
printf
(
"type=%x
\n
"
,
sd
.
type_
);
uint32_t
size
=
cardSize
(
&
sd
);
uint32_t
size
=
cardSize
(
&
sd
);
printf
(
"taille=%ld
\n
"
,
size
);
printf
(
"taille=%ld
\n
"
,
size
);
#endif
#ifdef TEST_WRITE
int
statutWrite
=
writeBlockSD
(
&
sd
,
BLOC_NO
,
blocW
);
#ifdef DEBUG
printf
(
"writeStatus=%x
\n
"
,
statutWrite
);
#endif
#endif
#ifdef TEST_READ
int
statutRead
=
readBlockSD
(
&
sd
,
BLOC_NO
,
blocR
);
#ifdef DEBUG
printf
(
"readstatus=%x
\n
"
,
statutRead
);
int
i
;
for
(
i
=
0
;
i
<
3
;
i
++
)
printf
(
"bloc[%d]=%x "
,
i
,
blocR
[
i
]);
printf
(
"
\n
"
);
#endif
#endif
return
0
;
LS
(
&
sd
);
while
(
1
)
{
_delay_ms
(
10
);
user_data
=
get_serial
();
printf
(
"%c"
,
user_data
);
/*if(user_data == '\r' )
{
}*/
}
// // Vérification du nombre d'arguments
// // Vérification du nombre d'arguments
// if (argc < 3) {
// if (argc < 3) {
// printf("Usage: %s filesystem_path ACTION [arguments...]\n", argv[0]);
// printf("Usage: %s filesystem_path ACTION [arguments...]\n", argv[0]);
...
...
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