- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This morning I came across with the following discussion.
PSoC Creator: Enable/Disable schematic page
In the discussion, /odissey1-san, suggested to refer to the following page
In the last answer of series of questions, there was information about
when we disabled a schematic page.
If we disable a schematic page, for example Page_2,
and generate application, there will be an additional header called "cydisabledsheets.h"
And the contents of "cydisabledsheets.h" would be
=====================
#ifndef INCLUDED_CYDISABLEDSHEETS_H
#define INCLUDED_CYDISABLEDSHEETS_H
#define Page_2__DISABLED 1u /* Page 2 */
#endif /* INCLUDED_CYDISABLEDSHEETS_H */
=====================
This means we can refer to "page"__DISABLED definition to determine if we should enable a component
and/or its associated functions.
Now in my MCU_Tester project, I have 6 schematic pages, "tty", "pwm", "adc", "i2c", "gpio", and "spi."
Each of them has only the related component.
Figure 1. schematic pages
And in "main.c" I define the top_level functions of each component along with the menu table.
Figure 2. function / menu definition in main.c (original)
When the program started, we see the splash like below
Figure 3. Splash Screen (original)
So to support page enable/disable, I modified this part as below.
If "spi__DISABLED" is not true,
define function
void do_spi(void) ;
and add menu item
{ "spi", do_spi, "spi test" },
and did same for "pwm", "adc", "i2c", "gpio."
Since if I disable "tty" this program won't be functional,
I made it an exception.
Figure 4. function / menu definition in main.c (modified)
Now to test if it works, the way I expected,
at first I disabled "spi".
Figure 5. disabling the "spi" schematic page
Figure 6. "spi" page disabled
Then I generated the application with "generate application" icon.
There appeared "cydisabledsheets.h" in the Workspace Explorer.
The contents of "cydisabledshets.h" was
Figure 7. "cydisabledsheets.h" with "spi" disabled
Now the main.c looked like below.
Note: spi related function and menu are now disabled, too.
Figure 8. function / menu definition in main.c (spi disabled)
Then I compiled and ran the program.
NOTE: There was no more "spi" command.
Figure 9. Splash Screen (spi is gone)
I tried to disable all but "tty."
Figure 10. all but "tty" page disabled
main.c now look like
Figure 11. function / menu definition in main.c (all but "tty" disabled)
But to compile this, I had a few problems, as some source files are referencing the defined values for the component(s).
Namely adc and i2c had problems.
So for the" adc_utils.h" and "adc_utils.c" I added #if !adc_DISABLED ~ #endif after the line #include "project.h"
And did similarly for i2c related headers and sources.
Figure 12. "adc_utils.h" with #if !adc__DISABLED added to support page enable/disable
The splash is now quite deserted.
Figure 13. Splash Screen (with 5 schematic pages disabled)
Then to test "recover", I enabled all the schematic pages, again.
Figure 14. All schematic pages enabled
The "main.c" seems
Figure 15. function / menu definition in main.c (all schematic pages enabled)
The splash screen also shows usual appearance.
Welcome back to the ordinary day!
Figure 16. Splash with all schematic pages enabed
Attached is the MCU_Tester project for CY8CKIT-044 with the page enable/disable ready.
moto
- Labels:
-
ispn:39614:1:0
-
l1:314:1:0
-
PSoC345LP
-
Tips