Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 3.13 KB

REQUIREMENTS.md

File metadata and controls

62 lines (46 loc) · 3.13 KB

Requirements for stdpins.h

Objectives

  1. Define port and pin used for a signal, easily changed later in the development process
  2. Define polarity of a signal, i. e. active high or active low, easily changed later in the development process
  3. use port/pin/polarity definition for regular input/output
  4. Simulate open-collector outputs
  5. use port/pin/polarity for pin change interrupt applications
  6. also be able to use 3rd party libraries such as VUSB or IRMP, which require specifying a port letter and pin number as separate #defines,
  7. also be able to use Arduino libraries, which refer to pins by the number used in the Arduino IDE
  8. Refer to pins with alternate functions like RXD0 or OC1B in a manner that is independent of the controller model (e. g. is PB1 on ATtiny85, but PD5 on ATmega328, and PD4 on ATmega644)

Requirements

Environment

  • R001 usable in C programs
  • R002 usable in C++ programs
  • R003 usable in "classic" AVR projects (AtmelStudio)
  • R004 usable in Arduino projects
  • R005 usable for projects with ATmega µCs
  • R006 usable for projects with ATtiny µCs

Basic I/O

  • R011 Assign information about port/pin/polarity to one symbol (preprocessor #define or variable)

  • R012 Set output using defined port/pin/polarity

    • R012.1 set output to true or false or a variable (polarity aware)
    • R012.2 set output to high or low (not polarity aware)
  • R013 Test input using defined port/pin/polarity

    • R013.1 test if input is true or false (polarity aware)
    • R013.2 test if input is high or low (not polarity aware)
  • R014 Define data direction using defined port/pin, as one of input (pull-up undefined), input with pull-up, input without pull-up, output

Open-collector outputs

  • R015 declare an output as open-collector (implies active-low polarity)
  • R016 simulate open-collector behavior when setting the output value

Alternate function names

  • R021 define alternate function names that can be used like normal pin/port/polarity definitions, independent of controller type
    • R021.1 define names for UART pins
    • R021.2 define names for I2C pins
    • R021.3 define names for external interrupt pins (polarity aware)
    • R021.4 define names for timer PWM pins (polarity aware)

Compatibility with other libraries

  • R031 extract port name like 'A', 'B', 'C' from port & pin definition
  • R032 extract bit number 0..7 from port & pin definition
  • R033 calculate Arduino pin number from port & pin
  • R033.1 calculate Arduino pin number for ATmega168/328 based boards
  • R033.2 calculate Arduino pin number for ATmega324/644/1284 based boards

Support for pin change interrupts

  • R041 calculate name of pin change interrupt mask register PCMSKn from pin/port/polarity definition
  • R042 calculate name of pin change interrupt enable register PCIEn from pin/port/polarity definition
  • R043 calculate name of pin change interrupt vector PCINTx_vect from pin/port/polarity definition