├── README.md ├── hardware └── fpga │ └── f32c │ ├── boards.txt │ ├── cores │ └── f32c │ │ ├── Arduino.h │ │ ├── HardwareSerial.h │ │ ├── Print.cpp │ │ ├── Print.h │ │ ├── Printable.h │ │ ├── Stream.h │ │ ├── UARTClass.cpp │ │ ├── UARTClass.h │ │ ├── WCharacter.h │ │ ├── WInterrupts.c │ │ ├── WInterrupts.h │ │ ├── WMath.cpp │ │ ├── WMath.h │ │ ├── WString.cpp │ │ ├── WString.h │ │ ├── abi.cpp │ │ ├── avr │ │ └── pgmspace.h │ │ ├── binary.h │ │ ├── itoa.c │ │ ├── itoa.h │ │ ├── main.cpp │ │ ├── new.cpp │ │ ├── wiring.c │ │ ├── wiring.h │ │ ├── wiring_analog.c │ │ ├── wiring_analog.h │ │ ├── wiring_constants.h │ │ ├── wiring_digital.c │ │ ├── wiring_digital.h │ │ ├── wiring_private.h │ │ ├── wiring_pulse.cpp │ │ ├── wiring_pulse.h │ │ ├── wiring_shift.c │ │ └── wiring_shift.h │ ├── obsolete │ ├── boards.txt │ └── platform.txt │ ├── platform.txt │ ├── programmers.txt │ ├── system │ ├── include │ │ ├── assert.h │ │ ├── complex.h │ │ ├── ctype.h │ │ ├── dev │ │ │ ├── fb.h │ │ │ ├── io.h │ │ │ ├── spi.h │ │ │ └── sprite.h │ │ ├── errno.h │ │ ├── fatfs │ │ │ ├── diskio.h │ │ │ ├── ff.h │ │ │ ├── ffconf.h │ │ │ └── integer.h │ │ ├── float.h │ │ ├── inttypes.h │ │ ├── limits.h │ │ ├── math.h │ │ ├── mips │ │ │ ├── _fpmath.h │ │ │ ├── _limits.h │ │ │ ├── _types.h │ │ │ ├── asm.h │ │ │ ├── atomic.h │ │ │ ├── cdefs.h │ │ │ ├── cpuregs.h │ │ │ ├── endian.h │ │ │ ├── io.h │ │ │ ├── regdef.h │ │ │ └── setjmp.h │ │ ├── riscv │ │ │ └── io.h │ │ ├── setjmp.h │ │ ├── stdarg.h │ │ ├── stdbool.h │ │ ├── stddef.h │ │ ├── stdint.h │ │ ├── stdio.h │ │ ├── stdlib.h │ │ ├── string.h │ │ ├── strings.h │ │ ├── sys │ │ │ ├── _null.h │ │ │ ├── _sigset.h │ │ │ ├── _timespec.h │ │ │ ├── _timeval.h │ │ │ ├── _types.h │ │ │ ├── cdefs.h │ │ │ ├── elf32.h │ │ │ ├── elf_common.h │ │ │ ├── endian.h │ │ │ ├── errno.h │ │ │ ├── fcntl.h │ │ │ ├── isr.h │ │ │ ├── limits.h │ │ │ ├── null.h │ │ │ ├── param.h │ │ │ ├── queue.h │ │ │ ├── select.h │ │ │ ├── signal.h │ │ │ ├── stat.h │ │ │ ├── stdint.h │ │ │ ├── time.h │ │ │ ├── timespec.h │ │ │ └── types.h │ │ ├── time.h │ │ └── unistd.h │ ├── mips │ │ └── lib │ │ │ ├── libc.a │ │ │ ├── libcrt0.a │ │ │ ├── libm.a │ │ │ └── libulx2s.a │ ├── riscv │ │ └── lib │ │ │ ├── libc.a │ │ │ ├── libcrt0.a │ │ │ ├── libm.a │ │ │ └── libulx2s.a │ └── src │ │ ├── Makefile │ │ ├── assert.c │ │ ├── atoi.c │ │ ├── diskio.c │ │ ├── div.c │ │ ├── div64.c │ │ ├── fatfs.c │ │ ├── fb.c │ │ ├── file.c │ │ ├── float │ │ ├── CREDITS.TXT │ │ ├── LICENSE.TXT │ │ ├── adddf3.c │ │ ├── addsf3.c │ │ ├── ashldi3.c │ │ ├── clzsi2.c │ │ ├── comparedf2.c │ │ ├── comparesf2.c │ │ ├── divdf3.c │ │ ├── divsf3.c │ │ ├── extendsfdf2.c │ │ ├── fixdfsi.c │ │ ├── fixsfsi.c │ │ ├── fixunsdfdi.c │ │ ├── fixunsdfsi.c │ │ ├── fixunssfsi.c │ │ ├── floatsidf.c │ │ ├── floatsisf.c │ │ ├── floatundidf.c │ │ ├── floatundisf.c │ │ ├── floatunsidf.c │ │ ├── floatunsisf.c │ │ ├── fp_lib.h │ │ ├── int_endianness.h │ │ ├── int_lib.h │ │ ├── int_types.h │ │ ├── int_util.h │ │ ├── lshrdi3.c │ │ ├── muldf3.c │ │ ├── mulsf3.c │ │ ├── negdf2.c │ │ ├── negsf2.c │ │ ├── subdf3.c │ │ ├── subsf3.c │ │ └── truncdfsf2.c │ │ ├── gets.c │ │ ├── isr.c │ │ ├── lcd.c │ │ ├── malloc.c │ │ ├── math │ │ ├── acos.c │ │ ├── acosf.c │ │ ├── acosh.c │ │ ├── acoshf.c │ │ ├── asin.c │ │ ├── asinf.c │ │ ├── asinh.c │ │ ├── asinhf.c │ │ ├── atan.c │ │ ├── atan2.c │ │ ├── atan2f.c │ │ ├── atanf.c │ │ ├── atanh.c │ │ ├── atanhf.c │ │ ├── ceil.c │ │ ├── ceilf.c │ │ ├── copysignf.c │ │ ├── cos.c │ │ ├── cosf.c │ │ ├── cosh.c │ │ ├── coshf.c │ │ ├── erf.c │ │ ├── erff.c │ │ ├── exp.c │ │ ├── expf.c │ │ ├── expm1.c │ │ ├── expm1f.c │ │ ├── fabs.c │ │ ├── fabsf.c │ │ ├── floor.c │ │ ├── floorf.c │ │ ├── fmod.c │ │ ├── fmodf.c │ │ ├── fpmath.h │ │ ├── frexp.c │ │ ├── frexpf.c │ │ ├── isfinite.c │ │ ├── isinf.c │ │ ├── isnan.c │ │ ├── k_log.h │ │ ├── k_logf.h │ │ ├── log.c │ │ ├── log10.c │ │ ├── log10f.c │ │ ├── log1p.c │ │ ├── log1pf.c │ │ ├── log2.c │ │ ├── log2f.c │ │ ├── logf.c │ │ ├── math_private.h │ │ ├── modf.c │ │ ├── modff.c │ │ ├── pow.c │ │ ├── powf.c │ │ ├── scalbn.c │ │ ├── scalbnf.c │ │ ├── sin.c │ │ ├── sinf.c │ │ ├── sinh.c │ │ ├── sinhf.c │ │ ├── sqrt.c │ │ ├── sqrtf.c │ │ ├── tan.c │ │ ├── tanf.c │ │ ├── tanh.c │ │ └── tanhf.c │ │ ├── memcmp.c │ │ ├── memcpy.c │ │ ├── memmove.c │ │ ├── memset.c │ │ ├── mips │ │ ├── exception.S │ │ ├── setjmp.S │ │ └── start.S │ │ ├── mul.c │ │ ├── printf.c │ │ ├── qsort.c │ │ ├── random.c │ │ ├── riscv │ │ └── start.S │ │ ├── sdcard.c │ │ ├── setjmperr.c │ │ ├── sio.c │ │ ├── sio_baud.c │ │ ├── sio_poll.c │ │ ├── spi.c │ │ ├── sprintf.c │ │ ├── sprite.c │ │ ├── strcasecmp.c │ │ ├── strcpy.c │ │ ├── strncpy.c │ │ ├── strstr.c │ │ ├── strtol.c │ │ └── tjpgd.c │ ├── tools │ ├── boards-manager │ │ ├── boards.txt │ │ ├── mkjson.sh │ │ ├── packbm.sh │ │ ├── platform.txt │ │ └── upload.sh │ ├── openocd │ │ └── scripts │ │ │ ├── board │ │ │ ├── de10-lite.cfg │ │ │ ├── kondor_ax.cfg │ │ │ ├── scarab_ms6p.cfg │ │ │ ├── sparrowhawk.cfg │ │ │ ├── tb276.cfg │ │ │ ├── tb299.cfg │ │ │ └── zybo.cfg │ │ │ └── interface │ │ │ ├── altera-usb-blaster-ftdi.cfg │ │ │ ├── ftdi │ │ │ ├── digilent_adept.cfg │ │ │ ├── fpu1.cfg │ │ │ └── ft2232-generic.cfg │ │ │ └── remote_bitbang.cfg │ └── xilinx-usb-xpc │ │ └── etc-udev-rules.d │ │ └── 55-xilinx-usb-xpc.rules │ └── variants │ ├── FleaFPGA-Uno │ ├── emard_timer.h │ ├── pins_arduino.h │ └── variant.h │ ├── esa11 │ ├── emard_timer.h │ ├── pins_arduino.h │ └── variant.h │ ├── flearduino_shield │ ├── emard_timer.h │ ├── pins_arduino.h │ └── variant.h │ ├── generic │ ├── emard_timer.h │ ├── pins_arduino.h │ └── variant.h │ └── ulx2s_physical │ ├── emard_timer.h │ ├── pins_arduino.h │ └── variant.h └── libraries ├── Adafruit_F32C_LEDSTRIP ├── Adafruit_F32C_LEDSTRIP.cpp ├── Adafruit_F32C_LEDSTRIP.h └── examples │ └── ledstrip │ ├── bitmap.h │ └── ledstrip.ino ├── Adafruit_F32C_VGA ├── Adafruit_F32C_VGA.cpp ├── Adafruit_F32C_VGA.h └── examples │ ├── pong_f32c_vga │ └── pong_f32c_vga.ino │ ├── simple_grafx │ └── simple_grafx.ino │ ├── vgademo │ └── vgademo.ino │ └── videoram │ └── videoram.ino ├── Adafruit_F32C_video ├── Adafruit_F32C_video.cpp ├── Adafruit_F32C_video.h └── examples │ └── pong_f32c_video │ └── pong_f32c_video.ino ├── Adafruit_GFX ├── Adafruit_GFX.cpp ├── Adafruit_GFX.h ├── README.txt ├── glcdfont.c └── license.txt ├── Adafruit_SSD1306 ├── Adafruit_SSD1306.cpp ├── Adafruit_SSD1306.h ├── README.txt ├── examples │ ├── pong_ssd1306_128x64 │ │ └── pong_ssd1306_128x64.ino │ ├── ssd1306_128x32_i2c │ │ └── ssd1306_128x32_i2c.ino │ ├── ssd1306_128x32_spi │ │ └── ssd1306_128x32_spi.ino │ ├── ssd1306_128x64_i2c │ │ └── ssd1306_128x64_i2c.ino │ └── ssd1306_128x64_spi │ │ └── ssd1306_128x64_spi.ino └── license.txt ├── Compositing ├── Compositing.cpp ├── Compositing.h ├── compositing_line.h ├── examples │ ├── c2_bitmap │ │ └── c2_bitmap.ino │ ├── c2_font │ │ ├── c2_font.ino │ │ └── font.h │ ├── c2_font_fancy │ │ ├── c2_font_fancy.ino │ │ └── font.h │ ├── c2_fractals │ │ └── c2_fractals.ino │ ├── c2_galaga_block │ │ ├── c2_galaga_block.ino │ │ └── shapes.h │ ├── c2_galaga_block_beard │ │ ├── c2_galaga_block_beard.ino │ │ └── shapes.h │ ├── c2_pong │ │ └── c2_pong.ino │ ├── c2_raytrace │ │ ├── c2_raytrace.ino │ │ ├── raytrace.h │ │ ├── rt1.c │ │ └── rt2.c │ ├── c2_slides │ │ └── c2_slides.ino │ ├── c2_slides_egg │ │ ├── c2_slides_egg.ino │ │ ├── shapes.h │ │ ├── sprites.cpp │ │ └── sprites.h │ ├── c2_sprites │ │ ├── c2_sprites.ino │ │ └── shapes.h │ ├── c2_sprites_beard │ │ ├── c2_sprites_beard.ino │ │ └── shapes.h │ ├── c2_ulx3s_test │ │ ├── adc.cpp │ │ ├── adc.h │ │ ├── btn.cpp │ │ ├── btn.h │ │ ├── c2_ulx3s_test.ino │ │ ├── dac.cpp │ │ ├── dac.h │ │ ├── edid.cpp │ │ ├── edid.h │ │ ├── flash.cpp │ │ ├── flash.h │ │ ├── font.h │ │ ├── oled.cpp │ │ ├── oled.h │ │ ├── pcm.cpp │ │ ├── pcm.h │ │ ├── ram.cpp │ │ ├── ram.h │ │ ├── rds.cpp │ │ ├── rds.h │ │ ├── rtc.cpp │ │ ├── rtc.cpp_pcf8523t │ │ ├── rtc.h │ │ ├── sd.cpp │ │ ├── sd.h │ │ ├── spi.cpp │ │ ├── spi.h │ │ └── todo.txt │ └── c2_vertical_stripes │ │ └── c2_vertical_stripes.ino ├── shape.h └── sprite.h ├── PCM ├── PCM.cpp ├── PCM.h └── examples │ ├── dcf77tx │ └── dcf77tx.ino │ ├── dummysynth │ └── dummysynth.ino │ ├── midisynth │ └── midisynth.ino │ ├── sine-rawio │ └── sine-rawio.ino │ └── sine │ └── sine.ino ├── PID ├── PID.h └── examples │ └── PID │ └── PID.ino ├── RCSwitch ├── RCSwitch.cpp ├── RCSwitch.h ├── examples │ ├── Garage │ │ └── Garage.ino │ ├── ReceiveDemo_Advanced │ │ ├── ReceiveDemo_Advanced.pde │ │ ├── helperfunctions.ino │ │ └── output.ino │ ├── ReceiveDemo_Simple │ │ └── ReceiveDemo_Simple.pde │ ├── Role │ │ └── Role.ino │ ├── SendDemo │ │ └── SendDemo.pde │ ├── TypeA_WithDIPSwitches │ │ └── TypeA_WithDIPSwitches.pde │ ├── TypeA_WithDIPSwitches_Lightweight │ │ └── TypeA_WithDIPSwitches_Lightweight.ino │ ├── TypeB_WithRotaryOrSlidingSwitches │ │ └── TypeB_WithRotaryOrSlidingSwitches.pde │ ├── TypeC_Intertechno │ │ └── TypeC_Intertechno.pde │ ├── TypeD_REV │ │ └── TypeD_REV.ino │ ├── TypeE_REVnew │ │ └── TypeE_REVnew.ino │ └── Webserver │ │ └── Webserver.pde └── keywords.txt ├── RDS ├── RDS.cpp ├── RDS.h └── examples │ ├── RDS │ └── RDS.ino │ └── RDSdebug │ └── RDSdebug.ino ├── SD ├── README.adoc ├── examples │ ├── CardInfo │ │ └── CardInfo.ino │ ├── Datalogger │ │ └── Datalogger.ino │ ├── DumpFile │ │ └── DumpFile.ino │ ├── Files │ │ └── Files.ino │ ├── ReadWrite │ │ └── ReadWrite.ino │ └── listfiles │ │ └── listfiles.ino ├── keywords.txt ├── library.properties └── src │ ├── File.cpp │ ├── README.txt │ ├── SD.cpp │ ├── SD.h │ └── utility │ ├── FatStructs.h │ ├── Sd2Card.cpp │ ├── Sd2Card.h │ ├── Sd2PinMap.h │ ├── SdFat.h │ ├── SdFatUtil.h │ ├── SdFatmainpage.h │ ├── SdFile.cpp │ ├── SdInfo.h │ ├── SdVolume.cpp │ └── dirty_workaround.h ├── SPI ├── SPI.cpp ├── SPI.h ├── examples │ ├── BarometricPressureSensor │ │ ├── BarometricPressureSensor.ino │ │ └── BarometricPressureSensor │ │ │ └── BarometricPressureSensor.ino │ ├── DigitalPotControl │ │ └── DigitalPotControl.ino │ ├── Flash_ID │ │ └── Flash_ID.ino │ └── OLED_SSD1331 │ │ └── OLED_SSD1331.ino └── keywords.txt ├── SoftwareWire ├── README.TXT ├── SoftwareWire.cpp ├── SoftwareWire.h ├── examples │ ├── Small_example │ │ └── Small_example.ino │ ├── StressTest_Master │ │ └── StressTest_Master.ino │ └── StressTest_Slave │ │ └── StressTest_Slave.ino ├── keywords.txt └── library.properties ├── TTS ├── TTS.cpp ├── TTS.h ├── english.h ├── examples │ └── TTS-FM │ │ └── TTS-FM.ino └── keywords.txt ├── ULX2S ├── examples │ └── fprog │ │ └── fprog.ino ├── fprog.c └── fprog.h ├── Vector ├── Vector.cpp ├── Vector.h ├── Vector_RAM.h ├── Vector_REG.h ├── examples │ ├── vector_blitter │ │ └── vector_blitter.ino │ ├── vector_fractal │ │ └── vector_fractal.ino │ ├── vector_fractal_fast │ │ └── vector_fractal_fast.ino │ ├── vector_fractal_file │ │ └── vector_fractal_file.ino │ ├── vector_fractal_file_chain │ │ ├── vector_fractal_file_chain.ino │ │ └── vector_fractal_file_chain.ino~ │ ├── vector_fractal_file_fast │ │ └── vector_fractal_file_fast.ino │ ├── vector_fractal_file_fast_4reg │ │ └── vector_fractal_file_fast_4reg.ino │ └── vector_test │ │ └── vector_test.ino ├── goldschmidt.c ├── goldschmidt.h ├── vector_link.c └── vector_link.h ├── Wire ├── Wire.cpp ├── Wire.h ├── examples │ ├── SFRRanger_reader │ │ └── SFRRanger_reader.ino │ ├── digital_potentiometer │ │ └── digital_potentiometer.ino │ ├── master_reader │ │ └── master_reader.ino │ ├── master_writer │ │ └── master_writer.ino │ ├── slave_receiver │ │ └── slave_receiver.ino │ └── slave_sender │ │ └── slave_sender.ino ├── keywords.txt └── utility │ ├── twi.c │ └── twi.h ├── f32c ├── examples │ ├── double_fade │ │ └── double_fade.ino │ ├── framebuffer │ │ └── framebuffer.ino │ ├── interrupts │ │ ├── gpio │ │ │ └── gpio.ino │ │ ├── input_capture │ │ │ └── input_capture.ino │ │ ├── mips_timer │ │ │ └── mips_timer.ino │ │ ├── pulse_read │ │ │ └── pulse_read.ino │ │ ├── pwm_switching │ │ │ └── pwm_switching.ino │ │ ├── pwm_timer │ │ │ └── pwm_timer.ino │ │ └── serial │ │ │ └── serial.ino │ ├── irq7_lowlevel │ │ └── interrupt7.ino │ ├── serialprint │ │ └── serialprint.ino │ ├── sprites │ │ └── sprites.ino │ └── synth │ │ └── midisynth.ino ├── f32c.cpp └── f32c.h ├── f32c_PS2Keyboard ├── README.md ├── examples │ └── Simple_Test │ │ └── Simple_Test.ino ├── f32c_PS2Keyboard.cpp ├── f32c_PS2Keyboard.h └── keywords.txt └── f32c_VGATextConsole ├── examples ├── arcagol │ ├── arcagol.ino │ ├── gol.c │ └── gol.h ├── boulder │ ├── boulder.ino │ ├── const.h │ ├── freq.h │ ├── game.c │ ├── game.h │ ├── gamedata.h │ ├── music.c │ ├── music.h │ ├── musicdata.h │ ├── osa.h │ └── sprites.h ├── f32c_16ColorBMapTest │ └── f32c_16ColorBMapTest.ino ├── f32c_TwoColorBMapTest │ └── f32c_TwoColorBMapTest.ino ├── f32c_VGAConsoleFeatures │ └── f32c_VGAConsoleFeatures.ino ├── f32c_VGAConsoleTest │ └── f32c_VGAConsoleTest.ino ├── f32c_compositing │ └── f32c_compositing.ino └── text_raw │ └── text_raw.ino ├── f32c_VGATextConsole.cpp ├── f32c_VGATextConsole.h ├── keywords.txt └── version history.txt /hardware/fpga/f32c/cores/f32c/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef HardwareSerial_h 20 | #define HardwareSerial_h 21 | 22 | #include 23 | 24 | #include "Stream.h" 25 | 26 | class HardwareSerial : public Stream 27 | { 28 | public: 29 | virtual void begin(unsigned long); 30 | virtual void end(); 31 | virtual int available(void) = 0; 32 | virtual int peek(void) = 0; 33 | virtual int read(void) = 0; 34 | virtual void flush(void) = 0; 35 | virtual size_t write(uint8_t) = 0; 36 | using Print::write; // pull in write(str) and write(buf, size) from Print 37 | virtual operator bool() = 0; 38 | }; 39 | 40 | extern void serialEventRun(void) __attribute__((weak)); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/WMath.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | extern "C" { 20 | #include "stdlib.h" 21 | #include "stdint.h" 22 | } 23 | #include "WMath.h" 24 | 25 | extern void randomSeed( uint32_t dwSeed ) 26 | { 27 | if ( dwSeed != 0 ) 28 | { 29 | srand( dwSeed ) ; 30 | } 31 | } 32 | 33 | extern long random( long howbig ) 34 | { 35 | if ( howbig == 0 ) 36 | { 37 | return 0 ; 38 | } 39 | 40 | return rand() % howbig; 41 | } 42 | 43 | extern long random( long howsmall, long howbig ) 44 | { 45 | if (howsmall >= howbig) 46 | { 47 | return howsmall; 48 | } 49 | 50 | long diff = howbig - howsmall; 51 | 52 | return random(diff) + howsmall; 53 | } 54 | 55 | extern long map(long x, long in_min, long in_max, long out_min, long out_max) 56 | { 57 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 58 | } 59 | 60 | extern uint16_t makeWord( uint16_t w ) 61 | { 62 | return w ; 63 | } 64 | 65 | extern uint16_t makeWord( uint8_t h, uint8_t l ) 66 | { 67 | return (h << 8) | l ; 68 | } 69 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/WMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_MATH_ 20 | #define _WIRING_MATH_ 21 | 22 | extern long random( long ) ; 23 | extern long random( long, long ) ; 24 | extern void randomSeed( uint32_t dwSeed ) ; 25 | extern long map( long, long, long, long, long ) ; 26 | 27 | extern uint16_t makeWord( uint16_t w ) ; 28 | extern uint16_t makeWord( uint8_t h, uint8_t l ) ; 29 | 30 | #define word(...) makeWord(__VA_ARGS__) 31 | 32 | 33 | #endif /* _WIRING_MATH_ */ 34 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/avr/pgmspace.h: -------------------------------------------------------------------------------- 1 | #ifndef __PGMSPACE_H_ 2 | #define __PGMSPACE_H_ 1 3 | 4 | #include 5 | 6 | #define PROGMEM 7 | #define PGM_P const char * 8 | #define PSTR(str) (str) 9 | 10 | #define _SFR_BYTE(n) (n) 11 | 12 | typedef void prog_void; 13 | typedef char prog_char; 14 | typedef unsigned char prog_uchar; 15 | typedef int8_t prog_int8_t; 16 | typedef uint8_t prog_uint8_t; 17 | typedef int16_t prog_int16_t; 18 | typedef uint16_t prog_uint16_t; 19 | typedef int32_t prog_int32_t; 20 | typedef uint32_t prog_uint32_t; 21 | 22 | #define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) 23 | #define strcpy_P(dest, src) strcpy((dest), (src)) 24 | #define strcat_P(dest, src) strcat((dest), (src)) 25 | #define strcmp_P(a, b) strcmp((a), (b)) 26 | #define strstr_P(a, b) strstr((a), (b)) 27 | #define strlen_P(a) strlen((a)) 28 | #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) 29 | 30 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 31 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 32 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 33 | #define pgm_read_float(addr) (*(const float *)(addr)) 34 | 35 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) 36 | #define pgm_read_word_near(addr) pgm_read_word(addr) 37 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 38 | #define pgm_read_float_near(addr) pgm_read_float(addr) 39 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) 40 | #define pgm_read_word_far(addr) pgm_read_word(addr) 41 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) 42 | #define pgm_read_float_far(addr) pgm_read_float(addr) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/itoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _ITOA_ 20 | #define _ITOA_ 21 | 22 | __BEGIN_DECLS 23 | 24 | #if 0 25 | 26 | extern void itoa( int n, char s[] ) ; 27 | 28 | #else 29 | 30 | extern char* itoa( int value, char *string, int radix ) ; 31 | extern char* ltoa( long value, char *string, int radix ) ; 32 | extern char* utoa( unsigned long value, char *string, int radix ) ; 33 | extern char* ultoa( unsigned long value, char *string, int radix ) ; 34 | #endif /* 0 */ 35 | 36 | __END_DECLS 37 | 38 | #endif // _ITOA_ 39 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/new.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include 20 | 21 | void *operator new(size_t size) { 22 | return malloc(size); 23 | } 24 | 25 | void *operator new[](size_t size) { 26 | return malloc(size); 27 | } 28 | 29 | void operator delete(void * ptr) { 30 | free(ptr); 31 | } 32 | 33 | void operator delete[](void * ptr) { 34 | free(ptr); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/wiring_digital.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ULX2S board GPIO & hardwired pins 3 | */ 4 | 5 | #include "Arduino.h" 6 | #include "wiring_analog.h" // this is needed to turn off pwm 7 | #include 8 | 9 | __BEGIN_DECLS 10 | 11 | void 12 | pinMode(uint32_t pin, uint32_t mode) 13 | { 14 | volatile uint32_t *port = (volatile uint32_t *) IO_GPIO_CTL; 15 | volatile uint32_t *pullup = (volatile uint32_t *) IO_GPIO_DATA; 16 | 17 | if (pin >= variant_pin_map_size || 18 | digitalPinToPort(pin) != IO_GPIO_DATA) 19 | return; 20 | 21 | switch (mode) { 22 | case INPUT_PULLUP: 23 | *port &= ~(1<= variant_pin_map_size) 44 | return; 45 | 46 | // if port has PWM channel, turn PWM off 47 | pwm_channel = variant_pin_map[pin].pwm; 48 | if(pwm_channel != OCP_NONE) 49 | { 50 | EMARD_TIMER[TC_CONTROL] &= ~pwm_enable_bitmask[pwm_channel].control_or; 51 | EMARD_TIMER[TC_APPLY] = pwm_enable_bitmask[pwm_channel].apply; 52 | } 53 | 54 | port = (PortRegister_t)digitalPinToPort(pin); 55 | 56 | if (val) 57 | *port |= (1<= variant_pin_map_size) 69 | return 0; 70 | 71 | port = (PortRegister_t)digitalPinToPortIn(pin); 72 | return ((*port & (1< 33 | #include 34 | 35 | #define EXTERNAL_NUM_INTERRUPTS 2 36 | 37 | typedef void (*voidFuncPtr)(void); 38 | 39 | __END_DECLS 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/wiring_pulse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_PULSE_ 20 | #define _WIRING_PULSE_ 21 | 22 | __BEGIN_DECLS 23 | 24 | /* 25 | * \brief Measures the length (in microseconds) of a pulse on the pin; state is HIGH 26 | * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds 27 | * to 3 minutes in length, but must be called at least a few dozen microseconds 28 | * before the start of the pulse. 29 | */ 30 | extern uint32_t pulseIn(uint32_t ulPin, bool ulState, uint32_t ulTimeout = 1000000L); 31 | extern uint32_t pulseRead(void); 32 | extern void pulseListen(uint32_t pin1, uint32_t pin2, bool state); 33 | extern uint32_t timerTicks2us(uint32_t t); 34 | 35 | __END_DECLS 36 | 37 | #endif /* _WIRING_PULSE_ */ 38 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/wiring_shift.c: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_shift.c - shiftOut() function 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | 22 | $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ 23 | */ 24 | 25 | #include "wiring_private.h" 26 | 27 | uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) { 28 | uint32_t value = 0; 29 | uint8_t i; 30 | 31 | for (i = 0; i < 8; ++i) { 32 | digitalWrite(clockPin, HIGH); 33 | if (bitOrder == LSBFIRST) 34 | value |= digitalRead(dataPin) << i; 35 | else 36 | value |= digitalRead(dataPin) << (7 - i); 37 | digitalWrite(clockPin, LOW); 38 | } 39 | return value; 40 | } 41 | 42 | void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) 43 | { 44 | uint8_t i; 45 | 46 | for (i = 0; i < 8; i++) { 47 | if (bitOrder == LSBFIRST) 48 | digitalWrite(dataPin, !!(val & (1 << i))); 49 | else 50 | digitalWrite(dataPin, !!(val & (1 << (7 - i)))); 51 | 52 | digitalWrite(clockPin, HIGH); 53 | digitalWrite(clockPin, LOW); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/cores/f32c/wiring_shift.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_SHIFT_ 20 | #define _WIRING_SHIFT_ 21 | 22 | __BEGIN_DECLS 23 | /* 24 | * \brief 25 | */ 26 | extern uint8_t shiftIn( uint8_t ulDataPin, uint8_t ulClockPin, uint8_t ulBitOrder ) ; 27 | 28 | 29 | /* 30 | * \brief 31 | */ 32 | extern void shiftOut( uint8_t ulDataPin, uint8_t ulClockPin, uint8_t ulBitOrder, uint8_t ulVal ) ; 33 | 34 | __END_DECLS 35 | 36 | #endif /* _WIRING_SHIFT_ */ 37 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/programmers.txt: -------------------------------------------------------------------------------- 1 | ujprog.name=ujprog (FPGArduino) 2 | ujprog.communication=usb 3 | ujprog.protocol=ujprog 4 | ujprog.program.protocol=ujprog 5 | ujprog.program.tool=ujprog 6 | ujprog.program.extra_params= 7 | ujprog.bootloader.tool=ujprog 8 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/dev/spi.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | #ifndef _SPI_H_ 29 | #define _SPI_H_ 30 | 31 | #include 32 | 33 | #define SPI_PORT_FLASH 0 34 | #define SPI_PORT_SDCARD 4 35 | 36 | int spi_byte(int, int); 37 | void spi_block_in(int, void *, int); 38 | void spi_start_transaction(int); 39 | 40 | #endif /* !_SPI_H_ */ 41 | 42 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/dev/sprite.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | void spr_flush(void); 29 | int spr_free(int); 30 | int spr_grab(int, int, int, int, int); 31 | int spr_trans(int, int); 32 | int spr_size(int, int *, int *); 33 | int spr_put(int, int, int); 34 | int spr_load(int, const char *, int); 35 | int jpg_load(const char *, int); 36 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/fatfs/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _INTEGER 6 | #define _INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | #include 12 | 13 | #else /* Embedded platform */ 14 | 15 | /* These types must be 16-bit, 32-bit or larger integer */ 16 | typedef int INT; 17 | typedef unsigned int UINT; 18 | 19 | /* These types must be 8-bit integer */ 20 | typedef char CHAR; 21 | typedef unsigned char UCHAR; 22 | typedef unsigned char BYTE; 23 | 24 | /* These types must be 16-bit integer */ 25 | typedef short SHORT; 26 | typedef unsigned short USHORT; 27 | typedef unsigned short WORD; 28 | typedef unsigned short WCHAR; 29 | 30 | /* These types must be 32-bit integer */ 31 | typedef long LONG; 32 | typedef unsigned long ULONG; 33 | typedef unsigned long DWORD; 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/stdarg.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | #ifndef _STDARG_H_ 29 | #define _STDARG_H_ 30 | 31 | /* va_arg stuff */ 32 | typedef __builtin_va_list __va_list; 33 | typedef __va_list va_list; 34 | #define va_start(ap, last) __builtin_va_start((ap), (last)) 35 | #define va_arg(ap, type) __builtin_va_arg((ap), type) 36 | #define va_copy(dest, src) __builtin_va_copy((dest), (src)) 37 | #define va_end(ap) __builtin_va_end(ap) 38 | 39 | #endif /* !_STDARG_H_ */ 40 | 41 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/strings.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | #ifndef _STRINGS_H_ 29 | #define _STRINGS_H_ 30 | 31 | int strcasecmp(const char *, const char *) __pure; 32 | int strncasecmp(const char *, const char *, size_t) __pure; 33 | 34 | #endif /* _STRINGS_H_ */ 35 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/sys/_null.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003 Marcel Moolenaar 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | * $FreeBSD: f32c/src/include/sys/_null.h 907 2012-02-14 21:18:19Z marko $ 27 | */ 28 | 29 | #ifndef NULL 30 | 31 | #if !defined(__cplusplus) 32 | #define NULL ((void *)0) 33 | #else 34 | #if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 35 | #define NULL __null 36 | #else 37 | #if defined(__LP64__) 38 | #define NULL (0L) 39 | #else 40 | #define NULL 0 41 | #endif /* __LP64__ */ 42 | #endif /* __GNUG__ */ 43 | #endif /* !__cplusplus */ 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/sys/endian.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/sys/isr.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | #ifndef _SYS_ISR_H_ 29 | #define _SYS_ISR_H_ 30 | 31 | #include 32 | 33 | typedef int isr_handler_fn(void); 34 | 35 | struct isr_link { 36 | SLIST_ENTRY(isr_link) isr_le; 37 | isr_handler_fn *handler_fn; 38 | }; 39 | 40 | 41 | void isr_register_handler(int, struct isr_link *); 42 | void isr_remove_handler(int, struct isr_link *); 43 | void enable_irq(int); 44 | void disable_irq(int); 45 | 46 | #endif /* !_SYS_ISR_H_ */ 47 | 48 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/include/sys/null.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003 Marcel Moolenaar 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | * $FreeBSD: f32c/src/include/sys/null.h 907 2012-02-14 21:18:19Z marko $ 27 | */ 28 | 29 | #ifndef NULL 30 | 31 | #if !defined(__cplusplus) 32 | #define NULL ((void *)0) 33 | #else 34 | #if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 35 | #define NULL __null 36 | #else 37 | #if defined(__LP64__) 38 | #define NULL (0L) 39 | #else 40 | #define NULL 0 41 | #endif /* __LP64__ */ 42 | #endif /* __GNUG__ */ 43 | #endif /* !__cplusplus */ 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/mips/lib/libc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/hardware/fpga/f32c/system/mips/lib/libc.a -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/mips/lib/libcrt0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/hardware/fpga/f32c/system/mips/lib/libcrt0.a -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/mips/lib/libm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/hardware/fpga/f32c/system/mips/lib/libm.a -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/mips/lib/libulx2s.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/hardware/fpga/f32c/system/mips/lib/libulx2s.a -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/riscv/lib/libc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/hardware/fpga/f32c/system/riscv/lib/libc.a -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/riscv/lib/libcrt0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/hardware/fpga/f32c/system/riscv/lib/libcrt0.a -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/riscv/lib/libm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/hardware/fpga/f32c/system/riscv/lib/libm.a -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/riscv/lib/libulx2s.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/hardware/fpga/f32c/system/riscv/lib/libulx2s.a -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/atoi.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | __attribute__((optimize("-Os"))) int 29 | atoi(const char *c) 30 | { 31 | int i = 0; 32 | int sign = 1; 33 | 34 | if (*c == '-') { 35 | sign = -1; 36 | c++; 37 | } 38 | for (; *c != '\0'; c++) { 39 | if (*c >= '0' && *c <= '9') 40 | i = i * 10 + (*c - '0'); 41 | else 42 | break; 43 | } 44 | 45 | return (sign * i); 46 | } 47 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/CREDITS.TXT: -------------------------------------------------------------------------------- 1 | This file is a partial list of people who have contributed to the LLVM/CompilerRT 2 | project. If you have contributed a patch or made some other contribution to 3 | LLVM/CompilerRT, please submit a patch to this file to add yourself, and it will be 4 | done! 5 | 6 | The list is sorted by surname and formatted to allow easy grepping and 7 | beautification by scripts. The fields are: name (N), email (E), web-address 8 | (W), PGP key ID and fingerprint (P), description (D), and snail-mail address 9 | (S). 10 | 11 | N: Craig van Vliet 12 | E: cvanvliet@auroraux.org 13 | W: http://www.auroraux.org 14 | D: Code style and Readability fixes. 15 | 16 | N: Edward O'Callaghan 17 | E: eocallaghan@auroraux.org 18 | W: http://www.auroraux.org 19 | D: CMake'ify Compiler-RT build system 20 | D: Maintain Solaris & AuroraUX ports of Compiler-RT 21 | 22 | N: Howard Hinnant 23 | E: hhinnant@apple.com 24 | D: Architect and primary author of compiler-rt 25 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2009-2012 by the contributors listed in CREDITS.TXT 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/ashldi3.c: -------------------------------------------------------------------------------- 1 | /* ====-- ashldi3.c - Implement __ashldi3 -----------------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | * 10 | * This file implements __ashldi3 for the compiler_rt library. 11 | * 12 | * ===----------------------------------------------------------------------=== 13 | */ 14 | 15 | #include "int_lib.h" 16 | 17 | /* Returns: a << b */ 18 | 19 | /* Precondition: 0 <= b < bits_in_dword */ 20 | 21 | ARM_EABI_FNALIAS(llsl, ashldi3); 22 | 23 | COMPILER_RT_ABI di_int 24 | __ashldi3(di_int a, si_int b) 25 | { 26 | const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); 27 | dwords input; 28 | dwords result; 29 | input.all = a; 30 | if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ 31 | { 32 | result.s.low = 0; 33 | result.s.high = input.s.low << (b - bits_in_word); 34 | } 35 | else /* 0 <= b < bits_in_word */ 36 | { 37 | if (b == 0) 38 | return a; 39 | result.s.low = input.s.low << b; 40 | result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b)); 41 | } 42 | return result.all; 43 | } 44 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/clzsi2.c: -------------------------------------------------------------------------------- 1 | /* ===-- clzsi2.c - Implement __clzsi2 -------------------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | * 10 | * This file implements __clzsi2 for the compiler_rt library. 11 | * 12 | * ===----------------------------------------------------------------------=== 13 | */ 14 | 15 | #include "int_lib.h" 16 | 17 | /* Returns: the number of leading 0-bits */ 18 | 19 | /* Precondition: a != 0 */ 20 | 21 | COMPILER_RT_ABI si_int 22 | __clzsi2(si_int a) 23 | { 24 | su_int x = (su_int)a; 25 | si_int t = ((x & 0xFFFF0000) == 0) << 4; /* if (x is small) t = 16 else 0 */ 26 | x >>= 16 - t; /* x = [0 - 0xFFFF] */ 27 | su_int r = t; /* r = [0, 16] */ 28 | /* return r + clz(x) */ 29 | t = ((x & 0xFF00) == 0) << 3; 30 | x >>= 8 - t; /* x = [0 - 0xFF] */ 31 | r += t; /* r = [0, 8, 16, 24] */ 32 | /* return r + clz(x) */ 33 | t = ((x & 0xF0) == 0) << 2; 34 | x >>= 4 - t; /* x = [0 - 0xF] */ 35 | r += t; /* r = [0, 4, 8, 12, 16, 20, 24, 28] */ 36 | /* return r + clz(x) */ 37 | t = ((x & 0xC) == 0) << 1; 38 | x >>= 2 - t; /* x = [0 - 3] */ 39 | r += t; /* r = [0 - 30] and is even */ 40 | /* return r + clz(x) */ 41 | /* switch (x) 42 | * { 43 | * case 0: 44 | * return r + 2; 45 | * case 1: 46 | * return r + 1; 47 | * case 2: 48 | * case 3: 49 | * return r; 50 | * } 51 | */ 52 | return r + ((2 - x) & -((x & 2) == 0)); 53 | } 54 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/fixunsdfdi.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | * 10 | * This file implements __fixunsdfdi for the compiler_rt library. 11 | * 12 | * ===----------------------------------------------------------------------=== 13 | */ 14 | 15 | #include "int_lib.h" 16 | 17 | /* Returns: convert a to a unsigned long long, rounding toward zero. 18 | * Negative values all become zero. 19 | */ 20 | 21 | /* Assumption: double is a IEEE 64 bit floating point type 22 | * du_int is a 64 bit integral type 23 | * value in double is representable in du_int or is negative 24 | * (no range checking performed) 25 | */ 26 | 27 | /* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ 28 | 29 | ARM_EABI_FNALIAS(d2ulz, fixunsdfdi); 30 | 31 | COMPILER_RT_ABI du_int 32 | __fixunsdfdi(double a) 33 | { 34 | double_bits fb; 35 | fb.f = a; 36 | int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023; 37 | if (e < 0 || (fb.u.s.high & 0x80000000)) 38 | return 0; 39 | udwords r; 40 | r.s.high = (fb.u.s.high & 0x000FFFFF) | 0x00100000; 41 | r.s.low = fb.u.s.low; 42 | if (e > 52) 43 | r.all <<= (e - 52); 44 | else 45 | r.all >>= (52 - e); 46 | return r.all; 47 | } 48 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/fixunsdfsi.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixunsdfsi.c - Implement __fixunsdfsi -----------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | * 10 | * This file implements __fixunsdfsi for the compiler_rt library. 11 | * 12 | * ===----------------------------------------------------------------------=== 13 | */ 14 | 15 | #include "int_lib.h" 16 | 17 | /* Returns: convert a to a unsigned int, rounding toward zero. 18 | * Negative values all become zero. 19 | */ 20 | 21 | /* Assumption: double is a IEEE 64 bit floating point type 22 | * su_int is a 32 bit integral type 23 | * value in double is representable in su_int or is negative 24 | * (no range checking performed) 25 | */ 26 | 27 | /* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ 28 | 29 | ARM_EABI_FNALIAS(d2uiz, fixunsdfsi); 30 | 31 | COMPILER_RT_ABI su_int 32 | __fixunsdfsi(double a) 33 | { 34 | double_bits fb; 35 | fb.f = a; 36 | int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023; 37 | if (e < 0 || (fb.u.s.high & 0x80000000)) 38 | return 0; 39 | return ( 40 | 0x80000000u | 41 | ((fb.u.s.high & 0x000FFFFF) << 11) | 42 | (fb.u.s.low >> 21) 43 | ) >> (31 - e); 44 | } 45 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/fixunssfsi.c: -------------------------------------------------------------------------------- 1 | /* ===-- fixunssfsi.c - Implement __fixunssfsi -----------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | * 10 | * This file implements __fixunssfsi for the compiler_rt library. 11 | * 12 | * ===----------------------------------------------------------------------=== 13 | */ 14 | 15 | #include "int_lib.h" 16 | 17 | /* Returns: convert a to a unsigned int, rounding toward zero. 18 | * Negative values all become zero. 19 | */ 20 | 21 | /* Assumption: float is a IEEE 32 bit floating point type 22 | * su_int is a 32 bit integral type 23 | * value in float is representable in su_int or is negative 24 | * (no range checking performed) 25 | */ 26 | 27 | /* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */ 28 | 29 | ARM_EABI_FNALIAS(f2uiz, fixunssfsi); 30 | 31 | COMPILER_RT_ABI su_int 32 | __fixunssfsi(float a) 33 | { 34 | float_bits fb; 35 | fb.f = a; 36 | int e = ((fb.u & 0x7F800000) >> 23) - 127; 37 | if (e < 0 || (fb.u & 0x80000000)) 38 | return 0; 39 | su_int r = (fb.u & 0x007FFFFF) | 0x00800000; 40 | if (e > 23) 41 | r <<= (e - 23); 42 | else 43 | r >>= (23 - e); 44 | return r; 45 | } 46 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/floatsidf.c: -------------------------------------------------------------------------------- 1 | //===-- lib/floatsidf.c - integer -> double-precision conversion --*- C -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements integer to double-precision conversion for the 11 | // compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even 12 | // mode. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #define DOUBLE_PRECISION 17 | #include "fp_lib.h" 18 | 19 | #include "int_lib.h" 20 | 21 | ARM_EABI_FNALIAS(i2d, floatsidf); 22 | 23 | fp_t __floatsidf(int a) { 24 | 25 | const int aWidth = sizeof a * CHAR_BIT; 26 | 27 | // Handle zero as a special case to protect clz 28 | if (a == 0) 29 | return fromRep(0); 30 | 31 | // All other cases begin by extracting the sign and absolute value of a 32 | rep_t sign = 0; 33 | if (a < 0) { 34 | sign = signBit; 35 | a = -a; 36 | } 37 | 38 | // Exponent of (fp_t)a is the width of abs(a). 39 | const int exponent = (aWidth - 1) - __builtin_clz(a); 40 | rep_t result; 41 | 42 | // Shift a into the significand field and clear the implicit bit. Extra 43 | // cast to unsigned int is necessary to get the correct behavior for 44 | // the input INT_MIN. 45 | const int shift = significandBits - exponent; 46 | result = (rep_t)(unsigned int)a << shift ^ implicitBit; 47 | 48 | // Insert the exponent 49 | result += (rep_t)(exponent + exponentBias) << significandBits; 50 | // Insert the sign bit and return 51 | return fromRep(result | sign); 52 | } 53 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/floatunsidf.c: -------------------------------------------------------------------------------- 1 | //===-- lib/floatunsidf.c - uint -> double-precision conversion ---*- C -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements unsigned integer to double-precision conversion for the 11 | // compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even 12 | // mode. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #define DOUBLE_PRECISION 17 | #include "fp_lib.h" 18 | 19 | #include "int_lib.h" 20 | 21 | ARM_EABI_FNALIAS(ui2d, floatunsidf); 22 | 23 | fp_t __floatunsidf(unsigned int a) { 24 | 25 | const int aWidth = sizeof a * CHAR_BIT; 26 | 27 | // Handle zero as a special case to protect clz 28 | if (a == 0) return fromRep(0); 29 | 30 | // Exponent of (fp_t)a is the width of abs(a). 31 | const int exponent = (aWidth - 1) - __builtin_clz(a); 32 | rep_t result; 33 | 34 | // Shift a into the significand field and clear the implicit bit. 35 | const int shift = significandBits - exponent; 36 | result = (rep_t)a << shift ^ implicitBit; 37 | 38 | // Insert the exponent 39 | result += (rep_t)(exponent + exponentBias) << significandBits; 40 | return fromRep(result); 41 | } 42 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/floatunsisf.c: -------------------------------------------------------------------------------- 1 | //===-- lib/floatunsisf.c - uint -> single-precision conversion ---*- C -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements unsigned integer to single-precision conversion for the 11 | // compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even 12 | // mode. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #define SINGLE_PRECISION 17 | #include "fp_lib.h" 18 | 19 | #include "int_lib.h" 20 | 21 | ARM_EABI_FNALIAS(ui2f, floatunsisf); 22 | 23 | fp_t __floatunsisf(unsigned int a) { 24 | 25 | const int aWidth = sizeof a * CHAR_BIT; 26 | 27 | // Handle zero as a special case to protect clz 28 | if (a == 0) return fromRep(0); 29 | 30 | // Exponent of (fp_t)a is the width of abs(a). 31 | const int exponent = (aWidth - 1) - __builtin_clz(a); 32 | rep_t result; 33 | 34 | // Shift a into the significand field, rounding if it is a right-shift 35 | if (exponent <= significandBits) { 36 | const int shift = significandBits - exponent; 37 | result = (rep_t)a << shift ^ implicitBit; 38 | } else { 39 | const int shift = exponent - significandBits; 40 | result = (rep_t)a >> shift ^ implicitBit; 41 | rep_t round = (rep_t)a << (typeWidth - shift); 42 | if (round > signBit) result++; 43 | if (round == signBit) result += result & 1; 44 | } 45 | 46 | // Insert the exponent 47 | result += (rep_t)(exponent + exponentBias) << significandBits; 48 | return fromRep(result); 49 | } 50 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/int_util.h: -------------------------------------------------------------------------------- 1 | /* ===-- int_util.h - internal utility functions ----------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===-----------------------------------------------------------------------=== 9 | * 10 | * This file is not part of the interface of this library. 11 | * 12 | * This file defines non-inline utilities which are available for use in the 13 | * library. The function definitions themselves are all contained in int_util.c 14 | * which will always be compiled into any compiler-rt library. 15 | * 16 | * ===-----------------------------------------------------------------------=== 17 | */ 18 | 19 | #ifndef INT_UTIL_H 20 | #define INT_UTIL_H 21 | 22 | /** \brief Trigger a program abort (or panic for kernel code). */ 23 | #define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, \ 24 | __FUNCTION__) 25 | void compilerrt_abort_impl(const char *file, int line, 26 | const char *function) 27 | #ifndef KERNEL_USE 28 | __attribute__((weak)) 29 | #endif 30 | __attribute__((noreturn)) __attribute__((visibility("hidden"))); 31 | 32 | #endif /* INT_UTIL_H */ 33 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/lshrdi3.c: -------------------------------------------------------------------------------- 1 | /* ===-- lshrdi3.c - Implement __lshrdi3 -----------------------------------=== 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is dual licensed under the MIT and the University of Illinois Open 6 | * Source Licenses. See LICENSE.TXT for details. 7 | * 8 | * ===----------------------------------------------------------------------=== 9 | * 10 | * This file implements __lshrdi3 for the compiler_rt library. 11 | * 12 | * ===----------------------------------------------------------------------=== 13 | */ 14 | 15 | #include "int_lib.h" 16 | 17 | /* Returns: logical a >> b */ 18 | 19 | /* Precondition: 0 <= b < bits_in_dword */ 20 | 21 | ARM_EABI_FNALIAS(llsr, lshrdi3); 22 | 23 | COMPILER_RT_ABI di_int 24 | __lshrdi3(di_int a, si_int b) 25 | { 26 | const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); 27 | udwords input; 28 | udwords result; 29 | input.all = a; 30 | if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ 31 | { 32 | result.s.high = 0; 33 | result.s.low = input.s.high >> (b - bits_in_word); 34 | } 35 | else /* 0 <= b < bits_in_word */ 36 | { 37 | if (b == 0) 38 | return a; 39 | result.s.high = input.s.high >> b; 40 | result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b); 41 | } 42 | return result.all; 43 | } 44 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/negdf2.c: -------------------------------------------------------------------------------- 1 | //===-- lib/negdf2.c - double-precision negation ------------------*- C -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements double-precision soft-float negation. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #define DOUBLE_PRECISION 15 | #include "fp_lib.h" 16 | 17 | ARM_EABI_FNALIAS(dneg, negdf2); 18 | 19 | fp_t __negdf2(fp_t a) { 20 | return fromRep(toRep(a) ^ signBit); 21 | } 22 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/negsf2.c: -------------------------------------------------------------------------------- 1 | //===-- lib/negsf2.c - single-precision negation ------------------*- C -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements single-precision soft-float negation. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #define SINGLE_PRECISION 15 | #include "fp_lib.h" 16 | 17 | ARM_EABI_FNALIAS(fneg, negsf2); 18 | 19 | COMPILER_RT_ABI fp_t 20 | __negsf2(fp_t a) { 21 | return fromRep(toRep(a) ^ signBit); 22 | } 23 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/subdf3.c: -------------------------------------------------------------------------------- 1 | //===-- lib/adddf3.c - Double-precision subtraction ---------------*- C -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements double-precision soft-float subtraction with the 11 | // IEEE-754 default rounding (to nearest, ties to even). 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #define DOUBLE_PRECISION 16 | #include "fp_lib.h" 17 | 18 | fp_t COMPILER_RT_ABI __adddf3(fp_t a, fp_t b); 19 | 20 | 21 | ARM_EABI_FNALIAS(dsub, subdf3); 22 | 23 | // Subtraction; flip the sign bit of b and add. 24 | COMPILER_RT_ABI fp_t 25 | __subdf3(fp_t a, fp_t b) { 26 | return __adddf3(a, fromRep(toRep(b) ^ signBit)); 27 | } 28 | 29 | /* FIXME: rsub for ARM EABI */ 30 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/float/subsf3.c: -------------------------------------------------------------------------------- 1 | //===-- lib/subsf3.c - Single-precision subtraction ---------------*- C -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements single-precision soft-float subtraction with the 11 | // IEEE-754 default rounding (to nearest, ties to even). 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #define SINGLE_PRECISION 16 | #include "fp_lib.h" 17 | 18 | fp_t COMPILER_RT_ABI __addsf3(fp_t a, fp_t b); 19 | 20 | ARM_EABI_FNALIAS(fsub, subsf3); 21 | 22 | // Subtraction; flip the sign bit of b and add. 23 | COMPILER_RT_ABI fp_t 24 | __subsf3(fp_t a, fp_t b) { 25 | return __addsf3(a, fromRep(toRep(b) ^ signBit)); 26 | } 27 | 28 | /* FIXME: rsub for ARM EABI */ 29 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/acoshf.c: -------------------------------------------------------------------------------- 1 | /* e_acoshf.c -- float version of e_acosh.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include 17 | __FBSDID("$FreeBSD: head/lib/msun/src/e_acoshf.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | #include "math.h" 20 | #include "math_private.h" 21 | 22 | static const float 23 | one = 1.0, 24 | ln2 = 6.9314718246e-01; /* 0x3f317218 */ 25 | 26 | float 27 | acoshf(float x) 28 | { 29 | float t; 30 | int32_t hx; 31 | GET_FLOAT_WORD(hx,x); 32 | if(hx<0x3f800000) { /* x < 1 */ 33 | return (x-x)/(x-x); 34 | } else if(hx >=0x4d800000) { /* x > 2**28 */ 35 | if(hx >=0x7f800000) { /* x is inf of NaN */ 36 | return x+x; 37 | } else 38 | return logf(x)+ln2; /* acosh(huge)=log(2x) */ 39 | } else if (hx==0x3f800000) { 40 | return 0.0; /* acosh(1) = 0 */ 41 | } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ 42 | t=x*x; 43 | return logf((float)2.0*x-one/(x+sqrtf(t-one))); 44 | } else { /* 1 17 | __FBSDID("$FreeBSD: head/lib/msun/src/s_asinhf.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | #include "math.h" 20 | #include "math_private.h" 21 | 22 | static const float 23 | one = 1.0000000000e+00, /* 0x3F800000 */ 24 | ln2 = 6.9314718246e-01, /* 0x3f317218 */ 25 | huge= 1.0000000000e+30; 26 | 27 | float 28 | asinhf(float x) 29 | { 30 | float t,w; 31 | int32_t hx,ix; 32 | GET_FLOAT_WORD(hx,x); 33 | ix = hx&0x7fffffff; 34 | if(ix>=0x7f800000) return x+x; /* x is inf or NaN */ 35 | if(ix< 0x31800000) { /* |x|<2**-28 */ 36 | if(huge+x>one) return x; /* return x inexact except 0 */ 37 | } 38 | if(ix>0x4d800000) { /* |x| > 2**28 */ 39 | w = logf(fabsf(x))+ln2; 40 | } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ 41 | t = fabsf(x); 42 | w = logf((float)2.0*t+one/(sqrtf(x*x+one)+t)); 43 | } else { /* 2.0 > |x| > 2**-28 */ 44 | t = x*x; 45 | w =log1pf(fabsf(x)+t/(one+sqrtf(one+t))); 46 | } 47 | if(hx>0) return w; else return -w; 48 | } 49 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/atanhf.c: -------------------------------------------------------------------------------- 1 | /* e_atanhf.c -- float version of e_atanh.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include 17 | __FBSDID("$FreeBSD: head/lib/msun/src/e_atanhf.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | #include "math.h" 20 | #include "math_private.h" 21 | 22 | static const float one = 1.0, huge = 1e30; 23 | 24 | static const float zero = 0.0; 25 | 26 | float 27 | atanhf(float x) 28 | { 29 | float t; 30 | int32_t hx,ix; 31 | GET_FLOAT_WORD(hx,x); 32 | ix = hx&0x7fffffff; 33 | if (ix>0x3f800000) /* |x|>1 */ 34 | return (x-x)/(x-x); 35 | if(ix==0x3f800000) 36 | return x/zero; 37 | if(ix<0x31800000&&(huge+x)>zero) return x; /* x<2**-28 */ 38 | SET_FLOAT_WORD(x,ix); 39 | if(ix<0x3f000000) { /* x < 0.5 */ 40 | t = x+x; 41 | t = (float)0.5*log1pf(t+t*x/(one-x)); 42 | } else 43 | t = (float)0.5*log1pf((x+x)/(one-x)); 44 | if(hx>=0) return t; else return -t; 45 | } 46 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/ceilf.c: -------------------------------------------------------------------------------- 1 | /* s_ceilf.c -- float version of s_ceil.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include 17 | __FBSDID("$FreeBSD: head/lib/msun/src/s_ceilf.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | #include "math.h" 20 | #include "math_private.h" 21 | 22 | static const float huge = 1.0e30; 23 | 24 | float 25 | ceilf(float x) 26 | { 27 | int32_t i0,j0; 28 | u_int32_t i; 29 | 30 | GET_FLOAT_WORD(i0,x); 31 | j0 = ((i0>>23)&0xff)-0x7f; 32 | if(j0<23) { 33 | if(j0<0) { /* raise inexact if x != 0 */ 34 | if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ 35 | if(i0<0) {i0=0x80000000;} 36 | else if(i0!=0) { i0=0x3f800000;} 37 | } 38 | } else { 39 | i = (0x007fffff)>>j0; 40 | if((i0&i)==0) return x; /* x is integral */ 41 | if(huge+x>(float)0.0) { /* raise inexact flag */ 42 | if(i0>0) i0 += (0x00800000)>>j0; 43 | i0 &= (~i); 44 | } 45 | } 46 | } else { 47 | if(j0==0x80) return x+x; /* inf or NaN */ 48 | else return x; /* x is integral */ 49 | } 50 | SET_FLOAT_WORD(x,i0); 51 | return x; 52 | } 53 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/copysignf.c: -------------------------------------------------------------------------------- 1 | /* s_copysignf.c -- float version of s_copysign.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include 17 | __FBSDID("$FreeBSD: stable/10/lib/msun/src/s_copysignf.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | /* 20 | * copysignf(float x, float y) 21 | * copysignf(x,y) returns a value with the magnitude of x and 22 | * with the sign bit of y. 23 | */ 24 | 25 | #include "math.h" 26 | #include "math_private.h" 27 | 28 | float 29 | copysignf(float x, float y) 30 | { 31 | u_int32_t ix,iy; 32 | GET_FLOAT_WORD(ix,x); 33 | GET_FLOAT_WORD(iy,y); 34 | SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000)); 35 | return x; 36 | } 37 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/cos.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_cos.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009-2011 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | double cos(double x) 39 | { 40 | return sin(x + M_PI_2); 41 | } 42 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/cosf.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_cosf.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009-2011 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | float cosf(float x) 39 | { 40 | return sinf(x + M_PI_2); 41 | } 42 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/cosh.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_cosh.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009-2011 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | double cosh(double x) 39 | { 40 | x = exp(x); 41 | return ((x + (1.0 / x)) / 2.0); 42 | } 43 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/coshf.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_coshf.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009-2011 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | float coshf(float x) 39 | { 40 | x = expf(x); 41 | return ((x + (1.0 / x)) / 2.0); 42 | } 43 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/fabs.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_fabs.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | 14 | /* 15 | * fabs(x) returns the absolute value of x. 16 | */ 17 | 18 | #include "math.h" 19 | #include "math_private.h" 20 | 21 | double 22 | fabs(double x) 23 | { 24 | u_int32_t high; 25 | GET_HIGH_WORD(high,x); 26 | SET_HIGH_WORD(x,high&0x7fffffff); 27 | return x; 28 | } 29 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/fabsf.c: -------------------------------------------------------------------------------- 1 | /* s_fabsf.c -- float version of s_fabs.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include 17 | __FBSDID("$FreeBSD: head/lib/msun/src/s_fabsf.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | /* 20 | * fabsf(x) returns the absolute value of x. 21 | */ 22 | 23 | #include "math.h" 24 | #include "math_private.h" 25 | 26 | float 27 | fabsf(float x) 28 | { 29 | u_int32_t ix; 30 | GET_FLOAT_WORD(ix,x); 31 | SET_FLOAT_WORD(x,ix&0x7fffffff); 32 | return x; 33 | } 34 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/floorf.c: -------------------------------------------------------------------------------- 1 | /* s_floorf.c -- float version of s_floor.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include 17 | __FBSDID("$FreeBSD: head/lib/msun/src/s_floorf.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | /* 20 | * floorf(x) 21 | * Return x rounded toward -inf to integral value 22 | * Method: 23 | * Bit twiddling. 24 | * Exception: 25 | * Inexact flag raised if x not equal to floorf(x). 26 | */ 27 | 28 | #include "math.h" 29 | #include "math_private.h" 30 | 31 | static const float huge = 1.0e30; 32 | 33 | float 34 | floorf(float x) 35 | { 36 | int32_t i0,j0; 37 | u_int32_t i; 38 | GET_FLOAT_WORD(i0,x); 39 | j0 = ((i0>>23)&0xff)-0x7f; 40 | if(j0<23) { 41 | if(j0<0) { /* raise inexact if x != 0 */ 42 | if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ 43 | if(i0>=0) {i0=0;} 44 | else if((i0&0x7fffffff)!=0) 45 | { i0=0xbf800000;} 46 | } 47 | } else { 48 | i = (0x007fffff)>>j0; 49 | if((i0&i)==0) return x; /* x is integral */ 50 | if(huge+x>(float)0.0) { /* raise inexact flag */ 51 | if(i0<0) i0 += (0x00800000)>>j0; 52 | i0 &= (~i); 53 | } 54 | } 55 | } else { 56 | if(j0==0x80) return x+x; /* inf or NaN */ 57 | else return x; /* x is integral */ 58 | } 59 | SET_FLOAT_WORD(x,i0); 60 | return x; 61 | } 62 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/frexp.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_frexp.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #include 14 | __FBSDID("$FreeBSD: head/lib/msun/src/s_frexp.c 176451 2008-02-22 02:30:36Z das $"); 15 | 16 | /* 17 | * for non-zero x 18 | * x = frexp(arg,&exp); 19 | * return a double fp quantity x such that 0.5 <= |x| <1.0 20 | * and the corresponding binary exponent "exp". That is 21 | * arg = x*2^exp. 22 | * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg 23 | * with *exp=0. 24 | */ 25 | 26 | #include 27 | 28 | #include "math.h" 29 | #include "math_private.h" 30 | 31 | static const double 32 | two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ 33 | 34 | double 35 | frexp(double x, int *eptr) 36 | { 37 | int32_t hx, ix, lx; 38 | EXTRACT_WORDS(hx,lx,x); 39 | ix = 0x7fffffff&hx; 40 | *eptr = 0; 41 | if(ix>=0x7ff00000||((ix|lx)==0)) return x; /* 0,inf,nan */ 42 | if (ix<0x00100000) { /* subnormal */ 43 | x *= two54; 44 | GET_HIGH_WORD(hx,x); 45 | ix = hx&0x7fffffff; 46 | *eptr = -54; 47 | } 48 | *eptr += (ix>>20)-1022; 49 | hx = (hx&0x800fffff)|0x3fe00000; 50 | SET_HIGH_WORD(x,hx); 51 | return x; 52 | } 53 | 54 | #if (LDBL_MANT_DIG == 53) 55 | __weak_reference(frexp, frexpl); 56 | #endif 57 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/frexpf.c: -------------------------------------------------------------------------------- 1 | /* s_frexpf.c -- float version of s_frexp.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include 17 | __FBSDID("$FreeBSD: head/lib/msun/src/s_frexpf.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | #include "math.h" 20 | #include "math_private.h" 21 | 22 | static const float 23 | two25 = 3.3554432000e+07; /* 0x4c000000 */ 24 | 25 | float 26 | frexpf(float x, int *eptr) 27 | { 28 | int32_t hx,ix; 29 | GET_FLOAT_WORD(hx,x); 30 | ix = 0x7fffffff&hx; 31 | *eptr = 0; 32 | if(ix>=0x7f800000||(ix==0)) return x; /* 0,inf,nan */ 33 | if (ix<0x00800000) { /* subnormal */ 34 | x *= two25; 35 | GET_FLOAT_WORD(hx,x); 36 | ix = hx&0x7fffffff; 37 | *eptr = -25; 38 | } 39 | *eptr += (ix>>23)-126; 40 | hx = (hx&0x807fffff)|0x3f000000; 41 | SET_FLOAT_WORD(x,hx); 42 | return x; 43 | } 44 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/k_logf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | */ 11 | 12 | #include 13 | __FBSDID("$FreeBSD: head/lib/msun/src/k_logf.h 226376 2011-10-15 05:23:28Z das $"); 14 | 15 | /* 16 | * Float version of k_log.h. See the latter for most comments. 17 | */ 18 | 19 | static const float 20 | /* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */ 21 | Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */ 22 | Lg2 = 0xccce13.0p-25, /* 0.40000972152 */ 23 | Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */ 24 | Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */ 25 | 26 | static inline float 27 | k_log1pf(float f) 28 | { 29 | float hfsq,s,z,R,w,t1,t2; 30 | 31 | s = f/((float)2.0+f); 32 | z = s*s; 33 | w = z*z; 34 | t1= w*(Lg2+w*Lg4); 35 | t2= z*(Lg1+w*Lg3); 36 | R = t2+t1; 37 | hfsq=(float)0.5*f*f; 38 | return s*(hfsq+R); 39 | } 40 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/modff.c: -------------------------------------------------------------------------------- 1 | /* s_modff.c -- float version of s_modf.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | 5 | /* 6 | * ==================================================== 7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 | * 9 | * Developed at SunPro, a Sun Microsystems, Inc. business. 10 | * Permission to use, copy, modify, and distribute this 11 | * software is freely granted, provided that this notice 12 | * is preserved. 13 | * ==================================================== 14 | */ 15 | 16 | #include 17 | __FBSDID("$FreeBSD: head/lib/msun/src/s_modff.c 176451 2008-02-22 02:30:36Z das $"); 18 | 19 | #include "math.h" 20 | #include "math_private.h" 21 | 22 | static const float one = 1.0; 23 | 24 | float 25 | modff(float x, float *iptr) 26 | { 27 | int32_t i0,j0; 28 | u_int32_t i; 29 | GET_FLOAT_WORD(i0,x); 30 | j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ 31 | if(j0<23) { /* integer part in x */ 32 | if(j0<0) { /* |x|<1 */ 33 | SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ 34 | return x; 35 | } else { 36 | i = (0x007fffff)>>j0; 37 | if((i0&i)==0) { /* x is integral */ 38 | u_int32_t ix; 39 | *iptr = x; 40 | GET_FLOAT_WORD(ix,x); 41 | SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ 42 | return x; 43 | } else { 44 | SET_FLOAT_WORD(*iptr,i0&(~i)); 45 | return x - *iptr; 46 | } 47 | } 48 | } else { /* no fraction part */ 49 | u_int32_t ix; 50 | *iptr = x*one; 51 | if (x != x) /* NaN */ 52 | return x; 53 | GET_FLOAT_WORD(ix,x); 54 | SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ 55 | return x; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/scalbn.c: -------------------------------------------------------------------------------- 1 | #include "math_private.h" 2 | 3 | double scalbn(double x, int n) 4 | { 5 | double scale; 6 | 7 | if (n > 1023) { 8 | x *= 0x1p1023; 9 | n -= 1023; 10 | if (n > 1023) { 11 | x *= 0x1p1023; 12 | n -= 1023; 13 | if (n > 1023) { 14 | STRICT_ASSIGN(double, x, x * 0x1p1023); 15 | return x; 16 | } 17 | } 18 | } else if (n < -1022) { 19 | x *= 0x1p-1022; 20 | n += 1022; 21 | if (n < -1022) { 22 | x *= 0x1p-1022; 23 | n += 1022; 24 | if (n < -1022) { 25 | STRICT_ASSIGN(double, x, x * 0x1p-1022); 26 | return x; 27 | } 28 | } 29 | } 30 | INSERT_WORDS(scale, (uint32_t)(0x3ff+n)<<20, 0); 31 | STRICT_ASSIGN(double, x, x * scale); 32 | return x; 33 | } 34 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/sinh.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_sinh.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009, 2010 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | double sinh(double x) 39 | { 40 | x = exp(x); 41 | return ((x - (1.0 / x)) / 2.0); 42 | } 43 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/sinhf.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_sinhf.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009, 2010 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | float sinhf(float x) 39 | { 40 | x = expf(x); 41 | return ((x - (1.0 / x)) / 2.0); 42 | } 43 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/tan.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_tan.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009, 2010 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | double tan(double x) 39 | { 40 | return (sin(x) / cos(x)); 41 | } 42 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/tanf.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_tanf.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009, 2010 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | float tanf(float x) 39 | { 40 | return (sinf(x) / cosf(x)); 41 | } 42 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/tanh.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_tanh.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009, 2010 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | double tanh(double x) 39 | { 40 | double x0 = exp(x); 41 | double x1 = 1.0 / x0; 42 | 43 | return ((x0 - x1) / (x0 + x1)); 44 | } 45 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/math/tanhf.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * libc/math/lib_tanhf.c 3 | * 4 | * This file is a part of NuttX: 5 | * 6 | * Copyright (C) 2012 Gregory Nutt. All rights reserved. 7 | * Ported by: Darcy Gong 8 | * 9 | * It derives from the Rhombs OS math library by Nick Johnson which has 10 | * a compatibile, MIT-style license: 11 | * 12 | * Copyright (C) 2009, 2010 Nick Johnson 13 | * 14 | * Permission to use, copy, modify, and distribute this software for any 15 | * purpose with or without fee is hereby granted, provided that the above 16 | * copyright notice and this permission notice appear in all copies. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | * 26 | ************************************************************************/ 27 | 28 | /************************************************************************ 29 | * Included Files 30 | ************************************************************************/ 31 | 32 | #include 33 | 34 | /************************************************************************ 35 | * Public Functions 36 | ************************************************************************/ 37 | 38 | float tanhf(float x) 39 | { 40 | float x0 = expf(x); 41 | float x1 = 1.0 / x0; 42 | 43 | return ((x0 + x1) / (x0 - x1)); 44 | } 45 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/memcpy.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | __attribute__((optimize("-Os"))) void * 29 | memcpy(int *dst, const int *src, unsigned int len) 30 | { 31 | char *from = (char *) src; 32 | char *to = (char *) dst; 33 | 34 | for (; len != 0; len--) 35 | *to++ = *from++; 36 | 37 | return (dst); 38 | } 39 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/memset.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | __attribute__((optimize("-Os"))) void * 29 | memset(char *b, int c, unsigned int len) 30 | { 31 | 32 | for (; len != 0; len--) 33 | *b++ = c; 34 | 35 | return (b); 36 | } 37 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/mul.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Marko Zec, University of Zagreb 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | * 25 | * $Id$ 26 | */ 27 | 28 | 29 | uint32_t 30 | __mulsi3(uint32_t a, uint32_t b) 31 | { 32 | uint32_t res; 33 | 34 | for (res = 0; b != 0; b >>= 1, a <<= 1) 35 | if (b & 1) 36 | res += a; 37 | return (res); 38 | } 39 | 40 | 41 | uint64_t 42 | __muldi3(uint64_t a, uint64_t b) 43 | { 44 | uint64_t res; 45 | 46 | for (res = 0; b != 0; b >>= 1, a <<= 1) 47 | if (b & 1) 48 | res += a; 49 | return (res); 50 | } 51 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/system/src/random.c: -------------------------------------------------------------------------------- 1 | 2 | static int randseed; 3 | 4 | 5 | uint32_t 6 | random(void) 7 | { 8 | int x, t; 9 | uint32_t hi, lo; 10 | 11 | /* 12 | * Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1). 13 | * From "Random number generators: good ones are hard to find", 14 | * Park and Miller, Communications of the ACM, vol. 31, no. 10, 15 | * October 1988, p. 1195. 16 | */ 17 | /* Can't be initialized with 0, so use another value. */ 18 | if ((x = randseed) == 0) 19 | x = 123459876; 20 | hi = x / 127773; 21 | lo = x % 127773; 22 | t = 16807 * lo - 2836 * hi; 23 | if (t < 0) 24 | t += 0x7fffffff; 25 | randseed = t; 26 | return (t); 27 | } 28 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/boards-manager/boards.txt: -------------------------------------------------------------------------------- 1 | ../../boards.txt -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/boards-manager/packbm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | ARCHIVE=~/public_html/fpgarduino/bm/fpgarduino.zip 3 | ARDUINODIR=$(pwd)/../../../../../ 4 | TOOLDIR=$(pwd) 5 | 6 | cd /tmp 7 | rm -rf arduino 8 | ln -sf "${ARDUINODIR}" arduino 9 | 10 | rm -f $ARCHIVE 11 | zip -r $ARCHIVE arduino/examples arduino/libraries arduino/tools 12 | rm -rf pack 13 | mkdir -p pack 14 | cd pack 15 | ln -s ../arduino/hardware/fpga/f32c arduino 16 | zip -r $ARCHIVE arduino/cores arduino/programmers.txt arduino/system arduino/variants arduino/tools 17 | cd .. 18 | rm -rf pack2 19 | mkdir -p pack2 20 | cd pack2 21 | ln -s ../arduino/hardware/fpga/f32c/tools/boards-manager arduino 22 | zip -r $ARCHIVE arduino/platform.txt arduino/boards.txt 23 | cd /tmp 24 | rm -rf arduino 25 | unzip $ARCHIVE 26 | rm -f $ARCHIVE 27 | zip -r $ARCHIVE arduino 28 | # unzip -tv $ARCHIVE 29 | rm -f ~/.arduino15/staging/packages/fpgarduino.zip 30 | sha256sum $ARCHIVE 31 | ls -al $ARCHIVE 32 | 33 | #cd ~/public_html/fpgarduino 34 | #./mkjson.sh > package_f32c_core_index.json 35 | #cd bm 36 | #./mkjson.sh > package_f32c_core_index.json 37 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/boards-manager/platform.txt: -------------------------------------------------------------------------------- 1 | ../../platform.txt -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/boards-manager/upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | scp bm/fpgarduino.zip login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 3 | #scp bm/bootloaders.zip login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 4 | #scp bm/ujprog-i686-pc-linux-gnu.tar.bz2 login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 5 | #scp bm/ujprog-x86_64-pc-linux-gnu.tar.bz2 login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 6 | #scp bm/ujprog-x86_64-apple-darwin.tar.bz2 login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 7 | #scp bm/ujprog-win32.zip login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 8 | #scp bm/openocd-0.9.0-linux32.tar.bz2 login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 9 | #scp bm/openocd-0.9.0-linux64.tar.bz2 login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 10 | #scp bm/openocd-0.9.0-windows.zip login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 11 | #scp bm/xc3sprog-771-win32.zip login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 12 | #scp bm/xc3sprog-774-linux32.tar.bz2 login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 13 | #scp bm/xc3sprog-774-linux64.tar.bz2 login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 14 | scp bm/numato-1.0.0-python3.zip login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 15 | scp bm/fleafpga-jtag-12.2-linux32.tar.bz2 login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/bm/ 16 | scp package_f32c_core_index.json login.nxlab.fer.hr:/jails/www/usr/local/www/data/fpgarduino/ 17 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/board/de10-lite.cfg: -------------------------------------------------------------------------------- 1 | # de10lite.ocd 2 | # OpenOCD commands 3 | 4 | telnet_port 4444 5 | gdb_port 3333 6 | 7 | adapter_khz 1000 8 | 9 | # JTAG TAPs 10 | jtag newtap chip tap -expected-id 0x031050dd -irlen 10 11 | 12 | init 13 | scan_chain 14 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/board/kondor_ax.cfg: -------------------------------------------------------------------------------- 1 | # ecp3.cfg 2 | # OpenOCD commands 3 | 4 | telnet_port 4444 5 | gdb_port 3333 6 | 7 | adapter_khz 25000 8 | 9 | # JTAG TAPs 10 | jtag newtap chip tap -expected-id 0x01113043 -irlen 8 -irmask 0xFF -ircapture 0x5 11 | 12 | init 13 | scan_chain 14 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/board/scarab_ms6p.cfg: -------------------------------------------------------------------------------- 1 | # xc6slx9.ocd 2 | # OpenOCD commands 3 | 4 | # impact->boundary scan->right click in right window->add xilinx device glue.bit->one step svf 5 | 6 | telnet_port 4444 7 | gdb_port 3333 8 | 9 | adapter_khz 1000 10 | 11 | # JTAG TAPs 12 | jtag newtap chip tap -expected-id 0x24004093 -irlen 6 13 | 14 | init 15 | scan_chain 16 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/board/sparrowhawk.cfg: -------------------------------------------------------------------------------- 1 | # tb276.ocd 2 | # OpenOCD commands 3 | 4 | # source [find interface/altera-usb-blaster.cfg] 5 | 6 | telnet_port 4444 7 | gdb_port 3333 8 | 9 | jtag_rclk 25000 10 | 11 | # JTAG TAPs 12 | jtag newtap chip tap -expected-id 0x01015043 -irlen 8 -irmask 0xFF -ircapture 0b00011101 13 | 14 | init 15 | scan_chain 16 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/board/tb276.cfg: -------------------------------------------------------------------------------- 1 | # tb276.ocd 2 | # OpenOCD commands 3 | 4 | # source [find interface/altera-usb-blaster.cfg] 5 | 6 | telnet_port 4444 7 | gdb_port 3333 8 | 9 | jtag_rclk 1000 10 | 11 | # JTAG TAPs 12 | jtag newtap chip tap -expected-id 0x020f10dd -irlen 10 13 | 14 | init 15 | scan_chain 16 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/board/tb299.cfg: -------------------------------------------------------------------------------- 1 | # TB299 xilinx XC6SLX9 2 | 3 | telnet_port 4444 4 | gdb_port 3333 5 | 6 | jtag_rclk 1200 7 | # JTAG TAPs 8 | jtag newtap chip tap -expected-id 0x24001093 -irlen 6 9 | 10 | init 11 | scan_chain 12 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/board/zybo.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # ZYBO board 3 | # 4 | 5 | set _CHIPNAME zynq 6 | set _TARGETNAME $_CHIPNAME.cpu 7 | 8 | jtag newtap chip tap -irlen 6 -ircapture 0x1 -irmask 0x03 \ 9 | -expected-id 0x23727093 \ 10 | -expected-id 0x03727093 \ 11 | -expected-id 0x13722093 12 | 13 | jtag newtap $_CHIPNAME dap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x4ba00477 14 | 15 | target create ${_TARGETNAME}0 cortex_a -chain-position $_CHIPNAME.dap \ 16 | -coreid 0 -dbgbase 0x80090000 17 | target create ${_TARGETNAME}1 cortex_a -chain-position $_CHIPNAME.dap \ 18 | -coreid 1 -dbgbase 0x80092000 19 | target smp ${_TARGETNAME}0 ${_TARGETNAME}1 20 | 21 | adapter_khz 1000 22 | 23 | ${_TARGETNAME}0 configure -event reset-assert-post "cortex_a dbginit" 24 | ${_TARGETNAME}1 configure -event reset-assert-post "cortex_a dbginit" 25 | 26 | init 27 | scan_chain 28 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/interface/altera-usb-blaster-ftdi.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Altera USB-Blaster II 3 | # 4 | 5 | interface usb_blaster 6 | usb_blaster_lowlevel_driver ftdi 7 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/interface/ftdi/digilent_adept.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # ZYBO ft2232hq usbserial jtag 3 | # 4 | 5 | interface ftdi 6 | ftdi_device_desc "Digilent Adept USB Device" 7 | ftdi_vid_pid 0x0403 0x6010 8 | 9 | ftdi_layout_init 0x3088 0x1f8b 10 | ftdi_layout_signal nSRST -data 0x3000 -oe 0x1000 11 | ftdi_layout_signal LED -data 0x0010 12 | 13 | reset_config srst_pulls_trst 14 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/interface/ftdi/fpu1.cfg: -------------------------------------------------------------------------------- 1 | # PLDkit FPU1 JTAG programmer 2 | 3 | interface ftdi 4 | ftdi_device_desc "FPU1 JTAG Programmer" 5 | ftdi_vid_pid 0x0403 0x6010 6 | ftdi_layout_init 0x3088 0x1f8b 7 | 8 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/interface/ftdi/ft2232-generic.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Generic FT2232 USB-JTAG Programmer 3 | # 4 | 5 | interface ftdi 6 | ftdi_device_desc "Dual RS232-HS" 7 | ftdi_vid_pid 0x0403 0x6010 8 | ftdi_layout_init 0x3088 0x1f8b 9 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/openocd/scripts/interface/remote_bitbang.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Remote bitbang programmer 3 | # 4 | 5 | interface remote_bitbang 6 | remote_bitbang_host jtag 7 | remote_bitbang_port 3335 8 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/tools/xilinx-usb-xpc/etc-udev-rules.d/55-xilinx-usb-xpc.rules: -------------------------------------------------------------------------------- 1 | # Xilinx platform cable 2 | # cypress FX2 -> CPLD XC2 -> jtag XC3 3 | 4 | # when inserted empty device 0x03fd:0x000d then load firmware 5 | # uncomment either cycfx2load or fxload line 6 | # or have both commented if you don't want to load firmware 7 | # when device is inserted into usb 8 | 9 | # cycfx2load will load firmware 10 | SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000d", RUN+="/usr/bin/cycfx2prog -id=03fd:000d prg:/usr/local/xilinx/14.7/ISE_DS/ISE/bin/lin/xusb_emb.hex run" 11 | # fxload will load firmware 12 | # SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000d", RUN+="/sbin/fxload -v -t fx2 -I /usr/local/xilinx/14.7/ISE_DS/ISE/bin/lin/xusb_emb.hex -D vid=0x03fd,pid=0x000d" 13 | # when firmware is loaded, green led near usb connector on Digilent Spartan 3AN Starter kit should be lit 14 | # and this command will list some jtag devices 15 | # xc3sprog -c xpc 16 | # JTAG loc.: 0 IDCODE: 0x22628093 Desc: XC3S700AN Rev: C IR length: 6 17 | # JTAG loc.: 1 IDCODE: 0xf5046093 Desc: XCF04S Rev: O IR length: 8 18 | 19 | # when device with firmware reloads as 0x03fd:0x0008 give it dialout group permission 20 | # non-root users that belog to dialout group can access jtag 21 | SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0008", GROUP="dialout", MODE="0664" 22 | 23 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/variants/esa11/variant.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _f32c_mips_variant_h 3 | #define _f32c_mips_variant_h 4 | 5 | #include 6 | 7 | /* LEDs */ 8 | #define PIN_LED_13 13 9 | #define PIN_LED 13 10 | #define LED_BUILTIN 13 11 | 12 | #include "Arduino.h" 13 | #ifdef __cplusplus 14 | #include "UARTClass.h" 15 | #endif 16 | 17 | #include "emard_timer.h" 18 | 19 | #ifdef __cplusplus 20 | extern UARTClass Serial; 21 | #endif 22 | 23 | /* 24 | * Analog pins 25 | */ 26 | static const uint8_t A0 = 16; 27 | static const uint8_t A1 = 17; 28 | 29 | /* 30 | ** PWM pins 31 | */ 32 | static const uint8_t PWM0 = 14; 33 | static const uint8_t PWM1 = 15; 34 | 35 | #endif /* _f32c_mips_variant_h */ 36 | 37 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/variants/flearduino_shield/variant.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _f32c_mips_variant_h 3 | #define _f32c_mips_variant_h 4 | 5 | #include 6 | 7 | /* LEDs */ 8 | #define PIN_LED_13 13 9 | #define PIN_LED 13 10 | #define LED_BUILTIN 13 11 | 12 | #include "Arduino.h" 13 | #ifdef __cplusplus 14 | #include "UARTClass.h" 15 | #endif 16 | 17 | #include "emard_timer.h" 18 | 19 | #ifdef __cplusplus 20 | extern UARTClass Serial; 21 | #endif 22 | 23 | /* 24 | * Analog pins 25 | */ 26 | static const uint8_t A0 = 16; 27 | static const uint8_t A1 = 17; 28 | 29 | /* 30 | ** PWM pins 31 | */ 32 | static const uint8_t PWM0 = 14; 33 | static const uint8_t PWM1 = 15; 34 | 35 | #endif /* _f32c_mips_variant_h */ 36 | 37 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/variants/generic/variant.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _f32c_mips_variant_h 3 | #define _f32c_mips_variant_h 4 | 5 | #include 6 | 7 | /* LEDs */ 8 | #define PIN_LED_13 13 9 | #define PIN_LED 13 10 | #define LED_BUILTIN 13 11 | 12 | #include "Arduino.h" 13 | #ifdef __cplusplus 14 | #include "UARTClass.h" 15 | #endif 16 | 17 | #include "emard_timer.h" 18 | 19 | #ifdef __cplusplus 20 | extern UARTClass Serial; 21 | #endif 22 | 23 | /* 24 | * Analog pins 25 | */ 26 | static const uint8_t A0 = 16; 27 | static const uint8_t A1 = 17; 28 | 29 | /* 30 | ** PWM pins 31 | */ 32 | static const uint8_t PWM0 = 14; 33 | static const uint8_t PWM1 = 15; 34 | 35 | #endif /* _f32c_mips_variant_h */ 36 | 37 | -------------------------------------------------------------------------------- /hardware/fpga/f32c/variants/ulx2s_physical/variant.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _f32c_mips_variant_h 3 | #define _f32c_mips_variant_h 4 | 5 | #include 6 | 7 | /* LEDs */ 8 | #define PIN_LED_13 13 9 | #define PIN_LED 13 10 | #define LED_BUILTIN 13 11 | 12 | #include "Arduino.h" 13 | #ifdef __cplusplus 14 | #include "UARTClass.h" 15 | #endif 16 | 17 | #include "emard_timer.h" 18 | 19 | #ifdef __cplusplus 20 | extern UARTClass Serial; 21 | #endif 22 | 23 | /* 24 | * Analog pins 25 | */ 26 | static const uint8_t A0 = 16; 27 | static const uint8_t A1 = 17; 28 | 29 | /* 30 | ** PWM pins 31 | */ 32 | static const uint8_t PWM0 = 6; 33 | static const uint8_t PWM1 = 5; 34 | 35 | #endif /* _f32c_mips_variant_h */ 36 | 37 | -------------------------------------------------------------------------------- /libraries/Adafruit_F32C_VGA/examples/simple_grafx/simple_grafx.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | Adafruit_F32C_VGA display(1); 4 | 5 | void setup() { 6 | // put your setup code here, to run once: 7 | display.begin(); 8 | display.clearDisplay(); 9 | display.setTextSize(2); 10 | display.setCursor(10,10); 11 | display.setTextColor(RED); 12 | display.print("RED "); 13 | display.setTextColor(GREEN); 14 | display.print("GREEN "); 15 | display.setTextColor(BLUE); 16 | display.print("BLUE "); 17 | display.setTextColor(CYAN); 18 | display.print("CYAN "); 19 | display.setTextColor(MAGENTA); 20 | display.print("MAGENTA "); 21 | display.setTextColor(YELLOW); 22 | display.print("YELLOW"); 23 | display.setTextColor(WHITE); 24 | display.setCursor(10,30); 25 | display.setTextColor(DARKRED); 26 | display.print("RED "); 27 | display.setTextColor(DARKGREEN); 28 | display.print("GREEN "); 29 | display.setTextColor(DARKBLUE); 30 | display.print("BLUE "); 31 | display.setTextColor(DARKCYAN); 32 | display.print("CYAN "); 33 | display.setTextColor(DARKMAGENTA); 34 | display.print("MAGENTA "); 35 | display.setTextColor(DARKYELLOW); 36 | display.print("YELLOW"); 37 | display.setTextColor(WHITE); 38 | display.setTextSize(4); 39 | display.setCursor(100,100); 40 | display.print("VGA DISPLAY TEST"); 41 | display.drawRect( 0,0, 640,480, WHITE); 42 | display.drawLine(100,180, 480,150, YELLOW); 43 | } 44 | 45 | void loop() { 46 | static uint32_t counter = 0; 47 | display.fillRect(100,200,400,28,BLACK); 48 | display.setTextColor(RED); 49 | display.setCursor(100,200); 50 | display.print(counter++); 51 | delay(1000); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /libraries/Adafruit_F32C_VGA/examples/videoram/videoram.ino: -------------------------------------------------------------------------------- 1 | 2 | //volatile uint32_t * videoram = (volatile uint32_t *) 0x800D0000; // near top 1MB 3 | volatile uint32_t * videoram = (volatile uint32_t *) 0x8000F000; // half-screen remains visible after reset 4 | volatile uint32_t * video_base = (volatile uint32_t *) 0xFFFFFB80; 5 | 6 | void setup() { 7 | // put your setup code here, to run once: 8 | 9 | for (int i = 0; i < 44000; i++) 10 | videoram[i] = 0; 11 | for (int i = 80; i < 160; i += 2) 12 | videoram[i] = 0xFFFFFFFF; 13 | #if 1 14 | videoram[0] = 0xffffff0F; 15 | videoram[1] = 0xff000000; 16 | videoram[2] = 0xff005505; 17 | videoram[3] = 0xffAA0000; 18 | videoram[17] = 0xAAaaaa; 19 | #endif 20 | *video_base = videoram; 21 | } 22 | 23 | void loop() { 24 | // put your main code here, to run repeatedly: 25 | uint8_t j = 0; 26 | static int x = 79; 27 | static uint32_t u = 0x01010101; 28 | int k; 29 | //return; 30 | if (x > 38400) x = 0; 31 | videoram[x+0] ^= u; 32 | videoram[x+1] += u; 33 | videoram[x+2] = u; 34 | u = (u >> 31) | (u << 1); 35 | x += 80; 36 | //delay(1); 37 | //return; 38 | if (1) 39 | for (int i = 80; i < 4096; i++) 40 | { 41 | videoram[i] = (i & 0) == 0 ? j | (j<<8) | (j<<16) | (j<<24) : 0; 42 | //videoram[i] = (i & 3) == 0 ? 129 : 0; 43 | if ((i & 3) == 0)j++; 44 | //delay(10); 45 | } 46 | // draw 45 angle line 47 | j = 1; 48 | k = 0; 49 | for (int i = 0; i < 480; i++) 50 | { 51 | videoram[k] = j; // j 52 | k += 80; 53 | j = (j << 1) | (j >> 7); 54 | if (j == 1) k++; 55 | } 56 | 57 | //videoram++; 58 | //*video_base=videoram; 59 | //delay(100); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /libraries/Adafruit_F32C_video/Adafruit_F32C_video.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | This is a library for F32C framebuffer 3 | *********************************************************************/ 4 | 5 | #if ARDUINO >= 100 6 | #include "Arduino.h" 7 | #else 8 | #include "WProgram.h" 9 | #endif 10 | 11 | #include 12 | 13 | #define BLACK 0 14 | #define WHITE 0xFFFF 15 | 16 | #define F32C_VIDEOWIDTH 512 17 | #define F32C_VIDEOHEIGHT 288 18 | 19 | class Adafruit_F32C_video : public Adafruit_GFX { 20 | public: 21 | Adafruit_F32C_video(int8_t mode); 22 | 23 | void begin(void); 24 | 25 | void clearDisplay(void); 26 | void invertDisplay(uint8_t i); 27 | void display(); 28 | 29 | void startscrollright(uint8_t start, uint8_t stop); 30 | void startscrollleft(uint8_t start, uint8_t stop); 31 | 32 | void startscrolldiagright(uint8_t start, uint8_t stop); 33 | void startscrolldiagleft(uint8_t start, uint8_t stop); 34 | void stopscroll(void); 35 | 36 | void dim(uint8_t contrast); 37 | 38 | void drawPixel(int16_t x, int16_t y, uint16_t color); 39 | void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); 40 | void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 41 | }; 42 | -------------------------------------------------------------------------------- /libraries/Adafruit_GFX/README.txt: -------------------------------------------------------------------------------- 1 | This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). 2 | 3 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 4 | 5 | Written by Limor Fried/Ladyada for Adafruit Industries. 6 | BSD license, check license.txt for more information. 7 | All text above must be included in any redistribution. 8 | 9 | To download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h 10 | 11 | Place the Adafruit_GFX library folder your /Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. 12 | -------------------------------------------------------------------------------- /libraries/Adafruit_GFX/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /libraries/Adafruit_SSD1306/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for our Monochrome OLEDs based on SSD1306 drivers 2 | 3 | Pick one up today in the adafruit shop! 4 | ------> http://www.adafruit.com/category/63_98 5 | 6 | These displays use SPI to communicate, 4 or 5 pins are required to 7 | interface 8 | 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | Scrolling code contributed by Michael Gregg 15 | BSD license, check license.txt for more information 16 | All text above must be included in any redistribution 17 | 18 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h 19 | 20 | Place the Adafruit_SSD1306 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. 21 | 22 | You will also have to download the Adafruit GFX Graphics core which does all the circles, text, rectangles, etc. You can get it from 23 | https://github.com/adafruit/Adafruit-GFX-Library 24 | and download/install that library as well -------------------------------------------------------------------------------- /libraries/Adafruit_SSD1306/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012, Adafruit Industries 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /libraries/Compositing/compositing_line.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPOSITING_LINE_H 2 | #define COMPOSITING_LINE_H 3 | 4 | #include 5 | 6 | // bits per pixel 7 | #ifndef SOC_VIDEO_BPP 8 | #define BPP 8 9 | #else 10 | #define BPP SOC_VIDEO_BPP 11 | #endif 12 | 13 | // RGB2PIXEL converts from 24-bit RGB888 to actual pixel_t format (8/16/32 bit) 14 | #if BPP == 8 15 | typedef uint8_t pixel_t; 16 | #define RGB2PIXEL(x) ( (((x) & 0xE00000) >> (24-3-5)) | (((x) & 0xE000) >> (16-3-2)) | (((x) & 0xC0) >> (8-2)) ) 17 | #endif 18 | 19 | #if BPP == 16 20 | typedef uint16_t pixel_t; 21 | #define RGB2PIXEL(x) ( (((x) & 0xF80000) >> (24-5-11)) | (((x) & 0xFC00) >> (16-6-5)) | (((x) & 0xF8) >> (8-5)) ) 22 | #endif 23 | 24 | #if BPP == 32 25 | typedef uint32_t pixel_t; 26 | #define RGB2PIXEL(x) x 27 | #endif 28 | 29 | struct compositing_line 30 | { 31 | struct compositing_line *next; // 32-bit continuation of the same structure, NULL if no more 32 | int16_t x; // where to start on screen (can be negative) 33 | uint16_t n; // number of pixels -1 contained here (0: 1 pixel) 34 | // pixels can be multiple of 4 (n lower 2 bits discarded) 35 | // for 8bpp minimum is 4 pixels 36 | pixel_t *bmp; // pointer to array of pixels (could be more than 1 element) 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_font/c2_font.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "font.h" 3 | 4 | #define N_LETTERS (sizeof(Font)/sizeof(Font[0])) 5 | 6 | Compositing c2; 7 | 8 | void setup() 9 | { 10 | int i; 11 | int unique_sprites; 12 | c2.init(); 13 | c2.alloc_sprites(765); // 1200 full screen, 765 triangle, it sets c2.sprite_max 14 | *c2.videobase_reg = NULL; // disable video during update 15 | *c2.cntrl_reg = 0; 16 | #if 1 17 | for(i = 0; i < c2.sprite_max && i < N_LETTERS; i++) 18 | c2.shape_to_sprite(&(Font[i])); 19 | unique_sprites = c2.n_sprites; 20 | for(i = unique_sprites; i < c2.sprite_max; i++) 21 | c2.sprite_clone(i%unique_sprites); 22 | // position all sprites to display a font 23 | int col=0, row=0; 24 | for(i = 0; i < c2.sprite_max; i++) 25 | { 26 | c2.Sprite[i]->x = col*16; 27 | c2.Sprite[i]->y = row*16; 28 | col++; 29 | if(col>=11+row) // triangle 30 | //if(col>=40) // full screen 31 | { 32 | col=0; 33 | row++; 34 | } 35 | } 36 | #endif 37 | 38 | c2.sprite_refresh(); 39 | 40 | // this is needed for vgatext 41 | // to disable textmode and enable bitmap 42 | *c2.cntrl_reg = 0b11000000; // enable video, yes bitmap, no text mode, no cursor 43 | } 44 | 45 | void loop() 46 | { 47 | 48 | } 49 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_font_fancy/c2_font_fancy.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "font.h" 3 | 4 | #define N_LETTERS (sizeof(Font)/sizeof(Font[0])) 5 | 6 | Compositing c2; 7 | 8 | void setup() 9 | { 10 | int i; 11 | int unique_sprites; 12 | c2.init(); 13 | c2.alloc_sprites(765); // 1200 full screen, 436 triangle, it sets c2.sprite_max 14 | *c2.videobase_reg = NULL; // disable video during update 15 | *c2.cntrl_reg = 0; 16 | #if 1 17 | for(i = 0; i < c2.sprite_max && i < N_LETTERS; i++) 18 | c2.shape_to_sprite(&(Font[i])); 19 | unique_sprites = c2.n_sprites; 20 | for(i = unique_sprites; i < c2.sprite_max; i++) 21 | c2.sprite_clone(i%unique_sprites); 22 | // position all sprites to display a font 23 | int col=0, row=0; 24 | for(i = 0; i < c2.sprite_max; i++) 25 | { 26 | c2.Sprite[i]->x = col*16; 27 | c2.Sprite[i]->y = row*16; 28 | col++; 29 | if(col>=11+row) // triangle 30 | //if(col>=40) // full screen 31 | { 32 | col=0; 33 | row++; 34 | } 35 | } 36 | #endif 37 | 38 | c2.sprite_refresh(); 39 | 40 | // this is needed for vgatext 41 | // to disable textmode and enable bitmap 42 | *c2.cntrl_reg = 0b11000000; // enable video, yes bitmap, no text mode, no cursor 43 | } 44 | 45 | void loop() 46 | { 47 | 48 | } 49 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_raytrace/c2_raytrace.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | (c)Emanuel Stiebler 3 | LICENSE=BSD 4 | 5 | Example 6 | compositing2 used as simple linear framebuffer 7 | ****************************************************/ 8 | extern "C" 9 | { 10 | #include "raytrace.h" 11 | } 12 | #include 13 | #define SPRITE_MAX 10 14 | Compositing c2; 15 | 16 | //Define Visuals 17 | //#define SCREEN_WIDTH 640 18 | //#define SCREEN_HEIGHT 480 19 | 20 | #define XRES (SCREEN_WIDTH-1) 21 | #define YRES (SCREEN_HEIGHT-1) 22 | #define ANZCOL 255 23 | 24 | // crude malloc() 25 | pixel_t *bitmap = (pixel_t *)0x80080000; 26 | 27 | void emu_set_pix(int x, int y, int r, int g, int b) 28 | { 29 | bitmap[x + SCREEN_WIDTH*y] = RGB2PIXEL((r << 16) | (g << 8) | b); 30 | } 31 | 32 | void cleanup(char *a) 33 | { 34 | // print some message if malloc fails 35 | } 36 | 37 | void setup() 38 | { 39 | int i, x,y; 40 | 41 | c2.init(); 42 | c2.alloc_sprites(SPRITE_MAX); 43 | // currently malloc() doesn't work for more than 1MB 44 | // bitmap = (pixel_t *) malloc(SCREEN_WIDTH*SCREEN_HEIGHT*sizeof(pixel_t)); // alloc memory for video 45 | c2.sprite_from_bitmap(SCREEN_WIDTH, SCREEN_HEIGHT, bitmap); // create c2 sprite 46 | c2.sprite_refresh(); // show it on screen 47 | 48 | for(i = 0; i < SCREEN_WIDTH*SCREEN_HEIGHT; i++) 49 | bitmap[i] = RGB2PIXEL(i<<8); // clear screen 50 | 51 | delay(1000); 52 | main_raytrace(); 53 | } 54 | 55 | void loop() 56 | { 57 | } 58 | 59 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_slides_egg/sprites.h: -------------------------------------------------------------------------------- 1 | void setup_sprites(); 2 | void prepare_sprites(); 3 | void loop_sprites(); 4 | void stop_sprites(); 5 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/adc.h: -------------------------------------------------------------------------------- 1 | void adc_init(); 2 | void adc_read(char *a); 3 | 4 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/btn.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void btn_init() 4 | { 5 | int i; 6 | // buttons 7 | for(i = 0; i < 6; i++) 8 | pinMode(i, INPUT); 9 | // switches 10 | for(i = 16; i < 20; i++) 11 | pinMode(i, INPUT); 12 | // leds 13 | for(i = 8; i < 16; i++) 14 | pinMode(i, OUTPUT); 15 | } 16 | 17 | void btn_read(char *line) 18 | { 19 | static uint8_t shiftdata = 0; 20 | uint8_t led = B10001 << (shiftdata++ & 3); 21 | sprintf(line, "BTN:%c%c%c%c%c%c%c SW:%c%c%c%c LED:%c%c%c%c%c%c%c%c\n", 22 | digitalRead(0) ? '_' : '0', 23 | digitalRead(1) ? '1' : '_', 24 | digitalRead(2) ? '2' : '_', 25 | digitalRead(3) ? '3' : '_', 26 | digitalRead(4) ? '4' : '_', 27 | digitalRead(5) ? '5' : '_', 28 | digitalRead(6) ? '6' : '_', 29 | digitalRead(16) ? '1' : '_', 30 | digitalRead(17) ? '2' : '_', 31 | digitalRead(18) ? '3' : '_', 32 | digitalRead(19) ? '4' : '_', 33 | led & B10000000 ? '7' : '_', 34 | led & B01000000 ? '6' : '_', 35 | led & B00100000 ? '5' : '_', 36 | led & B00010000 ? '4' : '_', 37 | led & B00001000 ? '3' : '_', 38 | led & B00000100 ? '2' : '_', 39 | led & B00000010 ? '1' : '_', 40 | led & B00000001 ? '0' : '_' 41 | ); 42 | for(int i = 0; i < 8; i++) 43 | digitalWrite(8+i, led & (1< 2 | #include "spi.h" 3 | 4 | volatile uint16_t *flash_spi = (uint16_t *)0xFFFFFB40; 5 | 6 | uint8_t flash_id(void) 7 | { 8 | spi_start_tx(flash_spi); 9 | spi_rxtx(flash_spi, 0xAB); 10 | spi_rxtx(flash_spi, 0); 11 | spi_rxtx(flash_spi, 0); 12 | spi_rxtx(flash_spi, 0); 13 | return spi_rxtx(flash_spi, 0); 14 | } 15 | 16 | // set up variables using the SD utility library functions: 17 | void flash_read(char *a) 18 | { 19 | uint8_t id = flash_id(); 20 | if(id >= 0x15 && id <= 0x17) 21 | sprintf(a, "FLASH: %02x OK ", id); 22 | else 23 | sprintf(a, "FLASH: %02x FAIL", id); 24 | } 25 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/flash.h: -------------------------------------------------------------------------------- 1 | void flash_read(char *a); 2 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/oled.h: -------------------------------------------------------------------------------- 1 | void oled_init(); 2 | void oled_read(char *a); 3 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/pcm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | PCM pcm = PCM(); 6 | 7 | struct sample 8 | { 9 | int16_t ch[2]; // 0:left and 1:right channel, signed 16 bit integers 10 | }; 11 | 12 | // crude malloc() 13 | volatile struct sample *buf = (volatile struct sample *) 0x80080000; 14 | int buflen = 1<<13; // number of samples, halfdma code easier if power of 2 15 | int halfdma = buflen*sizeof(struct sample)/2; 16 | int maxvolume = 20000; 17 | int stepvolume = 50; 18 | 19 | void pcm_tone() 20 | { 21 | for(int i = 0; i <= maxvolume; i += stepvolume) 22 | { 23 | pcm.volume(i, i); 24 | delayMicroseconds(1); 25 | } 26 | } 27 | 28 | void pcm_mute() 29 | { 30 | for(int i = maxvolume; i >= 0; i -= stepvolume) 31 | { 32 | pcm.volume(i, i); 33 | delayMicroseconds(1); 34 | } 35 | } 36 | 37 | void pcm_init() { 38 | // set audio parameters 39 | int i, rate = 22050; 40 | buf = (struct sample *)malloc(buflen * sizeof(struct sample)); 41 | pcm.dma((uint32_t *)buf, buflen); 42 | pcm.rate(rate); 43 | pcm_mute(); 44 | for(i = 0; i < buflen; i++) 45 | { 46 | int16_t left = 32767 * sin(2*M_PI/buflen * i * 200); 47 | int16_t right = 32767 * sin(2*M_PI/buflen * i * 201); 48 | buf[i].ch[0] = left; 49 | buf[i].ch[1] = right; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/pcm.h: -------------------------------------------------------------------------------- 1 | void pcm_tone(); 2 | void pcm_mute(); 3 | void pcm_init(); 4 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/ram.cpp: -------------------------------------------------------------------------------- 1 | /* Test for 32MB RAM 2 | ** Fill RAM with pseudoranom data and read back its content 3 | */ 4 | #include 5 | 6 | volatile uint32_t *ram_begin = (uint32_t *) 0x80100000; // test start 7 | volatile uint32_t *ram_end = (uint32_t *) 0x82000000; // test end 8 | 9 | 10 | static uint32_t rngseed = 123459876; 11 | 12 | uint32_t rng(void) 13 | { 14 | int x, t; 15 | uint32_t hi, lo; 16 | 17 | /* 18 | * Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1). 19 | * From "Random number generators: good ones are hard to find", 20 | * Park and Miller, Communications of the ACM, vol. 31, no. 10, 21 | * October 1988, p. 1195. 22 | */ 23 | /* Can't be initialized with 0, so use another value. */ 24 | if ((x = rngseed) == 0) 25 | x = 123459876; 26 | hi = x / 127773; 27 | lo = x % 127773; 28 | t = 16807 * lo - 2836 * hi; 29 | if (t < 0) 30 | t += 0x7fffffff; 31 | rngseed = t; 32 | return t; 33 | } 34 | 35 | void ram_test(char *a) 36 | { 37 | volatile uint32_t *addr; 38 | uint32_t errors = 0; 39 | static uint32_t seed = 123459876; 40 | rngseed = seed; 41 | for(addr = ram_begin; addr < ram_end; addr +=4) 42 | *addr = rng(); 43 | rngseed = seed; 44 | for(addr = ram_begin; addr < ram_end; addr +=4) 45 | if(*addr != rng()) 46 | errors++; 47 | if(errors) 48 | sprintf(a, "RAM: ERRORS:%d FAIL\n", errors); 49 | else 50 | sprintf(a, "RAM: OK\n"); 51 | seed++; // change seed each time 52 | } 53 | 54 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/ram.h: -------------------------------------------------------------------------------- 1 | void ram_test(char *a); 2 | 3 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/rds.cpp: -------------------------------------------------------------------------------- 1 | /* FM antenna test 2 | * Tune FM radio to 107.9 MHz 3 | * Bring ULX3S within 1 m distance of radio antenna 4 | * You should hear silence. 5 | * RDS display should show: "TEST1234" 6 | * RDS long message (optional on some radios): "@ABCDEFGHIJ.." 7 | */ 8 | 9 | #include 10 | 11 | RDS rds = RDS(); 12 | 13 | uint16_t pi = 0xCAFE; 14 | char ps[9] = "TEST1234"; 15 | char rt[65] = "ABCDEFGH"; 16 | 17 | void rds_init() { 18 | int i; 19 | for(i = 0; i < sizeof(rt)-1; i++) 20 | rt[i] = '@'+i; // ascii map 21 | /* Setup initial RDS text */ 22 | rds.pi(pi); // station numeric ID 23 | rds.stereo(0); // 0-Inform over RDS that we send Mono, 1-Stereo 24 | rds.ta(0); // 0-No, 1-Traffice Announcements 25 | rds.ps(ps); // 8-char text, displayed as station name 26 | rds.rt(rt); // 64-char text, not every radio displays it 27 | rds.Hz(107900000); // Hz carrier wave frequency 28 | rds.length(260); // bytes message length (260 default) 29 | } 30 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/rds.h: -------------------------------------------------------------------------------- 1 | void rds_init(); 2 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/rtc.h: -------------------------------------------------------------------------------- 1 | void rtc_init(); 2 | void rtc_read(char *a); 3 | void rtc_set_alarm(); 4 | void rtc_set_clock(); 5 | void rtc_clear_interrupts(); 6 | 7 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/sd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if 0 4 | #include "spi.h" 5 | volatile uint16_t *sd_spi = (uint16_t *)0xFFFFFB50; 6 | uint8_t sd_cmd0() 7 | { 8 | int i, r; 9 | 10 | spi_start_tx(sd_spi); 11 | for(i = 0; i < 10; i++) 12 | spi_rxtx(sd_spi, 0xFF); 13 | spi_rxtx(sd_spi, 0x40); 14 | spi_rxtx(sd_spi, 0x00); 15 | spi_rxtx(sd_spi, 0x00); 16 | spi_rxtx(sd_spi, 0x00); 17 | spi_rxtx(sd_spi, 0x95); 18 | 19 | //Polling it to check response to 0x01 20 | r = 0xFF; 21 | for(int i = 0; i < 1000 && r != 0xFF; i++) 22 | r = spi_rxtx(sd_spi, 0xFF); 23 | return r; 24 | } 25 | 26 | void sd_read(char *a) 27 | { 28 | uint8_t cmd0_response = sd_cmd0(); 29 | if(cmd0_response == 1) 30 | sprintf(a, "SD: %02x OK ", cmd0_response); 31 | else 32 | sprintf(a, "SD: %02x FAIL", cmd0_response); 33 | } 34 | #endif 35 | 36 | #if 1 37 | #include 38 | #include 39 | // set up variables using the SD utility library functions: 40 | Sd2Card card; 41 | SdVolume volume; 42 | SdFile root; 43 | // reading sd card type is slow 44 | void sd_read(char *a) 45 | { 46 | char *cardtype; 47 | if (card.init(SPI_HALF_SPEED, 2)) 48 | { 49 | switch (card.type()) 50 | { 51 | case SD_CARD_TYPE_SD1: 52 | cardtype = "1 "; 53 | break; 54 | case SD_CARD_TYPE_SD2: 55 | cardtype = "2 "; 56 | break; 57 | case SD_CARD_TYPE_SDHC: 58 | cardtype = "HC"; 59 | break; 60 | default: 61 | cardtype = "? "; 62 | } 63 | sprintf(a, "SD: %s OK", cardtype); 64 | } 65 | else 66 | { 67 | sprintf(a, "SD: FAIL "); 68 | } 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/sd.h: -------------------------------------------------------------------------------- 1 | void sd_read(char *a); 2 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/spi.cpp: -------------------------------------------------------------------------------- 1 | 2 | #if (_BYTE_ORDER == _LITTLE_ENDIAN) 3 | #define SPI_READY_MASK (1 << 8) 4 | #else 5 | #define SPI_READY_MASK (1 << 16) 6 | #endif 7 | 8 | uint8_t spi_start_tx(volatile uint16_t *port) 9 | { 10 | uint32_t in; 11 | 12 | ((uint8_t *)port)[1] = 0x80; 13 | do { 14 | in = *port; 15 | } while ((in & SPI_READY_MASK) == 0); 16 | 17 | #if (_BYTE_ORDER == _LITTLE_ENDIAN) 18 | return (in & 0xff); 19 | #else 20 | return (in >> 24); 21 | #endif 22 | } 23 | 24 | 25 | uint8_t spi_rxtx(volatile uint16_t *port, uint8_t _data) 26 | { 27 | uint32_t in; 28 | 29 | *(uint8_t *)port = _data; 30 | do { 31 | in = *port; 32 | } while ((in & SPI_READY_MASK) == 0); 33 | 34 | #if (_BYTE_ORDER == _LITTLE_ENDIAN) 35 | return (in & 0xff); 36 | #else 37 | return (in >> 24); 38 | #endif 39 | } 40 | 41 | -------------------------------------------------------------------------------- /libraries/Compositing/examples/c2_ulx3s_test/spi.h: -------------------------------------------------------------------------------- 1 | uint8_t spi_start_tx(volatile uint16_t *port); 2 | uint8_t spi_rxtx(volatile uint16_t *port, uint8_t _data); 3 | -------------------------------------------------------------------------------- /libraries/Compositing/shape.h: -------------------------------------------------------------------------------- 1 | #ifndef SHAPE_H 2 | #define SHAPE_H 3 | #include "compositing_line.h" // pixel_t only 4 | 5 | struct charcolors 6 | { 7 | const char c; // letter indicating the color (0 to end of list) 8 | const pixel_t color; // color value bits: RRRGGGBB if 8bpp 9 | }; 10 | 11 | // struct used to draw sprite in C 12 | struct shape 13 | { 14 | const struct charcolors *colors; // array of colors 15 | const char **bmp; // the bitmap, NULL-terminated 16 | const uint8_t w,h; // width x-size, height y-size 17 | }; 18 | 19 | // extern struct shape Shape[]; 20 | 21 | #endif // SHAPE_H 22 | -------------------------------------------------------------------------------- /libraries/Compositing/sprite.h: -------------------------------------------------------------------------------- 1 | #ifndef SPRITE_H 2 | #define SPRITE_H 3 | #include "compositing_line.h" 4 | #include "shape.h" 5 | 6 | // if using existing content, only 2K of video cache is sufficient 7 | // 1-USE 0-DON'T USE 8 | #define USE_EXISTING_CONTENT 1 9 | 10 | #define REMOVE_LEADING_TRANSPARENT 1 11 | 12 | // struct used to draw sprite in C 13 | struct sprite 14 | { 15 | int16_t x,y; // current position on the screen 16 | uint16_t h; // h: current height y-size (number of lines) 17 | uint16_t ha; // height allocated (absolute max of lines) 18 | struct compositing_line *line; // content: array of lines - NULL to terminate 19 | int16_t *lxo; // array of line x-offsets, removing leading transparent pixels and x-center adjustment 20 | }; 21 | 22 | #endif // SPRITE_H 23 | -------------------------------------------------------------------------------- /libraries/PCM/PCM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Author=EMARD 3 | License=CC 4 | */ 5 | #include "PCM.h" 6 | 7 | /* constructor does nothing */ 8 | PCM::PCM() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /libraries/PCM/PCM.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author=EMARD 3 | License=CC 4 | */ 5 | 6 | #ifndef _PCM_h 7 | #define _PCM_h 8 | 9 | #include 10 | #include 11 | 12 | #if 0 13 | struct sample 14 | { 15 | int16_t ch[2]; // 0:left and 1:right channel, signed 16 bit integers 16 | }; 17 | #endif 18 | 19 | class PCM { 20 | public: 21 | PCM(); 22 | 23 | inline void dma(uint32_t *addr, uint32_t size) 24 | { 25 | OUTW(IO_PCM_FIRST, addr); 26 | OUTW(IO_PCM_LAST, addr + (size&(-1 ^ 3))-1 ); 27 | } 28 | 29 | inline void dmafirst(uint32_t *addr) 30 | { 31 | OUTW(IO_PCM_FIRST, addr); 32 | } 33 | 34 | inline void dmalast(uint32_t *addr) 35 | { 36 | OUTW(IO_PCM_LAST, addr); 37 | } 38 | 39 | inline void Hz(uint32_t sample_rate_Hz) 40 | { 41 | OUTW(IO_PCM_FREQ, (uint32_t) (((float)(1<<24))/F_CPU*sample_rate_Hz)); 42 | } 43 | 44 | inline void rate(uint32_t sample_rate_Hz) 45 | { 46 | OUTW(IO_PCM_FREQ, (uint32_t) (((float)(1<<24))/F_CPU*sample_rate_Hz)); 47 | } 48 | 49 | inline void rateraw(uint32_t rate) 50 | { 51 | OUTW(IO_PCM_FREQ, rate); /* value 9108 at 81.25 MHz CPU makes 44.1 kHz sample rate */ 52 | } 53 | 54 | inline void volume(int16_t left, int16_t right) 55 | { 56 | OUTW(IO_PCM_VOLUME, left | (left << 16)); 57 | } 58 | 59 | inline uint32_t current() 60 | { 61 | uint32_t current_dma_pointer; 62 | INW(current_dma_pointer, IO_PCM_CUR); 63 | return current_dma_pointer; 64 | } 65 | 66 | #if 0 67 | private: 68 | volatile uint32_t *buf = (volatile uint32_t *) 0x80080000; 69 | uint32_t size = 8192; // bytes (bytes/4 = samples) 70 | #endif 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /libraries/PCM/examples/dummysynth/dummysynth.ino: -------------------------------------------------------------------------------- 1 | // Dummy synth example 2 | // Press buttons and hear some sounds. 3 | // For a more useful synth, see "midisynth" example. 4 | 5 | volatile uint32_t *voice = (uint32_t *)0xFFFFFBB0; // voices 6 | volatile uint32_t *pitch = (uint32_t *)0xFFFFFBB4; // frequency for prev written voice 7 | 8 | // Initialize each of 128 sinewave channels 9 | // to some frequency calculated in for-loop. 10 | // All channels initially muted (off). 11 | void setup() { 12 | for(int i = 0; i < 128; i++) 13 | { 14 | *voice = i | (0<<8); // channel number or'd with volume 0 (mute) 15 | *pitch = 1000000+2000*i; // frequency coefficient for the channel 16 | } 17 | } 18 | 19 | // When a button is pressed, volume of 20 | // a channel corresponding to the pressed button 21 | // is set to some audible volume. 22 | void loop() 23 | { 24 | for(int i = 1; i <= 6; i++) 25 | *voice = (6*i) // channel number in lower byte 26 | | (digitalRead(i)*1000<<8); // amplitude=1000 during keypress 27 | } 28 | -------------------------------------------------------------------------------- /libraries/PCM/examples/sine-rawio/sine-rawio.ino: -------------------------------------------------------------------------------- 1 | 2 | struct sample 3 | { 4 | int16_t ch[2]; // 0:left and 1:right channel, signed 16 bit integers 5 | }; 6 | 7 | // crude malloc() 8 | volatile struct sample *buf = (volatile struct sample *) 0x80080000; 9 | int buflen = 1<<13; // number of samples, halfdma code easier if power of 2 10 | int halfdma = buflen*sizeof(struct sample)/2; 11 | 12 | void setup() { 13 | // set audio parameters 14 | int i, vol = 21000; 15 | OUTW(IO_PCM_FIRST, (uint8_t *)buf); 16 | OUTW(IO_PCM_LAST, (uint8_t *)(buf + buflen - 1)); 17 | OUTW(IO_PCM_FREQ, 9108/2); /* 9108 => 44.1 kHz sample rate, 9108/2 => 22.05 kHz */ 18 | OUTW(IO_PCM_VOLUME, 0); // quiet when updating buffer 19 | for(i = 0; i < buflen; i++) 20 | { 21 | uint16_t left = 2*16383 * sin(2*M_PI/buflen * i * 200); 22 | uint16_t right = 2*16383 * sin(2*M_PI/buflen * i * 201); 23 | uint16_t mono; 24 | // left = right = 0; 25 | mono = left+right; 26 | buf[i].ch[0] = left; 27 | buf[i].ch[1] = right; 28 | } 29 | OUTW(IO_PCM_VOLUME, vol + (vol << 16)); 30 | } 31 | 32 | void loop() { 33 | static int cur, block = 0; 34 | // checking current position of DMA pointer and 35 | // updating the other half of the buffer 36 | INW(cur, IO_PCM_CUR); 37 | if ((cur & halfdma) != block) 38 | { 39 | // read(f, buf + block, 0x4000); 40 | block = cur & halfdma; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /libraries/PCM/examples/sine/sine.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | PCM pcm = PCM(); 5 | 6 | struct sample 7 | { 8 | int16_t ch[2]; // 0:left and 1:right channel, signed 16 bit integers 9 | }; 10 | 11 | // crude malloc() 12 | volatile struct sample *buf = (volatile struct sample *) 0x80080000; 13 | int buflen = 1<<13; // number of samples, halfdma code easier if power of 2 14 | int halfdma = buflen*sizeof(struct sample)/2; 15 | 16 | void setup() { 17 | // set audio parameters 18 | int i, vol = 21000, rate = 22050; 19 | pcm.dma((uint32_t *)buf, buflen); 20 | pcm.rate(rate); 21 | pcm.volume(0,0); 22 | for(i = 0; i < buflen; i++) 23 | { 24 | int16_t left = 32767 * sin(2*M_PI/buflen * i * 200); 25 | int16_t right = 32767 * sin(2*M_PI/buflen * i * 201); 26 | buf[i].ch[0] = left; 27 | buf[i].ch[1] = right; 28 | } 29 | pcm.volume(vol, vol); 30 | } 31 | 32 | void loop() { 33 | static int cur, block = 0; 34 | // checking current position of DMA pointer and 35 | // updating the other half of the buffer 36 | cur = pcm.current(); 37 | if ((cur & halfdma) != block) 38 | { 39 | // read(f, buf + block, 0x4000); 40 | block = cur & halfdma; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /libraries/PID/PID.h: -------------------------------------------------------------------------------- 1 | struct PID_s 2 | { 3 | int sp:24; unsigned int dummy1:8; 4 | int d:6; unsigned int dummy2:2; 5 | int i:6; unsigned int dummy3:2; 6 | int p:6; unsigned int dummy4:2; 7 | unsigned int dummy5:8; 8 | int out:12; unsigned int dummy6:20; 9 | int pv:24; unsigned int dummy7:8; 10 | }; 11 | 12 | volatile PID_s *PID = (volatile struct PID_s *) 0xFFFFFD80; 13 | -------------------------------------------------------------------------------- /libraries/PID/examples/PID/PID.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define N 4 4 | 5 | void PID_print(int i) 6 | { 7 | char line[255]; 8 | 9 | sprintf(line, "PID%d SP=%9d PV=%9d P=%3d I=%3d D=%3d OUT=%5d", 10 | i, PID[i].sp, PID[i].pv, PID[i].p, PID[i].i, PID[i].d, PID[i].out 11 | ); 12 | Serial.println(line); 13 | } 14 | 15 | void PID_hex(void) 16 | { 17 | char line[255]; 18 | uint32_t *rp = (uint32_t *) PID; 19 | 20 | for(int j = 0; j < 4; j++) 21 | { 22 | sprintf(line, "PID%d %08x", 23 | j, rp[j] 24 | ); 25 | Serial.println(line); 26 | } 27 | } 28 | 29 | void setup() { 30 | int i; 31 | 32 | for(i = 0; i < N; i++) 33 | { 34 | PID[i].sp = 0; 35 | PID[i].p = 6; 36 | PID[i].i = 13; 37 | PID[i].d = -3; 38 | } 39 | Serial.begin(115200); 40 | } 41 | 42 | void loop() { 43 | int ip; 44 | static int sp, state; 45 | int phase; 46 | int interval = 6; 47 | int jump[4] = {10000, -10000, 11000, -11000}; 48 | 49 | for(ip = 0; ip < N; ip++) 50 | { 51 | phase = state & ((1<> interval) & 1 ? -jump[ip] : jump[ip]; 57 | if(phase < 8) 58 | PID_print(ip); 59 | } 60 | delay(200); 61 | state++; 62 | } 63 | -------------------------------------------------------------------------------- /libraries/RCSwitch/RCSwitch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/libraries/RCSwitch/RCSwitch.cpp -------------------------------------------------------------------------------- /libraries/RCSwitch/RCSwitch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/libraries/RCSwitch/RCSwitch.h -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/Garage/Garage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for different sending methods 3 | 4 | http://code.google.com/p/rc-switch/ 5 | 6 | F32C setup 7 | Bitstream: ulx2s_8e_mips_bram_433M92_25mhz.jed 8 | Boards manager -> Generic FPGA Board 9 | CPU Architecture: MIPS 10 | CPU Speed: 25 MHz 11 | RAM Size: 16KB BRAM Internal 12 | Protocol: HEX 115.2 kbit/s no verify RS232 13 | PIN Map: Generic 14 | */ 15 | 16 | #include 17 | 18 | RCSwitch mySwitch; 19 | 20 | #define TX433 15 21 | #define LED 13 22 | 23 | enum {BUTTON_DOWN = 1, BUTTON_UP = 2}; 24 | 25 | #define EW_UP1 "111110000000001111110000001000000011111100000110000000001" 26 | #define EW_UP2 "000000111111111111110000000010000000000011111000000111111" 27 | void setup() { 28 | Serial.begin(115200); 29 | 30 | // Transmitter is connected to Arduino Pin #10 31 | mySwitch.enableTransmit(TX433); 32 | 33 | // Optional set protocol (default is 1, will work for most outlets) 34 | mySwitch.setProtocol(5); 35 | 36 | // Optional set pulse length. 37 | mySwitch.setPulseLength(220); 38 | 39 | // Optional set number of transmission repetitions. 40 | mySwitch.setRepeatTransmit(1); 41 | } 42 | 43 | void loop() { 44 | if(digitalRead(BUTTON_DOWN)) 45 | { 46 | /* down */ 47 | digitalWrite(LED, HIGH); 48 | /* Same switch as above, but using binary code */ 49 | // mySwitch.send(EW_DOWN); 50 | digitalWrite(LED, LOW); 51 | } 52 | 53 | if(digitalRead(BUTTON_UP)) 54 | { 55 | /* up */ 56 | digitalWrite(LED, HIGH); 57 | /* Same switch as above, but using binary code */ 58 | mySwitch.send(EW_UP1); 59 | mySwitch.send(EW_UP2); 60 | digitalWrite(LED, LOW); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/ReceiveDemo_Advanced/ReceiveDemo_Advanced.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Example for receiving 3 | 4 | http://code.google.com/p/rc-switch/ 5 | 6 | If you want to visualize a telegram copy the raw data and 7 | paste it into http://test.sui.li/oszi/ 8 | */ 9 | 10 | #include 11 | 12 | RCSwitch mySwitch = RCSwitch(); 13 | 14 | void setup() { 15 | Serial.begin(9600); 16 | mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2 17 | } 18 | 19 | void loop() { 20 | if (mySwitch.available()) { 21 | output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); 22 | mySwitch.resetAvailable(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/ReceiveDemo_Advanced/helperfunctions.ino: -------------------------------------------------------------------------------- 1 | static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength){ 2 | static char bin[64]; 3 | unsigned int i=0; 4 | 5 | while (Dec > 0) { 6 | bin[32+i++] = (Dec & 1 > 0) ? '1' : '0'; 7 | Dec = Dec >> 1; 8 | } 9 | 10 | for (unsigned int j = 0; j< bitLength; j++) { 11 | if (j >= bitLength - i) { 12 | bin[j] = bin[ 31 + i - (j - (bitLength - i)) ]; 13 | }else { 14 | bin[j] = '0'; 15 | } 16 | } 17 | bin[bitLength] = '\0'; 18 | 19 | return bin; 20 | } 21 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/ReceiveDemo_Advanced/output.ino: -------------------------------------------------------------------------------- 1 | void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) { 2 | 3 | if (decimal == 0) { 4 | Serial.print("Unknown encoding."); 5 | } else { 6 | char* b = dec2binWzerofill(decimal, length); 7 | Serial.print("Decimal: "); 8 | Serial.print(decimal); 9 | Serial.print(" ("); 10 | Serial.print( length ); 11 | Serial.print("Bit) Binary: "); 12 | Serial.print( b ); 13 | Serial.print(" Tri-State: "); 14 | Serial.print( bin2tristate( b) ); 15 | Serial.print(" PulseLength: "); 16 | Serial.print(delay); 17 | Serial.print(" microseconds"); 18 | Serial.print(" Protocol: "); 19 | Serial.println(protocol); 20 | } 21 | 22 | Serial.print("Raw data: "); 23 | for (int i=0; i<= length*2; i++) { 24 | Serial.print(raw[i]); 25 | Serial.print(","); 26 | } 27 | Serial.println(); 28 | Serial.println(); 29 | } 30 | 31 | 32 | static char* bin2tristate(char* bin) { 33 | char returnValue[50]; 34 | int pos = 0; 35 | int pos2 = 0; 36 | while (bin[pos]!='\0' && bin[pos+1]!='\0') { 37 | if (bin[pos]=='0' && bin[pos+1]=='0') { 38 | returnValue[pos2] = '0'; 39 | } else if (bin[pos]=='1' && bin[pos+1]=='1') { 40 | returnValue[pos2] = '1'; 41 | } else if (bin[pos]=='0' && bin[pos+1]=='1') { 42 | returnValue[pos2] = 'F'; 43 | } else { 44 | return "not applicable"; 45 | } 46 | pos = pos+2; 47 | pos2++; 48 | } 49 | returnValue[pos2] = '\0'; 50 | return returnValue; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/ReceiveDemo_Simple/ReceiveDemo_Simple.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Simple example for receiving 3 | 4 | http://code.google.com/p/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2 14 | } 15 | 16 | void loop() { 17 | if (mySwitch.available()) { 18 | 19 | int value = mySwitch.getReceivedValue(); 20 | 21 | if (value == 0) { 22 | Serial.print("Unknown encoding"); 23 | } else { 24 | Serial.print("Received "); 25 | Serial.print( mySwitch.getReceivedValue() ); 26 | Serial.print(" / "); 27 | Serial.print( mySwitch.getReceivedBitlength() ); 28 | Serial.print("bit "); 29 | Serial.print("Protocol: "); 30 | Serial.println( mySwitch.getReceivedProtocol() ); 31 | } 32 | 33 | mySwitch.resetAvailable(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/Role/Role.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for different sending methods 3 | 4 | http://code.google.com/p/rc-switch/ 5 | 6 | F32C setup 7 | Bitstream: ulx2s_8e_mips_bram_433_25mhz.jed 8 | Boards manager -> Generic FPGA Board 9 | CPU Architecture: MIPS 10 | CPU Speed: 25 MHz 11 | RAM Size: 16KB BRAM Internal 12 | Protocol: HEX 115.2 kbit/s no verify RS232 13 | PIN Map: Generic 14 | */ 15 | 16 | #include 17 | 18 | RCSwitch mySwitch; 19 | 20 | #define TX433 15 21 | #define LED 13 22 | 23 | enum {BUTTON_DOWN = 1, BUTTON_UP = 2}; 24 | 25 | #define EW_UP "011000100110" 26 | #define EW_DOWN "011000100101" 27 | 28 | void setup() { 29 | Serial.begin(115200); 30 | 31 | // Transmitter is connected to Arduino Pin #10 32 | mySwitch.enableTransmit(TX433); 33 | 34 | // Optional set protocol (default is 1, will work for most outlets) 35 | mySwitch.setProtocol(4); 36 | 37 | // Optional set pulse length. 38 | mySwitch.setPulseLength(37); 39 | 40 | // Optional set number of transmission repetitions. 41 | mySwitch.setRepeatTransmit(1); 42 | } 43 | 44 | void loop() { 45 | if(digitalRead(BUTTON_DOWN)) 46 | { 47 | /* down */ 48 | digitalWrite(LED, HIGH); 49 | /* Same switch as above, but using binary code */ 50 | mySwitch.send(EW_DOWN); 51 | digitalWrite(LED, LOW); 52 | } 53 | 54 | if(digitalRead(BUTTON_UP)) 55 | { 56 | /* up */ 57 | digitalWrite(LED, HIGH); 58 | /* Same switch as above, but using binary code */ 59 | mySwitch.send(EW_UP); 60 | digitalWrite(LED, LOW); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/SendDemo/SendDemo.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Example for different sending methods 3 | 4 | http://code.google.com/p/rc-switch/ 5 | 6 | */ 7 | 8 | #include 9 | 10 | RCSwitch mySwitch = RCSwitch(); 11 | 12 | void setup() { 13 | 14 | Serial.begin(9600); 15 | 16 | // Transmitter is connected to Arduino Pin #10 17 | mySwitch.enableTransmit(10); 18 | 19 | // Optional set pulse length. 20 | // mySwitch.setPulseLength(320); 21 | 22 | // Optional set protocol (default is 1, will work for most outlets) 23 | // mySwitch.setProtocol(2); 24 | 25 | // Optional set number of transmission repetitions. 26 | // mySwitch.setRepeatTransmit(15); 27 | 28 | } 29 | 30 | void loop() { 31 | 32 | /* See Example: TypeA_WithDIPSwitches */ 33 | mySwitch.switchOn("11111", "00010"); 34 | delay(1000); 35 | mySwitch.switchOn("11111", "00010"); 36 | delay(1000); 37 | 38 | /* Same switch as above, but using decimal code */ 39 | mySwitch.send(5393, 24); 40 | delay(1000); 41 | mySwitch.send(5396, 24); 42 | delay(1000); 43 | 44 | /* Same switch as above, but using binary code */ 45 | mySwitch.send("000000000001010100010001"); 46 | delay(1000); 47 | mySwitch.send("000000000001010100010100"); 48 | delay(1000); 49 | 50 | /* Same switch as above, but tri-state code */ 51 | mySwitch.sendTriState("00000FFF0F0F"); 52 | delay(1000); 53 | mySwitch.sendTriState("00000FFF0FF0"); 54 | delay(1000); 55 | 56 | delay(20000); 57 | } 58 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/TypeA_WithDIPSwitches/TypeA_WithDIPSwitches.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Example for outlets which are configured with a 10 pole DIP switch. 3 | 4 | http://code.google.com/p/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #10 14 | mySwitch.enableTransmit(10); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the setting of the first 5 DIP switches. 25 | // In this example it's ON-ON-OFF-OFF-ON. 26 | // 27 | // The second parameter represents the setting of the last 5 DIP switches. 28 | // In this example the last 5 DIP switches are OFF-ON-OFF-ON-OFF. 29 | mySwitch.switchOn("11001", "01010"); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff("11001", "01010"); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/TypeA_WithDIPSwitches_Lightweight/TypeA_WithDIPSwitches_Lightweight.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This is a minimal sketch without using the library at all but only works for 3 | the 10 pole dip switch sockets. It saves a lot of memory and thus might be 4 | very useful to use with ATTinys :) 5 | 6 | http://code.google.com/p/rc-switch/ 7 | */ 8 | 9 | int RCLpin = 7; 10 | 11 | void setup() { 12 | pinMode(RCLpin, OUTPUT); 13 | } 14 | 15 | void loop() { 16 | RCLswitch(0b010001000001); // DIPs an Steckdose: 0100010000 An:01 17 | delay(2000); 18 | 19 | RCLswitch(0b010001000010); // DIPs an Steckdose: 0100010000 Aus:10 20 | delay(2000); 21 | } 22 | 23 | void RCLswitch(uint16_t code) { 24 | for (int nRepeat=0; nRepeat<6; nRepeat++) { 25 | for (int i=4; i<16; i++) { 26 | RCLtransmit(1,3); 27 | if (((code << (i-4)) & 2048) > 0) { 28 | RCLtransmit(1,3); 29 | } else { 30 | RCLtransmit(3,1); 31 | } 32 | } 33 | RCLtransmit(1,31); 34 | } 35 | } 36 | 37 | void RCLtransmit(int nHighPulses, int nLowPulses) { 38 | digitalWrite(RCLpin, HIGH); 39 | delayMicroseconds( 350 * nHighPulses); 40 | digitalWrite(RCLpin, LOW); 41 | delayMicroseconds( 350 * nLowPulses); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/TypeB_WithRotaryOrSlidingSwitches/TypeB_WithRotaryOrSlidingSwitches.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Example for outlets which are configured with two rotary/sliding switches. 3 | 4 | http://code.google.com/p/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #10 14 | mySwitch.enableTransmit(10); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the setting of the first rotary switch. 25 | // In this example it's switched to "1" or "A" or "I". 26 | // 27 | // The second parameter represents the setting of the second rotary switch. 28 | // In this example it's switched to "4" or "D" or "IV". 29 | mySwitch.switchOn(1, 4); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff(1, 4); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/TypeC_Intertechno/TypeC_Intertechno.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Example for Intertechno outlets 3 | 4 | http://code.google.com/p/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #15 14 | mySwitch.enableTransmit(15); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the familycode (a, b, c, ... f) 25 | // The second parameter represents the group number 26 | // The third parameter represents the device number 27 | // 28 | // In this example it's family 'b', group #3, device #2 29 | mySwitch.switchOn('b', 3, 2); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff('b', 3, 2); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } -------------------------------------------------------------------------------- /libraries/RCSwitch/examples/TypeD_REV/TypeD_REV.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for REV outlets (e.g. 8342L) 3 | 4 | http://code.google.com/p/rc-switch/ 5 | 6 | Need help? http://forum.ardumote.com 7 | */ 8 | 9 | #include 10 | 11 | 12 | // ULX2S SRAM 81.25MHz -> 433.33MHz transmitter is at physical pin 40 = arduino pin 15 13 | // ULX2S BRAM 25MHz -> 433.92MHz transmitter is at physical pin 40 = arduino pin 15 14 | // CPU clock in arduino must be set correctly (81.25MHz or 25MHz) for pulse timing to work 15 | int tx433 = 15; 16 | int led = 12; // indicator led is at physical pin 12 17 | 18 | RCSwitch mySwitch = RCSwitch(); 19 | 20 | void setup() { 21 | 22 | mySwitch.enableTransmit(tx433); 23 | 24 | // set pulse length. 25 | mySwitch.setPulseLength(360); 26 | 27 | } 28 | 29 | void loop() { 30 | 31 | // Switch on: 32 | // The first parameter represents the channel (a, b, c, d) 33 | // The second parameter represents the device number 34 | // 35 | // In this example it's channel 'a', device #2 36 | digitalWrite(led, HIGH); // indicator ON 37 | mySwitch.switchOn('a', 2); 38 | 39 | // Wait a second 40 | delay(1000); 41 | 42 | // Switch off 43 | digitalWrite(led, LOW); // indicator OFF 44 | mySwitch.switchOff('a', 2); 45 | 46 | // Wait another second 47 | delay(1000); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /libraries/RCSwitch/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For RCSwitch 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | RCSwitch KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | ########## 16 | #SENDS Begin 17 | ########## 18 | switchOn KEYWORD2 19 | switchOff KEYWORD2 20 | sendTriState KEYWORD2 21 | send KEYWORD2 22 | ########## 23 | #SENDS End 24 | ########## 25 | 26 | ########## 27 | #RECEIVE Begin 28 | ########## 29 | enableReceive KEYWORD2 30 | disableReceive KEYWORD2 31 | available KEYWORD2 32 | resetAvailable KEYWORD2 33 | setReceiveTolerance KEYWORD2 34 | getReceivedValue KEYWORD2 35 | getReceivedBitlength KEYWORD2 36 | getReceivedDelay KEYWORD2 37 | getReceivedProtocol KEYWORD2 38 | getReceivedRawdata KEYWORD2 39 | ########## 40 | #RECEIVE End 41 | ########## 42 | 43 | ########## 44 | #OTHERS Begin 45 | ########## 46 | enableTransmit KEYWORD2 47 | disableTransmit KEYWORD2 48 | setPulseLength KEYWORD2 49 | setProtocol KEYWORD2 50 | setRepeatTransmit KEYWORD2 51 | ########## 52 | #OTHERS End 53 | ########## 54 | 55 | ####################################### 56 | # Constants (LITERAL1) 57 | ####################################### 58 | -------------------------------------------------------------------------------- /libraries/RDS/examples/RDS/RDS.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This is a test program that dynamically updates RDS message. 3 | AUTHOR=EMARD 4 | LICENSE=GPL 5 | */ 6 | 7 | #include 8 | 9 | RDS rds = RDS(); 10 | 11 | uint16_t pi = 0xCAFE; 12 | char ps[9] = "TEST1234"; 13 | char rt[65] = "ABCDEFGH"; 14 | 15 | void setup() { 16 | int i; 17 | for(i = 0; i < sizeof(rt)-1; i++) 18 | rt[i] = '@'+i; // ascii map 19 | /* Setup initial RDS text */ 20 | rds.pi(pi); // station numeric ID 21 | rds.stereo(0); // 0-Inform over RDS that we send Mono, 1-Stereo 22 | rds.ta(0); // 0-No, 1-Traffice Announcements 23 | rds.ps(ps); // 8-char text, displayed as station name 24 | rds.rt(rt); // 64-char text, not every radio displays it 25 | rds.Hz(107900000); // Hz carrier wave frequency 26 | rds.length(260); // bytes message length (260 default) 27 | Serial.begin(115200); 28 | } 29 | 30 | void loop() 31 | { 32 | static uint8_t number; 33 | 34 | snprintf(ps, sizeof(ps), "TEST%04d", number % 10000); 35 | snprintf(rt, sizeof(rt), "%05d Zzz...", number % 100000); 36 | 37 | // send strings for transmission 38 | rds.ps(ps); 39 | rds.rt(rt); 40 | // rds.ct(2015,7,22,15,30,900); 41 | 42 | // print actual status on serial 43 | Serial.print("0x"); 44 | Serial.print(pi, HEX); 45 | Serial.print(" "); 46 | Serial.print(ps); 47 | Serial.print(" "); 48 | Serial.println(rt); 49 | 50 | delay(2000); // wait 2 seconds 51 | number++; // increment number 52 | } 53 | -------------------------------------------------------------------------------- /libraries/RDS/examples/RDSdebug/RDSdebug.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This is a test program that dynamically updates RDS message. 3 | AUTHOR=EMARD 4 | LICENSE=GPL 5 | */ 6 | 7 | #include 8 | 9 | RDS rds = RDS(); 10 | 11 | uint16_t pi = 0xCAFE; 12 | char ps[9] = "TEST1234"; 13 | char rt[65] = "ABCDEFGH"; 14 | 15 | void setup() { 16 | int i; 17 | for(i = 0; i < sizeof(rt)-1; i++) 18 | rt[i] = '@'+i; // ascii map 19 | /* Setup initial RDS text */ 20 | rds.set_pi(pi); // station numeric ID 21 | rds.set_ps(ps); // 8-char text, displayed as station name 22 | rds.set_rt(rt); // 64-char text, not every radio displays it 23 | Serial.begin(115200); 24 | } 25 | 26 | struct rdsdebug { 27 | int rds:7, dummy1:1; 28 | int pilot:7, dummy2:1; 29 | int stereo:7, dummy3:1; 30 | }; 31 | 32 | void loop() 33 | { 34 | static uint8_t number; 35 | char line[100]; 36 | volatile uint32_t *rdsdebug = (volatile uint32_t *)0xFFFFFC00; 37 | int8_t rds, pilot, stereo; 38 | volatile struct rdsdebug *debug = (volatile struct rdsdebug *)rdsdebug; 39 | 40 | 41 | snprintf(line, sizeof(line), 42 | "%08x stereo=%3d pilot=%3d rds=%3d", 43 | *rdsdebug, debug->stereo, debug->pilot, debug->rds); 44 | Serial.println(line); 45 | 46 | delay(10); // wait 2 seconds 47 | number++; // increment number 48 | } 49 | -------------------------------------------------------------------------------- /libraries/SD/README.adoc: -------------------------------------------------------------------------------- 1 | = SD Library for Arduino = 2 | 3 | The SD library allows for reading from and writing to SD cards. 4 | 5 | For more information about this library please visit us at 6 | http://www.arduino.cc/en/Reference/SD 7 | 8 | == License == 9 | 10 | Copyright (C) 2009 by William Greiman 11 | Copyright (c) 2010 SparkFun Electronics 12 | 13 | This program is free software: you can redistribute it and/or modify 14 | it under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | This program is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU General Public License for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with this program. If not, see . 25 | -------------------------------------------------------------------------------- /libraries/SD/examples/DumpFile/DumpFile.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card file dump 3 | 4 | This example shows how to read a file from the SD card using the 5 | SD library and send it over the serial port. 6 | 7 | The circuit: 8 | * SD card attached to SPI bus as follows: 9 | ** MOSI - pin 11 10 | ** MISO - pin 12 11 | ** CLK - pin 13 12 | ** CS - pin 4 13 | 14 | created 22 December 2010 15 | by Limor Fried 16 | modified 9 Apr 2012 17 | by Tom Igoe 18 | 19 | This example code is in the public domain. 20 | 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | const int chipSelect = 4; 27 | 28 | void setup() 29 | { 30 | // Open serial communications and wait for port to open: 31 | Serial.begin(9600); 32 | while (!Serial) { 33 | ; // wait for serial port to connect. Needed for Leonardo only 34 | } 35 | 36 | 37 | Serial.print("Initializing SD card..."); 38 | 39 | // see if the card is present and can be initialized: 40 | if (!SD.begin(chipSelect)) { 41 | Serial.println("Card failed, or not present"); 42 | // don't do anything more: 43 | return; 44 | } 45 | Serial.println("card initialized."); 46 | 47 | // open the file. note that only one file can be open at a time, 48 | // so you have to close this one before opening another. 49 | File dataFile = SD.open("datalog.txt"); 50 | 51 | // if the file is available, write to it: 52 | if (dataFile) { 53 | while (dataFile.available()) { 54 | Serial.write(dataFile.read()); 55 | } 56 | dataFile.close(); 57 | } 58 | // if the file isn't open, pop up an error: 59 | else { 60 | Serial.println("error opening datalog.txt"); 61 | } 62 | } 63 | 64 | void loop() 65 | { 66 | } 67 | 68 | -------------------------------------------------------------------------------- /libraries/SD/examples/Files/Files.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card basic file example 3 | 4 | This example shows how to create and destroy an SD card file 5 | The circuit: 6 | * SD card attached to SPI bus as follows: 7 | ** MOSI - pin 11 8 | ** MISO - pin 12 9 | ** CLK - pin 13 10 | ** CS - pin 4 11 | 12 | created Nov 2010 13 | by David A. Mellis 14 | modified 9 Apr 2012 15 | by Tom Igoe 16 | 17 | This example code is in the public domain. 18 | 19 | */ 20 | #include 21 | #include 22 | 23 | File myFile; 24 | 25 | void setup() 26 | { 27 | // Open serial communications and wait for port to open: 28 | Serial.begin(9600); 29 | while (!Serial) { 30 | ; // wait for serial port to connect. Needed for Leonardo only 31 | } 32 | 33 | 34 | Serial.print("Initializing SD card..."); 35 | 36 | if (!SD.begin(4)) { 37 | Serial.println("initialization failed!"); 38 | return; 39 | } 40 | Serial.println("initialization done."); 41 | 42 | if (SD.exists("example.txt")) { 43 | Serial.println("example.txt exists."); 44 | } 45 | else { 46 | Serial.println("example.txt doesn't exist."); 47 | } 48 | 49 | // open a new file and immediately close it: 50 | Serial.println("Creating example.txt..."); 51 | myFile = SD.open("example.txt", FILE_WRITE); 52 | myFile.close(); 53 | 54 | // Check to see if the file exists: 55 | if (SD.exists("example.txt")) { 56 | Serial.println("example.txt exists."); 57 | } 58 | else { 59 | Serial.println("example.txt doesn't exist."); 60 | } 61 | 62 | // delete the file: 63 | Serial.println("Removing example.txt..."); 64 | SD.remove("example.txt"); 65 | 66 | if (SD.exists("example.txt")) { 67 | Serial.println("example.txt exists."); 68 | } 69 | else { 70 | Serial.println("example.txt doesn't exist."); 71 | } 72 | } 73 | 74 | void loop() 75 | { 76 | // nothing happens after setup finishes. 77 | } 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /libraries/SD/examples/listfiles/listfiles.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Listfiles 3 | 4 | This example shows how print out the files in a 5 | directory on a SD card 6 | 7 | The circuit: 8 | * SD card attached to SPI bus as follows: 9 | ** MOSI - pin 11 10 | ** MISO - pin 12 11 | ** CLK - pin 13 12 | ** CS - pin 4 13 | 14 | created Nov 2010 15 | by David A. Mellis 16 | modified 9 Apr 2012 17 | by Tom Igoe 18 | modified 2 Feb 2014 19 | by Scott Fitzgerald 20 | 21 | This example code is in the public domain. 22 | 23 | */ 24 | #include 25 | #include 26 | 27 | File root; 28 | 29 | void setup() 30 | { 31 | // Open serial communications and wait for port to open: 32 | Serial.begin(9600); 33 | while (!Serial) { 34 | ; // wait for serial port to connect. Needed for Leonardo only 35 | } 36 | 37 | Serial.print("Initializing SD card..."); 38 | 39 | if (!SD.begin(4)) { 40 | Serial.println("initialization failed!"); 41 | return; 42 | } 43 | Serial.println("initialization done."); 44 | 45 | root = SD.open("/"); 46 | 47 | printDirectory(root, 0); 48 | 49 | Serial.println("done!"); 50 | } 51 | 52 | void loop() 53 | { 54 | // nothing happens after setup finishes. 55 | } 56 | 57 | void printDirectory(File dir, int numTabs) { 58 | while(true) { 59 | 60 | File entry = dir.openNextFile(); 61 | if (! entry) { 62 | // no more files 63 | break; 64 | } 65 | for (uint8_t i=0; i 5 | sentence=Enables reading and writing on SD cards. For all Arduino boards. 6 | paragraph=Once an SD memory card is connected to the SPI interfare of the Arduino board you are enabled to create files and read/write on them. You can also move through directories on the SD card. 7 | category=Data Storage 8 | url=http://www.arduino.cc/en/Reference/SD 9 | architectures=* 10 | -------------------------------------------------------------------------------- /libraries/SD/src/README.txt: -------------------------------------------------------------------------------- 1 | 2 | ** SD - a slightly more friendly wrapper for sdfatlib ** 3 | 4 | This library aims to expose a subset of SD card functionality in the 5 | form of a higher level "wrapper" object. 6 | 7 | License: GNU General Public License V3 8 | (Because sdfatlib is licensed with this.) 9 | 10 | (C) Copyright 2010 SparkFun Electronics 11 | 12 | Now better than ever with optimization, multiple file support, directory handling, etc - ladyada! 13 | 14 | -------------------------------------------------------------------------------- /libraries/SD/src/utility/dirty_workaround.h: -------------------------------------------------------------------------------- 1 | #ifndef _DIRTY_WORKAROUND_H_ 2 | #define _DIRTY_WORKAROUND_H_ 3 | #define __arm__ 4 | 5 | #if 1 6 | #define SCK 24 7 | #define SS 25 8 | #define MOSI 26 9 | #define MISO 5 10 | #define softdelay() 11 | #endif 12 | 13 | // #define SOFTWARE_SPI 14 | 15 | #define cli() noInterrupts() 16 | #define sei() interrupts() 17 | #define fastDigitalWrite(a,b) digitalWrite(a,b) 18 | #define fastDigitalRead(a) digitalRead(a) 19 | #endif 20 | -------------------------------------------------------------------------------- /libraries/SPI/SPI.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | SPIClass::SPIClass(uint8_t spi_bus) 5 | :_spi_num(spi_bus) 6 | ,_spi(NULL) 7 | ,_ss(-1) 8 | ,_freq(1) // default is minimum SPI speed, about 400 kHz 9 | {} 10 | 11 | void SPIClass::begin(int8_t ss) 12 | { 13 | _ss = ss; 14 | _spi = (volatile uint16_t *)(0xFFFFFB40 + (_spi_num * 0x10)); 15 | ((volatile uint8_t *)_spi)[1] = _freq; 16 | } 17 | 18 | void SPIClass::end() { 19 | } 20 | 21 | void SPIClass::setClock(uint32_t clock) 22 | { 23 | _freq = (uint8_t)(clock/(F_CPU/256)); 24 | ((volatile uint8_t *)_spi)[1] = _freq; 25 | SPI_NOP; 26 | } 27 | 28 | void SPIClass::setBitOrder(uint8_t bitOrder) { 29 | } 30 | 31 | void SPIClass::setDataMode(uint8_t dataMode) { 32 | } 33 | 34 | uint8_t SPIClass::transfer(uint8_t _data) 35 | { 36 | uint32_t in; 37 | ((volatile uint8_t *)_spi)[0] = _data; 38 | do { 39 | in = *_spi; 40 | SPI_NOP; 41 | } while ((in & SPI_READY_MASK) == 0); 42 | 43 | #if (_BYTE_ORDER == _LITTLE_ENDIAN) 44 | return (in & 0xff); 45 | #else 46 | return (in >> 24); 47 | #endif 48 | } 49 | 50 | void SPIClass::set_pin(uint8_t pin) 51 | { 52 | if (_spi_num == SPI_EXT) { 53 | digitalWrite(pin, LOW); 54 | } 55 | } 56 | 57 | void SPIClass::unset_pin(uint8_t pin) 58 | { 59 | if (_spi_num == SPI_EXT) { 60 | digitalWrite(pin, HIGH); 61 | } 62 | } 63 | 64 | void SPIClass::beginTransaction(SPISettings settings) { 65 | setClock(settings._clock); 66 | beginTransaction(); 67 | } 68 | 69 | void SPIClass::beginTransaction() { 70 | ((volatile uint8_t *)_spi)[1] = 0x80; 71 | while ((*_spi & SPI_READY_MASK) == 0); 72 | ((volatile uint8_t *)_spi)[1] = _freq; 73 | unset_pin(_ss); 74 | } 75 | 76 | void SPIClass::endTransaction() { 77 | set_pin(_ss); 78 | } 79 | -------------------------------------------------------------------------------- /libraries/SPI/examples/Flash_ID/Flash_ID.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | SPIClass SPI_flash(SPI_FLASH); 4 | 5 | void setup(void) 6 | { 7 | Serial.begin(115200); 8 | Serial.println("Startup"); 9 | delay(1000); 10 | SPI_flash.begin(11); 11 | delay(1000); 12 | } 13 | 14 | void leading_zero_hex(uint8_t _value) { 15 | if (_value < 0x10) { 16 | Serial.print("0"); 17 | } 18 | Serial.print(_value, HEX); 19 | } 20 | 21 | void flash_id(void) 22 | { 23 | SPI_flash.beginTransaction(); 24 | SPI_flash.transfer(0x9F); 25 | leading_zero_hex(SPI_flash.transfer(0x00)); 26 | leading_zero_hex(SPI_flash.transfer(0x00)); 27 | leading_zero_hex(SPI_flash.transfer(0x00)); 28 | SPI_flash.endTransaction(); 29 | } 30 | 31 | void loop(void) 32 | { 33 | Serial.println("##############################"); 34 | delay(500); 35 | Serial.print("FLASH ID: 0x"); 36 | flash_id(); 37 | Serial.println('\0'); 38 | Serial.println("##############################"); 39 | delay(1000); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /libraries/SPI/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map SPI 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SPI KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | begin KEYWORD2 15 | end KEYWORD2 16 | transfer KEYWORD2 17 | setBitOrder KEYWORD2 18 | setDataMode KEYWORD2 19 | setClockDivider KEYWORD2 20 | setMOSI KEYWORD2 21 | setMISO KEYWORD2 22 | setSCK KEYWORD2 23 | usingInterrupt KEYWORD2 24 | beginTransaction KEYWORD2 25 | endTransaction KEYWORD2 26 | SPISettings KEYWORD2 27 | 28 | ####################################### 29 | # Constants (LITERAL1) 30 | ####################################### 31 | SPI_CLOCK_DIV4 LITERAL1 32 | SPI_CLOCK_DIV16 LITERAL1 33 | SPI_CLOCK_DIV64 LITERAL1 34 | SPI_CLOCK_DIV128 LITERAL1 35 | SPI_CLOCK_DIV2 LITERAL1 36 | SPI_CLOCK_DIV8 LITERAL1 37 | SPI_CLOCK_DIV32 LITERAL1 38 | SPI_MODE0 LITERAL1 39 | SPI_MODE1 LITERAL1 40 | SPI_MODE2 LITERAL1 41 | SPI_MODE3 LITERAL1 42 | -------------------------------------------------------------------------------- /libraries/SoftwareWire/examples/Small_example/Small_example.ino: -------------------------------------------------------------------------------- 1 | // I2C Digital Potentiometer 2 | // by Nicholas Zambetti 3 | // and Shawn Bonkowski 4 | 5 | // Demonstrates use of the Wire library 6 | // Controls AD5171 digital potentiometer via I2C/TWI 7 | 8 | // Created 31 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | // --------------------------------- 13 | // Example from : http://www.arduino.cc/en/Tutorial/DigitalPotentiometer 14 | // Adapted to show usage of the SoftwareWire library 15 | // --------------------------------- 16 | 17 | #include 18 | 19 | // SoftwareWire constructor. 20 | // Parameters: 21 | // (1) pin for the software sda 22 | // (2) pin for the software scl 23 | // (3) use internal pullup resistors. Default true. Set to false to disable them. 24 | // (4) allow the Slave to stretch the clock pulse. Default true. Set to false for faster code. 25 | // 26 | // Using pin 32 (software sda) and 33 (software scl) in this example. 27 | 28 | SoftwareWire myWire( 32, 33); 29 | 30 | void setup() 31 | { 32 | myWire.setClock(100000L); // Hz set I2C clock speed 33 | myWire.begin(); // join i2c bus (address optional for master) 34 | } 35 | 36 | byte val = 0; 37 | 38 | void loop() 39 | { 40 | myWire.beginTransmission(44); // transmit to device #44 (0x2c) 41 | // device address is specified in datasheet 42 | myWire.write(byte(0x00)); // sends instruction byte 43 | myWire.write(val); // sends potentiometer value byte 44 | myWire.endTransmission(); // stop transmitting 45 | 46 | val++; // increment value 47 | if(val == 64) // if reached 64th position (max) 48 | { 49 | val = 0; // start over from lowest value 50 | } 51 | delay(500); 52 | } 53 | -------------------------------------------------------------------------------- /libraries/SoftwareWire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For SoftwareWire 3 | ####################################### 4 | # Datatypes (KEYWORD1) 5 | ####################################### 6 | 7 | SoftwareWire KEYWORD1 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | setPins KEYWORD2 14 | beginTransmission KEYWORD2 15 | write KEYWORD2 16 | requestFrom KEYWORD2 17 | read KEYWORD2 18 | 19 | ####################################### 20 | # Constants (LITERAL1) 21 | ####################################### 22 | 23 | -------------------------------------------------------------------------------- /libraries/SoftwareWire/library.properties: -------------------------------------------------------------------------------- 1 | name=SoftwareWire 2 | version=1.3.2 3 | author=Testato, Koepel 4 | maintainer=Testato 5 | sentence=Creates a software I2C/TWI bus on every pins. 6 | paragraph=The SoftwareWire is only I2C Master mode. More than one software I2C bus can be created. The clock pulse stretching is implemented, so the Slave can be another Arduino board 7 | category=Device Control 8 | url=https://github.com/Testato/SoftwareWire 9 | architectures=* -------------------------------------------------------------------------------- /libraries/TTS/TTS.h: -------------------------------------------------------------------------------- 1 | /* 2 | Text To Speech syntesis library 3 | Copyright (c) 2008 Clive Webster. All rights reserved. 4 | Nov. 29th 2009 - Modified to work with Arduino by Gabriel Petrut. 5 | */ 6 | 7 | /* 8 | The Text To Speech library uses Timer1 to generate the PWM 9 | output on digital pin 10. The output signal needs to be fed 10 | to an RC filter then through an amplifier to the speaker. 11 | */ 12 | 13 | #ifndef TTS_h 14 | #define TTS_h 15 | 16 | #include 17 | #include 18 | #include "english.h" 19 | 20 | class TTS 21 | { 22 | private: 23 | 24 | public: 25 | TTS(); 26 | void say(const char * ); 27 | void speak(const char * ); 28 | void setPitch(byte pitch); 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libraries/TTS/examples/TTS-FM/TTS-FM.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Text To Speech syntesis library 3 | Copyright (c) 2008 Clive Webster. All rights reserved. 4 | Nov. 29th 2009 - Modified to work with Arduino by Gabriel Petrut. 5 | */ 6 | 7 | /* 8 | On AVR The Text To Speech library uses Timer1 to generate the PWM 9 | output on digital pin 10. The output signal needs to be fed 10 | to an RC filter then through an amplifier to the speaker. 11 | 12 | On F32C it uses PCM over DMA to play sound. 13 | (Only SRAM and SDRAM based boards have enough memory for PCM) 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | // Media pins 21 | #define ledPin 13 // LED standard on digital pin 13 22 | 23 | // Variables 24 | char text [50]; 25 | boolean state=0; 26 | 27 | TTS text2speech; 28 | RDS rds; // FM radio 29 | 30 | void setup() { 31 | rds.Hz(107900000); // Hz carrier wave frequency 32 | pinMode(ledPin, OUTPUT); 33 | Serial.begin(115200); 34 | } 35 | 36 | //================================================================ 37 | // Main Loop 38 | //================================================================ 39 | void loop(){ 40 | state = !state; 41 | digitalWrite(ledPin, state); 42 | Test_Speech(); 43 | } 44 | //================================================================ 45 | 46 | 47 | void Test_Speech() { 48 | text2speech.setPitch(6); //higher values = lower voice pitch 49 | strcpy(text, "Hello master! How are you doing?"); 50 | Serial.println(text); 51 | text2speech.say(text); 52 | delay(500); 53 | text2speech.setPitch(1); //lower values = higher voice pitch 54 | strcpy(text, "I am fine, thankyou."); 55 | Serial.println(text); 56 | text2speech.say(text); 57 | delay(1000); // delay a second 58 | } 59 | 60 | -------------------------------------------------------------------------------- /libraries/TTS/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Test 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | TTS KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | say KEYWORD2 16 | speak KEYWORD2 17 | setPitch KEYWORD2 18 | 19 | 20 | ####################################### 21 | # Constants (LITERAL1) 22 | ####################################### 23 | -------------------------------------------------------------------------------- /libraries/ULX2S/examples/fprog/fprog.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SPI flasher 3 | ----------- 4 | 5 | On fat32 formatted SD card, 6 | in the root directoy make a 7 | binary file: 8 | 9 | ulx2s_4m.img (length: 4194304 bytes, 4MB) 10 | 11 | fprog will copy content of this file 12 | to oboard SPI flash 13 | */ 14 | 15 | extern "C" { 16 | #include "fprog.h" 17 | } 18 | 19 | void setup(void) 20 | { 21 | Serial.begin(115200); 22 | Serial.println("Searching for SD card file ulx2s_4m.img"); 23 | Serial.println("4194304 bytes will be written to SPI flash"); 24 | fprog(); 25 | } 26 | 27 | void loop(void) 28 | { 29 | } 30 | -------------------------------------------------------------------------------- /libraries/ULX2S/fprog.h: -------------------------------------------------------------------------------- 1 | #ifndef FPROG_H 2 | #define FPROG_H 3 | 4 | void fprog(void); 5 | #endif 6 | -------------------------------------------------------------------------------- /libraries/Vector/Vector.h: -------------------------------------------------------------------------------- 1 | #ifndef VECTOR_H 2 | #define VECTOR_H 3 | 4 | #include 5 | #include "Vector_RAM.h" 6 | #include "Vector_REG.h" 7 | 8 | extern "C" 9 | { 10 | #include "vector_link.h" 11 | } 12 | 13 | class Vector 14 | { 15 | private: 16 | uint8_t vector_present; 17 | 18 | public: 19 | Vector(); 20 | void dumpreg(); 21 | volatile struct vector_header_s *create(int n); 22 | volatile struct vector_header_s *create(int n,int seglen); 23 | void print(struct vector_header_s *v); 24 | void io(int i, struct vector_header_s *vh, int store_mode); 25 | void oper(int a, int b, int c, int oper); 26 | void range(int i, uint16_t start, uint16_t stop); 27 | void load(int i, struct vector_header_s *vh); 28 | void store(struct vector_header_s *vh, int i); 29 | void add(int a, int b, int c); 30 | void sub(int a, int b, int c); 31 | void mul(int a, int b, int c); 32 | void div(int a, int b, int c); 33 | void f2i(int a, int b); 34 | void i2f(int a, int b); 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libraries/Vector/Vector_RAM.h: -------------------------------------------------------------------------------- 1 | #ifndef VECTOR_RAM_H 2 | #define VECTOR_RAM_H 3 | 4 | #include 5 | #include "Vector_REG.h" 6 | 7 | extern "C" 8 | { 9 | #include "vector_link.h" 10 | } 11 | 12 | class Vector_RAM 13 | { 14 | public: 15 | volatile struct vector_header_s *vh; 16 | Vector_RAM(int length) // create RAM-based vector 17 | { 18 | vh = create_segmented_vector(length, 0); 19 | } 20 | // vector store to RAM 21 | Vector_RAM& operator = (const class Vector_REG& rhs); 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libraries/Vector/goldschmidt.h: -------------------------------------------------------------------------------- 1 | #ifndef GOLDSCHMIDT_H 2 | #define GOLDSCHMIDT_H 3 | #include "vector_link.h" 4 | void divide_goldschmidt(union ifloat_u *result, union ifloat_u *x, union ifloat_u *y); 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino: -------------------------------------------------------------------------------- 1 | // I2C Digital Potentiometer 2 | // by Nicholas Zambetti 3 | // and Shawn Bonkowski 4 | 5 | // Demonstrates use of the Wire library 6 | // Controls AD5171 digital potentiometer via I2C/TWI 7 | 8 | // Created 31 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | // This example code is in the public domain. 13 | 14 | 15 | #include 16 | 17 | void setup() 18 | { 19 | Wire.begin(); // join i2c bus (address optional for master) 20 | } 21 | 22 | byte val = 0; 23 | 24 | void loop() 25 | { 26 | Wire.beginTransmission(44); // transmit to device #44 (0x2c) 27 | // device address is specified in datasheet 28 | Wire.write(byte(0x00)); // sends instruction byte 29 | Wire.write(val); // sends potentiometer value byte 30 | Wire.endTransmission(); // stop transmitting 31 | 32 | val++; // increment value 33 | if(val == 64) // if reached 64th position (max) 34 | { 35 | val = 0; // start over from lowest value 36 | } 37 | delay(500); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /libraries/Wire/examples/master_reader/master_reader.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Reader 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Reads data from an I2C/TWI slave device 6 | // Refer to the "Wire Slave Sender" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | Serial.begin(9600); // start serial for output 19 | } 20 | 21 | void loop() 22 | { 23 | Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 24 | 25 | while(Wire.available()) // slave may send less than requested 26 | { 27 | char c = Wire.read(); // receive a byte as character 28 | Serial.print(c); // print the character 29 | } 30 | 31 | delay(500); 32 | } 33 | -------------------------------------------------------------------------------- /libraries/Wire/examples/master_writer/master_writer.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Writer 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Writes data to an I2C/TWI slave device 6 | // Refer to the "Wire Slave Receiver" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | } 19 | 20 | byte x = 0; 21 | 22 | void loop() 23 | { 24 | Wire.beginTransmission(4); // transmit to device #4 25 | Wire.write("x is "); // sends five bytes 26 | Wire.write(x); // sends one byte 27 | Wire.endTransmission(); // stop transmitting 28 | 29 | x++; 30 | delay(500); 31 | } 32 | -------------------------------------------------------------------------------- /libraries/Wire/examples/slave_receiver/slave_receiver.ino: -------------------------------------------------------------------------------- 1 | // Wire Slave Receiver 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Receives data as an I2C/TWI slave device 6 | // Refer to the "Wire Master Writer" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(4); // join i2c bus with address #4 18 | Wire.onReceive(receiveEvent); // register event 19 | Serial.begin(9600); // start serial for output 20 | } 21 | 22 | void loop() 23 | { 24 | delay(100); 25 | } 26 | 27 | // function that executes whenever data is received from master 28 | // this function is registered as an event, see setup() 29 | void receiveEvent(int howMany) 30 | { 31 | while(1 < Wire.available()) // loop through all but the last 32 | { 33 | char c = Wire.read(); // receive byte as a character 34 | Serial.print(c); // print the character 35 | } 36 | int x = Wire.read(); // receive byte as an integer 37 | Serial.println(x); // print the integer 38 | } 39 | -------------------------------------------------------------------------------- /libraries/Wire/examples/slave_sender/slave_sender.ino: -------------------------------------------------------------------------------- 1 | // Wire Slave Sender 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Sends data as an I2C/TWI slave device 6 | // Refer to the "Wire Master Reader" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(2); // join i2c bus with address #2 18 | Wire.onRequest(requestEvent); // register event 19 | } 20 | 21 | void loop() 22 | { 23 | delay(100); 24 | } 25 | 26 | // function that executes whenever data is requested by master 27 | // this function is registered as an event, see setup() 28 | void requestEvent() 29 | { 30 | Wire.write("hello "); // respond with message of 6 bytes 31 | // as expected by master 32 | } 33 | -------------------------------------------------------------------------------- /libraries/Wire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Wire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | begin KEYWORD2 14 | beginTransmission KEYWORD2 15 | endTransmission KEYWORD2 16 | requestFrom KEYWORD2 17 | send KEYWORD2 18 | receive KEYWORD2 19 | onReceive KEYWORD2 20 | onRequest KEYWORD2 21 | 22 | ####################################### 23 | # Instances (KEYWORD2) 24 | ####################################### 25 | 26 | Wire KEYWORD2 27 | 28 | ####################################### 29 | # Constants (LITERAL1) 30 | ####################################### 31 | 32 | -------------------------------------------------------------------------------- /libraries/Wire/utility/twi.h: -------------------------------------------------------------------------------- 1 | /* 2 | twi.h - TWI/I2C library for Wiring & Arduino 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef twi_h 21 | #define twi_h 22 | 23 | #include 24 | 25 | //#define ATMEGA8 26 | 27 | #ifndef TWI_FREQ 28 | #define TWI_FREQ 100000L 29 | #endif 30 | 31 | #ifndef TWI_BUFFER_LENGTH 32 | #define TWI_BUFFER_LENGTH 32 33 | #endif 34 | 35 | #define TWI_READY 0 36 | #define TWI_MRX 1 37 | #define TWI_MTX 2 38 | #define TWI_SRX 3 39 | #define TWI_STX 4 40 | 41 | void twi_init(void); 42 | void twi_setAddress(uint8_t); 43 | uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t); 44 | uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t); 45 | uint8_t twi_transmit(const uint8_t*, uint8_t); 46 | void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) ); 47 | void twi_attachSlaveTxEvent( void (*)(void) ); 48 | void twi_reply(uint8_t); 49 | void twi_stop(void); 50 | void twi_releaseBus(void); 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /libraries/f32c/examples/double_fade/double_fade.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Double Fade 3 | 4 | This example shows how to fade an LEDs on pin 9 and 10 5 | using the analogWrite() function. 6 | 7 | This example code is in the public domain. 8 | */ 9 | 10 | int led1 = 9; // the pin that the LED is attached to 11 | int led2 = 10; 12 | int brightness = 0; // how bright the LED is 13 | int fadeAmount = 5; // how many points to fade the LED by 14 | 15 | // the setup routine runs once when you press reset: 16 | void setup() { 17 | // declare pin 9 to be an output: 18 | pinMode(led1, OUTPUT); 19 | pinMode(led2, OUTPUT); 20 | analogWriteResolution(12); 21 | digitalWrite(led1, HIGH); 22 | digitalWrite(led2, LOW); 23 | } 24 | 25 | // the loop routine runs over and over again forever: 26 | void loop() { 27 | static int mode = 0; 28 | // set the brightness of pin 9: 29 | mode++; 30 | mode &= 16383; 31 | if((mode & 8192) == 0) 32 | { 33 | analogWrite(led1, brightness); 34 | analogWrite(led2, 4095-brightness); 35 | } 36 | else 37 | { 38 | digitalWrite(led1, (mode & 256) == 0 ? LOW : HIGH); 39 | digitalWrite(led2, (mode & 256) == 0 ? HIGH : LOW); 40 | } 41 | 42 | // change the brightness for next time through the loop: 43 | brightness = brightness + fadeAmount; 44 | 45 | // reverse the direction of the fading at the ends of the fade: 46 | if (brightness == 0 || brightness == 4095) { 47 | fadeAmount = -fadeAmount ; 48 | } 49 | // wait for 30 milliseconds to see the dimming effect 50 | delay(1); 51 | } 52 | -------------------------------------------------------------------------------- /libraries/f32c/examples/interrupts/mips_timer/mips_timer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Timer interrupt 3 | 4 | This example shows how to blink LED 5 | using the interrupt. 6 | 7 | This example code is in the public domain. 8 | */ 9 | 10 | static int led = 13; // timer interrupt hardwired to arduino LED 11 | volatile uint8_t *led_pointer; // address of LED MMIO register 12 | static uint8_t led_bitmask; // LED bit set to 1, other bits 0 13 | static int timer_ticks; 14 | static int incrementInterval = 1000000; 15 | 16 | #define MANIFEST_MUL_INTERRUPT_BUG 0 17 | 18 | // WARNING: 19 | // Currently (2016-07-30), when f32c core is in interrupt context, 20 | // it doesn't correctly execute integer multiply instruction. 21 | // Sometimes, register corruption will occur. 22 | // Depending on how the code is compiled, bug will not always 23 | // manifest. 24 | 25 | void timer_handler() 26 | { 27 | #if MANIFEST_MUL_INTERRUPT_BUG 28 | digitalWrite(led, timer_ticks & 1); // may contain MUL 29 | #else 30 | *led_pointer = timer_ticks & 1 ? led_bitmask : 0; // no MUL 31 | #endif 32 | if(timerInterval < (F_CPU>>8)) 33 | incrementInterval = 100000; 34 | if(timerInterval > (F_CPU>>2)) 35 | incrementInterval = -100000; 36 | timerInterval += incrementInterval; 37 | timer_ticks++; 38 | } 39 | 40 | // the setup routine runs once when you press reset: 41 | void setup() { 42 | Serial.begin(115200); 43 | // led_pointer = -240; // dirty way 44 | led_pointer = (volatile uint8_t *) portOutputRegister(digitalPinToPort(led)); // clean way 45 | led_bitmask = digitalPinToBitMask(led); 46 | attachInterrupt(led, timer_handler, F_CPU>>3); 47 | } 48 | 49 | // the loop routine runs over and over again forever: 50 | void loop() { 51 | Serial.println(timer_ticks); 52 | delay(100); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /libraries/f32c/examples/interrupts/pwm_timer/pwm_timer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | PWM timer 3 | 4 | This example shows how to use pwm timer (aka emard timer) 5 | which does PWM (pulse width modulation) for analogWrite 6 | and interrupts for each PWM OCP (output compare) channel 7 | 8 | This example code is in the public domain. 9 | */ 10 | 11 | int led1 = 9; // the pin for OCP1 channel (hardwired) 12 | int led2 = 10; // the pin for OCP2 channel (hardwired) 13 | int led_activ1 = 12; // interrupt activity indicator for OCP1 14 | int led_activ2 = 13; // interrupt activity indicator for OCP2 15 | int32_t print_event; 16 | int32_t print_interval = 1000; 17 | 18 | void pwm1_isr(void) 19 | { 20 | digitalWrite(led_activ1, HIGH); 21 | } 22 | 23 | void pwm2_isr(void) 24 | { 25 | digitalWrite(led_activ2, HIGH); 26 | } 27 | 28 | // the setup routine runs once when you press reset: 29 | void setup() { 30 | pinMode(led1, OUTPUT); 31 | pinMode(led2, OUTPUT); 32 | analogWriteResolution(12); // 12 bits -> max value is 4095 33 | analogWriteFrequency(20); // 20 Hz switching frequency 34 | analogWrite(led1, 20); // intensity = 20/4095 35 | analogWritePhase(led1, 2000); 36 | analogWrite(led2, 100); // intensity = 100/4095 37 | // currently timer supports interrupts only on OCP rising edge (hardwired) 38 | attachInterrupt(led1, pwm1_isr, RISING); // rising edge of OCP1 will trigger interrupt 39 | attachInterrupt(led2, pwm2_isr, RISING); // rising edge of OCP2 will trigger interrupt 40 | print_event = millis(); 41 | Serial.begin(115200); 42 | } 43 | 44 | // the loop routine runs over and over again forever: 45 | void loop() { 46 | delay(100); 47 | digitalWrite(led_activ1, LOW); 48 | digitalWrite(led_activ2, LOW); 49 | if( ((int32_t)millis()-print_event) > 0) 50 | { 51 | print_event += print_interval; 52 | Serial.write("event\n"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /libraries/f32c/examples/interrupts/serial/serial.ino: -------------------------------------------------------------------------------- 1 | uint8_t serialrx_irq_magic=15; // magic pin that attaches serial interrupt 2 | 3 | uint8_t led=13; 4 | volatile uint8_t *led_pointer; // address of LED MMIO register 5 | static uint8_t led_bitmask; // LED bit set to 1, other bits 0 6 | 7 | void serialrx_irq(void) 8 | { 9 | if(Serial.available()) 10 | { 11 | uint8_t c = Serial.read(); 12 | *led_pointer = c; 13 | } 14 | } 15 | 16 | void setup() { 17 | led_pointer = (volatile uint8_t *) portOutputRegister(digitalPinToPort(led)); // clean way 18 | led_bitmask = digitalPinToBitMask(led); 19 | attachInterrupt(serialrx_irq_magic, serialrx_irq, RISING); 20 | } 21 | 22 | void loop() { 23 | delay(1000); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /libraries/f32c/examples/irq7_lowlevel/interrupt7.ino: -------------------------------------------------------------------------------- 1 | 2 | extern "C" { 3 | #include 4 | #include 5 | #include 6 | #include 7 | } 8 | 9 | static int tsc_next; 10 | static int irq7_ticks; 11 | 12 | static int 13 | tsc_isr(void) 14 | { 15 | 16 | irq7_ticks++; 17 | tsc_next += VARIANT_MCK; 18 | mtc0_macro(tsc_next, MIPS_COP_0_COMPARE); 19 | return (1); 20 | } 21 | 22 | static struct isr_link tsc_isr_link = {NULL, &tsc_isr}; 23 | 24 | void setup() { 25 | // put your setup code here, to run once: 26 | isr_register_handler(7, &tsc_isr_link); 27 | mfc0_macro(tsc_next, MIPS_COP_0_COUNT); 28 | tsc_next += VARIANT_MCK; 29 | mtc0_macro(tsc_next, MIPS_COP_0_COMPARE); 30 | asm("ei"); 31 | Serial.begin(115200); 32 | } 33 | 34 | void loop() { 35 | // put your main code here, to run repeatedly: 36 | Serial.println(irq7_ticks); 37 | delay(100); 38 | } 39 | -------------------------------------------------------------------------------- /libraries/f32c/examples/serialprint/serialprint.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Prints to the serial monitor. 3 | 4 | This example code is in the public domain. 5 | */ 6 | 7 | // the setup routine runs once when you press reset: 8 | void setup() { 9 | // initialize serial communication at 9600 bits per second: 10 | Serial.begin(115200); 11 | } 12 | 13 | // the loop routine runs over and over again forever: 14 | void loop() { 15 | // read the input on analog pin 0: 16 | static int sensorValue = 0; 17 | // print out the value you read: 18 | Serial.println(sensorValue++); 19 | digitalWrite(13, sensorValue & 1); 20 | // Serial.print(1.234); 21 | delay(100); // delay in between reads for stability 22 | } 23 | -------------------------------------------------------------------------------- /libraries/f32c/examples/sprites/sprites.ino: -------------------------------------------------------------------------------- 1 | // 2 | // ULX2S sprites demo 3 | // 4 | // One sprite is moveable using the cursor keys 5 | // Another one bounces from screen borders 6 | // 7 | 8 | extern "C" { 9 | #include 10 | #include 11 | #include 12 | } 13 | 14 | int spr0_x = 210, spr0_y = 65, spr1_x, spr1_y; 15 | int spr0_sizex, spr0_sizey; 16 | int spr1_sizex, spr1_sizey; 17 | int spr1_dirx, spr1_diry; 18 | 19 | void setup() { 20 | // put your setup code here, to run once: 21 | fb_set_mode(1); 22 | spr_load(0, "c:/demo/logos/ulx2s_top.jpg", 0); 23 | spr_load(1, "c:/demo/logos/unizg.jpg", 0); 24 | // black is transparent 25 | spr_trans(0, 0); 26 | spr_trans(1, 0); 27 | spr_size(0, &spr0_sizex, &spr0_sizey); 28 | spr_size(1, &spr1_sizex, &spr1_sizey); 29 | } 30 | 31 | void loop() { 32 | // put your main code here, to run repeatedly: 33 | int key; 34 | 35 | INB(key, IO_PUSHBTN); 36 | if (key & BTN_UP && spr0_y > 0) 37 | spr0_y--; 38 | if (key & BTN_LEFT && spr0_x > 0) 39 | spr0_x--; 40 | if (key & BTN_DOWN && spr0_y < 288 - spr0_sizey) 41 | spr0_y++; 42 | if (key & BTN_RIGHT && spr0_x < 512 - spr0_sizex) 43 | spr0_x++; 44 | 45 | if (spr1_y == 0) 46 | spr1_diry = 1; 47 | if (spr1_y == 288 - spr1_sizey) 48 | spr1_diry = -1; 49 | if (spr1_x == 0) 50 | spr1_dirx = 1; 51 | if (spr1_x == 512 - spr1_sizex) 52 | spr1_dirx = -1; 53 | spr1_x += spr1_dirx; 54 | spr1_y += spr1_diry; 55 | 56 | if ((key & BTN_CENTER) == 0) 57 | spr_put(0, spr0_x, spr0_y); 58 | spr_put(1, spr1_x, spr1_y); 59 | } 60 | -------------------------------------------------------------------------------- /libraries/f32c/f32c.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/libraries/f32c/f32c.cpp -------------------------------------------------------------------------------- /libraries/f32c/f32c.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/f32c/arduino/7d8cbb33fab873e2d2c6660be4eb42e09ac3eee0/libraries/f32c/f32c.h -------------------------------------------------------------------------------- /libraries/f32c_PS2Keyboard/README.md: -------------------------------------------------------------------------------- 1 | #PS/2 Keyboard Library# 2 | 3 | PS2Keyboard allows you to use a keyboard for user input. 4 | 5 | http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html 6 | 7 | ![](http://www.pjrc.com/teensy/td_libs_PS2Keyboard.jpg) 8 | -------------------------------------------------------------------------------- /libraries/f32c_PS2Keyboard/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For PS2Keyboard 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | PS2Keyboard KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | ####################################### 16 | # Constants (LITERAL1) 17 | ####################################### 18 | 19 | PS2_KC_BREAK LITERAL1 20 | PS2_KC_ENTER LITERAL1 21 | PS2_KC_ESC LITERAL1 22 | PS2_KC_KPLUS LITERAL1 23 | PS2_KC_KMINUS LITERAL1 24 | PS2_KC_KMULTI LITERAL1 25 | PS2_KC_NUM LITERAL1 26 | PS2_KC_BKSP LITERAL1 27 | -------------------------------------------------------------------------------- /libraries/f32c_VGATextConsole/examples/arcagol/gol.h: -------------------------------------------------------------------------------- 1 | #ifndef GOL_H 2 | #define GOL_H 3 | 4 | #include 5 | 6 | /* GoL struct 7 | */ 8 | struct gol 9 | { 10 | uint8_t v:1, n:4; 11 | // v: 1-bit pixel 1=on 0=off 12 | // n: 4-bit number of surrounding pixels (0-8) 13 | }; 14 | 15 | /* context required to iterate gol */ 16 | struct gol_context 17 | { 18 | uint16_t y; // current line to process 19 | /* buffer contains lines at y-1, y, y+1, y+2 20 | ** value of y_buf represents line at y 21 | */ 22 | uint8_t y_buf; // buffer circular pointer 0-3 here is copy of lines 23 | uint8_t y_buf_valid; // is the buffer content valid? 24 | }; 25 | 26 | extern struct gol_context gol_context; 27 | 28 | /* cell playfield dimensions 29 | ** represent infinite circular closed-in-itself 30 | ** area, use 2^n dimensions so the calculation of 31 | ** wraparound offset is easy 32 | */ 33 | enum { RANGE_X=128, RANGE_Y=64, RANGE_Y_BUF=4 }; 34 | 35 | extern struct gol cell[RANGE_Y][RANGE_X]; 36 | /* as we sequentially update we will store here 37 | ** previous values of 4 lines, one before and 2 ahead 38 | */ 39 | extern struct gol cell_buf[RANGE_Y_BUF][RANGE_X]; 40 | 41 | /* short iteration of a part of the GOL 42 | ** cells update. Saves state and can be 43 | ** called again any time again, 44 | ** when CPU has nothing to do and 45 | ** waits for vblank this will be called 46 | */ 47 | int gol_iterate(void); // calculates a part of the iteration 48 | void gol_clear(void); 49 | void gol_plot(uint16_t x, uint16_t y, uint8_t v); // plot a gol pixel 50 | // peek for the gol cell (returns struct gol) 51 | #define gol_peek(x,y) (cell[y & (RANGE_Y-1)][x & (RANGE_X-1)]) 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /libraries/f32c_VGATextConsole/examples/boulder/osa.h: -------------------------------------------------------------------------------- 1 | // -*- coding: utf-8 -*- 2 | #ifndef OSA_H 3 | #define OSA_H 4 | 5 | #include 6 | 7 | // DUMMY OS interface 8 | 9 | #define OS_Init(x) 10 | #define OS_Task_Create(x,y) 11 | #define OS_EI() 12 | #define OS_Run() 13 | #define OS_Bsem_Set(x) 14 | #define OS_Bsem_Wait(x) 15 | #define OS_Flag_Wait_11(x,y) 16 | #define OS_Flag_Set_0(x,y) 17 | #define OS_SMsg_Send_Now(x,y) 18 | #define OS_SMsg_Wait(x,y) 19 | #define OS_Delay(x) 20 | #define OS_Yield(x) 21 | 22 | #define OST_SMSG int 23 | #define BS_MAP_FREE 0 24 | #define near 25 | #define bit uint8_t 26 | #define CLRWDT(x) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libraries/f32c_VGATextConsole/examples/text_raw/text_raw.ino: -------------------------------------------------------------------------------- 1 | // crude malloc for video text memory 2 | // assumes compiled exectuable is <2K 3 | volatile uint16_t *vram = (volatile uint16_t *) 0x80000800; 4 | 5 | #define text_addr (*(volatile uint32_t *)0xFFFFFB8C) 6 | #define cntrl_reg (*(volatile uint8_t *)0xfffffb83) 7 | #define finescroll_reg (*(volatile uint8_t *)0xfffffb8b) 8 | #define vblank_reg (*(volatile uint8_t *)0xfffffb87) 9 | 10 | void setup() { 11 | text_addr = vram; // video text base address 12 | cntrl_reg = 0xC0; // enable text mode, no bitmap 13 | } 14 | 15 | void loop() { 16 | // display scrolling charset 17 | int i; 18 | uint16_t glyph; 19 | static uint16_t glyphstart = 0; 20 | static uint8_t fscroll = 0; 21 | while((vblank_reg & 0x80) != 0); 22 | while((vblank_reg & 0x80) == 0); 23 | fscroll = ++fscroll & 7; 24 | finescroll_reg = fscroll; 25 | if(fscroll == 0) 26 | { 27 | glyph = glyphstart++; 28 | for(i = 0; i < 81*31; i++) 29 | vram[i] = glyph++; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /libraries/f32c_VGATextConsole/keywords.txt: -------------------------------------------------------------------------------- 1 | NTSC LITERAL1 2 | PAL LITERAL1 3 | _NTSC LITERAL1 4 | _PAL LITERAL1 5 | WHITE LITERAL1 6 | BLACK LITERAL1 7 | INVERT LITERAL1 8 | UP LITERAL1 9 | DOWN LITERAL1 10 | LEFT LITERAL1 11 | RIGHT LITERAL1 12 | 13 | TVout KEYWORD1 14 | 15 | clear_screen KEYWORD2 16 | invert KEYWORD2 17 | 18 | begin KEYWORD2 19 | end KEYWORD2 20 | force_vscale KEYWORD2 21 | force_outstart KEYWORD2 22 | force_linestart KEYWORD2 23 | hres KEYWORD2 24 | vres KEYWORD2 25 | char_line KEYWORD2 26 | fill KEYWORD2 27 | delay KEYWORD2 28 | delay_frame KEYWORD2 29 | millis KEYWORD2 30 | set_pixel KEYWORD2 31 | get_pixel KEYWORD2 32 | fill KEYWORD2 33 | shift KEYWORD2 34 | draw_line KEYWORD2 35 | draw_row KEYWORD2 36 | draw_column KEYWORD2 37 | draw_rect KEYWORD2 38 | draw_circle KEYWORD2 39 | bitmap KEYWORD2 40 | set_vbi_hook KEYWORD2 41 | set_hbi_hook KEYWORD2 42 | tone KEYWORD2 43 | noTone KEYWORD2 44 | print_char KEYWORD2 45 | set_cursor KEYWORD2 46 | select_font KEYWORD2 47 | print KEYWORD2 48 | println KEYWORD2 49 | printPGM KEYWORD2 50 | 51 | --------------------------------------------------------------------------------