pxt-ev3/brick/uf2daemon/uf2.h

47 lines
1.3 KiB
C
Raw Normal View History

2017-07-25 12:51:51 +02:00
#ifndef UF2_H
#define UF2_H 1
#include "uf2format.h"
#include <stdio.h>
#include <string.h>
#ifndef INDEX_URL
#define INDEX_URL "https://www.pxt.io/"
#endif
#define UF2_VERSION_BASE "v0.1.0"
// needs to be more than ~4200 and less than ~65000 (to force FAT16)
#define NUM_FAT_BLOCKS 65000
#define UF2_VERSION UF2_VERSION_BASE " F"
//! Static block size for all memories
#define UDI_MSC_BLOCK_SIZE 512L
void read_block(uint32_t block_no, uint8_t *data);
void write_block(uint32_t block_no, uint8_t *data);
#define CONCAT_1(a, b) a##b
#define CONCAT_0(a, b) CONCAT_1(a, b)
2017-07-25 20:09:32 +02:00
#define STATIC_ASSERT(e) enum { CONCAT_0(_static_assert_, __LINE__) = 1 / ((e) ? 1 : 0) }
2017-07-25 12:51:51 +02:00
extern const char infoUf2File[];
void readAll(int fd, void *dst, uint32_t length);
STATIC_ASSERT(sizeof(UF2_Block) == 512);
2017-07-25 20:09:32 +02:00
void mylog(const char *fmt, ...);
2017-07-25 16:28:28 +02:00
#define FAIL(args...) \
do { \
2017-07-27 13:49:19 +02:00
mylog("<4>" args); \
2017-07-25 16:28:28 +02:00
exit(1); \
} while (0)
2017-07-25 20:09:32 +02:00
#define LOG mylog
2017-07-25 16:28:28 +02:00
2017-07-25 12:51:51 +02:00
#endif