aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Components/BindingProxy.cs
blob: e13436900e020901b17600e118f034c552c4e3b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Tango.SharedUI.Components
{
    public class BindingProxy : Freezable
    {
        #region Overrides of Freezable

        protected override Freezable CreateInstanceCore()
        {
            return new BindingProxy();
        }

        #endregion

        public object Data
        {
            get { return (object)GetValue(DataProperty); }
            set { SetValue(DataProperty, value); }
        }

        public static readonly DependencyProperty DataProperty =
            DependencyProperty.Register("Data", typeof(object),
                                         typeof(BindingProxy));
    }
}
ighlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
//*****************************************************************************
//
// lmdfuwrap.cpp : A thin wrapper over the lmdfu.dll library allowing it to be
//                 loaded dynamically rather than statically linking to its .lib
//                 file.
//
// Copyright (c) 2009-2017 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 2.1.4.178 of the Tiva Firmware Development Package.
//
//*****************************************************************************

#include <windows.h>
#include "lmdfu.h"
#include "lmdfuwrap.h"

//*****************************************************************************
//
// DLL module handle.
//
//*****************************************************************************
HINSTANCE hLMUSB = (HINSTANCE)NULL;

//*****************************************************************************
//
// Function pointers for each DLL entry point.
//
//*****************************************************************************
tLMDFUInit pfnLMDFUInit = NULL;
tLMDFUDeviceOpen pfnLMDFUDeviceOpen = NULL;
tLMDFUDeviceClose pfnLMDFUDeviceClose = NULL;
tLMDFUDeviceStringGet pfnLMDFUDeviceStringGet = NULL;
tLMDFUDeviceASCIIStringGet pfnLMDFUDeviceASCIIStringGet = NULL;
tLMDFUParamsGet pfnLMDFUParamsGet = NULL;
tLMDFUIsValidImage pfnLMDFUIsValidImage = NULL;
tLMDFUDownload pfnLMDFUDownload = NULL;
tLMDFUDownloadBin pfnLMDFUDownloadBin = NULL;
tLMDFUErase pfnLMDFUErase = NULL;
tLMDFUBlankCheck pfnLMDFUBlankCheck = NULL;
tLMDFUUpload pfnLMDFUUpload = NULL;
tLMDFUStatusGet pfnLMDFUStatusGet = NULL;
tLMDFUErrorStringGet pfnLMDFUErrorStringGet = NULL;
tLMDFUModeSwitch pfnLMDFUModeSwitch = NULL;

tLMDFUErr __stdcall _LMDFUInit(void)
{
    //
    // Try to load the USB DLL.
    //
    hLMUSB = LoadLibrary(TEXT("lmdfu.dll"));

    //
    // Did we find it?
    //
    if(hLMUSB)
    {
        //
        // Yes - query all the entry point addresses.
        //
        pfnLMDFUInit = (tLMDFUInit)GetProcAddress(hLMUSB, "LMDFUInit");
        pfnLMDFUDeviceOpen = (tLMDFUDeviceOpen)GetProcAddress(hLMUSB, "LMDFUDeviceOpen");
        pfnLMDFUDeviceClose = (tLMDFUDeviceClose)GetProcAddress(hLMUSB, "LMDFUDeviceClose");
        pfnLMDFUDeviceStringGet = (tLMDFUDeviceStringGet)GetProcAddress(hLMUSB, "LMDFUDeviceStringGet");
        pfnLMDFUDeviceASCIIStringGet = (tLMDFUDeviceASCIIStringGet)GetProcAddress(hLMUSB, "LMDFUDeviceASCIIStringGet");
        pfnLMDFUParamsGet = (tLMDFUParamsGet)GetProcAddress(hLMUSB, "LMDFUParamsGet");
        pfnLMDFUIsValidImage = (tLMDFUIsValidImage)GetProcAddress(hLMUSB, "LMDFUIsValidImage");
        pfnLMDFUDownload = (tLMDFUDownload)GetProcAddress(hLMUSB, "LMDFUDownload");
        pfnLMDFUDownloadBin = (tLMDFUDownloadBin)GetProcAddress(hLMUSB, "LMDFUDownloadBin");
        pfnLMDFUErase = (tLMDFUErase)GetProcAddress(hLMUSB, "LMDFUErase");
        pfnLMDFUBlankCheck = (tLMDFUBlankCheck)GetProcAddress(hLMUSB, "LMDFUBlankCheck");
        pfnLMDFUUpload = (tLMDFUUpload)GetProcAddress(hLMUSB, "LMDFUUpload");
        pfnLMDFUStatusGet = (tLMDFUStatusGet)GetProcAddress(hLMUSB, "LMDFUStatusGet");
        pfnLMDFUErrorStringGet = (tLMDFUErrorStringGet)GetProcAddress(hLMUSB, "LMDFUErrorStringGet");
        pfnLMDFUModeSwitch = (tLMDFUModeSwitch)GetProcAddress(hLMUSB, "LMDFUModeSwitch");

        //
        // Make sure we actually queried all the expected entry points.
        //
        if(!pfnLMDFUInit || !pfnLMDFUDeviceOpen ||  !pfnLMDFUDeviceClose ||
           !pfnLMDFUDeviceStringGet || !pfnLMDFUDeviceASCIIStringGet ||
           !pfnLMDFUParamsGet || !pfnLMDFUIsValidImage || !pfnLMDFUDownload ||
           !pfnLMDFUDownloadBin || !pfnLMDFUErase || !pfnLMDFUBlankCheck ||
           !pfnLMDFUUpload || !pfnLMDFUStatusGet || !pfnLMDFUErrorStringGet ||
           !pfnLMDFUModeSwitch)
        {
            //
            // We failed to query at least one entry point.  Return
            // DFU_ERR_INVALID_ADDR to signal to the caller that the driver
            // is likely the wrong version.
            //
            return(DFU_ERR_INVALID_ADDR);
        }
        else
        {
            //
            // We got all the expected function pointers so call the library
            // init function and return it's response.
            //
            return(pfnLMDFUInit());
        }
    }
    else
    {
        //
        // The DLL could not be found.  This tends to suggest that the driver
        // is not installed.  Return an appropriate error code to the caller
        // so that they can provide helpful information to the user.
        //
        return(DFU_ERR_NOT_FOUND);
    }
}

tLMDFUErr __stdcall _LMDFUDeviceOpen(int iDeviceIndex,
                                    tLMDFUDeviceInfo *psDevInfo,
                                    tLMDFUHandle *phHandle)
{
    if(pfnLMDFUDeviceOpen)
    {
        return(pfnLMDFUDeviceOpen(iDeviceIndex, psDevInfo, phHandle));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUDeviceClose(tLMDFUHandle hHandle, bool bReset)
{
    if(pfnLMDFUDeviceClose)
    {
        return(pfnLMDFUDeviceClose(hHandle, bReset));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUDeviceStringGet(tLMDFUHandle hHandle,
                                         unsigned char ucStringIndex,
                                         unsigned short usLanguageID,
                                         char *pcString,
                                         unsigned short *pusStringLen)
{
    if(pfnLMDFUDeviceStringGet)
    {
        return(pfnLMDFUDeviceStringGet(hHandle, ucStringIndex, usLanguageID,
                                       pcString, pusStringLen));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUDeviceASCIIStringGet(tLMDFUHandle hHandle,
                                              unsigned char ucStringIndex,
                                              char *pcString,
                                              unsigned short *pusStringLen)
{
    if(pfnLMDFUDeviceASCIIStringGet)
    {
        return(pfnLMDFUDeviceASCIIStringGet(hHandle, ucStringIndex, pcString,
                                            pusStringLen));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUParamsGet(tLMDFUHandle hHandle,
                                   tLMDFUParams *psParams)
{
    if(pfnLMDFUParamsGet)
    {
        return(pfnLMDFUParamsGet(hHandle, psParams));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUIsValidImage(tLMDFUHandle hHandle,
                                      unsigned char *pcDFUImage,
                                      unsigned long ulImageLen,
                                      bool *pbTivaFormat)
{
    if(pfnLMDFUIsValidImage)
    {
        return(pfnLMDFUIsValidImage(hHandle, pcDFUImage, ulImageLen,
                                    pbTivaFormat));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUDownload(tLMDFUHandle hHandle,
                                  unsigned char *pcDFUImage,
                                  unsigned long ulImageLen, bool bVerify,
                                  bool bIgnoreIDs, HWND hwndNotify)
{
    if(pfnLMDFUDownload)
    {
        return(pfnLMDFUDownload(hHandle, pcDFUImage, ulImageLen, bVerify,
                                bIgnoreIDs, hwndNotify));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUDownloadBin(tLMDFUHandle hHandle,
                                     unsigned char *pcBinaryImage,
                                     unsigned long ulImageLen,
                                     unsigned long ulStartAddr,
                                     bool bVerify, HWND hwndNotify)
{
    if(pfnLMDFUDownloadBin)
    {
        return(pfnLMDFUDownloadBin(hHandle, pcBinaryImage, ulImageLen,
                                   ulStartAddr, bVerify, hwndNotify));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUErase(tLMDFUHandle hHandle, unsigned long ulStartAddr,
                               unsigned long ulEraseLen, bool bVerify,
                               HWND hwndNotify)
{
    if(pfnLMDFUErase)
    {
        return(pfnLMDFUErase(hHandle, ulStartAddr, ulEraseLen, bVerify,
                             hwndNotify));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUBlankCheck(tLMDFUHandle hHandle,
                                    unsigned long ulStartAddr,
                                    unsigned long ulLen)
{
    if(pfnLMDFUBlankCheck)
    {
        return(pfnLMDFUBlankCheck(hHandle, ulStartAddr, ulLen));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUUpload(tLMDFUHandle hHandle, unsigned char *pcBuffer,
                                unsigned long ulStartAddr,
                                unsigned long ulImageLen, bool bRaw,
                                HWND hwndNotify)
{
    if(pfnLMDFUUpload)
    {
        return(pfnLMDFUUpload(hHandle, pcBuffer, ulStartAddr, ulImageLen,
                              bRaw, hwndNotify));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUStatusGet(tLMDFUHandle hHandle, tDFUStatus *pStatus)
{
    if(pfnLMDFUStatusGet)
    {
        return(pfnLMDFUStatusGet(hHandle, pStatus));
    }

    return(DFU_ERR_HANDLE);
}

tLMDFUErr __stdcall _LMDFUModeSwitch(tLMDFUHandle hHandle)
{
    if(pfnLMDFUStatusGet)
    {
        return(pfnLMDFUModeSwitch(hHandle));
    }

    return(DFU_ERR_HANDLE);
}

char * __stdcall _LMDFUErrorStringGet(tLMDFUErr eError)
{
    if(pfnLMDFUErrorStringGet)
    {
        return(pfnLMDFUErrorStringGet(eError));
    }

    return("Driver not installed");
}