diff options
author | yash1112 | 2017-07-07 21:20:49 +0530 |
---|---|---|
committer | yash1112 | 2017-07-07 21:20:49 +0530 |
commit | 3f52712f806fbd80d66dfdcaff401e5cf94dcca4 (patch) | |
tree | a8333b8187cb44b505b9fe37fc9a7ac8a1711c10 /src/c/hardware/avr/gpio/u8AVRDigitalSetups.c | |
download | Scilab2C_fossee_old-3f52712f806fbd80d66dfdcaff401e5cf94dcca4.tar.gz Scilab2C_fossee_old-3f52712f806fbd80d66dfdcaff401e5cf94dcca4.tar.bz2 Scilab2C_fossee_old-3f52712f806fbd80d66dfdcaff401e5cf94dcca4.zip |
sci2c arduino updated
Diffstat (limited to 'src/c/hardware/avr/gpio/u8AVRDigitalSetups.c')
-rw-r--r-- | src/c/hardware/avr/gpio/u8AVRDigitalSetups.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/c/hardware/avr/gpio/u8AVRDigitalSetups.c b/src/c/hardware/avr/gpio/u8AVRDigitalSetups.c new file mode 100644 index 0000000..e28c468 --- /dev/null +++ b/src/c/hardware/avr/gpio/u8AVRDigitalSetups.c @@ -0,0 +1,70 @@ +// Function to decide direction of a digital pin on AVR +// +// Calling Sequence +// AVRDigitalSetup(port,pin,direction) +// +// Parameters +// port : port of microcontroller to be used (1 for PORTA, 2 for PORTB,...) +// pin : pin of port (mentioned above) to be used +// direction : direction to be set for pin (0 for input, 1 for output) +// +// Description +// Each AVR microcontroller has pins which can be configured as digital +// outputs/inputs. These are normally divided among some 'ports' (group of pins). +// User has to select one of these port and which pin of that port to be +// used as digital output/input. Also, desired direction must be specified as +// 'INPUT' or 'OUTPUT'. +// +// Examples +// AVRDigitalSetup(1,0,1) +// +// Authors +// Siddhesh Wani +// + +#include "AVRPeripheralGPIO.h" + + +void u8AVRDigitalSetups(uint8 port,uint8 pin,uint8 direction) +{ + + if (direction == INPUT) + {/*Set pin as input*/ + if(port == PORT_A) + { + DDRA = DDRA & ~(1<<pin); + } + if(port == PORT_B) + { + DDRB = DDRB & ~(1<<pin); + } + if(port == PORT_C) + { + DDRC = DDRC & ~(1<<pin); + } + if(port == PORT_D) + { + DDRD = DDRD & ~(1<<pin); + } + } + else + {/*Set pin as output*/ + if(port == PORT_A) + { + DDRA = DDRA | (1<<pin); + } + if(port == PORT_B) + { + DDRB = DDRB | (1<<pin); + } + if(port == PORT_C) + { + DDRC = DDRC | (1<<pin); + } + if(port == PORT_D) + { + DDRD = DDRD | (1<<pin); + } + } +} + |