diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c index 4f99ae756..0949558f3 100644 --- a/armsrc/BigBuf.c +++ b/armsrc/BigBuf.c @@ -92,9 +92,9 @@ uint32_t BigBuf_get_size(void) { // get the address of the emulator memory. Allocate part of Bigbuf for it, if not yet done uint8_t *BigBuf_get_EM_addr(void) { // not yet allocated - if (emulator_memory == NULL) - emulator_memory = BigBuf_malloc(CARD_MEMORY_SIZE); - + if (emulator_memory == NULL) { + emulator_memory = BigBuf_calloc(CARD_MEMORY_SIZE); + } return emulator_memory; } @@ -366,8 +366,9 @@ void tosend_stuffbit(int b) { } dmabuf16_t *get_dma16(void) { - if (dma_16.buf == NULL) + if (dma_16.buf == NULL) { dma_16.buf = (uint16_t *)BigBuf_malloc(DMA_BUFFER_SIZE * sizeof(uint16_t)); + } return &dma_16; } diff --git a/armsrc/BigBuf.h b/armsrc/BigBuf.h index e496ce2f7..7eb8fa2ce 100644 --- a/armsrc/BigBuf.h +++ b/armsrc/BigBuf.h @@ -26,7 +26,7 @@ #define MAX_MIFARE_FRAME_SIZE 18 // biggest Mifare frame is answer to a read (one block = 16 Bytes) + 2 Bytes CRC #define MAX_MIFARE_PARITY_SIZE 3 // need 18 parity bits for the 18 Byte above. 3 Bytes are enough to store these #define CARD_MEMORY_SIZE 4096 -#define DMA_BUFFER_SIZE 512 +#define DMA_BUFFER_SIZE (512 + 256) // 8 data bits and 1 parity bit per payload byte, 1 correction bit, 1 SOC bit, 2 EOC bits #define TOSEND_BUFFER_SIZE (9 * MAX_FRAME_SIZE + 1 + 1 + 2)