diff --git a/platform/drivers/display/HX83XX_MDx.c b/platform/drivers/display/HX83XX_MDx.c index e76b597f..165b0a5e 100644 --- a/platform/drivers/display/HX83XX_MDx.c +++ b/platform/drivers/display/HX83XX_MDx.c @@ -88,10 +88,10 @@ #define LCD_FSMC_ADDR_DATA 0x60040000 /* - * LCD framebuffer, allocated on the heap by display_init(). + * LCD framebuffer, statically allocated. * Pixel format is RGB565, 16 bit per pixel */ -static uint16_t *frameBuffer; +static uint16_t frameBuffer[SCREEN_WIDTH * SCREEN_HEIGHT]; void __attribute__((used)) DMA2_Stream7_IRQHandler() { @@ -113,19 +113,8 @@ static inline __attribute__((__always_inline__)) void writeData(uint8_t val) void display_init() { - /* Framebuffer size, in bytes */ - const size_t fbSize = SCREEN_WIDTH * SCREEN_HEIGHT * sizeof(uint16_t); - - /* Allocate framebuffer, two bytes per pixel */ - frameBuffer = (uint16_t *) malloc(fbSize); - if(frameBuffer == NULL) - { - printf("*** LCD ERROR: cannot allocate framebuffer! ***"); - return; - } - /* Clear framebuffer, setting all pixels to 0xFFFF makes the screen white */ - memset(frameBuffer, 0xFF, fbSize); + memset(frameBuffer, 0xFF, SCREEN_WIDTH * SCREEN_HEIGHT * sizeof(uint16_t)); /* * Turn on DMA2 and configure its interrupt. DMA is used to transfer the @@ -335,11 +324,6 @@ void display_terminate() /* Shut off FSMC and deallocate framebuffer */ RCC->AHB3ENR &= ~RCC_AHB3ENR_FSMCEN; __DSB(); - - if(frameBuffer != NULL) - { - free(frameBuffer); - } } void display_renderRows(uint8_t startRow, uint8_t endRow) diff --git a/platform/mcu/STM32F4xx/drivers/usb_vcom.c b/platform/mcu/STM32F4xx/drivers/usb_vcom.c index e2f59d87..43dab47a 100644 --- a/platform/mcu/STM32F4xx/drivers/usb_vcom.c +++ b/platform/mcu/STM32F4xx/drivers/usb_vcom.c @@ -39,11 +39,12 @@ static __IO uint32_t usbd_cdc_AltSet = 0; uint8_t outEnpBuffer[CDC_DATA_OUT_PACKET_SIZE]; /* Circular buffer for incoming data enqueuement: each packet coming from host - * is stored here, eventually erasing oldest data + * is stored here, eventually erasing oldest data. + * Buffer is statically allocated. */ struct rb { - uint8_t *data; + uint8_t data[RX_RING_BUF_SIZE]; size_t readPtr; size_t writePtr; } @@ -203,9 +204,6 @@ int vcom_init() rxRingBuf.readPtr = 0; rxRingBuf.writePtr = 0; - rxRingBuf.data = (uint8_t *) malloc(RX_RING_BUF_SIZE); - if(rxRingBuf.data == NULL) return -1; - USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb); @@ -277,9 +275,6 @@ static uint8_t usbd_cdc_DeInit (void *pdev, uint8_t cfgidx) /* Open Command IN EP */ DCD_EP_Close(pdev,CDC_CMD_EP); - /* Deallocate RX buffer */ - if(rxRingBuf.data != NULL) free(rxRingBuf.data); - return USBD_OK; }