Introduction to .NET Micro Framework Development

5,298 views

Published on

An introduction to the .NET Micro Framework and the type of devices it is designed to help implement. Uses the Device Solutions Tahoe development board for a couple of demonstrations which builds a kitchen timer.

Published in: Technology, News & Politics
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,298
On SlideShare
0
From Embeds
0
Number of Embeds
451
Actions
Shares
0
Downloads
7
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • Introduction to .NET Micro Framework Development

    1. 1. Introduction to .NET Micro Framework Christopher Fairbairn ARANZ Medical Ltd [email_address]
    2. 2. The Device Landscape Windows Mobile, Pocket PC, SmartPhone, Windows CE Windows XP, Windows Vista, Windows XP Embedded Remote Controls , Wearable Devices, Auxiliary Displays Increasing functionality .NET Micro Framework .NET Compact Framework .NET Framework
    3. 3. Tahoe Development Board <ul><li>35mm x 35mm processor module </li></ul><ul><li>4MB Flash, 8MB SDRAM </li></ul><ul><li>100Mhz ARM920T Processor </li></ul>www.devicesolutions.net
    4. 4. .NET Micro Framework <ul><li>Smart Personal Object Technology (SPOT) </li></ul><ul><li>.NET Runtime in 300KB </li></ul><ul><li>Supports X86, ARM7, ARM9, M68K </li></ul>
    5. 5. C# experience VS 2005 Standard Edition .NET Micro Framework SDK A real device .NET MF - Requirements
    6. 6. Porting the .NET MF native User Applications and Libraries BCL .NET WPF Comms … CLR Execution Engine Type System Garbage Collector Interop PAL Timers RAM IO … Application Layer Class Library Layer Runtime Component Layer Hardware Layer Processor and Peripherals HAL OS or Drivers Facilities managed
    7. 7. Compiling for the .NET MF <ul><li>Supports CLS and CIL </li></ul><ul><li>C# only </li></ul><ul><li>No generics </li></ul><ul><li>Minimal assembly validation </li></ul><ul><li>Secure bootloader </li></ul>C# Source .NET Assembly .NET Micro Framework Assembly Device C# Compiler Metadata Processor Deployment
    8. 8. Hello World <ul><li>1974 Bell Laboratories memo by Brian Kernighan </li></ul>main() { printf(“hello, world”); }
    9. 9. Hello World OutputPort led = new OutputPort(Meridian.Pins.GPIO5, true); while (true) { Thread.Sleep(5000); led.Write(!led.Read()); }
    10. 10. DEMO The development process
    11. 11. Group Project <ul><li>Kitchen Timer </li></ul><ul><li>Push buttons </li></ul><ul><li>Tilt to pause </li></ul><ul><li>Logging </li></ul>
    12. 12. GPIO and Interrupts pin = new InterruptPort(Tahoe.Pins.SW9, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdge); pin.OnInterrupt += Pin_OnInterrupt; pin = new InputPort(Tahoe.Pins.SW9, Port.ResistorMode.PullUp); bool state = pin.Read(); pin = new OutputPort(Tahoe.Pins.SW9, true, Port.ResistorMode.PullDown); pin.Write(true); InputPort OutputPort InterruptPort
    13. 13. .NET MF GUI Support <ul><li>Improves with each release </li></ul><ul><li>Inspired by WPF </li></ul>
    14. 14. Drawing Primitives Bitmap bmp = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight); bmp.DrawRectangle( red, // outline colour 10, // outline thickness 20, 30, // x, y 40, 50, // width, height 0, // xCornerRadius 0, // yCornerRadius 0, 0, 0, 0, 0, 0, 0); bmp.Flush(); // copy bitmap to LCD
    15. 15. Drawing Primitives <ul><li>Object Orientated </li></ul><ul><li>Scene description </li></ul><ul><li>No declarative markup (XAML) </li></ul>Rectangle rect = new Rectangle(); rect.Width = 40; rect.Height = 50; rect.Fill = new SolidColorBrush(Color.Black); rect.Stroke = new Pen(Color.White, 10);
    16. 16. Creating Windows <ul><li>Static Controls </li></ul><ul><ul><li>Text, Bitmap </li></ul></ul><ul><li>Content Controls </li></ul><ul><ul><li>Border, ListBoxItem </li></ul></ul><ul><li>Container Controls </li></ul><ul><ul><li>Canvas, StackPanel, ScrollViewer </li></ul></ul><ul><li>Bitmap Fonts </li></ul>
    17. 17. DEMO Creating the basic Kitchen Timer Application
    18. 18. Interfacing Custom Hardware <ul><li>Direct hardware access considered “unsafe” </li></ul><ul><li>Managed interfaces </li></ul><ul><ul><li>GPIO </li></ul></ul><ul><ul><li>Serial </li></ul></ul><ul><ul><li>I2C </li></ul></ul><ul><ul><li>SPI </li></ul></ul><ul><li>More options for porting partners </li></ul><ul><ul><li>PWM </li></ul></ul>
    19. 19. Tahoe Accelerometer Module <ul><li>Analogue Accelerometer chip </li></ul><ul><li>I 2 C based ADC </li></ul><ul><li>Managed Device Driver </li></ul>
    20. 20. Input Manager <ul><li>Coordination of all input devices for WPF </li></ul><ul><li>Turns raw input into WPF events </li></ul><ul><li>Helper methods </li></ul><ul><ul><li>Buttons.IsButtonUp(Button.Pause); </li></ul></ul>
    21. 21. DEMO Adding tilt support
    22. 22. Weak References <ul><li>A way to alter GC behavior </li></ul><ul><li>Useful for implementing caches </li></ul>
    23. 23. Weak References <ul><li>A way to alter GC behavior </li></ul><ul><li>Useful for implementing caches </li></ul>WeakReference wr = new WeakReference(new SomeClass()); SomeClass foo = wr.Target as SomeClass; if (foo == null) foo = new SomeClass();
    24. 24. Extended Weak References <ul><li>Persists objects to EEPROM </li></ul><ul><li>Can recover objects after device restarts </li></ul><ul><ul><li>SurviveBoot </li></ul></ul><ul><ul><li>SurvivePowerDown </li></ul></ul><ul><li>Storage Priorities </li></ul>
    25. 25. DEMO Creating a log of Kitchen Timer usage
    26. 26. <ul><li>bansky.net/blog </li></ul><ul><li>www.microframework.cz </li></ul><ul><li>.NET Micro Framework Team Blog </li></ul><ul><li>microsoft.public.dotnet.framework.microframework </li></ul>Getting Started
    27. 27. Contact Information Christopher Fairbairn ARANZ Medical Ltd Questions? Email: [email_address] Website: www.christec.co.nz/blog/

    ×