The goal of this project is to provide a Generic DaisyLink firmware and module driver for the
DL40 Gadgeteer Module
The DL40 Module provides a hardware platform which can be used to develop custom Daisy Link Modules, this firmware transforms the DL40 module into a general purpose IO device that can easily be leveraged from any .NET MF mainboard.
The managed interface used to communicate with the firmware on DL40 provides the following interfaces.
Configures a pin as an input pin and provides functions to read the current state of the pin
Configures a pin as an output pin and provides functions to change the state of the pin
Configures a pin as an input pin which can raise interrupts when the state of the pin changes. When initializing the interrupt pin you can select which state changes will raise interrupts and those interrupts will be propagated back to the .NETMF mainboard.
Configures a pin as an input pin which will count the number of state changes it undergoes. At any point in time the mainboard can query for the current count which can either be automatically be reset when read or reset on demand from the mainboard.
- This interface supports two counter types. A general purpose counter which can be used to count pulses on any of the general purpose IO pins on the module and a capture pin counter which is limited to counting pulses on specific pins which are wired to
the internal timer peripherals of the DL40 chip. The general purpose counter can count pulses at frequencies of up to 150kHz, while the capture pins can count pulses at frequencies of 12MHz.
Provides access to 6 of the analog input pins on the DL40 chip
Provides the ability to generate PWM signals on the supported pins on the module. PWM can be used to control things like servo motors or the GHI Motor Driver etc.
Interrupt pins can be configured to raise interrupts on any of the following states
- An interrupt is raised every time the pin transitions from a low state to a high state
- An interrupt is raised every time the pin transitions from a high state to a low state
- An interrupt is raised every time the pin changes from one state to another
- An interrupt is raised continuously for the entire period that the pin is in the high state
- An interrupt is raised continuously for the entire period that the pin is in the low state
1. Create an instance of the driver on the mainboard
// Create an instance of the DLIOModule attached to Gadgeteer Socket 3
var module = new DLIOModule(3);
2. Setup an analog pin on the DL40 and read the value
// Setup AnalogPin
IAnalogInputPin AD1 = module.CreateAnalogInputPin(AnalogInputPinId.PIO1_4);
// Read the raw value
uint value = AD1.ReadRaw();
// Read the value as a double in the range 0..1
double proc1 = AD1.Read();
3. Create a pin to count the number of pulse on a pin
// Create a Capture Pin using Timer 0, which is a 16 bit timer capturing pin 0.2
IPulseCounterPin Counter = module.CreateCapturePin(CapturePinId.Capture16_0_2,
// Read the count
long reading = Counter.ReadCounter();
4. Setup and and respond to an interrupt pin
// Setup the interrupt pin
IInterruptPin InterruptPin = Module.CreateInterruptPin(3, 1,
// Wire the interrupt handler
InterruptPin.Interrupt += new PinInterruptHandler(Pin_Interrupt);
// Interrupt handler called when an interrupt is raised on the DL40 pin
void Pin_Interrupt(IInterruptPin pin, uint interruptCount)