PSoC Creator Schematic Page Enable/Disable Sample

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

Are these rubbishy ideas?

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

000-all_page_enabed.JPG

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)

000-main_c.JPG

When the program started, we see the splash like below

Figure 3. Splash Screen (original)

002-splash.JPG

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)

001-main_c.JPG

Now to test if it works, the way I expected,

at first I disabled "spi".

Figure 5. disabling the "spi" schematic page

010_disable_spi.JPG

Figure 6. "spi" page disabled

011-spi_disabled.JPG

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

013-cydisabledsheets_h.JPG

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)

014-main_c.JPG

Then I compiled and ran the program.

NOTE: There was no more "spi" command.

Figure 9. Splash Screen (spi is gone)

013-splash.JPG

I tried to disable all but "tty."

Figure 10. all but "tty" page disabled

020-all-but-tty-diabled.JPG

main.c now look like

Figure 11. function / menu definition in main.c (all but "tty" disabled)

021-main_c.JPG

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

023-adc_utils_h.JPG

The splash is now quite deserted.

Figure 13. Splash Screen (with 5 schematic pages disabled)

022-splash.JPG

Then to test "recover", I  enabled all the schematic pages, again.

Figure 14. All schematic pages enabled

030-all-enabed.JPG

The "main.c" seems

Figure 15. function / menu definition in main.c (all schematic pages enabled)

031-main_c.JPG

The splash screen also shows usual appearance.

Welcome back to the ordinary day!

Figure 16. Splash with all schematic pages enabed

032-splash.JPG

Attached is the MCU_Tester project for CY8CKIT-044 with the page enable/disable ready.

moto

0 Replies