www.pudn.com > Test_rtl8019_SRAM.zip > utils.c, change:2009-11-06,size:1733b


/**
//
//  @file	 		utils.c
//  @author 		RA Sewell
//  @brief 			Butterfly MP3 utility routines
//
//  Target(s)...: ATmega169
//
//  Compiler....: AVR-GCC 3.3.1; avr-libc 1.0
//
//  Revisions...: 1.0
//
//  YYYYMMDD - VER. - COMMENT                                       - SIGN.
//
//  20060304 - 1.0  - Created                                       - KS
// 
**/

#include "utils.h" 
#include "typedefs.h"
#include <inttypes.h>
#include <avr/pgmspace.h> 


/*****************************************************************************
*
*   Function name : strLen
*
*   Returns :       Length of string
*
*   Parameters :    None
*
*   Purpose :       Find the length of a string (excluding NULL char)
*
*****************************************************************************/
uint16 strLen(uint8 *str)
{
   uint16 len;

   for (len = 0; str[len] != 0x00; len++);

   return (len);
}
 
 
uint16 strLenP(uint8 *str)
{
   uint16 len;

   for (len = 0; pgm_read_byte((int)str + len) != 0x00; len++);

   return (len);
}

/*****************************************************************************
*
*   Function name : strCatChar
*
*   Returns :       None
*
*   Parameters :    None
*
*   Purpose :       Append a byte to a string buffer
*
*****************************************************************************/
void strCatChar(uint8 *str, uint8 byte)
{
   uint16 len;

   len = strLen(str);
   str[len] = byte;
   str[len+1] = '\0';
}


 
#ifdef HEARTBEAT_BIT 
void HeartBeat(void) 
{ 
    static uint8_t beat; 
 
    if ((beat = !beat) == 0) { 
        cbi(HEARTBEAT_PORT, HEARTBEAT_BIT); 
    } 
    else { 
        sbi(HEARTBEAT_PORT, HEARTBEAT_BIT); 
    } 
    sbi(HEARTBEAT_DDR, HEARTBEAT_BIT); 
} 
#endif