fixed bogus slotcount use display + moved some stuff to dynalloc to save ram

sipo
Ondřej Hruška 6 years ago
parent 7df577f9b1
commit 05875a8167
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 13
      USB/usbd_conf.c
  2. 11
      comm/msg_bulkread.c
  3. 1
      comm/msg_bulkread.h
  4. 2
      tasks/task_msg.c
  5. 2
      utils/stacksmon.c

@ -47,6 +47,7 @@
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include <utils/malloc_safe.h>
#include "platform.h"
#include "usbd_def.h"
#include "usbd_core.h"
@ -633,8 +634,6 @@ void USBD_LL_Delay (uint32_t Delay)
HAL_Delay(Delay);
}
static uint32_t _static_malloc_pos = 0;
/**
* @brief static single allocation.
* @param size: size of allocated memory
@ -642,11 +641,7 @@ static uint32_t _static_malloc_pos = 0;
*/
void *USBD_static_malloc(uint32_t size)
{
// XXX this was modified to support multiple classes
static uint32_t mem[(sizeof(USBD_MSC_BOT_HandleTypeDef)/4)+1+(sizeof(USBD_CDC_HandleTypeDef)/4)+1];/* On 32-bit boundary */
uint32_t oldpos = _static_malloc_pos;
_static_malloc_pos += size/4+1;
return &mem[oldpos];
return malloc_ck(size);
}
/**
@ -656,9 +651,7 @@ void *USBD_static_malloc(uint32_t size)
*/
void USBD_static_free(void *p)
{
// This is wrong, but will work if both frees and malloc's
// are always called together and not interleaved
_static_malloc_pos = 0;
free_ck(p);
}
/**

@ -5,14 +5,12 @@
#include "platform.h"
#include <TinyFrame.h>
#include "utils/malloc_safe.h"
#include "messages.h"
#include "utils/payload_parser.h"
#include "utils/payload_builder.h"
/** Buffer for preparing bulk chunks */
static uint8_t bulkread_buffer[BULK_READ_BUF_LEN];
/**
* TF listener for the bulk read transaction
*/
@ -26,6 +24,7 @@ static TF_Result bulkread_lst(TinyFrame *tf, TF_Msg *msg)
}
assert_param(NULL != bulk);
assert_param(NULL != bulk->_buffer);
if (msg->type == MSG_BULK_ABORT) {
goto close;
@ -39,7 +38,7 @@ static TF_Result bulkread_lst(TinyFrame *tf, TF_Msg *msg)
chunk = MIN(chunk, BULK_READ_BUF_LEN);
// load data into the buffer
bulk->read(bulk, chunk, bulkread_buffer);
bulk->read(bulk, chunk, bulk->_buffer);
bool last = (bulk->offset + chunk >= bulk->len);
@ -47,7 +46,7 @@ static TF_Result bulkread_lst(TinyFrame *tf, TF_Msg *msg)
TF_ClearMsg(&resp);
resp.frame_id = bulk->frame_id;
resp.type = (last ? MSG_BULK_END : MSG_BULK_DATA); // the last chunk has the END type
resp.data = bulkread_buffer;
resp.data = bulk->_buffer;
resp.len = (TF_LEN) chunk;
TF_Respond(tf, &resp);
@ -64,6 +63,7 @@ close:
// Ask user to free the bulk and userdata
bulk->read(bulk, 0, NULL);
msg->userdata = NULL;
free_ck(bulk->_buffer);
}
return TF_CLOSE;
}
@ -76,6 +76,7 @@ void bulkread_start(TinyFrame *tf, BulkRead *bulk)
assert_param(bulk->read);
bulk->offset = 0;
bulk->_buffer = malloc_ck(BULK_READ_BUF_LEN);
{
uint8_t buf[8];

@ -30,6 +30,7 @@ struct bulk_read {
bulkread_data_cb read; //!< Read callback
uint32_t len; //!< Total data length
void *userdata; //!< A place for arbitrary userdata
uint8_t *_buffer;
uint32_t offset; //!< Internal offset counter, will be set to 0 on start.
};

@ -80,7 +80,7 @@ void TaskMsgJob(const void *argument)
#if USE_STACK_MONITOR
uint32_t count;
count = (uint32_t) uxQueueMessagesWaiting(queMsgJobHandle); // this seems to return N+1, hence we don't add the +1 for the one just removed.
count = (uint32_t) uxQueueMessagesWaiting(queMsgJobHandle)+1;
msgQueHighWaterMark = MAX(msgQueHighWaterMark, count);
#endif
}

@ -15,7 +15,7 @@ struct stackhandle {
uint32_t len;
};
#define STACK_NUM 8
#define STACK_NUM 3
static uint32_t nextidx = 0;
static struct stackhandle stacks[STACK_NUM];

Loading…
Cancel
Save