![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
pausa
Fork of primercorte by
memory.cpp
- Committer:
- nicolasrojas
- Date:
- 2018-06-06
- Revision:
- 5:9187685429b3
- Parent:
- 0:0119b611fc51
File content as of revision 5:9187685429b3:
#include "mbed.h" #include "memory.h" int mem_head = 0; int mem_tail = 0; uint8_t full = 0; MEM_TYPE buffer[MEM_SIZE]; void tail_reset() { mem_tail=0; } void mem_free() { mem_head=0; full=0; } uint8_t mem_put(MEM_TYPE data) { if (full) return 1; buffer[mem_head] = data; mem_head += 1; if (mem_head == MEM_SIZE) full =1; return 0; } uint8_t mem_get(MEM_TYPE* data) { if (mem_head == 0) return 1; if (mem_head == mem_tail) return 1; *data = buffer[mem_tail]; mem_tail += 1; return 0; }