User guide

Neuron C Programmer’s Guide vii
Table of Contents
Welcome.........................................................................................................iii
Audience ........................................................................................................iii
Related Documentation ................................................................................ iv
Typographic Conventions for Syntax...........................................................iv
Chapter 1. Overview .......................................................................................... 1
What Is Neuron C?......................................................................................... 2
Comparing Neuron C Version 2 to Version 1 ........................................ 2
Unique Aspects of Neuron C ......................................................................... 3
Neuron C Integer Constants...................................................................4
Neuron C Variables ................................................................................. 5
Neuron C Variable Types .................................................................5
Neuron C Storage Classes ................................................................ 6
Variable Initialization ...................................................................... 7
Neuron C Declarations ..................................................................... 7
Network Variables, SNVTs, and UNVTs............................................... 8
Configuration Properties......................................................................... 9
Functional Blocks and Functional Profiles.......................................... 10
Data-Driven Compared with Command-Driven Protocols........... 11
Event-Driven Scheduling or Polled Scheduling ..................................11
Low-Level Messaging ............................................................................ 11
I/O Devices ............................................................................................. 11
Neuron-Hosted and Host-Based Compilation ............................................ 12
Differences between Neuron C and ANSI C............................................... 13
Chapter 2. Focusing on a Single Device.......................................................... 15
What Happens on a Single Device? ............................................................ 16
The Scheduler............................................................................................... 16
When Clauses ........................................................................................ 16
When Statement .................................................................................... 17
Types of Events Used in When Clauses............................................... 18
Predefined Events ................................................................................. 18
Event Processing............................................................................. 20
Reset Event ..................................................................................... 21
User-Defined Events ............................................................................. 22
Scheduling of When Clauses.................................................................22
Priority When Clauses .......................................................................... 23
Interrupts............................................................................................... 24
Function Prototypes .............................................................................. 24
Timers ........................................................................................................... 25
Declaring Timers ................................................................................... 25
Examples ......................................................................................... 26
The timer_expires Event....................................................................... 26
Input/Output ................................................................................................ 27
I/O Object Types .................................................................................... 28
Declaring I/O Objects in Neuron C.......................................................29
Device Self-Documentation .........................................................................30
Examples ...................................................................................................... 30
Example 1: Thermostat Interface........................................................31
Example 2: Simple Light Dimmer Interface....................................... 33
Example 3: Seven-Segment LED Display Interface........................... 35
Input Clock Frequency and Timer Accuracy..............................................36