DL40 Module (DaisyLink)

This document is obsolete.

Last modified August 8, 2014

DL40 Module (DaisyLink)

Required

Tutorials:  First Gadgeteer Project

Introduction

This module extends any mainboard with a 32bit 50Mhz co-processor. This processor handled gadgeteer's daisylink protocol but from there, the user can extend that in any way they like. Use the module to create a new daisylink module or use to handle time critical tasks.

One good example would be in creating a parallel port module to handle stepper motors. Stepper-motor-controller boards use pulses to move the motors. Generating these steps from managed code running on mainboard is not a good idea. Instead, the mainboard can send a command to the co-processor running on the module telling it to pulse a specific pin. The co-processor then handles the pulses. This module actually exists; see ParallelCNC_Module

GHI provides complete keil code project to run on DL4-0 and also provide the needed communication drivers on C# side.

Some information on programming the DL40 using Jlink and SWD can be found in http://www.ghielectronics.com/docs/146/programming-the-dl40-using-jlink-and-swd

There are no limits on what can be done with the co-processor. This is a must have module for all gadgeteer users.

Example 1: Blink an LED

This example will change state of P2.5 on DL40. Connect a LED to that pin, LED will blink.

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
 
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
 
namespace Test_DL40_Firmware
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            new Thread(ThreadTest).Start();
            Debug.Print("Program Started");
        }
        void ThreadTest()
        {
            while (true)
            {
                Thread.Sleep(100);
                WriteGPIO(genericDaisylink, 2, 5, HIGH);
                Thread.Sleep(100);
                WriteGPIO(genericDaisylink, 2, 5, LOW);
                byte read = ReadGPIO(genericDaisylink, 2, 7);
                Debug.Print("P2.7 = " + read);
                Thread.Sleep(100);
            }
        }
 
        void WriteGPIO(GenericDaisylink dlmodule, byte port, byte pin, byte value)
        {
            dlmodule.WriteRegister(PORT_REGISTER, port);
            dlmodule.WriteRegister(PIN_REGISTER, pin);
            dlmodule.WriteRegister(DIR_REGISTER, DIR_OUTPUT);
            dlmodule.WriteRegister(VALUE_REGISTER, value);
            dlmodule.WriteRegister(ACTIVE_REGISTER, REG_ACT_ENABLE);
        }
        byte ReadGPIO(GenericDaisylink dlmodule, byte port, byte pin)
        {
            dlmodule.WriteRegister(PORT_REGISTER, port);
            dlmodule.WriteRegister(PIN_REGISTER, pin);
            dlmodule.WriteRegister(DIR_REGISTER, DIR_INPUT);
            dlmodule.WriteRegister(ACTIVE_REGISTER, REG_ACT_ENABLE);
            return dlmodule.ReadRegister(REG_READ_START_INDEX + VALUE_REGISTER);
        }
 
        // Define DL40 register
        const int PORT_REGISTER = 0x1;
        const int PIN_REGISTER = 0x2;
        const int DIR_REGISTER = 0x3;
        const int VALUE_REGISTER = 0x4;
        const int ACTIVE_REGISTER = 0x0;
        // Define DL40 pin dir
        const int DIR_INPUT = 0x0;
        const int DIR_OUTPUT = 0x1;
        // Define active register value
        const int REG_ACT_DISABLE = 0x0;
        const int REG_ACT_ENABLE = 0x1;
        // Define pin state
        const int LOW = 0x0;
        const int HIGH = 0x1;
        // Define start Read register index
        const int REG_READ_START_INDEX = 8;
    }
}

Open Daisylink source code

The source code for this module's processor can be found here:http://www.ghielectronics.com/downloads/src/DL40_firmware_sources.zip . For more information on Open Daisylink, including how to reflash the board, see this page.

Another Source for Driver

Another soruce for DL40-IO module Firmware and Driver is found on codeplex: http://dl40io.codeplex.com/

Leave feedback about this document.
Let us know if the information presented here was accurate, helpful and if you have any suggestions.
Leave feedback about this document.
Let us know if the information presented here was accurate, helpful and if you have any suggestions.

* Indicates required fields.
This form is only for feedback not support.
Review our how to find information guide on locating helpful resources.