mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
LP-512 Moved some non-DMA memory allocations (uavobjects, hid/cdc driver structures and com rx/tx buffers) to CCM if available.
This commit is contained in:
parent
5ea1c9011b
commit
9f16143ba7
@ -72,7 +72,7 @@ static struct pios_com_dev *PIOS_COM_alloc(void)
|
||||
{
|
||||
struct pios_com_dev *com_dev;
|
||||
|
||||
com_dev = (struct pios_com_dev *)pios_malloc(sizeof(struct pios_com_dev));
|
||||
com_dev = (struct pios_com_dev *)pios_fastheapmalloc(sizeof(struct pios_com_dev));
|
||||
if (!com_dev) {
|
||||
return NULL;
|
||||
}
|
||||
@ -120,14 +120,14 @@ int32_t PIOS_COM_Init(uint32_t *com_id, const struct pios_com_driver *driver, ui
|
||||
|
||||
if ((rx_buffer_len > 0) && !rx_buffer) {
|
||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||
rx_buffer = (uint8_t *)pios_malloc(rx_buffer_len);
|
||||
rx_buffer = (uint8_t *)pios_fastheapmalloc(rx_buffer_len);
|
||||
#endif
|
||||
PIOS_Assert(rx_buffer);
|
||||
}
|
||||
|
||||
if ((tx_buffer_len > 0) && !tx_buffer) {
|
||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||
tx_buffer = (uint8_t *)pios_malloc(tx_buffer_len);
|
||||
tx_buffer = (uint8_t *)pios_fastheapmalloc(tx_buffer_len);
|
||||
#endif
|
||||
PIOS_Assert(tx_buffer);
|
||||
}
|
||||
@ -798,44 +798,6 @@ int32_t PIOS_COM_RegisterAvailableCallback(uint32_t com_id, pios_com_callback_av
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback used to pass data from one ocm port to another in PIOS_COM_LinkComPare.
|
||||
* \param[in] context The "to" com port
|
||||
* \param[in] buf The data buffer
|
||||
* \param[in] buf_len The number of bytes received
|
||||
* \param[in] headroom Not used
|
||||
* \param[in] task_woken Not used
|
||||
*/
|
||||
static uint16_t PIOS_COM_LinkComPairRxCallback(uint32_t context, uint8_t *buf, uint16_t buf_len, __attribute__((unused)) uint16_t *headroom, __attribute__((unused)) bool *task_woken)
|
||||
{
|
||||
int32_t sent = PIOS_COM_SendBufferNonBlocking(context, buf, buf_len);
|
||||
|
||||
if (sent > 0) {
|
||||
return sent;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Link a pair of com ports so that any data arriving on one is sent out the other.
|
||||
* \param[in] com1_id The first com port
|
||||
* \param[in] com2_id The second com port
|
||||
*/
|
||||
void PIOS_COM_LinkComPair(uint32_t com1_id, uint32_t com2_id, bool link_ctrl_line, bool link_baud_rate)
|
||||
{
|
||||
PIOS_COM_ASYNC_RegisterRxCallback(com1_id, PIOS_COM_LinkComPairRxCallback, com2_id);
|
||||
PIOS_COM_ASYNC_RegisterRxCallback(com2_id, PIOS_COM_LinkComPairRxCallback, com1_id);
|
||||
// Optionally link the control like and baudrate changes between the two.
|
||||
if (link_ctrl_line) {
|
||||
PIOS_COM_RegisterCtrlLineCallback(com1_id, (pios_com_callback_ctrl_line)PIOS_COM_SetCtrlLine, com2_id);
|
||||
PIOS_COM_RegisterCtrlLineCallback(com2_id, (pios_com_callback_ctrl_line)PIOS_COM_SetCtrlLine, com1_id);
|
||||
}
|
||||
if (link_baud_rate) {
|
||||
PIOS_COM_RegisterBaudRateCallback(com1_id, (pios_com_callback_baud_rate)PIOS_COM_ChangeBaud, com2_id);
|
||||
PIOS_COM_RegisterBaudRateCallback(com2_id, (pios_com_callback_baud_rate)PIOS_COM_ChangeBaud, com1_id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Invoke driver specific control functions
|
||||
* \param[in] port COM port
|
||||
|
@ -95,7 +95,7 @@ static struct pios_usb_cdc_dev *PIOS_USB_CDC_alloc(void)
|
||||
{
|
||||
struct pios_usb_cdc_dev *usb_cdc_dev;
|
||||
|
||||
usb_cdc_dev = (struct pios_usb_cdc_dev *)pios_malloc(sizeof(struct pios_usb_cdc_dev));
|
||||
usb_cdc_dev = (struct pios_usb_cdc_dev *)pios_fastheapmalloc(sizeof(struct pios_usb_cdc_dev));
|
||||
if (!usb_cdc_dev) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ static struct pios_usb_hid_dev *PIOS_USB_HID_alloc(void)
|
||||
{
|
||||
struct pios_usb_hid_dev *usb_hid_dev;
|
||||
|
||||
usb_hid_dev = (struct pios_usb_hid_dev *)pios_malloc(sizeof(struct pios_usb_hid_dev));
|
||||
usb_hid_dev = (struct pios_usb_hid_dev *)pios_fastheapmalloc(sizeof(struct pios_usb_hid_dev));
|
||||
if (!usb_hid_dev) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ static struct UAVOData *UAVObjAllocSingle(uint32_t num_bytes)
|
||||
uint32_t object_size = sizeof(struct UAVOSingle) + num_bytes;
|
||||
|
||||
/* Allocate the object from the heap */
|
||||
struct UAVOSingle *uavo_single = (struct UAVOSingle *)pios_malloc(object_size);
|
||||
struct UAVOSingle *uavo_single = (struct UAVOSingle *)pios_fastheapmalloc(object_size);
|
||||
|
||||
if (!uavo_single) {
|
||||
return NULL;
|
||||
@ -250,7 +250,7 @@ static struct UAVOData *UAVObjAllocMulti(uint32_t num_bytes)
|
||||
uint32_t object_size = sizeof(struct UAVOMulti) + num_bytes;
|
||||
|
||||
/* Allocate the object from the heap */
|
||||
struct UAVOMulti *uavo_multi = (struct UAVOMulti *)pios_malloc(object_size);
|
||||
struct UAVOMulti *uavo_multi = (struct UAVOMulti *)pios_fastheapmalloc(object_size);
|
||||
|
||||
if (!uavo_multi) {
|
||||
return NULL;
|
||||
@ -1598,7 +1598,7 @@ static InstanceHandle createInstance(struct UAVOData *obj, uint16_t instId)
|
||||
|
||||
/* Create the actual instance */
|
||||
uint32_t size = sizeof(struct UAVOMultiInst) + obj->instance_size;
|
||||
instEntry = (struct UAVOMultiInst *)pios_malloc(size);
|
||||
instEntry = (struct UAVOMultiInst *)pios_fastheapmalloc(size);
|
||||
if (!instEntry) {
|
||||
return NULL;
|
||||
}
|
||||
@ -1687,7 +1687,7 @@ static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue,
|
||||
}
|
||||
|
||||
// Add queue to list
|
||||
event = (struct ObjectEventEntry *)pios_malloc(sizeof(struct ObjectEventEntry));
|
||||
event = (struct ObjectEventEntry *)pios_fastheapmalloc(sizeof(struct ObjectEventEntry));
|
||||
if (event == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user