Bailey O.H.Embedded systems.Desktop integration.2005
.pdf
440 |
Chapter 10 / The PSoC Prototype |
|
|
people. There are several ways to limit access. One method is to check the origination IP address against a list of accepted addresses to see if it is an authorized control station. We could also add a password so that the user could be authenticated, limiting access to specific individuals working from specific workstations. In short, there are many ways to provide controls
prohibiting unauthorized use. The following listing illustrates one way of implementing UDP to connect to the PSoC.
Listing 10-6
/****************************************************************************** UDP Test Program for PSoC – Copyright 2004, Oliver H. Bailey
This program is for Embedded Systems, Desktop Integration Book
*****************************************************************************/
#include "predef.h" #include <stdio.h> #include <ctype.h> #include <startnet.h> #include <ucos.h> #include <udp.h> #include <autoupdate.h> #include <string.h> #include <taskmon.h>
extern "C"
{
void UserMain( void *pd );
}
// We |
have to use 4 byte aligment for the NetBurner |
DWORD |
UdpTestStk[USER_TASK_STK_SIZE] __attribute__( ( aligned( 4 ) ) ); |
/******************************************************************************* The UDP Read Packet Function. - Waits for 100 clock ticks and then returns if no data arrived.
*******************************************************************************/
void UDPRead( void *pd )
{
int UDP_port = |
( int ) pd; |
// |
UDP Port Number assignment |
printf( "Using |
port #%d\n", UDP_port ); |
// |
Print Port Number |
Chapter 10 / The PSoC Prototype |
443 |
|
|
This is a very simple demo for the NetBurner device. We could add multicasting, which allows support for broadcasting temperature data to multiple receivers. The purpose of this program is to get you familiar with the differences between TCP/IP and UDP. It also serves as a simple program that illustrates the process of setting up UDP data handlers in the NetBurner environment.
PSoC Schematics
Chapter 10
Figure 10-25: PSoC schematic
444 |
Chapter 10 / The PSoC Prototype |
||
|
|
|
|
|
|
|
|
|
|
|
|
Figure 10-26: PSoC schematic
Chapter Summary
In this chapter we’ve seen how to implement the thermostat using the Cypress PSoC and EZ-USB. While the PSoC brings more flexibility than any of the other microcontrollers, it comes at the expense of much higher complexity and a deeper understanding of how the microcontroller internals work. The PSoC is a convergence of software and hardware technologies.
Chapter 10 / The PSoC Prototype |
445 |
|
|
Hardware Summary
We have now implemented three different microcontrollers and three different USB interfaces. We have also used several different languages and methods of connecting each different type of interface to the desktop and embedded processor — from the simple to the complex. We could spend thousands of pages on these subjects and still not cover all the available information. The intention is to provide you, the reader, with the information to make a good decision in selecting components. In the course of developing each prototype we have published small code snippets to give you the experience of using different types of software tools and interfaces. For in-depth descriptions, please review the project source files as they contain very detailed information on how the software was implemented and interfaced to system clocks and other microprocessor-specific hardware. In the next and final chapter we look at the tools used to develop cross-platform software.
Chapter 10
This page intentionally left blank.
448 |
Chapter 11 / Cross-Platform Application Development |
|
|
Ethernet, TCP/IP, and UDP
Ethernet is both well defined and well supported across all computers built today. As a wired interface it has become inexpensive and fast, making it the favored way to introduce DSL and cable into a building. Additionally, it is very well documented and supported on all computers as a means for creating and accessing a network. Today’s Ethernet standards have evolved from several different technologies into a solid, well-defined and supported network standard.
The software that makes the Ethernet interface so widely available is TCP/IP. From the desktop integration point of view TCP/IP is supported on every major computing platform available today. Windows, Linux, UNIX, FreeBSD, Macintosh, and even IBM mainframes all support the TCP/IP protocol suite. Of even greater importance is the fact that all of the above mentioned systems are running either Windows, Linux, or a version of BSD as the core operating system, at least at the kernel level. Also of importance is the fact that TCP/IP is supported at the operating system level of all the above mentioned systems and using a common, well-defined and portable interface, the socket library.
With the exception of Microsoft Windows, the Berkeley sockets are the standard interface when using UNIX-, Linux-, or BSD-based systems. This includes the Mac OS X, which is based on the BSD kernel. Microsoft chose to implement a slightly different version known as Winsock. The differences can be distinguished by using the define statements in the program source code, allowing us to have a single source interface to the Ethernet layer of the operating system.
