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

📄 utils.c

📁 jennic jn5139模块的睡眠模式代码
💻 C
字号:
/****************************************************************************
 *
 * MODULE:             Utilities Code
 *
 * COMPONENT:          $RCSfile: $
 *
 * VERSION:            $Name:  $
 *
 * REVISION:           $Revision: 0.1 $
 *
 * DATED:              $Date:  $
 *
 * STATUS:             $State: Exp $
 *
 * AUTHOR:             GPfef
 *
 * DESCRIPTION:
 *
 *
 * LAST MODIFIED BY:   $Author: gpfef $
 *                     $Modtime: $
 *
 ****************************************************************************
 *
 *  (c) Copyright 2006 JENNIC Ltd
 *
 ****************************************************************************/

/****************************************************************************/
/***        Include files                                                 ***/
/****************************************************************************/
#include "jendefs.h"
#include <AppHardwareApi.h>
#include "Utils.h"

/****************************************************************************/
/***        Macro Definitions                                             ***/
/****************************************************************************/

/****************************************************************************/
/***        Type Definitions                                              ***/
/****************************************************************************/


/****************************************************************************/
/***        Local Function Prototypes                                     ***/
/****************************************************************************/

/****************************************************************************/
/***        Exported Variables                                            ***/
/****************************************************************************/

/****************************************************************************/
/***        Local Variables                                               ***/
/****************************************************************************/

/****************************************************************************/
/***        Exported Functions                                            ***/
/****************************************************************************/

/****************************************************************************
 *
 * NAME: vUtils_Init
 *
 * DESCRIPTION:
 * Initialises UART
 *
 * PARAMETERS:      Name            RW  Usage
 *
 * RETURNS:
 * void, never returns
 *
 ****************************************************************************/
PUBLIC void vUtils_Init(void)
{
    /* Enable UART 0: 19200-8-N-1 */
    vAHI_UartEnable(E_AHI_UART_0);
    vAHI_UartReset(E_AHI_UART_0, TRUE, TRUE);
    vAHI_UartReset(E_AHI_UART_0, FALSE, FALSE);
    vAHI_UartSetClockDivisor(E_AHI_UART_0, E_AHI_UART_RATE_38400);
}

/****************************************************************************
 *
 * NAME: vUtils_DisplayMsg
 *
 * DESCRIPTION:
 * Used to display text plus number
 *
 * PARAMETERS:      Name            RW  Usage
 *                  pcMessage  		R   Message to display
 *                  u32Data         R   Data to display
 *
 * RETURNS:
 * void, never returns
 *
 ****************************************************************************/
PUBLIC void vUtils_DisplayMsg(char *pcMessage, uint32 u32Data)
{
    //vUtils_Debug(pcMessage);
    while (*pcMessage)
    {
        while ((u8AHI_UartReadLineStatus(0) & 0x20) == 0);
        vAHI_UartWriteData(0, *pcMessage);
        pcMessage++;
    }
    vUtils_DisplayHex(u32Data, 8);
}

/****************************************************************************
 *
 * NAME: vUtils_Debug
 *
 * DESCRIPTION:
 * Sends a string to UART0 using the hardware API.
 *
 * PARAMETERS:      Name            RW  Usage
 *                  pcMessage       R   Null-terminated message to send
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void vUtils_Debug(char *pcMessage)
{
    while (*pcMessage)
    {
        while ((u8AHI_UartReadLineStatus(0) & 0x20) == 0);
        vAHI_UartWriteData(0, *pcMessage);
        pcMessage++;
    }
    vAHI_UartWriteData(0, '\r');
    vAHI_UartWriteData(0, '\n');
}

/****************************************************************************
 *
 * NAME: vUtils_DisplayHex
 *
 * DESCRIPTION:
 *
 * PARAMETERS:      Name            RW  Usage
 *                  u32Data       	R   Value to send
 *					iSize           R   Length of value
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void vUtils_DisplayHex(uint32 u32Data, int iSize)
{
    char acValue[9];
    char *pcString = acValue;
    uint8 u8Nybble;
    int i, j;

    j = 0;
    for (i = (iSize << 2) - 4; i >= 0; i -= 4)
    {
        u8Nybble = (uint8)((u32Data >> i) & 0x0f);
        u8Nybble += 0x30;
        if (u8Nybble > 0x39)
            u8Nybble += 7;

        *pcString = u8Nybble;
        pcString++;
    }
    *pcString = '\0';

    vUtils_Debug(acValue);
}
/****************************************************************************/
/***        Local Functions                                               ***/
/****************************************************************************/


/****************************************************************************/
/***        END OF FILE                                                   ***/
/****************************************************************************/

⌨️ 快捷键说明

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