memtest.c
Go to the documentation of this file.
1 /*
2  memsize.c : test the MP25P16 flash memory
3 
4  Copyright (C) 2016 Simon D. Levy
5 
6  This file is part of BreezySTM32.
7 
8  BreezySTM32 is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  BreezySTM32 is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <breezystm32.h>
23 #include <string.h>
24 
25 const char * MESSAGE = "Hello, world!";
26 
27 static int msglen;
28 
29 void setup(void)
30 {
31  spiInit(SPI2);
32  m25p16_init();
33  flashfsInit();
34 
35  while (!flashfsIsReady())
36  ;
37 
38  msglen = strlen(MESSAGE);
39 
40  flashfsWrite((uint8_t *)MESSAGE, msglen, true); // sync
41 }
42 
43 void loop(void)
44 {
45  delay(500);
46 
47  char s[100]; // long enough for any message?
48 
49  printf("%s\n", flashfsReadAbs(0, (uint8_t *)s, msglen) < msglen ? "error reading bytes" : s);
50 }
const char * MESSAGE
Definition: memtest.c:25
#define SPI2
Definition: stm32f4xx.h:2050
#define printf
Definition: printf.h:119
static int msglen
Definition: memtest.c:27
XmlRpcServer s
bool flashfsIsReady()
Definition: drv_flashfs.c:111
int flashfsReadAbs(uint32_t address, uint8_t *buffer, unsigned int len)
Definition: drv_flashfs.c:468
bool m25p16_init()
Definition: drv_m25p16.c:217
void setup(void)
Definition: memtest.c:29
void flashfsInit()
Definition: drv_flashfs.c:565
bool spiInit(SPI_TypeDef *instance)
Definition: drv_spi.c:372
void loop(void)
Definition: memtest.c:43
void flashfsWrite(const uint8_t *data, unsigned int len, bool sync)
Definition: drv_flashfs.c:385
void delay(uint32_t ms)
Definition: system.c:98


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:25