2 #include "../firmware.h"
6 #define UART_INTERFACE UART_CAMERA
8 static uint32_t address;
10 #define DATA_BUFFER_LENGTH 50
11 static uint8_t data_write[DATA_BUFFER_LENGTH];
12 static uint8_t data_read[DATA_BUFFER_LENGTH];
14 #define PRINT_BUFFER_LENGTH 200
15 uint32_t print_buffer_counter;
17 #define PRINTF_BUFFER_COUNTER_APPEND_ARGS(output, print_buffer_counter, ...) \
18 print_buffer_counter += (size_t)snprintf( \
19 (output+print_buffer_counter), \
20 (PRINT_BUFFER_LENGTH-print_buffer_counter), \
27 char output[PRINT_BUFFER_LENGTH];
32 UART_puts(UART_INTERFACE,
"\r\nFRAM Memory Demo\r\n");
40 UART_puts(UART_INTERFACE,
"Self-test: PASS\r\n");
44 UART_puts(UART_INTERFACE,
"Self-test: FAIL\r\n");
48 address =
Random(FRAM_MAX_ADDRESS);
51 for(i=0;i<DATA_BUFFER_LENGTH;i++)
53 data_write[i] = (uint8_t)
Random(UINT8_MAX-1);
57 print_buffer_counter = 0;
58 PRINTF_BUFFER_COUNTER_APPEND_ARGS(
61 "Write:\r\n * Address: 0x%08lx\r\n * Data: 0x",
64 for(i=0;i<DATA_BUFFER_LENGTH;i++)
66 PRINTF_BUFFER_COUNTER_APPEND_ARGS(
73 PRINTF_BUFFER_COUNTER_APPEND_ARGS(
80 FRAM_write(address, data_write, DATA_BUFFER_LENGTH);
82 FRAM_read(address, data_read, DATA_BUFFER_LENGTH);
84 print_buffer_counter = 0;
85 PRINTF_BUFFER_COUNTER_APPEND_ARGS(
88 "Read:\r\n * Address: 0x%08lx\r\n * Data: 0x",
91 for(i=0;i<DATA_BUFFER_LENGTH;i++)
93 PRINTF_BUFFER_COUNTER_APPEND_ARGS(
100 PRINTF_BUFFER_COUNTER_APPEND_ARGS(
102 print_buffer_counter,
107 if(memcmp(data_read, data_write, DATA_BUFFER_LENGTH) == 0)
109 UART_puts(UART_INTERFACE,
"Buffer Match: PASS\r\n");
113 UART_puts(UART_INTERFACE,
"Buffer Match: FAIL\r\n");
116 UART_puts(UART_INTERFACE,
"---------------\r\n");
void Delay_ms(uint32_t milliseconds)
void UART_init(uint8_t uart_num, uint32_t baudrate)
uint32_t Random(uint32_t max)
void FRAM_read(uint32_t address, uint8_t *data, uint32_t length)
void LED_off(uint8_t led_num)
int main(void)
Runs all module tests.
void FRAM_write(uint32_t address, uint8_t *data, uint32_t length)
void UART_puts(uint8_t uart_num, char *str)
void LED_on(uint8_t led_num)