Migrate from https://cmakerhk.wordpress.com/2018/10/13/marco-define/
#include #include #include "avr/interrupt.h" typedef unsigned char BYTE; //8bit 0-255 typedef unsigned int BYTE2; //16bit 0-65535 typedef unsigned long BYTE4;//32bit 0-4294967295 typedef enum { FALSE, TRUE } bool; // 0 false, 1 true //Marcos of register #define F_CPU 16000000UL // 16 MHz for ATmega328p, UL stand for unsigned integer #define SETBIT(ADDRESS,BIT) (ADDRESS |= (1< //exam ultimate shorthand /* * EIE3105_exam.c * * Created: 12/4/2017 12:51:11 AM * Author : CenzSA12 */ #define F_CPU 16000000UL // 16 MHz for ATmega328p, UL stand for unsigned integer #define prescaler 256 #define F_CPU_prescaler 16000000UL/prescaler #include #include #include "avr/interrupt.h" typedef unsigned char BYTE; //8bit 0-255 typedef unsigned int BYTE2; //16bit 0-65535 typedef unsigned long BYTE4;//32bit 0-4294967295 typedef enum { FALSE, TRUE } bool; // 0 false, 1 true //Marcos of register #define SETBIT(ADDRESS,BIT) (ADDRESS |= (1< #define ASCIIHex2Num(__ASCII__) (__ASCII__ & 0x0F) + 9*((__ASCII__ & 0x40) >> 6) #define Num2ASCII_CAP(__Num__) (__Num__ | 0x30) + 7*(__Num__ / 10 ) int main () { int i = 0; char c = 'C'; i = ASCIIHex2Num ('e'); printf("%i", i); c = Num2ASCII_CAP (i); printf ("%c", c); return 0; }