mn_system.hpp
Go to the documentation of this file.
1 
21 #ifndef __MINILIB_SYSTEMINFOS_H__
22 #define __MINILIB_SYSTEMINFOS_H__
23 
24 #include "../mn_config.hpp"
25 #include "../mn_timespan.hpp"
26 
27 namespace mn {
28  namespace device {
32  class system_stream {
33  public:
34  virtual int erase(uint32_t sector) = 0;
35  virtual int erase(uint32_t offset, size_t size) = 0;
36  virtual int write(uint32_t offset, uint32_t *data, size_t size) = 0;
37  virtual int read(uint32_t offset, uint32_t *data, size_t size) = 0;
38  };
39 
44  class basic_system {
45  public /* types */:
46 
47  public /*section power */:
48  enum class power_state_code : int {
49  normal,
51  };
52 
59  static void shutdown(power_state_code code, mn::timespan_t span = mn::timespan_t(0));
60 
67  static void restart(power_state_code code, mn::timespan_t span = mn::timespan_t(0));
68 
74  static void deepsleep(power_state_code code, uint64_t time_us, mn::timespan_t span = mn::timespan_t(0));
75  public /* section RAM */:
76 
80  union randomAccessMemory {
81  struct {
82  uint32_t size;
83  uint32_t free;
84  uint32_t min_freeSinceBoot;
85  uint32_t maxAlloc;
86  };
87  uint32_t data[3];
88  };
89 
93  static randomAccessMemory get_internal();
98  static randomAccessMemory get_external();
99 
100 
101  public /* cpu/SoC Infos */:
102 
107  static uint8_t get_num_cores();
108 
114  static uint8_t get_core_speed(const uint8_t core);
115 
120  static uint8_t get_speed();
121 
126  static void set_core_speed(const uint8_t core, const uint8_t speed);
127 
131  static void set_speed(const uint8_t speed);
132 
137  static const char* get_sdk_version();
138 
143  static const char* get_name();
144 
145  public /*misc */:
146 
150  static system_stream* get_flash();
151 
157  static system_stream* get_partition_stream(const char* name);
158 
159  };
160  }
161 }
162 
163 
164 
165 #endif // __MINILIB_SYSTEMINFOS_H__
This class represents a time span (using microseconds)
Definition: mn_timespan.hpp:35
Get system infos and useful system functins of the using platform.
Definition: mn_system.hpp:44
uint32_t free
Definition: mn_system.hpp:83
static uint8_t get_speed()
Get the mega hertz of the cpu.
Definition: mn_system_esp32.cpp:180
static void deepsleep(power_state_code code, uint64_t time_us, mn::timespan_t span=mn::timespan_t(0))
Enter deep sleep with wakeup by timer.
Definition: mn_system_esp32.cpp:127
static void set_core_speed(const uint8_t core, const uint8_t speed)
Set the speed of a given core.
Definition: mn_system_esp32.cpp:186
static randomAccessMemory get_external()
Return the infos from the external RAM.
Definition: mn_system_esp32.cpp:156
static void restart(power_state_code code, mn::timespan_t span=mn::timespan_t(0))
Restart the CPU.
Definition: mn_system_esp32.cpp:116
uint32_t maxAlloc
Definition: mn_system.hpp:85
uint32_t min_freeSinceBoot
Definition: mn_system.hpp:84
static uint8_t get_core_speed(const uint8_t core)
Get the speed of a core in Mhz.
Definition: mn_system_esp32.cpp:176
static randomAccessMemory get_internal()
Return the infos from the internal RAM.
Definition: mn_system_esp32.cpp:141
static system_stream * get_partition_stream(const char *name)
Get a system stream to write/read to a partition.
Definition: mn_system_esp32.cpp:92
static void set_speed(const uint8_t speed)
Set the speed in Mhz of the cpu.
Definition: mn_system_esp32.cpp:190
uint32_t data[3]
Definition: mn_system.hpp:86
static const char * get_name()
Get the name of the using Platform.
Definition: mn_system_esp32.cpp:197
static const char * get_sdk_version()
Get the version of the using platform SDKs.
Definition: mn_system_esp32.cpp:194
public static void shutdown(power_state_code code, mn::timespan_t span=mn::timespan_t(0))
Halt the CPU.
Definition: mn_system_esp32.cpp:101
public error
Definition: mn_system.hpp:50
A simple abstractes class for easy handle any flash drivers.
Definition: mn_system.hpp:32
virtual int erase(uint32_t offset, size_t size)=0
virtual int erase(uint32_t sector)=0
virtual int write(uint32_t offset, uint32_t *data, size_t size)=0
virtual int read(uint32_t offset, uint32_t *data, size_t size)=0
Definition: mn_allocator_typetraits.hpp:25