@@ -72,7 +72,7 @@ pbio_error_t pbsys_storage_set_user_data(uint32_t offset, const uint8_t *data, u
7272}
7373
7474/**
75- * Gets pointer to user data or user program.
75+ * Gets pointer to user data, settings, or program.
7676 *
7777 * @param [in] offset Offset from the base address.
7878 * @param [in] data The data reference.
@@ -81,8 +81,9 @@ pbio_error_t pbsys_storage_set_user_data(uint32_t offset, const uint8_t *data, u
8181 * Otherwise, ::PBIO_SUCCESS.
8282 */
8383pbio_error_t pbsys_storage_get_user_data (uint32_t offset , uint8_t * * data , uint32_t size ) {
84- // User is allowed to read beyond user storage to include program data.
85- if (offset + size > sizeof (map -> user_data ) + sizeof (map -> program_size ) + map -> program_size ) {
84+ // User is allowed to read beyond user storage to include settings and
85+ // program data.
86+ if (offset + size > (map -> program_data - map -> user_data ) + map -> program_size ) {
8687 return PBIO_ERROR_INVALID_ARG ;
8788 }
8889 * data = map -> user_data + offset ;
@@ -112,7 +113,8 @@ static void pbsys_storage_update_checksum(void) {
112113 // Add checksum for each word in the written data and empty checked size.
113114 for (uint32_t offset = 0 ; offset < checksize ; offset += sizeof (uint32_t )) {
114115 uint32_t * word = (uint32_t * )((uint8_t * )map + offset );
115- // Assume that everything after written data is erased.
116+ // Assume that everything after written data is erased by the block
117+ // device driver prior to writing.
116118 checksum += offset < map -> write_size ? * word : 0xFFFFFFFF ;
117119 }
118120
0 commit comments