⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 musdk.c

📁 freescale i.mx31 BSP CE5.0全部源码
💻 C
📖 第 1 页 / 共 2 页
字号:
//      length
//          [in] Length of data to read.
//
//      dataBufPtr
//          [out] Pointer to data buffer containing 
//          resultant read data.
//
// Returns:
//      TRUE if success.
//      FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL MUReadData(HANDLE hMU, UINT16 length, UINT8 *dataBufPtr)
{
    DWORD bytesRead;

    MU_FUNCTION_ENTRY();

    if (!ReadFile(hMU, dataBufPtr, length, (LPDWORD) &bytesRead, NULL))
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU ReadFile failed!\r\n"), __WFUNCTION__));
        return FALSE;
    }

    if (length != bytesRead)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: Did not read the correct number of bytes!\r\n"), __WFUNCTION__));
        return FALSE;
    }

    MU_FUNCTION_EXIT();

    return TRUE;
}


//------------------------------------------------------------------------------
//
// Function: MUGPI
//
// This method allows the caller to generate a general
// purpose interrupt to the DSP side.
//
// Parameters:
//      hMU
//          [in] Handle to MU driver.
//
//      gpiNum
//          [in] General Purpose Interrupt number.
//          Possibly numbers are 1, 2, 3, or 4.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
void MUGPI(HANDLE hMU, UINT8 gpiNum)
{
    MU_FUNCTION_ENTRY();

    if ((gpiNum < 1) || (gpiNum > 4))
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: GPI number is %d.  This number must be either 1, 2, 3, or 4.\r\n"), 
            __WFUNCTION__, gpiNum));
        return;
    }
    
    // issue the IOCTL to write data
    if (!DeviceIoControl(hMU,      // file handle to the driver
        MU_IOCTL_GPI,              // I/O control code
        NULL,                      // in buffer
        gpiNum,                    // in buffer size
        NULL,                      // out buffer
        0,                         // out buffer size
        0,                         // number of bytes returned
        NULL))                     // ignored (=NULL)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU_IOCTL_GPI failed!\r\n"), __WFUNCTION__));
    }

    MU_FUNCTION_EXIT();
}


//------------------------------------------------------------------------------
//
// Function: MUSideReset
//
// This method allows the caller to reset all MU registers on the 
// caller's side.
//
// Parameters:
//      hMU
//          [in] Handle to MU driver.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
void MUSideReset(HANDLE hMU)
{
    MU_FUNCTION_ENTRY();

    // issue the IOCTL to write data
    if (!DeviceIoControl(hMU,      // file handle to the driver
        MU_IOCTL_SIDE_RESET,       // I/O control code
        NULL,                      // in buffer
        0,                         // in buffer size
        NULL,                      // out buffer
        0,                         // out buffer size
        0,                         // number of bytes returned
        NULL))                     // ignored (=NULL)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU_IOCTL_SIDE_RESET failed!\r\n"), __WFUNCTION__));
    }

    MU_FUNCTION_EXIT();
}


//------------------------------------------------------------------------------
//
// Function: MUSystemReset
//
// This method allows the caller to reset all MU registers including
// the messaging section on both sides.
//
// Parameters:
//      hMU
//          [in] Handle to MU driver.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
void MUSystemReset(HANDLE hMU)
{
    MU_FUNCTION_ENTRY();

    // issue the IOCTL to write data
    if (!DeviceIoControl(hMU,      // file handle to the driver
        MU_IOCTL_SYSTEM_RESET,       // I/O control code
        NULL,                      // in buffer
        0,                         // in buffer size
        NULL,                      // out buffer
        0,                         // out buffer size
        0,                         // number of bytes returned
        NULL))                     // ignored (=NULL)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU_IOCTL_SYSTEM_RESET failed!\r\n"), __WFUNCTION__));
    }

    MU_FUNCTION_EXIT();
}


//------------------------------------------------------------------------------
//
// Function: MUDSPResetON
//
// This method allows the Applications Processor (AP) to hold the 
// DSP in reset until MUDSPResetOFF is asserted.
//
// Parameters:
//      hMU
//          [in] Handle to MU driver.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
void MUDSPResetON(HANDLE hMU)
{
    MU_FUNCTION_ENTRY();

    // issue the IOCTL to write data
    if (!DeviceIoControl(hMU,      // file handle to the driver
        MU_IOCTL_DSP_RESET_ON,     // I/O control code
        NULL,                      // in buffer
        0,                         // in buffer size
        NULL,                      // out buffer
        0,                         // out buffer size
        0,                         // number of bytes returned
        NULL))                     // ignored (=NULL)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU_IOCTL_DSP_RESET_ON failed!\r\n"), __WFUNCTION__));
    }

    MU_FUNCTION_EXIT();
}

//------------------------------------------------------------------------------
//
// Function: MUDSPResetOFF
//
// This method allows the AP to release the DSP from reset.
//
// Parameters:
//      hMU
//          [in] Handle to MU driver.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
void MUDSPResetOFF(HANDLE hMU)
{
    MU_FUNCTION_ENTRY();

    // issue the IOCTL to write data
    if (!DeviceIoControl(hMU,      // file handle to the driver
        MU_IOCTL_DSP_RESET_OFF,     // I/O control code
        NULL,                      // in buffer
        0,                         // in buffer size
        NULL,                      // out buffer
        0,                         // out buffer size
        0,                         // number of bytes returned
        NULL))                     // ignored (=NULL)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU_IOCTL_DSP_RESET_OFF failed!\r\n"), __WFUNCTION__));
    }

    MU_FUNCTION_EXIT();
}

//------------------------------------------------------------------------------
//
// Function: MUWait4Reset
//
// This method allows the caller to wait until the other side
// has come out of reset.  This is a blocking call.
//
// Parameters:
//      hMU
//          [in] Handle to MU driver.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
void MUWait4Reset(HANDLE hMU)
{
    MU_FUNCTION_ENTRY();

    // issue the IOCTL to write data
    if (!DeviceIoControl(hMU,      // file handle to the driver
        MU_IOCTL_WAIT_FOR_RESET,     // I/O control code
        NULL,                      // in buffer
        0,                         // in buffer size
        NULL,                      // out buffer
        0,                         // out buffer size
        0,                         // number of bytes returned
        NULL))                     // ignored (=NULL)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU_IOCTL_WAIT_FOR_RESET failed!\r\n"), __WFUNCTION__));
    }

    MU_FUNCTION_EXIT();
}

//------------------------------------------------------------------------------
//
// Function: MUEnableInterrupts
//
// This method allows the caller to enable peripheral interrupts.
//
// Parameters:
//      hMU
//          [in] Handle to MU driver.
//
//      MUIntrs
//          [in] Identifies one or more interrupts to enable.
//
// Returns:
//      TRUE if successful.
//      FALSE if the handle is invalid.
//      FALSE if any parameter values fall outside their range.
//
//------------------------------------------------------------------------------
DWORD MUEnableInterrupts(HANDLE hMU, MUIntrType_c MUIntr)
{
    MU_FUNCTION_ENTRY();

    // issue the IOCTL to write data
    if (!DeviceIoControl(hMU,      // file handle to the driver
        MU_IOCTL_ENABLE_INTERRUPTS,// I/O control code
        NULL,                      // in buffer
        MUIntr,                    // in buffer size
        NULL,                      // out buffer
        0,                         // out buffer size
        0,                         // number of bytes returned
        NULL))                     // ignored (=NULL)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU_IOCTL_ENABLE_INTERRUPTS failed!\r\n"), __WFUNCTION__));
        return ERROR_INVALID_HANDLE;
    }

    MU_FUNCTION_EXIT();

    return ERROR_SUCCESS;
}

//------------------------------------------------------------------------------
//
// Function: MUDisableInterrupts
//
// This method allows the caller to disable peripheral interrupts.
//
// Parameters:
//      hMU
//          [in] Handle to MU driver.
//
//      MUIntr
//          [in] Identifies one or more interrupts to disable.
//
// Returns:
//      TRUE if successful.
//      FALSE if the handle is invalid.
//      FALSE if any parameter values fall outside their range.
//
//------------------------------------------------------------------------------
DWORD MUDisableInterrupts(HANDLE hMU, MUIntrType_c MUIntr)
{
    MU_FUNCTION_ENTRY();

    // issue the IOCTL to write data
    if (!DeviceIoControl(hMU,      // file handle to the driver
        MU_IOCTL_DISABLE_INTERRUPTS, // I/O control code
        NULL,                      // in buffer
        MUIntr,                    // in buffer size
        NULL,                      // out buffer
        0,                         // out buffer size
        0,                         // number of bytes returned
        NULL))                     // ignored (=NULL)
    {
        DEBUGMSG(ZONE_ERROR,
            (TEXT("%s: MU_IOCTL_DISABLE_INTERRUPTS failed!\r\n"), __WFUNCTION__));
        return ERROR_INVALID_HANDLE;
    }

    MU_FUNCTION_EXIT();

    return ERROR_SUCCESS;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -