Exemplo n.º 1
0
static T_uezError Generic_USBHost_Control(
            void *aWorkspace,
            TUInt8 aDeviceAddress,
            TUInt8 aBMRequestType,
            TUInt8 aRequest,
            TUInt16 aValue,
            TUInt16 aIndex,
            TUInt16 aLength,
            void *aBuffer,
            TUInt32 aTimeout)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iUSBHost)->Control(
            p->iUSBHost,
            aDeviceAddress,
            aBMRequestType,
            aRequest,
            aValue,
            aIndex,
            aLength,
            aBuffer,
            aTimeout);
    IRelease();

    return error;
}
Exemplo n.º 2
0
static T_uezError Generic_USBHost_GetDescriptor(
            void *aWorkspace,
            TUInt8 aDeviceAddress,
            TUInt8 aType,
            TUInt8 aIndex,
            TUInt8 *aBuffer,
            TUInt32 aSize,
            TUInt32 aTimeout)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iUSBHost)->GetDescriptor(
            p->iUSBHost,
            aDeviceAddress,
            aType,
            aIndex,
            aBuffer,
            aSize,
            aTimeout);
    IRelease();

    return error;
}
/*---------------------------------------------------------------------------*
 * Routine:  Keypad_NXP_I2C_PCA9555_Open
 *---------------------------------------------------------------------------*
 * Description:
 *      Increment the number of users
 * Inputs:
 *      void *aW                    -- Workspace
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError Keypad_NXP_I2C_PCA9555_Open(void *aWorkspace)
{
    T_Keypad_NXP_I2C_PCA9555_Workspace *p = 
        (T_Keypad_NXP_I2C_PCA9555_Workspace *)aWorkspace;
    T_uezError error = UEZ_ERROR_NONE;

    IGrab(p);

    p->iNumOpen++;
    if (p->iNumOpen==1) {
        // Setup the keypad's input/output pins
        IKeypad_PCA9555_WriteReg(p, 0x06, P0_7_LED_OUT_REG & P0_6_BACKLIGHT_OUT_REG);
        IKeypad_PCA9555_WriteReg(p, 0x07, P1_7_6_LED_OUT_REG & P1_KPAD_ROW_OUT_REG);

        // LEDs off
        IKeypad_PCA9555_WriteReg(p, 0x03, 0xC0);

#if KEYPAD_USES_EXTERNAL_IRQ
        // First to open?  Enable interrupts
        error = (*p->iEINT)->Enable(p->iEINT, KEYPAD_EINT2_CHANNEL);
#endif
    }

    IRelease(p);

    return error;
}
Exemplo n.º 4
0
static void Generic_USBHost_ResetPort(void *aWorkspace)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;

    IGrab();
    (*p->iUSBHost)->ResetPort(p->iUSBHost);
    IRelease();
}
Exemplo n.º 5
0
T_uezError Timer_Generic_Disable(void *aWorkspace)
{
    T_Timer_Generic_Workspace *p = (T_Timer_Generic_Workspace *)aWorkspace;

    IGrab();
    (*p->iTimer)->Disable(p->iTimer);
    IRelease();

    return UEZ_ERROR_NONE;
}
Exemplo n.º 6
0
static void *Generic_USBHost_AllocBuffer(void *aWorkspace, TUInt32 aSize)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    void *ptr;

    IGrab();
    ptr = (*p->iUSBHost)->AllocBuffer(p->iUSBHost, aSize);
    IRelease();

    return ptr;
}
Exemplo n.º 7
0
/*---------------------------------------------------------------------------*
 * Routine:  Generic_USBHost_Init
 *---------------------------------------------------------------------------*
 * Description:
 *      Initializes the LPC247x host controller with buffers
 * Inputs:
 *      void *aWorkspace            -- USB Host controller workspace
 *---------------------------------------------------------------------------*/
static T_uezError Generic_USBHost_Init(void *aWorkspace)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iUSBHost)->Init(p->iUSBHost);
    IRelease();

    return error;
}
Exemplo n.º 8
0
T_uezError Timer_Generic_SetTimerMode(void *aWorkspace, T_Timer_Mode aMode)
{
    T_Timer_Generic_Workspace *p = (T_Timer_Generic_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iTimer)->SetTimerMode(p->iTimer, aMode);
    IRelease();

    return error;
}
Exemplo n.º 9
0
static T_usbHostDeviceState Generic_USBHost_GetState(void *aWorkspace)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    T_usbHostDeviceState state;

    IGrab();
    state = (*p->iUSBHost)->GetState(p->iUSBHost);
    IRelease();

    return state;
}
Exemplo n.º 10
0
/*---------------------------------------------------------------------------*
 * Routine:  DAC_Generic_SetVRef
 *---------------------------------------------------------------------------*
 * Description:
 *      Set internal voltage reference.
 * Inputs:
 *      void *aW                     -- DAC workspace
 *      const TUInt32 aVRef          -- Set VRef in millivolts.
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError DAC_Generic_SetVRef(void *aWorkspace, const TUInt32 aVRef)
{
    T_DAC_Generic_Workspace *p = (T_DAC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iDAC)->SetVRef(p->iDAC, aVRef);
    IRelease();

    return error;
}
Exemplo n.º 11
0
/*---------------------------------------------------------------------------*
 * Routine:  DAC_Generic_SetBias
 *---------------------------------------------------------------------------*
 * Description:
 *      Set BIAS.
 * Inputs:
 *      void *aW                     -- DAC workspace
 *      TBool aBias                  -- Value to determine if BIAS should be set.
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError DAC_Generic_SetBias(void *aWorkspace, TBool aBias)
{
    T_DAC_Generic_Workspace *p = (T_DAC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iDAC)->SetBias(p->iDAC, aBias);
    IRelease();

    return error;
}
Exemplo n.º 12
0
/*---------------------------------------------------------------------------*
 * Routine:  DAC_Generic_Read
 *---------------------------------------------------------------------------*
 * Description:
 *      Read value from the DAC in milliVolts.
 * Inputs:
 *      void *aW                     -- DAC workspace
 *      TUInt32 *aMilliVolts         -- Value in mV to be written to.
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError DAC_Generic_ReadMilliVolts(void *aWorkspace, TUInt32 * aMilliVolts)
{
    T_DAC_Generic_Workspace *p = (T_DAC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iDAC)->ReadMilliVolts(p->iDAC, aMilliVolts);
    IRelease();

    return error;
}
Exemplo n.º 13
0
/*---------------------------------------------------------------------------*
 * Routine:  CRC_Generic_Interface_SetSeed
 *---------------------------------------------------------------------------*
 * Description:
 *      Start the seed (usually 0) of a new calculation.
 * Inputs:
 *      void *aWorkspace               -- Workspace
 *      TUInt32 aSeed                -- Seed value
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError CRC_Generic_Interface_SetSeed(void *aWorkspace, TUInt32 aSeed)
{
    T_CRC_Generic_Workspace *p = (T_CRC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iCRC)->SetSeed(p->iCRC, aSeed);
    IRelease();

    return error;
}
Exemplo n.º 14
0
/*---------------------------------------------------------------------------*
 * Routine:  CRC_Generic_Interface_ReadChecksum
 *---------------------------------------------------------------------------*
 * Description:
 *      Return current checksum reading
 * Inputs:
 *      void *aWorkspace               -- Workspace
 *      TUInt32 *aValue -- Place to store checksum
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError CRC_Generic_Interface_ReadChecksum(void *aWorkspace, TUInt32 *aValue)
{
    T_CRC_Generic_Workspace *p = (T_CRC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iCRC)->ReadChecksum(p->iCRC, aValue);
    IRelease();

    return error;
}
Exemplo n.º 15
0
/*---------------------------------------------------------------------------*
 * Routine:  DAC_Generic_Write
 *---------------------------------------------------------------------------*
 * Description:
 *      Write value to the DAC.
 * Inputs:
 *      void *aW                     -- DAC workspace
 *      TUInt32 aValue               -- Value to be written to DAC
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError DAC_Generic_Write(void *aWorkspace, TUInt32 aValue)
{
    T_DAC_Generic_Workspace *p = (T_DAC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iDAC)->Write(p->iDAC, aValue);
    IRelease();

    return error;
}
Exemplo n.º 16
0
T_uezError Timer_Generic_SetCaptureSource(
    void *aWorkspace,
    TUInt32 aSourceIndex)
{
    T_Timer_Generic_Workspace *p = (T_Timer_Generic_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iTimer)->SetCaptureSource(p->iTimer, aSourceIndex);
    IRelease();

    return error;
}
Exemplo n.º 17
0
static T_uezError Generic_USBHost_SetAddress(
            void *aWorkspace,
            TUInt8 aAddress)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iUSBHost)->SetAddress(p->iUSBHost, aAddress);
    IRelease();

    return error;
}
/*---------------------------------------------------------------------------*
 * Routine:  Keypad_NXP_I2C_PCA9555_Unregister
 *---------------------------------------------------------------------------*
 * Description:
 *      Remove the given queue from the list of event queues.
 * Inputs:
 *      void *aWorkspace            -- Workspace
 *      T_uezQueue                  -- Queue to remove from events
 * Outputs:
 *      
 *---------------------------------------------------------------------------*/
T_uezError Keypad_NXP_I2C_PCA9555_Unregister(
        void *aWorkspace, 
        T_uezQueue aQueue)
{
    T_Keypad_NXP_I2C_PCA9555_Workspace *p = 
        (T_Keypad_NXP_I2C_PCA9555_Workspace *)aWorkspace;
    T_uezError error = UEZ_ERROR_NONE;

    IGrab(p);
    IQueueRemove(p, aQueue);
    IRelease(p);

    return error;
}
Exemplo n.º 19
0
/*---------------------------------------------------------------------------*
 * Routine: CRC_Generic_Interface_SetComputationType
 *---------------------------------------------------------------------------*
 * Description:
 *      Sets computation mode using either CCITT, CRC16, or CRC32 polynom
 * Inputs:
 *      void *aWorkspace               -- Workspace
 *      T_uezCRCComputationType aType  -- Type of CRC computations to do
 * Outputs:
 *      T_uezError                     -- Error code
 *---------------------------------------------------------------------------*/
T_uezError CRC_Generic_Interface_SetComputationType(
        void *aWorkspace,
        T_uezCRCComputationType aType)
{
    T_CRC_Generic_Workspace *p = (T_CRC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iCRC)->SetComputationType(p->iCRC, aType);
    IRelease();

    return error;
}
Exemplo n.º 20
0
/*---------------------------------------------------------------------------*
 * Routine:  CRC_Generic_Interface_RemoveModifier
 *---------------------------------------------------------------------------*
 * Description:
 *      Add a modifier to the algorithm.  If the modifier already has been
 *      added, do nothing.
 * Inputs:
 *      void *aWorkspace               -- Workspace
 *      T_uezCRCModifier aModifier -- Type of modifier to add
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError CRC_Generic_Interface_RemoveModifier(
        void *aWorkspace,
        T_uezCRCModifier aModifier)
{
    T_CRC_Generic_Workspace *p = (T_CRC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iCRC)->RemoveModifier(p->iCRC, aModifier);
    IRelease();

    return error;
}
Exemplo n.º 21
0
static T_uezError Generic_USBHost_SetControlPacketSize(
            void *aWorkspace,
            TUInt8 aDeviceAddress,
            TUInt16 aPacketSize)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iUSBHost)->SetControlPacketSize(p->iUSBHost, aDeviceAddress, aPacketSize);
    IRelease();

    return error;
}
Exemplo n.º 22
0
T_uezError Timer_Generic_SetExternalControl(
    void *aWorkspace,
    TUInt8 aMatchRegister,
    T_Timer_ExternalControl aExtControl)
{
    T_Timer_Generic_Workspace *p = (T_Timer_Generic_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iTimer)->SetExternalControl(p->iTimer, aMatchRegister,
            aExtControl);
    IRelease();

    return error;
}
Exemplo n.º 23
0
/*---------------------------------------------------------------------------*
 * Routine:  CRC_Generic_Interface_ComputeData
 *---------------------------------------------------------------------------*
 * Description:
 *      Pass in a set of data to compute a checksum.  This can be a single
 *      value or a group of data.  The size of the data elements are passed
 *      as well to tell if computations on small data (bytes) or larger
 *      chunks (words).
 * Inputs:
 *      void *aWorkspace               -- Workspace
 *      void *aData                    -- Pointer to data array
 *      T_uezCRCDataElementSize aSize  -- Size of each element
 *      TUInt32 aNumDataElements       -- Number of data elements to process
 * Outputs:
 *      T_uezError                     -- Error code
 *---------------------------------------------------------------------------*/
T_uezError CRC_Generic_Interface_ComputeData(
        void *aWorkspace,
        void *aData,
        T_uezCRCDataElementSize aSize,
        TUInt32 aNumDataElements)
{
    T_CRC_Generic_Workspace *p = (T_CRC_Generic_Workspace *)aWorkspace;
    T_uezError error;

    // Pass on the request
    IGrab();
    error = (*p->iCRC)->ComputeData(p->iCRC, aData, aSize, aNumDataElements);
    IRelease();

    return error;
}
Exemplo n.º 24
0
T_uezError Timer_Generic_SetMatchRegister(
    void *aWorkspace,
    TUInt8 aMatchRegister,
    TUInt32 aMatchPoint,
    T_Timer_MatchPointFunction aFunctions)
{
    T_Timer_Generic_Workspace *p = (T_Timer_Generic_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iTimer)->SetMatchRegisterFunctions(p->iTimer, aMatchRegister,
            aFunctions, aMatchPoint);
    IRelease();

    return error;
}
Exemplo n.º 25
0
static T_uezError Generic_USBHost_SetConfiguration(
            void *aWorkspace,
            TUInt8 aDeviceAddress,
            TUInt32 aConfiguration)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iUSBHost)->SetConfiguration(
            p->iUSBHost,
            aDeviceAddress,
            aConfiguration);
    IRelease();

    return error;
}
Exemplo n.º 26
0
T_uezError Timer_Generic_SetMatchCallback(
    void *aWorkspace,
    TUInt8 aMatchRegister,
    T_DeviceTimer_Callback aCallbackFunc,
    void *aCallbackWorkspace)
{
    T_Timer_Generic_Workspace *p = (T_Timer_Generic_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    p->iCallbackFunc = aCallbackFunc;
    p->iCallbackWorkspace = aCallbackWorkspace;
    error = (*p->iTimer)->SetMatchCallback(p->iTimer, aMatchRegister,
                                           ITimerGenericCallback, p);
    IRelease();

    return error;
}
/*---------------------------------------------------------------------------*
 * Routine:  ExternalInterrupt_NXP_LPC1756_Reset
 *---------------------------------------------------------------------------*
 * Description:
 *      Unregister the external interrupt handler.
 * Inputs:
 *      TUInt32 aChannel            -- EINT channel (0 to 3)
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError ExternalInterrupt_NXP_LPC1756_Reset(
        void *aWorkspace,
        TUInt32 aChannel)
{
    TUInt32 irqNum;
    T_ExternalInterrupt_NXP_LPC1756_Workspace *p =
        (T_ExternalInterrupt_NXP_LPC1756_Workspace *)aWorkspace;
    T_eintCallback *p_callback;
    T_uezError error = UEZ_ERROR_NONE;

    IGrab(p);

    // Fake loop
    while (1) {
        // Is this a valid channel?
        if (aChannel >= NUM_EXTERNAL_INTERRUPTS) {
            error = UEZ_ERROR_OUT_OF_RANGE;
            break;
        }

        // Is this external interrupt already in cleared?
        p_callback = G_eintCallbacks+aChannel;
        if (!p_callback->iCallbackFunc) {
            error = UEZ_ERROR_NOT_FOUND;
            break;
        }

        // Unregister it
        irqNum = EINT0_IRQn+aChannel;
        InterruptDisable(irqNum);
        InterruptUnregister(irqNum);
        p_callback->iPriority = (T_irqPriority) 0;
        p_callback->iTrigger = 0;
        p_callback->iCallbackWorkspace = 0;
        p_callback->iCallbackFunc = 0;

        // Do not loop
        break;
    }

    IRelease(p);

    return error;
}
Exemplo n.º 28
0
static T_uezError Generic_USBHost_ConfigureEndpoint(
            void *aWorkspace,
            TUInt8 aDeviceAddress,
            TUInt8 aEndpointAndInOut,   // bit 0x80 is set if IN
            TUInt16 aMaxPacketSize)
{
    T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace;
    T_uezError error;

    IGrab();
    error = (*p->iUSBHost)->ConfigureEndpoint(
            p->iUSBHost,
            aDeviceAddress,
            aEndpointAndInOut,   // bit 0x80 is set if IN
            aMaxPacketSize);
    IRelease();

    return error;
}
/*---------------------------------------------------------------------------*
 * Routine:  ExternalInterrupt_NXP_LPC1756_Enable
 *---------------------------------------------------------------------------*
 * Description:
 *      Enable the given external interrupt
 * Inputs:
 *      TUInt32 aChannel            -- EINT channel (0 to 3)
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError ExternalInterrupt_NXP_LPC1756_Enable(
        void *aWorkspace,
        TUInt32 aChannel)
{
    TUInt32 irqNum;
    T_ExternalInterrupt_NXP_LPC1756_Workspace *p =
        (T_ExternalInterrupt_NXP_LPC1756_Workspace *)aWorkspace;
    T_eintCallback *p_callback;
    T_uezError error = UEZ_ERROR_NONE;

    IGrab(p);

    // Fake loop
    while (1) {
        // Is this a valid channel?
        if (aChannel >= NUM_EXTERNAL_INTERRUPTS) {
            error = UEZ_ERROR_OUT_OF_RANGE;
            break;
        }

        // Is this external interrupt available?
        p_callback = G_eintCallbacks+aChannel;
        if (!p_callback->iCallbackFunc) {
            error = UEZ_ERROR_NOT_FOUND;
            break;
        }

        // Disable it
        irqNum = EINT0_IRQn+aChannel;
        InterruptEnable(irqNum);

        // Do not loop
        break;
    }

    IRelease(p);

    return error;
}
/*---------------------------------------------------------------------------*
 * Routine:  Keypad_NXP_I2C_PCA9555_Close
 *---------------------------------------------------------------------------*
 * Description:
 *      Declare the number of users
 * Inputs:
 *      void *aW                    -- Workspace
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError Keypad_NXP_I2C_PCA9555_Close(void *aWorkspace)
{
    T_Keypad_NXP_I2C_PCA9555_Workspace *p = 
        (T_Keypad_NXP_I2C_PCA9555_Workspace *)aWorkspace;
    T_uezError error = UEZ_ERROR_NONE;

    IGrab(p);

    if (p->iNumOpen) {
        p->iNumOpen--;
        if (p->iNumOpen==0) {
#if KEYPAD_USES_EXTERNAL_IRQ
            // First to open?  Enable interrupts
            error = (*p->iEINT)->Disable(p->iEINT, KEYPAD_EINT2_CHANNEL);
#endif
        }
    }

    IRelease(p);

    return error;
}