2020-11-27 05:10:47 -05:00
|
|
|
#pragma once
|
2015-12-10 12:26:56 -05:00
|
|
|
//
|
2020-11-27 05:10:47 -05:00
|
|
|
// FILE: avrheap.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2024-04-09 03:21:57 -04:00
|
|
|
// VERSION: 0.2.7
|
|
|
|
// DATE: 2015-10-25
|
|
|
|
// PURPOSE: Experimental Arduino library to investigate the AVR heap Arduino UNO
|
2015-12-10 12:26:56 -05:00
|
|
|
|
2021-05-28 07:20:16 -04:00
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
#if !defined(ARDUINO_ARCH_AVR)
|
|
|
|
#error “Avrheap library only AVR boards, tested only with UNO.”
|
2015-12-10 12:26:56 -05:00
|
|
|
#endif
|
|
|
|
|
2021-05-28 07:20:16 -04:00
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
#include "Arduino.h"
|
2015-12-10 12:26:56 -05:00
|
|
|
#include "Printable.h"
|
|
|
|
|
2021-05-28 07:20:16 -04:00
|
|
|
|
2024-04-09 03:21:57 -04:00
|
|
|
#define AVRHEAP_LIB_VERSION (F("0.2.7"))
|
2021-05-28 07:20:16 -04:00
|
|
|
|
2015-12-10 12:26:56 -05:00
|
|
|
|
2015-12-10 14:19:02 -05:00
|
|
|
class Avrheap : public Printable
|
2015-12-10 12:26:56 -05:00
|
|
|
{
|
|
|
|
public:
|
2021-01-29 06:31:58 -05:00
|
|
|
Avrheap();
|
2015-12-10 12:30:14 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
bool isFragmented();
|
|
|
|
uint16_t freeListCount();
|
|
|
|
uint16_t freeListSize();
|
|
|
|
void freeListWalk(bool withDump = true);
|
|
|
|
uint16_t freeListLargest();
|
2015-12-10 12:30:14 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
uint16_t startAddress();
|
2015-12-10 12:43:57 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void dumpHeap(uint16_t count);
|
|
|
|
size_t heapWalk(Print& p, bool withDump = true) const;
|
|
|
|
size_t heapWalk(bool withDump = true);
|
|
|
|
virtual size_t printTo(Print& p) const;
|
2015-12-10 14:19:02 -05:00
|
|
|
|
2015-12-10 12:26:56 -05:00
|
|
|
private:
|
2021-01-29 06:31:58 -05:00
|
|
|
bool inFreeList(uint16_t addr);
|
2015-12-10 12:26:56 -05:00
|
|
|
};
|
|
|
|
|
2021-05-28 07:20:16 -04:00
|
|
|
|
2015-12-10 14:19:02 -05:00
|
|
|
size_t hNibble(Print& p, byte val);
|
|
|
|
size_t hByte(Print& p, byte val);
|
|
|
|
size_t hWord(Print& p, uint16_t val);
|
|
|
|
size_t dumpR(Print& p, byte* adr, int len);
|
|
|
|
size_t dumpAlloced(Print& p, byte *ptr, bool withDump = true);
|
|
|
|
size_t dumpAlloced(byte *ptr, bool withDump = true);
|
|
|
|
|
2021-05-28 07:20:16 -04:00
|
|
|
|
2023-10-17 13:54:22 -04:00
|
|
|
// -- END OF FILE --
|