Coolquest, Inc. Home Products Support About Contact
cbold_logo_gif C++BOLD Example Design: Simple cbold_logo_gif

Design Home <<  File View    Class View Output (partial) Parts Library Examples Home

 

// THIS FILE IS IN THE PUBLIC DOMAIN.
// IT IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
// file simple_sub.h:  example simple subsystem file: LED + resistor passive design with optional LED array
 
#ifndef _simple_sub_h_                           // <=== change these lines to match your file name
#define _simple_sub_h_
 
// This is a simple subsystem header file.                                   <===
// To adapt this file to your design, see comments that contain this arrow:  <===
// See also simple.cpp and simple.h.                                         <===
 
// include header files used by this subsystem, e.g., part header files
#include "leds.h"                                // <=== example part header file -- be sure the included file's directory is in your compiler's include path
#include "headers.h"
#include "resistors.h"

clone( CP_RCHIP805, CP_R110 );                   // define a 110 ohm resistor type that is identical to a CP_RCHIP805 except named CP_R110
clone( CP_RCHIP805, CP_R220 );                   // define a 220 ohm resistor type
 
//===============================================//
//#define USE_LED_ARRAY                          // <=== uncomment this line to implement the LED array
//===============================================//
 
                                                 // <=== if your subsystem has member modules, either define them here or #include their header file(s) here
 
class CM_Simple : public TModule {               // <=== change name (CM_Simple) to match your subsystem name
public:
// ***** member bundles ***** //
                                                 // <=== declare member bundles here
// ***** member ports ***** //
  port VCC;                                      // <=== example member ports
  port GND;
 
// ***** member modules and parts ***** //
 
// type         name                             // <=== example member part declarations
   CP_CHIP_LED  LED_Single;                      // one LED
   CP_R220      R_Single;                        // one 220 ohm resistor for the single LED
   CP_HEADER2   Power;                           // one two-pin header for power connections
// AR_INCL #ifdef USE_LED_ARRAY
   CP_CHIP_LED  LED_Array[ 4 ];                  // array of LED's
   CP_R110      R_Array[   4 ];                  // one 110 ohm resistor for each LED in the array
// AR_INCL #endif

  virtual void Register() {
                                                 // <=== register all member bundles, ports, modules and parts here
    reg(  VCC            );    // auto_reg
    reg(  GND            );    // auto_reg
    reg(  LED_Single     );    // auto_reg
    reg(  R_Single       );    // auto_reg
    reg(  Power          );    // auto_reg
    #ifdef USE_LED_ARRAY       // auto_reg
    rega( LED_Array, 4   );    // auto_reg
    rega( R_Array, 4     );    // auto_reg
    #endif                     // auto_reg
  }
 
  virtual void Connect() {
                                                 // <=== example internal connections
    VCC << Power.P( 1 );
    GND << Power.P( 2 );

    VCC    ^ R_Single ^     "ANODE_S"             << LED_Single.ANODE;
    GND                                           << LED_Single.CATHODE;
    #ifdef USE_LED_ARRAY
      bus( "ANODE_A", 3, 0 );

      for ( int i = 0; i < 4; ++ i ) {
        VCC  ^ R_Array[ i ] ^ bus( "ANODE_A" )( i ) << LED_Array[ i ].ANODE;
        GND                                         << LED_Array[ i ].CATHODE;
      }
    #endif
  }
};
 
#endif

 

Design Home <<  File View    Class View Output (partial) Parts Library Examples Home

Legal Copyright © 2007 by Coolquest, Inc. Contact