diff options
author | Ayke van Laethem <[email protected]> | 2019-04-28 18:49:17 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-05-26 20:48:50 +0200 |
commit | 94b8214529f1cebad2cc45b5c1820695a7dd8201 (patch) | |
tree | 62ea7f3171ba0a3f106998e2ddc8ed1c7e799f59 /src/machine/machine_avr.go | |
parent | 421ef04efb87889d73d5b404202a655f41d2e1e4 (diff) | |
download | tinygo-94b8214529f1cebad2cc45b5c1820695a7dd8201.tar.gz tinygo-94b8214529f1cebad2cc45b5c1820695a7dd8201.zip |
machine: refactor pins to be of Pin type
Diffstat (limited to 'src/machine/machine_avr.go')
-rw-r--r-- | src/machine/machine_avr.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/machine/machine_avr.go b/src/machine/machine_avr.go index ffb88d913..51bf77614 100644 --- a/src/machine/machine_avr.go +++ b/src/machine/machine_avr.go @@ -6,15 +6,15 @@ import ( "device/avr" ) -type GPIOMode uint8 +type PinMode uint8 const ( - GPIO_INPUT = iota - GPIO_OUTPUT + PinInput PinMode = iota + PinOutput ) // Set changes the value of the GPIO pin. The pin must be configured as output. -func (p GPIO) Set(value bool) { +func (p Pin) Set(value bool) { if value { // set bits port, mask := p.PortMaskSet() port.Set(mask) @@ -30,7 +30,7 @@ func (p GPIO) Set(value bool) { // Warning: there are no separate pin set/clear registers on the AVR. The // returned mask is only valid as long as no other pin in the same port has been // changed. -func (p GPIO) PortMaskSet() (*avr.Register8, uint8) { +func (p Pin) PortMaskSet() (*avr.Register8, uint8) { port, mask := p.getPortMask() return port, port.Get() | mask } @@ -41,7 +41,7 @@ func (p GPIO) PortMaskSet() (*avr.Register8, uint8) { // Warning: there are no separate pin set/clear registers on the AVR. The // returned mask is only valid as long as no other pin in the same port has been // changed. -func (p GPIO) PortMaskClear() (*avr.Register8, uint8) { +func (p Pin) PortMaskClear() (*avr.Register8, uint8) { port, mask := p.getPortMask() return port, port.Get() &^ mask } @@ -68,7 +68,7 @@ func (a ADC) Get() uint16 { // set the ADLAR bit (left-adjusted result) to get a value scaled to 16 // bits. This has the same effect as shifting the return value left by 6 // bits. - avr.ADMUX.Set(avr.ADMUX_REFS0 | avr.ADMUX_ADLAR | (a.Pin & 0x07)) + avr.ADMUX.Set(avr.ADMUX_REFS0 | avr.ADMUX_ADLAR | (uint8(a.Pin) & 0x07)) // start the conversion avr.ADCSRA.SetBits(avr.ADCSRA_ADSC) |