ATtiny85 Template Code
Code snippets for the ATtiny85
 All Files Functions Variables Typedefs Enumerations Enumerator Macros
utility.c
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------*
2 * General utility functions
3 *---------------------------------------------------------------------------*
4 * 15-Apr-2014 ShaneG
5 *
6 * A collection of utility functions that don't really fit anywhere else.
7 *--------------------------------------------------------------------------*/
8 #include "utility.h"
9 
10 // Determine the inner loop for the 'wait()' function. This is based on 6
11 // instruction cycles per loop.
12 #define WAIT_INNER (F_CPU / 6000)
13 
21 void wait(uint16_t millis) {
22  for(uint16_t outer=0; outer<millis; outer++) {
23  for(uint16_t inner=0; inner<WAIT_INNER; inner++) {
24  asm volatile(
25  " nop \n\t"
26  );
27  }
28  }
29  }
30 
37 char hexChar(uint8_t value) {
38  value &= 0x0F;
39  if(value<10)
40  return '0' + value;
41  return value + 'A' - 10;
42  }
43 
#define WAIT_INNER
Definition: utility.c:12
void wait(uint16_t millis)
Definition: utility.c:21
char hexChar(uint8_t value)
Definition: utility.c:37