summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/hardware
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/c/hardware')
-rw-r--r--2.3-1/src/c/hardware/avr/adc/u8AVRADCSetups.c22
-rw-r--r--2.3-1/src/c/hardware/avr/adc/u8AVRReadADCs.c54
-rw-r--r--2.3-1/src/c/hardware/avr/default_files/Makefile387
-rw-r--r--2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalIns.c29
-rw-r--r--2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalOuts.c12
-rw-r--r--2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalPortSetups.c81
-rw-r--r--2.3-1/src/c/hardware/avr/includes/AVRPeripheralADC.h4
-rw-r--r--2.3-1/src/c/hardware/avr/includes/AVRPeripheralGPIO.h17
-rw-r--r--2.3-1/src/c/hardware/avr/includes/AVRPeripheralPWM.h13
-rw-r--r--2.3-1/src/c/hardware/avr/includes/AVRPeripheralTimer.h17
-rw-r--r--2.3-1/src/c/hardware/avr/includes/AVRPeripheralUART.h59
-rw-r--r--2.3-1/src/c/hardware/avr/includes/AVRUtil.h14
-rw-r--r--2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h14
-rw-r--r--2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h19
-rw-r--r--2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h27
-rw-r--r--2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h18
-rw-r--r--2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralUART.h57
-rw-r--r--2.3-1/src/c/hardware/avr/interfaces/int_AVRUtil.h19
-rw-r--r--2.3-1/src/c/hardware/avr/pwm/u8AVRPWM0SetDutys.c24
-rw-r--r--2.3-1/src/c/hardware/avr/pwm/u8AVRPWM0Setups.c50
-rw-r--r--2.3-1/src/c/hardware/avr/pwm/u8AVRPWM1SetDutys.c31
-rw-r--r--2.3-1/src/c/hardware/avr/pwm/u8AVRPWM1Setups.c69
-rw-r--r--2.3-1/src/c/hardware/avr/pwm/u8AVRPWM2SetDutys.c22
-rw-r--r--2.3-1/src/c/hardware/avr/pwm/u8AVRPWM2Setups.c47
-rw-r--r--2.3-1/src/c/hardware/avr/pwm/u8AVRPWMSetDutys.c39
-rw-r--r--2.3-1/src/c/hardware/avr/pwm/u8AVRPWMSetups.c60
-rw-r--r--2.3-1/src/c/hardware/avr/timer/u16AVRGetTimerValues.c51
-rw-r--r--2.3-1/src/c/hardware/avr/timer/u8AVRGetTimerValues.c44
-rw-r--r--2.3-1/src/c/hardware/avr/timer/u8AVRTimerSetups.c138
-rw-r--r--2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmits.c88
-rw-r--r--2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c21
-rw-r--r--2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmita.c26
-rw-r--r--2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmits.c31
-rw-r--r--2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c24
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmita.c27
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmits.c73
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c31
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmita.c25
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmits.c26
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmita.c28
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmits.c87
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c38
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c20
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c215
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmita.c26
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmits.c60
-rw-r--r--2.3-1/src/c/hardware/avr/util/u16AVRSleeps.c15
47 files changed, 1999 insertions, 300 deletions
diff --git a/2.3-1/src/c/hardware/avr/adc/u8AVRADCSetups.c b/2.3-1/src/c/hardware/avr/adc/u8AVRADCSetups.c
index f9d310b8..66f491b2 100644
--- a/2.3-1/src/c/hardware/avr/adc/u8AVRADCSetups.c
+++ b/2.3-1/src/c/hardware/avr/adc/u8AVRADCSetups.c
@@ -1,19 +1,19 @@
// Function to initialise ADC of AVR
//
// Calling Sequence
-// AVRSetupADC(uint8 prescalar, uint8 adc_ref)
+// AVRSetupADC(uint8 prescaler, uint8 adc_ref)
//
// Parameters
-// prescalar: prescalar to be used for generating ADC clock (0-7)
+// 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. 'prescalar' is
+// 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^prescalar). Select appropriate prescalar depending
+// 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
@@ -21,21 +21,23 @@
//
// Authors
// Siddhesh Wani
-//
+// Ashish Kamble
#include "AVRPeripheralADC.h"
-void u8AVRADCSetups(uint8 prescalar, uint8 adc_ref)
+uint8 u8AVRADCSetups(uint8 prescaler, uint8 adc_ref)
{
- /*Set the prescalar value*/
- ADCSRA |= (prescalar & 0x07);
+/*Set the prescaler value*/
+ ADCSRA |= (prescaler & 0x07);
/*Set the adc reference voltage*/
- ADMUX |= ((adc_ref & 0x03) << 6);
+ ADMUX |= ((adc_ref & 0x03) << 6);
/*Enable ADC hardware. Set ADEN bit*/
- ADCSRA |= (1<<7);
+ADCSRA |= (1<<7);
+return 0;
}
+
diff --git a/2.3-1/src/c/hardware/avr/adc/u8AVRReadADCs.c b/2.3-1/src/c/hardware/avr/adc/u8AVRReadADCs.c
index 71fe1363..302f8c82 100644
--- a/2.3-1/src/c/hardware/avr/adc/u8AVRReadADCs.c
+++ b/2.3-1/src/c/hardware/avr/adc/u8AVRReadADCs.c
@@ -1,3 +1,13 @@
+// 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
@@ -22,25 +32,51 @@
//
// Authors
// Siddhesh Wani
-//
+// Ashish Kamble
#include "AVRPeripheralADC.h"
-uint16 u8AVRReadADCs(uint8 channel)
+uint8 u8AVRReadADCs(uint8 channel)
{
- /*Set ADC conversion channel*/
- ADMUX |= (channel & 0x1F);
+
+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);
+// ADCSRA |= (1<<6);
/*Wait for conversion to complete. Check 'ADIF' bit*/
- while(!(ADCSRA & (1<<4)));
+// while(!(ADCSRA & (1<<4)));
/*Clear ADIF flag*/
- ADCSRA |= (1<<4);
+// ADCSRA |= (1<<4);
/*ADC conversion result is stored in ADCH/L registers*/
- return (ADC);
-}
+// return (ADC);
+
+
diff --git a/2.3-1/src/c/hardware/avr/default_files/Makefile b/2.3-1/src/c/hardware/avr/default_files/Makefile
new file mode 100644
index 00000000..c388196b
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalIns.c b/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalIns.c
index 6b61a56b..a2517b98 100644
--- a/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalIns.c
+++ b/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalIns.c
@@ -1,3 +1,13 @@
+// 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
@@ -28,27 +38,26 @@
uint8 u8AVRDigitalIns(uint8 port,uint8 pin)
{
- uint8 state = 0;
+ unsigned int state = 0;
if(port == PORT_A)
{
- state = (uint8)(PINA & (1<<pin));
- return state;
+ state = bit_is_clear(PINA,pin);
+ return !state;
}
if(port == PORT_B)
{
- state = (uint8)(PINB & (1<<pin));
- return state;
+ state = bit_is_clear(PINB,pin);
+ return !state;
}
if(port == PORT_C)
{
- state = (uint8)(PINC & (1<<pin));
- return state;
+ state = bit_is_clear(PINC,pin);
+ return !state;
}
if(port == PORT_D)
{
- state = (uint8)(PIND & (1<<pin));
- return state;
+ state = bit_is_clear(PIND,pin);
+ return !state;
}
-//return state;
}
diff --git a/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalOuts.c b/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalOuts.c
index 118da542..8998fc91 100644
--- a/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalOuts.c
+++ b/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalOuts.c
@@ -1,3 +1,13 @@
+// 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
@@ -20,7 +30,7 @@
//
// Authors
// Siddhesh Wani
-//
+// Ashish Kamble
#include "AVRPeripheralGPIO.h"
diff --git a/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalPortSetups.c b/2.3-1/src/c/hardware/avr/gpio/u8AVRDigitalPortSetups.c
new file mode 100644
index 00000000..54ec7312
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/includes/AVRPeripheralADC.h b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralADC.h
index 736c3406..2a27e37d 100644
--- a/2.3-1/src/c/hardware/avr/includes/AVRPeripheralADC.h
+++ b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralADC.h
@@ -15,9 +15,9 @@ extern "C" {
#endif
//Function prototypes
-void u8AVRADCSetups(uint8 prescalar, uint8 adc_ref);
+uint8 u8AVRADCSetups(uint8 prescaler, uint8 adc_ref);
-uint16 u8AVRReadADCs(uint8 channel);
+uint8 u8AVRReadADCs(uint8 channel);
#ifdef __cplusplus
diff --git a/2.3-1/src/c/hardware/avr/includes/AVRPeripheralGPIO.h b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralGPIO.h
index 37f2377e..9a8d2d65 100644
--- a/2.3-1/src/c/hardware/avr/includes/AVRPeripheralGPIO.h
+++ b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralGPIO.h
@@ -1,8 +1,14 @@
-//This file defines constants corresponding to gpios and digital input functions.
-//
-// Authors
-// Siddhesh Wani
+// 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__
@@ -38,6 +44,9 @@ 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
diff --git a/2.3-1/src/c/hardware/avr/includes/AVRPeripheralPWM.h b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralPWM.h
index 2e41db6e..2107a5a4 100644
--- a/2.3-1/src/c/hardware/avr/includes/AVRPeripheralPWM.h
+++ b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralPWM.h
@@ -1,7 +1,7 @@
//This file defines functions prototypes related to PWM.
//
// Authors
-// Siddhesh Wani
+// Ashish Kamble
//
#ifndef __AVRPERIPHERALPWM_H__
@@ -15,10 +15,17 @@ extern "C" {
#endif
//Function prototypes
-void u8AVRPWMSetups(uint8 timer, uint8 prescalar, uint8 waveform_mode, uint8 output_mode);
+uint8 u8AVRPWM0Setups(uint8 waveform_mode, uint8 output_mode);
-void u8AVRPWMSetDutys(uint8 timer, uint8 duty);
+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" */
diff --git a/2.3-1/src/c/hardware/avr/includes/AVRPeripheralTimer.h b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralTimer.h
index 78b04aae..ab087692 100644
--- a/2.3-1/src/c/hardware/avr/includes/AVRPeripheralTimer.h
+++ b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralTimer.h
@@ -1,8 +1,13 @@
-//This file defines functions prototypes related to Timer.
-//
-// Authors
-// Siddhesh Wani
+// 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__
@@ -15,10 +20,10 @@ extern "C" {
#endif
//Function prototypes
-uint8 u8AVRTimerSetups(uint8 timer, uint8 prescalar);
-uint8 u8AVRGetTimerValue(uint8 timer);
+uint16 u8AVRGetTimerValues(uint16 timer);
+uint8 u8AVRTimerSetups(uint8 timer, uint16 prescaler,uint8 clock_source);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/2.3-1/src/c/hardware/avr/includes/AVRPeripheralUART.h b/2.3-1/src/c/hardware/avr/includes/AVRPeripheralUART.h
new file mode 100644
index 00000000..09db3b03
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/includes/AVRUtil.h b/2.3-1/src/c/hardware/avr/includes/AVRUtil.h
index 0aa1923f..55789bef 100644
--- a/2.3-1/src/c/hardware/avr/includes/AVRUtil.h
+++ b/2.3-1/src/c/hardware/avr/includes/AVRUtil.h
@@ -1,8 +1,14 @@
-//This file defines functions corresponding to delay functions
-//
-// Authors
-// Siddhesh Wani
+// 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__
diff --git a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h
index 425b03fc..5d3a48e5 100644
--- a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h
+++ b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralADC.h
@@ -1,8 +1,14 @@
-//This file defines constants corresponding to gpios.
-//
-// Authors
-// Siddhesh Wani
+// 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__
diff --git a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h
index c034718c..3fcbb8f5 100644
--- a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h
+++ b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralGPIO.h
@@ -1,8 +1,15 @@
-//This file defines constants corresponding to gpios.
-//
-// Authors
-// Siddhesh Wani
+
+// 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__
@@ -22,6 +29,10 @@ extern "C" {
#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
diff --git a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h
index 2d5e5cbd..5c5950bc 100644
--- a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h
+++ b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralPWM.h
@@ -1,8 +1,14 @@
-//This file defines constants corresponding to gpios.
-//
-// Authors
-// Siddhesh Wani
+// 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__
@@ -14,10 +20,17 @@
extern "C" {
#endif
-#define AVRPWMSetup(in1,in2,in3,in4) u8AVRPWMSetups((uint8) in1,\
- (uint8) in2, (uint8) in3, (uint8) in4);
+#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 AVRPWMSetDuty(in1,in2) u8AVRPWMSetDutys((uint8) in1, (uint8) in2);
+#define AVRPWM1SetDuty(in1,in2,in3) u8AVRPWM1SetDutys((uint8) in1,(uint16) in2,(uint16) in3);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h
index b4b66bae..3ec6a7ec 100644
--- a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h
+++ b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralTimer.h
@@ -1,8 +1,14 @@
-//This file defines constants corresponding to gpios.
-//
-// Authors
-// Siddhesh Wani
+// 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__
@@ -14,9 +20,9 @@
extern "C" {
#endif
-#define AVRTimerSetup(in1,in2) u8AVRTimerSetups((uint8) in1, (uint8) in2);
+#define AVRGetTimerValue(in1) u8AVRGetTimerValues((uint16) in1);
-#define AVRGetTimerValue(in1) u8AVRGetTimerValues((uint8) in1);
+#define AVRTimerSetup(in1,in2,in3) u8AVRTimerSetups((uint8) in1, (uint16) in2, (uint8) in3);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralUART.h b/2.3-1/src/c/hardware/avr/interfaces/int_AVRPeripheralUART.h
new file mode 100644
index 00000000..81b4af68
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/interfaces/int_AVRUtil.h b/2.3-1/src/c/hardware/avr/interfaces/int_AVRUtil.h
index 2d6bbef7..51cbce58 100644
--- a/2.3-1/src/c/hardware/avr/interfaces/int_AVRUtil.h
+++ b/2.3-1/src/c/hardware/avr/interfaces/int_AVRUtil.h
@@ -1,8 +1,14 @@
-//This file defines interfaces corresponding to uitl function.
-//
-// Authors
-// Siddhesh Wani
+// 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__
@@ -14,7 +20,10 @@
extern "C" {
#endif
-#define d0sleepu80(in1) u16AVRSleeps ((uint16) in1);
+//#define d0sleepu80(in1) u16AVRSleeps ((uint16) in1);
+
+#define AVRSleep(in1) u16AVRSleeps ((uint16) in1);
+
#ifdef __cplusplus
} /* extern "C" */
diff --git a/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM0SetDutys.c b/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM0SetDutys.c
new file mode 100644
index 00000000..106a872e
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM0Setups.c b/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM0Setups.c
new file mode 100644
index 00000000..131ee68b
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM1SetDutys.c b/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM1SetDutys.c
new file mode 100644
index 00000000..47aad1c8
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM1Setups.c b/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM1Setups.c
new file mode 100644
index 00000000..b3f2d8f4
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM2SetDutys.c b/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM2SetDutys.c
new file mode 100644
index 00000000..e0b53186
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM2Setups.c b/2.3-1/src/c/hardware/avr/pwm/u8AVRPWM2Setups.c
new file mode 100644
index 00000000..f5f87672
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/pwm/u8AVRPWMSetDutys.c b/2.3-1/src/c/hardware/avr/pwm/u8AVRPWMSetDutys.c
deleted file mode 100644
index 0f358fc3..00000000
--- a/2.3-1/src/c/hardware/avr/pwm/u8AVRPWMSetDutys.c
+++ /dev/null
@@ -1,39 +0,0 @@
-// Function to set duty for PWM of AVR
-//
-// Calling Sequence
-// u8AVRPWMSetDutys(uint8 timer, uint8 duty)
-//
-// Parameters
-// timer: timer to be used for PWM generation (0,1,2)
-// duty: duty for PWM waveform (0-100)
-//
-// Description
-// This function sets duty for PWM waveform according to given parameters.
-//
-// Examples
-// u8AVRPWMSetDutys(0,10) //Sets 10% duty for timer 0 output.
-//
-// Authors
-// Siddhesh Wani
-//
-
-#include "AVRPeripheralPWM.h"
-
-void u8AVRPWMSetDutys(uint8 timer, uint8 duty)
-{
- uint8 duty_value=0;
-
- switch(timer)
- {
- case 0:
- duty_value = (uint8)(((uint16)(duty * 0xff))/100);
- OCR0 = duty_value;
- break;
- case 2:
- duty_value = (uint8)(((uint16)(duty * 0xff))/100);
- OCR2 = duty_value;
- break;
- }
-
-
-}
diff --git a/2.3-1/src/c/hardware/avr/pwm/u8AVRPWMSetups.c b/2.3-1/src/c/hardware/avr/pwm/u8AVRPWMSetups.c
deleted file mode 100644
index 945f2312..00000000
--- a/2.3-1/src/c/hardware/avr/pwm/u8AVRPWMSetups.c
+++ /dev/null
@@ -1,60 +0,0 @@
-// Function to initialise PWM of AVR
-//
-// Calling Sequence
-// u8AVRPWMSetups(uint8 timer, uint8 prescalar, uint8 waveform_mode, uint8 output_mode)
-//
-// Parameters
-// timer: timer to be used for PWM generation (0,1,2)
-// prescalar: prescalar to be used for generating PWM waveform (0-7)
-// waveform_mode: decides type of waveform generation
-// 0 -> Normal mode
-// 1 -> Phase correct mode
-// 2 -> CTC mode
-// 3 -> Fase PWM mode
-// output_mode: decides the compare output mode. (0-3)
-// behaviour of the output is different for different inputs
-// depending upon 'waveform_mode' chosen.
-// ***Refer datasheet for more description about above modes
-//
-// Description
-// This function initialises PWM of AVR with given parameters. 'timer'
-// decides which of the three (0,1,2) timers available to be used. The
-// 'prescalar' is needed for deciding PWM clock. Select appropriate prescalar
-// depending on MCU clock. Choose required pwmmode using 'waveform_generation'
-// and 'output_mode'. Please refer datasheet for more description of 'wafefom_mode'
-// and 'output mode'.
-// Examples
-// AVRPWMSetup(0,1,2,2)
-//
-// Authors
-// Siddhesh Wani
-//
-
-#include "AVRPeripheralPWM.h"
-
-
-void u8AVRPWMSetups(uint8 timer, uint8 prescalar, uint8 waveform_mode, uint8 output_mode)
-{
- switch(timer)
- {
- case 0:
- TCCR0|= (prescalar & 0x07); //Select clock source
- //Select waveform generation mode
- TCCR0|= ((waveform_mode & 0x04) << 4);
- //Select compare output mode
- TCCR0 |= ((output_mode & 0x01) << 3); //WGM0
- TCCR0 |= ((output_mode & 0x02) << 6); //WGM1
- break;
- case 1:
- break;
- case 2:
- TCCR2|= (prescalar & 0x07); //Select clock source
- //Select waveform generation mode
- TCCR2|= ((waveform_mode & 0x04) << 4);
- //Select compare output mode
- TCCR2 |= ((output_mode & 0x01) << 3); //WGM0
- TCCR2 |= ((output_mode & 0x02) << 6); //WGM1
- break;
- }
-}
-
diff --git a/2.3-1/src/c/hardware/avr/timer/u16AVRGetTimerValues.c b/2.3-1/src/c/hardware/avr/timer/u16AVRGetTimerValues.c
new file mode 100644
index 00000000..8ef16e8d
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/timer/u8AVRGetTimerValues.c b/2.3-1/src/c/hardware/avr/timer/u8AVRGetTimerValues.c
index c542c182..e08bb3a6 100644
--- a/2.3-1/src/c/hardware/avr/timer/u8AVRGetTimerValues.c
+++ b/2.3-1/src/c/hardware/avr/timer/u8AVRGetTimerValues.c
@@ -1,3 +1,14 @@
+// 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
@@ -12,26 +23,41 @@
//
//
// Authors
-// Siddhesh Wani
+// Ashish Kamble
//
#include "AVRPeripheralTimer.h"
+#include <avr/interrupt.h>
-uint8 u8AVRGetTimerValues(uint8 timer)
-{
+uint16 u8AVRGetTimerValues(uint16 timer)
+{ uint16_t x;
switch(timer)
{
case 0:
- return TCNT0;
-
+ {
+ x = TCNT0;
+ break;
+ }
case 1:
- break;
+ {
+ unsigned char sreg;
+ unsigned int val;
+ sreg = SREG;
+ cli();
+ val = TCNT1;
+ SREG = sreg;
+ sei();
+ x = val;
+ break;
+ }
case 2:
- return TCNT2;
+ {
+ x = TCNT2;
+ break;
+ }
}
-
- return 0;
+return x;
}
diff --git a/2.3-1/src/c/hardware/avr/timer/u8AVRTimerSetups.c b/2.3-1/src/c/hardware/avr/timer/u8AVRTimerSetups.c
index 1d93429b..6ee8d2af 100644
--- a/2.3-1/src/c/hardware/avr/timer/u8AVRTimerSetups.c
+++ b/2.3-1/src/c/hardware/avr/timer/u8AVRTimerSetups.c
@@ -1,42 +1,110 @@
-// Function to setup timer on AVR
-//
-// Calling Sequence
-// u8AVRTimerSetups(timer, prescalar)
-//
-// Parameters
-// timer: timer to be set up (0,1,2)
-// prescalar: prescalar to be used for timer (0-7)
-// ***Refer datasheet for more description about timer
-//
-// Description
-// This function sets prescalr for timers. 'timer' decides which of the
-// three (0,1,2) timers available to be used. The 'prescalar' is needed for
-// deciding timer clock. Select appropriate prescalar depending on MCU clock
-// and requirement.
-//
-//
-// Authors
-// Siddhesh Wani
-//
+/* 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,uint8 prescalar)
+uint8 u8AVRTimerSetups(uint8 timer,uint16 prescaler,uint8 clock_source)
{
- switch(timer)
- {
- case 0:
- TCCR0|= (prescalar & 0x07); //Select clock source
- break;
- case 1:
- break;
- case 2:
- TCCR2|= (prescalar & 0x07); //Select clock source
- break;
- }
-
- return 0;
+
+ 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/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmits.c
new file mode 100644
index 00000000..ec63c4de
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c b/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c
new file mode 100644
index 00000000..8978cc00
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmita.c
new file mode 100644
index 00000000..fea9319d
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmits.c
new file mode 100644
index 00000000..502f2727
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c
new file mode 100644
index 00000000..f3384068
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmita.c
new file mode 100644
index 00000000..8d0fcd47
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmits.c
new file mode 100644
index 00000000..4d907762
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c
new file mode 100644
index 00000000..99638c77
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmita.c
new file mode 100644
index 00000000..10345738
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmits.c
new file mode 100644
index 00000000..6b8c20fb
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmita.c
new file mode 100644
index 00000000..8b8e6301
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmits.c
new file mode 100644
index 00000000..3cfb4a27
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c
new file mode 100644
index 00000000..a68a5aa9
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c
new file mode 100644
index 00000000..df0a55b7
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c
index f311500a..085ac6e3 100644
--- a/2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c
+++ b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c
@@ -1,84 +1,143 @@
-// Function to initialise uart interface of AVR
-//
-// Calling Sequence
-// u8AVRUARTSetups(uint8 mode, uint8 baudrate, uint8 stopbits, uint8 parity)
-//
-// Parameters
-// mode : Mode of usart interface (0-Normal mode, 1-Double speed mode,
-// 2-Synchronous master mode)
-// baudrate : Baudrate for communication. Refer AVRPeripheralUART.h
-// for available options)
-// stopbits : No. of stopbits (0-1) for stopbits 1 and 2 resp.
-// parity: set parity bit. (0-disabled, 1-Even parity, 2-Odd parity)
-//
-//
-// Description
-// This function initialises uart interface for AVR. Available modes are
-// Normal mode (0), Double speed mode (1), Synchronous master mode(2). 'baudrate'
-// decides baudrate for communication. For baudrate settings, variable
-// 'XTAL_FREQUENCY' is required. 'stopbits' sets no of stopbits for data
-// packet. 0 for 1 stopbit and 1 for 2 stopbits. 'parity' decides parity bit
-// for communication. 0 for disabling parity bit, 1 for even parity and 2
-// for odd parity.
-//
-// Authors
-// Siddhesh Wani
-//
+/* 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, uint8 baudrate, uint8 stopbits, uint8 parity)
+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)
{
- switch (mode) //According to mode set bits UMSEL and U2X
- {
- case 0: //Normal mode
- UCSRC &= ~(1<<6); //Clear bit 6 UMSEL
- break;
-
- case 1: //Double speed mode
- UCSRC &= ~(1<<6); //Clear bit 6 UMSEL
- break;
-
- case 2: //Synchronous master mode
- UCSRC |= (1<<6); //Set bit 6 UMSEL
- break;
- }
-
- if(stopbits == 0)
- { // 1 stopbit
- UCSRC &= ~(1<<3);
- }
- else
- { // 2 stopbits
- UCSRC |= (1<<3);
- }
-
- //Set parity bit settings
- switch(parity)
- {
- case 0: // Parity disabled
- UCSRC &= ~(3<<4); //UPM1:0=0
- break;
- case 1:// Even parity
- UCSRC |= (1<<5); //UPM1:0 = 2
- UCSRC &= ~(1<<4);
- break;
- case 2:// Odd parity
- UCSRC |= (1<<5); //UPM1:1 = 3
- UCSRC |= (1<<4);
- break;
- }
-
- //Set baud rate
- # define BAUD baudrate
- #include "util/setbaud.h"
- UBRRH = UBRRH_VALUE;
- UBRRL = UBRRL_VALUE;
- #if USE_2X
- UCSRA |= (1 << U2X);
- #else
- UCSRA &= ~(1 << U2X);
- #endif
- return 0;
+ 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/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmita.c
new file mode 100644
index 00000000..14e2a0ea
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmits.c
new file mode 100644
index 00000000..e7e5c716
--- /dev/null
+++ b/2.3-1/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/2.3-1/src/c/hardware/avr/util/u16AVRSleeps.c b/2.3-1/src/c/hardware/avr/util/u16AVRSleeps.c
index 4d81c964..a6a7e508 100644
--- a/2.3-1/src/c/hardware/avr/util/u16AVRSleeps.c
+++ b/2.3-1/src/c/hardware/avr/util/u16AVRSleeps.c
@@ -1,8 +1,15 @@
-//Function to introduce specific delay in milliseconds
-//
-//Authors
-// Siddhesh Wani
+// 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"