Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Example Return Values #317

Merged
merged 18 commits into from
Jan 19, 2023
Merged

Conversation

Jake-Carter
Copy link
Contributor

@karaanil Continuation of #218

@Jake-Carter Jake-Carter mentioned this pull request Jan 2, 2023
@Jake-Carter Jake-Carter requested review from karaanil and ozersa January 2, 2023 23:43
@EdwinFairchild
Copy link
Contributor

should be able to merge main into this for new CI-test.

}

while (1) {}

return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line might cause warning, like unreachable point...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ozersa and @Jake-Carter Can you build MAX32572 samples? When I import the projects on Eclipse I am seeing "Preprocessor Include Path/Entries/GNU C/CDT Cross GCC Built-in Compiler Settings" as empty. Therefore, the project can not find gcc command. This is why I have skipped MAX32572 samples.

} else {
printf(" Passed \n");
return 0;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better just returning result,
The success return value must be consistent (zero) but fail case can be different (non-zero).
Instead of increasing code line just returning result will be better.
Please apply same idea for other cases in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ozersa this is an internal function. Moreover, such change may require many changes on other projects. Isn't it better to skip such change in our first iteration and somehow achieve to merge. @Jake-Carter what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karaanil I agree with @ozersa that this small internal function is probably not necessary.

If you really wanted to inform the user which CRCs are failing, I would suggest a simple printf like below.

int Test_CRC(int asynchronous) 
{
    // ... 

    ret = (CHECK != crc_req.resultCRC);
    if (ret) printf( "Failed CRC check! Received: %x\tExpected: %x\n", crc_req.resultCRC, CHECK);
    MXC_CTB_Shutdown(MXC_CTB_FEATURE_CRC | MXC_CTB_FEATURE_DMA);
    return ret;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like only the CRC examples would need this cleanup

} else {
printf(" Passed \n");
return 0;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


printf("\nExample complete.\n");
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might give warning (unreachable line...), please check it.

}

while (1) {}

return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
printf(" Passed \n\n");
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment...

} else {
printf("Example Failed\n");
return -1;
}

return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return -1;
}

return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
printf("Example Failed\n\n");
return -1;
}
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

while (1) {}
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -140,11 +140,12 @@ int main(void)

if (fail) {
printf("\Example Failed");
Copy link
Contributor

@ozersa ozersa Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related this PR but please fix typo add \n,
\E might cause some issue

} else {
printf("-->EXAMPLE SUCCEEDED\n");
}

while (1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR shall not change example functionality (as possible as),
In this case at the end of example led blinks, instead of removing this feature you should add a counter to blink the led n times, n can be 10.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ozersa which line blinks the LED? I am seeing that it is either off or on. Since GPIO's will preserve the state after code finishes, it should work as before. Am I wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is okay that we have such a while loop at the end. However, I am checking the code and it initially has blocking empty while loops at the top that changed to a simple return. I mean this portion mostly is not executed. Moreover, the other UART examples do not have such a loop in their original form. Therefore, removing this portion makes this example similar to the other UART examples.
Do we really need such a portion? Why others do not have it but MAX32660 has? @ozersa

@@ -218,15 +218,10 @@ int main(void)
if (fail != 0) {
LED_On(0);
printf("-->EXAMPLE FAILED\n");
while (1) {}
return E_FAIL;
} else {
printf("-->EXAMPLE SUCCEEDED\n");
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -45,6 +45,7 @@
#include "board.h"
#include "dma.h"
#include "aes.h"
#include "aes_regs.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed to include aes_regs.h file
aes.h file include it.

@@ -47,6 +47,7 @@
#include "nvic_table.h"
#include "flc.h"
#include "icc.h"
#include "flc_regs.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include flc_regs.h file flc.h already include it.

@@ -45,6 +45,7 @@
#include "mxc_device.h"
#include "nvic_table.h"
#include "dma.h"
#include "dma_regs.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include dma_regs.h file dma.h already include it.

@@ -45,6 +45,7 @@
#include "mxc_device.h"
#include "nvic_table.h"
#include "dma.h"
#include "dma_regs.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include dma_regs.h file. dma.h already include it.

@@ -45,6 +45,7 @@
#include "board.h"
#include "dma.h"
#include "aes.h"
#include "aes_regs.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include aes_regs.h file.

@@ -45,6 +45,7 @@
#include "mxc_device.h"
#include "nvic_table.h"
#include "dma.h"
#include "dma_regs.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no needed include.

@@ -47,6 +47,7 @@
#include "nvic_table.h"
#include "flc.h"
#include "icc.h"
#include "flc_regs.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor

@ozersa ozersa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unneeded code lines and includes should not be added
The example functionality shall not be change as possible as.

@ozersa ozersa force-pushed the dev-examples-return-value-update branch from 8cfcc0b to cabb35b Compare January 19, 2023 11:22
Standardize return message and value for single shot ones

Signed-off-by: Sadik.Ozer <sadik.ozer@analog.com>
@ozersa ozersa force-pushed the dev-examples-return-value-update branch from cabb35b to 18a33e1 Compare January 19, 2023 11:39
Copy link
Contributor

@ozersa ozersa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related changes has been applied.

@ozersa
Copy link
Contributor

ozersa commented Jan 19, 2023

@Jake-Carter Could it be merged as soon as possible?
The PR effect too many examples so that if it not been merged in a short term, it will be out of date and more conflict will occur in future that will cause extra rework...
I will appreciate if it to be merged as soon as possible.

@Jake-Carter Jake-Carter merged commit 2591919 into main Jan 19, 2023
@Jake-Carter
Copy link
Contributor Author

@ozersa Of course, just merged

@Jake-Carter Jake-Carter deleted the dev-examples-return-value-update branch January 19, 2023 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants