MHVLib
20111011
An efficiency oriented runtime library for AVR microcontrollers
|
#include <avr/io.h>
#include <inttypes.h>
#include <stddef.h>
#include <util/atomic.h>
Go to the source code of this file.
Classes | |
struct | mhv_pin |
Defines | |
#define | MHV_IO_H_ |
#define | NORETURN __attribute__ ((noreturn)) |
#define | PURE __attribute__ ((pure)) |
#define | GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) |
#define | mhv_make_pin(_mhv_port, _mhv_bit) _mhv_make_pin(_mhv_port, _mhv_bit) |
#define | _mhv_make_pin(_mhv_port, _mhv_bit) MHV_PIN_ ## _mhv_port ## _mhv_bit |
#define | mhv_pin(mhvParms) _mhv_pin(mhvParms) |
#define | _mhv_pin(mhvDir, mhvOutput, mhvInput, mhvBit, mhvPCInt) {mhvDir, mhvOutput, mhvInput, _BV(mhvBit), mhvPCInt} |
#define | mhv_out(mhvParms) _mhv_out(mhvParms) |
#define | _mhv_out(mhvDir, mhvOutput, mhvInput, mhvBit, mhvPCInt) mhvOutput |
#define | mhv_in(mhvParms) _mhv_in(mhvParms) |
#define | _mhv_in(mhvDir, mhvOutput, mhvInput, mhvBit, mhvPCInt) mhvInput |
#define | mhv_bit(mhvParms) _mhv_bit(mhvParms) |
#define | _mhv_bit(mhvDir, mhvOutput, mhvInput, mhvBit, mhvPCInt) mhvBit |
#define | mhv_dir(mhvParms) _mhv_dir(mhvParms) |
#define | _mhv_dir(mhvDir, mhvOutput, mhvInput, mhvBit, mhvPCInt) mhvDir |
#define | mhv_pcint(mhvParms) _mhv_pcint(mhvParms) |
#define | _mhv_PCInt(mhvDir, mhvOutput, mhvInput, mhvBit, mhvPCInt) mhvPCInt |
#define | mhv_declareExternalInterrupt(mhvInterruptParms, mhvFunction) _mhv_declareExternalInterrupt(mhvInterruptParms, mhvFunction) |
#define | _mhv_declareExternalInterrupt(mhvInterruptHandler, mhvModeRegister, mhvModeBitshift, mhvFunction) ISR(mhvInterruptHandler) mhvFunction |
#define | mhv_enableExternalInterrupt(mhvInterruptParms, mhvInterruptMode) |
#define | _mhv_enableExternalInterrupt(mhvInterruptHandler, mhvModeRegister, mhvModeBitshift, mhvInterruptMode) *mhvModeRegister = (*mhvModeRegister & ~(0x03 << mhvModeBitshift)) | (mhvInterruptMode << mhvModeBitshift) |
Typedefs | |
typedef struct mhv_pin | MHV_PIN |
typedef enum mhv_interruptMode | MHV_INTERRUPTMODE |
Enumerations | |
enum | mhv_interruptMode { MHV_INTERRUPT_LOW, MHV_INTERRUPT_CHANGE, MHV_INTERRUPT_FALLING, MHV_INTERRUPT_RISING } |
Functions | |
void | mhv_pinOn (MHV_PIN *pin) |
void | mhv_pinOnAtomic (MHV_PIN *pin) |
void | mhv_pinOn (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_pinOnAtomic (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_pinOff (MHV_PIN *pin) |
void | mhv_pinOffAtomic (MHV_PIN *pin) |
void | mhv_pinOff (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_pinOffAtomic (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_pinSet (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt, bool state) |
void | mhv_pinSetAtomic (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt, bool state) |
void | mhv_setOutput (MHV_PIN *pin) |
void | mhv_setOutputAtomic (MHV_PIN *pin) |
void | mhv_setOutput (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_setOutputAtomic (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_setInput (MHV_PIN *pin) |
void | mhv_setInputAtomic (MHV_PIN *pin) |
void | mhv_setInput (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_setInputAtomic (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_setInputPullup (MHV_PIN *pin) |
void | mhv_setInputPullupAtomic (MHV_PIN *pin) |
void | mhv_setInputPullup (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_setInputPullupAtomic (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_pinToggle (MHV_PIN *pin) |
void | mhv_pinToggleAtomic (MHV_PIN *pin) |
void | mhv_pinToggle (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_pinToggleAtomic (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
bool | mhv_pinRead (MHV_PIN *pin) |
bool | mhv_pinRead (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t bit, int8_t pcInt) |
void | mhv_memClear (void *bufIn, uint8_t len, uint8_t count) |
void | mhv_memClear (void *bufIn, uint8_t len) |
#define _mhv_bit | ( | mhvDir, | |
mhvOutput, | |||
mhvInput, | |||
mhvBit, | |||
mhvPCInt | |||
) | mhvBit |
#define _mhv_declareExternalInterrupt | ( | mhvInterruptHandler, | |
mhvModeRegister, | |||
mhvModeBitshift, | |||
mhvFunction | |||
) | ISR(mhvInterruptHandler) mhvFunction |
#define _mhv_dir | ( | mhvDir, | |
mhvOutput, | |||
mhvInput, | |||
mhvBit, | |||
mhvPCInt | |||
) | mhvDir |
#define _mhv_enableExternalInterrupt | ( | mhvInterruptHandler, | |
mhvModeRegister, | |||
mhvModeBitshift, | |||
mhvInterruptMode | |||
) | *mhvModeRegister = (*mhvModeRegister & ~(0x03 << mhvModeBitshift)) | (mhvInterruptMode << mhvModeBitshift) |
#define _mhv_in | ( | mhvDir, | |
mhvOutput, | |||
mhvInput, | |||
mhvBit, | |||
mhvPCInt | |||
) | mhvInput |
#define _mhv_make_pin | ( | _mhv_port, | |
_mhv_bit | |||
) | MHV_PIN_ ## _mhv_port ## _mhv_bit |
#define _mhv_out | ( | mhvDir, | |
mhvOutput, | |||
mhvInput, | |||
mhvBit, | |||
mhvPCInt | |||
) | mhvOutput |
#define _mhv_PCInt | ( | mhvDir, | |
mhvOutput, | |||
mhvInput, | |||
mhvBit, | |||
mhvPCInt | |||
) | mhvPCInt |
#define _mhv_pin | ( | mhvDir, | |
mhvOutput, | |||
mhvInput, | |||
mhvBit, | |||
mhvPCInt | |||
) | {mhvDir, mhvOutput, mhvInput, _BV(mhvBit), mhvPCInt} |
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) |
#define mhv_bit | ( | mhvParms | ) | _mhv_bit(mhvParms) |
#define mhv_declareExternalInterrupt | ( | mhvInterruptParms, | |
mhvFunction | |||
) | _mhv_declareExternalInterrupt(mhvInterruptParms, mhvFunction) |
#define mhv_dir | ( | mhvParms | ) | _mhv_dir(mhvParms) |
#define mhv_enableExternalInterrupt | ( | mhvInterruptParms, | |
mhvInterruptMode | |||
) |
#define mhv_in | ( | mhvParms | ) | _mhv_in(mhvParms) |
#define mhv_make_pin | ( | _mhv_port, | |
_mhv_bit | |||
) | _mhv_make_pin(_mhv_port, _mhv_bit) |
#define mhv_out | ( | mhvParms | ) | _mhv_out(mhvParms) |
#define mhv_pcint | ( | mhvParms | ) | _mhv_pcint(mhvParms) |
#define mhv_pin | ( | mhvParms | ) | _mhv_pin(mhvParms) |
typedef enum mhv_interruptMode MHV_INTERRUPTMODE |
enum mhv_interruptMode |
Situations that interrupts can be triggered on
void mhv_memClear | ( | void * | bufIn, |
uint8_t | len, | ||
uint8_t | count | ||
) | [inline] |
void mhv_memClear | ( | void * | bufIn, |
uint8_t | len | ||
) | [inline] |
void mhv_pinOff | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_pinOff | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
void mhv_pinOffAtomic | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_pinOffAtomic | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
Set an output pin off (used if the state of a pin on the same port is altered in an interrupt handler)
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pcInt | A member of the MHV_PIN_* macro |
void mhv_pinOn | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_pinOn | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
void mhv_pinOnAtomic | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_pinOnAtomic | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
Set an output pin on (used if the state of a pin on the same port is altered in an interrupt handler)
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pcInt | A member of the MHV_PIN_* macro |
bool mhv_pinRead | ( | MHV_PIN * | pin | ) | [inline] |
bool mhv_pinRead | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
void mhv_pinSet | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt, | ||
bool | state | ||
) | [inline] |
Set an output pin on or off (state should really be constant for optimal performance)
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pcInt | A member of the MHV_PIN_* macro |
state | true to turn the pin on |
void mhv_pinSetAtomic | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt, | ||
bool | state | ||
) | [inline] |
Set an output pin on or off (state should really be constant for optimal performance) (used if the state of a pin on the same port is altered in an interrupt handler)
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pcInt | A member of the MHV_PIN_* macro |
state | true to turn the pin on |
void mhv_pinToggle | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_pinToggle | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
void mhv_pinToggleAtomic | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_pinToggleAtomic | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
Toggle a pin (used if the direction of a pin on the same port is altered in an interrupt handler)
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pcInt | A member of the MHV_PIN_* macro |
void mhv_setInput | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_setInput | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
void mhv_setInputAtomic | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_setInputAtomic | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
Set a pin to be an input (used if the direction of a pin on the same port is altered in an interrupt handler)
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pcInt | A member of the MHV_PIN_* macro |
void mhv_setInputPullup | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_setInputPullup | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
void mhv_setInputPullupAtomic | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_setInputPullupAtomic | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
Set a pin to be an input, with the internal pullup enabled (used if the direction of a pin on the same port is altered in an interrupt handler)
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pcInt | A member of the MHV_PIN_* macro |
void mhv_setOutput | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_setOutput | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
void mhv_setOutputAtomic | ( | MHV_PIN * | pin | ) | [inline] |
void mhv_setOutputAtomic | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pcInt | ||
) | [inline] |
Set a pin to be an output (used if the direction of a pin on the same port is altered in an interrupt handler)
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pcInt | A member of the MHV_PIN_* macro |