odds_and_ends.h File Reference

#include <avr/io.h>
#include <avr/interrupt.h>
#include "config.h"
#include <util/delay.h>
#include <util/delay_basic.h>

Go to the source code of this file.

Functions

uint8_t asciitovalue (uint8_t ascii)
 Convert an ASCII character to its numeric equivalent.
uint8_t hex2ascii_h (uint8_t hexval)
 Convert the top nibble of a btye to ASCII.
uint8_t hex2ascii_l (uint8_t hexval)
 Convert the bottom nibble of a btye to ASCII.
uint8_t bcd_to_hex (uint8_t bcd)
 Convert a BCD value in a byte to the correct hex value.
uint8_t get_bcd_switch_setting (void)
 return a value derived from a BCD switch


Function Documentation

uint8_t asciitovalue ( uint8_t  ascii  ) 

Convert an ASCII character to its numeric equivalent.

Parameters:
ascii ASCII character to convert
Returns:
uint8_t Converted value

uint8_t bcd_to_hex ( uint8_t  bcd  ) 

Convert a BCD value in a byte to the correct hex value.

Parameters:
bcd uint8_t value in BCD
Returns:
returns uint8_t hex value converted from BCD
For example, 23 -> 0x17

uint8_t get_bcd_switch_setting ( void   ) 

return a value derived from a BCD switch

Returns:
uint8_t Top bit set if there has been a change since function last called Bottom (usually 4) bits represent the number on the switch dial. eg dial=6, and this is a change from previous value, return value is 0x86
requires the BCD switch to be on 4 consecutive bits of a single port Needs definitions of BCD_PIN The PIN the switch is on, eg PINB BCD_SHIFT The number of bit positions to shift right to get the value bottom aligned BCD_MASK The mask required to select the switch bits once shifted, nearly always 0x0F

uint8_t hex2ascii_h ( uint8_t  hexval  ) 

Convert the top nibble of a btye to ASCII.

Parameters:
hexval 8 bit value whose top 4 bits are to be converted to ASCII
Returns:
uint8_t Converted value

uint8_t hex2ascii_l ( uint8_t  hexval  ) 

Convert the bottom nibble of a btye to ASCII.

Parameters:
hexval 8 bit value whose bottom 4 bits are to be converted to ASCII
Returns:
uint8_t Converted value


Generated on Wed Nov 10 11:54:59 2010 by  doxygen 1.5.8