A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://arm-software.github.io/CMSIS_5/Driver/html/group__SampleUseOfStorageDriver.html below:

Sample Use of Storage Driver

The following is a generic algorithm to erase and program one ARM_STORAGE_BLOCK_ATTRIBUTES::erase_unit worth of storage and then read it back to be verified. It handles both synchronous and asynchronous driver implementations.

#include <stdio.h>

#include <string.h>

#define TEST_ASSERT(Expr) if (!(Expr)) { printf("%s:%u: assertion failure\n", __FUNCTION__, __LINE__); while (1) ;}

#define TEST_ASSERT_EQUAL(expected, actual) if ((expected) != (actual)) {printf("%s:%u: assertion failure\n", __FUNCTION__, __LINE__); while (1) ;}

#define TEST_ASSERT_NOT_EQUAL(expected, actual) if ((expected) == (actual)) {printf("%s:%u: assertion failure\n", __FUNCTION__, __LINE__); while (1) ;}

void progressStateMachine(void);

static enum {

NEEDS_INITIALIZATION,

NEEDS_ERASE,

NEEDS_PROGRAMMING,

NEEDS_READ,

NEEDS_VERIFICATION_FOLLOWING_READ,

FINISHED

} state;

static const unsigned BUFFER_SIZE = 16384;

static uint8_t buffer[BUFFER_SIZE];

void main(int argc __unused, char** argv __unused)

{

state = NEEDS_INITIALIZATION;

progressStateMachine();

while (true) {

}

}

void progressStateMachine(void)

{

int32_t rc;

}

TEST_ASSERT(firstBlock.

size

> 0);

switch (state) {

case NEEDS_INITIALIZATION:

state = NEEDS_ERASE;

return;

}

TEST_ASSERT_EQUAL(1, rc);

case NEEDS_ERASE:

state = NEEDS_PROGRAMMING;

return;

}

case NEEDS_PROGRAMMING:

#define PATTERN 0xAA

state = NEEDS_READ;

return;

}

case NEEDS_READ:

state = NEEDS_VERIFICATION_FOLLOWING_READ;

return;

}

case NEEDS_VERIFICATION_FOLLOWING_READ:

printf("verifying data\r\n");

TEST_ASSERT_EQUAL(PATTERN, buffer[i]);

}

state = FINISHED;

printf("done\r\n");

break;

case FINISHED:

break;

}

}

{

(void)status;

(void)operation;

switch (operation) {

progressStateMachine();

break;

default:

printf("callbackHandler: unexpected callback for opcode %u with status %ld\r\n", operation, status);

break;

}

}


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4