Skip to main content
BTurc.2
Senior
Solved

How it works the return??

Hello all,

I'm using the HAL library for the camera, specifically I'm using the function:

 HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef *hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)

In the function are many return HAL_ERROR, and one HAL_OK. When the function works fine It return a 0, but when I have an error it return 2.

Why It retuns 2 if the HAL_ERROR is defined as 1 when I have an error.

This topic has been closed for replies.
LCE
LCEBest answer
Principal III

I think 2 is busy:

typedef enum
{
 HAL_OK = 0x00U,
 HAL_ERROR = 0x01U,
 HAL_BUSY = 0x02U,
 HAL_TIMEOUT = 0x03U
} HAL_StatusTypeDef;

5 replies

LCE
LCEBest answer
Principal III

I think 2 is busy:

typedef enum
{
 HAL_OK = 0x00U,
 HAL_ERROR = 0x01U,
 HAL_BUSY = 0x02U,
 HAL_TIMEOUT = 0x03U
} HAL_StatusTypeDef;

BTurc.2
BTurc.2Author
Senior

Ohh, Okey, I see that a function inside could return a HAL_BUSY, but the main function only could return HAL_OK and HAL_ERROR, so why It return the HAL_BUSY??. The return of the subfunction is only used in the subfunction no??

LCE
Principal III

I don't know that function.

Check it again, then debug it.

Mike_ST
ST Technical Moderator

Hello,

if you have:

status = function(...);

and later you have

return status;

then status might be the return value of the sub-function.

As LCE wrote, please use the debugger so you can better understand where you get HAL_BUSY.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
BTurc.2
BTurc.2Author
Senior

I will try to debug it! Thanks for the help!