Fix STM32 flashing options (#2997)
[ExpressLRS.git] / src / include / helpers.h
blob59e455133c8d493fcc6d1c1bea9c1499cc85a845
1 #pragma once
3 #include "targets.h"
5 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
7 #ifndef UNUSED
8 #define UNUSED(x) (void)(x)
9 #endif
11 class NullStream : public Stream
13 public:
14 int available() override
16 return 0;
19 void flush() override
23 int peek() override
25 return -1;
28 int read() override
30 return -1;
33 size_t write(uint8_t u_Data) override
35 UNUSED(u_Data);
36 return 0x01;
39 size_t write(const uint8_t *buffer, size_t size) override
41 UNUSED(buffer);
42 return size;
46 #if defined(PLATFORM_STM32)
47 inline const char *strchrnul(const char *pos, const char find)
49 const char *semi = strchr(pos, find);
50 if (semi == nullptr)
52 semi = pos + strlen(pos);
54 return semi;
56 #endif