7.2. Function Reference

7.2.1. BV

#include <io.h>
	    

BV(pos);

description. This macro converts a bit definition into a bit mask. It is intended to be used with the bit definitions in the io.h header file. For instance, to build a mask of both the wdtoe and wde watchdog bits, you would use "BV(WDTOE) | BV(WDE)".

7.2.2. bit_is_clear

#include <io.h>
	    

uint8_t bit_is_clear(uint8_t port, uint8_t bit);

description. Returns 1 if the specified bit in port is clear. bit can be 0 to 7. This function uses the sbic instruction to test the bit, so port needs to be a valid address for that instruction.

7.2.3. bit_is_set

#include <io.h>
	    

uint8_t bit_is_set(uint8_t port, uint8_t bit);

description. Returns 1 if the specified bit in port is set. bit can be 0 to 7. This function uses the sbis instruction to test the bit, so port needs to be a valid address for that instruction.

7.2.4. cbi

#include <io.h>
	    

void cbi(uint8_t port, uint8_t bit);

description. Clears the specified bit, bit, in the I/O register specified by port. bit is a value from 0 to 7 and should be specified as one of the defined symbols in the I/O header files. If port specifies an actual I/O register, this macro reduces to a single in-line assembly instruction. If it isn't an I/O register, it attempts to generate the most efficient code to complete the operation.

see also. sbi()

7.2.5. inp

#include <io.h>
	    

uint8_t inp(uint8_t port);

description. Reads the 8-bit value from the I/O port specified by port. If port is a constant value, this macro assumes the value refers to a valid address and tries to use the in instruction. A variable argument results in an access using direct addressing.

7.2.6. __inw

#include <io.h>
	    

uint16_t __inw(uint8_t port);

description. Reads a 16-bit value from I/O registers. This routine was created for accessing the 16-bit registers (ADC, ICR1, OCR1, TCNT1) because they need to be read in the proper order. This macro should only be used if interrupts are disabled since it only generates the two lines of assembly that reads the register.

7.2.7. __inw_atomic

#include <io.h>
	    

uint16_t __inw_atomic(uint8_t port);

description. Atomically reads a 16-bit value from I/O registers. The generated code disables interrupts during the access and properly restores the interrupt state when through. This routine was created for accessing the 16-bit registers (ADC, ICR1, OCR1, TCNT1) because they need to be read in the proper order. This macro can safely be used in interrupt and non-interrupt routines because it preserves the interrupt enable flag (although you may not want to pay for the extra lines of assembly in an interrupt routine.)

7.2.8. loop_until_bit_is_clear

#include <io.h>
	    

void loop_until_bit_is_clear(uint8_t port, uint8_t bit);

description. This macro generates a very tight polling loop that waits for a bit to become cleared. It uses the sbic instruction to perform the test, so the value of port is restricted to valid I/O register addresses for that instruction. bit is a value from 0 to 7.

7.2.9. loop_until_bit_is_set

#include <io.h>
	    

void loop_until_bit_is_set(uint8_t port, uint8_t bit);

description. This macro generates a very tight polling loop that waits for a bit to become set. It uses the cbic instruction to perform the test, so the value of port is restricted to valid I/O register addresses for that instruction. bit is a value from 0 to 7.

7.2.10. outp

#include <io.h>
	    

void outp(uint8_t val, uint8_t port);

description. Writes the 8-bit value val to port. If port is a constant value, this macro assumes the value refers to a valid address and tries to use the out instruction. A variable argument results in an access using direct addressing.

7.2.11. __outw

#include <io.h>
	    

void __outw(uint16_t val, uint8_t port);

description. Writes to a 16-bit I/O register. This routine was created for manipulating the 16-bit registers (ADC, ICR1, OCR1, TCNT1) because they need to be written in the proper order. This macro should only be used if interrupts are disabled since it only generates the two lines of assembly that modify the register.

7.2.12. __outw_atomic

#include <io.h>
	    

void __outw_atomic(uint16_t val, uint8_t port);

description. Atomically writes to a 16-bit I/O register. The generated code disables interrupts during the access and properly restores the interrupt state when through. This routine was created for accessing the 16-bit registers (ADC, ICR1, OCR1, TCNT1) because they need to be written in the proper order. This macro can safely be used in interrupt and non-interrupt routines because it preserves the interrupt enable flag (although you may not want to pay for the extra lines of assembly in an interrupt routine.)

7.2.13. parity_even_bit

#include <io.h>
	    

void parity_even_bit(uint8_t val);

description. Returns 1 if val has even parity. All eight bits are used in the calculation.

7.2.14. sbi

#include <io.h>
	    

void sbi(uint8_t port, uint8_t bit);

description. Sets the specified bit, bit, in the I/O register specified by port. bit is a value from 0 to 7 and should be specified as one of the defined symbols in the I/O header files. If port specifies an actual I/O register, this macro reduces to a single in-line assembly instruction. If it isn't an I/O register, it attempts to generate the most efficient code to complete the operation.

see also. cbi()