Index

Arduino Multi-Processor

Hardware Design

Bus Organisation

Library Software

  1. Port Registers

The Bus Controller

Node Identifiers

Miscellaneous Functions

Programming Techniques

Schematics

Firmware


images/7-1.png

Miscellaneous Functions



The DataFlow library provides a few other functions which have not been described above.

The connection structure defined by the library is very simple and allows the classes which define processing node behaviour to be interconnected by the main program without each task needing to keep track of explicit node identifiers and port numbers.

typedef struct connection
{
  byte node, port;
};

connection link(byte node, byte port)
{
  connection c;
  c.node = node;
  c.port = port;
  return c;
}

connection link(byte node)
{
  return link(node, 1);
}


The 2 versions of the link function generate connections to a specific node using a specific port, or to a node assuming the default port number 1.

In addition to the send_to and receive_on functions for byte data there are also functions for communicating other types of data. As the library is specific to the ATmega 328 based hardware, types such as byte, int and long are used in preference to the rather ugly size specific variants, e.g. uint8_t. The function signatures are as follows.

void send_int_to(int value, connection c);

void send_int_to(int value, byte sink, byte port);

void send_long_to(long value, connection c);

void send_long_to(long value, byte sink, byte port);

void send_float_to(float value, connection c);

void send_float_to(float value, byte sink, byte port);

int receive_int_on(byte port);

int receive_long_on(byte port);

int receive_float_on(byte port);


It is important that when a processing node sends a value of a particular type, the intended receiver uses the complementary receive function to receive the same type, i.e. send_int_to matches receive_int_on. The intended type has therefore been made explicit in the send function names rather than using function overloading.

Next: Programming Techniques