summaryrefslogtreecommitdiff
path: root/src/c/hardware
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/hardware')
-rw-r--r--src/c/hardware/avr/adc/u8AVRADCSetups.c43
-rw-r--r--src/c/hardware/avr/adc/u8AVRReadADCs.c82
-rw-r--r--src/c/hardware/avr/default_files/Makefile387
-rw-r--r--src/c/hardware/avr/gpio/u8AVRDigitalIns.c63
-rw-r--r--src/c/hardware/avr/gpio/u8AVRDigitalOuts.c78
-rw-r--r--src/c/hardware/avr/gpio/u8AVRDigitalPortSetups.c81
-rw-r--r--src/c/hardware/avr/gpio/u8AVRDigitalSetups.c70
-rw-r--r--src/c/hardware/avr/includes/AVRPeripheralADC.h27
-rw-r--r--src/c/hardware/avr/includes/AVRPeripheralGPIO.h54
-rw-r--r--src/c/hardware/avr/includes/AVRPeripheralPWM.h34
-rw-r--r--src/c/hardware/avr/includes/AVRPeripheralTimer.h32
-rw-r--r--src/c/hardware/avr/includes/AVRPeripheralUART.h59
-rw-r--r--src/c/hardware/avr/includes/AVRUtil.h31
-rw-r--r--src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h32
-rw-r--r--src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h40
-rw-r--r--src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h39
-rw-r--r--src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h31
-rw-r--r--src/c/hardware/avr/interfaces/int_AVRPeripheralUART.h57
-rw-r--r--src/c/hardware/avr/interfaces/int_AVRUtil.h32
-rw-r--r--src/c/hardware/avr/pwm/u8AVRPWM0SetDutys.c24
-rw-r--r--src/c/hardware/avr/pwm/u8AVRPWM0Setups.c50
-rw-r--r--src/c/hardware/avr/pwm/u8AVRPWM1SetDutys.c31
-rw-r--r--src/c/hardware/avr/pwm/u8AVRPWM1Setups.c69
-rw-r--r--src/c/hardware/avr/pwm/u8AVRPWM2SetDutys.c22
-rw-r--r--src/c/hardware/avr/pwm/u8AVRPWM2Setups.c47
-rw-r--r--src/c/hardware/avr/timer/u16AVRGetTimerValues.c51
-rw-r--r--src/c/hardware/avr/timer/u8AVRGetTimerValues.c63
-rw-r--r--src/c/hardware/avr/timer/u8AVRTimerSetups.c110
-rw-r--r--src/c/hardware/avr/uart/dAVRUARTTransmits.c88
-rw-r--r--src/c/hardware/avr/uart/dAVRUARTTransmitu8.c21
-rw-r--r--src/c/hardware/avr/uart/gAVRUARTTransmita.c26
-rw-r--r--src/c/hardware/avr/uart/gAVRUARTTransmits.c31
-rw-r--r--src/c/hardware/avr/uart/gAVRUARTTransmitu8.c24
-rw-r--r--src/c/hardware/avr/uart/i16AVRUARTTransmita.c27
-rw-r--r--src/c/hardware/avr/uart/i16AVRUARTTransmits.c73
-rw-r--r--src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c31
-rw-r--r--src/c/hardware/avr/uart/i8AVRUARTTransmita.c25
-rw-r--r--src/c/hardware/avr/uart/i8AVRUARTTransmits.c26
-rw-r--r--src/c/hardware/avr/uart/u16AVRUARTTransmita.c28
-rw-r--r--src/c/hardware/avr/uart/u16AVRUARTTransmits.c87
-rw-r--r--src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c38
-rw-r--r--src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c20
-rw-r--r--src/c/hardware/avr/uart/u8AVRUARTSetups.c143
-rw-r--r--src/c/hardware/avr/uart/u8AVRUARTTransmita.c26
-rw-r--r--src/c/hardware/avr/uart/u8AVRUARTTransmits.c60
-rw-r--r--src/c/hardware/avr/util/u16AVRSleeps.c21
-rw-r--r--src/c/hardware/rasberrypi/ISR/i16RPIPinISRs.c25
-rw-r--r--src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c24
-rw-r--r--src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c26
-rw-r--r--src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c39
-rw-r--r--src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h36
-rw-r--r--src/c/hardware/rasberrypi/includes/RPIPeripheralPWM.h31
-rw-r--r--src/c/hardware/rasberrypi/includes/RPIPeripheralPinISR.h26
-rw-r--r--src/c/hardware/rasberrypi/includes/RPIPeripheralSerial.h49
-rw-r--r--src/c/hardware/rasberrypi/includes/RPIPeripheralThreading.h28
-rw-r--r--src/c/hardware/rasberrypi/includes/RPIPeripheralTiming.h34
-rw-r--r--src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h33
-rw-r--r--src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralPWM.h30
-rw-r--r--src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralPinISR.h25
-rw-r--r--src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralSerial.h47
-rw-r--r--src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralThreading.h25
-rw-r--r--src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralTiming.h34
-rw-r--r--src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetClocks.c27
-rw-r--r--src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetModes.c28
-rw-r--r--src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetRanges.c25
-rw-r--r--src/c/hardware/rasberrypi/pwm/u8RPIHardPWMWrites.c26
-rw-r--r--src/c/hardware/rasberrypi/serial/dRPISerialSendDataa.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/dRPISerialSendDatas.c35
-rw-r--r--src/c/hardware/rasberrypi/serial/gRPISerialSendDatas.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/i16RPISerialDataAvails.c25
-rw-r--r--src/c/hardware/rasberrypi/serial/i16RPISerialGetChars.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/i16RPISerialSendDataa.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/i16RPISerialSendDatas.c24
-rw-r--r--src/c/hardware/rasberrypi/serial/i8RPISerialSendDataa.c26
-rw-r--r--src/c/hardware/rasberrypi/serial/i8RPISerialSendDatas.c22
-rw-r--r--src/c/hardware/rasberrypi/serial/sRPISerialSendDataa.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/sRPISerialSendDatas.c34
-rw-r--r--src/c/hardware/rasberrypi/serial/u16RPISerialSendDataa.c28
-rw-r--r--src/c/hardware/rasberrypi/serial/u16RPISerialSendDatas.c23
-rw-r--r--src/c/hardware/rasberrypi/serial/u16RPISerialSetups.c25
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialCloses.c21
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialFlushs.c21
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialSendChars.c21
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialSendDataa.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialSendDatas.c22
-rw-r--r--src/c/hardware/rasberrypi/threading/u16RPIThreadCreates.c24
-rw-r--r--src/c/hardware/rasberrypi/timing/u16RPIDelayMicros.c22
-rw-r--r--src/c/hardware/rasberrypi/timing/u16RPIDelayMillis.c25
-rw-r--r--src/c/hardware/rasberrypi/timing/u32RPIGetMicros.c21
-rw-r--r--src/c/hardware/rasberrypi/timing/u32RPIGetMillis.c21
90 files changed, 3754 insertions, 0 deletions
diff --git a/src/c/hardware/avr/adc/u8AVRADCSetups.c b/src/c/hardware/avr/adc/u8AVRADCSetups.c
new file mode 100644
index 0000000..66f491b
--- /dev/null
+++ b/src/c/hardware/avr/adc/u8AVRADCSetups.c
@@ -0,0 +1,43 @@
+// Function to initialise ADC of AVR
+//
+// Calling Sequence
+// AVRSetupADC(uint8 prescaler, uint8 adc_ref)
+//
+// Parameters
+// prescaler: prescaler to be used for generating ADC clock (0-7)
+// adc_ref : reference voltage to be used for ADC conversion
+// 0 -> Voltage on VREF pin
+// 1 -> Voltage on AVCC pin
+// 2 -> Internal 2.56 reference voltage
+//
+// Description
+// This function initialises ADc of AVR with given parameters. 'prescaler' is
+// needed for deciding ADC clock. ADC clock should be between 50KHz and 200KHz
+// and it given as (MCU clock/2^prescaler). Select appropriate prescaler depending
+// on MCU clock. 'adc_ref' selects one of the available reference voltage sources
+// available
+// Examples
+// AVRADCSetup(128,0)
+//
+// Authors
+// Siddhesh Wani
+// Ashish Kamble
+
+#include "AVRPeripheralADC.h"
+
+
+uint8 u8AVRADCSetups(uint8 prescaler, uint8 adc_ref)
+{
+/*Set the prescaler value*/
+ ADCSRA |= (prescaler & 0x07);
+
+ /*Set the adc reference voltage*/
+ ADMUX |= ((adc_ref & 0x03) << 6);
+
+ /*Enable ADC hardware. Set ADEN bit*/
+ADCSRA |= (1<<7);
+
+return 0;
+}
+
+
diff --git a/src/c/hardware/avr/adc/u8AVRReadADCs.c b/src/c/hardware/avr/adc/u8AVRReadADCs.c
new file mode 100644
index 0000000..302f8c8
--- /dev/null
+++ b/src/c/hardware/avr/adc/u8AVRReadADCs.c
@@ -0,0 +1,82 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+// Function to get voltage on analog pin on AVR
+//
+// Calling Sequence
+// u8AVRReadADCs(channel)
+//
+// Parameters
+// channel : Select which channel is to be read. Values from 0-7 select one
+// of the pins ADC0-ADC7. For other possible channel values refer
+// datasheet
+// Returns->
+// result : Digital value for the voltage present on channel selected
+//
+// Description
+// This function returns digital value for present on adc pins. 'channel'
+// selects which of the ADC0-ADC7 is to be used for reading analog value.
+// Apart from reading just ADC0-ADC7 other it can also read differential
+// voltages between some pins. For channel values for those options, please
+// refer datasheet.
+//
+// Examples
+// adc_result = u8AVRReadADC(0) //Read ADC0
+//
+// Authors
+// Siddhesh Wani
+// Ashish Kamble
+
+
+#include "AVRPeripheralADC.h"
+
+uint8 u8AVRReadADCs(uint8 channel)
+{
+
+uint8 i;
+
+ ADCH=0x00;
+
+ i=channel&0x07;
+ ADMUX=i|0x60; //i|0x40 for 10 bits
+ ADCSRA|=1<<ADSC;
+
+ while(ADCSRA & (1<<ADSC)); // wait for conv. to complete
+ uint8 temp=ADCH; //unsigned int temp=ADC; for 10 bits
+
+ return temp;
+
+}
+
+
+
+
+
+
+
+
+
+
+/*Set ADC conversion channel*/
+// ADMUX |= (channel & 0x1F);
+
+ /*Start ADC conversion. Set 'ADSC' bit*/
+// ADCSRA |= (1<<6);
+
+ /*Wait for conversion to complete. Check 'ADIF' bit*/
+// while(!(ADCSRA & (1<<4)));
+
+ /*Clear ADIF flag*/
+// ADCSRA |= (1<<4);
+
+ /*ADC conversion result is stored in ADCH/L registers*/
+// return (ADC);
+
+
diff --git a/src/c/hardware/avr/default_files/Makefile b/src/c/hardware/avr/default_files/Makefile
new file mode 100644
index 0000000..c388196
--- /dev/null
+++ b/src/c/hardware/avr/default_files/Makefile
@@ -0,0 +1,387 @@
+
+# make all = Make software and program
+# make clean = Clean out built project files.
+# make program = Download the hex file to the device, using avrdude. Please
+# customize the avrdude settings below first!
+
+# Microcontroller Type
+MCU = atmega16
+
+# Target file name (without extension).
+TARGET = main
+
+# Programming hardware:
+AVRDUDE_PROGRAMMER = usbasp
+
+AVRDUDE_PORT = /dev/usb
+
+############# Don't need to change below here for most purposes (Elliot)
+
+# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
+# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+
+CSRCDIR = src/c
+HSRCDIR = includes
+ISRCDIR = interfaces
+SCI2CDIR = .
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard $(CSRCDIR)/*.c) main.c
+
+# If there is more than one source file, append them above, or modify and
+# uncomment the following:
+#SRC += foo.c bar.c
+
+# You can also wrap lines by appending a backslash to the end of the line:
+#SRC += baz.c \
+#xyzzy.c
+
+
+
+# List Assembler source files here.
+# Make them always end in a capital .S. Files ending in a lowercase .s
+# will not be considered source files but generated files (assembler
+# output from the compiler), and will be deleted upon "make clean"!
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
+# it will preserve the spelling of the filenames, and gcc itself does
+# care about how the name is spelled on its command-line.
+ASRC =
+
+
+# List any extra directories to look for include files here.
+# Each directory must be seperated by a space.
+EXTRAINCDIRS = includes interfaces
+EXTRALIBDIRS = .
+
+
+# Optional compiler flags.
+# -g: generate debugging information (for GDB, or for COFF conversion)
+# -O*: optimization level
+# -f...: tuning, see gcc manual and avr-libc documentation
+# -Wall...: warning level
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create assembler listing
+#CFLAGS = -g -O$(OPT) \
+#-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
+#-Wall -Wstrict-prototypes \
+#-Wa,-adhlns=$(<:.c=.lst) \
+#$(patsubst %,-I%,$(EXTRAINCDIRS))
+CFLAGS = -g -Wall $(patsubst %,-I%,$(EXTRAINCDIRS)) $(patsubst %,-L%,$(EXTRALIBDIRS))
+
+# Set a "language standard" compiler flag.
+# Unremark just one line below to set the language standard to use.
+# gnu99 = C99 + GNU extensions. See GCC manual for more information.
+#CFLAGS += -std=c89
+#CFLAGS += -std=gnu89
+#CFLAGS += -std=c99
+#CFLAGS += -std=gnu99
+
+
+
+# Optional assembler flags.
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create listing
+# -gstabs: have the assembler create line number information; note that
+# for use in COFF files, additional information about filenames
+# and function names needs to be present in the assembler source
+# files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+
+# Optional linker flags.
+# -Wl,...: tell GCC to pass this to linker.
+# -Map: create map file
+# --cref: add cross reference to map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+
+
+
+# Additional libraries
+
+# Minimalistic printf version
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires -lm below)
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
+
+# -lm = math library
+LDFLAGS += -lc
+LDFLAGS += -lm
+
+# Programming support using avrdude. Settings and variables.
+
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE += -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_FLAGS += -V
+
+# Increase verbosity level. Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_FLAGS += -v -v
+
+#Run while cable attached or don't
+AVRDUDE_FLAGS += -E reset #keep chip disabled while cable attached
+#AVRDUDE_FLAGS += -E noreset
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x04:m #run with 8 Mhz clock
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x21:m #run with 1 Mhz clock #default clock mode
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x01:m #run with 1 Mhz clock no start up time
+
+# ---------------------------------------------------------------------------
+
+# Define directories, if needed.
+DIRAVR = /usr/lib/avr
+DIRAVRBIN = $(DIRAVR)/bin
+DIRAVRUTILS = $(DIRAVR)/utils/bin
+DIRINC = $(DIRAVR)/include
+DIRLIB = $(DIRAVR)/lib
+
+
+# Define programs and commands.
+SHELL = sh
+
+CC = avr-gcc
+
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+AR = avr-ar
+
+# Programming support using avrdude.
+AVRDUDE = avrdude
+
+
+REMOVE = rm -f
+COPY = cp
+
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = -------- end --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+#LOCAL_LIB
+LOCAL_LIB = main.a
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+# Default target: make program!
+all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
+ $(TARGET).lss $(TARGET).sym sizeafter finished end
+# $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+ @echo
+ @echo $(MSG_BEGIN)
+
+finished:
+ @echo $(MSG_ERRORS_NONE)
+
+end:
+ @echo $(MSG_END)
+ @echo
+
+
+# Display size of file.
+sizebefore:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
+
+sizeafter:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+ @$(CC) --version
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in
+# AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+ --change-section-address .data-0x800000 \
+ --change-section-address .bss-0x800000 \
+ --change-section-address .noinit-0x800000 \
+ --change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+ @echo
+ @echo $(MSG_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+ @echo
+ @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+ @echo
+ @echo $(MSG_FLASH) $@
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+ @echo
+ @echo $(MSG_EEPROM) $@
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+ @echo
+ @echo $(MSG_EXTENDED_LISTING) $@
+ $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+ @echo
+ @echo $(MSG_SYMBOL_TABLE) $@
+ avr-nm -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: %.a
+ @echo
+ @echo $(MSG_LINKING) $@
+ $(CC) $(ALL_CFLAGS) $(LOCAL_LIB) -o $@ $(LDFLAGS)
+
+$(LOCAL_LIB): $(OBJ)
+ $(AR) rcs $@ $(OBJ)
+
+# Compile: create object files from C source files.
+%.o : %.c
+ @echo
+ @echo $(MSG_COMPILING) $<
+ $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+ $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+ @echo
+ @echo $(MSG_ASSEMBLING) $<
+ $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+
+
+
+# Target: clean project.
+clean: begin clean_list finished end
+
+clean_list :
+ @echo
+ @echo $(MSG_CLEANING)
+ $(REMOVE) $(TARGET).hex
+ $(REMOVE) $(TARGET).eep
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).cof
+ $(REMOVE) $(TARGET).elf
+ $(REMOVE) $(TARGET).map
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).a90
+ $(REMOVE) $(TARGET).sym
+ $(REMOVE) $(TARGET).lnk
+ $(REMOVE) $(TARGET).lss
+ $(REMOVE) $(OBJ)
+ $(REMOVE) $(LST)
+ $(REMOVE) $(SRC:.c=.s)
+ $(REMOVE) $(SRC:.c=.d)
+ $(REMOVE) *~
+
+# Automatically generate C source code dependencies.
+# (Code originally taken from the GNU make user manual and modified
+# (See README.txt Credits).)
+#
+# Note that this will work with sh (bash) and sed that is shipped with WinAVR
+# (see the SHELL variable defined above).
+# This may not work with other shells or other seds.
+#
+%.d: %.c
+ set -e; $(CC) -MM $(ALL_CFLAGS) $< \
+ | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
+ [ -s $@ ] || rm -f $@
+
+
+# Remove the '-' if you want to see the dependency files generated.
+-include $(SRC:.c=.d)
+
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
+ clean clean_list program
diff --git a/src/c/hardware/avr/gpio/u8AVRDigitalIns.c b/src/c/hardware/avr/gpio/u8AVRDigitalIns.c
new file mode 100644
index 0000000..a2517b9
--- /dev/null
+++ b/src/c/hardware/avr/gpio/u8AVRDigitalIns.c
@@ -0,0 +1,63 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+// Function to get current state (high\low) of a digital pin on AVR
+//
+// Calling Sequence
+// u8AVRDigitalIns(port,pin)
+//
+// Parameters
+// port : port of microcontroller to be used (1 for PORTA, 2 for PORTB,...)
+// pin : pin of port (mentioned above) to be used
+// Returns->
+// state : state of the pin (0 for low and 1 for high)
+//
+// Description
+// Each AVR microcontroller has pins which can be configured as digital
+// outputs. These are normally divided among some 'ports' (group of pins).
+// User has to select one of these port and which pin of that port is to
+// be read. Function returns current state of the pin '1' (high) or '0' (low).
+//
+//
+// Examples
+// state = u8AVRDigitalIns(1,0)
+//
+// Authors
+// Siddhesh Wani
+//
+
+
+#include "AVRPeripheralGPIO.h"
+
+uint8 u8AVRDigitalIns(uint8 port,uint8 pin)
+{
+ unsigned int state = 0;
+ if(port == PORT_A)
+ {
+ state = bit_is_clear(PINA,pin);
+ return !state;
+ }
+ if(port == PORT_B)
+ {
+ state = bit_is_clear(PINB,pin);
+ return !state;
+ }
+ if(port == PORT_C)
+ {
+ state = bit_is_clear(PINC,pin);
+ return !state;
+ }
+ if(port == PORT_D)
+ {
+ state = bit_is_clear(PIND,pin);
+ return !state;
+ }
+
+}
diff --git a/src/c/hardware/avr/gpio/u8AVRDigitalOuts.c b/src/c/hardware/avr/gpio/u8AVRDigitalOuts.c
new file mode 100644
index 0000000..8998fc9
--- /dev/null
+++ b/src/c/hardware/avr/gpio/u8AVRDigitalOuts.c
@@ -0,0 +1,78 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+// Function to change state (high\low) of a digital output pin on AVR
+//
+// Calling Sequence
+// u8AVRDigitalOuts(port,pin,state)
+//
+// Parameters
+// port : port of microcontroller to be used (1 for PORTA, 2 for PORTB,...)
+// pin : pin of port (mentioned above) to be used
+// state : state to be outputed on pin (0 for low and 1 for high)
+//
+// Description
+// Each AVR microcontroller has pins which can be configured as digital
+// outputs. These are normally divided among some 'ports' (group of pins).
+// User has to select one of these port and which pin of that port as
+// digital output. Also, desired output state must be specified as
+// '1' (high) or '0' (low).
+//
+// Examples
+// u8AVRDigitalOuts(1,0,1)
+//
+// Authors
+// Siddhesh Wani
+// Ashish Kamble
+
+
+#include "AVRPeripheralGPIO.h"
+
+void u8AVRDigitalOuts(uint8 port,uint8 pin,uint8 state)
+{
+ if(state == LOW)
+ {/*Make output pin high*/
+ if(port == PORT_A)
+ {
+ PORTA = PORTA & ~(1<<pin);
+ }
+ if(port == PORT_B)
+ {
+ PORTB = PORTB & ~(1<<pin);
+ }
+ if(port == PORT_C)
+ {
+ PORTC = PORTC & ~(1<<pin);
+ }
+ if(port == PORT_D)
+ {
+ PORTD = PORTD & ~(1<<pin);
+ }
+ }
+ else
+ {/*Make output pin high*/
+ if(port == PORT_A)
+ {
+ PORTA = PORTA | (1<<pin);
+ }
+ if(port == PORT_B)
+ {
+ PORTB = PORTB | (1<<pin);
+ }
+ if(port == PORT_C)
+ {
+ PORTC = PORTC | (1<<pin);
+ }
+ if(port == PORT_D)
+ {
+ PORTD = PORTD | (1<<pin);
+ }
+ }
+}
diff --git a/src/c/hardware/avr/gpio/u8AVRDigitalPortSetups.c b/src/c/hardware/avr/gpio/u8AVRDigitalPortSetups.c
new file mode 100644
index 0000000..54ec731
--- /dev/null
+++ b/src/c/hardware/avr/gpio/u8AVRDigitalPortSetups.c
@@ -0,0 +1,81 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+// Function to decide direction of a digital pin on AVR
+//
+// Calling Sequence
+// AVRDigitalPortSetup(port,direction)
+//
+// Parameters
+// port : port of microcontroller to be used (1 for PORTA, 2 for PORTB,...)
+// 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
+// AVRDigitalPortSetup(1,0); //this function will PortA as input Port
+//
+// Authors
+// Siddhesh Wani
+// Ashish Kamble
+
+
+#include "AVRPeripheralGPIO.h"
+
+uint8 u8AVRDigitalPortSetups(uint8 port,uint8 direction)
+{
+ if(direction == INPUT)
+ {
+ /*Set port as input*/
+ if(port == PORT_A)
+ {
+ DDRA = 0x00;
+ }
+ if(port == PORT_B)
+ {
+ DDRB = 0x00;
+ }
+ if(port == PORT_C)
+ {
+ DDRC = 0x00;
+ }
+ if(port == PORT_D)
+ {
+ DDRD = 0x00;
+ }
+ }
+ else
+ {
+ /*Set port as output*/
+ if(port == PORT_A)
+ {
+ DDRA = 0xFF;
+ }
+ if(port == PORT_B)
+ {
+ DDRB = 0xFF;
+ }
+ if(port == PORT_C)
+ {
+ DDRC = 0xFF;
+ }
+ if(port == PORT_D)
+ {
+ DDRD = 0xFF;
+ }
+ }
+ return 0;
+}
+
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);
+ }
+ }
+}
+
diff --git a/src/c/hardware/avr/includes/AVRPeripheralADC.h b/src/c/hardware/avr/includes/AVRPeripheralADC.h
new file mode 100644
index 0000000..2a27e37
--- /dev/null
+++ b/src/c/hardware/avr/includes/AVRPeripheralADC.h
@@ -0,0 +1,27 @@
+//This file defines constants corresponding to gpios and digital input functions.
+//
+// Authors
+// Siddhesh Wani
+//
+
+#ifndef __AVRPERIPHERALADC_H__
+#define __AVRPERIPHERALADC_H__
+
+#include <avr/io.h>
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//Function prototypes
+uint8 u8AVRADCSetups(uint8 prescaler, uint8 adc_ref);
+
+uint8 u8AVRReadADCs(uint8 channel);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALGPIO_H__ */
diff --git a/src/c/hardware/avr/includes/AVRPeripheralGPIO.h b/src/c/hardware/avr/includes/AVRPeripheralGPIO.h
new file mode 100644
index 0000000..9a8d2d6
--- /dev/null
+++ b/src/c/hardware/avr/includes/AVRPeripheralGPIO.h
@@ -0,0 +1,54 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Author: Ashish Kamble
+// Email: toolbox@scilab.in
+
+
+#ifndef __AVRPERIPHERALGPIO_H__
+#define __AVRPERIPHERALGPIO_H__
+
+#include <avr/io.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <avr/io.h>
+#include "types.h"
+
+//Port definitions
+#define PORT_A 1
+#define PORT_B 2
+#define PORT_C 3
+#define PORT_D 4
+
+//Direction definitions
+#define INPUT 0
+#define OUTPUT 1
+
+//Pin state definitions
+#define LOW 0
+#define HIGH 1
+
+//Function prototypes
+void u8AVRDigitalSetups(uint8 port,uint8 pin,uint8 direction);
+
+uint8 u8AVRDigitalIns(uint8 port,uint8 pin);
+
+void u8AVRDigitalOuts(uint8 port,uint8 pin,uint8 state);
+
+uint8 u8AVRDigitalPortSetups(uint8 port,uint8 direction);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALGPIO_H__ */
diff --git a/src/c/hardware/avr/includes/AVRPeripheralPWM.h b/src/c/hardware/avr/includes/AVRPeripheralPWM.h
new file mode 100644
index 0000000..2107a5a
--- /dev/null
+++ b/src/c/hardware/avr/includes/AVRPeripheralPWM.h
@@ -0,0 +1,34 @@
+//This file defines functions prototypes related to PWM.
+//
+// Authors
+// Ashish Kamble
+//
+
+#ifndef __AVRPERIPHERALPWM_H__
+#define __AVRPERIPHERALPWM_H__
+
+#include <avr/io.h>
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//Function prototypes
+uint8 u8AVRPWM0Setups(uint8 waveform_mode, uint8 output_mode);
+
+uint8 u8AVRPWM2Setups(uint8 waveform_mode, uint8 output_mode);
+
+uint8 u8AVRPWM1Setups(uint8 waveform_mode, uint8 output_mode, uint8 output_pin);
+
+uint8 u8AVRPWM0SetDutys(uint8 duty);
+
+uint8 u8AVRPWM2SetDutys(uint8 duty);
+
+uint8 u8AVRPWM1SetDutys(uint8 output_pin, uint16 duty, uint16 Top_Value);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALPWM_H__ */
diff --git a/src/c/hardware/avr/includes/AVRPeripheralTimer.h b/src/c/hardware/avr/includes/AVRPeripheralTimer.h
new file mode 100644
index 0000000..ab08769
--- /dev/null
+++ b/src/c/hardware/avr/includes/AVRPeripheralTimer.h
@@ -0,0 +1,32 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Author: Ashish Kamble
+// Email: toolbox@scilab.in
+
+#ifndef __AVRPERIPHERALTIMER_H__
+#define __AVRPERIPHERALTIMER_H__
+
+#include <avr/io.h>
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//Function prototypes
+
+uint16 u8AVRGetTimerValues(uint16 timer);
+
+uint8 u8AVRTimerSetups(uint8 timer, uint16 prescaler,uint8 clock_source);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALTIMER_H__ */
diff --git a/src/c/hardware/avr/includes/AVRPeripheralUART.h b/src/c/hardware/avr/includes/AVRPeripheralUART.h
new file mode 100644
index 0000000..09db3b0
--- /dev/null
+++ b/src/c/hardware/avr/includes/AVRPeripheralUART.h
@@ -0,0 +1,59 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Author: Ashish Kamble
+// Email: toolbox@scilab.in
+
+
+#ifndef __AVRPERIPHERALUART_H__
+#define __AVRPERIPHERALUART_H__
+
+#include <avr/io.h>
+#include "types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//Function prototypes
+uint8 u8AVRUARTSetups(uint8 mode, uint32 baudrate, uint8 stopbits, uint8 parity);
+
+uint8 u8AVRUARTTransmits(uint8 data);
+
+uint8 gAVRUARTTransmits(char* msg,int size);
+
+uint8 u16AVRUARTTransmits(uint16 data);
+
+uint8 i16AVRUARTTransmits(int16 data);
+
+uint8 i8AVRUARTTransmits(int8 data);
+
+//uint8 sAVRUARTTransmits(float data);
+
+uint8 u8AVRUARTTransmita(uint8 *x,int size);
+
+//uint8 gAVRUARTTransmita(uint8 *x,int size);
+
+uint8 u16AVRUARTTransmita(uint16 *x,int size);
+
+uint8 i16AVRUARTTransmita(int16 *x,int size);
+
+uint8 i8AVRUARTTransmita(int8 *x,int size);
+
+uint8 u8AVRUSARTReceiveCharu8();
+
+uint8 dAVRUARTTransmits(double data);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRUART_H__ */
+
+
diff --git a/src/c/hardware/avr/includes/AVRUtil.h b/src/c/hardware/avr/includes/AVRUtil.h
new file mode 100644
index 0000000..55789be
--- /dev/null
+++ b/src/c/hardware/avr/includes/AVRUtil.h
@@ -0,0 +1,31 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Author: Siddhesh Wani
+// Email: toolbox@scilab.in
+
+#ifndef __AVRUTIL_H__
+#define __AVRUTIL_H__
+
+#include <avr/io.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "types.h"
+#include "util/delay.h"
+
+uint8 u16AVRSleeps (uint16 delay);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRUTIL_H__ */
diff --git a/src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h b/src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h
new file mode 100644
index 0000000..5d3a48e
--- /dev/null
+++ b/src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h
@@ -0,0 +1,32 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Aithor: Ashish Kamble
+// Email: toolbox@scilab.in
+
+
+#ifndef __INT_AVRPERIPHERALADC_H__
+#define __INT_AVRPERIPHERALADC_H__
+
+#include <avr/io.h>
+#include "AVRPeripheralADC.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AVRADCSetup(in1,in2) u8AVRADCSetups((uint8) in1,\
+ (uint8) in2);
+
+#define AVRReadADC(in1) u8AVRReadADCs((uint8) in1);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALADC_H__ */
diff --git a/src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h b/src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h
new file mode 100644
index 0000000..3fcbb8f
--- /dev/null
+++ b/src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h
@@ -0,0 +1,40 @@
+
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Author: Siddhesh Wani, Ashish Kamble
+// Email: toolbox@scilab.in
+
+
+#ifndef __INT_AVRPERIPHERALGPIO_H__
+#define __INT_AVRPERIPHERALGPIO_H__
+
+#include <avr/io.h>
+#include "AVRPeripheralGPIO.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AVRDigitalSetup(in1,in2,in3) u8AVRDigitalSetups((uint8) in1,\
+ (uint8) in2, (uint8) in3);
+
+#define AVRDigitalIn(in1,in2) u8AVRDigitalIns((uint8) in1, (uint8) in2);
+
+#define AVRDigitalOut(in1,in2,in3) u8AVRDigitalOuts((uint8) in1,\
+ (uint8) in2, (uint8) in3);
+
+#define AVRDigitalPortSetup(in1,in2) u8AVRDigitalPortSetups((uint8) in1,\
+ (uint8) in2);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALGPIO_H__ */
diff --git a/src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h b/src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h
new file mode 100644
index 0000000..5c5950b
--- /dev/null
+++ b/src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h
@@ -0,0 +1,39 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Author: Ashish Kamble
+// Email: toolbox@scilab.in
+
+
+#ifndef __INT_AVRPERIPHERALPWM_H__
+#define __INT_AVRPERIPHERALPWM_H__
+
+#include <avr/io.h>
+#include "AVRPeripheralPWM.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AVRPWM0Setup(in1,in2) u8AVRPWM0Setups((uint8) in1, (uint8) in2);
+
+#define AVRPWM2Setup(in1,in2) u8AVRPWM2Setups((uint8) in1, (uint8) in2);
+
+#define AVRPWM1Setup(in1,in2,in3) u8AVRPWM1Setups((uint8) in1, (uint8) in2, (uint8) in3);
+
+#define AVRPWM0SetDuty(in1) u8AVRPWM0SetDutys((uint8) in1);
+
+#define AVRPWM2SetDuty(in1) u8AVRPWM2SetDutys((uint8) in1);
+
+#define AVRPWM1SetDuty(in1,in2,in3) u8AVRPWM1SetDutys((uint8) in1,(uint16) in2,(uint16) in3);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALADC_H__ */
diff --git a/src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h b/src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h
new file mode 100644
index 0000000..3ec6a7e
--- /dev/null
+++ b/src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h
@@ -0,0 +1,31 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Author: Siddhesh Wani, Ashish Kamble
+// Email: toolbox@scilab.in
+
+
+#ifndef __INT_AVRPERIPHERALTIMER_H__
+#define __INT_AVRPERIPHERALTIMER_H__
+
+#include <avr/io.h>
+#include "AVRPeripheralTimer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AVRGetTimerValue(in1) u8AVRGetTimerValues((uint16) in1);
+
+#define AVRTimerSetup(in1,in2,in3) u8AVRTimerSetups((uint8) in1, (uint16) in2, (uint8) in3);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALADC_H__ */
diff --git a/src/c/hardware/avr/interfaces/int_AVRPeripheralUART.h b/src/c/hardware/avr/interfaces/int_AVRPeripheralUART.h
new file mode 100644
index 0000000..81b4af6
--- /dev/null
+++ b/src/c/hardware/avr/interfaces/int_AVRPeripheralUART.h
@@ -0,0 +1,57 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Authors: Siddhesh Wani, Ashish Kamble
+// Email: toolbox@scilab.in
+
+
+#ifndef __INT_AVRPERIPHERALUART_H__
+#define __INT_AVRPERIPHERALUART_H__
+
+#include <avr/io.h>
+#include "AVRPeripheralUART.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AVRUARTSetup(in1,in2,in3,in4) u8AVRUARTSetups((uint8) in1,(uint32) in2,(uint8) in3,(uint8) in4);
+
+#define u80AVRUARTTransmitu80(in1) u8AVRUARTTransmits((uint8) in1);
+
+#define g2AVRUARTTransmitu80(in1,in2) gAVRUARTTransmits((char*) in1,in2[0]*in2[1]);
+
+#define u160AVRUARTTransmitu80(in1) u16AVRUARTTransmits((uint16) in1);
+
+#define i160AVRUARTTransmitu80(in1) i16AVRUARTTransmits((int16) in1);
+
+#define i80AVRUARTTransmitu80(in1) i8AVRUARTTransmits((int8) in1);
+
+#define u82AVRUARTTransmitu80(in1,in2) u8AVRUARTTransmita((uint8) in1,in2[0]*in2[1]);
+
+#define d0AVRUARTTransmitu80(in1) dAVRUARTTransmits((double) in1);
+
+//#define g2AVRUARTTransmitu80(in1,in2) gAVRUARTTransmita((char*) in1,in2[0]*in2[1]);
+
+#define u162AVRUARTTransmitu80(in1,in2) u16AVRUARTTransmita((uint16) in1,in2[0]*in2[1]);
+
+#define i162AVRUARTTransmitu80(in1,in2) i16AVRUARTTransmita((int16) in1,in2[0]*in2[1]);
+
+#define i82AVRUARTTransmitu80(in1,in2) i8AVRUARTTransmita((int8) in1,in2[0]*in2[1]);
+
+#define u80AVRUSARTReceiveCharu80() u8AVRUSARTReceiveCharu8();
+
+//#define s0AVRUARTTransmitu80(in1) sAVRUARTTransmits((float) in1);
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALUART_H__ */
diff --git a/src/c/hardware/avr/interfaces/int_AVRUtil.h b/src/c/hardware/avr/interfaces/int_AVRUtil.h
new file mode 100644
index 0000000..51cbce5
--- /dev/null
+++ b/src/c/hardware/avr/interfaces/int_AVRUtil.h
@@ -0,0 +1,32 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Author: Siddhesh Wani
+// Email: toolbox@scilab.in
+
+
+#ifndef __INT_AVRUTIL_H__
+#define __INT_AVRUTIL_H__
+
+#include <avr/io.h>
+#include "AVRUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//#define d0sleepu80(in1) u16AVRSleeps ((uint16) in1);
+
+#define AVRSleep(in1) u16AVRSleeps ((uint16) in1);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__AVRPERIPHERALGPIO_H__ */
diff --git a/src/c/hardware/avr/pwm/u8AVRPWM0SetDutys.c b/src/c/hardware/avr/pwm/u8AVRPWM0SetDutys.c
new file mode 100644
index 0000000..106a872
--- /dev/null
+++ b/src/c/hardware/avr/pwm/u8AVRPWM0SetDutys.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Set Duty cycle of PWM Output generated by Timer0 at OC0 pin.
+
+
+#include "AVRPeripheralPWM.h"
+
+uint8 u8AVRPWM0SetDutys(uint8 duty)
+{
+ uint8 duty_value = 0;
+ duty_value = (((uint16)(duty * 0xff))/100);
+ OCR0 = duty_value;
+ return 0;
+}
+
diff --git a/src/c/hardware/avr/pwm/u8AVRPWM0Setups.c b/src/c/hardware/avr/pwm/u8AVRPWM0Setups.c
new file mode 100644
index 0000000..131ee68
--- /dev/null
+++ b/src/c/hardware/avr/pwm/u8AVRPWM0Setups.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Setup PWM output for OC0 pin.
+
+
+#include "AVRPeripheralPWM.h"
+
+
+uint8 u8AVRPWM0Setups(uint8 waveform_mode, uint8 output_mode)
+{
+ switch(waveform_mode)
+ {
+ case 0:
+ TCCR0 |= (1<<WGM00);
+ break;
+
+ case 1:
+ TCCR0 |= (1<<WGM00)|(1<<WGM01);
+ break;
+
+ case 2:
+ TCCR0 |= (1<<WGM01);
+ break;
+ }
+ switch(output_mode)
+ {
+ case 0:
+ TCCR0 |= (1<<COM01);
+ break;
+
+ case 1:
+ TCCR0 |= (1<<COM00)|(1<<COM01);
+ break;
+
+ case 2:
+ TCCR0 |= (1<<COM00);
+ break;
+ }
+ return 0;
+}
+
diff --git a/src/c/hardware/avr/pwm/u8AVRPWM1SetDutys.c b/src/c/hardware/avr/pwm/u8AVRPWM1SetDutys.c
new file mode 100644
index 0000000..47aad1c
--- /dev/null
+++ b/src/c/hardware/avr/pwm/u8AVRPWM1SetDutys.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Set Duty cycle and Top Value of PWM Output generated by Timer1 at OC1A or OC1B pin.
+
+#include "AVRPeripheralPWM.h"
+
+uint8 u8AVRPWM1SetDutys(uint8 output_pin, uint16 duty, uint16 Top_Value)
+{
+ uint16 duty_value = 0;
+ ICR1 = Top_Value;
+ if(output_pin==0)
+ {
+ duty_value = (((uint16)(duty * Top_Value))/100);
+ OCR1A = duty_value;
+ }
+ else if(output_pin==1)
+ {
+ duty_value = (((uint16)(duty * Top_Value))/100);
+ OCR1B = duty_value;
+ }
+ return 0;
+}
diff --git a/src/c/hardware/avr/pwm/u8AVRPWM1Setups.c b/src/c/hardware/avr/pwm/u8AVRPWM1Setups.c
new file mode 100644
index 0000000..b3f2d8f
--- /dev/null
+++ b/src/c/hardware/avr/pwm/u8AVRPWM1Setups.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Setup PWM output for OC1A or OC1B pin.
+
+#include "AVRPeripheralPWM.h"
+
+uint8 u8AVRPWM1Setups(uint8 waveform_mode, uint8 output_mode, uint8 output_pin)
+{
+ switch(waveform_mode)
+ {
+ case 0:
+ TCCR1A |= (1<<WGM11);
+ TCCR1B |= (1<<WGM13);
+ break;
+
+ case 1:
+ TCCR1A |= (1<<WGM11);
+ TCCR1B |= (1<<WGM12)|(1<<WGM13);
+ break;
+
+ case 2:
+ TCCR1B |= (1<<WGM12)|(1<<WGM13);
+ break;
+ }
+ if(output_pin==0)
+ {
+ switch(output_mode)
+ {
+ case 0:
+ TCCR1A |= (1<<COM1A1);
+ break;
+
+ case 1:
+ TCCR1A |= (1<<COM1A0)|(1<<COM1A1);
+ break;
+
+ case 2:
+ TCCR1A |= (1<<COM1A0);
+ break;
+ }
+ }
+ else if(output_pin==1)
+ {
+ switch(output_mode==0)
+ {
+ case 0:
+ TCCR1A |= (1<<COM1B1);
+ break;
+
+ case 1:
+ TCCR1A |= (1<<COM1B0)|(1<<COM1B1);
+ break;
+
+ case 2:
+ TCCR1A |= (1<<COM1B0);
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/src/c/hardware/avr/pwm/u8AVRPWM2SetDutys.c b/src/c/hardware/avr/pwm/u8AVRPWM2SetDutys.c
new file mode 100644
index 0000000..e0b5318
--- /dev/null
+++ b/src/c/hardware/avr/pwm/u8AVRPWM2SetDutys.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Set Duty cycle of PWM Output generated by Timer2 at OC2 pin.
+
+#include "AVRPeripheralPWM.h"
+
+uint8 u8AVRPWM2SetDutys(uint8 duty)
+{
+ uint8 duty_value = 0;
+ duty_value = (uint8)(((uint16)(duty * 0xff))/100);
+ OCR2 = duty_value;
+ return 0;
+}
diff --git a/src/c/hardware/avr/pwm/u8AVRPWM2Setups.c b/src/c/hardware/avr/pwm/u8AVRPWM2Setups.c
new file mode 100644
index 0000000..f5f8767
--- /dev/null
+++ b/src/c/hardware/avr/pwm/u8AVRPWM2Setups.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Setup PWM output for OC2 pin.
+
+#include "AVRPeripheralPWM.h"
+
+uint8 u8AVRPWM2Setups(uint8 waveform_mode, uint8 output_mode)
+{
+ switch(waveform_mode)
+ {
+ case 0:
+ TCCR2 |= (1<<WGM20);
+ break;
+
+ case 1:
+ TCCR2 |= (1<<WGM20)|(1<<WGM21);
+ break;
+
+ case 2:
+ TCCR2 |= (1<<WGM21);
+ break;
+ }
+ switch(output_mode)
+ {
+ case 0:
+ TCCR2 |= (1<<COM21);
+ break;
+
+ case 1:
+ TCCR2 |= (1<<COM20)|(1<<COM21);
+ break;
+
+ case 2:
+ TCCR2 |= (1<<COM20);
+ break;
+ }
+ return 0;
+}
diff --git a/src/c/hardware/avr/timer/u16AVRGetTimerValues.c b/src/c/hardware/avr/timer/u16AVRGetTimerValues.c
new file mode 100644
index 0000000..8ef16e8
--- /dev/null
+++ b/src/c/hardware/avr/timer/u16AVRGetTimerValues.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function selects the clock source and timer with prescaler.
+
+
+#include "AVRPeripheralTimer.h"
+#include <avr/interrupt.h>
+
+
+uint16 u8AVRGetTimerValues(uint16 timer)
+{
+ uint16_t x;
+ switch(timer)
+ {
+ case 0:
+ {
+ x = TCNT0;
+ break;
+ }
+
+ case 1:
+ {
+ unsigned char sreg;
+ unsigned int val;
+ sreg = SREG;
+ cli();
+ val = TCNT1;
+ SREG = sreg;
+ sei();
+ x = val;
+ break;
+ }
+
+ case 2:
+ {
+ x = TCNT2;
+ break;
+ }
+ }
+return x;
+}
+
diff --git a/src/c/hardware/avr/timer/u8AVRGetTimerValues.c b/src/c/hardware/avr/timer/u8AVRGetTimerValues.c
new file mode 100644
index 0000000..e08bb3a
--- /dev/null
+++ b/src/c/hardware/avr/timer/u8AVRGetTimerValues.c
@@ -0,0 +1,63 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+
+// Function to get timer count
+//
+// Calling Sequence
+// u8AVRGetTimerValues(timer)
+//
+// Parameters
+// timer: timer whose current count is to be returned (0,1,2)
+// ***Refer datasheet for more description about timer
+//
+// Description
+// This function returns the count of timer specified
+//
+//
+// Authors
+// Ashish Kamble
+//
+
+
+#include "AVRPeripheralTimer.h"
+#include <avr/interrupt.h>
+
+
+uint16 u8AVRGetTimerValues(uint16 timer)
+{ uint16_t x;
+ switch(timer)
+ {
+ case 0:
+ {
+ x = TCNT0;
+ break;
+ }
+ case 1:
+ {
+ unsigned char sreg;
+ unsigned int val;
+ sreg = SREG;
+ cli();
+ val = TCNT1;
+ SREG = sreg;
+ sei();
+ x = val;
+ break;
+ }
+ case 2:
+ {
+ x = TCNT2;
+ break;
+ }
+ }
+return x;
+}
+
diff --git a/src/c/hardware/avr/timer/u8AVRTimerSetups.c b/src/c/hardware/avr/timer/u8AVRTimerSetups.c
new file mode 100644
index 0000000..6ee8d2a
--- /dev/null
+++ b/src/c/hardware/avr/timer/u8AVRTimerSetups.c
@@ -0,0 +1,110 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function selects the clock source and timer with prescaler.
+
+#include "AVRPeripheralTimer.h"
+
+uint8 u8AVRTimerSetups(uint8 timer,uint16 prescaler,uint8 clock_source)
+{
+
+ if(clock_source==0)
+ {
+ if(timer==0)
+ {
+ switch(prescaler)
+ {
+ case 1: TCCR0 |= (1<<CS00);
+ TCNT0 = 0x00;
+ case 8: TCCR0 |= (1<<CS01);
+ TCNT0 = 0x00;
+ case 64: TCCR0 |= (1<<CS00)|(1<<CS01);
+ TCNT0 = 0x00;
+ case 256: TCCR0 |= (1<<CS02);
+ TCNT0 = 0x00;
+ case 1024: TCCR0 |= (1<<CS00)|(1<<CS02);
+ TCNT0 = 0x00;
+ }
+ }
+ else if(timer==2)
+ {
+ switch(prescaler)
+ {
+ case 1: TCCR2 |= (1<<CS20);
+ TCNT2 = 0x00;
+ case 8: TCCR2 |= (1<<CS21);
+ TCNT2 = 0x00;
+ case 64: TCCR2 |= (1<<CS20)|(1<<CS21);
+ TCNT2 = 0x00;
+ case 256: TCCR2 |= (1<<CS22);
+ TCNT2 = 0x00;
+ case 1024: TCCR2 |= (1<<CS20)|(1<<CS22);
+ TCNT2 = 0x00;
+ }
+ }
+ else if(timer==1)
+ {
+ switch(prescaler)
+ {
+ case 1: TCCR1B |= (1<<CS10);
+ TCNT1H = 0x00;
+ TCNT1L = 0x00;
+ case 8: TCCR1B |= (1<<CS11);
+ TCNT1H = 0x00;
+ TCNT1L = 0x00;
+ case 64: TCCR1B |= (1<<CS10)|(1<<CS11);
+ TCNT1H = 0x00;
+ TCNT1L = 0x00;
+ case 256: TCCR1B |= (1<<CS12);
+ TCNT1H = 0x00;
+ TCNT1L = 0x00;
+ case 1024: TCCR1B |= (1<<CS10)|(1<<CS12);
+ TCNT1H = 0x00;
+ TCNT1L = 0x00;
+ }
+ }
+ }
+ else if(clock_source==1)
+ {
+ if(timer==0)
+ {
+ TCCR0 |= (1<<CS00)|(1<<CS01)|(1<<CS02);
+ TCNT0 = 0x00;
+ }
+ else if(timer==2)
+ {
+ TCCR2 |= (1<<CS20)|(1<<CS21)|(1<<CS22);
+ TCNT2 = 0x00;
+ }
+ else if(timer==1)
+ {
+ TCCR1B |= (1<<CS10)|(1<<CS11)|(1<<CS12);
+ TCNT1H = 0x00;
+ TCNT1L = 0x00;
+ }
+ }
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/c/hardware/avr/uart/dAVRUARTTransmits.c b/src/c/hardware/avr/uart/dAVRUARTTransmits.c
new file mode 100644
index 0000000..ec63c4d
--- /dev/null
+++ b/src/c/hardware/avr/uart/dAVRUARTTransmits.c
@@ -0,0 +1,88 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Not Tested//
+#include "AVRPeripheralUART.h"
+#include<math.h>
+
+
+uint8 dAVRUARTTransmits(double data)
+{
+ //Extract integer part
+ long int intpart = (long int)data;
+ //Extract double part
+ //double floatpart = data - (double)intpart;
+ char* str;
+ int i = 0;
+ while(intpart)
+ {
+ str[i] = (intpart%10) + '0';
+ intpart = intpart/10;
+ i++;
+ }
+ str[i]='\0';
+ /*
+ int j = 0;
+ int k = i-1;
+ char temp;
+ while(j<k)
+ {
+ temp = str[j];
+ str[j] = str[k];
+ str[k] = temp;
+ j++;
+ k--;
+ }
+*/
+
+
+ /*
+ char* strfloat;
+ floatpart = floatpart*1000000000;
+ int l = 0;
+ while(floatpart)
+ {
+ strfloat[l] = ((unsigned int)floatpart%10) + '0';
+ floatpart = floatpart/10;
+ l++;
+ }
+ while(*strfloat!='\0')
+ {
+ str[i+1] = strfloat[l-1];
+ i++;
+ l--;
+ }
+ */
+
+ while(*str!='\0')
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = *str; // Put data into buffer, sends the data
+ str++;
+ }
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c b/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c
new file mode 100644
index 0000000..8978cc0
--- /dev/null
+++ b/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Char.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 dAVRUARTTransmitu8(uint8 data)
+{
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = data; // Put data into buffer, sends the data
+}
diff --git a/src/c/hardware/avr/uart/gAVRUARTTransmita.c b/src/c/hardware/avr/uart/gAVRUARTTransmita.c
new file mode 100644
index 0000000..fea9319
--- /dev/null
+++ b/src/c/hardware/avr/uart/gAVRUARTTransmita.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit String.
+
+
+#include "AVRPeripheralUART.h"
+
+
+uint8 gAVRUARTTransmita(uint8 *x, int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ gAVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
diff --git a/src/c/hardware/avr/uart/gAVRUARTTransmits.c b/src/c/hardware/avr/uart/gAVRUARTTransmits.c
new file mode 100644
index 0000000..502f272
--- /dev/null
+++ b/src/c/hardware/avr/uart/gAVRUARTTransmits.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit String.
+
+
+#include "AVRPeripheralUART.h"
+
+
+uint8 gAVRUARTTransmits(char* msg,int size)
+{
+ while(*msg!='\0')
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = *msg; // Put data into buffer, sends the data
+ msg++;
+ }
+while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
diff --git a/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c b/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c
new file mode 100644
index 0000000..f338406
--- /dev/null
+++ b/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit String.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 gAVRUARTTransmitu8(uint8 *msg)
+{
+ while(*msg!='\0')
+ {
+ AVRUARTTransmitChar(*msg);
+ msg++;
+ }
+}
diff --git a/src/c/hardware/avr/uart/i16AVRUARTTransmita.c b/src/c/hardware/avr/uart/i16AVRUARTTransmita.c
new file mode 100644
index 0000000..8d0fcd4
--- /dev/null
+++ b/src/c/hardware/avr/uart/i16AVRUARTTransmita.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 i16AVRUARTTransmita(int16 *x, int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ i16AVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
+
+
diff --git a/src/c/hardware/avr/uart/i16AVRUARTTransmits.c b/src/c/hardware/avr/uart/i16AVRUARTTransmits.c
new file mode 100644
index 0000000..4d90776
--- /dev/null
+++ b/src/c/hardware/avr/uart/i16AVRUARTTransmits.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+
+uint8 i16AVRUARTTransmits(int16 data)
+{
+ uint8 temp1;
+ uint8 temp2;
+ uint8 temp3;
+ uint8 temp4;
+ uint8 temp5;
+ if(data<0)
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (45); // Put data into buffer, sends the data
+ }
+ data = abs(data);
+ temp1 = data/10000;
+ if(temp1==0);
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp1); // Put data into buffer, sends the data
+ }
+ data = data % 10000;
+ temp2 = data/1000;
+ if((temp1==0)&(temp2==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp2); // Put data into buffer, sends the data
+ }
+ data = data % 1000;
+ temp3 = data/100;
+ if((temp1==0)&(temp2==0)&(temp3==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp3); // Put data into buffer, sends the data
+ }
+ data = data % 100;
+ temp4 = data/10;
+ if((temp1==0)&(temp2==0)&(temp3==0)&(temp4==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp4); // Put data into buffer, sends the data
+ }
+ temp5 = data % 10;
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp5); // Put data into buffer, sends the data
+
+
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
+
diff --git a/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c b/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c
new file mode 100644
index 0000000..99638c7
--- /dev/null
+++ b/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 i16AVRUARTTransmitu8(int16 data)
+{
+ uint16 temp1;
+ uint16 temp2;
+ temp1 = abs(data)/100;
+ if(data<0)
+ AVRUARTTransmitChar(45);
+ AVRUARTTransmitChar(48+temp1);
+ temp1 = abs(data) - temp1*100;
+ temp2 = temp1;
+ temp1 = temp1/10;
+ AVRUARTTransmitChar(48+temp1);
+ temp2 = temp2 - temp1*10;
+ AVRUARTTransmitChar(48+temp2);
+}
diff --git a/src/c/hardware/avr/uart/i8AVRUARTTransmita.c b/src/c/hardware/avr/uart/i8AVRUARTTransmita.c
new file mode 100644
index 0000000..1034573
--- /dev/null
+++ b/src/c/hardware/avr/uart/i8AVRUARTTransmita.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 i8AVRUARTTransmita(int8 *x,int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ i8AVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
diff --git a/src/c/hardware/avr/uart/i8AVRUARTTransmits.c b/src/c/hardware/avr/uart/i8AVRUARTTransmits.c
new file mode 100644
index 0000000..6b8c20f
--- /dev/null
+++ b/src/c/hardware/avr/uart/i8AVRUARTTransmits.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 i8AVRUARTTransmits(int8 data)
+{
+ uint8 temp1;
+ temp1 = abs(data);
+ if(data<0)
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (45); // Put data into buffer, sends the data
+ u8AVRUARTTransmits(temp1);
+ return 0;
+}
diff --git a/src/c/hardware/avr/uart/u16AVRUARTTransmita.c b/src/c/hardware/avr/uart/u16AVRUARTTransmita.c
new file mode 100644
index 0000000..8b8e630
--- /dev/null
+++ b/src/c/hardware/avr/uart/u16AVRUARTTransmita.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Unsigned Integer Values.
+
+#include "AVRPeripheralUART.h"
+
+uint8 u16AVRUARTTransmita(uint16 *x, int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ u16AVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
+
+
+
+
diff --git a/src/c/hardware/avr/uart/u16AVRUARTTransmits.c b/src/c/hardware/avr/uart/u16AVRUARTTransmits.c
new file mode 100644
index 0000000..3cfb4a2
--- /dev/null
+++ b/src/c/hardware/avr/uart/u16AVRUARTTransmits.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Unsigned Integer Values.
+
+#include "AVRPeripheralUART.h"
+
+uint8 u16AVRUARTTransmits(uint16 data)
+{
+ uint8 temp1;
+ uint8 temp2;
+ uint8 temp3;
+ uint8 temp4;
+ uint8 temp5;
+ temp1 = data/10000;
+ if(temp1==0);
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp1); // Put data into buffer, sends the data
+ }
+ data = data % 10000;
+ temp2 = data/1000;
+ if((temp1==0)&(temp2==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp2); // Put data into buffer, sends the data
+ }
+ data = data % 1000;
+ temp3 = data/100;
+ if((temp1==0)&(temp2==0)&(temp3==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp3); // Put data into buffer, sends the data
+ }
+ data = data % 100;
+ temp4 = data/10;
+ if((temp1==0)&(temp2==0)&(temp3==0)&(temp4==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp4); // Put data into buffer, sends the data
+ }
+ temp5 = data % 10;
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp5); // Put data into buffer, sends the data
+
+
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c b/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c
new file mode 100644
index 0000000..a68a5aa
--- /dev/null
+++ b/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Unsigned Integer Values.
+
+#include "AVRPeripheralUART.h"
+
+uint8 u16AVRUARTTransmitu8(uint16 data)
+{
+ uint8 temp1;
+ uint8 temp2;
+ uint8 temp3;
+ uint8 temp4;
+ temp1 = data/10000;
+ dAVRUARTTransmitu8(48+temp1);
+ temp1 = data - temp1*10000;
+ temp2 = temp1;
+ temp1 = temp1/1000;
+ dAVRUARTTransmitu8(48+temp1);
+ temp1 = temp2 - temp1*1000;
+ temp3 = temp1;
+ temp1 = temp1/100;
+ dAVRUARTTransmitu8(48+temp1);
+ temp1 = temp3 - temp1*100;
+ temp4 = temp1;
+ temp1 = temp1/10;
+ dAVRUARTTransmitu8(48+temp1);
+ temp1 = temp4 - temp1*10;
+ dAVRUARTTransmitu8(48+temp1);
+}
diff --git a/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c b/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c
new file mode 100644
index 0000000..df0a55b
--- /dev/null
+++ b/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Receive Char.
+
+#include "AVRPeripheralUART.h"
+
+uint8 u8AVRUSARTReceiveCharu8()
+{
+ while ( !(UCSRA & (1<<RXC)) ) ; // Wait for data to be received
+ return UDR; // Get and return received data from buffer
+}
diff --git a/src/c/hardware/avr/uart/u8AVRUARTSetups.c b/src/c/hardware/avr/uart/u8AVRUARTSetups.c
new file mode 100644
index 0000000..085ac6e
--- /dev/null
+++ b/src/c/hardware/avr/uart/u8AVRUARTSetups.c
@@ -0,0 +1,143 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Setup Serial communication for ATmega16.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 u8AVRUARTSetups(uint8 mode, uint32 baudrate, uint8 stopbits, uint8 parity)
+{
+//Enable UART and USART
+ UCSRC |= (1<<URSEL);
+ UCSRB |= (1<<TXEN)|(1<<RXEN);
+
+ switch (mode) //According to mode set bits UMSEL and U2X
+{
+ case 0: //Normal mode
+ UCSRC &= ~(1<<UMSEL); //Clear bit 6 UMSEL and U2X=0
+ UCSRA &= ~(1<<U2X);
+ UCSRC &= ~(1<<UCPOL); // Clock polarity bit
+ break;
+
+ case 1: //Double speed mode
+ UCSRC &= ~(1<<UMSEL); //Clear bit 6 UMSEL and U2X=1
+ UCSRA |= (1<<U2X);
+ UCSRC &= ~(1<<UCPOL); //Clock polarity bit
+ break;
+
+ case 2: //Synchronous mode
+ UCSRC |= (1<<UMSEL); //Set bit 6 UMSEL and set clock polarity
+ UCSRC |= (1<<UCPOL);
+ break;
+}
+
+//Set stop bits
+if(stopbits == 0)
+{
+ UCSRC &= ~(1<<USBS); // 1 stopbit
+}
+else UCSRC |= (1<<USBS); //2 stopbits
+
+//Set parity bit settings
+switch(parity)
+{
+ case 0: // Parity disabled
+ UCSRC &= ~(1<<UPM1); //UPM1:0=0
+ UCSRC &= ~(1<<UPM0);
+ break;
+
+ case 1: // Even parity
+ UCSRC |= (1<<UPM1); //UPM1:0 = 2
+ UCSRC &= ~(1<<UPM0);
+ break;
+
+ case 2: // Odd parity
+ UCSRC |= (1<<UPM1); //UPM1:1 = 3
+ UCSRC |= (1<<UPM0);
+ break;
+}
+
+//Set baudrate
+UCSRC &= ~(1<<URSEL);
+switch(baudrate)
+{
+ case 2400:
+ UBRRL = 0xA0;
+ UBRRH = 0x01;
+ break;
+
+ case 4800:
+ UBRRL = 0xCF;
+ UBRRH = 0x00;
+ break;
+
+ case 9600:
+ UBRRL = 0x67;
+ UBRRH = 0x00;
+ break;
+
+ case 14400:
+ UBRRL = 0x44;
+ UBRRH = 0x00;
+ break;
+
+ case 19200:
+ UBRRL = 0x33;
+ UBRRH = 0x00;
+ break;
+
+ case 28800:
+ UBRRL = 0x22;
+ UBRRH = 0x00;
+ break;
+
+ case 38400:
+ UBRRL = 0x19;
+ UBRRH = 0x00;
+ break;
+
+ case 57600:
+ UBRRL = 0x10;
+ UBRRH = 0x00;
+ break;
+
+ case 768000:
+ UBRRL = 0x0C;
+ UBRRH = 0x00;
+ break;
+
+ case 115200:
+ UBRRL = 0x08;
+ UBRRH = 0x00;
+ break;
+
+ case 230400:
+ UBRRL = 0x03;
+ UBRRH = 0x00;
+ break;
+
+ case 250000:
+ UBRRL = 0x03;
+ UBRRH = 0x00;
+ break;
+
+ case 1000000:
+ UBRRL = 0x00;
+ UBRRH = 0x00;
+ break;
+}
+
+//Set data format
+UCSRC|= (1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1);
+
+ return 0;
+}
diff --git a/src/c/hardware/avr/uart/u8AVRUARTTransmita.c b/src/c/hardware/avr/uart/u8AVRUARTTransmita.c
new file mode 100644
index 0000000..14e2a0e
--- /dev/null
+++ b/src/c/hardware/avr/uart/u8AVRUARTTransmita.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Char.
+
+
+#include "AVRPeripheralUART.h"
+
+
+uint8 u8AVRUARTTransmita(uint8* x, int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ u8AVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
diff --git a/src/c/hardware/avr/uart/u8AVRUARTTransmits.c b/src/c/hardware/avr/uart/u8AVRUARTTransmits.c
new file mode 100644
index 0000000..e7e5c71
--- /dev/null
+++ b/src/c/hardware/avr/uart/u8AVRUARTTransmits.c
@@ -0,0 +1,60 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Char.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 u8AVRUARTTransmits(uint8 data)
+{
+ uint8 temp1;
+ uint8 temp2;
+ temp1 = data;
+ data = data/100;
+ if(data==0);
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+data); // Put data into buffer, sends the data
+ }
+ temp1 = temp1 - data*100;
+ temp2 = temp1;
+ temp1 = temp1/10;
+ if((data==0)&(temp1==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp1); // Put data into buffer, sends the data
+ }
+ temp2 = temp2 - temp1*10;
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp2); // Put data into buffer, sends the data
+
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/c/hardware/avr/util/u16AVRSleeps.c b/src/c/hardware/avr/util/u16AVRSleeps.c
new file mode 100644
index 0000000..9fbd512
--- /dev/null
+++ b/src/c/hardware/avr/util/u16AVRSleeps.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2017 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Organization: FOSSEE, IIT Bombay
+ Author: Siddhesh Wani
+ Email: toolbox@scilab.in
+*/
+//Function to introduce specific delay in milliseconds
+
+#include "AVRUtil.h"
+
+uint8 u16AVRSleeps (uint16 delay)
+{
+ _delay_ms(delay);
+
+ return 0;
+}
diff --git a/src/c/hardware/rasberrypi/ISR/i16RPIPinISRs.c b/src/c/hardware/rasberrypi/ISR/i16RPIPinISRs.c
new file mode 100644
index 0000000..6e398a1
--- /dev/null
+++ b/src/c/hardware/rasberrypi/ISR/i16RPIPinISRs.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to declare interrupt on pins and corresponding ISRs */
+
+#include "types.h"
+#include "RPIPeripheralPinISR.h"
+#include "RPIPeripheralDigital.h"
+
+int16 i16RPIPinISRs(uint8 pin, uint8 edgetype, void (*ISRFunction)(void))
+{
+ int status;
+ status = wiringPiISR((int)phy_pin[pin-1], (int) edgetype, ISRFunction);
+ return status;
+}
+
diff --git a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c
new file mode 100644
index 0000000..7b84350
--- /dev/null
+++ b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to read the state of the gpio pin */
+
+#include "types.h"
+#include "RPIPeripheralDigital.h"
+
+/*pin is reduced by one as array index starts from 0 and pin no starts from 1*/
+uint8 u8RPIDigitalIns(uint8 pin)
+{
+ uint8 state = 0;
+ state = digitalRead(phy_pin[pin-1]);
+ return (state);
+}
diff --git a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c
new file mode 100644
index 0000000..f828f77
--- /dev/null
+++ b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to change the output state of the gpio pin */
+
+
+#include "types.h"
+#include "RPIPeripheralDigital.h"
+
+/*pin is reduced by one as array index starts from 0 and pin no starts from 1*/
+void u8RPIDigitalOuts(uint8 pin, uint8 state)
+{
+ if (state == 0) /*low output*/
+ digitalWrite(phy_pin[pin-1], LOW);
+ if (state == 1) /*high output*/
+ digitalWrite(phy_pin[pin-1], HIGH);
+}
diff --git a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c
new file mode 100644
index 0000000..f5fefe0
--- /dev/null
+++ b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to setup digital pins
+ direction = 1 -> output
+ direction = 0 -> input
+*/
+
+#include "types.h"
+#include "RPIPeripheralDigital.h"
+
+
+/*This array maps pin numbers on RPi board, with pin numbers corrsponding
+to WiringPi library*/
+int phy_pin[] = {17, 17, 8, 17, 9, 17, 7, 15, 17, 16, /*Pin 1 to 10*/
+ 0, 1, 2, 17, 3, 4, 17, 5, 12, 17, /*Pin 11 to 20*/
+ 13, 6, 14, 10, 17, 11, 30, 31, 21, 17, /*Pin 21 to 30*/
+ 22, 26, 23, 17, 24, 27, 25, 28, 17, 29 }; /*Pin 31 to 40*/
+
+/*pin is reduced by one as arrayiindex starts from 0 and pin no starts from 1*/
+void u8RPIDigitalSetups(uint8 pin, uint8 direction)
+{
+ if(direction == 1) /*Pin to be used as output*/
+ pinMode(phy_pin[pin-1], OUTPUT);
+ else if(direction == 2)
+ pinMode(phy_pin[pin-1], PWM_OUTPUT);
+ else
+ pinMode(phy_pin[pin-1], INPUT);
+
+}
diff --git a/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h b/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h
new file mode 100644
index 0000000..2f40ffb
--- /dev/null
+++ b/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* This file declares functions and constants related to GPIO pins*/
+
+#ifndef __RPIPERIPHERALGPIO_H__
+#define __RPIPERIPHERALGPIO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include "types.h"
+#include "wiringPi.h"
+
+extern int phy_pin[];
+
+void u8RPIDigitalSetups(uint8 pin, uint8 direction);
+void u8RPIDigitalOuts(uint8 pin, uint8 state);
+uint8 u8RPIDigitalIns(uint8 pin);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__RPIPERIPHERALGPIO_H__*/
diff --git a/src/c/hardware/rasberrypi/includes/RPIPeripheralPWM.h b/src/c/hardware/rasberrypi/includes/RPIPeripheralPWM.h
new file mode 100644
index 0000000..d463d9c
--- /dev/null
+++ b/src/c/hardware/rasberrypi/includes/RPIPeripheralPWM.h
@@ -0,0 +1,31 @@
+ /* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __RPIPERIPHERALPWM_H__
+#define __RPIPERIPHERALPWM_H__
+
+#include "types.h"
+#include "wiringPi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void u8RPIHardPWMWrites(uint8 pin, uint16 value);
+void u8RPIHardPWMSetRanges(uint16 value);
+void u8RPIHardPWMSetModes(uint8 mode);
+void u8RPIHardPWMSetClocks(uint16 clk_divisor);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__RPIPERIPHERALPWM_H__*/
diff --git a/src/c/hardware/rasberrypi/includes/RPIPeripheralPinISR.h b/src/c/hardware/rasberrypi/includes/RPIPeripheralPinISR.h
new file mode 100644
index 0000000..fc5a8d0
--- /dev/null
+++ b/src/c/hardware/rasberrypi/includes/RPIPeripheralPinISR.h
@@ -0,0 +1,26 @@
+ /* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __RPIPERIPHERALPINISR_H__
+#define __RPIPERIPHERALPINISR_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int16 i16RPIPinISRs(uint8 pin, uint8 edgetype, void (*ISRFunction)(void));
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__RPIPERIPHERALPINISR_H__*/
diff --git a/src/c/hardware/rasberrypi/includes/RPIPeripheralSerial.h b/src/c/hardware/rasberrypi/includes/RPIPeripheralSerial.h
new file mode 100644
index 0000000..14df95b
--- /dev/null
+++ b/src/c/hardware/rasberrypi/includes/RPIPeripheralSerial.h
@@ -0,0 +1,49 @@
+ /* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __RPIPERIPHERALSERIAL_H__
+#define __RPIPERIPHERALSERIAL_H__
+
+#include "types.h"
+#include "wiringSerial.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int u8RPISerialSetups(char* port, int baudrate);
+void u8RPISerialCloses(int fd);
+
+void u8RPISerialSendChars(int fd, uint8 data);
+void u8RPISerialSendDatas(int fd, uint8 data);
+void i8RPISerialSendDatas(int fd, int8 data);
+void u16RPISerialSendDatas(int fd, uint16 data);
+void i16RPISerialSendDatas(int fd, int16 data);
+void sRPISerialSendDatas(int fd, float data);
+void dRPISerialSendDatas(int fd, double data);
+void u8RPISerialSendDataa(int fd, uint8* data, int size);
+void i8RPISerialSendDataa(int fd, int8* data, int size);
+void u16RPISerialSendDataa(int fd, uint16* data, int size);
+void i16RPISerialSendDataa(int fd, int16* data, int size);
+void sRPISerialSendDataa(int fd, float* data, int size);
+void dRPISerialSendDataa(int fd, double* data, int size);
+void gRPISerialSendDatas(int fd, uint8* data, int size);
+
+int16 i16RPISerialDataAvails(int fd);
+int16 i16RPISerialGetChars(int fd);
+
+void u8RPISerialFlushs(int fd);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__RPIPERIPHERALSERIAL_H__*/
diff --git a/src/c/hardware/rasberrypi/includes/RPIPeripheralThreading.h b/src/c/hardware/rasberrypi/includes/RPIPeripheralThreading.h
new file mode 100644
index 0000000..a7b2adb
--- /dev/null
+++ b/src/c/hardware/rasberrypi/includes/RPIPeripheralThreading.h
@@ -0,0 +1,28 @@
+ /* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __RPIPERIPHERALTHREADING_H__
+#define __RPIPERIPHERALTHREADING_H__
+
+#include "types.h"
+#include "wiringPi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+uint16 RPIThreadCreate(void *(*threadFunction)(void*));
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__RPIPERIPHERALTHREADING_H__*/
diff --git a/src/c/hardware/rasberrypi/includes/RPIPeripheralTiming.h b/src/c/hardware/rasberrypi/includes/RPIPeripheralTiming.h
new file mode 100644
index 0000000..854073f
--- /dev/null
+++ b/src/c/hardware/rasberrypi/includes/RPIPeripheralTiming.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* This file declares functions and constants related to rasberrypi*/
+
+#ifndef __RPIPERIPHERALTIMING_H__
+#define __RPIPERIPHERALTIMING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "types.h"
+#include "wiringPi.h"
+
+void u16RPIDelayMillis(uint16 time);
+void u16RPIDelayMicros(uint16 time);
+uint32 u32RPIGetMillis();
+uint32 u32RPIGetMicros();
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__RPIPERIPHERALTIMING_H__*/
diff --git a/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h
new file mode 100644
index 0000000..40a8e1a
--- /dev/null
+++ b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+#ifndef __INT_RPIPERIPHERALGPIO_H__
+#define __INT_RPIPERIPHERALGPIO_H__
+
+#include "types.h"
+#include "RPIPeripheralDigital.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RPI_DigitalSetup(in1,in2) u8RPIDigitalSetups((uint8) in1, (uint8) in2);
+
+#define RPI_DigitalIn(in1) u8RPIDigitalIns((uint8) in1);
+
+#define RPI_DigitalOut(in1,in2) u8RPIDigitalOuts((uint8) in1, (uint8) in2);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__RPIPERIPHERALGPIO_H__ */
diff --git a/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralPWM.h b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralPWM.h
new file mode 100644
index 0000000..8c8f4c6
--- /dev/null
+++ b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralPWM.h
@@ -0,0 +1,30 @@
+ /* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __INT_RPIPERIPHERALPWM_H__
+#define __INT_RPIPERIPHERALPWM_H__
+
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RPI_HardPWMWrite(pin,value) u8RPIHardPWMWrites((uint8)pin,(uint16)value)
+#define RPI_HardPWMSetRange(value) u8RPIHardPWMSetRanges((uint16)value)
+#define RPI_HardPWMSetMode(mode) u8RPIHardPWMSetModes((uint8)mode)
+#define RPI_HardPWMSetClock(clk_divisor) u8RPIHardPWMSetClocks((uint16)clk_divisor)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_RPIPERIPHERALPWM_H__*/
diff --git a/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralPinISR.h b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralPinISR.h
new file mode 100644
index 0000000..b2c1ed1
--- /dev/null
+++ b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralPinISR.h
@@ -0,0 +1,25 @@
+ /* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __INT_RPIPERIPHERALPINISR_H__
+#define __INT_RPIPERIPHERALPINISR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RPI_PinISR(pin,edge,funname) i16RPIPinISRs((uint8)pin,(uint8)edge,funname)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_RPIPERIPHERALPINISR_H__*/
diff --git a/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralSerial.h b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralSerial.h
new file mode 100644
index 0000000..5d53b98
--- /dev/null
+++ b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralSerial.h
@@ -0,0 +1,47 @@
+ /* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __INT_RPIPERIPHERALSERIAL_H__
+#define __INT_RPIPERIPHERALSERIAL_H__
+
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RPI_SerialSetup(port,size,baudrate) u16RPISerialSetups(port,baudrate)
+#define RPI_SerialClose(fd) u8RPISerialCloses(fd)
+
+#define u80u80RPI_SerialSendData(fd,data) u8RPISerialSendDatas(fd,data)
+#define u80i80RPI_SerialSendData(fd,data) i8RPISerialSendDatas(fd,data)
+#define u80u160RPI_SerialSendData(fd,data) u16RPISerialSendDatas(fd,data)
+#define u80i160RPI_SerialSendData(fd,data) i16RPISerialSendDatas(fd,data)
+#define u80s0RPI_SerialSendData(fd,data) sRPISerialSendDatas(fd,data)
+#define u80d0RPI_SerialSendData(fd,data) dRPISerialSendDatas(fd,data)
+
+#define u80u82RPI_SerialSendData(fd,data,size) u8RPISerialSendDataa(fd,data,size[0]*size[1]);
+#define u80i82RPI_SerialSendData(fd,data,size) i8RPISerialSendDataa(fd,data,size[0]*size[1]);
+#define u80u162RPI_SerialSendData(fd,data,size) u16RPISerialSendDataa(fd,data,size[0]*size[1]);
+#define u80i162RPI_SerialSendData(fd,data,size) i16RPISerialSendDataa(fd,data,size[0]*size[1]);
+#define u80s2RPI_SerialSendData(fd,data,size) sRPISerialSendDataa(fd,data,size[0]*size[1]);
+#define u80d2RPI_SerialSendData(fd,data,size) dRPISerialSendDataa(fd,data,size[0]*size[1]);
+#define u80g2RPI_SerialSendData(fd,data,size) gRPISerialSendDatas(fd,data,size[0]*size[1]);
+
+#define RPI_SerialDataAvail(fd) i16RPISerialDataAvails(fd)
+#define RPI_SerialGetChar(fd) i16RPISerialGetChars(fd)
+#define RPI_SerialFlush(fd) u8RPISerialFlushs(fd)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_RPIPERIPHERALSERIAL_H__*/
diff --git a/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralThreading.h b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralThreading.h
new file mode 100644
index 0000000..68ed6e0
--- /dev/null
+++ b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralThreading.h
@@ -0,0 +1,25 @@
+ /* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+ */
+#ifndef __INT_RPIPERIPHERALTHREADING_H__
+#define __INT_RPIPERIPHERALTHREADING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RPI_ThreadCreate(fn) RPIThreadCreate(fn);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_RPIPERIPHERALTHREADING_H__*/
diff --git a/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralTiming.h b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralTiming.h
new file mode 100644
index 0000000..1a70465
--- /dev/null
+++ b/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralTiming.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+
+#ifndef __INT_RPIPERIPHERALTIMING_H__
+#define __INT_RPIPERIPHERALTIMING_H__
+
+#include "types.h"
+#include "RPIPeripheralTiming.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RPI_DelayMicro(in1) u16RPIDelayMicros((uint16) in1)
+#define RPI_DelayMilli(in1) u16RPIDelayMillis((uint16) in1)
+#define RPI_GetMicro() u32RPIGetMicros()
+#define RPI_GetMillis() u32RPIGetMillis()
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__RPIPERIPHERALTIMING_H__ */
diff --git a/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetClocks.c b/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetClocks.c
new file mode 100644
index 0000000..d06b135
--- /dev/null
+++ b/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetClocks.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/*Function to set clock for pwm channel. Default clock is 19.2 MHz. 'clk_divisor'
+ along with range decides frequency for PWM
+ PWM frequency = 19.2 MHz / clk_divisor/ range
+ Range for clk_divisor = 1-2048
+ */
+
+#include "types.h"
+#include "RPIPeripheralPWM.h"
+
+void u8RPIHardPWMSetClocks(uint16 clk_divisor)
+{
+ pwmSetClock(clk_divisor);
+
+
+}
diff --git a/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetModes.c b/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetModes.c
new file mode 100644
index 0000000..0cca7a7
--- /dev/null
+++ b/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetModes.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/*Function to set mode for PWM channel. Two modes are available
+ 0 --> balanced mode
+ 1 --> mark/space mode
+ */
+
+#include "types.h"
+#include "RPIPeripheralPWM.h"
+
+void u8RPIHardPWMSetModes(uint8 mode)
+{
+ if (mode == 1) /*mark/space mode*/
+ pwmSetMode(PWM_MODE_MS);
+ else
+ pwmSetMode(PWM_MODE_BAL);
+
+}
diff --git a/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetRanges.c b/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetRanges.c
new file mode 100644
index 0000000..b2489f5
--- /dev/null
+++ b/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetRanges.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/*Function to assigne pwm duty to specified pin. PWM duty is decided by 'value'
+ and 'range' specified using corresponding function.
+ PWM duty = value/range
+ */
+
+#include "types.h"
+#include "RPIPeripheralPWM.h"
+
+void u8RPIHardPWMSetRanges(uint16 value)
+{
+ pwmSetRange(value);
+
+}
diff --git a/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMWrites.c b/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMWrites.c
new file mode 100644
index 0000000..ae02bf0
--- /dev/null
+++ b/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMWrites.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/*Function to set range for pwm channel. PWM duty is decided by 'range'
+ and 'value' specified using corresponding function.
+ PWM duty = value/range
+ */
+
+#include "types.h"
+#include "RPIPeripheralPWM.h"
+#include "RPIPeripheralDigital.h"
+
+void u8RPIHardPWMWrites(uint8 pin, uint16 value)
+{
+ pwmWrite((int)phy_pin[pin-1], value);
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/dRPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/dRPISerialSendDataa.c
new file mode 100644
index 0000000..f990255
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/dRPISerialSendDataa.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send double data array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void dRPISerialSendDataa(int fd, double* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; count++)
+ {
+ dRPISerialSendDatas(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/dRPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/dRPISerialSendDatas.c
new file mode 100644
index 0000000..39112fc
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/dRPISerialSendDatas.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send double data on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void dRPISerialSendDatas(int fd, double data)
+{
+ uint8 count;
+
+ union double_bytes{
+ double double_data;
+ unsigned char bytes[sizeof(double)];
+ } in_data;
+
+ in_data.double_data = data;
+
+ for(count=0; count<sizeof(double); count++)
+ {
+ /*Send lsb first*/
+ serialPutchar(fd, (uint8) in_data.bytes[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/gRPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/gRPISerialSendDatas.c
new file mode 100644
index 0000000..f4ec8a8
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/gRPISerialSendDatas.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send string on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void gRPISerialSendDatas(int fd, uint8* data, int size)
+{
+ int count = 0;
+
+ while(data[count] != '\0')
+ {
+ serialPutchar(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/i16RPISerialDataAvails.c b/src/c/hardware/rasberrypi/serial/i16RPISerialDataAvails.c
new file mode 100644
index 0000000..b56a819
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i16RPISerialDataAvails.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to check for data availability at specified port. Returns no of
+ bytes to be read */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+int16 i16RPISerialDataAvails(int fd)
+{
+ int bytes = 0;
+ bytes = serialDataAvail(fd);
+
+ return bytes;
+}
diff --git a/src/c/hardware/rasberrypi/serial/i16RPISerialGetChars.c b/src/c/hardware/rasberrypi/serial/i16RPISerialGetChars.c
new file mode 100644
index 0000000..18ca2a7
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i16RPISerialGetChars.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to read character from spcified serial port (file descriptor).
+ This function will block execution for 10 secs if no character is available,
+ and will return -1 in that case*/
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+int16 i16RPISerialGetChars(int fd)
+{
+ int data = 0;
+
+ data = serialGetchar(fd);
+
+ return data;
+}
diff --git a/src/c/hardware/rasberrypi/serial/i16RPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/i16RPISerialSendDataa.c
new file mode 100644
index 0000000..24180f4
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i16RPISerialSendDataa.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send signed 16-bit data array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void i16RPISerialSendDataa(int fd, int16* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ i16RPISerialSendDatas(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/i16RPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/i16RPISerialSendDatas.c
new file mode 100644
index 0000000..fe6fe6f
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i16RPISerialSendDatas.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send signed 16-bit byte on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void i16RPISerialSendDatas(int fd, int16 data)
+{
+ /*Send lsb first*/
+ serialPutchar(fd, (uint8) data);
+ serialPutchar(fd, (uint8) (data>>8));
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/i8RPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/i8RPISerialSendDataa.c
new file mode 100644
index 0000000..c4dd199
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i8RPISerialSendDataa.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send signed 8-bit byte array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void i8RPISerialSendDataa(int fd, int8* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ i8RPISerialSendDatas(fd, data[count]);
+ }
+}
diff --git a/src/c/hardware/rasberrypi/serial/i8RPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/i8RPISerialSendDatas.c
new file mode 100644
index 0000000..e637871
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i8RPISerialSendDatas.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send signed 8-bit byte on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void i8RPISerialSendDatas(int fd, int8 data)
+{
+ serialPutchar(fd, (uint8) data);
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/sRPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/sRPISerialSendDataa.c
new file mode 100644
index 0000000..14c0bc7
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/sRPISerialSendDataa.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send float data array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void sRPISerialSendDataa(int fd, float* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ sRPISerialSendDatas(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/sRPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/sRPISerialSendDatas.c
new file mode 100644
index 0000000..ff78dd1
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/sRPISerialSendDatas.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send float data on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void sRPISerialSendDatas(int fd, float data)
+{
+ uint8 count;
+
+ union float_bytes{
+ float float_data;
+ unsigned char bytes[sizeof(float)];
+ } in_data;
+ in_data.float_data = data;
+
+ for(count=0; count<sizeof(float); count++)
+ {
+ /*Send lsb first*/
+ serialPutchar(fd, (uint8) in_data.bytes[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/u16RPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/u16RPISerialSendDataa.c
new file mode 100644
index 0000000..b444047
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u16RPISerialSendDataa.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send unsigned 16-bit data array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u16RPISerialSendDataa(int fd, uint16* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ u16RPISerialSendDatas(fd, data[count]);
+ }
+
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/u16RPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/u16RPISerialSendDatas.c
new file mode 100644
index 0000000..b4a90c2
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u16RPISerialSendDatas.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send unsigned 16-bit data on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u16RPISerialSendDatas(int fd, uint16 data)
+{
+ /*Send lsb first*/
+ serialPutchar(fd, (uint8) data);
+ serialPutchar(fd, (uint8) (data>>8));
+}
diff --git a/src/c/hardware/rasberrypi/serial/u16RPISerialSetups.c b/src/c/hardware/rasberrypi/serial/u16RPISerialSetups.c
new file mode 100644
index 0000000..cde4cba
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u16RPISerialSetups.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to setup port with desired baud rate. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+int u16RPISerialSetups(char* port, int baudrate)
+{
+ int fd;
+
+ fd = serialOpen (port, baudrate);
+
+ return fd;
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialCloses.c b/src/c/hardware/rasberrypi/serial/u8RPISerialCloses.c
new file mode 100644
index 0000000..5162d15
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialCloses.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to close serial port opened. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialCloses(int fd)
+{
+ serialClose (fd);
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialFlushs.c b/src/c/hardware/rasberrypi/serial/u8RPISerialFlushs.c
new file mode 100644
index 0000000..c80a92c
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialFlushs.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to discards data serial buffer (received as well as waiting to be sent */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialFlushs(int fd)
+{
+ serialFlush(fd);
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialSendChars.c b/src/c/hardware/rasberrypi/serial/u8RPISerialSendChars.c
new file mode 100644
index 0000000..e381351
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialSendChars.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send 8-bit char on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialSendChars(int fd, uint8 data)
+{
+ serialPutchar(fd, data);
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/u8RPISerialSendDataa.c
new file mode 100644
index 0000000..9d09714
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialSendDataa.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send unsigned 8-bit byte array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialSendDataa(int fd, uint8* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ u8RPISerialSendDatas(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/u8RPISerialSendDatas.c
new file mode 100644
index 0000000..9edb439
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialSendDatas.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send unsigned 8-bit byte on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialSendDatas(int fd, uint8 data)
+{
+ serialPutchar(fd, data);
+
+}
diff --git a/src/c/hardware/rasberrypi/threading/u16RPIThreadCreates.c b/src/c/hardware/rasberrypi/threading/u16RPIThreadCreates.c
new file mode 100644
index 0000000..c05c959
--- /dev/null
+++ b/src/c/hardware/rasberrypi/threading/u16RPIThreadCreates.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to create thread for given function */
+
+#include "types.h"
+#include "RPIPeripheralThreading.h"
+
+uint16 RPIThreadCreate(void *(*threadFunction)(void*))
+{
+ int status;
+ status = piThreadCreate (threadFunction);
+ return status;
+}
+
diff --git a/src/c/hardware/rasberrypi/timing/u16RPIDelayMicros.c b/src/c/hardware/rasberrypi/timing/u16RPIDelayMicros.c
new file mode 100644
index 0000000..9aeeab7
--- /dev/null
+++ b/src/c/hardware/rasberrypi/timing/u16RPIDelayMicros.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to insert some delay in code execution. */
+
+#include "types.h"
+#include "RPIPeripheralTiming.h"
+
+void u16RPIDelayMicros(uint16 time)
+{
+ delayMicroseconds(time);
+}
+
diff --git a/src/c/hardware/rasberrypi/timing/u16RPIDelayMillis.c b/src/c/hardware/rasberrypi/timing/u16RPIDelayMillis.c
new file mode 100644
index 0000000..2679086
--- /dev/null
+++ b/src/c/hardware/rasberrypi/timing/u16RPIDelayMillis.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to insert some delay in code execution. */
+
+
+
+#include "types.h"
+#include "RPIPeripheralTiming.h"
+
+void u16RPIDelayMillis(uint16 time)
+{
+ delay(time);
+
+}
+
diff --git a/src/c/hardware/rasberrypi/timing/u32RPIGetMicros.c b/src/c/hardware/rasberrypi/timing/u32RPIGetMicros.c
new file mode 100644
index 0000000..eb086a9
--- /dev/null
+++ b/src/c/hardware/rasberrypi/timing/u32RPIGetMicros.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to get time in microsecond since first setup function called */
+
+#include "types.h"
+#include "RPIPeripheralTiming.h"
+
+uint32 u32RPIGetMicros()
+{
+ return(micros());
+} \ No newline at end of file
diff --git a/src/c/hardware/rasberrypi/timing/u32RPIGetMillis.c b/src/c/hardware/rasberrypi/timing/u32RPIGetMillis.c
new file mode 100644
index 0000000..c118975
--- /dev/null
+++ b/src/c/hardware/rasberrypi/timing/u32RPIGetMillis.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - IIT Bombay - FOSSEE
+
+ This file must be used under the terms of the CeCILL.
+ This source file is licensed as described in the file COPYING, which
+ you should have received as part of this distribution. The terms
+ are also available at
+ http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to get time in millisecond since first setup function called */
+
+#include "types.h"
+#include "RPIPeripheralTiming.h"
+
+uint32 u32RPIGetMillis()
+{
+ return(millis());
+} \ No newline at end of file