├── .githooks └── pre-commit ├── .github └── workflows │ ├── check-pull-request.yml │ └── deploy-pages.yml ├── .gitignore ├── Doxyfile ├── LICENSE ├── Makefile ├── Makefile-githook ├── README.md ├── docs └── README.md ├── libraries ├── Adafruit_BusIO │ ├── Adafruit_BusIO_Register.cpp │ ├── Adafruit_BusIO_Register.h │ ├── Adafruit_I2CDevice.cpp │ ├── Adafruit_I2CDevice.h │ ├── Adafruit_I2CRegister.h │ ├── Adafruit_SPIDevice.cpp │ └── Adafruit_SPIDevice.h ├── Adafruit_ICM20X │ ├── Adafruit_ICM20649.cpp │ ├── Adafruit_ICM20649.h │ ├── Adafruit_ICM20948.cpp │ ├── Adafruit_ICM20948.h │ ├── Adafruit_ICM20X.cpp │ ├── Adafruit_ICM20X.h │ ├── README.md │ ├── code-of-conduct.md │ └── license.txt ├── Adafruit_LIS3MDL │ ├── Adafruit_LIS3MDL.cpp │ └── Adafruit_LIS3MDL.h ├── Adafruit_LSM6DS │ ├── Adafruit_ISM330DHCX.cpp │ ├── Adafruit_ISM330DHCX.h │ ├── Adafruit_LSM6DS.cpp │ ├── Adafruit_LSM6DS.h │ ├── Adafruit_LSM6DS3.cpp │ ├── Adafruit_LSM6DS3.h │ ├── Adafruit_LSM6DS33.cpp │ ├── Adafruit_LSM6DS33.h │ ├── Adafruit_LSM6DS3TRC.cpp │ ├── Adafruit_LSM6DS3TRC.h │ ├── Adafruit_LSM6DSL.cpp │ ├── Adafruit_LSM6DSL.h │ ├── Adafruit_LSM6DSO32.cpp │ ├── Adafruit_LSM6DSO32.h │ ├── Adafruit_LSM6DSOX.cpp │ ├── Adafruit_LSM6DSOX.h │ └── license.txt ├── Adafruit_Sensor │ ├── Adafruit_Sensor.cpp │ ├── Adafruit_Sensor.h │ └── LICENSE.txt ├── FastLED │ └── src │ │ ├── FastLED.cpp │ │ ├── FastLED.h │ │ ├── bitswap.cpp │ │ ├── bitswap.h │ │ ├── chipsets.h │ │ ├── chsv.h │ │ ├── color.h │ │ ├── colorpalettes.cpp │ │ ├── colorpalettes.h │ │ ├── colorutils.cpp │ │ ├── colorutils.h │ │ ├── controller.h │ │ ├── cpp_compat.h │ │ ├── crgb.h │ │ ├── crgb.hpp │ │ ├── dither_mode.h │ │ ├── dmx.h │ │ ├── eorder.h │ │ ├── fastled_config.h │ │ ├── fastled_delay.h │ │ ├── fastled_progmem.h │ │ ├── fastpin.h │ │ ├── fastspi.h │ │ ├── fastspi_bitbang.h │ │ ├── fastspi_dma.h │ │ ├── fastspi_nop.h │ │ ├── fastspi_ref.h │ │ ├── fastspi_types.h │ │ ├── five_bit_hd_gamma.cpp │ │ ├── five_bit_hd_gamma.h │ │ ├── force_inline.h │ │ ├── hsv2rgb.cpp │ │ ├── hsv2rgb.h │ │ ├── led_sysdefs.h │ │ ├── lib8tion.cpp │ │ ├── lib8tion.h │ │ ├── lib8tion │ │ ├── math8.h │ │ ├── random8.h │ │ ├── scale8.h │ │ ├── trig8.h │ │ └── types.h │ │ ├── namespace.h │ │ ├── noise.cpp │ │ ├── noise.h │ │ ├── pixel_controller.h │ │ ├── pixel_iterator.h │ │ ├── pixelset.h │ │ ├── pixeltypes.h │ │ ├── platforms.cpp │ │ ├── platforms.h │ │ ├── platforms │ │ ├── apollo3 │ │ │ ├── clockless_apollo3.h │ │ │ ├── fastled_apollo3.h │ │ │ ├── fastpin_apollo3.h │ │ │ ├── fastspi_apollo3.h │ │ │ └── led_sysdefs_apollo3.h │ │ ├── arm │ │ │ ├── common │ │ │ │ └── m0clockless.h │ │ │ ├── d21 │ │ │ │ ├── clockless_arm_d21.h │ │ │ │ ├── fastled_arm_d21.h │ │ │ │ ├── fastpin_arm_d21.h │ │ │ │ └── led_sysdefs_arm_d21.h │ │ │ ├── d51 │ │ │ │ ├── README.txt │ │ │ │ ├── clockless_arm_d51.h │ │ │ │ ├── fastled_arm_d51.h │ │ │ │ ├── fastpin_arm_d51.h │ │ │ │ └── led_sysdefs_arm_d51.h │ │ │ ├── k20 │ │ │ │ ├── clockless_arm_k20.h │ │ │ │ ├── clockless_block_arm_k20.h │ │ │ │ ├── fastled_arm_k20.h │ │ │ │ ├── fastpin_arm_k20.h │ │ │ │ ├── fastspi_arm_k20.h │ │ │ │ ├── led_sysdefs_arm_k20.h │ │ │ │ ├── octows2811_controller.h │ │ │ │ ├── smartmatrix_t3.h │ │ │ │ └── ws2812serial_controller.h │ │ │ ├── k66 │ │ │ │ ├── clockless_arm_k66.h │ │ │ │ ├── clockless_block_arm_k66.h │ │ │ │ ├── fastled_arm_k66.h │ │ │ │ ├── fastpin_arm_k66.h │ │ │ │ ├── fastspi_arm_k66.h │ │ │ │ └── led_sysdefs_arm_k66.h │ │ │ ├── kl26 │ │ │ │ ├── clockless_arm_kl26.h │ │ │ │ ├── fastled_arm_kl26.h │ │ │ │ ├── fastpin_arm_kl26.h │ │ │ │ ├── fastspi_arm_kl26.h │ │ │ │ └── led_sysdefs_arm_kl26.h │ │ │ ├── mxrt1062 │ │ │ │ ├── block_clockless_arm_mxrt1062.h │ │ │ │ ├── clockless_arm_mxrt1062.h │ │ │ │ ├── fastled_arm_mxrt1062.h │ │ │ │ ├── fastpin_arm_mxrt1062.h │ │ │ │ ├── fastspi_arm_mxrt1062.h │ │ │ │ ├── led_sysdefs_arm_mxrt1062.h │ │ │ │ └── octows2811_controller.h │ │ │ ├── nrf51 │ │ │ │ ├── clockless_arm_nrf51.h │ │ │ │ ├── fastled_arm_nrf51.h │ │ │ │ ├── fastpin_arm_nrf51.h │ │ │ │ ├── fastspi_arm_nrf51.h │ │ │ │ └── led_sysdefs_arm_nrf51.h │ │ │ ├── nrf52 │ │ │ │ ├── arbiter_nrf52.h │ │ │ │ ├── clockless_arm_nrf52.h │ │ │ │ ├── fastled_arm_nrf52.h │ │ │ │ ├── fastpin_arm_nrf52.h │ │ │ │ ├── fastpin_arm_nrf52_variants.h │ │ │ │ ├── fastspi_arm_nrf52.h │ │ │ │ └── led_sysdefs_arm_nrf52.h │ │ │ ├── renesas │ │ │ │ ├── clockless_arm_renesas.h │ │ │ │ ├── fastled_arm_renesas.h │ │ │ │ ├── fastpin_arm_renesas.h │ │ │ │ └── led_sysdef_arm_renesas.h │ │ │ ├── rp2040 │ │ │ │ ├── clockless_arm_rp2040.h │ │ │ │ ├── fastled_arm_rp2040.h │ │ │ │ ├── fastpin_arm_rp2040.h │ │ │ │ ├── led_sysdefs_arm_rp2040.h │ │ │ │ ├── pio_asm.h │ │ │ │ └── pio_gen.h │ │ │ ├── sam │ │ │ │ ├── clockless_arm_sam.h │ │ │ │ ├── clockless_block_arm_sam.h │ │ │ │ ├── fastled_arm_sam.h │ │ │ │ ├── fastpin_arm_sam.h │ │ │ │ ├── fastspi_arm_sam.h │ │ │ │ └── led_sysdefs_arm_sam.h │ │ │ └── stm32 │ │ │ │ ├── clockless_arm_stm32.h │ │ │ │ ├── cm3_regs.h │ │ │ │ ├── fastled_arm_stm32.h │ │ │ │ ├── fastpin_arm_stm32.h │ │ │ │ └── led_sysdefs_arm_stm32.h │ │ ├── avr │ │ │ ├── clockless_trinket.h │ │ │ ├── fastled_avr.h │ │ │ ├── fastpin_avr.h │ │ │ ├── fastspi_avr.h │ │ │ └── led_sysdefs_avr.h │ │ ├── esp │ │ │ ├── 32 │ │ │ │ ├── clock_cycles.h │ │ │ │ ├── clockless_block_esp32.h │ │ │ │ ├── clockless_i2s_esp32.h │ │ │ │ ├── clockless_rmt_esp32.h │ │ │ │ ├── fastled_esp32.h │ │ │ │ ├── fastpin_esp32.h │ │ │ │ ├── fastspi_esp32.h │ │ │ │ ├── i2s.cpp │ │ │ │ ├── i2s.h │ │ │ │ ├── idf4_clockless_rmt_esp32.h │ │ │ │ ├── idf4_rmt.cpp │ │ │ │ ├── idf4_rmt.h │ │ │ │ ├── idf4_rmt_impl.cpp │ │ │ │ ├── idf4_rmt_impl.h │ │ │ │ ├── idf5_clockless_rmt_esp32.h │ │ │ │ ├── led_strip │ │ │ │ │ ├── enabled.h │ │ │ │ │ ├── led_strip.h │ │ │ │ │ ├── led_strip_api.cpp │ │ │ │ │ ├── led_strip_interface.h │ │ │ │ │ ├── led_strip_rmt.h │ │ │ │ │ ├── led_strip_rmt_dev.cpp │ │ │ │ │ ├── led_strip_rmt_dev_idf4.cpp │ │ │ │ │ ├── led_strip_rmt_encoder.cpp │ │ │ │ │ ├── led_strip_rmt_encoder.h │ │ │ │ │ ├── led_strip_spi.h │ │ │ │ │ ├── led_strip_spi_dev.cpp │ │ │ │ │ ├── led_strip_types.h │ │ │ │ │ ├── readme │ │ │ │ │ ├── rmt_demo.cpp │ │ │ │ │ └── rmt_demo.h │ │ │ │ └── led_sysdefs_esp32.h │ │ │ └── 8266 │ │ │ │ ├── clockless_block_esp8266.h │ │ │ │ ├── clockless_esp8266.h │ │ │ │ ├── fastled_esp8266.h │ │ │ │ ├── fastpin_esp8266.h │ │ │ │ ├── fastspi_esp8266.h │ │ │ │ └── led_sysdefs_esp8266.h │ │ ├── fastspi_ardunio_core.h │ │ └── stub │ │ │ ├── clockless_stub.h │ │ │ ├── fastled_stub.h │ │ │ ├── fastspi_stub.h │ │ │ ├── led_sysdefs_stub.cpp │ │ │ └── led_sysdefs_stub.h │ │ ├── power_mgt.cpp │ │ ├── power_mgt.h │ │ ├── rgbw.cpp │ │ ├── rgbw.h │ │ ├── simplex.cpp │ │ ├── stub_main.cpp │ │ ├── transpose8x1_noinline.cpp │ │ ├── transpose8x1_noinline.h │ │ ├── types.h │ │ └── wiring.cpp ├── FlexCAN_T4 │ ├── FlexCAN_T4.h │ ├── FlexCAN_T4.tpp │ ├── FlexCAN_T4Beta1BoardArchive.zip │ ├── FlexCAN_T4FD.tpp │ ├── FlexCAN_T4FDTimings.tpp │ ├── LICENSE │ ├── README.md │ ├── circular_buffer.h │ ├── imxrt_flexcan.h │ ├── isotp.h │ ├── isotp.tpp │ ├── isotp_server.h │ ├── isotp_server.tpp │ └── kinetis_flexcan.h ├── FreqMeasureMulti │ ├── FreqMeasureMulti.cpp │ ├── FreqMeasureMulti.h │ ├── FreqMeasureMultiIMXRT.cpp │ ├── FreqMeasureMultiIMXRT.h │ ├── README.md │ ├── docs │ │ └── issue_template.md │ └── keywords.txt ├── QNEthernet │ ├── README.md │ └── src │ │ ├── QNDNSClient.cpp │ │ ├── QNDNSClient.h │ │ ├── QNEthernet.cpp │ │ ├── QNEthernet.h │ │ ├── QNEthernetClient.cpp │ │ ├── QNEthernetClient.h │ │ ├── QNEthernetFrame.cpp │ │ ├── QNEthernetFrame.h │ │ ├── QNEthernetServer.cpp │ │ ├── QNEthernetServer.h │ │ ├── QNEthernetUDP.cpp │ │ ├── QNEthernetUDP.h │ │ ├── QNMDNS.cpp │ │ ├── QNMDNS.h │ │ ├── StaticInit.h │ │ ├── altcp_tls_adapter.cpp │ │ ├── arch │ │ ├── cc.h │ │ └── sys_arch.h │ │ ├── default_altcp_functions.cpp │ │ ├── driver_select.h │ │ ├── drivers │ │ ├── driver_teensy41.c │ │ ├── driver_teensy41.h │ │ ├── driver_unsupported.c │ │ ├── driver_unsupported.h │ │ ├── driver_w5500.cpp │ │ ├── driver_w5500.h │ │ └── driver_w5500_config.h │ │ ├── internal │ │ ├── ConnectionHolder.h │ │ ├── ConnectionManager.cpp │ │ ├── ConnectionManager.h │ │ ├── ConnectionState.h │ │ ├── DiffServ.h │ │ └── PrintfChecked.h │ │ ├── lwip │ │ ├── acd.h │ │ ├── altcp.c │ │ ├── altcp.h │ │ ├── altcp_alloc.c │ │ ├── altcp_tcp.c │ │ ├── altcp_tcp.h │ │ ├── altcp_tls.h │ │ ├── api.h │ │ ├── api │ │ │ └── err.c │ │ ├── apps │ │ │ ├── altcp_proxyconnect.h │ │ │ ├── altcp_tls │ │ │ │ ├── altcp_tls_mbedtls.c │ │ │ │ ├── altcp_tls_mbedtls_mem.c │ │ │ │ ├── altcp_tls_mbedtls_mem.h │ │ │ │ └── altcp_tls_mbedtls_structs.h │ │ │ ├── altcp_tls_mbedtls_opts.h │ │ │ ├── http │ │ │ │ └── altcp_proxyconnect.c │ │ │ ├── mdns.h │ │ │ ├── mdns │ │ │ │ ├── mdns.c │ │ │ │ ├── mdns_domain.c │ │ │ │ └── mdns_out.c │ │ │ ├── mdns_domain.h │ │ │ ├── mdns_opts.h │ │ │ ├── mdns_out.h │ │ │ └── mdns_priv.h │ │ ├── arch.h │ │ ├── autoip.h │ │ ├── debug.h │ │ ├── def.c │ │ ├── def.h │ │ ├── dhcp.h │ │ ├── dhcp6.h │ │ ├── dns.c │ │ ├── dns.h │ │ ├── err.h │ │ ├── errno.h │ │ ├── etharp.h │ │ ├── ethip6.h │ │ ├── icmp.h │ │ ├── icmp6.h │ │ ├── if_api.h │ │ ├── igmp.h │ │ ├── inet.h │ │ ├── inet_chksum.c │ │ ├── inet_chksum.h │ │ ├── init.c │ │ ├── init.h │ │ ├── ip.c │ │ ├── ip.h │ │ ├── ip4.h │ │ ├── ip4_addr.h │ │ ├── ip4_frag.h │ │ ├── ip6.h │ │ ├── ip6_addr.h │ │ ├── ip6_frag.h │ │ ├── ip6_zone.h │ │ ├── ip_addr.h │ │ ├── ipv4 │ │ │ ├── acd.c │ │ │ ├── autoip.c │ │ │ ├── dhcp.c │ │ │ ├── etharp.c │ │ │ ├── icmp.c │ │ │ ├── igmp.c │ │ │ ├── ip4.c │ │ │ ├── ip4_addr.c │ │ │ └── ip4_frag.c │ │ ├── ipv6 │ │ │ ├── dhcp6.c │ │ │ ├── ethip6.c │ │ │ ├── icmp6.c │ │ │ ├── inet6.c │ │ │ ├── ip6.c │ │ │ ├── ip6_addr.c │ │ │ ├── ip6_frag.c │ │ │ ├── mld6.c │ │ │ └── nd6.c │ │ ├── mem.c │ │ ├── mem.h │ │ ├── memp.c │ │ ├── memp.h │ │ ├── mld6.h │ │ ├── nd6.h │ │ ├── netbuf.h │ │ ├── netdb.h │ │ ├── netif.c │ │ ├── netif.h │ │ ├── netifapi.h │ │ ├── opt.h │ │ ├── pbuf.c │ │ ├── pbuf.h │ │ ├── priv │ │ │ ├── altcp_priv.h │ │ │ ├── api_msg.h │ │ │ ├── mem_priv.h │ │ │ ├── memp_priv.h │ │ │ ├── memp_std.h │ │ │ ├── nd6_priv.h │ │ │ ├── raw_priv.h │ │ │ ├── sockets_priv.h │ │ │ ├── tcp_priv.h │ │ │ └── tcpip_priv.h │ │ ├── prot │ │ │ ├── acd.h │ │ │ ├── autoip.h │ │ │ ├── dhcp.h │ │ │ ├── dhcp6.h │ │ │ ├── dns.h │ │ │ ├── etharp.h │ │ │ ├── ethernet.h │ │ │ ├── iana.h │ │ │ ├── icmp.h │ │ │ ├── icmp6.h │ │ │ ├── ieee.h │ │ │ ├── igmp.h │ │ │ ├── ip.h │ │ │ ├── ip4.h │ │ │ ├── ip6.h │ │ │ ├── mld6.h │ │ │ ├── nd6.h │ │ │ ├── tcp.h │ │ │ └── udp.h │ │ ├── raw.c │ │ ├── raw.h │ │ ├── sio.h │ │ ├── snmp.h │ │ ├── sockets.h │ │ ├── stats.c │ │ ├── stats.h │ │ ├── sys.c │ │ ├── sys.h │ │ ├── tcp.c │ │ ├── tcp.h │ │ ├── tcp_in.c │ │ ├── tcp_out.c │ │ ├── tcpbase.h │ │ ├── tcpip.h │ │ ├── timeouts.c │ │ ├── timeouts.h │ │ ├── udp.c │ │ └── udp.h │ │ ├── lwip_driver.c │ │ ├── lwip_driver.h │ │ ├── lwip_hooks.h │ │ ├── lwipopts.h │ │ ├── main.cpp │ │ ├── netif │ │ ├── etharp.h │ │ ├── ethernet.c │ │ ├── ethernet.h │ │ └── ppp │ │ │ ├── ppp_impl.h │ │ │ └── ppp_opts.h │ │ ├── qnethernet_hal.cpp │ │ ├── qnethernet_opts.h │ │ ├── security │ │ ├── RandomDevice.cpp │ │ ├── RandomDevice.h │ │ ├── entropy.c │ │ └── entropy.h │ │ ├── sys_arch.cpp │ │ └── util │ │ ├── PrintUtils.cpp │ │ ├── PrintUtils.h │ │ ├── ip_tools.cpp │ │ └── ip_tools.h ├── SD │ ├── README.md │ ├── SD.cpp │ ├── SD.h │ ├── keywords.txt │ └── library.properties ├── SPI │ ├── SPI.cpp │ └── SPI.h ├── SdFat │ ├── LICENSE.md │ ├── README.md │ ├── doc │ │ ├── Doxyfile │ │ ├── SdErrorCodes.txt │ │ ├── SdFat.html │ │ ├── ZipMsg │ │ │ └── index.html │ │ ├── clean_html.bat │ │ ├── del_html.bat │ │ ├── html.zip │ │ ├── html │ │ │ └── index.html │ │ └── mainpage.h │ ├── library.properties │ └── src │ │ ├── BufferedPrint.h │ │ ├── DigitalIO │ │ ├── DigitalPin.h │ │ ├── SoftSPI.h │ │ ├── boards │ │ │ ├── AvrDevelopersGpioPinMap.h │ │ │ ├── BobuinoGpioPinMap.h │ │ │ ├── GpioPinMap.h │ │ │ ├── LeonardoGpioPinMap.h │ │ │ ├── MegaGpioPinMap.h │ │ │ ├── SleepingBeautyGpioPinMap.h │ │ │ ├── Standard1284GpioPinMap.h │ │ │ ├── Teensy2GpioPinMap.h │ │ │ ├── Teensy2ppGpioPinMap.h │ │ │ └── UnoGpioPinMap.h │ │ └── readme.txt │ │ ├── ExFatLib │ │ ├── ExFatConfig.h │ │ ├── ExFatDbg.cpp │ │ ├── ExFatFile.cpp │ │ ├── ExFatFile.h │ │ ├── ExFatFilePrint.cpp │ │ ├── ExFatFileWrite.cpp │ │ ├── ExFatFormatter.cpp │ │ ├── ExFatFormatter.h │ │ ├── ExFatLib.h │ │ ├── ExFatName.cpp │ │ ├── ExFatPartition.cpp │ │ ├── ExFatPartition.h │ │ ├── ExFatVolume.cpp │ │ └── ExFatVolume.h │ │ ├── FatLib │ │ ├── FatDbg.cpp │ │ ├── FatFile.cpp │ │ ├── FatFile.h │ │ ├── FatFileLFN.cpp │ │ ├── FatFilePrint.cpp │ │ ├── FatFileSFN.cpp │ │ ├── FatFormatter.cpp │ │ ├── FatFormatter.h │ │ ├── FatLib.h │ │ ├── FatName.cpp │ │ ├── FatPartition.cpp │ │ ├── FatPartition.h │ │ ├── FatVolume.cpp │ │ └── FatVolume.h │ │ ├── FreeStack.cpp │ │ ├── FreeStack.h │ │ ├── FsLib │ │ ├── FsFile.cpp │ │ ├── FsFile.h │ │ ├── FsFormatter.h │ │ ├── FsLib.h │ │ ├── FsNew.cpp │ │ ├── FsNew.h │ │ ├── FsVolume.cpp │ │ └── FsVolume.h │ │ ├── MinimumSerial.cpp │ │ ├── MinimumSerial.h │ │ ├── RingBuf.h │ │ ├── SdCard │ │ ├── CPPLINT.cfg │ │ ├── SdCard.h │ │ ├── SdCardInfo.cpp │ │ ├── SdCardInfo.h │ │ ├── SdCardInterface.h │ │ ├── SdSpiCard.cpp │ │ ├── SdSpiCard.h │ │ ├── SdioCard.h │ │ ├── SdioTeensy.cpp │ │ └── SdioTeensy.h │ │ ├── SdFat.h │ │ ├── SdFatConfig.h │ │ ├── SpiDriver │ │ ├── SdSpiArduinoDriver.h │ │ ├── SdSpiArtemis.cpp │ │ ├── SdSpiAvr.h │ │ ├── SdSpiBareUnoDriver.h │ │ ├── SdSpiBaseClass.h │ │ ├── SdSpiChipSelect.cpp │ │ ├── SdSpiDriver.h │ │ ├── SdSpiDue.cpp │ │ ├── SdSpiESP.cpp │ │ ├── SdSpiLibDriver.h │ │ ├── SdSpiParticle.cpp │ │ ├── SdSpiSTM32.cpp │ │ ├── SdSpiSTM32Core.cpp │ │ ├── SdSpiSoftDriver.h │ │ └── SdSpiTeensy3.cpp │ │ ├── common │ │ ├── ArduinoFiles.h │ │ ├── CPPLINT.cfg │ │ ├── CompileDateTime.h │ │ ├── DebugMacros.h │ │ ├── FmtNumber.cpp │ │ ├── FmtNumber.h │ │ ├── FsApiConstants.h │ │ ├── FsBlockDevice.h │ │ ├── FsBlockDeviceInterface.h │ │ ├── FsCache.cpp │ │ ├── FsCache.h │ │ ├── FsDateTime.cpp │ │ ├── FsDateTime.h │ │ ├── FsName.cpp │ │ ├── FsName.h │ │ ├── FsStructs.cpp │ │ ├── FsStructs.h │ │ ├── FsUtf.cpp │ │ ├── FsUtf.h │ │ ├── PrintBasic.cpp │ │ ├── PrintBasic.h │ │ ├── SysCall.h │ │ ├── upcase.cpp │ │ └── upcase.h │ │ ├── iostream │ │ ├── ArduinoStream.h │ │ ├── StdioStream.cpp │ │ ├── StdioStream.h │ │ ├── StreamBaseClass.cpp │ │ ├── bufstream.h │ │ ├── fstream.h │ │ ├── ios.h │ │ ├── iostream.h │ │ ├── istream.cpp │ │ ├── istream.h │ │ ├── ostream.cpp │ │ └── ostream.h │ │ └── sdios.h ├── TeensyDebug │ ├── README.md │ ├── notes.md │ └── src │ │ ├── TeensyDebug.cpp │ │ ├── TeensyDebug.h │ │ └── gdbstub.cpp ├── VL53L4CD │ ├── platform.cpp │ ├── vl53l4cd_api.cpp │ ├── vl53l4cd_api.h │ ├── vl53l4cd_calibration.cpp │ └── vl53l4cd_class.h ├── WDT_T4 │ ├── Watchdog_t4.h │ └── Watchdog_t4.tpp ├── Wire │ ├── Wire.cpp │ ├── Wire.h │ ├── WireIMXRT.cpp │ ├── WireIMXRT.h │ ├── WireKinetis.cpp │ ├── WireKinetis.h │ ├── keywords.txt │ ├── library.properties │ └── utility │ │ ├── twi.c │ │ └── twi.h └── unity │ ├── unity.c │ ├── unity.h │ ├── unity_config.h │ └── unity_internals.h ├── src ├── comms │ ├── SDManager.cpp │ ├── SDManager.hpp │ ├── comms_layer.cpp │ ├── comms_layer.hpp │ ├── config_layer.cpp │ ├── config_layer.hpp │ ├── data │ │ ├── buff_encoder_data.hpp │ │ ├── comms_data.cpp │ │ ├── comms_data.hpp │ │ ├── comms_ref_data.hpp │ │ ├── config_section.hpp │ │ ├── data_structs.hpp │ │ ├── dr16_data.hpp │ │ ├── firmware_data.cpp │ │ ├── firmware_data.hpp │ │ ├── hive_data.cpp │ │ ├── hive_data.hpp │ │ ├── icm_sensor_data.hpp │ │ ├── lidar_data_packet_si.hpp │ │ ├── logging_data.hpp │ │ ├── packet_payload.cpp │ │ ├── packet_payload.hpp │ │ ├── rev_sensor_data.hpp │ │ ├── robot_state_data.hpp │ │ ├── sendable.cpp │ │ ├── sendable.hpp │ │ ├── test_data.hpp │ │ └── tof_sensor_data.hpp │ ├── ethernet_comms.cpp │ ├── ethernet_comms.hpp │ ├── ethernet_packet.hpp │ ├── hid_comms.cpp │ ├── hid_comms.hpp │ ├── hid_packet.hpp │ └── packet_header.hpp ├── controls │ ├── controller.cpp │ ├── controller.hpp │ ├── controller_manager.cpp │ ├── controller_manager.hpp │ ├── estimator.cpp │ ├── estimator.hpp │ ├── estimator_manager.cpp │ ├── estimator_manager.hpp │ ├── state.cpp │ └── state.hpp ├── filters │ ├── lowpass_filter.cpp │ ├── lowpass_filter.hpp │ ├── pid_filter.cpp │ └── pid_filter.hpp ├── main.cpp ├── sensors │ ├── ACS712.cpp │ ├── ACS712.hpp │ ├── ET16S.cpp │ ├── ET16S.hpp │ ├── ICM20649.cpp │ ├── ICM20649.hpp │ ├── IMUSensor.cpp │ ├── IMUSensor.hpp │ ├── LEDBoard.cpp │ ├── LEDBoard.hpp │ ├── LSM6DSOX.cpp │ ├── LSM6DSOX.hpp │ ├── RefSystem.cpp │ ├── RefSystem.hpp │ ├── RefSystemPacketDefs.hpp │ ├── Sensor.cpp │ ├── Sensor.hpp │ ├── SensorManager.cpp │ ├── SensorManager.hpp │ ├── StereoCamTrigger.cpp │ ├── StereoCamTrigger.hpp │ ├── TOFSensor.hpp │ ├── buff_encoder.cpp │ ├── buff_encoder.hpp │ ├── can │ │ ├── C610.cpp │ │ ├── C610.hpp │ │ ├── C620.cpp │ │ ├── C620.hpp │ │ ├── GIM.cpp │ │ ├── GIM.hpp │ │ ├── MG8016EI6.cpp │ │ ├── MG8016EI6.hpp │ │ ├── SDC104.cpp │ │ ├── SDC104.hpp │ │ ├── can_manager.cpp │ │ ├── can_manager.hpp │ │ └── motor.hpp │ ├── d200.cpp │ ├── d200.hpp │ ├── dr16.cpp │ ├── dr16.hpp │ ├── limit_switch.hpp │ ├── rev_encoder.cpp │ └── rev_encoder.hpp └── utils │ ├── bitwise_operations.hpp │ ├── profiler.cpp │ ├── profiler.hpp │ ├── timing.cpp │ ├── timing.hpp │ ├── vector_math.cpp │ ├── vector_math.hpp │ ├── watchdog.hpp │ ├── wrapping.cpp │ └── wrapping.hpp ├── teensy4 ├── Arduino.h ├── AudioStream.cpp ├── AudioStream.h ├── Blink.cc ├── Client.h ├── CrashReport.cpp ├── CrashReport.h ├── DMAChannel.cpp ├── DMAChannel.h ├── DateStrings.cpp ├── EventResponder.cpp ├── EventResponder.h ├── FS.h ├── HardwareSerial.cpp ├── HardwareSerial.h ├── HardwareSerial1.cpp ├── HardwareSerial2.cpp ├── HardwareSerial3.cpp ├── HardwareSerial4.cpp ├── HardwareSerial5.cpp ├── HardwareSerial6.cpp ├── HardwareSerial7.cpp ├── HardwareSerial8.cpp ├── IPAddress.cpp ├── IPAddress.h ├── IntervalTimer.cpp ├── IntervalTimer.h ├── Keyboard.h ├── MIDIUSB.h ├── Mouse.h ├── Print.cpp ├── Print.h ├── Printable.h ├── Server.h ├── Stream.cpp ├── Stream.h ├── Time.cpp ├── TimeLib.h ├── Tone.cpp ├── Udp.h ├── WCharacter.h ├── WMath.cpp ├── WProgram.h ├── WString.cpp ├── WString.h ├── analog.c ├── arm_common_tables.h ├── arm_const_structs.h ├── arm_math.h ├── avr │ ├── eeprom.h │ ├── interrupt.h │ ├── io.h │ ├── pgmspace.h │ ├── power.h │ ├── sleep.h │ └── wdt.h ├── avr_emulation.h ├── avr_functions.h ├── binary.h ├── bootdata.c ├── clockspeed.c ├── cmsis_gcc.h ├── core_cm7.h ├── core_cmInstr.h ├── core_id.h ├── core_pins.h ├── debug │ └── printf.h ├── debugprintf.c ├── delay.c ├── digital.c ├── eeprom.c ├── elapsedMillis.h ├── extmem.c ├── fuse.c ├── imxrt.h ├── imxrt1062.ld ├── imxrt1062_mm.ld ├── imxrt1062_t41.ld ├── inplace_function.h ├── interrupt.c ├── keylayouts.c ├── keylayouts.h ├── libc.c ├── math_helper.h ├── memcpy-armv7m.S ├── memset.S ├── new.cpp ├── nonstd.c ├── pgmspace.h ├── pins_arduino.h ├── printf.c ├── printf.h ├── pwm.c ├── rtc.c ├── serialEvent.cpp ├── serialEvent1.cpp ├── serialEvent2.cpp ├── serialEvent3.cpp ├── serialEvent4.cpp ├── serialEvent5.cpp ├── serialEvent6.cpp ├── serialEvent7.cpp ├── serialEvent8.cpp ├── serialEventUSB1.cpp ├── serialEventUSB2.cpp ├── sm_alloc_valid.c ├── sm_calloc.c ├── sm_free.c ├── sm_hash.c ├── sm_malloc.c ├── sm_malloc_stats.c ├── sm_pool.c ├── sm_realloc.c ├── sm_realloc_i.c ├── sm_realloc_move.c ├── sm_szalloc.c ├── sm_util.c ├── sm_zalloc.c ├── smalloc.h ├── smalloc_i.h ├── startup.c ├── tempmon.c ├── usb.c ├── usb_audio.cpp ├── usb_audio.h ├── usb_desc.c ├── usb_desc.h ├── usb_dev.h ├── usb_flightsim.cpp ├── usb_flightsim.h ├── usb_inst.cpp ├── usb_joystick.c ├── usb_joystick.h ├── usb_keyboard.c ├── usb_keyboard.h ├── usb_midi.c ├── usb_midi.h ├── usb_mouse.c ├── usb_mouse.h ├── usb_mtp.c ├── usb_mtp.h ├── usb_names.h ├── usb_rawhid.c ├── usb_rawhid.h ├── usb_seremu.c ├── usb_seremu.h ├── usb_serial.c ├── usb_serial.h ├── usb_serial2.c ├── usb_serial3.c ├── usb_touch.c ├── usb_touch.h ├── util │ ├── atomic.h │ ├── crc16.h │ ├── delay.h │ └── parity.h ├── wiring.h ├── wiring_private.h └── yield.cpp └── tools ├── get_tty_path.sh ├── git_scraper.cpp ├── install_arduino.sh ├── install_compiler.sh ├── install_tytools.sh ├── monitor.c ├── monitor.sh ├── prepare_gdb.sh ├── tcm_blame.py └── waggle-interceptor ├── Cargo.lock ├── Cargo.toml ├── README.md ├── make-upload.sh └── src └── main.rs /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # pre-commit githook, runs before a git commit is accepted. 4 | 5 | # branch protection githook inspired from https://stackoverflow.com/questions/75955185/is-there-a-way-to-protect-a-git-branch-locally 6 | # githook directory must be set locally in order for the hook to run. 7 | # set directory using: git config --local core.hooksPath 8 | 9 | current_branch="$(git branch --show-current)" 10 | 11 | # supports multiple protected branches. Add additional branches to for loop: for protected_branch in "branch1" "branch2" ... ; do 12 | for protected_branch in "main"; do 13 | if [[ "$protected_branch" == "$current_branch" ]]; then 14 | echo "ERROR: local branch $current_branch is protected" 15 | exit 1 16 | fi 17 | done 18 | 19 | exit 0 -------------------------------------------------------------------------------- /.github/workflows/deploy-pages.yml: -------------------------------------------------------------------------------- 1 | # This workflow generates documentation for a project using Doxygen and sets it up for GitHub pages. It will push the 2 | # documentation onto a special orphan branch to avoid cluttering the source code. This implementation comes from 3 | # https://ntamonsec.blogspot.com/2020/06/github-actions-doxygen-documentation.html 4 | name: Deploy Documentation 5 | 6 | # Controls when the action will run. 7 | on: 8 | push: 9 | branches: [ main ] 10 | 11 | jobs: 12 | build-documentation: 13 | runs-on: ubuntu-latest 14 | steps: 15 | # Checkout sets up working directory as project root 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | # Run Doxygen Build 19 | - name: Run Doxygen 20 | uses: mattnotmitt/doxygen-action@v1.9.1 21 | with: 22 | doxyfile-path: ./Doxyfile # Docs build settings 23 | working-directory: . 24 | enable-latex: false # could enable latex later if needed, but it has a slow install. 25 | - name: Pages Deployment 26 | if: success() || failure() # (Attempt to) deploy docs even if doxygen fails 27 | uses: peaceiris/actions-gh-pages@v3 28 | with: 29 | github_token: ${{ secrets.GITHUB_TOKEN }} 30 | publish_dir: ./docs/html/ 31 | enable_jekyll: false 32 | allow_empty_commit: false 33 | force_orphan: true 34 | publish_branch: doxygen-documentation 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore doxygen output directory. Shared documentation is handled by github-actions in a separate branch, not individuals' compilations sent here. 2 | /docs/html 3 | /docs/latex 4 | # Don't commit doxygen warnings log 5 | /docs/doxygen_warnings.txt 6 | 7 | # Ignore the build directory 8 | build 9 | build/ 10 | 11 | # Ignore the output binaries 12 | *.elf 13 | *.hex 14 | 15 | # Ignore the output debug files 16 | *.dump 17 | *.map 18 | 19 | # Ignore the libraries 20 | *.a 21 | *.tar.xz 22 | 23 | # Ignore clangd files 24 | compile_commands.json 25 | .cache/ 26 | .clangd 27 | .clang-format 28 | 29 | # Ignore any tools/ directory artifacts 30 | tools/*.txt 31 | tools/*.out 32 | tools/git_scraper 33 | tools/custom_monitor 34 | tools/compiler 35 | 36 | # Ignore the output from the git scraper 37 | src/git_info.h 38 | 39 | # Ignore MacOS files 40 | *.DS_Store 41 | 42 | # Ignore .vscode config 43 | .vscode 44 | 45 | 46 | # Ignore Rust tool's build directory 47 | /tools/waggle-interceptor/target 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023-2024 CU Robotics 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Makefile-githook: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make 2 | 3 | # run with: make -f Makefile-githook init 4 | 5 | # Set githook path to .githooks/ (from ./git/hooks) so that they are tracked on the repository's version control. 6 | init: 7 | git config --local core.hooksPath .githooks -------------------------------------------------------------------------------- /libraries/Adafruit_BusIO/Adafruit_I2CDevice.h: -------------------------------------------------------------------------------- 1 | #ifndef Adafruit_I2CDevice_h 2 | #define Adafruit_I2CDevice_h 3 | 4 | #include 5 | #include 6 | 7 | ///< The class which defines how we will talk to this device over I2C 8 | class Adafruit_I2CDevice { 9 | public: 10 | Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire); 11 | uint8_t address(void); 12 | bool begin(bool addr_detect = true); 13 | void end(void); 14 | bool detected(void); 15 | 16 | bool read(uint8_t *buffer, size_t len, bool stop = true); 17 | bool write(const uint8_t *buffer, size_t len, bool stop = true, 18 | const uint8_t *prefix_buffer = nullptr, size_t prefix_len = 0); 19 | bool write_then_read(const uint8_t *write_buffer, size_t write_len, 20 | uint8_t *read_buffer, size_t read_len, 21 | bool stop = false); 22 | bool setSpeed(uint32_t desiredclk); 23 | 24 | /*! @brief How many bytes we can read in a transaction 25 | * @return The size of the Wire receive/transmit buffer */ 26 | size_t maxBufferSize() { return _maxBufferSize; } 27 | 28 | private: 29 | uint8_t _addr; 30 | TwoWire *_wire; 31 | bool _begun; 32 | size_t _maxBufferSize; 33 | bool _read(uint8_t *buffer, size_t len, bool stop); 34 | }; 35 | 36 | #endif // Adafruit_I2CDevice_h 37 | -------------------------------------------------------------------------------- /libraries/Adafruit_BusIO/Adafruit_I2CRegister.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_I2C_REGISTER_H_ 2 | #define _ADAFRUIT_I2C_REGISTER_H_ 3 | 4 | #include 5 | #include 6 | 7 | typedef Adafruit_BusIO_Register Adafruit_I2CRegister; 8 | typedef Adafruit_BusIO_RegisterBits Adafruit_I2CRegisterBits; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libraries/Adafruit_ICM20X/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2019 Bryan Siepert for 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/Adafruit_LSM6DS/Adafruit_ISM330DHCX.cpp: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * @file Adafruit_ISM330DHCX.cpp Adafruit ISM330DHCX 6-DoF Accelerometer 4 | * and Gyroscope library 5 | * 6 | * Bryan Siepert for Adafruit Industries 7 | * BSD (see license.txt) 8 | */ 9 | 10 | #include "Arduino.h" 11 | #include 12 | 13 | #include "Adafruit_ISM330DHCX.h" 14 | 15 | /*! 16 | * @brief Instantiates a new ISM330DHCX class 17 | */ 18 | Adafruit_ISM330DHCX::Adafruit_ISM330DHCX(void) {} 19 | 20 | bool Adafruit_ISM330DHCX::_init(int32_t sensor_id) { 21 | // make sure we're talking to the right chip 22 | if (chipID() != ISM330DHCX_CHIP_ID) { 23 | return false; 24 | } 25 | _sensorid_accel = sensor_id; 26 | _sensorid_gyro = sensor_id + 1; 27 | _sensorid_temp = sensor_id + 2; 28 | 29 | reset(); 30 | 31 | // call base class _init() 32 | Adafruit_LSM6DS::_init(sensor_id); 33 | 34 | return true; 35 | } 36 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_ISM330DHCX.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_ISM330DHCX.h 3 | * 4 | * I2C Driver for the Adafruit ISM330DHCX 6-DoF Accelerometer and Gyroscope 5 | *library 6 | * 7 | * This is a library for the Adafruit ISM330DHCX breakout: 8 | * https://www.adafruit.com/products/4480 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing products from 12 | * Adafruit! 13 | * 14 | * 15 | * BSD license (see license.txt) 16 | */ 17 | 18 | #ifndef _ADAFRUIT_ISM330DHCX_H 19 | #define _ADAFRUIT_ISM330DHCX_H 20 | 21 | #include "Adafruit_LSM6DSOX.h" 22 | 23 | #define ISM330DHCX_CHIP_ID 0x6B ///< ISM330DHCX default device id from WHOAMI 24 | 25 | /*! 26 | * @brief Class that stores state and functions for interacting with 27 | * the ISM330DHCX I2C Digital Potentiometer 28 | */ 29 | class Adafruit_ISM330DHCX : public Adafruit_LSM6DSOX { 30 | public: 31 | Adafruit_ISM330DHCX(); 32 | ~Adafruit_ISM330DHCX(){}; 33 | 34 | private: 35 | bool _init(int32_t sensor_id); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DS3.cpp: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * @file Adafruit_LSM6DS3.cpp Adafruit LSM6DS3 6-DoF Accelerometer 4 | * and Gyroscope library 5 | * 6 | * Bryan Siepert for Adafruit Industries 7 | * BSD (see license.txt) 8 | */ 9 | 10 | #include "Arduino.h" 11 | #include 12 | 13 | #include "Adafruit_LSM6DS3.h" 14 | 15 | /*! 16 | * @brief Instantiates a new LSM6DS3 class 17 | */ 18 | Adafruit_LSM6DS3::Adafruit_LSM6DS3(void) {} 19 | 20 | bool Adafruit_LSM6DS3::_init(int32_t sensor_id) { 21 | // make sure we're talking to the right chip 22 | if (chipID() != LSM6DS3_CHIP_ID) { 23 | return false; 24 | } 25 | _sensorid_accel = sensor_id; 26 | _sensorid_gyro = sensor_id + 1; 27 | _sensorid_temp = sensor_id + 2; 28 | 29 | temperature_sensitivity = 16.0; 30 | 31 | reset(); 32 | 33 | // call base class _init() 34 | Adafruit_LSM6DS::_init(sensor_id); 35 | 36 | return true; 37 | } 38 | 39 | /**************************************************************************/ 40 | /*! 41 | @brief Enables and disables the I2C master bus pulllups. 42 | @param enable_pullups true to enable the I2C pullups, false to disable. 43 | */ 44 | void Adafruit_LSM6DS3::enableI2CMasterPullups(bool enable_pullups) { 45 | Adafruit_BusIO_Register master_config = Adafruit_BusIO_Register( 46 | i2c_dev, spi_dev, ADDRBIT8_HIGH_TOREAD, LSM6DS3_MASTER_CONFIG); 47 | Adafruit_BusIO_RegisterBits i2c_master_pu_en = 48 | Adafruit_BusIO_RegisterBits(&master_config, 1, 3); 49 | 50 | i2c_master_pu_en.write(enable_pullups); 51 | } 52 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DS3.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_LSM6DS3.h 3 | * 4 | * I2C Driver for the Adafruit LSM6DS3 6-DoF Accelerometer and Gyroscope 5 | *library 6 | * 7 | * This is a library for the Adafruit LSM6DS3 breakout: 8 | * https://www.adafruit.com/ 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing products from 12 | * Adafruit! 13 | * 14 | * 15 | * BSD license (see license.txt) 16 | */ 17 | 18 | #ifndef _ADAFRUIT_LSM6DS3_H 19 | #define _ADAFRUIT_LSM6DS3_H 20 | 21 | #include "Adafruit_LSM6DS.h" 22 | 23 | #define LSM6DS3_CHIP_ID 0x69 ///< LSM6DS3 default device id from WHOAMI 24 | 25 | #define LSM6DS3_MASTER_CONFIG 0x1A ///< I2C Master config 26 | 27 | /*! 28 | * @brief Class that stores state and functions for interacting with 29 | * the LSM6DS3 30 | */ 31 | class Adafruit_LSM6DS3 : public Adafruit_LSM6DS { 32 | public: 33 | Adafruit_LSM6DS3(); 34 | ~Adafruit_LSM6DS3(){}; 35 | 36 | void enableI2CMasterPullups(bool enable_pullups); 37 | 38 | private: 39 | bool _init(int32_t sensor_id); 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DS33.cpp: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * @file Adafruit_LSM6DS33.cpp Adafruit LSM6DS33 6-DoF Accelerometer 4 | * and Gyroscope library 5 | * 6 | * Bryan Siepert for Adafruit Industries 7 | * BSD (see license.txt) 8 | */ 9 | 10 | #include "Arduino.h" 11 | #include 12 | 13 | #include "Adafruit_LSM6DS33.h" 14 | 15 | /*! 16 | * @brief Instantiates a new LSM6DS33 class 17 | */ 18 | Adafruit_LSM6DS33::Adafruit_LSM6DS33(void) {} 19 | 20 | bool Adafruit_LSM6DS33::_init(int32_t sensor_id) { 21 | // make sure we're talking to the right chip 22 | if (chipID() != LSM6DS33_CHIP_ID) { 23 | return false; 24 | } 25 | _sensorid_accel = sensor_id; 26 | _sensorid_gyro = sensor_id + 1; 27 | _sensorid_temp = sensor_id + 2; 28 | 29 | temperature_sensitivity = 16.0; 30 | 31 | reset(); 32 | if (chipID() != LSM6DS33_CHIP_ID) { 33 | return false; 34 | } 35 | 36 | // call base class _init() 37 | Adafruit_LSM6DS::_init(sensor_id); 38 | 39 | return true; 40 | } 41 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DS33.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_LSM6DS33.h 3 | * 4 | * I2C Driver for the Adafruit LSM6DS33 6-DoF Accelerometer and Gyroscope 5 | *library 6 | * 7 | * This is a library for the Adafruit LSM6DS33 breakout: 8 | * https://www.adafruit.com/products/4480 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing products from 12 | * Adafruit! 13 | * 14 | * 15 | * BSD license (see license.txt) 16 | */ 17 | 18 | #ifndef _ADAFRUIT_LSM6DS33_H 19 | #define _ADAFRUIT_LSM6DS33_H 20 | 21 | #include "Adafruit_LSM6DS.h" 22 | 23 | #define LSM6DS33_CHIP_ID 0x69 ///< LSM6DS33 default device id from WHOAMI 24 | 25 | /*! 26 | * @brief Class that stores state and functions for interacting with 27 | * the LSM6DS33 I2C Digital Potentiometer 28 | */ 29 | class Adafruit_LSM6DS33 : public Adafruit_LSM6DS { 30 | public: 31 | Adafruit_LSM6DS33(); 32 | ~Adafruit_LSM6DS33(){}; 33 | 34 | private: 35 | bool _init(int32_t sensor_id); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DS3TRC.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_LSM6DSL.h 3 | * 4 | * I2C Driver for the Adafruit LSM6DSL 6-DoF Accelerometer and Gyroscope 5 | *library 6 | * 7 | * This is a library for the Adafruit LSM6DSL breakout: 8 | * https://www.adafruit.com/ 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing products from 12 | * Adafruit! 13 | * 14 | * 15 | * BSD license (see license.txt) 16 | */ 17 | 18 | #ifndef _ADAFRUIT_LSM6DS3TRC_H 19 | #define _ADAFRUIT_LSM6DS3TRC_H 20 | 21 | #include "Adafruit_LSM6DS.h" 22 | 23 | #define LSM6DS3TRC_CHIP_ID 0x6A ///< LSM6DSL default device id from WHOAMI 24 | 25 | #define LSM6DS3TRC_MASTER_CONFIG 0x1A ///< I2C Master config 26 | 27 | /*! 28 | * @brief Class that stores state and functions for interacting with 29 | * the LSM6DS3TRC 30 | */ 31 | class Adafruit_LSM6DS3TRC : public Adafruit_LSM6DS { 32 | public: 33 | Adafruit_LSM6DS3TRC(); 34 | ~Adafruit_LSM6DS3TRC(){}; 35 | 36 | void enableI2CMasterPullups(bool enable_pullups); 37 | void enablePedometer(bool enable); 38 | 39 | private: 40 | bool _init(int32_t sensor_id); 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DSL.cpp: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * @file Adafruit_LSM6DSL.cpp Adafruit LSM6DSL 6-DoF Accelerometer 4 | * and Gyroscope library 5 | * 6 | * Adapted by Eugene Anikin for Adafruit Industries 7 | * BSD (see license.txt) 8 | */ 9 | 10 | #include "Arduino.h" 11 | #include 12 | 13 | #include "Adafruit_LSM6DSL.h" 14 | 15 | /*! 16 | * @brief Instantiates a new LSM6DSL class 17 | */ 18 | Adafruit_LSM6DSL::Adafruit_LSM6DSL(void) {} 19 | 20 | bool Adafruit_LSM6DSL::_init(int32_t sensor_id) { 21 | // make sure we're talking to the right chip 22 | if (chipID() != LSM6DSL_CHIP_ID) { 23 | return false; 24 | } 25 | _sensorid_accel = sensor_id; 26 | _sensorid_gyro = sensor_id + 1; 27 | _sensorid_temp = sensor_id + 2; 28 | 29 | reset(); 30 | 31 | // call base class _init() 32 | Adafruit_LSM6DS::_init(sensor_id); 33 | 34 | return true; 35 | } 36 | 37 | /**************************************************************************/ 38 | /*! 39 | @brief Enables and disables the I2C master bus pulllups. 40 | @param enable_pullups true to enable the I2C pullups, false to disable. 41 | */ 42 | void Adafruit_LSM6DSL::enableI2CMasterPullups(bool enable_pullups) { 43 | Adafruit_BusIO_Register master_config = Adafruit_BusIO_Register( 44 | i2c_dev, spi_dev, ADDRBIT8_HIGH_TOREAD, LSM6DSL_MASTER_CONFIG); 45 | Adafruit_BusIO_RegisterBits i2c_master_pu_en = 46 | Adafruit_BusIO_RegisterBits(&master_config, 1, 3); 47 | 48 | i2c_master_pu_en.write(enable_pullups); 49 | } 50 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DSL.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_LSM6DSL.h 3 | * 4 | * I2C Driver for the Adafruit LSM6DSL 6-DoF Accelerometer and Gyroscope 5 | *library 6 | * 7 | * This is a library for the Adafruit LSM6DSL breakout: 8 | * https://www.adafruit.com/ 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing products from 12 | * Adafruit! 13 | * 14 | * 15 | * BSD license (see license.txt) 16 | */ 17 | 18 | #ifndef _ADAFRUIT_LSM6DSL_H 19 | #define _ADAFRUIT_LSM6DSL_H 20 | 21 | #include "Adafruit_LSM6DS.h" 22 | 23 | #define LSM6DSL_CHIP_ID 0x6A ///< LSM6DSL default device id from WHOAMI 24 | 25 | #define LSM6DSL_MASTER_CONFIG 0x1A ///< I2C Master config 26 | 27 | /*! 28 | * @brief Class that stores state and functions for interacting with 29 | * the LSM6DSL 30 | */ 31 | class Adafruit_LSM6DSL : public Adafruit_LSM6DS { 32 | public: 33 | Adafruit_LSM6DSL(); 34 | ~Adafruit_LSM6DSL(){}; 35 | 36 | void enableI2CMasterPullups(bool enable_pullups); 37 | 38 | private: 39 | bool _init(int32_t sensor_id); 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DSO32.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_LSM6DSO32.h 3 | * 4 | * I2C Driver for the Adafruit LSM6DSO32 6-DoF Accelerometer and Gyroscope 5 | *library 6 | * 7 | * This is a library for the Adafruit LSM6DSO32 breakout: 8 | * https://www.adafruit.com/products/PID_HERE 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing products from 12 | * Adafruit! 13 | * 14 | * 15 | * BSD license (see license.txt) 16 | */ 17 | 18 | #ifndef _ADAFRUIT_LSM6DSO32_H 19 | #define _ADAFRUIT_LSM6DSO32_H 20 | 21 | #include "Adafruit_LSM6DS.h" 22 | #include "Adafruit_LSM6DSOX.h" 23 | #define LSM6DSO32_CHIP_ID 0x6C ///< LSM6DSO32 default device id from WHOAMI 24 | 25 | /** The accelerometer data range */ 26 | typedef enum dso32_accel_range { 27 | LSM6DSO32_ACCEL_RANGE_4_G, 28 | LSM6DSO32_ACCEL_RANGE_32_G, 29 | LSM6DSO32_ACCEL_RANGE_8_G, 30 | LSM6DSO32_ACCEL_RANGE_16_G 31 | } lsm6dso32_accel_range_t; 32 | 33 | /*! 34 | * @brief Class that stores state and functions for interacting with 35 | * the LSM6DSO32 I2C Digital Potentiometer 36 | */ 37 | class Adafruit_LSM6DSO32 : public Adafruit_LSM6DSOX { 38 | public: 39 | Adafruit_LSM6DSO32(); 40 | 41 | lsm6dso32_accel_range_t getAccelRange(void); 42 | void setAccelRange(lsm6dso32_accel_range_t new_range); 43 | void _read(void); 44 | 45 | private: 46 | bool _init(int32_t sensor_id); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/Adafruit_LSM6DSOX.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_LSM6DSOX.h 3 | * 4 | * I2C Driver for the Adafruit LSM6DSOX 6-DoF Accelerometer and Gyroscope 5 | *library 6 | * 7 | * This is a library for the Adafruit LSM6DSOX breakout: 8 | * https://www.adafruit.com/products/PID_HERE 9 | * 10 | * Adafruit invests time and resources providing this open source code, 11 | * please support Adafruit and open-source hardware by purchasing products from 12 | * Adafruit! 13 | * 14 | * 15 | * BSD license (see license.txt) 16 | */ 17 | 18 | #ifndef _ADAFRUIT_LSM6DSOX_H 19 | #define _ADAFRUIT_LSM6DSOX_H 20 | 21 | #include "Adafruit_LSM6DS.h" 22 | 23 | #define LSM6DSOX_CHIP_ID 0x6C ///< LSM6DSOX default device id from WHOAMI 24 | 25 | #define LSM6DSOX_FUNC_CFG_ACCESS 0x1 ///< Enable embedded functions register 26 | #define LSM6DSOX_PIN_CTRL 0x2 ///< Pin control register 27 | 28 | #define LSM6DSOX_INT1_CTRL 0x0D ///< Interrupt enable for data ready 29 | #define LSM6DSOX_CTRL1_XL 0x10 ///< Main accelerometer config register 30 | #define LSM6DSOX_CTRL2_G 0x11 ///< Main gyro config register 31 | #define LSM6DSOX_CTRL3_C 0x12 ///< Main configuration register 32 | #define LSM6DSOX_CTRL9_XL 0x18 ///< Includes i3c disable bit 33 | 34 | #define LSM6DSOX_MASTER_CONFIG 0x14 35 | ///< I2C Master config; access must be enabled with bit SHUB_REG_ACCESS 36 | ///< is set to '1' in FUNC_CFG_ACCESS (01h). 37 | 38 | /*! 39 | * @brief Class that stores state and functions for interacting with 40 | * the LSM6DSOX I2C Digital Potentiometer 41 | */ 42 | class Adafruit_LSM6DSOX : public Adafruit_LSM6DS { 43 | public: 44 | Adafruit_LSM6DSOX(); 45 | 46 | void enableI2CMasterPullups(bool enable_pullups); 47 | void disableSPIMasterPullups(bool disable_pullups); 48 | 49 | private: 50 | bool _init(int32_t sensor_id); 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /libraries/Adafruit_LSM6DS/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2019 Bryan Siepert for 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/FastLED/src/bitswap.cpp: -------------------------------------------------------------------------------- 1 | /// @file bitswap.cpp 2 | /// Functions for doing a rotation of bits/bytes used by parallel output 3 | 4 | /// Disables pragma messages and warnings 5 | #define FASTLED_INTERNAL 6 | -------------------------------------------------------------------------------- /libraries/FastLED/src/colorpalettes.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_COLORPALETTES_H 2 | #define __INC_COLORPALETTES_H 3 | 4 | #include "FastLED.h" 5 | #include "colorutils.h" 6 | 7 | /// @file colorpalettes.h 8 | /// Declarations for the predefined color palettes supplied by FastLED. 9 | 10 | // Have Doxygen ignore these declarations 11 | /// @cond 12 | 13 | FASTLED_NAMESPACE_BEGIN 14 | 15 | extern const TProgmemRGBPalette16 CloudColors_p FL_PROGMEM; 16 | extern const TProgmemRGBPalette16 LavaColors_p FL_PROGMEM; 17 | extern const TProgmemRGBPalette16 OceanColors_p FL_PROGMEM; 18 | extern const TProgmemRGBPalette16 ForestColors_p FL_PROGMEM; 19 | 20 | extern const TProgmemRGBPalette16 RainbowColors_p FL_PROGMEM; 21 | 22 | /// Alias of RainbowStripeColors_p 23 | #define RainbowStripesColors_p RainbowStripeColors_p 24 | extern const TProgmemRGBPalette16 RainbowStripeColors_p FL_PROGMEM; 25 | 26 | extern const TProgmemRGBPalette16 PartyColors_p FL_PROGMEM; 27 | 28 | extern const TProgmemRGBPalette16 HeatColors_p FL_PROGMEM; 29 | 30 | 31 | DECLARE_GRADIENT_PALETTE( Rainbow_gp); 32 | 33 | FASTLED_NAMESPACE_END 34 | 35 | /// @endcond 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libraries/FastLED/src/cpp_compat.h: -------------------------------------------------------------------------------- 1 | /// @file cpp_compat.h 2 | /// Compatibility functions based on C++ version 3 | 4 | #ifndef __INC_CPP_COMPAT_H 5 | #define __INC_CPP_COMPAT_H 6 | 7 | #include "FastLED.h" 8 | 9 | #if __cplusplus <= 199711L 10 | 11 | /// Compile-time assertion checking, introduced in C++11 12 | /// @see https://en.cppreference.com/w/cpp/language/static_assert 13 | #define static_assert(expression, message) 14 | 15 | /// Declares that it is possible to evaluate a value at compile time, introduced in C++11 16 | /// @see https://en.cppreference.com/w/cpp/language/constexpr 17 | #define constexpr const 18 | 19 | #else 20 | 21 | // things that we can turn on if we're in a C++11 environment 22 | #endif 23 | 24 | /// @def FASTLED_REGISTER 25 | /// Helper macro to replace the deprecated 'register' keyword if we're 26 | /// using modern C++ where it's been removed entirely. 27 | 28 | #if __cplusplus < 201703L 29 | #define FASTLED_REGISTER register 30 | #else 31 | #ifdef FASTLED_REGISTER 32 | #undef FASTLED_REGISTER 33 | #endif 34 | #define FASTLED_REGISTER 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libraries/FastLED/src/dither_mode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | /// Disable dithering 5 | #define DISABLE_DITHER 0x00 6 | /// Enable dithering using binary dithering (only option) 7 | #define BINARY_DITHER 0x01 8 | /// The dither setting, either DISABLE_DITHER or BINARY_DITHER 9 | typedef uint8_t EDitherMode; 10 | -------------------------------------------------------------------------------- /libraries/FastLED/src/eorder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "namespace.h" 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | /// RGB color channel orderings, used when instantiating controllers to determine 7 | /// what order the controller should send data out in. The default ordering 8 | /// is RGB. 9 | /// Within this enum, the red channel is 0, the green channel is 1, and the 10 | /// blue chanel is 2. 11 | enum EOrder { 12 | RGB=0012, ///< Red, Green, Blue (0012) 13 | RBG=0021, ///< Red, Blue, Green (0021) 14 | GRB=0102, ///< Green, Red, Blue (0102) 15 | GBR=0120, ///< Green, Blue, Red (0120) 16 | BRG=0201, ///< Blue, Red, Green (0201) 17 | BGR=0210 ///< Blue, Green, Red (0210) 18 | }; 19 | 20 | // After EOrder is applied this is where W is inserted for RGBW. 21 | enum EOrderW { 22 | W3 = 0x3, ///< White is fourth 23 | W2 = 0x2, ///< White is third 24 | W1 = 0x1, ///< White is second 25 | W0 = 0x0, ///< White is first 26 | WDefault = W3 27 | }; 28 | 29 | FASTLED_NAMESPACE_END 30 | 31 | -------------------------------------------------------------------------------- /libraries/FastLED/src/fastspi_dma.h: -------------------------------------------------------------------------------- 1 | /// @file fastspi_dma.h 2 | /// Direct memory access (DMA) functions for SPI interfaces 3 | /// @deprecated This header file is empty. 4 | -------------------------------------------------------------------------------- /libraries/FastLED/src/force_inline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define FASTLED_FORCE_INLINE __attribute__((always_inline)) inline -------------------------------------------------------------------------------- /libraries/FastLED/src/namespace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef FASTLED_NAMESPACE_BEGIN 4 | /// Start of the FastLED namespace 5 | #define FASTLED_NAMESPACE_BEGIN 6 | /// End of the FastLED namespace 7 | #define FASTLED_NAMESPACE_END 8 | /// "Using" directive for the namespace 9 | #define FASTLED_USING_NAMESPACE 10 | #endif -------------------------------------------------------------------------------- /libraries/FastLED/src/pixeltypes.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_PIXELS_H 2 | #define __INC_PIXELS_H 3 | 4 | #include "FastLED.h" 5 | 6 | #include 7 | #include "lib8tion.h" 8 | #include "color.h" 9 | #include "eorder.h" 10 | #include "chsv.h" 11 | #include "crgb.hpp" 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms.cpp: -------------------------------------------------------------------------------- 1 | /// @file platforms.cpp 2 | /// Platform-specific functions and variables 3 | 4 | /// Disables pragma messages and warnings 5 | #define FASTLED_INTERNAL 6 | 7 | 8 | // Interrupt handlers cannot be defined in the header. 9 | // They must be defined as C functions, or they won't 10 | // be found (due to name mangling), and thus won't 11 | // override any default weak definition. 12 | #if defined(NRF52_SERIES) 13 | 14 | #include "platforms/arm/nrf52/led_sysdefs_arm_nrf52.h" 15 | #include "platforms/arm/nrf52/arbiter_nrf52.h" 16 | 17 | uint32_t isrCount; 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | // NOTE: Update platforms.cpp in root of FastLED library if this changes 23 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE0) 24 | void PWM0_IRQHandler(void) { ++isrCount; PWM_Arbiter<0>::isr_handler(); } 25 | #endif 26 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE1) 27 | void PWM1_IRQHandler(void) { ++isrCount; PWM_Arbiter<1>::isr_handler(); } 28 | #endif 29 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE2) 30 | void PWM2_IRQHandler(void) { ++isrCount; PWM_Arbiter<2>::isr_handler(); } 31 | #endif 32 | #if defined(FASTLED_NRF52_ENABLE_PWM_INSTANCE3) 33 | void PWM3_IRQHandler(void) { ++isrCount; PWM_Arbiter<3>::isr_handler(); } 34 | #endif 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // defined(NRF52_SERIES) 40 | 41 | 42 | 43 | // FASTLED_NAMESPACE_BEGIN 44 | // FASTLED_NAMESPACE_END 45 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/apollo3/fastled_apollo3.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_APOLLO3_H 2 | #define __INC_FASTLED_APOLLO3_H 3 | 4 | #include "fastpin_apollo3.h" 5 | #include "fastspi_apollo3.h" 6 | #include "clockless_apollo3.h" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/apollo3/led_sysdefs_apollo3.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_APOLLO3_H 2 | #define __INC_LED_SYSDEFS_APOLLO3_H 3 | 4 | #define FASTLED_APOLLO3 5 | 6 | #ifndef INTERRUPT_THRESHOLD 7 | #define INTERRUPT_THRESHOLD 1 8 | #endif 9 | 10 | // Default to allowing interrupts 11 | #ifndef FASTLED_ALLOW_INTERRUPTS 12 | #define FASTLED_ALLOW_INTERRUPTS 1 13 | #endif 14 | 15 | #if FASTLED_ALLOW_INTERRUPTS == 1 16 | #define FASTLED_ACCURATE_CLOCK 17 | #endif 18 | 19 | #ifndef F_CPU 20 | #define F_CPU 48000000 21 | #endif 22 | 23 | // Default to NOT using PROGMEM 24 | #ifndef FASTLED_USE_PROGMEM 25 | #define FASTLED_USE_PROGMEM 0 26 | #endif 27 | 28 | // data type defs 29 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 30 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 31 | 32 | #define FASTLED_NO_PINMAP 33 | 34 | // reusing/abusing cli/sei defs for due 35 | // These should be fine for the Apollo3. It has its own defines in cmsis_gcc.h 36 | #define cli() __disable_irq(); //__disable_fault_irq(); 37 | #define sei() __enable_irq(); //__enable_fault_irq(); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/d21/fastled_arm_d21.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_D21_H 2 | #define __INC_FASTLED_ARM_D21_H 3 | 4 | #include "fastpin_arm_d21.h" 5 | #include "clockless_arm_d21.h" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/d21/led_sysdefs_arm_d21.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_D21_H 2 | #define __INC_LED_SYSDEFS_ARM_D21_H 3 | 4 | 5 | #define FASTLED_ARM 6 | #define FASTLED_ARM_M0_PLUS 7 | 8 | #ifndef INTERRUPT_THRESHOLD 9 | #define INTERRUPT_THRESHOLD 1 10 | #endif 11 | 12 | // Default to allowing interrupts 13 | #ifndef FASTLED_ALLOW_INTERRUPTS 14 | #define FASTLED_ALLOW_INTERRUPTS 1 15 | #endif 16 | 17 | #if FASTLED_ALLOW_INTERRUPTS == 1 18 | #define FASTLED_ACCURATE_CLOCK 19 | #endif 20 | 21 | // reusing/abusing cli/sei defs for due 22 | #define cli() __disable_irq(); 23 | #define sei() __enable_irq(); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/d51/README.txt: -------------------------------------------------------------------------------- 1 | FastLED updates for adafruit FEATHER M4 and fixes to ITSBITSY M4 compiles 2 | SAMD51 3 | 4 | Tested on 5 | - FEATHER M4 with DOTSTAR and neopixel strips 6 | - Seeed Wio Terminal and WS2812B and APA102 LED strips using either SPI or GPIO pins 7 | 8 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/d51/fastled_arm_d51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_D51_H 2 | #define __INC_FASTLED_ARM_D51_H 3 | 4 | #include "fastpin_arm_d51.h" 5 | #include "../../fastspi_ardunio_core.h" 6 | #include "clockless_arm_d51.h" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/d51/led_sysdefs_arm_d51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_D51_H 2 | #define __INC_LED_SYSDEFS_ARM_D51_H 3 | 4 | 5 | #define FASTLED_ARM 6 | 7 | #ifndef INTERRUPT_THRESHOLD 8 | #define INTERRUPT_THRESHOLD 1 9 | #endif 10 | 11 | // Default to allowing interrupts 12 | #ifndef FASTLED_ALLOW_INTERRUPTS 13 | #define FASTLED_ALLOW_INTERRUPTS 1 14 | #endif 15 | 16 | #if FASTLED_ALLOW_INTERRUPTS == 1 17 | #define FASTLED_ACCURATE_CLOCK 18 | #endif 19 | 20 | // reusing/abusing cli/sei defs for due 21 | #define cli() __disable_irq(); 22 | #define sei() __enable_irq(); 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/k20/fastled_arm_k20.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_K20_H 2 | #define __INC_FASTLED_ARM_K20_H 3 | 4 | // Include the k20 headers 5 | #include "fastpin_arm_k20.h" 6 | #include "fastspi_arm_k20.h" 7 | #include "octows2811_controller.h" 8 | #include "ws2812serial_controller.h" 9 | #include "smartmatrix_t3.h" 10 | #include "clockless_arm_k20.h" 11 | #include "clockless_block_arm_k20.h" 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/k20/led_sysdefs_arm_k20.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_K20_H 2 | #define __INC_LED_SYSDEFS_ARM_K20_H 3 | 4 | #define FASTLED_TEENSY3 5 | #define FASTLED_ARM 6 | 7 | #ifndef INTERRUPT_THRESHOLD 8 | #define INTERRUPT_THRESHOLD 1 9 | #endif 10 | 11 | // Default to allowing interrupts 12 | #ifndef FASTLED_ALLOW_INTERRUPTS 13 | #define FASTLED_ALLOW_INTERRUPTS 1 14 | #endif 15 | 16 | #if FASTLED_ALLOW_INTERRUPTS == 1 17 | #define FASTLED_ACCURATE_CLOCK 18 | #endif 19 | 20 | #if (F_CPU == 96000000) 21 | #define CLK_DBL 1 22 | #endif 23 | 24 | // Get some system include files 25 | #include 26 | #include // for cli/se definitions 27 | 28 | // Define the register types 29 | #if defined(ARDUINO) // && ARDUINO < 150 30 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 31 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 32 | #endif 33 | 34 | extern volatile uint32_t systick_millis_count; 35 | # define MS_COUNTER systick_millis_count 36 | 37 | 38 | // Default to using PROGMEM, since TEENSY3 provides it 39 | // even though all it does is ignore it. Just being 40 | // conservative here in case TEENSY3 changes. 41 | #ifndef FASTLED_USE_PROGMEM 42 | #define FASTLED_USE_PROGMEM 1 43 | #endif 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/k20/smartmatrix_t3.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_SMARTMATRIX_T3_H 2 | #define __INC_SMARTMATRIX_T3_H 3 | 4 | #ifdef SmartMatrix_h 5 | #include 6 | 7 | FASTLED_NAMESPACE_BEGIN 8 | 9 | extern SmartMatrix *pSmartMatrix; 10 | 11 | // note - dmx simple must be included before FastSPI for this code to be enabled 12 | class CSmartMatrixController : public CPixelLEDController { 13 | SmartMatrix matrix; 14 | 15 | public: 16 | // initialize the LED controller 17 | virtual void init() { 18 | // Initialize 32x32 LED Matrix 19 | matrix.begin(); 20 | matrix.setBrightness(255); 21 | matrix.setColorCorrection(ccNone); 22 | 23 | // Clear screen 24 | clearLeds(0); 25 | matrix.swapBuffers(); 26 | pSmartMatrix = &matrix; 27 | } 28 | 29 | virtual void showPixels(PixelController & pixels) { 30 | if(SMART_MATRIX_CAN_TRIPLE_BUFFER) { 31 | rgb24 *md = matrix.getRealBackBuffer(); 32 | } else { 33 | rgb24 *md = matrix.backBuffer(); 34 | } 35 | while(pixels.has(1)) { 36 | md->red = pixels.loadAndScale0(); 37 | md->green = pixels.loadAndScale1(); 38 | md->blue = pixels.loadAndScale2(); 39 | md++; 40 | pixels.advanceData(); 41 | pixels.stepDithering(); 42 | } 43 | matrix.swapBuffers(); 44 | if(SMART_MATRIX_CAN_TRIPLE_BUFFER && pixels.advanceBy() > 0) { 45 | matrix.setBackBuffer(pixels.mData); 46 | } 47 | } 48 | }; 49 | 50 | FASTLED_NAMESPACE_END 51 | 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/k20/ws2812serial_controller.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_WS2812SERIAL_CONTROLLER_H 2 | #define __INC_WS2812SERIAL_CONTROLLER_H 3 | 4 | #ifdef USE_WS2812SERIAL 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | template 9 | class CWS2812SerialController : public CPixelLEDController { 10 | WS2812Serial *pserial; 11 | uint8_t *drawbuffer,*framebuffer; 12 | 13 | void _init(int nLeds) { 14 | if (pserial == NULL) { 15 | drawbuffer = (uint8_t*)malloc(nLeds * 3); 16 | framebuffer = (uint8_t*)malloc(nLeds * 12); 17 | pserial = new WS2812Serial(nLeds, framebuffer, drawbuffer, DATA_PIN, WS2812_RGB); 18 | pserial->begin(); 19 | } 20 | } 21 | 22 | public: 23 | CWS2812SerialController() { pserial = NULL; } 24 | 25 | virtual void init() { /* do nothing yet */ } 26 | 27 | virtual void showPixels(PixelController & pixels) { 28 | _init(pixels.size()); 29 | 30 | uint8_t *p = drawbuffer; 31 | 32 | while(pixels.has(1)) { 33 | *p++ = pixels.loadAndScale0(); 34 | *p++ = pixels.loadAndScale1(); 35 | *p++ = pixels.loadAndScale2(); 36 | pixels.stepDithering(); 37 | pixels.advanceData(); 38 | } 39 | pserial->show(); 40 | } 41 | 42 | }; 43 | 44 | FASTLED_NAMESPACE_END 45 | 46 | #endif // USE_WS2812SERIAL 47 | #endif // __INC_WS2812SERIAL_CONTROLLER_H 48 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/k66/fastled_arm_k66.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_K66_H 2 | #define __INC_FASTLED_ARM_K66_H 3 | 4 | // Include the k66 headers 5 | #include "fastpin_arm_k66.h" 6 | #include "fastspi_arm_k66.h" 7 | #include "../k20/octows2811_controller.h" 8 | #include "../k20/ws2812serial_controller.h" 9 | #include "../k20/smartmatrix_t3.h" 10 | #include "clockless_arm_k66.h" 11 | #include "clockless_block_arm_k66.h" 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/k66/led_sysdefs_arm_k66.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_K66_H 2 | #define __INC_LED_SYSDEFS_ARM_K66_H 3 | 4 | #define FASTLED_TEENSY3 5 | #define FASTLED_ARM 6 | 7 | #ifndef INTERRUPT_THRESHOLD 8 | #define INTERRUPT_THRESHOLD 1 9 | #endif 10 | 11 | // Default to allowing interrupts 12 | #ifndef FASTLED_ALLOW_INTERRUPTS 13 | #define FASTLED_ALLOW_INTERRUPTS 1 14 | #endif 15 | 16 | #if FASTLED_ALLOW_INTERRUPTS == 1 17 | #define FASTLED_ACCURATE_CLOCK 18 | #endif 19 | 20 | #if (F_CPU == 192000000) 21 | #define CLK_DBL 1 22 | #endif 23 | 24 | // Get some system include files 25 | #include 26 | #include // for cli/se definitions 27 | 28 | // Define the register types 29 | #if defined(ARDUINO) // && ARDUINO < 150 30 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 31 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 32 | #endif 33 | 34 | extern volatile uint32_t systick_millis_count; 35 | # define MS_COUNTER systick_millis_count 36 | 37 | 38 | // Default to using PROGMEM, since TEENSY3 provides it 39 | // even though all it does is ignore it. Just being 40 | // conservative here in case TEENSY3 changes. 41 | #ifndef FASTLED_USE_PROGMEM 42 | #define FASTLED_USE_PROGMEM 1 43 | #endif 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/kl26/fastled_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_KL26_H 2 | #define __INC_FASTLED_ARM_KL26_H 3 | 4 | // Include the k20 headers 5 | #include "fastpin_arm_kl26.h" 6 | #include "fastspi_arm_kl26.h" 7 | #include "clockless_arm_kl26.h" 8 | #include "../k20/ws2812serial_controller.h" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/kl26/led_sysdefs_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_KL26_H 2 | #define __INC_LED_SYSDEFS_ARM_KL26_H 3 | 4 | #define FASTLED_TEENSYLC 5 | #define FASTLED_ARM 6 | #define FASTLED_ARM_M0_PLUS 7 | 8 | #ifndef INTERRUPT_THRESHOLD 9 | #define INTERRUPT_THRESHOLD 1 10 | #endif 11 | 12 | #define FASTLED_SPI_BYTE_ONLY 13 | 14 | // Default to allowing interrupts 15 | #ifndef FASTLED_ALLOW_INTERRUPTS 16 | // #define FASTLED_ALLOW_INTERRUPTS 1 17 | #endif 18 | 19 | #if FASTLED_ALLOW_INTERRUPTS == 1 20 | #define FASTLED_ACCURATE_CLOCK 21 | #endif 22 | 23 | #if (F_CPU == 96000000) 24 | #define CLK_DBL 1 25 | #endif 26 | 27 | // Get some system include files 28 | #include 29 | #include // for cli/se definitions 30 | 31 | // Define the register types 32 | #if defined(ARDUINO) // && ARDUINO < 150 33 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 34 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 35 | #endif 36 | 37 | extern volatile uint32_t systick_millis_count; 38 | # define MS_COUNTER systick_millis_count 39 | 40 | // Default to using PROGMEM since TEENSYLC provides it 41 | // even though all it does is ignore it. Just being 42 | // conservative here in case TEENSYLC changes. 43 | #ifndef FASTLED_USE_PROGMEM 44 | #define FASTLED_USE_PROGMEM 1 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/mxrt1062/fastled_arm_mxrt1062.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_MXRT1062_H 2 | #define __INC_FASTLED_ARM_MXRT1062_H 3 | 4 | #include "fastpin_arm_mxrt1062.h" 5 | #include "fastspi_arm_mxrt1062.h" 6 | #include "octows2811_controller.h" 7 | #include "../k20/ws2812serial_controller.h" 8 | #include "../k20/smartmatrix_t3.h" 9 | #include "clockless_arm_mxrt1062.h" 10 | #include "block_clockless_arm_mxrt1062.h" 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/mxrt1062/led_sysdefs_arm_mxrt1062.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_MXRT1062_H 2 | #define __INC_LED_SYSDEFS_ARM_MXRT1062_H 3 | 4 | #define FASTLED_TEENSY4 5 | #define FASTLED_ARM 6 | 7 | #ifndef INTERRUPT_THRESHOLD 8 | #define INTERRUPT_THRESHOLD 1 9 | #endif 10 | 11 | // Default to allowing interrupts 12 | #ifndef FASTLED_ALLOW_INTERRUPTS 13 | #define FASTLED_ALLOW_INTERRUPTS 1 14 | #endif 15 | 16 | #if FASTLED_ALLOW_INTERRUPTS == 1 17 | #define FASTLED_ACCURATE_CLOCK 18 | #endif 19 | 20 | #if (F_CPU == 96000000) 21 | #define CLK_DBL 1 22 | #endif 23 | 24 | // Get some system include files 25 | #include 26 | #include // for cli/se definitions 27 | 28 | // Define the register types 29 | #if defined(ARDUINO) // && ARDUINO < 150 30 | typedef volatile uint32_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 31 | typedef volatile uint32_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 32 | #endif 33 | 34 | // extern volatile uint32_t systick_millis_count; 35 | // # define MS_COUNTER systick_millis_count 36 | 37 | // Teensy4 provides progmem 38 | #ifndef FASTLED_USE_PROGMEM 39 | #define FASTLED_USE_PROGMEM 1 40 | #endif 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/mxrt1062/octows2811_controller.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_OCTOWS2811_CONTROLLER_H 2 | #define __INC_OCTOWS2811_CONTROLLER_H 3 | 4 | #ifdef USE_OCTOWS2811 5 | 6 | #include "OctoWS2811.h" 7 | 8 | FASTLED_NAMESPACE_BEGIN 9 | 10 | template 11 | class COctoWS2811Controller : public CPixelLEDController { 12 | OctoWS2811 *pocto; 13 | uint8_t *drawbuffer,*framebuffer; 14 | 15 | void _init(int nLeds) { 16 | if(pocto == NULL) { 17 | drawbuffer = (uint8_t*)malloc(nLeds * 8 * 3); 18 | framebuffer = (uint8_t*)malloc(nLeds * 8 * 3); 19 | 20 | // byte ordering is handled in show by the pixel controller 21 | int config = WS2811_RGB; 22 | config |= CHIP; 23 | 24 | pocto = new OctoWS2811(nLeds, framebuffer, drawbuffer, config); 25 | 26 | pocto->begin(); 27 | } 28 | } 29 | public: 30 | COctoWS2811Controller() { pocto = NULL; } 31 | virtual int size() { return CLEDController::size() * 8; } 32 | 33 | virtual void init() { /* do nothing yet */ } 34 | 35 | virtual void showPixels(PixelController &pixels) { 36 | uint32_t size = pixels.size(); 37 | uint32_t sizeTimes8 = 8U * size; 38 | _init(size); 39 | 40 | uint32_t index = 0; 41 | while (pixels.has(1)) { 42 | for (int lane = 0; lane < 8; lane++) { 43 | uint8_t r = pixels.loadAndScale0(lane); 44 | uint8_t g = pixels.loadAndScale1(lane); 45 | uint8_t b = pixels.loadAndScale2(lane); 46 | pocto->setPixel(index, r, g, b); 47 | index += size; 48 | } 49 | index -= sizeTimes8; 50 | index++; 51 | pixels.stepDithering(); 52 | pixels.advanceData(); 53 | } 54 | 55 | pocto->show(); 56 | } 57 | 58 | }; 59 | 60 | FASTLED_NAMESPACE_END 61 | 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/nrf51/fastled_arm_nrf51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_NRF51_H 2 | #define __INC_FASTLED_ARM_NRF51_H 3 | 4 | // Include the k20 headers 5 | #include "fastpin_arm_nrf51.h" 6 | #include "fastspi_arm_nrf51.h" 7 | #include "clockless_arm_nrf51.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/nrf51/led_sysdefs_arm_nrf51.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_SYSDEFS_ARM_NRF51 2 | #define __LED_SYSDEFS_ARM_NRF51 3 | 4 | #ifndef NRF51 5 | #define NRF51 6 | #endif 7 | 8 | #define LED_TIMER NRF_TIMER1 9 | #define FASTLED_NO_PINMAP 10 | #define FASTLED_HAS_CLOCKLESS 11 | 12 | #define FASTLED_SPI_BYTE_ONLY 13 | 14 | #define FASTLED_ARM 15 | #define FASTLED_ARM_M0 16 | 17 | #ifndef F_CPU 18 | #define F_CPU 16000000 19 | #endif 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | typedef volatile uint32_t RoReg; 26 | typedef volatile uint32_t RwReg; 27 | typedef uint32_t prog_uint32_t; 28 | typedef uint8_t boolean; 29 | 30 | #define PROGMEM 31 | #define NO_PROGMEM 32 | #define NEED_CXX_BITS 33 | 34 | // Default to NOT using PROGMEM here 35 | #ifndef FASTLED_USE_PROGMEM 36 | #define FASTLED_USE_PROGMEM 0 37 | #endif 38 | 39 | #ifndef FASTLED_ALLOW_INTERRUPTS 40 | #define FASTLED_ALLOW_INTERRUPTS 1 41 | #endif 42 | 43 | #define cli() __disable_irq(); 44 | #define sei() __enable_irq(); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/nrf52/fastled_arm_nrf52.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_NRF52_H 2 | #define __INC_FASTLED_ARM_NRF52_H 3 | 4 | #include "led_sysdefs_arm_nrf52.h" 5 | #include "arbiter_nrf52.h" 6 | #include "fastpin_arm_nrf52.h" 7 | #include "fastspi_arm_nrf52.h" 8 | #include "clockless_arm_nrf52.h" 9 | 10 | #endif // #ifndef __INC_FASTLED_ARM_NRF52_H 11 | 12 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/nrf52/led_sysdefs_arm_nrf52.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_SYSDEFS_ARM_NRF52 2 | #define __LED_SYSDEFS_ARM_NRF52 3 | 4 | #include "force_inline.h" 5 | 6 | #define FASTLED_ARM 7 | 8 | #ifndef F_CPU 9 | #define F_CPU 64000000 // the NRF52 series has a 64MHz CPU 10 | #endif 11 | 12 | // even though CPU is at 64MHz, use the 8MHz-defined timings because... 13 | // PWM module runs at 16MHz 14 | // SPI0..2 runs at 8MHz 15 | #define CLOCKLESS_FREQUENCY 16000000 // the NRF52 has EasyDMA for PWM module at 16MHz 16 | 17 | #ifndef F_TIMER 18 | #define F_TIMER 16000000 // the NRF52 timer is 16MHz, even though CPU is 64MHz 19 | #endif 20 | 21 | #if !defined(FASTLED_USE_PROGMEM) 22 | #define FASTLED_USE_PROGMEM 0 // nRF52 series have flat memory model 23 | #endif 24 | 25 | #if !defined(FASTLED_ALLOW_INTERRUPTS) 26 | #define FASTLED_ALLOW_INTERRUPTS 1 27 | #endif 28 | 29 | // Use PWM instance 0 30 | // See clockless_arm_nrf52.h and (in root of library) platforms.cpp 31 | #define FASTLED_NRF52_ENABLE_PWM_INSTANCE0 32 | 33 | #if defined(FASTLED_NRF52_NEVER_INLINE) 34 | #define FASTLED_NRF52_INLINE_ATTRIBUTE FASTLED_FORCE_INLINE 35 | #else 36 | #define FASTLED_NRF52_INLINE_ATTRIBUTE FASTLED_FORCE_INLINE 37 | #endif 38 | 39 | 40 | 41 | #include 42 | #include // for FastSPI 43 | #include // for Clockless 44 | #include // for Clockless / anything else using interrupts 45 | typedef __I uint32_t RoReg; 46 | typedef __IO uint32_t RwReg; 47 | 48 | #define cli() __disable_irq() 49 | #define sei() __enable_irq() 50 | 51 | #define FASTLED_NRF52_DEBUGPRINT(format, ...)\ 52 | // do { FastLED_NRF52_DebugPrint(format, ##__VA_ARGS__); } while(0); 53 | 54 | #endif // __LED_SYSDEFS_ARM_NRF52 55 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/renesas/fastled_arm_renesas.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_RENESAS_H 2 | #define __INC_FASTLED_ARM_RENESAS_H 3 | 4 | #include "fastpin_arm_renesas.h" 5 | #include "../../fastspi_ardunio_core.h" 6 | #include "clockless_arm_renesas.h" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/renesas/led_sysdef_arm_renesas.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_RENESAS_H 2 | #define __INC_LED_SYSDEFS_ARM_RENESAS_H 3 | 4 | #define FASTLED_ARM 5 | 6 | #ifndef INTERRUPT_THRESHOLD 7 | #define INTERRUPT_THRESHOLD 1 8 | #endif 9 | 10 | // Default to allowing interrupts 11 | #ifndef FASTLED_ALLOW_INTERRUPTS 12 | #define FASTLED_ALLOW_INTERRUPTS 1 13 | #endif 14 | 15 | #if FASTLED_ALLOW_INTERRUPTS == 1 16 | #define FASTLED_ACCURATE_CLOCK 17 | #endif 18 | 19 | // reusing/abusing cli/sei defs for due 20 | #define cli() __disable_irq(); 21 | #define sei() __enable_irq(); 22 | 23 | #define FASTLED_NO_PINMAP 24 | 25 | typedef volatile uint32_t RoReg; 26 | typedef volatile uint32_t RwReg; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/rp2040/fastled_arm_rp2040.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_RP2040_H 2 | #define __INC_FASTLED_ARM_RP2040_H 3 | 4 | // Include the rp2040 headers 5 | #include "fastpin_arm_rp2040.h" 6 | #include "clockless_arm_rp2040.h" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/sam/fastled_arm_sam.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_SAM_H 2 | #define __INC_FASTLED_ARM_SAM_H 3 | 4 | // Include the sam headers 5 | #include "fastpin_arm_sam.h" 6 | #include "fastspi_arm_sam.h" 7 | #include "clockless_arm_sam.h" 8 | #include "clockless_block_arm_sam.h" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/sam/led_sysdefs_arm_sam.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_SAM_H 2 | #define __INC_LED_SYSDEFS_ARM_SAM_H 3 | 4 | 5 | #define FASTLED_ARM 6 | 7 | // Setup DUE timer defines/channels/etc... 8 | #ifndef DUE_TIMER_CHANNEL 9 | #define DUE_TIMER_GROUP 0 10 | #endif 11 | 12 | #ifndef DUE_TIMER_CHANNEL 13 | #define DUE_TIMER_CHANNEL 0 14 | #endif 15 | 16 | #define DUE_TIMER ((DUE_TIMER_GROUP==0) ? TC0 : ((DUE_TIMER_GROUP==1) ? TC1 : TC2)) 17 | #define DUE_TIMER_ID (ID_TC0 + (DUE_TIMER_GROUP*3) + DUE_TIMER_CHANNEL) 18 | #define DUE_TIMER_VAL (DUE_TIMER->TC_CHANNEL[DUE_TIMER_CHANNEL].TC_CV << 1) 19 | #define DUE_TIMER_RUNNING ((DUE_TIMER->TC_CHANNEL[DUE_TIMER_CHANNEL].TC_SR & TC_SR_CLKSTA) != 0) 20 | 21 | #ifndef INTERRUPT_THRESHOLD 22 | #define INTERRUPT_THRESHOLD 1 23 | #endif 24 | 25 | // Default to allowing interrupts 26 | #ifndef FASTLED_ALLOW_INTERRUPTS 27 | #define FASTLED_ALLOW_INTERRUPTS 1 28 | #endif 29 | 30 | #if FASTLED_ALLOW_INTERRUPTS == 1 31 | #define FASTLED_ACCURATE_CLOCK 32 | #endif 33 | 34 | // reusing/abusing cli/sei defs for due 35 | #define cli() __disable_irq(); __disable_fault_irq(); 36 | #define sei() __enable_irq(); __enable_fault_irq(); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/arm/stm32/fastled_arm_stm32.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_SAM_H 2 | #define __INC_FASTLED_ARM_SAM_H 3 | 4 | // Include the sam headers 5 | #include "fastpin_arm_stm32.h" 6 | // #include "fastspi_arm_stm32.h" 7 | #include "clockless_arm_stm32.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/avr/fastled_avr.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_AVR_H 2 | #define __INC_FASTLED_AVR_H 3 | 4 | #include "fastpin_avr.h" 5 | #include "fastspi_avr.h" 6 | #include "clockless_trinket.h" 7 | 8 | // Default to using PROGMEM 9 | #ifndef FASTLED_USE_PROGMEM 10 | #define FASTLED_USE_PROGMEM 1 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/clock_cycles.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include "hal/cpu_hal.h" 6 | 7 | #include "esp_idf_version.h" 8 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) 9 | #define __cpu_hal_get_cycle_count esp_cpu_get_cycle_count 10 | #else 11 | #define __cpu_hal_get_cycle_count cpu_hal_get_cycle_count 12 | #endif // ESP_IDF_VERSION 13 | 14 | 15 | __attribute__ ((always_inline)) inline static uint32_t __clock_cycles() { 16 | uint32_t cyc; 17 | #ifdef FASTLED_XTENSA 18 | __asm__ __volatile__ ("rsr %0,ccount":"=a" (cyc)); 19 | #else 20 | cyc = __cpu_hal_get_cycle_count(); 21 | #endif 22 | return cyc; 23 | } -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/clockless_rmt_esp32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Integration into FastLED ClocklessController 3 | * Copyright (c) 2024, Zach Vorhies 4 | * Copyright (c) 2018,2019,2020 Samuel Z. Guyer 5 | * Copyright (c) 2017 Thomas Basler 6 | * Copyright (c) 2017 Martin F. Falatic 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | #pragma once 27 | 28 | #include "esp_idf_version.h" 29 | 30 | #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) 31 | #include "idf4_clockless_rmt_esp32.h" 32 | #else 33 | #include "idf5_clockless_rmt_esp32.h" 34 | #endif -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/fastled_esp32.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fastpin_esp32.h" 4 | 5 | #ifdef FASTLED_ALL_PINS_HARDWARE_SPI 6 | #include "fastspi_esp32.h" 7 | #endif 8 | 9 | #ifdef FASTLED_ESP32_I2S 10 | #include "clockless_i2s_esp32.h" 11 | #else 12 | #include "clockless_rmt_esp32.h" 13 | #endif 14 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/idf5_clockless_rmt_esp32.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "idf4_clockless_rmt_esp32.h" -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/led_strip/enabled.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #ifndef FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN_COMPILE_PROBLEMATIC_CODE 5 | #define FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN_COMPILE_PROBLEMATIC_CODE 0 6 | #endif 7 | 8 | #ifndef FASTLED_ESP32_COMPONENT_LED_STRIP_FORCE_IDF4 9 | #define FASTLED_ESP32_COMPONENT_LED_STRIP_FORCE_IDF4 0 10 | #endif 11 | 12 | #ifndef ESP32 13 | // No led strip component when not in ESP32 mode. 14 | #define FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN 0 15 | #else 16 | #if !defined(FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN) 17 | #include "esp_idf_version.h" 18 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) 19 | #define FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN 0 20 | #else 21 | #define FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN 0 22 | #endif // ESP_IDF_VERSION 23 | #endif // FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN 24 | #endif // ESP32 25 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/led_strip/led_strip_rmt_encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #pragma once 7 | 8 | #include "enabled.h" 9 | 10 | 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include 17 | #include "led_strip_types.h" 18 | 19 | 20 | #include "driver/rmt_encoder.h" 21 | 22 | /** 23 | * @brief Type of led strip encoder configuration 24 | */ 25 | typedef struct { 26 | uint32_t resolution; /*!< Encoder resolution, in Hz */ 27 | led_model_t led_model; /*!< LED model */ 28 | } led_strip_encoder_config_t; 29 | 30 | /** 31 | * @brief Create RMT encoder for encoding LED strip pixels into RMT symbols 32 | * 33 | * @param[in] config Encoder configuration 34 | * @param[out] ret_encoder Returned encoder handle 35 | * @return 36 | * - ESP_ERR_INVALID_ARG for any invalid arguments 37 | * - ESP_ERR_NO_MEM out of memory when creating led strip encoder 38 | * - ESP_OK if creating encoder successfully 39 | */ 40 | esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/led_strip/led_strip_spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #pragma once 7 | 8 | 9 | #include 10 | #include "esp_err.h" 11 | #include "driver/spi_master.h" 12 | #include "led_strip_types.h" 13 | 14 | 15 | #include "esp_err.h" 16 | #include "driver/spi_master.h" 17 | 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /** 24 | * @brief LED Strip SPI specific configuration 25 | */ 26 | typedef struct { 27 | spi_clock_source_t clk_src; /*!< SPI clock source */ 28 | spi_host_device_t spi_bus; /*!< SPI bus ID. Which buses are available depends on the specific chip */ 29 | struct { 30 | uint32_t with_dma: 1; /*!< Use DMA to transmit data */ 31 | } flags; /*!< Extra driver flags */ 32 | } led_strip_spi_config_t; 33 | 34 | /** 35 | * @brief Create LED strip based on SPI MOSI channel 36 | * @note Although only the MOSI line is used for generating the signal, the whole SPI bus can't be used for other purposes. 37 | * 38 | * @param led_config LED strip configuration 39 | * @param spi_config SPI specific configuration 40 | * @param ret_strip Returned LED strip handle 41 | * @return 42 | * - ESP_OK: create LED strip handle successfully 43 | * - ESP_ERR_INVALID_ARG: create LED strip handle failed because of invalid argument 44 | * - ESP_ERR_NOT_SUPPORTED: create LED strip handle failed because of unsupported configuration 45 | * - ESP_ERR_NO_MEM: create LED strip handle failed because of out of memory 46 | * - ESP_FAIL: create LED strip handle failed because some other error 47 | */ 48 | esp_err_t led_strip_new_spi_device(const led_strip_config_t *led_config, const led_strip_spi_config_t *spi_config, led_strip_handle_t *ret_strip); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/led_strip/led_strip_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #pragma once 7 | 8 | #include 9 | 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /** 16 | * @brief LED strip pixel format 17 | */ 18 | typedef enum { 19 | // Note - Zach Vorhies - Only this enum means that there is no re-ordering of the colors. 20 | LED_PIXEL_FORMAT_GRB, /*!< Pixel format: GRB */ 21 | LED_PIXEL_FORMAT_GRBW, /*!< Pixel format: GRBW */ 22 | LED_PIXEL_FORMAT_INVALID /*!< Invalid pixel format */ 23 | } led_pixel_format_t; 24 | 25 | /** 26 | * @brief LED strip model 27 | * @note Different led model may have different timing parameters, so we need to distinguish them. 28 | */ 29 | typedef enum { 30 | LED_MODEL_WS2812, /*!< LED strip model: WS2812 */ 31 | LED_MODEL_SK6812, /*!< LED strip model: SK6812 */ 32 | LED_MODEL_INVALID /*!< Invalid LED strip model */ 33 | } led_model_t; 34 | 35 | /** 36 | * @brief LED strip handle 37 | */ 38 | typedef struct led_strip_t *led_strip_handle_t; 39 | 40 | /** 41 | * @brief LED Strip Configuration 42 | */ 43 | typedef struct { 44 | int strip_gpio_num; /*!< GPIO number that used by LED strip */ 45 | uint32_t max_leds; /*!< Maximum LEDs in a single strip */ 46 | led_pixel_format_t led_pixel_format; /*!< LED pixel format */ 47 | led_model_t led_model; /*!< LED model */ 48 | 49 | struct { 50 | uint32_t invert_out: 1; /*!< Invert output signal */ 51 | } flags; /*!< Extra driver flags */ 52 | } led_strip_config_t; 53 | 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/led_strip/readme: -------------------------------------------------------------------------------- 1 | This is a work in progress! 2 | 3 | ``` 4 | #include 5 | 6 | #include "platforms/esp/32/led_strip/led_strip.h" 7 | 8 | void setup() {} 9 | void loop() {} 10 | ``` 11 | 12 | 13 | 14 | Copied on Aug-31-2024 from 15 | https://github.com/espressif/idf-extra-components/tree/60c14263f3b69ac6e98ecae79beecbe5c18d5596/led_strip 16 | 17 | 18 | And then modified so that the library component has private symbols for FastLED 19 | (prevents linker errors if the user also includes led_strip) -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/led_strip/rmt_demo.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #ifdef ESP32 4 | 5 | #include "enabled.h" 6 | 7 | #if FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN 8 | 9 | void rmt_demo(); 10 | #endif // FASTLED_ESP32_COMPONENT_LED_STRIP_BUILT_IN 11 | #endif // ESP32 -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/32/led_sysdefs_esp32.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "esp32-hal.h" 3 | #ifndef ESP32 4 | #define ESP32 5 | #endif 6 | 7 | #define FASTLED_ESP32 8 | 9 | #if CONFIG_IDF_TARGET_ARCH_RISCV 10 | #define FASTLED_RISCV 11 | #else 12 | #define FASTLED_XTENSA 13 | #endif 14 | 15 | // Handling for older versions of ESP32 Arduino core 16 | #if !defined(ESP_IDF_VERSION) 17 | // Older versions of ESP_IDF only supported ESP32 18 | #define CONFIG_IDF_TARGET_ESP32 1 19 | // Define missing version macros. Hard code older version 3.0 since actual version is unknown 20 | #define ESP_IDF_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch)) 21 | #define ESP_IDF_VERSION ESP_IDF_VERSION_VAL(3, 0, 0) 22 | #endif 23 | 24 | // Use system millis timer 25 | #define FASTLED_HAS_MILLIS 26 | 27 | typedef volatile uint32_t RoReg; 28 | typedef volatile uint32_t RwReg; 29 | typedef unsigned long prog_uint32_t; 30 | 31 | 32 | // Default to NOT using PROGMEM here 33 | #ifndef FASTLED_USE_PROGMEM 34 | # define FASTLED_USE_PROGMEM 0 35 | #endif 36 | 37 | #ifndef FASTLED_ALLOW_INTERRUPTS 38 | # define FASTLED_ALLOW_INTERRUPTS 1 39 | # define INTERRUPT_THRESHOLD 0 40 | #endif 41 | 42 | #define NEED_CXX_BITS 43 | 44 | // These can be overridden 45 | # define FASTLED_ESP32_RAW_PIN_ORDER 46 | 47 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/8266/fastled_esp8266.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fastpin_esp8266.h" 4 | 5 | #ifdef FASTLED_ALL_PINS_HARDWARE_SPI 6 | #include "fastspi_esp8266.h" 7 | #endif 8 | 9 | #include "clockless_esp8266.h" 10 | #include "clockless_block_esp8266.h" 11 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/esp/8266/led_sysdefs_esp8266.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef ESP8266 4 | #define ESP8266 5 | #endif 6 | 7 | #define FASTLED_ESP8266 8 | 9 | // Use system millis timer 10 | #define FASTLED_HAS_MILLIS 11 | 12 | typedef volatile uint32_t RoReg; 13 | typedef volatile uint32_t RwReg; 14 | typedef uint32_t prog_uint32_t; 15 | 16 | 17 | // Default to NOT using PROGMEM here 18 | #ifndef FASTLED_USE_PROGMEM 19 | # define FASTLED_USE_PROGMEM 0 20 | #endif 21 | 22 | #ifndef FASTLED_ALLOW_INTERRUPTS 23 | # define FASTLED_ALLOW_INTERRUPTS 1 24 | # define INTERRUPT_THRESHOLD 0 25 | #endif 26 | 27 | #define NEED_CXX_BITS 28 | 29 | // These can be overridden 30 | #if !defined(FASTLED_ESP8266_RAW_PIN_ORDER) && !defined(FASTLED_ESP8266_NODEMCU_PIN_ORDER) && !defined(FASTLED_ESP8266_D1_PIN_ORDER) 31 | # ifdef ARDUINO_ESP8266_NODEMCU 32 | # define FASTLED_ESP8266_NODEMCU_PIN_ORDER 33 | # else 34 | # define FASTLED_ESP8266_RAW_PIN_ORDER 35 | # endif 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/stub/clockless_stub.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_STUB_H 2 | #define __INC_CLOCKLESS_STUB_H 3 | 4 | #include "namespace.h" 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | #if defined(FASTLED_STUB_IMPL) 9 | 10 | #define FASTLED_HAS_CLOCKLESS 1 11 | 12 | template 13 | class ClocklessController : public CPixelLEDController { 14 | public: 15 | virtual void init() { } 16 | 17 | protected: 18 | virtual void showPixels(PixelController & pixels) { } 19 | }; 20 | 21 | #endif // defined(FASTLED_STUB_IMPL) 22 | 23 | FASTLED_NAMESPACE_END 24 | 25 | #endif // __INC_CLOCKLESS_STUB_H -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/stub/fastled_stub.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_STUB_H 2 | #define __INC_FASTLED_STUB_H 3 | 4 | // fastpin_stub.h isn't needed (as it's not used by clockless) 5 | #include "fastspi_stub.h" 6 | #include "clockless_stub.h" 7 | 8 | /** 9 | * Could avoid clockless and fastspi with 10 | * #define NO_HARDWARE_PIN_SUPPORT 11 | * #undef HAS_HARDWARE_PIN_SUPPORT 12 | * But then compiling throws pragma message about "Forcing software SPI" 13 | */ 14 | #define HAS_HARDWARE_PIN_SUPPORT 15 | 16 | #endif // __INC_FASTLED_STUB_H -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/stub/fastspi_stub.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTSPI_STUB_H 2 | #define __INC_FASTSPI_STUB_H 3 | 4 | #include "namespace.h" 5 | 6 | // This is a stub implementation of fastspi. 7 | 8 | FASTLED_NAMESPACE_BEGIN 9 | 10 | #if defined(FASTLED_STUB_IMPL) 11 | 12 | #define FASTLED_ALL_PINS_HARDWARE_SPI 13 | 14 | class StubSPIOutput { 15 | public: 16 | StubSPIOutput() { } 17 | }; 18 | 19 | #endif // defined(FASTLED_STUB_IMPL) 20 | 21 | FASTLED_NAMESPACE_END 22 | 23 | #endif // __INC_FASTSPI_STUB_H -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/stub/led_sysdefs_stub.cpp: -------------------------------------------------------------------------------- 1 | 2 | #ifdef FASTLED_STUB_IMPL // Only use this if explicitly defined. 3 | 4 | #include "led_sysdefs_stub.h" 5 | 6 | #include 7 | #include 8 | 9 | void pinMode(uint8_t pin, uint8_t mode) { 10 | // Empty stub as we don't actually ever write anything 11 | } 12 | 13 | uint32_t millis() { 14 | return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); 15 | } 16 | 17 | uint32_t micros() { 18 | return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); 19 | } 20 | 21 | void delay(int ms) { 22 | std::this_thread::sleep_for (std::chrono::milliseconds(ms)); 23 | } 24 | 25 | #endif // FASTLED_STUB_IMPL -------------------------------------------------------------------------------- /libraries/FastLED/src/platforms/stub/led_sysdefs_stub.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_STUB_H 2 | #define __INC_LED_SYSDEFS_STUB_H 3 | 4 | #ifndef FASTLED_STUB_IMPL 5 | #define FASTLED_STUB_IMPL 6 | #endif 7 | 8 | #include 9 | 10 | #ifndef F_CPU 11 | #define F_CPU 1000000000 12 | #endif // F_CPU 13 | 14 | #define FASTLED_HAS_MILLIS 15 | 16 | #define digitalPinToBitMask(P) ( 0 ) 17 | #define digitalPinToPort(P) ( 0 ) 18 | #define portOutputRegister(P) ( 0 ) 19 | #define portInputRegister(P) ( 0 ) 20 | 21 | #define INPUT 0 22 | #define OUTPUT 1 23 | 24 | typedef volatile uint32_t RoReg; 25 | typedef volatile uint32_t RwReg; 26 | 27 | #define FASTLED_NEEDS_YIELD 28 | 29 | extern "C" { 30 | void pinMode(uint8_t pin, uint8_t mode); 31 | 32 | uint32_t millis(void); 33 | uint32_t micros(void); 34 | 35 | void delay(int ms); 36 | void yield(void); 37 | } 38 | 39 | #endif // __INC_LED_SYSDEFS_STUB_H -------------------------------------------------------------------------------- /libraries/FastLED/src/stub_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a stub implementation of main that can be used to include an *.ino 3 | * file which is so close to C++ that many of them can be compiled as C++. The 4 | * notable difference between a *.ino file and a *.cpp file is that the *.ino 5 | * file does not need to include function prototypes, and are instead 6 | * auto-generated. 7 | */ 8 | 9 | 10 | #ifdef FASTLED_STUB_MAIN_INCLUDE_INO 11 | 12 | #ifndef _FASTLED_STRINGIFY 13 | #define _FASTLED_STRINGIFY_HELPER(x) #x 14 | #define _FASTLED_STRINGIFY(x) _FASTLED_STRINGIFY_HELPER(x) 15 | #endif 16 | 17 | // Correctly include the file by expanding and stringifying the macro value 18 | #include _FASTLED_STRINGIFY(FASTLED_STUB_MAIN_INCLUDE_INO) 19 | 20 | #include 21 | 22 | // XY does mapping to a 1D array. Make it weak so that 23 | // the user can override it if they have supplied an example 24 | // in their sketch. 25 | #pragma weak XY 26 | uint16_t XY(uint8_t x, uint8_t y) { 27 | std::cout << "Warning: XY function not defined. Using stub implementation." << std::endl; 28 | return 0; 29 | } 30 | 31 | int main() { 32 | // Super simple main function that just calls the setup and loop functions. 33 | setup(); 34 | while(1) { 35 | loop(); 36 | } 37 | } 38 | #endif // FASTLED_STUB_MAIN_INCLUDE_INO -------------------------------------------------------------------------------- /libraries/FastLED/src/transpose8x1_noinline.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void transpose8x1_noinline(unsigned char *A, unsigned char *B) { 5 | uint32_t x, y, t; 6 | 7 | // Load the array and pack it into x and y. 8 | y = *(unsigned int*)(A); 9 | x = *(unsigned int*)(A+4); 10 | 11 | // pre-transform x 12 | t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7); 13 | t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14); 14 | 15 | // pre-transform y 16 | t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7); 17 | t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14); 18 | 19 | // final transform 20 | t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F); 21 | y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F); 22 | x = t; 23 | 24 | *((uint32_t*)B) = y; 25 | *((uint32_t*)(B+4)) = x; 26 | } 27 | -------------------------------------------------------------------------------- /libraries/FastLED/src/transpose8x1_noinline.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | void transpose8x1_noinline(unsigned char *A, unsigned char *B); 4 | -------------------------------------------------------------------------------- /libraries/FastLED/src/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | #include "led_sysdefs.h" 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | #if defined(__AVR__) 9 | typedef int cycle_t; ///< 8.8 fixed point (signed) value 10 | #else 11 | typedef int64_t cycle_t; ///< 8.8 fixed point (signed) value 12 | #endif 13 | 14 | FASTLED_NAMESPACE_END 15 | 16 | #endif // TYPES_H -------------------------------------------------------------------------------- /libraries/FlexCAN_T4/FlexCAN_T4Beta1BoardArchive.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CU-Robotics/firmware/0364e8379a874e99cc43b52b98fb8450684ecfbd/libraries/FlexCAN_T4/FlexCAN_T4Beta1BoardArchive.zip -------------------------------------------------------------------------------- /libraries/FlexCAN_T4/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Antonio Brewer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /libraries/FreqMeasureMulti/FreqMeasureMulti.h: -------------------------------------------------------------------------------- 1 | #ifndef FreqMeasureMulti_h 2 | #define FreqMeasureMulti_h 3 | 4 | #include 5 | 6 | #define FREQMEASUREMULTI_BUFFER_LEN 24 7 | // capture modes 8 | #define FREQMEASUREMULTI_RAISING 1 9 | #define FREQMEASUREMULTI_FALLING 2 10 | #define FREQMEASUREMULTI_INTERLEAVE 3 11 | #define FREQMEASUREMULTI_SPACE_ONLY 5 12 | #define FREQMEASUREMULTI_MARK_ONLY 6 13 | #define FREQMEASUREMULTI_ALTERNATE 7 14 | // result constants for fmultiRecord.level 15 | #define LEVEL_SPACE_ONLY 0 16 | #define LEVEL_SPACE_MARK 1 17 | #define LEVEL_MARK_SPACE 2 18 | #define LEVEL_MARK_ONLY 3 19 | #define LEVEL_UNDEFINED 255 20 | 21 | typedef struct { 22 | uint8_t level; 23 | uint32_t count; 24 | } fmultiRecord; 25 | 26 | #if defined(__IMXRT1062__) 27 | #include "FreqMeasureMultiIMXRT.h" 28 | #else 29 | 30 | // Teensy 3.x and LC 31 | class FreqMeasureMulti 32 | { 33 | public: 34 | bool begin(uint32_t pin); 35 | bool begin(uint32_t pin, uint8_t mode); 36 | uint32_t available(void); 37 | uint32_t read(void); 38 | uint8_t readLevel(void); 39 | static float countToFrequency(uint32_t count); 40 | static float countToNanoseconds(uint32_t count); 41 | void end(void); 42 | private: 43 | fmultiRecord buffer_value[FREQMEASUREMULTI_BUFFER_LEN]; 44 | uint8_t buffer_head; 45 | uint8_t buffer_tail; 46 | 47 | friend void ftm0_isr(void); 48 | void isr(bool inc); 49 | uint8_t channel; 50 | uint8_t last_read_level; 51 | uint32_t raiscap_previous; 52 | uint32_t fallcap_previous; 53 | bool act_on_fall, act_on_raise, read_diff; 54 | bool next_is_falling; 55 | }; 56 | #endif //defined(__IMXRT1062__) 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /libraries/FreqMeasureMulti/docs/issue_template.md: -------------------------------------------------------------------------------- 1 | Please use this form only to report code defects or bugs. 2 | 3 | For any question, even questions directly pertaining to this code, post your question on the forum. 4 | 5 | Teensy: forum.pjrc.com 6 | 7 | If you are experiencing trouble but not certain of the cause, or need help using this code, ask on the forum. This is not the place to ask for support or help, even directly related to this code. Only use this form you are certain you have discovered a defect in this code! 8 | 9 | Please verify the problem occurs when using the very latest version, using the newest version of Arduino and any other related software. 10 | 11 | 12 | ----------------------------- Remove above ----------------------------- 13 | 14 | 15 | 16 | ### Description 17 | 18 | Describe your problem. 19 | 20 | 21 | 22 | ### Steps To Reproduce Problem 23 | 24 | Please give detailed instructions needed for anyone to attempt to reproduce the problem. 25 | 26 | 27 | 28 | ### Hardware & Software 29 | 30 | Board 31 | Shields / modules used 32 | Arduino IDE version 33 | Teensyduino version 34 | Operating system & version 35 | Any other software or hardware? 36 | 37 | 38 | ### Arduino Sketch 39 | 40 | ```cpp 41 | // Change the code below by your sketch (please try to give the smallest code which demonstrates the problem) 42 | #include 43 | 44 | // libraries: give links/details so anyone can compile your code for the same result 45 | 46 | void setup() { 47 | } 48 | 49 | void loop() { 50 | } 51 | ``` 52 | 53 | 54 | ### Errors or Incorrect Output 55 | 56 | If you see any errors or incorrect output, please show it here. Please use copy & paste to give an exact copy of the message. Details matter, so please show (not merely describe) the actual message or error exactly as it appears. 57 | 58 | 59 | -------------------------------------------------------------------------------- /libraries/FreqMeasureMulti/keywords.txt: -------------------------------------------------------------------------------- 1 | FreqMeasureMulti KEYWORD1 2 | begin KEYWORD2 3 | available KEYWORD2 4 | read KEYWORD2 5 | readLevel KEYWORD2 6 | countToFrequency KEYWORD2 7 | countToNanoseconds KEYWORD2 8 | end KEYWORD2 9 | 10 | FREQMEASUREMULTI_RAISING LITERAL1 11 | FREQMEASUREMULTI_FALLING LITERAL1 12 | FREQMEASUREMULTI_INTERLEAVE LITERAL1 13 | FREQMEASUREMULTI_SPACE_ONLY LITERAL1 14 | FREQMEASUREMULTI_MARK_ONLY LITERAL1 15 | FREQMEASUREMULTI_ALTERNATE LITERAL1 16 | LEVEL_SPACE_ONLY LITERAL1 17 | LEVEL_SPACE_MARK LITERAL1 18 | LEVEL_MARK_SPACE LITERAL1 19 | LEVEL_MARK_ONLY LITERAL1 20 | LEVEL_UNDEFINED LITERAL1 21 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/arch/sys_arch.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2023-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // sys_arch.h supports the system functions for lwIP. 5 | // This file is part of the QNEthernet library. 6 | 7 | // C++ includes 8 | #include 9 | 10 | #include "lwip/opt.h" 11 | 12 | #if SYS_LIGHTWEIGHT_PROT 13 | typedef uint32_t sys_prot_t; 14 | #endif /* SYS_LIGHTWEIGHT_PROT */ 15 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/default_altcp_functions.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2023-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // default_altcp_functions.cpp provides default implementations of QNEthernet's 5 | // altcp interface functions. 6 | // This file is part of the QNEthernet library. 7 | 8 | #include "lwip/opt.h" 9 | #include "qnethernet_opts.h" 10 | 11 | #if LWIP_ALTCP && QNETHERNET_ENABLE_ALTCP_DEFAULT_FUNCTIONS 12 | 13 | // C++ includes 14 | #include 15 | #include 16 | 17 | #include "lwip/altcp.h" 18 | #include "lwip/altcp_tcp.h" 19 | #include "lwip/ip_addr.h" 20 | 21 | // This implementation uses the TCP allocator and returns true. 22 | [[gnu::weak]] 23 | std::function 24 | qnethernet_altcp_get_allocator = 25 | []([[maybe_unused]] const ip_addr_t *ipaddr, 26 | [[maybe_unused]] uint16_t port, 27 | altcp_allocator_t &allocator) { 28 | allocator.alloc = &altcp_tcp_alloc; 29 | allocator.arg = nullptr; 30 | return true; 31 | }; 32 | 33 | // This implementation does nothing. 34 | [[gnu::weak]] 35 | std::function qnethernet_altcp_free_allocator = 36 | []([[maybe_unused]] const altcp_allocator_t &allocator) {}; 37 | 38 | #endif // LWIP_ALTCP && QNETHERNET_ENABLE_ALTCP_DEFAULT_FUNCTIONS 39 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/driver_select.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // driver_select.h chooses a driver header to include. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #include "qnethernet_opts.h" 10 | 11 | // -------------------------------------------------------------------------- 12 | // External Driver 13 | // -------------------------------------------------------------------------- 14 | 15 | // First check for the existence of an external driver 16 | // https://forum.pjrc.com/index.php?threads/new-lwip-based-ethernet-library-for-teensy-4-1.68066/post-345539 17 | #if defined(__has_include) 18 | // https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html 19 | #if __has_include() 20 | #include 21 | #define QNETHERNET_INTERNAL_DRIVER_EXTERNAL 22 | #endif // __has_include() 23 | #endif // defined(__has_include) 24 | 25 | // -------------------------------------------------------------------------- 26 | // No External Driver 27 | // -------------------------------------------------------------------------- 28 | 29 | // Don't include anything else if an external driver has been included 30 | #ifndef QNETHERNET_INTERNAL_DRIVER_EXTERNAL 31 | 32 | #if defined(QNETHERNET_DRIVER_W5500) 33 | #include "drivers/driver_w5500.h" 34 | #define QNETHERNET_INTERNAL_DRIVER_W5500 35 | #elif defined(ARDUINO_TEENSY41) 36 | #include "drivers/driver_teensy41.h" 37 | #define QNETHERNET_INTERNAL_DRIVER_TEENSY41 38 | #else 39 | #include "drivers/driver_unsupported.h" 40 | #define QNETHERNET_INTERNAL_DRIVER_UNSUPPORTED 41 | #endif // Driver selection 42 | 43 | #endif // QNETHERNET_INTERNAL_DRIVER_EXTERNAL 44 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/drivers/driver_teensy41.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2021-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // driver_teensy41.h defines Teensy 4.1-specific things. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #define MTU 1500 10 | #define MAX_FRAME_LEN 1522 11 | 12 | // lwIP options 13 | 14 | // ARP options 15 | #define ETH_PAD_SIZE 2 /* 0 */ 16 | 17 | // Checksum options 18 | #define CHECKSUM_GEN_IP 0 /* 1 */ 19 | #define CHECKSUM_GEN_UDP 0 /* 1 */ 20 | #define CHECKSUM_GEN_TCP 0 /* 1 */ 21 | #define CHECKSUM_GEN_ICMP 0 /* 1 */ 22 | // #define CHECKSUM_GEN_ICMP6 1 23 | #define CHECKSUM_CHECK_IP 0 /* 1 */ 24 | #define CHECKSUM_CHECK_UDP 0 /* 1 */ 25 | #define CHECKSUM_CHECK_TCP 0 /* 1 */ 26 | #define CHECKSUM_CHECK_ICMP 0 /* 1 */ 27 | // #define CHECKSUM_CHECK_ICMP6 1 28 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/drivers/driver_unsupported.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2021-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // driver_unsupported.h defines things for unsupported boards. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #define MTU 1500 10 | #define MAX_FRAME_LEN 1522 11 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/drivers/driver_w5500.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // driver_w5500.h defines things for W5500 boards. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #define MTU 1500 10 | #define MAX_FRAME_LEN 1522 /* Includes the 4-byte FCS (frame check sequence) */ 11 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/drivers/driver_w5500_config.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // driver_w5500_config.h contains the W5500 Ethernet interface configuration. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | // SPI settings 12 | // static SPISettings kSPISettings{14000000, MSBFIRST, SPI_MODE0}; 13 | static const SPISettings kSPISettings{30000000, MSBFIRST, SPI_MODE0}; 14 | static SPIClass &spi = SPI; 15 | static constexpr int kDefaultCSPin = 10; 16 | 17 | static constexpr bool kSocketInterruptsEnabled = false; 18 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/internal/ConnectionHolder.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2021-2022,2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // ConnectionHolder.h holds everything needed to define a connection. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #include "lwip/opt.h" 10 | 11 | #if LWIP_TCP 12 | 13 | // C++ includes 14 | #include 15 | 16 | #include "ConnectionState.h" 17 | #include "lwip/err.h" 18 | 19 | namespace qindesign { 20 | namespace network { 21 | namespace internal { 22 | 23 | // ConnectionHolder is effectively a connection proxy, useful because 24 | // connections need to be managed by both a server and client. This is the 25 | // argument passed to the lwIP callbacks. 26 | struct ConnectionHolder final { 27 | err_t lastError = ERR_OK; 28 | /*volatile*/ bool connected = false; 29 | std::unique_ptr state; 30 | 31 | // Remaining data after a connection is closed 32 | // Will only be non-empty after the connection is closed 33 | /*volatile*/ size_t remainingPos = 0; 34 | std::vector remaining; 35 | // `remainingPos` should never be past the end of `remaining` 36 | }; 37 | 38 | } // namespace internal 39 | } // namespace network 40 | } // namespace qindesign 41 | 42 | #endif // LWIP_TCP 43 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/internal/ConnectionState.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2021-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // ConnectionState.h defines all the data needed to host a connection. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #include "lwip/opt.h" 10 | 11 | #if LWIP_TCP 12 | 13 | // C++ includes 14 | #include 15 | #include 16 | 17 | #include "lwip/altcp.h" 18 | 19 | namespace qindesign { 20 | namespace network { 21 | namespace internal { 22 | 23 | // ConnectionState holds all the state needed for a connection. 24 | struct ConnectionState final { 25 | // Creates a new object and sets `arg` as the pcb's arg. This also reserves 26 | // TCP_WND bytes as buffer space. 27 | ConnectionState(altcp_pcb *tpcb, void *arg) : pcb(tpcb) { 28 | altcp_arg(tpcb, arg); 29 | buf.reserve(TCP_WND); 30 | } 31 | 32 | // Sets the callback arg to nullptr and then calls the 'remove' function. The 33 | // object should be deleted before more 'tcp' functions are called. 34 | ~ConnectionState() { 35 | // Ensure callbacks are no longer called with this as the argument 36 | altcp_arg(pcb, nullptr); 37 | 38 | if (removeFunc != nullptr) { 39 | removeFunc(this); 40 | } 41 | } 42 | 43 | altcp_pcb * /*volatile*/ pcb = nullptr; 44 | 45 | // Incoming data buffer 46 | std::vector buf; 47 | /*volatile*/ size_t bufPos = 0; 48 | 49 | // Called from the destructor after the callback arg is deleted. 50 | std::function removeFunc = nullptr; 51 | }; 52 | 53 | } // namespace internal 54 | } // namespace network 55 | } // namespace qindesign 56 | 57 | #endif // LWIP_TCP 58 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/internal/DiffServ.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // DiffServ.h defines an interface for DiffServ functions. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace qindesign { 12 | namespace network { 13 | namespace internal { 14 | 15 | // DiffServ defines some DiffServ-related methods. 16 | class DiffServ { 17 | public: 18 | DiffServ() = default; 19 | virtual ~DiffServ() = default; 20 | 21 | // Sets the differentiated services (DiffServ, DS) field in the outgoing IP 22 | // header. The top 6 bits are the differentiated services code point (DSCP) 23 | // value, and the bottom 2 bits are the explicit congestion notification 24 | // (ECN) value. 25 | // 26 | // This returns whether successful. 27 | virtual bool setOutgoingDiffServ(uint8_t ds) = 0; 28 | 29 | // Returns the differentiated services (DiffServ) value from the outgoing 30 | // IP header. 31 | virtual uint8_t outgoingDiffServ() const = 0; 32 | }; 33 | 34 | } // namespace internal 35 | } // namespace network 36 | } // namespace qindesign 37 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/internal/PrintfChecked.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // PrintfChecked.h defines a printf with format string checking. As of this 5 | // writing, format string checking for Print::printf isn't enabled on some 6 | // platforms, which is why this is defined here. 7 | // 8 | // To use this class: 9 | // 1. Derive from PrintfChecked in addition to Print, and 10 | // 2. Put `using qindesign::network::internal::PrintfChecked::printf;` in the 11 | // public area of your class. 12 | // 13 | // This file is part of the QNEthernet library. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | namespace qindesign { 21 | namespace network { 22 | namespace internal { 23 | 24 | class PrintfChecked { 25 | public: 26 | // Define a format-checked printf. 27 | [[gnu::format(printf, 2, 3)]] 28 | int printf(const char *format, ...) { 29 | std::va_list args; 30 | va_start(args, format); 31 | int retval = vdprintf(reinterpret_cast(this), format, args); 32 | va_end(args); 33 | return retval; 34 | } 35 | }; 36 | 37 | } // namespace internal 38 | } // namespace network 39 | } // namespace qindesign 40 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/lwip_hooks.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2022-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // lwip_hooks.h contains lwIP hook declarations. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | #include "lwip/err.h" 10 | #include "lwip/netif.h" 11 | #include "lwip/pbuf.h" 12 | #include "qnethernet_opts.h" 13 | 14 | #if QNETHERNET_ENABLE_RAW_FRAME_SUPPORT 15 | 16 | #define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(p, netif) \ 17 | unknown_eth_protocol((p), (netif)) 18 | 19 | err_t unknown_eth_protocol(struct pbuf *p, struct netif *netif); 20 | 21 | #endif // QNETHERNET_ENABLE_RAW_FRAME_SUPPORT 22 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/netif/etharp.h: -------------------------------------------------------------------------------- 1 | /* ARP has been moved to core/ipv4, provide this #include for compatibility only */ 2 | #include "lwip/etharp.h" 3 | #include "netif/ethernet.h" 4 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/security/RandomDevice.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2023-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // RandomDevice.cpp implements RandomDevice. 5 | // This file is part of the QNEthernet library. 6 | 7 | #include "RandomDevice.h" 8 | 9 | #include 10 | 11 | #include 12 | 13 | #ifndef FLASHMEM 14 | #define FLASHMEM 15 | #endif // !FLASHMEM 16 | 17 | namespace qindesign { 18 | namespace security { 19 | 20 | extern "C" { 21 | void qnethernet_hal_init_rand(); 22 | uint32_t qnethernet_hal_rand(); 23 | } // extern "C" 24 | 25 | STATIC_INIT_DEFN(RandomDevice, randomDevice); 26 | 27 | RandomDevice &RandomDevice::instance() { 28 | return randomDevice; 29 | } 30 | 31 | FLASHMEM RandomDevice::RandomDevice() { 32 | qnethernet_hal_init_rand(); 33 | } 34 | 35 | RandomDevice::result_type RandomDevice::operator()() { 36 | return qnethernet_hal_rand(); 37 | } 38 | 39 | } // namespace security 40 | } // namespace qindesign 41 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/security/RandomDevice.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2023-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // RandomDevice.h defines a class that conforms to the 5 | // UniformRandomBitGenerator C++ named requirement. 6 | // This file is part of the QNEthernet library. 7 | 8 | #pragma once 9 | 10 | // C++ includes 11 | #include 12 | #include 13 | 14 | #include "StaticInit.h" 15 | 16 | namespace qindesign { 17 | namespace security { 18 | 19 | // RandomDevice implements UniformRandomBitGenerator. 20 | class RandomDevice { 21 | public: 22 | typedef uint32_t result_type; 23 | 24 | // Accesses the singleton instance. 25 | static RandomDevice &instance(); 26 | 27 | // Disallow copying and moving 28 | RandomDevice(const RandomDevice &) = delete; 29 | RandomDevice &operator=(const RandomDevice &) = delete; 30 | 31 | static constexpr result_type min() { 32 | return std::numeric_limits::min(); 33 | } 34 | 35 | static constexpr result_type max() { 36 | return std::numeric_limits::max(); 37 | } 38 | 39 | result_type operator()(); 40 | 41 | private: 42 | RandomDevice(); 43 | ~RandomDevice() = default; 44 | 45 | friend class StaticInit; 46 | }; 47 | 48 | STATIC_INIT_DECL(RandomDevice, randomDevice); 49 | 50 | } // namespace security 51 | } // namespace qindesign 52 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/sys_arch.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2021-2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // sys_arch.cpp provides system function implementations for lwIP. 5 | // This file is part of the QNEthernet library. 6 | 7 | #include "arch/sys_arch.h" 8 | 9 | // C++ includes 10 | #include 11 | 12 | #include "lwip/opt.h" 13 | 14 | // -------------------------------------------------------------------------- 15 | // Time 16 | // -------------------------------------------------------------------------- 17 | 18 | extern "C" { 19 | 20 | uint32_t qnethernet_hal_millis(); 21 | 22 | u32_t sys_now(void) { 23 | return qnethernet_hal_millis(); 24 | } 25 | 26 | } // extern "C" 27 | 28 | // -------------------------------------------------------------------------- 29 | // Core Locking 30 | // -------------------------------------------------------------------------- 31 | 32 | extern "C" { 33 | 34 | #if SYS_LIGHTWEIGHT_PROT 35 | sys_prot_t sys_arch_protect(void) { 36 | return 0; 37 | } 38 | 39 | void sys_arch_unprotect(sys_prot_t pval) { 40 | } 41 | #endif // SYS_LIGHTWEIGHT_PROT 42 | 43 | } // extern "C" 44 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/util/ip_tools.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2022,2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // ip_tools.c implements the functions defined in ip_tools.h. 5 | // This file is part of the QNEthernet library. 6 | 7 | #include "ip_tools.h" 8 | 9 | #include "lwip/opt.h" 10 | 11 | namespace qindesign { 12 | namespace network { 13 | 14 | #if LWIP_IPV4 15 | 16 | uint32_t ip_addr_get_ip4_uint32(const ip_addr_t *ip) { 17 | if (IP_IS_V4(ip)) { 18 | return ip4_addr_get_u32(ip_2_ip4(ip)); 19 | #if LWIP_IPV6 20 | } else if (IP_IS_V6(ip)) { 21 | if (ip6_addr_isipv4mappedipv6(ip_2_ip6(ip))) { 22 | return ip_2_ip6(ip)->addr[3]; 23 | } 24 | #endif // LWIP_IPV6 25 | } 26 | return IPADDR_ANY; 27 | } 28 | 29 | #if defined(TEENSYDUINO) && TEENSYDUINO <= 158 30 | bool operator==(const IPAddress &a, const IPAddress &b) { 31 | return (const_cast(a) == b); 32 | } 33 | 34 | bool operator!=(const IPAddress &a, const IPAddress &b) { 35 | return !(const_cast(a) == b); 36 | } 37 | #endif // defined(TEENSYDUINO) && TEENSYDUINO <= 158 38 | 39 | uint32_t get_uint32(const IPAddress &ip) { 40 | #if defined(TEENSYDUINO) && TEENSYDUINO <= 158 41 | // The uint32_t operator doesn't work with const IPAddress, hence 42 | // the const_cast 43 | return static_cast(const_cast(ip)); 44 | #else 45 | return static_cast(ip); 46 | #endif // defined(TEENSYDUINO) && TEENSYDUINO <= 158 47 | } 48 | 49 | #endif // LWIP_IPV4 50 | 51 | } // network 52 | } // qindesign 53 | -------------------------------------------------------------------------------- /libraries/QNEthernet/src/util/ip_tools.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: (c) 2022,2024 Shawn Silverman 2 | // SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | // ip_tools.h defines some utilities for working with IP addresses. 5 | // This file is part of the QNEthernet library. 6 | 7 | #pragma once 8 | 9 | // C++ includes 10 | #include 11 | 12 | #include 13 | 14 | #include "lwip/ip_addr.h" 15 | 16 | namespace qindesign { 17 | namespace network { 18 | 19 | #if LWIP_IPV4 20 | 21 | // Gets the 32-bit IPv4 address from the given ip_addr_t. This takes into 22 | // consideration IPv4-mapped IPv6 addresses. This will return zero for 23 | // non-IPv4-mapped addresses. 24 | uint32_t ip_addr_get_ip4_uint32(const ip_addr_t *ip); 25 | 26 | #if defined(TEENSYDUINO) && TEENSYDUINO <= 158 27 | // Missing IPAddress operators 28 | bool operator==(const IPAddress &a, const IPAddress &b); 29 | bool operator!=(const IPAddress &a, const IPAddress &b); 30 | #endif // defined(TEENSYDUINO) && TEENSYDUINO <= 158 31 | 32 | // Gets the 32-bit address from the given const IPAddress. 33 | uint32_t get_uint32(const IPAddress &ip); 34 | 35 | #endif // LWIP_IPV4 36 | 37 | } // namespace network 38 | } // namespace qindesign 39 | -------------------------------------------------------------------------------- /libraries/SD/README.md: -------------------------------------------------------------------------------- 1 | #SD Library# 2 | 3 | 4 | ![](http://www.pjrc.com/store/sd_adaptor.jpg) 5 | 6 | -------------------------------------------------------------------------------- /libraries/SD/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map SD 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SD KEYWORD1 10 | File KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | begin KEYWORD2 16 | exists KEYWORD2 17 | mkdir KEYWORD2 18 | remove KEYWORD2 19 | rmdir KEYWORD2 20 | open KEYWORD2 21 | close KEYWORD2 22 | seek KEYWORD2 23 | position KEYWORD2 24 | size KEYWORD2 25 | format KEYWORD2 26 | mediaPresent KEYWORD2 27 | setMediaDetectPin KEYWORD2 28 | 29 | ####################################### 30 | # Constants (LITERAL1) 31 | ####################################### 32 | FILE_READ LITERAL1 33 | FILE_WRITE LITERAL1 34 | BUILTIN_SDCARD LITERAL1 35 | -------------------------------------------------------------------------------- /libraries/SD/library.properties: -------------------------------------------------------------------------------- 1 | name=SD 2 | version=2.0.0 3 | author=Paul Stoffregen 4 | maintainer=Paul Stoffregen 5 | sentence=Arduino SD compatibility layer for SdFat. 6 | paragraph=To access SD cards, we now use Bill Greiman's SdFat library. This library just provides a thin wrapper so programs written for Arduino's SD library can use SdFat. None of the original Arduino SD library code is present in this compatibility library. 7 | category=Data Storage 8 | url=https://github.com/PaulStoffregen/SD 9 | architectures=avr,* 10 | -------------------------------------------------------------------------------- /libraries/SdFat/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2011..2020 Bill Greiman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /libraries/SdFat/doc/SdFat.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A web page that points a browser to a different page 4 | 5 | 6 | 7 | 8 | Your browser didn't automatically redirect. Open html/index.html manually. 9 | 10 | 11 | -------------------------------------------------------------------------------- /libraries/SdFat/doc/ZipMsg/index.html: -------------------------------------------------------------------------------- 1 |

Replace the content of the html folder by unzipping html.zip.

2 |

I have zipped the documentation since Doxygen changes every file each time it runs.

3 |

This makes viewing changes on GitHub difficult.

4 |

 

-------------------------------------------------------------------------------- /libraries/SdFat/doc/clean_html.bat: -------------------------------------------------------------------------------- 1 | del html\*.md5 2 | del html\*.map 3 | pause -------------------------------------------------------------------------------- /libraries/SdFat/doc/del_html.bat: -------------------------------------------------------------------------------- 1 | rm html/*.* 2 | rm html/search/*.* 3 | pause -------------------------------------------------------------------------------- /libraries/SdFat/doc/html.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CU-Robotics/firmware/0364e8379a874e99cc43b52b98fb8450684ecfbd/libraries/SdFat/doc/html.zip -------------------------------------------------------------------------------- /libraries/SdFat/doc/html/index.html: -------------------------------------------------------------------------------- 1 |

Replace the content of the html folder by unzipping html.zip.

2 |

I have zipped the documentation since Doxygen changes every file each time it runs.

3 |

This makes viewing changes on GitHub difficult.

4 |

 

-------------------------------------------------------------------------------- /libraries/SdFat/library.properties: -------------------------------------------------------------------------------- 1 | name=SdFat 2 | version=2.1.2 3 | license=MIT 4 | author=Bill Greiman 5 | maintainer=Bill Greiman 6 | sentence=Provides access to SD memory cards. 7 | paragraph=The SdFat library supports FAT16, FAT32, and exFAT file systems on Standard SD, SDHC, and SDXC cards. 8 | category=Data Storage 9 | url=https://github.com/greiman/SdFat 10 | repository=https://github.com/greiman/SdFat.git 11 | architectures=* 12 | -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/boards/AvrDevelopersGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef AvrDevelopersGpioPinMap_h 2 | #define AvrDevelopersGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(B, 0), // D0 5 | GPIO_PIN(B, 1), // D1 6 | GPIO_PIN(B, 2), // D2 7 | GPIO_PIN(B, 3), // D3 8 | GPIO_PIN(B, 4), // D4 9 | GPIO_PIN(B, 5), // D5 10 | GPIO_PIN(B, 6), // D6 11 | GPIO_PIN(B, 7), // D7 12 | GPIO_PIN(D, 0), // D8 13 | GPIO_PIN(D, 1), // D9 14 | GPIO_PIN(D, 2), // D10 15 | GPIO_PIN(D, 3), // D11 16 | GPIO_PIN(D, 4), // D12 17 | GPIO_PIN(D, 5), // D13 18 | GPIO_PIN(D, 6), // D14 19 | GPIO_PIN(D, 7), // D15 20 | GPIO_PIN(C, 0), // D16 21 | GPIO_PIN(C, 1), // D17 22 | GPIO_PIN(C, 2), // D18 23 | GPIO_PIN(C, 3), // D19 24 | GPIO_PIN(C, 4), // D20 25 | GPIO_PIN(C, 5), // D21 26 | GPIO_PIN(C, 6), // D22 27 | GPIO_PIN(C, 7), // D23 28 | GPIO_PIN(A, 7), // D24 29 | GPIO_PIN(A, 6), // D25 30 | GPIO_PIN(A, 5), // D26 31 | GPIO_PIN(A, 4), // D27 32 | GPIO_PIN(A, 3), // D28 33 | GPIO_PIN(A, 2), // D29 34 | GPIO_PIN(A, 1), // D30 35 | GPIO_PIN(A, 0) // D31 36 | }; 37 | #endif // AvrDevelopersGpioPinMap_h -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/boards/BobuinoGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef BobuinoGpioPinMap_h 2 | #define BobuinoGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(B, 0), // D0 5 | GPIO_PIN(B, 1), // D1 6 | GPIO_PIN(B, 2), // D2 7 | GPIO_PIN(B, 3), // D3 8 | GPIO_PIN(B, 4), // D4 9 | GPIO_PIN(B, 5), // D5 10 | GPIO_PIN(B, 6), // D6 11 | GPIO_PIN(B, 7), // D7 12 | GPIO_PIN(D, 0), // D8 13 | GPIO_PIN(D, 1), // D9 14 | GPIO_PIN(D, 2), // D10 15 | GPIO_PIN(D, 3), // D11 16 | GPIO_PIN(D, 4), // D12 17 | GPIO_PIN(D, 5), // D13 18 | GPIO_PIN(D, 6), // D14 19 | GPIO_PIN(D, 7), // D15 20 | GPIO_PIN(C, 0), // D16 21 | GPIO_PIN(C, 1), // D17 22 | GPIO_PIN(C, 2), // D18 23 | GPIO_PIN(C, 3), // D19 24 | GPIO_PIN(C, 4), // D20 25 | GPIO_PIN(C, 5), // D21 26 | GPIO_PIN(C, 6), // D22 27 | GPIO_PIN(C, 7), // D23 28 | GPIO_PIN(A, 0), // D24 29 | GPIO_PIN(A, 1), // D25 30 | GPIO_PIN(A, 2), // D26 31 | GPIO_PIN(A, 3), // D27 32 | GPIO_PIN(A, 4), // D28 33 | GPIO_PIN(A, 5), // D29 34 | GPIO_PIN(A, 6), // D30 35 | GPIO_PIN(A, 7) // D31 36 | }; 37 | #endif // BobuinoGpioPinMap_h -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/boards/LeonardoGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef LeonardoGpioPinMap_h 2 | #define LeonardoGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(D, 2), // D0 5 | GPIO_PIN(D, 3), // D1 6 | GPIO_PIN(D, 1), // D2 7 | GPIO_PIN(D, 0), // D3 8 | GPIO_PIN(D, 4), // D4 9 | GPIO_PIN(C, 6), // D5 10 | GPIO_PIN(D, 7), // D6 11 | GPIO_PIN(E, 6), // D7 12 | GPIO_PIN(B, 4), // D8 13 | GPIO_PIN(B, 5), // D9 14 | GPIO_PIN(B, 6), // D10 15 | GPIO_PIN(B, 7), // D11 16 | GPIO_PIN(D, 6), // D12 17 | GPIO_PIN(C, 7), // D13 18 | GPIO_PIN(B, 3), // D14 19 | GPIO_PIN(B, 1), // D15 20 | GPIO_PIN(B, 2), // D16 21 | GPIO_PIN(B, 0), // D17 22 | GPIO_PIN(F, 7), // D18 23 | GPIO_PIN(F, 6), // D19 24 | GPIO_PIN(F, 5), // D20 25 | GPIO_PIN(F, 4), // D21 26 | GPIO_PIN(F, 1), // D22 27 | GPIO_PIN(F, 0), // D23 28 | GPIO_PIN(D, 4), // D24 29 | GPIO_PIN(D, 7), // D25 30 | GPIO_PIN(B, 4), // D26 31 | GPIO_PIN(B, 5), // D27 32 | GPIO_PIN(B, 6), // D28 33 | GPIO_PIN(D, 6) // D29 34 | }; 35 | #endif // LeonardoGpioPinMap_h 36 | -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/boards/SleepingBeautyGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef SleepingBeautyGpioPinMap_h 2 | #define SleepingBeautyGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(D, 0), // D0 5 | GPIO_PIN(D, 1), // D1 6 | GPIO_PIN(D, 2), // D2 7 | GPIO_PIN(D, 3), // D3 8 | GPIO_PIN(B, 0), // D4 9 | GPIO_PIN(B, 1), // D5 10 | GPIO_PIN(B, 2), // D6 11 | GPIO_PIN(B, 3), // D7 12 | GPIO_PIN(D, 6), // D8 13 | GPIO_PIN(D, 5), // D9 14 | GPIO_PIN(B, 4), // D10 15 | GPIO_PIN(B, 5), // D11 16 | GPIO_PIN(B, 6), // D12 17 | GPIO_PIN(B, 7), // D13 18 | GPIO_PIN(C, 7), // D14 19 | GPIO_PIN(C, 6), // D15 20 | GPIO_PIN(A, 5), // D16 21 | GPIO_PIN(A, 4), // D17 22 | GPIO_PIN(A, 3), // D18 23 | GPIO_PIN(A, 2), // D19 24 | GPIO_PIN(A, 1), // D20 25 | GPIO_PIN(A, 0), // D21 26 | GPIO_PIN(D, 4), // D22 27 | GPIO_PIN(D, 7), // D23 28 | GPIO_PIN(C, 2), // D24 29 | GPIO_PIN(C, 3), // D25 30 | GPIO_PIN(C, 4), // D26 31 | GPIO_PIN(C, 5), // D27 32 | GPIO_PIN(C, 1), // D28 33 | GPIO_PIN(C, 0), // D29 34 | GPIO_PIN(A, 6), // D30 35 | GPIO_PIN(A, 7) // D31 36 | }; 37 | #endif // SleepingBeautyGpioPinMap_h -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/boards/Standard1284GpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef Standard1284GpioPinMap_h 2 | #define Standard1284GpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(B, 0), // D0 5 | GPIO_PIN(B, 1), // D1 6 | GPIO_PIN(B, 2), // D2 7 | GPIO_PIN(B, 3), // D3 8 | GPIO_PIN(B, 4), // D4 9 | GPIO_PIN(B, 5), // D5 10 | GPIO_PIN(B, 6), // D6 11 | GPIO_PIN(B, 7), // D7 12 | GPIO_PIN(D, 0), // D8 13 | GPIO_PIN(D, 1), // D9 14 | GPIO_PIN(D, 2), // D10 15 | GPIO_PIN(D, 3), // D11 16 | GPIO_PIN(D, 4), // D12 17 | GPIO_PIN(D, 5), // D13 18 | GPIO_PIN(D, 6), // D14 19 | GPIO_PIN(D, 7), // D15 20 | GPIO_PIN(C, 0), // D16 21 | GPIO_PIN(C, 1), // D17 22 | GPIO_PIN(C, 2), // D18 23 | GPIO_PIN(C, 3), // D19 24 | GPIO_PIN(C, 4), // D20 25 | GPIO_PIN(C, 5), // D21 26 | GPIO_PIN(C, 6), // D22 27 | GPIO_PIN(C, 7), // D23 28 | GPIO_PIN(A, 0), // D24 29 | GPIO_PIN(A, 1), // D25 30 | GPIO_PIN(A, 2), // D26 31 | GPIO_PIN(A, 3), // D27 32 | GPIO_PIN(A, 4), // D28 33 | GPIO_PIN(A, 5), // D29 34 | GPIO_PIN(A, 6), // D30 35 | GPIO_PIN(A, 7) // D31 36 | }; 37 | #endif // Standard1284GpioPinMap_h -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/boards/Teensy2GpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef Teensy2GpioPinMap_h 2 | #define Teensy2GpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(B, 0), // D0 5 | GPIO_PIN(B, 1), // D1 6 | GPIO_PIN(B, 2), // D2 7 | GPIO_PIN(B, 3), // D3 8 | GPIO_PIN(B, 7), // D4 9 | GPIO_PIN(D, 0), // D5 10 | GPIO_PIN(D, 1), // D6 11 | GPIO_PIN(D, 2), // D7 12 | GPIO_PIN(D, 3), // D8 13 | GPIO_PIN(C, 6), // D9 14 | GPIO_PIN(C, 7), // D10 15 | GPIO_PIN(D, 6), // D11 16 | GPIO_PIN(D, 7), // D12 17 | GPIO_PIN(B, 4), // D13 18 | GPIO_PIN(B, 5), // D14 19 | GPIO_PIN(B, 6), // D15 20 | GPIO_PIN(F, 7), // D16 21 | GPIO_PIN(F, 6), // D17 22 | GPIO_PIN(F, 5), // D18 23 | GPIO_PIN(F, 4), // D19 24 | GPIO_PIN(F, 1), // D20 25 | GPIO_PIN(F, 0), // D21 26 | GPIO_PIN(D, 4), // D22 27 | GPIO_PIN(D, 5), // D23 28 | GPIO_PIN(E, 6), // D24 29 | }; 30 | #endif // Teensy2GpioPinMap_h 31 | -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/boards/Teensy2ppGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef Teensypp2GpioPinMap_h 2 | #define Teensypp2GpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(D, 0), // D0 5 | GPIO_PIN(D, 1), // D1 6 | GPIO_PIN(D, 2), // D2 7 | GPIO_PIN(D, 3), // D3 8 | GPIO_PIN(D, 4), // D4 9 | GPIO_PIN(D, 5), // D5 10 | GPIO_PIN(D, 6), // D6 11 | GPIO_PIN(D, 7), // D7 12 | GPIO_PIN(E, 0), // D8 13 | GPIO_PIN(E, 1), // D9 14 | GPIO_PIN(C, 0), // D10 15 | GPIO_PIN(C, 1), // D11 16 | GPIO_PIN(C, 2), // D12 17 | GPIO_PIN(C, 3), // D13 18 | GPIO_PIN(C, 4), // D14 19 | GPIO_PIN(C, 5), // D15 20 | GPIO_PIN(C, 6), // D16 21 | GPIO_PIN(C, 7), // D17 22 | GPIO_PIN(E, 6), // D18 23 | GPIO_PIN(E, 7), // D19 24 | GPIO_PIN(B, 0), // D20 25 | GPIO_PIN(B, 1), // D21 26 | GPIO_PIN(B, 2), // D22 27 | GPIO_PIN(B, 3), // D23 28 | GPIO_PIN(B, 4), // D24 29 | GPIO_PIN(B, 5), // D25 30 | GPIO_PIN(B, 6), // D26 31 | GPIO_PIN(B, 7), // D27 32 | GPIO_PIN(A, 0), // D28 33 | GPIO_PIN(A, 1), // D29 34 | GPIO_PIN(A, 2), // D30 35 | GPIO_PIN(A, 3), // D31 36 | GPIO_PIN(A, 4), // D32 37 | GPIO_PIN(A, 5), // D33 38 | GPIO_PIN(A, 6), // D34 39 | GPIO_PIN(A, 7), // D35 40 | GPIO_PIN(E, 4), // D36 41 | GPIO_PIN(E, 5), // D37 42 | GPIO_PIN(F, 0), // D38 43 | GPIO_PIN(F, 1), // D39 44 | GPIO_PIN(F, 2), // D40 45 | GPIO_PIN(F, 3), // D41 46 | GPIO_PIN(F, 4), // D42 47 | GPIO_PIN(F, 5), // D43 48 | GPIO_PIN(F, 6), // D44 49 | GPIO_PIN(F, 7), // D45 50 | }; 51 | #endif // Teensypp2GpioPinMap_h 52 | -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/boards/UnoGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef UnoGpioPinMap_h 2 | #define UnoGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(D, 0), // D0 5 | GPIO_PIN(D, 1), // D1 6 | GPIO_PIN(D, 2), // D2 7 | GPIO_PIN(D, 3), // D3 8 | GPIO_PIN(D, 4), // D4 9 | GPIO_PIN(D, 5), // D5 10 | GPIO_PIN(D, 6), // D6 11 | GPIO_PIN(D, 7), // D7 12 | GPIO_PIN(B, 0), // D8 13 | GPIO_PIN(B, 1), // D9 14 | GPIO_PIN(B, 2), // D10 15 | GPIO_PIN(B, 3), // D11 16 | GPIO_PIN(B, 4), // D12 17 | GPIO_PIN(B, 5), // D13 18 | GPIO_PIN(C, 0), // D14 19 | GPIO_PIN(C, 1), // D15 20 | GPIO_PIN(C, 2), // D16 21 | GPIO_PIN(C, 3), // D17 22 | GPIO_PIN(C, 4), // D18 23 | GPIO_PIN(C, 5) // D19 24 | }; 25 | #endif // UnoGpioPinMap_h -------------------------------------------------------------------------------- /libraries/SdFat/src/DigitalIO/readme.txt: -------------------------------------------------------------------------------- 1 | Selected files from the DigitalIO library. 2 | 3 | https://github.com/greiman/DigitalIO -------------------------------------------------------------------------------- /libraries/SdFat/src/ExFatLib/ExFatConfig.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef ExFatConfig_h 26 | #define ExFatConfig_h 27 | #include "SdFatConfig.h" 28 | 29 | #ifndef EXFAT_READ_ONLY 30 | #define EXFAT_READ_ONLY 0 31 | #endif // EXFAT_READ_ONLY 32 | 33 | #endif // ExFatConfig_h 34 | -------------------------------------------------------------------------------- /libraries/SdFat/src/ExFatLib/ExFatLib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef ExFatLib_h 26 | #define ExFatLib_h 27 | #include "ExFatVolume.h" 28 | #include "ExFatFormatter.h" 29 | #endif // ExFatLib_h 30 | -------------------------------------------------------------------------------- /libraries/SdFat/src/ExFatLib/ExFatVolume.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #define DBG_FILE "ExFatVolume.cpp" 26 | #include "../common/DebugMacros.h" 27 | #include "ExFatLib.h" 28 | ExFatVolume* ExFatVolume::m_cwv = nullptr; 29 | //----------------------------------------------------------------------------- 30 | bool ExFatVolume::chdir(const char* path) { 31 | ExFatFile dir; 32 | if (!dir.open(vwd(), path, O_RDONLY)) { 33 | DBG_FAIL_MACRO; 34 | goto fail; 35 | } 36 | if (!dir.isDir()) { 37 | DBG_FAIL_MACRO; 38 | goto fail; 39 | } 40 | m_vwd = dir; 41 | return true; 42 | 43 | fail: 44 | return false; 45 | } 46 | -------------------------------------------------------------------------------- /libraries/SdFat/src/FatLib/FatLib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef FatLib_h 26 | #define FatLib_h 27 | #include "FatVolume.h" 28 | #include "FatFormatter.h" 29 | #endif // FatLib_h 30 | -------------------------------------------------------------------------------- /libraries/SdFat/src/FatLib/FatVolume.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #define DBG_FILE "FatVolume.cpp" 26 | #include "../common/DebugMacros.h" 27 | #include "FatLib.h" 28 | FatVolume* FatVolume::m_cwv = nullptr; 29 | //------------------------------------------------------------------------------ 30 | bool FatVolume::chdir(const char *path) { 31 | FatFile dir; 32 | if (!dir.open(vwd(), path, O_RDONLY)) { 33 | DBG_FAIL_MACRO; 34 | goto fail; 35 | } 36 | if (!dir.isDir()) { 37 | DBG_FAIL_MACRO; 38 | goto fail; 39 | } 40 | m_vwd = dir; 41 | return true; 42 | 43 | fail: 44 | return false; 45 | } 46 | -------------------------------------------------------------------------------- /libraries/SdFat/src/FsLib/FsLib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef FsLib_h 26 | #define FsLib_h 27 | /** 28 | * \file 29 | * \brief FsLib include file. 30 | */ 31 | #include "FsVolume.h" 32 | #include "FsFile.h" 33 | #include "FsFormatter.h" 34 | #endif // FsLib_h 35 | -------------------------------------------------------------------------------- /libraries/SdFat/src/FsLib/FsNew.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #include "FsNew.h" 26 | void* operator new(size_t size, newalign_t* ptr) { 27 | (void)size; 28 | return ptr; 29 | } 30 | -------------------------------------------------------------------------------- /libraries/SdFat/src/SdCard/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | exclude_files=SdioTeensy.h -------------------------------------------------------------------------------- /libraries/SdFat/src/common/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | exclude_files=PrintBasic.cpp 2 | exclude_files=PrintBasic.h 3 | exclude_files=PrintTemplates.h -------------------------------------------------------------------------------- /libraries/SdFat/src/common/FsBlockDevice.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef FsBlockDevice_h 26 | #define FsBlockDevice_h 27 | #include "SdCard/SdCard.h" 28 | #if HAS_SDIO_CLASS || USE_BLOCK_DEVICE_INTERFACE 29 | typedef FsBlockDeviceInterface FsBlockDevice; 30 | #else 31 | typedef SdCard FsBlockDevice; 32 | #endif 33 | #endif // FsBlockDevice_h 34 | -------------------------------------------------------------------------------- /libraries/SdFat/src/common/upcase.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef upcase_h 26 | #define upcase_h 27 | #include 28 | uint16_t toUpcase(uint16_t chr); 29 | uint32_t upcaseChecksum(uint16_t unicode, uint32_t checksum); 30 | #endif // upcase_h 31 | -------------------------------------------------------------------------------- /libraries/SdFat/src/sdios.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2021 Bill Greiman 3 | * This file is part of the SdFat library for SD memory cards. 4 | * 5 | * MIT License 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef sdios_h 26 | #define sdios_h 27 | /** 28 | * \file 29 | * \brief C++ IO Streams features. 30 | */ 31 | #include "iostream/ArduinoStream.h" 32 | #include "iostream/fstream.h" 33 | #include "iostream/StdioStream.h" 34 | #endif // sdios_h 35 | -------------------------------------------------------------------------------- /libraries/WDT_T4/Watchdog_t4.h: -------------------------------------------------------------------------------- 1 | #if !defined(_WATCHDOG_T4_H_) 2 | #define _WATCHDOG_T4_H_ 3 | 4 | #include "Arduino.h" 5 | 6 | typedef void (*watchdog_class_ptr)(); 7 | 8 | typedef enum WDT_DEV_TABLE { 9 | WDT1 = (uint32_t)0x400B8000, 10 | WDT2 = (uint32_t)0x400D0000, 11 | WDT3 = (uint32_t)0x400BC000, 12 | EWM = (uint32_t)0x400B4000 13 | } WDT_DEV_TABLE; 14 | 15 | typedef enum RTWDOG_CLK_TABLE { 16 | BUS_CLK = 0, 17 | LPO_CLK = 1, 18 | INT_CLK = 2, 19 | ER_CLK = 3 20 | } RTWDOG_CLK_TABLE; 21 | 22 | typedef struct WDT_timings_t { 23 | double trigger = 5; 24 | double timeout = 10; 25 | double window = 0; 26 | uint8_t pin = 0; 27 | RTWDOG_CLK_TABLE clock = LPO_CLK; /* default clock, 32KHz */ 28 | bool lp_suspend = 0; 29 | uint8_t input = 0; 30 | bool update = 1; 31 | bool cmd32en = 1; 32 | watchdog_class_ptr callback = nullptr; 33 | } WDT_timings_t; 34 | 35 | #define WDT_CLASS template 36 | #define WDT_FUNC template 37 | #define WDT_OPT WDT_T4<_device> 38 | 39 | class WDT_T4_Base { 40 | public: 41 | virtual void watchdog_isr() = 0; 42 | virtual void ewatchdog_isr() = 0; 43 | watchdog_class_ptr watchdog_class_handler = 0; 44 | private: 45 | }; 46 | 47 | static WDT_T4_Base* _WDT1 = nullptr; 48 | static WDT_T4_Base* _WDT2 = nullptr; 49 | static WDT_T4_Base* _WDT3 = nullptr; 50 | static WDT_T4_Base* _EWM = nullptr; 51 | 52 | WDT_CLASS class WDT_T4 : public WDT_T4_Base { 53 | public: 54 | void begin(WDT_timings_t config); 55 | void callback(watchdog_class_ptr handler) { watchdog_class_handler = handler; } 56 | void reset(); 57 | void feed(); 58 | bool expired(); 59 | private: 60 | watchdog_class_ptr watchdog_class_handler; 61 | void watchdog_isr(); 62 | void ewatchdog_isr(); 63 | }; 64 | 65 | #include "Watchdog_t4.tpp" 66 | #endif -------------------------------------------------------------------------------- /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 | setClock KEYWORD2 22 | setSDA KEYWORD2 23 | setSCL KEYWORD2 24 | 25 | ####################################### 26 | # Instances (KEYWORD2) 27 | ####################################### 28 | 29 | Wire KEYWORD2 30 | 31 | ####################################### 32 | # Constants (LITERAL1) 33 | ####################################### 34 | 35 | -------------------------------------------------------------------------------- /libraries/Wire/library.properties: -------------------------------------------------------------------------------- 1 | name=Wire 2 | version=1.0 3 | author=Arduino 4 | maintainer=Paul Stoffregen 5 | sentence=This library allows you to communicate with I2C and Two Wire Interface devices. 6 | paragraph=It allows the communication with I2C devices like temperature sensors, realtime clocks and many others using SDA (Data Line) and SCL (Clock Line). 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/Wire 9 | architectures=* 10 | 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/comms/data/buff_encoder_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(FIRMWARE) 4 | #include "comms/data/comms_data.hpp" // for CommsData 5 | #elif defined(HIVE) 6 | #include "modules/comms/data/comms_data.hpp" // for CommsData 7 | #endif 8 | 9 | #include // uintN_t 10 | 11 | /// @brief Structure for the buff encoder sensor. 12 | struct BuffEncoderData : Comms::CommsData { 13 | BuffEncoderData() : CommsData(Comms::TypeLabel::BuffEncoderData, Comms::PhysicalMedium::Ethernet, Comms::Priority::Medium, sizeof(BuffEncoderData)) { } 14 | /// Sensor ID. 15 | uint8_t id; 16 | /// Measured angle. 17 | float m_angle; 18 | }; -------------------------------------------------------------------------------- /src/comms/data/comms_data.cpp: -------------------------------------------------------------------------------- 1 | #include "comms_data.hpp" 2 | 3 | #if defined(HIVE) 4 | #include // for doctest 5 | 6 | TEST_CASE("To string does stuff") { 7 | CHECK(Comms::to_string(Comms::TypeLabel::NONE) == "NONE"); 8 | CHECK(Comms::to_string(Comms::TypeLabel::TestData) == "TestData"); 9 | CHECK(Comms::to_string(Comms::TypeLabel::BigTestData) == "BigTestData"); 10 | CHECK(Comms::to_string(Comms::TypeLabel::LoggingData) == "LoggingData"); 11 | CHECK(Comms::to_string(Comms::TypeLabel::BuffEncoderData) == "BuffEncoderData"); 12 | CHECK(Comms::to_string(Comms::TypeLabel::ICMSensorData) == "ICMSensorData"); 13 | CHECK(Comms::to_string(Comms::TypeLabel::RevEncoderData) == "RevEncoderData"); 14 | CHECK(Comms::to_string(Comms::TypeLabel::TOFSensorData) == "TOFSensorData"); 15 | CHECK(Comms::to_string(Comms::TypeLabel::LidarDataPacketSI) == "LidarDataPacketSI"); 16 | CHECK(Comms::to_string(Comms::TypeLabel::DR16Data) == "DR16Data"); 17 | CHECK(Comms::to_string(Comms::TypeLabel::TempRobotState) == "TempRobotState"); 18 | CHECK(Comms::to_string(Comms::TypeLabel::TargetState) == "TargetState"); 19 | CHECK(Comms::to_string(Comms::TypeLabel::EstimatedState) == "EstimatedState"); 20 | CHECK(Comms::to_string(Comms::TypeLabel::OverrideState) == "OverrideState"); 21 | CHECK(Comms::to_string(Comms::TypeLabel::ConfigSection) == "ConfigSection"); 22 | CHECK(Comms::to_string(Comms::TypeLabel::CommsRefData) == "CommsRefData"); 23 | CHECK(Comms::to_string(Comms::TypeLabel(0xff)) == "UNKNOWN"); 24 | } 25 | 26 | #endif -------------------------------------------------------------------------------- /src/comms/data/comms_ref_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(FIRMWARE) 4 | #include "comms/data/comms_data.hpp" // for CommsData 5 | #elif defined(HIVE) 6 | #include "modules/comms/data/comms_data.hpp" // for CommsData 7 | #endif 8 | 9 | #include // uintN_t 10 | 11 | // TODO: make this nice 12 | /// @brief Ref data 13 | struct CommsRefData : Comms::CommsData { 14 | CommsRefData() : CommsData(Comms::TypeLabel::CommsRefData, Comms::PhysicalMedium::Ethernet, Comms::Priority::High, sizeof(CommsRefData)) { } 15 | 16 | /// @brief Raw data 17 | uint8_t raw[180] = { 0 }; 18 | }; -------------------------------------------------------------------------------- /src/comms/data/config_section.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(FIRMWARE) 4 | #include "comms/data/comms_data.hpp" // for CommsData 5 | #elif defined(HIVE) 6 | #include "modules/comms/data/comms_data.hpp" // for CommsData 7 | #endif 8 | 9 | #include // uintN_t 10 | 11 | // TODO: make this ethernet capable 12 | /// @brief Section of a config packet 13 | struct ConfigSection : Comms::CommsData { 14 | ConfigSection() : CommsData(Comms::TypeLabel::ConfigSection, Comms::PhysicalMedium::HID, Comms::Priority::High, sizeof(ConfigSection)) { } 15 | 16 | /// @brief filler byte 17 | uint8_t filler = 0xff; 18 | /// @brief Section ID 19 | int8_t section_id = 0; 20 | /// @brief Subsection ID 21 | int8_t subsection_id = 0; 22 | /// @brief Info bit, stores the config request bit 23 | bool request_bit = 0; 24 | 25 | /// @brief Size of the whole section 26 | uint16_t section_size = 0; 27 | /// @brief Size of the subsection 28 | uint16_t subsection_size = 0; 29 | 30 | /// @brief Raw config data 31 | uint8_t raw[1000] = { 0 }; 32 | }; -------------------------------------------------------------------------------- /src/comms/data/data_structs.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DATA_STRUCTS_HPP 2 | #define DATA_STRUCTS_HPP 3 | 4 | #if defined(FIRMWARE) 5 | #include "comms/data/comms_data.hpp" // for CommsData 6 | #elif defined(HIVE) 7 | #include "modules/comms/data/comms_data.hpp" // for CommsData 8 | #endif 9 | 10 | #include // uintN_t 11 | 12 | #include "test_data.hpp" 13 | 14 | #include "buff_encoder_data.hpp" 15 | 16 | #include "rev_sensor_data.hpp" 17 | 18 | #include "icm_sensor_data.hpp" 19 | 20 | #include "tof_sensor_data.hpp" 21 | 22 | #include "lidar_data_packet_si.hpp" 23 | 24 | #include "dr16_data.hpp" 25 | 26 | #include "robot_state_data.hpp" 27 | 28 | #include "config_section.hpp" 29 | 30 | #include "comms_ref_data.hpp" 31 | 32 | #endif // DATA_STRUCTS_HPP -------------------------------------------------------------------------------- /src/comms/data/hive_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(HIVE) 4 | #include "modules/comms/data/comms_data.hpp" // for CommsData 5 | #include "modules/comms/data/data_structs.hpp" // for shared data structs 6 | #elif defined(FIRMWARE) 7 | #include "comms/data/comms_data.hpp" // for CommsData 8 | #include "comms/data/data_structs.hpp" // for shared data structs 9 | #endif 10 | 11 | namespace Comms { 12 | 13 | /// @brief Megastruct for receiving data from Hive, filled on firmware. 14 | struct HiveData { 15 | /// @brief Set a data section in the mega struct. 16 | /// @param data The data to be set. 17 | /// @warning This is not thread safe, call this on local copies only 18 | void set_data(CommsData* data); 19 | 20 | /// @brief Test data 21 | TestData test_data; 22 | /// @brief Big test data 23 | BigTestData big_test_data; 24 | 25 | /// @brief Target state 26 | TargetState target_state; 27 | 28 | /// @brief Override state 29 | OverrideState override_state; 30 | 31 | /// @brief Config section 32 | ConfigSection config_section; 33 | }; 34 | 35 | } // namespace Comms 36 | -------------------------------------------------------------------------------- /src/comms/data/icm_sensor_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(FIRMWARE) 4 | #include "comms/data/comms_data.hpp" // for CommsData 5 | #elif defined(HIVE) 6 | #include "modules/comms/data/comms_data.hpp" // for CommsData 7 | #endif 8 | 9 | #include // uintN_t 10 | 11 | /// @brief Structure for the ICM sensor. 12 | struct ICMSensorData : Comms::CommsData { 13 | ICMSensorData() : CommsData(Comms::TypeLabel::ICMSensorData, Comms::PhysicalMedium::Ethernet, Comms::Priority::Medium, sizeof(ICMSensorData)) { } 14 | /// Sensor ID. 15 | uint8_t id; 16 | /// Acceleration in X-axis. 17 | float accel_X; 18 | /// Acceleration in Y-axis. 19 | float accel_Y; 20 | /// Acceleration in Z-axis. 21 | float accel_Z; 22 | /// Gyroscope reading in X-axis. 23 | float gyro_X; 24 | /// Gyroscope reading in Y-axis. 25 | float gyro_Y; 26 | /// Gyroscope reading in Z-axis. 27 | float gyro_Z; 28 | /// Temperature reading. 29 | float temperature; 30 | }; -------------------------------------------------------------------------------- /src/comms/data/rev_sensor_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(FIRMWARE) 4 | #include "comms/data/comms_data.hpp" // for CommsData 5 | #elif defined(HIVE) 6 | #include "modules/comms/data/comms_data.hpp" // for CommsData 7 | #endif 8 | 9 | #include // uintN_t 10 | 11 | /// @brief Structure for the Rev encoder sensor. 12 | struct RevSensorData : Comms::CommsData { 13 | RevSensorData() : CommsData(Comms::TypeLabel::RevEncoderData, Comms::PhysicalMedium::Ethernet, Comms::Priority::Medium, sizeof(RevSensorData)) { } 14 | /// Sensor ID. 15 | uint8_t id; 16 | /// Encoder ticks. 17 | int ticks; 18 | /// Angle in radians. 19 | float radians; 20 | }; -------------------------------------------------------------------------------- /src/comms/data/test_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(FIRMWARE) 4 | #include "comms/data/comms_data.hpp" // for CommsData 5 | #elif defined(HIVE) 6 | #include "modules/comms/data/comms_data.hpp" // for CommsData 7 | #endif 8 | 9 | #include // uintN_t 10 | 11 | /// @brief Data struct for testing purposes 12 | struct TestData : Comms::CommsData { 13 | TestData() : Comms::CommsData(Comms::TypeLabel::TestData, Comms::PhysicalMedium::Ethernet, Comms::Priority::High, sizeof(TestData)) {} 14 | /// @brief x value 15 | float x = 1.f; 16 | /// @brief y value 17 | float y = 2.f; 18 | /// @brief z value 19 | float z = 3.f; 20 | /// @brief w value 21 | uint32_t w = 0x98765432; 22 | }; 23 | 24 | /// @brief Data struct for testing purposes 25 | struct BigTestData : Comms::CommsData { 26 | BigTestData() : Comms::CommsData(Comms::TypeLabel::BigTestData, Comms::PhysicalMedium::Ethernet, Comms::Priority::High, sizeof(BigTestData)) {} 27 | 28 | /// @brief a bunch of data 29 | float blah[128] = { 0 }; 30 | }; -------------------------------------------------------------------------------- /src/comms/data/tof_sensor_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(FIRMWARE) 4 | #include "comms/data/comms_data.hpp" // for CommsData 5 | #elif defined(HIVE) 6 | #include "modules/comms/data/comms_data.hpp" // for CommsData 7 | #endif 8 | 9 | #include // uintN_t 10 | 11 | /// @brief Structure for the TOF (Time-of-Flight) sensor. 12 | struct TOFSensorData : Comms::CommsData { 13 | TOFSensorData() : CommsData(Comms::TypeLabel::TOFSensorData, Comms::PhysicalMedium::Ethernet, Comms::Priority::Medium, sizeof(TOFSensorData)) { } 14 | /// Sensor ID. 15 | uint8_t id; 16 | /// Latest distance measurement. 17 | uint16_t latest_distance; 18 | }; -------------------------------------------------------------------------------- /src/comms/hid_packet.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "packet_header.hpp" 4 | 5 | namespace Comms { 6 | 7 | /// @brief The maximum size of a HID packet, including the header 8 | constexpr uint32_t HID_PACKET_MAX_SIZE = (1023u); 9 | 10 | /// @brief The size of the payload-usable space in a HID packet 11 | constexpr uint32_t HID_PACKET_PAYLOAD_SIZE = (HID_PACKET_MAX_SIZE - PACKET_HEADER_SIZE); 12 | 13 | /// @brief A complete HID packet, including the header and payload 14 | struct HIDPacket { 15 | /// @brief The header of the packet 16 | PacketHeader header = {}; 17 | /// @brief The payload of the packet 18 | uint8_t data[HID_PACKET_PAYLOAD_SIZE] = { 0 }; 19 | 20 | /// @brief The first byte of the packet itself 21 | /// @return A pointer to the first byte of the packet 22 | uint8_t* data_start() { return reinterpret_cast(this); } 23 | 24 | /// @brief The first byte of the payload 25 | /// @return A pointer to the first byte of the payload 26 | uint8_t* payload() { return data; } 27 | }; 28 | 29 | /// @brief The largest alignment block of the HID packet 30 | constexpr uint32_t HID_PACKET_ALIGNMENT = (alignof(HIDPacket)); 31 | 32 | } // end Comms namespace -------------------------------------------------------------------------------- /src/comms/packet_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include // uintX_t 4 | #include // memset 5 | 6 | /// @brief Comms packet flags 7 | /// @note These flags are used to indicate the state of the packet 8 | enum class PacketFlags : uint8_t { 9 | NONE = 0, 10 | CONFIGURED = 1 << 0, // 0x01 11 | }; 12 | 13 | /// @brief The start of frame (SOF) byte 14 | constexpr uint8_t PACKET_SOF = 0xAB; 15 | 16 | /// @brief Comms packet header struct 17 | struct PacketHeader { 18 | /// @brief Starter byte (Start of Frame) 19 | uint8_t SOF = PACKET_SOF; // must be first 20 | /// @brief Info flags for this packet 21 | PacketFlags flags = PacketFlags::NONE; 22 | /// @brief A sequential ID of this packet. Value is incremented every time a packet is sent 23 | uint16_t sequence = 0; 24 | }; 25 | 26 | /// @brief Size of a packet header 27 | constexpr uint32_t PACKET_HEADER_SIZE = (sizeof(PacketHeader)); 28 | 29 | /// @brief The largest alignment block of the packet header 30 | constexpr uint32_t PACKET_HEADER_ALIGNMENT = (alignof(PacketHeader)); -------------------------------------------------------------------------------- /src/filters/lowpass_filter.cpp: -------------------------------------------------------------------------------- 1 | #include "lowpass_filter.hpp" -------------------------------------------------------------------------------- /src/filters/lowpass_filter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOWPASS_FILTER_H 2 | #define LOWPASS_FILTER_H 3 | 4 | /// @brief Filter out short term fluctuations in signals 5 | class LowpassFilter { 6 | private: 7 | /// @brief gain 8 | float K = 0.4; // default gain 9 | /// @brief returned output 10 | float output = 0.0; 11 | 12 | public: 13 | /// @brief make new lowpass filter 14 | /// @param K gain 15 | LowpassFilter(float K) { this->K = K; } 16 | /// @brief set gain 17 | /// @param K new gain 18 | void set_gain(float K) { this->K = K; } 19 | /// @brief filter and return output 20 | /// @param measurement input measurment 21 | /// @return filtered output 22 | float filter(float measurement) { 23 | output = (K * output) + ((1 - K) * measurement); 24 | return output; 25 | } 26 | }; 27 | 28 | #endif // LOWPASS_FILTER_H -------------------------------------------------------------------------------- /src/filters/pid_filter.cpp: -------------------------------------------------------------------------------- 1 | #include "pid_filter.hpp" -------------------------------------------------------------------------------- /src/filters/pid_filter.hpp: -------------------------------------------------------------------------------- 1 | #include "math.h" 2 | #include 3 | 4 | #ifndef PID_FILTER_H 5 | #define PID_FILTER_H 6 | 7 | /// @brief PIDF filter used in controls. Gains are configurable via K 8 | struct PIDFilter { 9 | /// @brief gains 10 | float K[4] = { 0.0 }; // P, I, D, F 11 | /// @brief integrated error 12 | float sumError = 0; 13 | /// @brief previous error 14 | float prevError = 0; 15 | 16 | /// @brief target 17 | float setpoint = 0; 18 | /// @brief estimate 19 | float measurement = 0; 20 | /// @brief feedforward component 21 | float feedForward = 0; 22 | 23 | /// @brief calculate pidf output 24 | /// @param dt delta time 25 | /// @param bound bound from -1 to 1 26 | /// @param wrap wrap at 2*pi 27 | /// @return pidf output 28 | float filter(float dt, bool bound, bool wrap) { 29 | float error = setpoint - measurement; 30 | if (error > PI && wrap) error -= 2 * PI; 31 | if (error < -PI && wrap) error += 2 * PI; 32 | // if(wrap) Serial.println(error); 33 | sumError += error * dt; 34 | float output = (K[0] * error) + (K[2] * ((error - prevError) / dt)) + K[3]; 35 | // + (K[1] * sumError) 36 | // + (K[2] * ((error - prevError) / dt)); 37 | // + (K[3] * feedForward); 38 | prevError = error; 39 | if (fabs(output) > 1.0 && bound) output /= fabs(output); 40 | return output; 41 | } 42 | 43 | /// @brief set gains 44 | /// @param gains new gains 45 | void set_K(float gains[4]) { 46 | for (int i = 0;i < 4; i++) { 47 | K[i] = gains[i]; 48 | } 49 | } 50 | }; 51 | 52 | #endif // PID_FILTER_H -------------------------------------------------------------------------------- /src/sensors/ACS712.cpp: -------------------------------------------------------------------------------- 1 | #include "ACS712.hpp" 2 | 3 | float ACS712::read() { 4 | // equation from datasheet 5 | // 2.475 is the baseline read with little to no power draw on chassis 6 | // 3.3 is the voltage of the system 7 | // 1023 is the max value of the analog read 8 | float result = (m_base_voltage - ((analogRead(m_pin) * (3.3 / 1023.0)))) / m_sensitivity; 9 | current = result; 10 | current = 0.6 * old_current + 0.4 * current; 11 | 12 | old_current = current; 13 | 14 | return result; 15 | } -------------------------------------------------------------------------------- /src/sensors/ACS712.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ACS712_CURRENT_SENSOR_HPP 2 | #define ACS712_CURRENT_SENSOR_HPP 3 | 4 | #include 5 | 6 | // Datasheet: https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf 7 | 8 | /// @brief The pin to read current from. TEENSY I SENSE on the electrical team pinout 9 | constexpr int ACS712_READ_PIN = 38; 10 | 11 | /// @brief Class for reading current from ACS712 sensor 12 | class ACS712 { 13 | public: 14 | /// @brief Default Constructor. Uses the default pin to read current from 15 | ACS712() : m_pin(ACS712_READ_PIN) {} 16 | 17 | /// @brief Basic Constructor. Assigns whatever pin to read with 18 | /// @param pin The pin to read current from 19 | ACS712(int pin) : m_pin(pin) {}; 20 | 21 | /// @brief Reads the current from the ACS712 sensor 22 | /// @return The current read from the sensor in mA 23 | float read(); 24 | /// @brief gets the last read current (lowpass filtered) from the sensor 25 | /// @return float current 26 | inline float get_current() { return current; } 27 | 28 | private: 29 | /// @brief The pin to read current from 30 | int m_pin = -1; 31 | 32 | /// @brief The base voltage of the sensor 33 | const float m_base_voltage = 2.475f; 34 | 35 | /// @brief The sensitivity of the sensor, taken from the datasheet 36 | const float m_sensitivity = 0.066f; 37 | 38 | /// @brief The current read from the sensor 39 | float current = 0; 40 | /// @brief The old current read from the sensor 41 | float old_current = 0; 42 | }; 43 | 44 | extern ACS712 current_sensor; 45 | 46 | #endif // ACS712_CURRENT_SENSOR_HPP -------------------------------------------------------------------------------- /src/sensors/IMUSensor.cpp: -------------------------------------------------------------------------------- 1 | #include "IMUSensor.hpp" 2 | 3 | // default implementation for printing data 4 | void IMUSensor::print() { 5 | // Display the temperature data, measured in Celcius 6 | Serial.print("\t\tTemperature "); 7 | Serial.print(get_temperature()); 8 | Serial.println(" deg C"); 9 | // Display the acceleration data, measured in m/s^2) 10 | Serial.print("\t\tAccel X: "); 11 | Serial.print(get_accel_X()); 12 | Serial.print(" \tY: "); 13 | Serial.print(get_accel_Y()); 14 | Serial.print(" \tZ: "); 15 | Serial.print(get_accel_Z()); 16 | Serial.println(" m/s^2 "); 17 | // Display gyroscope data, measured in radians/s 18 | Serial.print("\t\tGyro X: "); 19 | Serial.print(get_gyro_X()); 20 | Serial.print(" \tY: "); 21 | Serial.print(get_gyro_Y()); 22 | Serial.print(" \tZ: "); 23 | Serial.print(get_gyro_Z()); 24 | Serial.println(" radians/s "); 25 | Serial.println(); 26 | } -------------------------------------------------------------------------------- /src/sensors/LSM6DSOX.cpp: -------------------------------------------------------------------------------- 1 | #include "LSM6DSOX.hpp" 2 | 3 | LSM6DSOX::LSM6DSOX() {} 4 | 5 | // initialize LSM 6 | void LSM6DSOX::init() { 7 | // start I2C communication (SPI not supported on LSM6DOX+LIS3MDL hardware) 8 | sensor.begin_I2C(); 9 | 10 | // set data ranges 11 | sensor.setAccelRange(LSM6DS_ACCEL_RANGE_16_G); 12 | sensor.setGyroRange(LSM6DS_GYRO_RANGE_2000_DPS); // LSM does not support 4000 DPS 13 | 14 | sensor.setAccelDataRate(LSM6DS_RATE_6_66K_HZ); 15 | sensor.setGyroDataRate(LSM6DS_RATE_6_66K_HZ); 16 | } 17 | 18 | bool LSM6DSOX::read() { 19 | // get the event data from the sensor class 20 | sensor.getEvent(&accel, &gyro, &temp); 21 | 22 | // assign result to this object's members. 23 | // could increase efficiency by specifying which values we need, and only assigning values to the object's members from that. 24 | // However, getEvent will read all values from the sensor regardless, and assigning these values is very fast 25 | 26 | accel_X = accel.acceleration.x; 27 | accel_Y = accel.acceleration.y; 28 | accel_Z = accel.acceleration.z; 29 | gyro_X = gyro.gyro.x; 30 | gyro_Y = gyro.gyro.y; 31 | gyro_Z = gyro.gyro.z; 32 | 33 | temperature = temp.temperature; 34 | return true; 35 | } -------------------------------------------------------------------------------- /src/sensors/LSM6DSOX.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LSM6DSOX_H 2 | #define LSM6DSOX_H 3 | 4 | #include "IMUSensor.hpp" // abstract parent 5 | // adafruit library specific to LSM6DS(...) hardware 6 | #include 7 | 8 | /// @brief Sensor access for an LSM6DSOX IMU Sensor. Child of the abstract IMUSensor class. 9 | /// @note We currently use the LSM6DSOX+LIS3MDL, which has an accelerometer, gyroscope, and magnetometer. This board only supports I2C (not SPI) communication. 10 | /// @see Adafruit library this class utilizes: https://adafruit.github.io/Adafruit_LSM6DS/html/class_adafruit___l_s_m6_d_s_o_x.html 11 | class LSM6DSOX : public IMUSensor { 12 | public: 13 | /// @brief Constructor. Currently does nothing, use @ref init() instead for initialization. 14 | LSM6DSOX(); 15 | 16 | /// @brief Initialize the sensor 17 | void init(); 18 | 19 | /// @copydoc IMUSensor::read() 20 | bool read() override; 21 | 22 | private: 23 | /// @brief sensor object from adafruit libraries. 24 | Adafruit_LSM6DSOX sensor; 25 | }; 26 | 27 | #endif -------------------------------------------------------------------------------- /src/sensors/Sensor.cpp: -------------------------------------------------------------------------------- 1 | #include "Sensor.hpp" 2 | 3 | uint8_t Sensor::next_id_ = 0; -------------------------------------------------------------------------------- /src/sensors/Sensor.hpp: -------------------------------------------------------------------------------- 1 | // Sensor.hpp 2 | 3 | #ifndef SENSOR_HPP 4 | #define SENSOR_HPP 5 | 6 | #include 7 | 8 | enum SensorType : uint8_t { 9 | BUFFENC = 0, 10 | ICM = 1, 11 | REVENC = 2, 12 | TOF = 3, 13 | LIDAR = 4, 14 | 15 | // Add other sensor types here 16 | }; 17 | 18 | /// @brief Base class for all sensors. 19 | class Sensor { 20 | public: 21 | /// @brief Constructor to initialize the sensor with a specific type. 22 | /// @param type The type of the sensor. 23 | Sensor(SensorType type) : type_(type), id_(next_id_++) { }; 24 | 25 | /// @brief Constructor to initialize the sensor with a specific type and ID. 26 | /// @param type The type of the sensor. 27 | /// @param id The ID of the sensor. 28 | Sensor(SensorType type, uint8_t id) : type_(type), id_(id) { }; 29 | 30 | /// @brief Virtual destructor for the sensor. 31 | virtual ~Sensor() = default; 32 | 33 | /// @brief Get the type of the sensor. 34 | /// @return The type of the sensor. 35 | SensorType getType() const { return type_; } 36 | 37 | /// @brief Get the ID of the sensor. 38 | /// @return The ID of the sensor. 39 | uint8_t getId() const { return id_; } 40 | 41 | /// @brief Set the ID of the sensor. 42 | /// @param id The new ID of the sensor. 43 | void setId(uint8_t id) { id_ = id; } 44 | 45 | /// @brief Read the sensor data. 46 | /// @return true if successful, false if no data available 47 | virtual bool read() = 0; 48 | 49 | protected: 50 | 51 | ///The type of the sensor. 52 | SensorType type_; 53 | ///The ID of the sensor. 54 | uint8_t id_; 55 | 56 | private: 57 | /// Static variable to generate unique IDs for sensors. 58 | static uint8_t next_id_; 59 | }; 60 | 61 | #endif // SENSOR_HPP 62 | -------------------------------------------------------------------------------- /src/sensors/StereoCamTrigger.cpp: -------------------------------------------------------------------------------- 1 | #include "StereoCamTrigger.hpp" 2 | 3 | void StereoCamTrigger::track_exposures() { 4 | // disable interrupts to protect volatile access 5 | cli(); 6 | 7 | // generate HIGH pulse with given width to create square wave 8 | digitalWrite(TRIG_PIN, HIGH); 9 | delayMicroseconds(TRIG_PULSE_WIDTH); 10 | digitalWrite(TRIG_PIN, LOW); 11 | 12 | // update timestamp 13 | #ifdef LOG_STEREO_FPS 14 | uint32_t prev_timestamp = latest_exposure_timestamp; 15 | #endif 16 | 17 | latest_exposure_timestamp = micros(); 18 | 19 | #ifdef LOG_STEREO_FPS 20 | uint32_t delta = latest_exposure_timestamp - prev_timestamp; 21 | 22 | // print FPS estimate 23 | Serial.printf("fps: %f\n", 1/(float(delta) * 1.0e-6)); 24 | #endif 25 | 26 | // reenable interrupts 27 | sei(); 28 | } 29 | 30 | void StereoCamTrigger::start(int res) { 31 | if (stopped) { 32 | // if the timer is stopped, start it again with the track_exposures callback 33 | timer.begin([this]{ track_exposures(); }, res); 34 | stopped = false; 35 | } 36 | } 37 | 38 | void StereoCamTrigger::stop() { 39 | if (!stopped) { 40 | // if the timer is running, stop it 41 | timer.end(); 42 | stopped = true; 43 | } 44 | } 45 | 46 | void StereoCamTrigger::init() { 47 | // configure GPIO pin for sending output signal 48 | pinMode(TRIG_PIN, OUTPUT); 49 | 50 | // determine timer resolution from FPS 51 | float spf = 1.0 / float(fps); // seconds per frame 52 | int mpf = 1.0e+6 * spf; // micros per frame 53 | 54 | // start the timer with the calculated resolution 55 | start(mpf); 56 | } 57 | 58 | uint32_t StereoCamTrigger::get_latest_exposure_timestamp() { 59 | uint32_t ret; 60 | 61 | cli(); // disable interrupts to protect volatile access 62 | ret = latest_exposure_timestamp; 63 | sei(); // reenable interrupts 64 | 65 | return ret; 66 | } -------------------------------------------------------------------------------- /src/sensors/buff_encoder.cpp: -------------------------------------------------------------------------------- 1 | #include "buff_encoder.hpp" 2 | 3 | const SPISettings BuffEncoder::m_settings = SPISettings(1000000, MT6835_BITORDER, SPI_MODE3); 4 | 5 | bool BuffEncoder::read() { 6 | 7 | uint8_t data[6] = { 0 }; // transact 48 bits 8 | 9 | // set the operation 10 | data[0] = (MT6835_OP_ANGLE << 4); 11 | data[1] = MT6835_REG_ANGLE1; 12 | 13 | // do the SPI transfer 14 | SPI.beginTransaction(m_settings); 15 | digitalWrite(m_CS, LOW); 16 | SPI.transfer(data, 6); 17 | digitalWrite(m_CS, HIGH); 18 | SPI.endTransaction(); 19 | 20 | 21 | // convert received angle into radians 22 | int raw_angle = (data[2] << 13) | (data[3] << 5) | (data[4] >> 3); 23 | float radians = raw_angle / (float)MT6835_CPR * (3.14159265 * 2.0); 24 | 25 | // assign angle 26 | m_angle = radians; 27 | //add angle to the data struct 28 | buff_sensor_data.m_angle = m_angle; 29 | return true; 30 | } 31 | 32 | 33 | void BuffEncoder::print() { 34 | Serial.printf("Buff Encoder:\n\t"); 35 | Serial.println(m_angle); 36 | } -------------------------------------------------------------------------------- /src/sensors/limit_switch.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // tie C pin to 3.3v 6 | // NO pin is the pin to read, it is set up as input pulldown 7 | // NC should be untied 8 | 9 | /// @brief Class to manage a limit switch 10 | class LimitSwitch { 11 | public: 12 | /// @brief Constructor for the LimitSwitch class 13 | /// @param pin The pin number to which the limit switch is connected 14 | LimitSwitch(int pin) : pin(pin) { 15 | pinMode(pin, INPUT_PULLDOWN); 16 | } 17 | 18 | /// @brief Get the status of the switch 19 | /// @return true if the switch is pressed, false otherwise 20 | bool isPressed() { 21 | return digitalRead(pin); 22 | } 23 | 24 | /// @brief Set the pin number for the limit switch 25 | /// @param newPin The new pin number to which the limit switch is connected 26 | void setPin(int newPin) { 27 | pin = newPin; 28 | pinMode(pin, INPUT); 29 | } 30 | 31 | private: 32 | /// @brief The pin number to which the limit switch is connected 33 | int pin; 34 | }; 35 | -------------------------------------------------------------------------------- /src/sensors/rev_encoder.cpp: -------------------------------------------------------------------------------- 1 | #include "rev_encoder.hpp" 2 | 3 | RevEncoder::RevEncoder(uint8_t encoder_pin) : Sensor(SensorType::REVENC) { 4 | this->in_pin = encoder_pin; 5 | pinMode(this->in_pin, INPUT); // Set the pin used to measure the encoder to be an input 6 | freq.begin(this->in_pin, FREQMEASUREMULTI_MARK_ONLY); 7 | }; 8 | 9 | void RevEncoder::init(uint8_t encoder_pin, bool is_relative) { 10 | this->in_pin = encoder_pin; 11 | pinMode(this->in_pin, INPUT); // Set the pin used to measure the encoder to be an input 12 | freq.begin(this->in_pin, FREQMEASUREMULTI_MARK_ONLY); 13 | if(is_relative){ 14 | for(int i=0;i<500;i++){ 15 | this->read(); 16 | delayMicroseconds(5); 17 | } 18 | starting_value = this->radians; 19 | } 20 | } 21 | 22 | bool RevEncoder::read() { 23 | while (this->freq.available() > 1) { 24 | this->freq.read(); 25 | } 26 | 27 | if (freq.available()) { 28 | int frequency = round(this->freq.countToNanoseconds(this->freq.read()) / 1000); 29 | this->ticks = frequency % 1024; 30 | this->radians = (((float)this->ticks) / 1024.0) * M_PI * 2; 31 | } 32 | //copy the data to the data struct 33 | rev_sensor_data.id = id_; 34 | rev_sensor_data.ticks = ticks; 35 | rev_sensor_data.radians = radians; 36 | return true; 37 | 38 | } 39 | 40 | float RevEncoder::get_angle_ticks() { 41 | return this->ticks; 42 | } 43 | 44 | float RevEncoder::get_angle_radians() { 45 | return (this->radians-starting_value); 46 | } 47 | 48 | void RevEncoder::print() { 49 | Serial.println("Rev Encoder:"); 50 | Serial.print("\tTicks: "); 51 | Serial.println(ticks); 52 | Serial.print("\tRadians: "); 53 | Serial.println(radians); 54 | } -------------------------------------------------------------------------------- /src/utils/bitwise_operations.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef BITWISE_OPERATIONS_H 4 | #define BITWISE_OPERATIONS_H 5 | 6 | uint16_t combine_bytes(uint8_t high, uint8_t low) { 7 | uint16_t result = 0; 8 | return ((result | high) << 8) | low; 9 | } 10 | 11 | #endif // BITWISE_OPERATIONS_H -------------------------------------------------------------------------------- /src/utils/timing.cpp: -------------------------------------------------------------------------------- 1 | #include "timing.hpp" -------------------------------------------------------------------------------- /src/utils/vector_math.cpp: -------------------------------------------------------------------------------- 1 | #include "vector_math.hpp" -------------------------------------------------------------------------------- /src/utils/vector_math.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef VECTOR_MATH_H 4 | #define VECTOR_MATH_H 5 | 6 | void rotate2D(float* v, float* v_tf, float angle) { 7 | v_tf[0] = (v[0] * cos(angle)) - (v[1] * sin(angle)); 8 | v_tf[1] = (v[0] * sin(angle)) + (v[1] * cos(angle)); 9 | } 10 | 11 | float vectorProduct(float* a, float* b, int n) { 12 | int product = 0; 13 | for (int i = 0; i < n; i++) { 14 | product += a[i] * b[i]; 15 | } 16 | return product; 17 | } 18 | 19 | float crossProduct2D(float* a, float* b) { 20 | return (a[0] * b[1]) - (a[1] * b[0]); 21 | } 22 | 23 | void weightedVectorAddition(float* a, float* b, float k1, float k2, int n, float* output) { 24 | for (int i = 0; i < n; i++) { 25 | output[i] = (k1 * a[i]) + (k2 * b[i]); 26 | } 27 | } 28 | 29 | void nWeightedVectorAddition(float* a, float* b, float* k1, float* k2, int n, float* output) { 30 | for (int i = 0; i < n; i++) { 31 | output[i] = (k1[i] * a[i]) + (k2[i] * b[i]); 32 | } 33 | } 34 | 35 | #endif // VECTOR_MATH_H -------------------------------------------------------------------------------- /src/utils/wrapping.cpp: -------------------------------------------------------------------------------- 1 | #include "wrapping.hpp" -------------------------------------------------------------------------------- /src/utils/wrapping.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef WRAPPING_H 4 | #define WRAPPING_H 5 | 6 | float wrapAngle(float angle) { 7 | while (angle >= M_PI) angle -= 2 * M_PI; 8 | while (angle <= -M_PI) angle += 2 * M_PI; 9 | return angle; 10 | } 11 | 12 | #endif // WRAPPING_H -------------------------------------------------------------------------------- /teensy4/Arduino.h: -------------------------------------------------------------------------------- 1 | // This header file is in the public domain. 2 | 3 | #ifndef Arduino_h 4 | #define Arduino_h 5 | 6 | #include "WProgram.h" 7 | #include "pins_arduino.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /teensy4/Blink.cc: -------------------------------------------------------------------------------- 1 | // Only for testing with the Makefile - not actually part of the core library 2 | 3 | #include 4 | 5 | int led = 13; 6 | 7 | void setup() { 8 | pinMode(led, OUTPUT); 9 | } 10 | 11 | void loop() { 12 | digitalWrite(led, HIGH); 13 | delay(1000); 14 | digitalWrite(led, LOW); 15 | delay(1000); 16 | } 17 | -------------------------------------------------------------------------------- /teensy4/Client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client.h - Base class that provides Client 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 | #if ARDUINO >= 100 21 | 22 | #ifndef client_h 23 | #define client_h 24 | #include "Print.h" 25 | #include "Stream.h" 26 | #include "IPAddress.h" 27 | 28 | class Client : public Stream { 29 | 30 | public: 31 | virtual int connect(IPAddress ip, uint16_t port) =0; 32 | virtual int connect(const char *host, uint16_t port) =0; 33 | virtual size_t write(uint8_t) =0; 34 | virtual size_t write(const uint8_t *buf, size_t size) =0; 35 | virtual int available() = 0; 36 | virtual int read() = 0; 37 | virtual int read(uint8_t *buf, size_t size) = 0; 38 | virtual int peek() = 0; 39 | virtual void flush() = 0; 40 | virtual void stop() = 0; 41 | virtual uint8_t connected() = 0; 42 | virtual operator bool() = 0; 43 | protected: 44 | uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; 45 | }; 46 | 47 | #endif 48 | #endif 49 | -------------------------------------------------------------------------------- /teensy4/CrashReport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class CrashReportClass: public Printable { 7 | public: 8 | virtual size_t printTo(Print& p) const; 9 | static void clear(); 10 | operator bool(); 11 | static void breadcrumb(unsigned int num, unsigned int value) { 12 | // crashreport_breadcrumbs_struct occupies exactly 1 cache row 13 | volatile struct crashreport_breadcrumbs_struct *bc = 14 | (struct crashreport_breadcrumbs_struct *)0x2027FFC0; 15 | if (num >= 1 && num <= 6) { 16 | num--; 17 | bc->value[num] = value; 18 | bc->bitmask |= (1 << num); 19 | bc->checksum = checksum(bc, 28); 20 | arm_dcache_flush((void *)bc, sizeof(struct crashreport_breadcrumbs_struct)); 21 | } 22 | } 23 | static uint32_t checksum(volatile const void *data, int len) { 24 | volatile const uint16_t *p = (volatile const uint16_t *)data; 25 | uint32_t a=1, b=0; // Adler Fletcher kinda, len < 720 bytes 26 | while (len > 0) { 27 | a += *p++; 28 | b += a; 29 | len -= 2; 30 | } 31 | a = a & 65535; 32 | b = b & 65535; 33 | return a | (b << 16); 34 | } 35 | }; 36 | 37 | extern CrashReportClass CrashReport; 38 | -------------------------------------------------------------------------------- /teensy4/Keyboard.h: -------------------------------------------------------------------------------- 1 | // empty Keyboard.h file, for compability with Arduino's Keyboard examples 2 | 3 | // This header file is in the public domain. 4 | -------------------------------------------------------------------------------- /teensy4/MIDIUSB.h: -------------------------------------------------------------------------------- 1 | #ifndef MIDIUSB_h 2 | #define MIDIUSB_h 3 | 4 | // For compatibility with Arduino's MIDIUSB library 5 | 6 | #include "usb_midi.h" 7 | 8 | #ifdef __cplusplus 9 | #if !defined(USB_MIDI) && !defined(USB_MIDI4) && !defined(USB_MIDI16) && !defined(USB_MIDI_SERIAL) && !defined(USB_MIDI4_SERIAL) && !defined(USB_MIDI16_SERIAL) && !defined(USB_MIDI_AUDIO_SERIAL) && !defined(USB_MIDI16_AUDIO_SERIAL) && !defined(USB_EVERYTHING) 10 | #error "Please select MIDI in Tools > USB Type to use MIDIUSB.h" 11 | #endif 12 | 13 | typedef struct { 14 | union { 15 | struct { 16 | uint8_t header; 17 | uint8_t byte1; 18 | uint8_t byte2; 19 | uint8_t byte3; 20 | }; 21 | uint32_t word; 22 | }; 23 | } midiEventPacket_t; 24 | 25 | 26 | class MIDI_ 27 | { 28 | public: 29 | constexpr MIDI_(void) { } 30 | uint32_t available(void) { 31 | return usb_midi_available(); 32 | } 33 | midiEventPacket_t read(void) { 34 | midiEventPacket_t event; 35 | event.word = usb_midi_read_message(); 36 | return event; 37 | } 38 | void flush(void) { 39 | usb_midi_flush_output(); 40 | } 41 | void sendMIDI(midiEventPacket_t event) { 42 | usb_midi_write_packed(event.word); 43 | } 44 | size_t write(const uint8_t *buffer, size_t size) { 45 | // TODO - is this really needed? 46 | return 0; 47 | } 48 | operator bool() { 49 | // TODO - is this really needed? 50 | return true; 51 | } 52 | }; 53 | extern MIDI_ MidiUSB; 54 | 55 | #endif // __cplusplus 56 | #endif // MIDIUSB_h 57 | -------------------------------------------------------------------------------- /teensy4/Mouse.h: -------------------------------------------------------------------------------- 1 | // empty Mouse.h file, for compability with Arduino's Mouse examples 2 | 3 | // This header file is in the public domain. 4 | -------------------------------------------------------------------------------- /teensy4/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 | #ifdef __cplusplus 24 | 25 | #include 26 | 27 | class Print; 28 | 29 | /** The Printable class provides a way for new classes to allow themselves to be printed. 30 | By deriving from Printable and implementing the printTo method, it will then be possible 31 | for users to print out instances of this class by passing them into the usual 32 | Print::print and Print::println methods. 33 | */ 34 | class Printable 35 | { 36 | public: 37 | virtual size_t printTo(Print& p) const = 0; 38 | }; 39 | 40 | 41 | #endif 42 | #endif 43 | -------------------------------------------------------------------------------- /teensy4/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Base class that provides Server 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 | #if ARDUINO >= 100 21 | 22 | #ifndef server_h 23 | #define server_h 24 | 25 | #include "Print.h" 26 | 27 | class Server : public Print { 28 | public: 29 | virtual void begin() =0; 30 | }; 31 | 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /teensy4/avr/eeprom.h: -------------------------------------------------------------------------------- 1 | /* Simple compatibility headers for AVR code used with ARM chips 2 | * Copyright (c) 2015 Paul Stoffregen 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 | */ 22 | 23 | // Guidelines for editing this file: 24 | // https://forum.pjrc.com/threads/34537-Teensy-LC-Increase-EEPROM-Size/page2 25 | 26 | #ifndef _AVR_EEPROM_H_ 27 | #define _AVR_EEPROM_H_ 1 28 | 29 | #include 30 | #include 31 | 32 | #include "avr_functions.h" 33 | 34 | #if defined(ARDUINO_TEENSY40) 35 | #define E2END 0x437 36 | #elif defined(ARDUINO_TEENSY41) 37 | #define E2END 0x10BB 38 | #elif defined(ARDUINO_TEENSY_MICROMOD) 39 | #define E2END 0x10BB 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /teensy4/avr/interrupt.h: -------------------------------------------------------------------------------- 1 | // This header file is in the public domain. 2 | -------------------------------------------------------------------------------- /teensy4/avr/io.h: -------------------------------------------------------------------------------- 1 | /* Simple compatibility headers for AVR code used with ARM chips 2 | * Copyright (c) 2015 Paul Stoffregen 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 | */ 22 | 23 | #include "../avr_emulation.h" 24 | -------------------------------------------------------------------------------- /teensy4/avr/power.h: -------------------------------------------------------------------------------- 1 | /* Simple compatibility headers for AVR code used with ARM chips 2 | * Copyright (c) 2015 Paul Stoffregen 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 | */ 22 | 23 | #ifndef _AVR_POWER_H_ 24 | #define _AVR_POWER_H_ 1 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /teensy4/avr/wdt.h: -------------------------------------------------------------------------------- 1 | // This header file is in the public domain. 2 | 3 | #ifndef _AVR_WDT_H_ 4 | #define _AVR_WDT_H_ 5 | 6 | #define WDTO_15MS 0 7 | #define WDTO_30MS 1 8 | #define WDTO_60MS 2 9 | #define WDTO_120MS 3 10 | #define WDTO_250MS 4 11 | #define WDTO_500MS 5 12 | #define WDTO_1S 6 13 | #define WDTO_2S 7 14 | #define WDTO_4S 8 15 | #define WDTO_8S 9 16 | 17 | #define wdt_reset() 18 | #define wdt_enable(timeout) 19 | #define wdt_disable() 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /teensy4/core_id.h: -------------------------------------------------------------------------------- 1 | // This header file is in the public domain. 2 | 3 | #ifndef CORE_TEENSY 4 | #define CORE_TEENSY 5 | #endif 6 | -------------------------------------------------------------------------------- /teensy4/debug/printf.h: -------------------------------------------------------------------------------- 1 | // uncommenting the line below will enable the debug printf statements in cores\teensy4 2 | // by default it will print to the Serial4 TX pin at baud rate of 115200 3 | //#define PRINT_DEBUG_STUFF 4 | 5 | // uncommenting the line below will switch to doing outputs to USB Serial or SEREMU instead of Serial4 6 | // However some of the earlier print statements that happen before USB is initialized will be lost 7 | // if you need those outputs, better to use Serial 4. 8 | //#define PRINT_DEBUG_USING_USB // if both defined will try to direct stuff out USB Serial or SEREMU 9 | 10 | #ifdef PRINT_DEBUG_STUFF 11 | // defining printf this way breaks things like Serial.printf() in C++ :( 12 | #define printf(...) printf_debug(__VA_ARGS__) 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | void printf_debug_init(void); 17 | void printf_debug(const char *format, ...); 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #else 23 | #define printf_init() 24 | #define printf(...) 25 | #define printf_debug_init() 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /teensy4/extmem.c: -------------------------------------------------------------------------------- 1 | // External memory allocation functions. Attempt to use external memory, 2 | // but automatically fall back to internal RAM if external RAM can't be used. 3 | 4 | #include 5 | #include "smalloc.h" 6 | #include "wiring.h" 7 | 8 | #if defined(ARDUINO_TEENSY41) 9 | // Teensy 4.1 external RAM address range is 0x70000000 to 0x7FFFFFFF 10 | #define HAS_EXTRAM 11 | #define IS_EXTMEM(addr) (((uint32_t)(addr) >> 28) == 7) 12 | #endif 13 | 14 | 15 | void *extmem_malloc(size_t size) 16 | { 17 | #ifdef HAS_EXTRAM 18 | void *ptr = sm_malloc_pool(&extmem_smalloc_pool, size); 19 | if (ptr) return ptr; 20 | #endif 21 | return malloc(size); 22 | } 23 | 24 | void extmem_free(void *ptr) 25 | { 26 | #ifdef HAS_EXTRAM 27 | if (IS_EXTMEM(ptr)) { 28 | sm_free_pool(&extmem_smalloc_pool, ptr); 29 | return; 30 | } 31 | #endif 32 | free(ptr); 33 | } 34 | 35 | void *extmem_calloc(size_t nmemb, size_t size) 36 | { 37 | #ifdef HAS_EXTRAM 38 | // Note: It is assumed that the pool was created with do_zero set to true 39 | void *ptr = sm_malloc_pool(&extmem_smalloc_pool, nmemb*size); 40 | if (ptr) return ptr; 41 | #endif 42 | return calloc(nmemb, size); 43 | } 44 | 45 | void *extmem_realloc(void *ptr, size_t size) 46 | { 47 | #ifdef HAS_EXTRAM 48 | if (IS_EXTMEM(ptr)) { 49 | return sm_realloc_pool(&extmem_smalloc_pool, ptr, size); 50 | } 51 | #endif 52 | return realloc(ptr, size); 53 | } 54 | -------------------------------------------------------------------------------- /teensy4/fuse.c: -------------------------------------------------------------------------------- 1 | #include "core_pins.h" 2 | #include "imxrt.h" 3 | 4 | uint32_t IMXRTfuseRead(volatile uint32_t *fuses) 5 | { 6 | if (((uint32_t)fuses & 0x0F) != 0) return 0; // illegal address 7 | uint32_t addr = ((uint32_t)fuses - (uint32_t)&HW_OCOTP_LOCK) >> 4; 8 | if (addr > 0x2F) return 0; // illegal address 9 | if (HW_OCOTP_CTRL & HW_OCOTP_CTRL_ERROR) { 10 | HW_OCOTP_CTRL_CLR = HW_OCOTP_CTRL_ERROR; 11 | } 12 | HW_OCOTP_CTRL = HW_OCOTP_CTRL_ADDR(addr); 13 | HW_OCOTP_READ_CTRL = HW_OCOTP_READ_CTRL_READ_FUSE; 14 | while (HW_OCOTP_CTRL & HW_OCOTP_CTRL_BUSY) ; // wait 15 | return HW_OCOTP_READ_FUSE_DATA; 16 | } 17 | 18 | void IMXRTfuseWrite(volatile uint32_t *fuses, uint32_t value) 19 | { 20 | if (((uint32_t)fuses & 0x0F) != 0) return; // illegal address 21 | uint32_t oldvalue = IMXRTfuseRead(fuses); 22 | if ((oldvalue | value) == oldvalue) return; // no write needed 23 | uint32_t addr = ((uint32_t)fuses - (uint32_t)&HW_OCOTP_LOCK) >> 4; 24 | if (addr > 0x2F) return; // illegal address 25 | if (HW_OCOTP_CTRL & HW_OCOTP_CTRL_ERROR) { 26 | HW_OCOTP_CTRL_CLR = HW_OCOTP_CTRL_ERROR; 27 | } 28 | // TODO: abort writing to certain fuses known to brick Lockable Teensy 29 | HW_OCOTP_CTRL = HW_OCOTP_CTRL_WR_UNLOCK(0x3E77) | HW_OCOTP_CTRL_ADDR(addr); 30 | HW_OCOTP_DATA = value; 31 | while (HW_OCOTP_CTRL & HW_OCOTP_CTRL_BUSY) ; // wait 32 | delayMicroseconds(2); 33 | if (HW_OCOTP_CTRL & HW_OCOTP_CTRL_ERROR) return; 34 | *fuses = IMXRTfuseRead(fuses); // update shadow register 35 | } 36 | 37 | void IMXRTfuseReload() 38 | { 39 | if (HW_OCOTP_CTRL & HW_OCOTP_CTRL_ERROR) { 40 | HW_OCOTP_CTRL_CLR = HW_OCOTP_CTRL_ERROR; 41 | } 42 | HW_OCOTP_CTRL = HW_OCOTP_CTRL_RELOAD_SHADOWS; 43 | while (HW_OCOTP_CTRL & (HW_OCOTP_CTRL_BUSY | HW_OCOTP_CTRL_RELOAD_SHADOWS)) ; 44 | } 45 | -------------------------------------------------------------------------------- /teensy4/libc.c: -------------------------------------------------------------------------------- 1 | // this file no longer used 2 | -------------------------------------------------------------------------------- /teensy4/new.cpp: -------------------------------------------------------------------------------- 1 | /* Teensyduino Core Library 2 | * http://www.pjrc.com/teensy/ 3 | * Copyright (c) 2018 PJRC.COM, LLC. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * 1. The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #include 27 | 28 | void * operator new(size_t size) 29 | { 30 | return malloc(size); 31 | } 32 | 33 | void * operator new[](size_t size) 34 | { 35 | return malloc(size); 36 | } 37 | 38 | void operator delete(void * ptr) 39 | { 40 | free(ptr); 41 | } 42 | 43 | void operator delete[](void * ptr) 44 | { 45 | free(ptr); 46 | } 47 | 48 | void operator delete(void * ptr, size_t size __attribute__((unused))) 49 | { 50 | free(ptr); 51 | } 52 | 53 | void operator delete[](void * ptr, size_t size __attribute__((unused))) 54 | { 55 | free(ptr); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /teensy4/pgmspace.h: -------------------------------------------------------------------------------- 1 | // For compatibility with some ESP8266 programs 2 | #include 3 | -------------------------------------------------------------------------------- /teensy4/serialEvent.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEvent1.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEvent2.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEvent3.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEvent4.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEvent5.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEvent6.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEvent7.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEvent8.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEventUSB1.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/serialEventUSB2.cpp: -------------------------------------------------------------------------------- 1 | // nothing to see here 2 | -------------------------------------------------------------------------------- /teensy4/sm_alloc_valid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | int sm_alloc_valid_pool(struct smalloc_pool *spool, const void *p) 10 | { 11 | struct smalloc_hdr *shdr; 12 | 13 | if (!smalloc_verify_pool(spool)) { 14 | errno = EINVAL; 15 | return 0; 16 | } 17 | 18 | if (!p) return 0; 19 | 20 | shdr = USER_TO_HEADER(p); 21 | if (smalloc_is_alloc(spool, shdr)) return 1; 22 | return 0; 23 | } 24 | 25 | int sm_alloc_valid(const void *p) 26 | { 27 | return sm_alloc_valid_pool(&smalloc_curr_pool, p); 28 | } 29 | -------------------------------------------------------------------------------- /teensy4/sm_calloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | void *sm_calloc_pool(struct smalloc_pool *spool, size_t x, size_t y) 10 | { 11 | return sm_zalloc_pool(spool, x * y); 12 | } 13 | 14 | void *sm_calloc(size_t x, size_t y) 15 | { 16 | return sm_calloc_pool(&smalloc_curr_pool, x, y); 17 | } 18 | -------------------------------------------------------------------------------- /teensy4/sm_free.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | void sm_free_pool(struct smalloc_pool *spool, void *p) 10 | { 11 | struct smalloc_hdr *shdr; 12 | char *s; 13 | 14 | if (!smalloc_verify_pool(spool)) { 15 | errno = EINVAL; 16 | return; 17 | } 18 | 19 | if (!p) return; 20 | 21 | shdr = USER_TO_HEADER(p); 22 | if (smalloc_is_alloc(spool, shdr)) { 23 | if (spool->do_zero) memset(p, 0, shdr->rsz); 24 | s = CHAR_PTR(p); 25 | s += shdr->usz; 26 | memset(s, 0, HEADER_SZ); 27 | if (spool->do_zero) memset(s+HEADER_SZ, 0, shdr->rsz - shdr->usz); 28 | memset(shdr, 0, HEADER_SZ); 29 | return; 30 | } 31 | 32 | smalloc_UB(spool, p); 33 | return; 34 | } 35 | 36 | void sm_free(void *p) 37 | { 38 | sm_free_pool(&smalloc_curr_pool, p); 39 | } 40 | -------------------------------------------------------------------------------- /teensy4/sm_hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | /* An adopted Jenkins one-at-a-time hash */ 10 | #define UIHOP(x, s) do { \ 11 | hash += (x >> s) & 0xff;\ 12 | hash += hash << 10; \ 13 | hash ^= hash >> 6; \ 14 | } while (0) 15 | uintptr_t smalloc_uinthash(uintptr_t x) 16 | { 17 | uintptr_t hash = 0; 18 | 19 | UIHOP(x, 0); 20 | UIHOP(x, 8); 21 | UIHOP(x, 16); 22 | UIHOP(x, 24); 23 | 24 | hash += hash << 3; 25 | hash ^= hash >> 11; 26 | hash += hash << 15; 27 | 28 | return hash; 29 | } 30 | #undef UIHOP 31 | 32 | uintptr_t smalloc_mktag(struct smalloc_hdr *shdr) 33 | { 34 | uintptr_t r = smalloc_uinthash(PTR_UINT(shdr)); 35 | r += shdr->rsz; 36 | r = smalloc_uinthash(r); 37 | r += shdr->usz; 38 | r = smalloc_uinthash(r); 39 | return r; 40 | } 41 | -------------------------------------------------------------------------------- /teensy4/sm_malloc_stats.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | int sm_malloc_stats_pool(struct smalloc_pool *spool, size_t *total, size_t *user, size_t *free, int *nr_blocks) 10 | { 11 | struct smalloc_hdr *shdr, *basehdr; 12 | int r = 0; 13 | 14 | if (!smalloc_verify_pool(spool)) { 15 | errno = EINVAL; 16 | return -1; 17 | } 18 | 19 | if (!total && !user && !free && !nr_blocks) return 0; 20 | 21 | if (total) *total = 0; 22 | if (user) *user = 0; 23 | if (free) *free = 0; 24 | if (nr_blocks) *nr_blocks = 0; 25 | 26 | shdr = basehdr = spool->pool; 27 | while (CHAR_PTR(shdr)-CHAR_PTR(basehdr) < spool->pool_size) { 28 | if (smalloc_is_alloc(spool, shdr)) { 29 | if (total) *total += HEADER_SZ + shdr->rsz + HEADER_SZ; 30 | if (user) *user += shdr->usz; 31 | if (nr_blocks) *nr_blocks += 1; 32 | r = 1; 33 | } 34 | 35 | shdr++; 36 | } 37 | 38 | *free = spool->pool_size - *total; 39 | 40 | return r; 41 | } 42 | 43 | int sm_malloc_stats(size_t *total, size_t *user, size_t *free, int *nr_blocks) 44 | { 45 | return sm_malloc_stats_pool(&smalloc_curr_pool, total, user, free, nr_blocks); 46 | } 47 | -------------------------------------------------------------------------------- /teensy4/sm_realloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | void *sm_realloc_pool(struct smalloc_pool *spool, void *p, size_t n) 10 | { 11 | return sm_realloc_pool_i(spool, p, n, 0); 12 | } 13 | 14 | void *sm_realloc(void *p, size_t n) 15 | { 16 | return sm_realloc_pool_i(&smalloc_curr_pool, p, n, 0); 17 | } 18 | -------------------------------------------------------------------------------- /teensy4/sm_realloc_move.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | void *sm_realloc_move_pool(struct smalloc_pool *spool, void *p, size_t n) 10 | { 11 | return sm_realloc_pool_i(spool, p, n, 1); 12 | } 13 | 14 | void *sm_realloc_move(void *p, size_t n) 15 | { 16 | return sm_realloc_pool_i(&smalloc_curr_pool, p, n, 1); 17 | } 18 | -------------------------------------------------------------------------------- /teensy4/sm_szalloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | size_t sm_szalloc_pool(struct smalloc_pool *spool, const void *p) 10 | { 11 | struct smalloc_hdr *shdr; 12 | 13 | if (!smalloc_verify_pool(spool)) { 14 | errno = EINVAL; 15 | return ((size_t)-1); 16 | } 17 | 18 | if (!p) return 0; 19 | 20 | shdr = USER_TO_HEADER(p); 21 | if (smalloc_is_alloc(spool, shdr)) return shdr->usz; 22 | smalloc_UB(spool, p); 23 | return 0; 24 | } 25 | 26 | size_t sm_szalloc(const void *p) 27 | { 28 | return sm_szalloc_pool(&smalloc_curr_pool, p); 29 | } 30 | -------------------------------------------------------------------------------- /teensy4/sm_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | static int smalloc_check_bounds(struct smalloc_pool *spool, struct smalloc_hdr *shdr) 10 | { 11 | if (!spool) return 0; 12 | if (CHAR_PTR(shdr) >= CHAR_PTR(spool->pool) 13 | && CHAR_PTR(shdr) <= (CHAR_PTR(spool->pool)+spool->pool_size)) 14 | return 1; 15 | return 0; 16 | } 17 | 18 | static int smalloc_valid_tag(struct smalloc_hdr *shdr) 19 | { 20 | char *s; 21 | uintptr_t r = smalloc_mktag(shdr); 22 | size_t x; 23 | 24 | if (shdr->tag == r) { 25 | s = CHAR_PTR(HEADER_TO_USER(shdr)); 26 | s += shdr->usz; 27 | for (x = 0; x < sizeof(struct smalloc_hdr); x += sizeof(uintptr_t)) { 28 | r = smalloc_uinthash(r); 29 | if (memcmp(s+x, &r, sizeof(uintptr_t)) != 0) return 0; 30 | } 31 | s += x; x = 0; 32 | while (x < shdr->rsz - shdr->usz) { 33 | if (s[x] != '\xFF') return 0; 34 | x++; 35 | } 36 | return 1; 37 | } 38 | return 0; 39 | } 40 | 41 | static void smalloc_do_crash(struct smalloc_pool *spool __attribute__((unused)), const void *p __attribute__((unused))) 42 | { 43 | char *c = NULL; 44 | *c = 'X'; 45 | } 46 | 47 | smalloc_ub_handler smalloc_UB = smalloc_do_crash; 48 | 49 | void sm_set_ub_handler(smalloc_ub_handler handler) 50 | { 51 | if (!handler) smalloc_UB = smalloc_do_crash; 52 | else smalloc_UB = handler; 53 | } 54 | 55 | int smalloc_is_alloc(struct smalloc_pool *spool, struct smalloc_hdr *shdr) 56 | { 57 | if (!smalloc_check_bounds(spool, shdr)) return 0; 58 | if (shdr->rsz == 0) return 0; 59 | if (shdr->rsz > SIZE_MAX) return 0; 60 | if (shdr->usz > SIZE_MAX) return 0; 61 | if (shdr->usz > shdr->rsz) return 0; 62 | if (shdr->rsz % HEADER_SZ) return 0; 63 | if (!smalloc_valid_tag(shdr)) return 0; 64 | return 1; 65 | } 66 | -------------------------------------------------------------------------------- /teensy4/sm_zalloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #include "smalloc_i.h" 8 | 9 | void *sm_zalloc_pool(struct smalloc_pool *spool, size_t n) 10 | { 11 | void *r = sm_malloc_pool(spool, n); 12 | if (r) memset(r, 0, n); 13 | return r; 14 | } 15 | 16 | void *sm_zalloc(size_t n) 17 | { 18 | return sm_zalloc_pool(&smalloc_curr_pool, n); 19 | } 20 | -------------------------------------------------------------------------------- /teensy4/smalloc_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of SMalloc. 3 | * SMalloc is MIT licensed. 4 | * Copyright (c) 2017 Andrey Rys. 5 | */ 6 | 7 | #ifndef _SMALLOC_I_H 8 | #define _SMALLOC_I_H 9 | 10 | #include "smalloc.h" 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | struct smalloc_hdr { 20 | size_t rsz; /* real allocated size with overhead (if any) */ 21 | size_t usz; /* exact user size as reported by s_szalloc */ 22 | uintptr_t tag; /* sum of all the above, hashed value */ 23 | }; 24 | 25 | #define HEADER_SZ (sizeof(struct smalloc_hdr)) 26 | #define MIN_POOL_SZ (HEADER_SZ*20) 27 | 28 | #define VOID_PTR(p) ((void *)p) 29 | #define CHAR_PTR(p) ((char *)p) 30 | #define PTR_UINT(p) ((uintptr_t)VOID_PTR(p)) 31 | #define HEADER_PTR(p) ((struct smalloc_hdr *)p) 32 | #define USER_TO_HEADER(p) (HEADER_PTR((CHAR_PTR(p)-HEADER_SZ))) 33 | #define HEADER_TO_USER(p) (VOID_PTR((CHAR_PTR(p)+HEADER_SZ))) 34 | 35 | extern smalloc_ub_handler smalloc_UB; 36 | 37 | uintptr_t smalloc_uinthash(uintptr_t x); 38 | uintptr_t smalloc_mktag(struct smalloc_hdr *shdr); 39 | int smalloc_verify_pool(struct smalloc_pool *spool); 40 | int smalloc_is_alloc(struct smalloc_pool *spool, struct smalloc_hdr *shdr); 41 | 42 | void *sm_realloc_pool_i(struct smalloc_pool *spool, void *p, size_t n, int nomove); 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /teensy4/usb_dev.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "imxrt.h" 3 | 4 | #if !defined(USB_DISABLED) 5 | 6 | typedef struct transfer_struct transfer_t; 7 | struct transfer_struct { 8 | uint32_t next; 9 | volatile uint32_t status; 10 | uint32_t pointer0; 11 | uint32_t pointer1; 12 | uint32_t pointer2; 13 | uint32_t pointer3; 14 | uint32_t pointer4; 15 | uint32_t callback_param; 16 | }; 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | void usb_init(void); 23 | void usb_init_serialnumber(void); 24 | 25 | void usb_config_rx(uint32_t ep, uint32_t packet_size, int do_zlp, void (*cb)(transfer_t *)); 26 | void usb_config_tx(uint32_t ep, uint32_t packet_size, int do_zlp, void (*cb)(transfer_t *)); 27 | void usb_config_rx_iso(uint32_t ep, uint32_t packet_size, int mult, void (*cb)(transfer_t *)); 28 | void usb_config_tx_iso(uint32_t ep, uint32_t packet_size, int mult, void (*cb)(transfer_t *)); 29 | 30 | void usb_prepare_transfer(transfer_t *transfer, const void *data, uint32_t len, uint32_t param); 31 | void usb_transmit(int endpoint_number, transfer_t *transfer); 32 | void usb_receive(int endpoint_number, transfer_t *transfer); 33 | uint32_t usb_transfer_status(const transfer_t *transfer); 34 | 35 | void usb_start_sof_interrupts(int interface); 36 | void usb_stop_sof_interrupts(int interface); 37 | 38 | extern void (*usb_timer0_callback)(void); 39 | extern void (*usb_timer1_callback)(void); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #else // !defined(USB_DISABLED) 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | void usb_init(void); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | 58 | #endif // !defined(USB_DISABLED) 59 | -------------------------------------------------------------------------------- /teensy4/util/delay.h: -------------------------------------------------------------------------------- 1 | /* Teensyduino Core Library 2 | * http://www.pjrc.com/teensy/ 3 | * Copyright (c) 2016 PJRC.COM, LLC. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * 1. The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * 2. If the Software is incorporated into a build system that allows 17 | * selection among a list of target devices, then similar target 18 | * devices manufactured by PJRC.COM must be included in the list of 19 | * target devices and selectable in the same manner. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 25 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 26 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 27 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | * SOFTWARE. 29 | */ 30 | 31 | #ifndef _delay_us 32 | #define _delay_us(n) delayMicroseconds(n) 33 | #endif 34 | 35 | #ifndef _delay_ms 36 | #define _delay_ms(n) delay(n) 37 | #endif 38 | -------------------------------------------------------------------------------- /teensy4/util/parity.h: -------------------------------------------------------------------------------- 1 | /* Teensyduino Core Library 2 | * http://www.pjrc.com/teensy/ 3 | * Copyright (c) 2016 PJRC.COM, LLC. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * 1. The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * 2. If the Software is incorporated into a build system that allows 17 | * selection among a list of target devices, then similar target 18 | * devices manufactured by PJRC.COM must be included in the list of 19 | * target devices and selectable in the same manner. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 25 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 26 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 27 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | * SOFTWARE. 29 | */ 30 | 31 | #ifndef _UTIL_PARITY_H_ 32 | #define _UTIL_PARITY_H_ 33 | 34 | static inline uint8_t parity_even_bit(uint8_t x) __attribute__((pure, always_inline, unused)); 35 | static inline uint8_t parity_even_bit(uint8_t x) 36 | { 37 | x ^= x >> 1; 38 | x ^= x >> 2; 39 | x ^= x >> 4; 40 | return x & 1; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /teensy4/wiring_private.h: -------------------------------------------------------------------------------- 1 | // empty header file, here for libraries which try to include it (eg, Adafruit_GFX) 2 | -------------------------------------------------------------------------------- /tools/get_tty_path.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get the device file for the Teensy Serial interface 4 | # tycmd list -Ojson -v : List all devices in JSON format with verbose output, this includes the device file 5 | # grep -e "\-Teensy\"" : Filter out only the Teensy devices, this excludes devices like Teensy@1 6 | # grep -o "Serial\", \"[^]]*" : Extract the serial device path section from the JSON output 7 | # grep -o '/[^"]*' : Extract the device file path from the serial device path section 8 | teensy_serial_path=$(tycmd list -Ojson -v | grep -e "\-Teensy\"" | grep -o "Serial\", \"[^]]*" | grep -o '/[^"]*') 9 | 10 | # Check if the device file exists 11 | if [ -e "$teensy_serial_path" ]; then 12 | echo "$teensy_serial_path" 13 | exit 0 14 | fi 15 | 16 | # If the device file does not exist, print an error message and exit with an error code (redirected to stderr) 17 | echo "Teensy device file not found" 1>&2 18 | 19 | exit 1 -------------------------------------------------------------------------------- /tools/install_arduino.sh: -------------------------------------------------------------------------------- 1 | # verify that curl is installed 2 | sudo apt update 3 | sudo apt install -y curl 4 | 5 | # download arduino-cli's install script 6 | curl -o arduino-install-thing.sh https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh 7 | # make this executable 8 | chmod +x arduino-install-thing.sh 9 | # run the install script and place it in /usr/local/bin (env var) 10 | sudo BINDIR=/usr/local/bin/ ./arduino-install-thing.sh 11 | # clean up install script 12 | rm arduino-install-thing.sh 13 | 14 | # install the needed board/tools for Teensy 15 | arduino-cli core install teensy:avr@1.59.0 --additional-urls "https://www.pjrc.com/teensy/package_teensy_index.json" 16 | 17 | # install the compiler if we're running on arm (aarch64) 18 | ./tools/install_compiler.sh 19 | -------------------------------------------------------------------------------- /tools/install_compiler.sh: -------------------------------------------------------------------------------- 1 | # download links for gcc-arm-none-eabi-14.2.rel1 2 | x86_64_Linux="https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-eabi.tar.xz" 3 | AArch64_Linux="https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-aarch64-arm-none-eabi.tar.xz" 4 | x86_64_MacOS="https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz" 5 | Arm64_MacOS="https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-darwin-arm64-arm-none-eabi.tar.xz" 6 | 7 | # where to store the compiler 8 | OUTPUT=./tools/compiler 9 | 10 | TAR_NAME=./arm-gnu-toolchain-14.2.rel1.tar.xz 11 | 12 | # remove the old compiler 13 | rm -rf $OUTPUT 14 | 15 | # create a directory to store the compiler 16 | mkdir -p $OUTPUT 17 | 18 | # install the correct compiler based on the OS and architecture 19 | if [[ "$(uname -s)" == "Linux" ]]; then 20 | if [[ $(uname -m) == "x86_64" ]]; then 21 | wget $x86_64_Linux -O $TAR_NAME 22 | elif [[ $(uname -m) == "aarch64" ]]; then 23 | wget $AArch64_Linux -O $TAR_NAME 24 | fi 25 | elif [[ "$(uname -s)" == "Darwin" ]]; then 26 | if [[ $(uname -m) == "x86_64" ]]; then 27 | wget $x86_64_MacOS -O $TAR_NAME 28 | elif [[ $(uname -m) == "arm64" ]]; then 29 | wget $Arm64_MacOS -O $TAR_NAME 30 | fi 31 | fi 32 | 33 | # extract the compiler 34 | echo "Extracting the compiler..." 35 | tar -xf $TAR_NAME -C $OUTPUT 36 | mv $OUTPUT/arm-gnu-toolchain* $OUTPUT/arm-gnu-toolchain 37 | 38 | # remove the downloaded tar files 39 | echo "Cleaning up..." 40 | rm -f $TAR_NAME 41 | -------------------------------------------------------------------------------- /tools/install_tytools.sh: -------------------------------------------------------------------------------- 1 | # install dependencies (curl) 2 | sudo apt install curl 3 | 4 | # makes the keyrings directory with correct permission 5 | sudo mkdir -p -m0755 /etc/apt/keyrings 6 | 7 | # downloads the key for the repo for apt to install from 8 | sudo curl https://download.koromix.dev/debian/koromix-archive-keyring.gpg -o /etc/apt/keyrings/koromix-archive-keyring.gpg 9 | 10 | # adds the repo to the apt list 11 | echo "deb [signed-by=/etc/apt/keyrings/koromix-archive-keyring.gpg] https://download.koromix.dev/debian stable main" | sudo tee /etc/apt/sources.list.d/koromix.dev-stable.list 12 | 13 | # updates apt 14 | sudo apt update 15 | 16 | # install tytools 17 | sudo apt install -y tytools 18 | -------------------------------------------------------------------------------- /tools/monitor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # verify that the backup monitor is compiled 4 | gcc ./tools/monitor.c -Wall -Wextra -Wpedantic -Werror -Wshadow -o ./tools/custom_monitor 5 | 6 | # handle sigint in a strange way to not break tycmd monitor 7 | trap 'exit 0' INT; 8 | 9 | # The correct serial device has the following name 10 | # usb-Teensyduino_USB_Custom_*-if00 11 | # where * is a number 12 | # The important part is the "if00" at the end, its interface number 00 13 | 14 | tty_path=$(./tools/get_tty_path.sh) 15 | 16 | # If the tty path is not empty, we can start the monitor 17 | if [ -n "$tty_path" ]; then 18 | echo "Monitoring Teensy on $tty_path" 19 | 20 | # Start the monitor, if it fails, try the backup monitor 21 | # If both monitors fail, the teensy is likely in an invalid state and not listening to the serial port. Click the button and reflash to fix. 22 | ./tools/custom_monitor $tty_path || tycmd monitor --reconnect --board="-Teensy@$tty_path" || echo "Failed to monitor." 23 | 24 | exit 0 25 | else 26 | # failed to find the correct serial device 27 | echo "Failed to monitor." 28 | 29 | exit 1 30 | fi -------------------------------------------------------------------------------- /tools/prepare_gdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This finds the correct ttyACM device and puts it into gdb_commands.txt 4 | 5 | # The correct serial device has the following name 6 | # usb-Teensyduino_USB_Custom_*-if02 7 | # Where * is a number unique to that serial device, we dont care about that though 8 | # The important part is the "if02" at the end, its interface number 02 9 | # SerialUSB1 is what interface 02 references 10 | 11 | tty_path=$(./tools/get_tty_path.sh *-if02) 12 | 13 | # Now we put it into gdb_commands.txt 14 | if [ -n "$tty_path" ]; then 15 | echo "target remote $tty_path" > ./tools/gdb_commands.txt 16 | 17 | exit 0 18 | else 19 | echo "Failed to prepare gdb" 20 | 21 | exit 1 22 | fi -------------------------------------------------------------------------------- /tools/waggle-interceptor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "waggle-interceptor" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | serde = { version = "1.0", features = ["derive"] } 8 | serde_json = "1.0" 9 | rand = "0.8" 10 | reqwest = { version = "0.11", features = ["json"] } 11 | tokio = { version = "1", features = ["full"] } 12 | image = "0.25.5" 13 | base64 = "0.22.1" 14 | clearscreen = "4.0.1" 15 | colored = "3.0.0" 16 | -------------------------------------------------------------------------------- /tools/waggle-interceptor/README.md: -------------------------------------------------------------------------------- 1 | # Waggle Interceptor 2 | 3 | This is a tool for allowing you to send information from teensy to the waggle dashboard. 4 | 5 | ## Installation 6 | 7 | - Install [Waggle](https://github.com/CU-Robotics/waggle) somewhere on your machine 8 | 9 | - Install [Rust](https://www.rust-lang.org/tools/install) 10 | ```sh 11 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 12 | ``` 13 | 14 | - MAC ONLY: 15 | - Install [Homebrew](https://brew.sh) if you haven't already 16 | ```sh 17 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 18 | 19 | - Install unbuffer 20 | ```sh 21 | brew install expect 22 | ``` 23 | 24 | - LINUX ONLY: 25 | 26 | - Install unbuffer 27 | ```sh 28 | sudo apt install expect 29 | ``` 30 | 31 | ## Usage 32 | 33 | - Run waggle with `./waggle` 34 | 35 | - Anywhere you want to add a datapoint to the dashboard, print on a newline with the format `waggle graph GRAPH_NAME GRAPH_VALUE`. For instance, if I wanted to graph that `torque_fr` is currently 3.14, I would print `waggle graph torque_fr 3.14` 36 | 37 | - Instead of running make upload, run `./tools/waggle-interceptor/make-upload.sh` **Run this in your standard terminal, not the VS Code built-in terminal, unless you want to have no memory remaining on your machine** 38 | 39 | That's it :) 40 | -------------------------------------------------------------------------------- /tools/waggle-interceptor/make-upload.sh: -------------------------------------------------------------------------------- 1 | RED='\033[0;31m' 2 | NC='\033[0m' # No Color 3 | 4 | if command -v rustc &> /dev/null 5 | then 6 | echo "Rust is installed" 7 | else 8 | 9 | echo -e "${RED}It looks like rust is not installed, attempting automatic installation (see https://www.rust-lang.org/tools/install)${NC}" 10 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 11 | echo "Rust is not installed" 12 | fi 13 | 14 | echo "Compiling the project. This may take a while the first time..." 15 | cargo build --manifest-path tools/waggle-interceptor/Cargo.toml --release 16 | ./tools/waggle-interceptor/target/release/waggle-interceptor make upload 17 | --------------------------------------------------------------------------------