Added ESP32-S3
This commit is contained in:
parent
0e043e792e
commit
b972a8bab6
2 changed files with 120 additions and 0 deletions
31
ESP32-S3/cache.h
Normal file
31
ESP32-S3/cache.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/***************************************************************
|
||||
* *
|
||||
* Taiko Sanro - Arduino *
|
||||
* Cache data structure *
|
||||
* *
|
||||
* Chris *
|
||||
* wisaly@gmail.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#ifndef CACHE_H
|
||||
#define CACHE_H
|
||||
|
||||
template <class T, int L>
|
||||
class Cache {
|
||||
public:
|
||||
Cache() { memset(data_, 0, sizeof(data_)); }
|
||||
inline void put(T value) {
|
||||
current_ = (current_ + 1) & (L - 1);
|
||||
data_[current_] = value;
|
||||
}
|
||||
inline T get(int offset = 0) const {
|
||||
return data_[(current_ + offset) & (L - 1)];
|
||||
}
|
||||
|
||||
private:
|
||||
T data_[L];
|
||||
int current_ = 0;
|
||||
};
|
||||
|
||||
#endif // CACHE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue