Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
749e71d9
Commit
749e71d9
authored
May 05, 2015
by
Vowstar
Committed by
Orgmar
May 05, 2015
Browse files
Fixed strange SPI flash API error. Added word_of_aligned_array.
parent
32e9ac20
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/platform/flash_api.c
View file @
749e71d9
...
@@ -396,11 +396,25 @@ uint8_t byte_of_aligned_array(const uint8_t *aligned_array, uint32_t index)
...
@@ -396,11 +396,25 @@ uint8_t byte_of_aligned_array(const uint8_t *aligned_array, uint32_t index)
NODE_DBG
(
"aligned_array is not 4-byte aligned.
\n
"
);
NODE_DBG
(
"aligned_array is not 4-byte aligned.
\n
"
);
return
0
;
return
0
;
}
}
uint32_t
v
=
((
uint32_t
*
)
aligned_array
)[
index
/
4
];
volatile
uint32_t
v
=
((
uint32_t
*
)
aligned_array
)[
index
/
4
];
uint8_t
*
p
=
(
uint8_t
*
)
(
&
v
);
uint8_t
*
p
=
(
uint8_t
*
)
(
&
v
);
return
p
[
(
index
%
4
)
];
return
p
[
(
index
%
4
)
];
}
}
uint16_t
word_of_aligned_array
(
const
uint16_t
*
aligned_array
,
uint32_t
index
)
{
if
(
(((
uint32_t
)
aligned_array
)
%
4
)
!=
0
)
{
NODE_DBG
(
"aligned_array is not 4-byte aligned.
\n
"
);
return
0
;
}
volatile
uint32_t
v
=
((
uint32_t
*
)
aligned_array
)[
index
/
2
];
uint16_t
*
p
=
(
uint16_t
*
)
(
&
v
);
return
(
index
%
2
==
0
)
?
p
[
0
]
:
p
[
1
];
// return p[ (index % 2) ]; // -- why error???
// (byte_of_aligned_array((uint8_t *)aligned_array, index * 2 + 1) << 8) | byte_of_aligned_array((uint8_t *)aligned_array, index * 2);
}
// uint8_t flash_rom_get_checksum(void)
// uint8_t flash_rom_get_checksum(void)
// {
// {
// // SPIFlashInfo spi_flash_info ICACHE_STORE_ATTR = flash_rom_getinfo();
// // SPIFlashInfo spi_flash_info ICACHE_STORE_ATTR = flash_rom_getinfo();
...
...
app/platform/flash_api.h
View file @
749e71d9
...
@@ -107,6 +107,7 @@ bool flash_init_data_default(void);
...
@@ -107,6 +107,7 @@ bool flash_init_data_default(void);
bool
flash_init_data_blank
(
void
);
bool
flash_init_data_blank
(
void
);
bool
flash_self_destruct
(
void
);
bool
flash_self_destruct
(
void
);
uint8_t
byte_of_aligned_array
(
const
uint8_t
*
aligned_array
,
uint32_t
index
);
uint8_t
byte_of_aligned_array
(
const
uint8_t
*
aligned_array
,
uint32_t
index
);
uint16_t
word_of_aligned_array
(
const
uint16_t
*
aligned_array
,
uint32_t
index
);
// uint8_t flash_rom_get_checksum(void);
// uint8_t flash_rom_get_checksum(void);
// uint8_t flash_rom_calc_checksum(void);
// uint8_t flash_rom_calc_checksum(void);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment