前段时间去搞其他东西,加上放假,这两天重新调查,终于找到了问题的根源。
先说下之前卡住在那里,那是一个查询块是不是空的判断。下面会说到这个查询为什么不是空的。
用cubeMX生成工程的时候,在TouchGFXGenerateHal.cpp里面有两个函数
[C] 纯文本查看 复制代码 void TouchGFXGeneratedHAL::flushFrameBuffer(const touchgfx::Rect& rect)
{
HAL::flushFrameBuffer(rect);
// Once flushFrameBuffer() is called by the framework a block is already for transfer
// Mark it ready for transfer and transmit it if user defined method isTransmittingData() does not return false
// If data is not being transmitted, transfer the data with user defined method transmitFrameBufferBlock().
frameBufferAllocator->markBlockReadyForTransfer();
if (!touchgfxDisplayDriverTransmitActive())
{
touchgfx::Rect r;
// Get pointer to block buffer and coordinates of the rect
const uint8_t* pixels = frameBufferAllocator->getBlockForTransfer(r);
// Start transmission of the block
touchgfxDisplayDriverTransmitBlock((uint8_t*)pixels, r.x, r.y, r.width, r.height);
}
}
和
[C] 纯文本查看 复制代码 // A user must call touchgfx::startNewTransfer(); once transmitFrameBufferBlock() has successfully sent a block.
void startNewTransfer()
{
FrameBufferAllocator* fba = HAL::getInstance()->getFrameBufferAllocator();
// Free the previous transmitted block, marking it ready for rendering
fba->freeBlockAfterTransfer();
if (fba->hasBlockReadyForTransfer())
{
touchgfx::Rect r;
// Get pointer to block buffer and coordinates of the rect
const uint8_t* pixels = fba->getBlockForTransfer(r);
// Start transmission of the block
touchgfxDisplayDriverTransmitBlock((uint8_t*)pixels, r.x, r.y, r.width, r.height);
}
}
这两个函数是一样功能的,不知道为什么工具要生成后面这个startNewTransfer函数。
这个函数,是在另一个函数里面调用的
[C] 纯文本查看 复制代码 extern "C"
void DisplayDriver_TransferCompleteCallback()
{
// After completed transmission start new transfer if blocks are ready.
touchgfx::startNewTransfer();
}
这个函数是在spi,或者dma传输完成后调用的。这里的功能只是告诉touchGFX传输完成了,可以去清理掉那个块。
但由于startNewTransfer这个还加了
[C] 纯文本查看 复制代码 if (fba->hasBlockReadyForTransfer())
{
touchgfx::Rect r;
// Get pointer to block buffer and coordinates of the rect
const uint8_t* pixels = fba->getBlockForTransfer(r);
// Start transmission of the block
touchgfxDisplayDriverTransmitBlock((uint8_t*)pixels, r.x, r.y, r.width, r.height);
}
这一段,所以这里会将下一块的状态改为SENDING,也就是执行了 fba->getBlockForTransfer(r)这个。
所以解决办法就是将这一段函数里面的if后面全部屏蔽掉。这个只做释放当前块的操作就行。
[C] 纯文本查看 复制代码 // A user must call touchgfx::startNewTransfer(); once transmitFrameBufferBlock() has successfully sent a block.
void startNewTransfer()
{
FrameBufferAllocator* fba = HAL::getInstance()->getFrameBufferAllocator();
// Free the previous transmitted block, marking it ready for rendering
fba->freeBlockAfterTransfer();
// if (fba->hasBlockReadyForTransfer())
// {
// touchgfx::Rect r;
// // Get pointer to block buffer and coordinates of the rect
// const uint8_t* pixels = fba->getBlockForTransfer(r);
// // Start transmission of the block
// touchgfxDisplayDriverTransmitBlock((uint8_t*)pixels, r.x, r.y, r.width, r.height);
// }
}
|