V2.0

Readme.txt

Actual readme is in AVRAugment_io.h header (generated from "avr bitfield pin header generator.py" ). Btw you are recommeded to add this for inclusion on top of sourcecode.

#include "./AVRAugment_io.h" // for SET_REG( REG_NAME , PIN , VALUE ) & GET_REG( REG_NAME , PIN )

/* This is for those who want a more self discriptive sourcecode */
// Port Register Alias (Definition from "Register Description" in various atmel microcontroller datasheet ) 
// ( x = port alphabet ) (Extra info http://www.zembedded.com/avr-registers-explained/ ) 
#define PINMODE    DDR   ; // DDRx  : Data Direction Register (highBit=output::lowBit=input)
#define SETOUTPUT PORT  ; // PORTx : PORT x data register (if"DDRxn"=highBit??highBit=drivenHigh::lowBit=drivenLow) (if"DDRxn"=lowBit??highBit=pullUp::lowBit=floatingPin)
#define READPIN PIN   ; // PINx  : Port x INput pins address (highBit=sensedHigh::lowBit=sensedLow)

// boolean preprocessor constants
#define HIGH 0x1
#define LOW  0x0
#define INPUT 0x0
#define OUTPUT 0x1
#define true 0x1
#define false 0x0
#define PULLUP 0x1
#define FLOATING 0x0

/* Reference Sheet for digital pins:: e.g: 
        # Write digital output high/low
        "SET_REG(PINMODE,B3,OUTPUT)" --> "SET_REG(SETOUTPUT,B3,HIGH)" 
        "SET_REG(PINMODE,B3,OUTPUT)" --> "SET_REG(SETOUTPUT,B3,LOW)" 
        # Read digitial input (floating or with internal pullup resistor)
        "SET_REG(PINMODE,B3,INPUT)" --> "SET_REG(SETOUTPUT,B3,PULLUP)" --> "GET_REG(READPIN,B3)"
        "SET_REG(PINMODE,B3,INPUT)" --> "SET_REG(SETOUTPUT,B3,FLOATING)" --> "GET_REG(READPIN,B3)"
*/

internal readme

// Generated @ Sat 11-07-2015 03:17AM 48sec
/*
    TITLE:   AVR Augmentation for io.h
    Purpose: Increase portability, Readability, Save time
    AUTHOR:  Brian Khuu
    Version: V2.0
        Objective of V2:: 
            To basically allow for flexible usage of registers beyond whatever is defined in this.
                e.g.
                    Instead of:             SET_PORT( B1, 0xFF) --> Sets bit 1 @ PORTB to 1	
                    Want something like:    SET_REG(PORT, B1, OxFF) 
                    This method is more intuitive as well. But works only if the naming convention by Atmel remains consistent in this format::
                      Register Location: < REGISTER TYPE NAME (e.g. DDR ) > < REGISTER LETTER > ( e.g. DDRB )
                      Pin Naming:        < REGISTER LETTER > < Pin Number >

                    Thus what I would need to generate in masses is like this::
                      #define B1_BITMASK PB1
                      #define B1_NUMBER 1
                      #define B1_LETTER B
    Assumption:
        That you are using io.h (For avr MCU) and
        that it splits IOs into banks of Port letters each with an word sized of pin numbers
            e.g. ( PA5 -> Port A pin 5 . Is a macro within io.h )
        Port letters Supported: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
        Pin numbers Supported: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16

        Also assumes that Pxn is defined, and that registers are named like DDRx or PINx or PORTx etc... (x=letter, n=number)

    cite: initial inspiration from cinderblock "[CODE] [C] Simplifying PORT and DDR #defines for Portability
           http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=73829
    cite: "GET" and "SET" macros from David Jahshan's game_console Template

    Example blink code for the arduino UNO in C located in bottom of this header file
*/

~~~~~~~~~ EXAMPLE ~~~~~~~~~~~

// Example blink code for Arduino UNO 16MHz (atmega328p)
#define F_CPU 16000000UL // For delay.h to function
#include <avr/io.h> // PIN, DDR, PORT defs
#include <util/delay.h> //_delay_ms()
#include "./AVRAugment_io.h"
##define LED13 B5 // Only need to change this to swap pins
#define DDR_13	SET_REG( DDR, LED13, 0xFF ) //IN=0x00, OUT=0xFF
#define ON_13	SET_REG( PORT, LED13, 0xFF ) //LOW=0x00, HIGH=0xFF
#define OFF_13	SET_REG( PORT, LED13, 0x00 ) //LOW=0x00, HIGH=0xFF
int main(void)
{
	DDR_13;
	ON_13;
	while(1)
	{
		_delay_ms(2000);
		OFF_13;
		_delay_ms(2000);
		ON_13;
	}
}

link

--

V1.1

minor fixes to readme, and regen all files

link


V1.0

This is some header file which is useful when coding for embedded AVR microprocessors.

TITLE: AVR Augmentation for io.h Purpose: Increase portability, Readability, Save time AUTHOR: Brian Khuu Version: V1.0

Assumption: That you are using io.h (For avr MCU) and that it splits IOs into banks of Port letters each with an word sized of pin numbers e.g. ( PA5 -> Port A pin 5 . Is a macro within io.h ) Port letters Supported: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P Pin numbers Supported: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16

cite: initial inspiration from cinderblock "[CODE] [C] Simplifying PORT and DDR #defines for Portability http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=73829 cite: "GET" and "SET" macros from David Jahshan's game_console Template

Example blink code for the arduino UNO in C located in bottom of this header file

link