github.com/aykevl/tinygo@v0.5.0/src/machine/machine_attiny.go (about)

     1  // +build avr,attiny
     2  
     3  package machine
     4  
     5  import (
     6  	"device/avr"
     7  )
     8  
     9  // Configure sets the pin to input or output.
    10  func (p GPIO) Configure(config GPIOConfig) {
    11  	if config.Mode == GPIO_OUTPUT { // set output bit
    12  		*avr.DDRB |= 1 << p.Pin
    13  	} else { // configure input: clear output bit
    14  		*avr.DDRB &^= 1 << p.Pin
    15  	}
    16  }
    17  
    18  func (p GPIO) getPortMask() (*avr.RegValue, uint8) {
    19  	return avr.PORTB, 1 << p.Pin
    20  }
    21  
    22  // Get returns the current value of a GPIO pin.
    23  func (p GPIO) Get() bool {
    24  	val := *avr.PINB & (1 << p.Pin)
    25  	return (val > 0)
    26  }
    27  
    28  // UART on the AVR is a dummy implementation. UART has not been implemented for ATtiny
    29  // devices.
    30  type UART struct {
    31  	Buffer *RingBuffer
    32  }
    33  
    34  // Configure is a dummy implementation. UART has not been implemented for ATtiny
    35  // devices.
    36  func (uart UART) Configure(config UARTConfig) {
    37  }
    38  
    39  // WriteByte is a dummy implementation. UART has not been implemented for ATtiny
    40  // devices.
    41  func (uart UART) WriteByte(c byte) error {
    42  	return nil
    43  }
    44  
    45  // Tx is a dummy implementation. I2C has not been implemented for ATtiny
    46  // devices.
    47  func (i2c I2C) Tx(addr uint16, w, r []byte) error {
    48  	return nil
    49  }