manufacturer of I/O-rich SBCs, operator interfaces, handheld instruments, and development tools for embedded control low cost single board computers, embedded controllers, and operator interfaces for scientific instruments & industrial control development tools for embedded control order our low cost I/O-rich embedded control products embedded controller manufacturer profile single board computers & embedded controllers development tools & starter kits for your embedded design operator interfaces with touchscreens and graphical user interface plug-in expansion modules for digital & analog I/O C language & Forth language integrated development tools, IDE single board and embedded computer accessories embedded controller enclosures, bezels, environmental gaskets

Table of Contents

Introduction

USB Wildcard Specifications

USB Overview

Data Rates

USB Cables and Receptacles

Powering Options

USB Wildcard Hardware

Connecting To the Wildcard Bus

Selecting the Wildcard Address

Self Power/Bus Power Jumper

PC Driver Software

Customizing the EEPROM on the USB Wildcard

Using the Windows Device Manager to View USB Properties

Using the Mosaic Terminal with the USB Wildcard

Mosaic USB Driver Software

Installing the Mosaic USB Wildcard Driver Software

Using the Mosaic USB Driver Code with C

Using the Mosaic USB Driver Code with Forth

Glossary of Mosaic USB Driver Functions

Overview of Glossary Notation

Glossary Quick Reference

Glossary Entries

C Demonstration Program

Forth Demonstration Program

Hardware Schematics, pdf

The USB Wildcard User Guide

<< Previous | Next>>

C Demonstration Program

This section presents the ANSI C version of the demonstration program source code.

 

// ****************************************************************************************

// FILE NAME:   USBDemo.c

// copyright 2007 Mosaic Industries, Inc. All rights reserved.

// ---------------------------------------------------------------------

// DATE:        1/9/2007

// VERSION:     1.0, for QED/Q-Line (HC-11) and PDQ line (HCS-12) controllers

// ---------------------------------------------------------------------

// This is the demonstration code for the USB Wildcard.

// Please see its User Guide for more details.

// QED/Q-Line:

// The USB Wildcard kernel extension file Install.txt

// MUST be loaded into memory before this file can be loaded.

 

// This is an illustrative demonstration ("demo") program that

// shows how to run a task using the USB Wildcard serial port. The task simply

// echoes incoming characters back to the terminal.

 

// When the top level function main() is running, the controller

// is simultaneously using 2 serial ports:

// the standard primary serial port is running the QED interactive monitor,

// and the USB serial channel on the USB Wildcard is echoing characters.

//

// The QED operating system supports revectorable I/O, meaning that

// in any given task the standard C serial I/O routines such as

// putchar, puts, getchar, gets, printf, and scanf can be made to use

// any specified serial channel.  All that is required is to customize

// three functions named Key, AskKey, and Emit to the specified serial channel

// for the specified task.  This file shows how to do this

// using the functions defined in the USB Wildcard kernel extension.

//

// MAKE SURE THAT THE USB_MODULE_NUM CONSTANT MATCHES YOUR HARDWARE JUMPER SETTINGS!!

 

// ---------------------------------------------------------------------

// Demonstration functions defined in this file:

// USB_MODULE_NUM  // this constant MUST match hardware jumper settings!

// void USB_Monitor(void)  // infinite task loop, echoes all incoming chars on usb

// void USB_Demo(void)

    // builds and activates an echoing monitor task on the usb port,

    // leaving the standard monitor running on the rs232 port.

// void main(void) // runs the demo program

 

// ---------------------------------------------------------------------

// Disclaimer: THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT

//             ANY WARRANTIES OR REPRESENTATIONS EXPRESS OR IMPLIED,

//             INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES

//             OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

//

// *********************************************************************

 

#ifdef __GNUC__

// For PDQ line platforms, the driver is enabled by simply including

// the header file below.

#include <Mosaic_12/allqed.h>

#include <stdio.h>

#include <stdlib.h>

#include <usb_wildcard_driver.h>

 

#else

// For the QED/Q line platform, we include the kernel extension manager

// generated library.c.  We assume that it is present in this directory.

#include <mosaic/allqed.h>

#include "library.h"

#include "library.c"

#endif       // __GNU__

 

 

 

// ******************* DEMONSTRATION PROGRAM ***************************

 

// The default task runs an interactive monitor as usual, using the 68HC11 UART.

// We create a second task that echoes all incoming chars via the USB Wildcard serial port.

// To run this demonstration, simply execute:

//       main

// You'll be running the standard monitor on the RS232 port,

// plus an independent serial-echo task on the USB port.

// You can open two instances of the Mosaic terminal, one for each task,

// and interact with both tasks.  Use the terminal's

// Settings -> Comm -> Port menu item to specify the USB's comm port.

 

// NOTE: YOU MUST MAKE SURE THAT USB_MODULE_NUM CONSTANT MATCHES YOUR HARDWARE JUMPERS!!

#define USB_MODULE_NUM 1   // double check your hardware jumper settings!!!

 

 

// Define and allocate RAM for the task areas:

TASK     usb_task;  // 1 Kbyte per task area

 

void USB_Monitor(void)

    // infinite task loop for usb_task, simply echoes all incoming chars on usb

{   uchar this_char;

    USB_Revector();

    printf("Ready to echo incoming characters on USB...\r\n");

    while(1)   // infinite task loop

    {   this_char = getchar();

        if( this_char == '\r')

             this_char = '\n'; // substitute linefeed for cr, ansi-c style

        putchar(this_char); // automatically adds cr in front of linefeed

    }

}

 

void USB_Demo(void)

    // builds and activates an echoing monitor task on the usb port,

    // leaving the standard monitor running on the rs232 port.

{   usb_module = USB_MODULE_NUM;

    printf("\nStarting USB Wildcard Demo...\r\n");

    SERIAL_ACCESS = RELEASE_ALWAYS; // ensure lots of PAUSEs in Forth task

    NEXT_TASK = TASKBASE;  // required! empty the round-robin task loop

    BUILD_C_TASK(0,0,&usb_task); // no heap needed

    ACTIVATE(USB_Monitor,&usb_task);

    StartTimeslicer();  // enable task switching

}

 

 

void main(void)

{   USB_Demo();

    printf("USB Demo task has been set up; use the Mosaic Terminal to exercise it.\r\n");

}

 

 

<< Previous | Next>>


Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2012 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation