if the len varies, probably better to change block to a pointer..
the sender will need to malloc(len) and the receiver should free the pointer..
#define BLOCK_SIZE 512
#define SD_QUEUE_SIZE 16 // maybe only 8
typedef struct {
uint16_t len;
uint8_t* block;
} SdBlock;
QueueHandle_t SdQ;
QueueHandle_t SdFileName;
QueueHandle_t SdError;
void setup() {
Serial.begin(500000);
SdQ = xQueueCreate(SD_QUEUE_SIZE, sizeof(SdBlock));
if(SdQ == NULL){
Serial.println("Error creating the queue");
}
}
void loop() {
}
void SendToTask(uint8_t* buf, uint16_t len) {
SdBlock qBlock;
qBlock.block = (uint8_t*)malloc(len);
memcpy (qBlock.block, buf, len);
qBlock.len = len;
xQueueSend(SdQ, &qBlock, portMAX_DELAY);
}
good luck.. ~q