├── CHANGES.txt ├── LICENSE ├── README.md ├── README_ch.md ├── boards.txt ├── cores └── w806 │ ├── Arduino.c │ ├── Arduino.h │ ├── Binary.h │ ├── Common.h │ ├── GPIO_defs.h │ ├── HardwareSerial.cpp │ ├── HardwareSerial.h │ ├── HardwareSerial.md │ ├── Print.cpp │ ├── Print.h │ ├── Printable.h │ ├── Stream.cpp │ ├── Stream.h │ ├── WMath.cpp │ ├── WString.cpp │ ├── WString.h │ ├── W_DMA.c │ ├── W_DMA.h │ ├── W_IRQ_Priority.h │ ├── W_PWM.c │ ├── W_PWM.h │ ├── W_interrupt.cpp │ ├── W_interrupt.h │ ├── core_w600_noniso.c │ ├── debug.h │ ├── include │ ├── arch │ │ └── XT804 │ │ │ ├── csi_config.h │ │ │ ├── csi_core │ │ │ ├── core_804.h │ │ │ ├── csi_core.h │ │ │ └── csi_gcc.h │ │ │ └── csi_dsp │ │ │ ├── csky_common_tables.h │ │ │ ├── csky_const_structs.h │ │ │ ├── csky_math.h │ │ │ ├── csky_vdsp2_const_structs.h │ │ │ └── csky_vdsp2_math.h │ ├── driver │ │ ├── wm_adc.h │ │ ├── wm_cpu.h │ │ ├── wm_dma.h │ │ ├── wm_gpio.h │ │ ├── wm_gpio_ex.h │ │ ├── wm_hal.h │ │ ├── wm_i2c.h │ │ ├── wm_i2s.h │ │ ├── wm_internal_flash.h │ │ ├── wm_pmu.h │ │ ├── wm_psram.h │ │ ├── wm_pwm.h │ │ ├── wm_rcc.h │ │ ├── wm_sdio.h │ │ ├── wm_spi.h │ │ ├── wm_spi_flash.h │ │ ├── wm_tim.h │ │ ├── wm_touch.h │ │ ├── wm_uart.h │ │ └── wm_wdg.h │ ├── wm_regs.h │ └── wm_type_def.h │ ├── inttypes.h │ ├── ld │ └── gcc_csky.ld │ ├── lib │ ├── arch │ │ └── XT804 │ │ │ ├── bsp │ │ │ ├── Makefile │ │ │ ├── __rt_entry.S │ │ │ ├── board_init.c │ │ │ ├── startup.S │ │ │ ├── system.c │ │ │ ├── trap_c.c │ │ │ └── vectors.S │ │ │ └── libc │ │ │ ├── Makefile │ │ │ └── libc_port.c │ ├── drivers │ │ ├── wm_adc.c │ │ ├── wm_cpu.c │ │ ├── wm_dma.c │ │ ├── wm_gpio.c │ │ ├── wm_hal.c │ │ ├── wm_i2c.c │ │ ├── wm_i2s.c │ │ ├── wm_internal_flash.c │ │ ├── wm_pmu.c │ │ ├── wm_psram.c │ │ ├── wm_pwm.c │ │ ├── wm_sdio.c │ │ ├── wm_spi.c │ │ ├── wm_spi_flash.c │ │ ├── wm_tim.c │ │ ├── wm_touch.c │ │ ├── wm_uart.c │ │ └── wm_wdg.c │ └── libdsp.a │ ├── main.cpp │ ├── pgmspace.cpp │ ├── pgmspace.h │ ├── stdlib_noniso.h │ ├── wiring_private.h │ ├── wm_fifo.c │ ├── wm_fifo.h │ ├── wm_it.c │ └── wm_it.h ├── doc ├── Air101_pinout.JPG ├── Air103_Board_V1.2.pdf ├── Air103_MCU_V1.2.pdf ├── Air103_pinout.png ├── PWM.md ├── SPI.md ├── W801-KIT-V1.0-schematic.pdf ├── W801_pinout.png ├── W806-KIT-V1.0-schematic.png ├── W806_datasheet.pdf ├── W806_pinout.png ├── W_DMA.md ├── arduino_preferences.png ├── board_chioce.png ├── board_manager.png ├── board_manager_zh.png ├── board_select.png ├── option_zh.png └── rect7811.png ├── libraries ├── BasicsExamples │ ├── BasicsExamples.h │ ├── examples │ │ ├── Adc │ │ │ └── Adc.ino │ │ ├── Blink │ │ │ └── Blink.ino │ │ ├── Gpio_interrupt │ │ │ └── Gpio_interrupt.ino │ │ ├── PSRAM_test │ │ │ └── PSRAM_test.ino │ │ ├── Pwm │ │ │ └── Pwm.ino │ │ ├── Servo │ │ │ └── Servo.ino │ │ └── randomNumber │ │ │ └── randomNumber.ino │ ├── keywords.txt │ └── library.properties ├── EEPROM │ ├── EEPROM.h │ ├── Readme.md │ └── examples │ │ └── EEPROM │ │ └── EEPROM.ino ├── GyverOLED-w80x │ ├── Image converter │ │ ├── BITmaper-outdated.zip │ │ └── ImageProcessor │ │ │ └── download.txt │ ├── LICENSE │ ├── README.md │ ├── README_EN.md │ ├── examples │ │ ├── 3Dcube │ │ │ └── 3Dcube.ino │ │ ├── animations │ │ │ └── animations.ino │ │ ├── bitmap_demo │ │ │ └── bitmap_demo.ino │ │ ├── bitmap_move_fast │ │ │ └── bitmap_move_fast.ino │ │ ├── bitmap_move_fast_nobuf │ │ │ └── bitmap_move_fast_nobuf.ino │ │ ├── drawBattery │ │ │ └── drawBattery.ino │ │ ├── drawIcons │ │ │ └── drawIcons.ino │ │ ├── menuButton │ │ │ └── menuButton.ino │ │ ├── oledPrintTest │ │ │ └── oledPrintTest.ino │ │ ├── oledPrintTest_w80x │ │ │ └── oledPrintTest_w80x.ino │ │ └── oled_demo │ │ │ └── oled_demo.ino │ ├── icons │ │ ├── icons7x7.png │ │ ├── icons8x8.png │ │ ├── iconsVisualiser │ │ │ └── iconsVisualiser.pde │ │ └── readme.txt │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── GyverOLED.h │ │ ├── charMap.h │ │ ├── icons_7x7.h │ │ └── icons_8x8.h ├── HAL_Examples │ ├── examples │ │ ├── hal_gpio_led_interrupt │ │ │ └── hal_gpio_led_interrupt.ino │ │ ├── hal_i2c_rw_eeprom │ │ │ └── hal_i2c_rw_eeprom.ino │ │ ├── hal_internal_flash │ │ │ └── hal_internal_flash.ino │ │ ├── hal_led │ │ │ └── hal_led.ino │ │ ├── hal_pwm_led │ │ │ └── hal_pwm_led.ino │ │ ├── hal_spi_ST7735 │ │ │ └── hal_spi_ST7735.ino │ │ └── hal_tim_irq │ │ │ └── hal_tim_irq.ino │ └── hal_examples.h ├── HardwareTimer │ ├── HardwareTimer.cpp │ ├── HardwareTimer.h │ ├── Readme.md │ └── examples │ │ └── Tim_Led_Irq │ │ └── Tim_Led_Irq.ino ├── I2S │ ├── I2S.h │ ├── Readme.md │ ├── examples │ │ └── Wav_SD_Player │ │ │ └── Wav_SD_Player.ino │ └── wav_files │ │ ├── music.wav │ │ └── one_tone.wav ├── ILI9341_Fast_SDIO_SPI │ ├── LICENSE │ ├── README.md │ ├── README.txt │ ├── examples │ │ ├── SDIO_TFT_Test │ │ │ └── SDIO_TFT_Test.ino │ │ └── Test_ili9341_sdio_spi │ │ │ └── Test_ili9341_sdio_spi.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── ILI9341_Fast.cpp │ │ ├── ILI9341_Fast.h │ │ ├── driver.h │ │ └── lcd.h ├── LiquidCrystal │ ├── README.adoc │ ├── examples │ │ ├── Autoscroll │ │ │ └── Autoscroll.ino │ │ ├── Blink │ │ │ └── Blink.ino │ │ ├── Cursor │ │ │ └── Cursor.ino │ │ ├── CustomCharacter │ │ │ └── CustomCharacter.ino │ │ ├── Display │ │ │ └── Display.ino │ │ ├── HelloWorld │ │ │ └── HelloWorld.ino │ │ ├── Scroll │ │ │ └── Scroll.ino │ │ ├── SerialDisplay │ │ │ └── SerialDisplay.ino │ │ ├── TextDirection │ │ │ └── TextDirection.ino │ │ └── setCursor │ │ │ └── setCursor.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── LiquidCrystal.cpp │ │ └── LiquidCrystal.h ├── SD │ ├── .travis.yml │ ├── README.adoc │ ├── examples │ │ ├── CardInfo │ │ │ └── CardInfo.ino │ │ ├── CardInfo_w80x │ │ │ └── CardInfo_w80x.ino │ │ ├── Datalogger │ │ │ └── Datalogger.ino │ │ ├── DumpFile │ │ │ └── DumpFile.ino │ │ ├── Files │ │ │ └── Files.ino │ │ ├── NonBlockingWrite │ │ │ └── NonBlockingWrite.ino │ │ ├── ReadWrite │ │ │ └── ReadWrite.ino │ │ └── listfiles │ │ │ └── listfiles.ino │ ├── extras │ │ └── codespell-ignore-words-list.txt │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── File.cpp │ │ ├── README.txt │ │ ├── SD.cpp │ │ ├── SD.h │ │ └── utility │ │ ├── FatStructs.h │ │ ├── Sd2Card.cpp │ │ ├── Sd2Card.h │ │ ├── Sd2PinMap.h │ │ ├── SdFat.h │ │ ├── SdFatUtil.h │ │ ├── SdFatmainpage.h │ │ ├── SdFile.cpp │ │ ├── SdInfo.h │ │ └── SdVolume.cpp ├── SPI │ ├── DigitalPotControl │ │ └── DigitalPotControl.ino │ ├── SPI.cpp │ ├── SPI.h │ ├── ST7735_HardSPI │ │ └── ST7735_HardSPI.ino │ ├── Spi_tx_dma │ │ └── Spi_tx_dma.ino │ └── keywords.txt ├── Wire │ ├── HardwareI2C.cpp │ ├── HardwareI2C.h │ ├── LCD2004_PCF8547 │ │ ├── LCD2004_PCF8547.h │ │ └── LCD2004_PCF8547.ino │ ├── MPU_QMC_Test │ │ ├── MPU_QMC_Test.ino │ │ └── YMFC-32_document_1.pdf │ ├── SoftwareI2C.cpp │ ├── SoftwareI2C.h │ ├── TinyRTC_RW_eeprom │ │ └── TinyRTC_RW_eeprom.ino │ ├── Wire.cpp │ ├── Wire.h │ ├── Wire_base.cpp │ ├── Wire_base.h │ └── i2c_scanner │ │ └── i2c_scanner.ino ├── keywords.txt └── w80x_test_lvgl │ ├── ILI9341_Fast_SDIO.h │ ├── driver.h │ └── w80x_test_lvgl.ino ├── package_w80x_index.json ├── package_w80x_isme_proxy_index.json ├── package_w80x_test_index.json ├── platform.txt └── variants ├── air101 ├── pins_arduino.h └── variant.h ├── air103 ├── pins_arduino.h └── variant.h ├── w800 ├── pins_arduino.h └── variant.h ├── w801 ├── pins_arduino.h └── variant.h ├── w802 ├── pins_arduino.h └── variant.h └── w806 ├── pins_arduino.h └── variant.h /CHANGES.txt: -------------------------------------------------------------------------------- 1 | 0.0.6 January, 29 2024 2 | Add W800, W802 and Air_101 boards 3 | Add SDIO as DMA request source to W_DMA library 4 | Add SPI_TX_DMA example 5 | Some minor fixes 6 | 7 | 0.0.5b August, 15 2023 8 | Error fix and update to 0.0.5a 9 | Add Ili9341_Fast_SPI SDIO-SPI example 10 | Add basic LVGL example 11 | Add definitions of PRId32 & PRIu32 types, required for LVGL 12 | Some minor fixes 13 | 14 | 0.0.5a August, 14 2023 15 | Fix bug with multiple definitions of pinMap table (pull request #23) 16 | Add I2S & DMA using Wav_SD_Player example 17 | Add LiquidCrystal library 18 | Fix bug in attachInterrupt parameters order (issie #22) 19 | Enforce SPI and Wire compatibility, many other compatibility changes 20 | 21 | 0.0.4 July, 10 2023 22 | !! Incompatible change !! 23 | - rename boards 24 | Other changes: 25 | - add advanced PWM features (see doc/PWM.md file) 26 | - fix analogWrite() to output no signal with duty = 0 27 | - change the pgmspace.h to get rid strict assignment warnings 28 | - add __cxa_pure_virtual function to main.cpp to prevent linker bug 29 | - change optimization options menu 30 | - some other bug fixes -------------------------------------------------------------------------------- /README_ch.md: -------------------------------------------------------------------------------- 1 | # w80x_duino 2 | w806为[联盛德](http://www.winnermicro.com/)公司推出一款基于平头哥(XT-E804)架构的MCU 3 | 4 | **W806芯片参数** 5 | 6 | - 封装QFN56, 6mm x 6mm, pin间距0.35mm 7 | 8 | **MCU 特性** 9 | 10 | - 集成 32 位 XT804 处理器,工作频率 240MHz,内置 DSP、浮点运算单元与安全引擎 11 | - 内置 1MB Flash,288KB RAM 12 | - 集成 PSRAM 接口,支持最高 64MB 外置 PSRAM 存储器 13 | - 集成 6 路 UART 高速接口 14 | - 集成 4 路 16 比特 ADC,最高采样率 1KHz 15 | - 集成 1 个高速 SPI 接口(从接口),支持最高 50MHz 16 | - 集成一个主/从 SPI 接口 17 | - 集成 1 个 SDIO_HOST 接口,支持 SDIO2.0、SDHC、MMC4.2 18 | - 集成 1 个 SDIO_DEVICE,支持 SDIO2.0,最高吞吐率 200Mbps 19 | - 集成 1 个 I2C 控制器 20 | - 集成 GPIO 控制器,最多支持 44 个 GPIO 21 | - 集成 5 路 PWM 接口 22 | - 集成 1 路 Duplex I2S 控制器 23 | - 集成 LCD 控制器,支持 4x32 接口 24 | - 集成 1 个 7816 接口 25 | - 集成 15 个 Touch Sensor 26 | 27 | **供电** 28 | 29 | - 3.3V 单电源供电 30 | - 支持工作、睡眠、待机、关机工作模式 31 | - 待机功耗小于 10uA 32 | 33 | ## w80x_duino开发板Arduino IDE支持包安装 34 | 35 | 1、**文件->首选项** 36 | 37 | 2、在附加开发板管理器网址输入如下网址: 38 | 39 | > https://cdn.jsdelivr.net/gh/Hi-LinkDuino/w80x_arduino/package_w80x_proxy_index.json 40 | > 41 | > **如果这个不行请使用这个链接地址** 42 | 43 | > https://cdn.jsdelivr.net/gh/Hi-LinkDuino/w80x_arduino/package_w80x_index.json 44 | 45 | ![](./doc/option_zh.png) 46 | 47 | 3、**工具->开发板->开发板管理** 48 | 搜索**w80x_duino**,选择最新版本安装(如果搜索不到,请安装arduino IDE1.8.15以上) 49 | 50 | ![board_manage_zh](./doc/board_manager_zh.png) 51 | 52 | 4、**工具->开发板** 53 | ![](./doc/board_chioce.png) 54 | 55 | 代表w80x_duino开发环境搭建完成 56 | 57 | 5、**上传** 58 | 上传的过程忠按提示按主板上的复位键即可下载 59 | 60 | ## w80x_duino开发计划 61 | 打勾的代表已经实现并验证,没有打勾的代表正在开发中,期待更多开发者一起维护 62 | 63 | - [x] [支持arduino ide开发基于w806的官方SDK API调用开发](https://github.com/Hi-LinkDuino/w80x_arduino/tree/v0.0.1) 64 | - [x] [GPIO适配](https://github.com/Hi-LinkDuino/w80x_arduino/commit/53fb7892e041c1e37913b0c73fd1abaf5970a111) 65 | - [ ] [Serial适配]() 66 | - [x] [ADC适配](https://github.com/Hi-LinkDuino/w80x_arduino/pull/10) 67 | - [x] [PWM适配](https://github.com/Hi-LinkDuino/w80x_arduino/commit/8de553ff1431182d11d7fec1267ff2efeb1d84c9) 68 | - [ ] [timer适配]() 69 | - [ ] [I2C适配]() 70 | - [ ] [SPI适配]() 71 | - [ ] [flash模拟eerom操作适配]() 72 | 73 | ### 说明 74 | 由于此芯片为平头哥新架构,工具链和各种工具几乎是全新的,所有arduino标准接口都得全部适配。工作量还是挺大。 75 | 大家使用有问题,直接提[issue](https://github.com/Hi-LinkDuino/w80x_arduino/issues) 76 | 欢迎开发者协同开发提交commit,本项目会持续更新。 77 | 78 | ## 致谢 79 | - Hi-Link海凌科开发生产了此开发板 80 | - 此开源项目由[nulllab空想实验室](https://github.com/nulllaborg)团队维护,并得到联盛德官方捐赠 81 | -------------------------------------------------------------------------------- /cores/w806/GPIO_defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __GPIO_DEFS_H__ 2 | #define __GPIO_DEFS_H__ 3 | 4 | // Атрибуты выводов 5 | 6 | // Pin masks 7 | #define PIN_DIO_Pos (0) 8 | #define PIN_DIO_Msk (1 << PIN_DIO_Pos) 9 | 10 | #define PIN_PWM_Pos (1) 11 | #define PIN_PWM_Msk ( 0b111 << PIN_PWM_Pos ) 12 | 13 | #define PIN_ADC_Pos (4) 14 | #define PIN_ADC_Msk ( 0b111 << PIN_ADC_Pos ) 15 | 16 | #define PIN_SPI_Pos (7) 17 | #define PIN_SPI_Msk ( 0b111 << PIN_SPI_Pos ) 18 | 19 | 20 | #define NONE (0) // Вывод не используется 21 | #define DIO (1 << PIN_DIO_Pos) // Цифровой ввод/вывод 22 | 23 | #define PWM0 ((0+1) << PIN_PWM_Pos) // Каналы ШИМ 24 | #define PWM1 ((1+1) << PIN_PWM_Pos) 25 | #define PWM2 ((2+1) << PIN_PWM_Pos) 26 | #define PWM3 ((3+1) << PIN_PWM_Pos) 27 | #define PWM4 ((4+1) << PIN_PWM_Pos) 28 | 29 | #define ADC1 ((1) << PIN_ADC_Pos) // Каналы АЦП 30 | #define ADC2 ((2) << PIN_ADC_Pos) 31 | #define ADC3 ((3) << PIN_ADC_Pos) 32 | #define ADC4 ((4) << PIN_ADC_Pos) 33 | 34 | #define _SPI_MOSI ((1) << PIN_SPI_Pos) // SPI 35 | #define _SPI_MISO ((2) << PIN_SPI_Pos) 36 | #define _SPI_SCK ((3) << PIN_SPI_Pos) 37 | #define _SPI_SS ((4) << PIN_SPI_Pos) 38 | 39 | 40 | // Константная таблица/массив возможных альтернатив 41 | // Порт,Вывод порта,Пин платы,Альтернативы 42 | 43 | typedef struct { 44 | GPIO_TypeDef * pPort ; // Указатель на порт 45 | uint32_t halPin ; // Вывод определен в HAL 46 | uint32_t ulPin ; // Вывод на плате 47 | uint32_t ulPinAttribute ; // Аттрибуты вывода (альтернативы) 48 | } PIN_MAP ; 49 | 50 | 51 | 52 | #endif -------------------------------------------------------------------------------- /cores/w806/HardwareSerial.md: -------------------------------------------------------------------------------- 1 | ## **HardwareSerial Library for W80x boards** 2 | 3 | **Written by:** _Dmitry E. Dmitriev_ . 4 | 5 | ### **What is the HardwareSerial library.** 6 | 7 | The HardwareSerial library provides an easy to use interface to interact with the UART channels of WM MCUs. 8 | 9 | Winner Micro devices and clones such as W806, W801, Air103... etc has as much as six high-speed hardware UARTs. The one, UART0, is connected to the board's USB-UART bridge (CH340/341) chip, and the others five are available to the user. 10 | 11 | ### **UART pins table** 12 | 13 | | **UART** | **Default pins** (TX, RX) | **Alternative pins** | 14 | |:---------|:----------------:|:--------------:| 15 | | UART0 | **PB19**, **PB20** | - | 16 | | UART1 | **PB6**, **PB7** | - | 17 | | UART2 | **PB2**, **PB3** | PA2, PA3 | 18 | | UART3 | **PB0**, **PB1** | PA5, PA6 | 19 | | UART4 | **PB4**, **PB5** | PA8, PA9 | 20 | | UART5 | **PA12**, **PA13** | PB18,PB17 | 21 | 22 | ### **How to use it** 23 | To add its functionality to your sketch you'll need to initialize HardwareSerial object with number of used MCU UART (1..5). The UART0 `Serial` instance is defined by system and shouldn't be defined by user. 24 | 25 | ```Arduino 26 | HardwareSerial mySerial(2); // initialize Serial object on UART2 27 | 28 | void setup(){ 29 | mySerial.begin(9600, SERIAL_8N1); 30 | } 31 | 32 | void loop(){ 33 | 34 | } 35 | 36 | ``` 37 | 38 | For uarts 2-5 you can change the default TX RX pins to the alternative option by calling the HardwareSerial constructor with number of UART and keyword `REMAP_TX_RX` as second parameter: 39 | 40 | ##### **`HardwareSerial Serial5(5, REMAP_TX_RX);`** 41 | 42 | 43 | ### **Configure** 44 | 45 | Before using the uart, it must be configured. Using begin() method you can set port baudrate, number of stopbits and mode of parity control: 46 | 47 | #### **`Serial.begin(baudrate)`** 48 | #### **`Serial.begin(baudrate, options)`** 49 | 50 | The first parameter `baudrate` can be varied from 600 to 2000000 baud. For UART control options you can use defines below: 51 | 52 | - **SERIAL_8N1** - 8 bits, 1 stopbit, parity none 53 | - **SERIAL_8N2** - 8 bits, 2 stopbits, parity none 54 | - **SERIAL_8E1** - 8 bits, 1 stopbit, parity even 55 | - **SERIAL_8E2** - 8 bits, 2 stopbits, parity even 56 | - **SERIAL_8O1** - 8 bits, 1 stopbit, parity odd 57 | - **SERIAL_8O2** - 8 bits, 2 stopbits, parity odd 58 | 59 | If `options` parameter is omitted, default `SERIAL_8N1` will be used. 60 | 61 | This function doesn't have a return value. 62 | 63 | ### **Library functions** 64 | 65 | Most HardwareSerial methods such as `print()`, `println()`, `write()`, `peek()`, `available()` and `read()` are similar to the ones of the Arduino standard Serial class. For more info please consult the Arduino manual. The only one that have been added to the current library is 66 | 67 | #### **`Serial.printf(const char *fmt,...)`** 68 | 69 | The function sends formatted output to the serial port. It uses standard C++ `printf` style format to control the output. Please consult C++ `printf` manual for detail. 70 | 71 | If successful, the function returns the total number of characters printed. On failure, a negative number is returned. -------------------------------------------------------------------------------- /cores/w806/Printable.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Printable.h 3 | * 4 | * @brief IPAddress Module 5 | * 6 | * @author Huangleilei 7 | * 8 | * Copyright (c) 2019 Winner Microelectronics Co., Ltd. 9 | */ 10 | #ifndef Printable_h 11 | #define Printable_h 12 | 13 | #include 14 | 15 | class Print; 16 | 17 | class Printable 18 | { 19 | public: 20 | /** 21 | * @brief This pure virtual function is used to called by print/println function. 22 | * @param[in] p Specify the Print object. 23 | * 24 | * @return bool 25 | * 26 | * @note The length of print successfully. 27 | */ 28 | virtual size_t printTo(Print &p) const = 0; 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /cores/w806/WMath.cpp: -------------------------------------------------------------------------------- 1 | /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2 | 3 | /* 4 | Part of the Wiring project - http://wiring.org.co 5 | Copyright (c) 2004-06 Hernando Barragan 6 | Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/ 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General 19 | Public License along with this library; if not, write to the 20 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 21 | Boston, MA 02111-1307 USA 22 | */ 23 | 24 | extern "C" { 25 | #include "stdlib.h" 26 | #include "stdint.h" 27 | } 28 | 29 | void randomSeed(uint32_t seed) 30 | { 31 | if (seed != 0) { 32 | srand(seed); 33 | } 34 | } 35 | 36 | int32_t random(int32_t howbig) 37 | { 38 | if (howbig == 0) { 39 | return 0; 40 | } 41 | return rand() % howbig; 42 | } 43 | 44 | int32_t random(int32_t howsmall, int32_t howbig) 45 | { 46 | return ((howsmall) + (int32_t) ((howbig) - (howsmall)) * rand() / 32768); 47 | 48 | } 49 | 50 | int32_t map(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max) 51 | { 52 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 53 | } 54 | 55 | uint16_t makeWord(uint16_t w) { return w; } 56 | uint16_t makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; } 57 | -------------------------------------------------------------------------------- /cores/w806/W_DMA.h: -------------------------------------------------------------------------------- 1 | #ifndef __W_DMA_H__ 2 | #define __W_DMA_H__ 3 | /** 4 | * @file W_DMA.h 5 | * 6 | * @brief Minimal implementation of W80x DMA support 7 | * 8 | * @author Dmitry E. Dmitriev 9 | * 10 | * Copyright (c) 2023 11 | */ 12 | #include "./include/driver/wm_hal.h" 13 | 14 | #define DMA_REQUEST_SOURCE_SDIO_RX 0xFF01UL 15 | #define DMA_REQUEST_SOURCE_SDIO_TX 0xFF02UL 16 | 17 | extern DMA_HandleTypeDef hdma_channel[8]; 18 | 19 | 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | /** 25 | * @brief Get number of next unused DMA channel. 26 | * The W80x controllers has an eight equivalent 27 | * DMA channels. Every channel can be used for 28 | * every type of DMA transfers. 29 | * 30 | * 31 | * @return DMA channel num, 0-7 in success or (-1) if no free 32 | * channels available. 33 | * 34 | * @note 35 | */ 36 | int8_t claim_unused_dma_channel(); 37 | 38 | /** 39 | * @brief Configure DMA channel to use of some common 40 | * Memory-to-Periph or Periph-to-Memory DMA modes. 41 | * The transfer direction are determined by selected mode. 42 | * Use one of these modes: 43 | * DMA_REQUEST_SOURCE_SPI_RX 44 | * DMA_REQUEST_SOURCE_SPI_TX 45 | * DMA_REQUEST_SOURCE_ADC_CH0 46 | * DMA_REQUEST_SOURCE_ADC_CH1 47 | * DMA_REQUEST_SOURCE_ADC_CH2 48 | * DMA_REQUEST_SOURCE_ADC_CH3 49 | * DMA_REQUEST_SOURCE_I2S_RX 50 | * DMA_REQUEST_SOURCE_I2S_TX 51 | * DMA_REQUEST_SOURCE_SDIO_RX 52 | * DMA_REQUEST_SOURCE_SDIO_TX 53 | * 54 | * @param[in] ch dma chammel number, byte 55 | * @param[in] request_src periph and direction mode 56 | * 57 | * @return Pointer to configured DMA handle, DMA_HandleTypeDef* 58 | * 59 | * @note 60 | */ 61 | DMA_HandleTypeDef *dma_simple_config(uint8_t ch, uint32_t request_src); 62 | 63 | /** 64 | * @brief Initialize a DMA channel with prepared configuration. 65 | * 66 | * @param[in] hdma pointer to DMA handle, DMA_HandleTypeDef* 67 | * 68 | * @return HAL_OK or some HAL_ERROR values 69 | * 70 | * @note 71 | */ 72 | uint8_t dma_init(DMA_HandleTypeDef *hdma); 73 | 74 | 75 | /** 76 | * @brief DMA IRQ Handlers 77 | * 78 | * 79 | * @note 80 | */ 81 | void DMA_Channel0_IRQHandler(void); 82 | void DMA_Channel1_IRQHandler(void); 83 | void DMA_Channel2_IRQHandler(void); 84 | void DMA_Channel3_IRQHandler(void); 85 | void DMA_Channel4_7_IRQHandler(void); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif -------------------------------------------------------------------------------- /cores/w806/W_PWM.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef W_PWM_h 3 | #define W_PWM_h 4 | 5 | 6 | #include "Common.h" 7 | #include "variant.h" 8 | 9 | /** pwm interrupt callback type **/ 10 | typedef void (*pwm_irq_callback)(); 11 | // PWM IRQ handler 12 | void HAL_PWM_IRQHandler(void); 13 | 14 | void PWM_Init(PWM_HandleTypeDef* hpwm, uint32_t channel); 15 | uint32_t setPWM_Freq(PWM_HandleTypeDef* hpwm, uint32_t pwmFreq); 16 | uint32_t setPWM_Freq_Period(PWM_HandleTypeDef* hpwm, uint32_t pwmFreq, uint8_t period); 17 | void setPWM_OutInverse(PWM_HandleTypeDef* hpwm, bool pwm_inverse, bool start); 18 | void setPWM_AutoReload(PWM_HandleTypeDef *hpwm, bool pwm_autoreload, bool start); 19 | void setPWM_PulseCounter(PWM_HandleTypeDef *hpwm, uint8_t num_cnt); 20 | void configPWM_Pulses(PWM_HandleTypeDef *hpwm, uint8_t pulse_cnt, pwm_irq_callback callback, bool start); 21 | void disablePWM_Pulses(PWM_HandleTypeDef *hpwm, bool start); 22 | void startPWM(PWM_HandleTypeDef* hpwm); 23 | void stopPWM(PWM_HandleTypeDef* hpwm); 24 | 25 | // depredicated, leave for compatibility 26 | uint32_t setPWMFreq(uint8_t pin, uint32_t pwmFreq); 27 | #endif -------------------------------------------------------------------------------- /cores/w806/W_interrupt.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "W_interrupt.h" 3 | #include "W_IRQ_Priority.h" 4 | uint32_t GPIOA_CallbackFlag =0; 5 | gpio_irq_callback GPIOA_Callback[GPIOA_PINS_CNT] = {0}; 6 | 7 | uint32_t GPIOB_CallbackFlag =0; 8 | gpio_irq_callback GPIOB_Callback[GPIOB_PINS_CNT] = {0}; 9 | 10 | void attachInterrupt(uint16_t pin, gpio_irq_callback callback, uint16_t mode) 11 | { 12 | 13 | if (pin_Map[pin].ulPinAttribute & PIN_DIO_Msk) 14 | { 15 | if (IS_GPIO_IT_MODE(mode)) 16 | { 17 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 18 | GPIO_InitStruct.Pin = pin_Map[pin].halPin; 19 | GPIO_InitStruct.Mode = mode; 20 | if (!is_gpio_clk_en) 21 | { 22 | __HAL_RCC_GPIO_CLK_ENABLE(); 23 | is_gpio_clk_en = true; 24 | } 25 | HAL_GPIO_Init(pin_Map[pin].pPort, &GPIO_InitStruct); 26 | if (pin_Map[pin].pPort == GPIOB) 27 | { 28 | HAL_NVIC_SetPriority(GPIOB_IRQn, GPIOB_IRQn_PRIORITY); // приоритет прерывания 1 29 | HAL_NVIC_EnableIRQ(GPIOB_IRQn); 30 | GPIOB_CallbackFlag |= pin_Map[pin].halPin; 31 | GPIOB_Callback[pin - PB0] = callback; 32 | } 33 | else 34 | { 35 | HAL_NVIC_SetPriority(GPIOA_IRQn, GPIOA_IRQn_PRIORITY); 36 | HAL_NVIC_EnableIRQ(GPIOA_IRQn); 37 | GPIOA_CallbackFlag |= pin_Map[pin].halPin; 38 | GPIOA_Callback[pin - PA0] = callback; 39 | } 40 | } 41 | } 42 | } 43 | 44 | void detachInterrupt(uint16_t pin) 45 | { 46 | 47 | if (pin_Map[pin].ulPinAttribute & PIN_DIO_Msk) 48 | { 49 | 50 | HAL_GPIO_DeInit(pin_Map[pin].pPort, pin_Map[pin].halPin); 51 | if (pin_Map[pin].pPort == GPIOB) 52 | { 53 | GPIOB_CallbackFlag &= ~(pin_Map[pin].halPin); 54 | GPIOB_Callback[pin - PB0] = NULL; 55 | } 56 | else 57 | { 58 | GPIOA_CallbackFlag &= ~(pin_Map[pin].halPin); 59 | GPIOA_Callback[pin - PA0] = NULL; 60 | } 61 | } 62 | } 63 | 64 | 65 | void HAL_GPIO_EXTI_Callback(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin) 66 | { 67 | //UNUSED(GPIO_Pin); 68 | uint8_t i =0; 69 | if (GPIO_Pin == GPIO_PIN_ALL) return; 70 | if (GPIOx == GPIOA) { 71 | while (i < GPIOA_PINS_CNT) { 72 | if (GPIO_Pin & (1 << i)) { 73 | if (GPIOA_Callback[i] != NULL) (* (GPIOA_Callback[i])) (); 74 | } 75 | i++; 76 | } 77 | } 78 | else { 79 | while (i < GPIOB_PINS_CNT) { 80 | if (GPIO_Pin & (1 << i)) { 81 | if (GPIOB_Callback[i] != NULL) (* (GPIOB_Callback[i])) (); 82 | } 83 | i++; 84 | } 85 | } 86 | 87 | 88 | } -------------------------------------------------------------------------------- /cores/w806/W_interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef _W_INTERRUPT_H 2 | #define _W_INTERRUPT_H 3 | 4 | #include 5 | /** timer interrupt callback type **/ 6 | typedef void (*gpio_irq_callback)(); 7 | 8 | #define IS_GPIO_IT_MODE(MODE) (((MODE) == GPIO_MODE_IT_HIGH_LEVEL ) ||\ 9 | ((MODE) == GPIO_MODE_IT_LOW_LEVEL ) ||\ 10 | ((MODE) == GPIO_MODE_IT_RISING) ||\ 11 | ((MODE) == GPIO_MODE_IT_FALLING) ||\ 12 | ((MODE) == GPIO_MODE_IT_RISING_FALLING) ) 13 | 14 | 15 | #define RISING GPIO_MODE_IT_RISING 16 | #define FALLING GPIO_MODE_IT_FALLING 17 | #define CHANGE GPIO_MODE_IT_RISING_FALLING 18 | #define HIGH_LEVEL GPIO_MODE_IT_HIGH_LEVEL 19 | #define LOW_LEVEL GPIO_MODE_IT_LOW_LEVEL 20 | 21 | #define GPIOA_PINS_CNT 16 22 | #define GPIOB_PINS_CNT 32 23 | 24 | /*extern uint32_t GPIOA_CallbackFlag ; 25 | extern gpio_irq_callback GPIOA_Callback[GPIOA_PINS_CNT]; 26 | 27 | extern uint32_t GPIOB_CallbackFlag; 28 | extern gpio_irq_callback GPIOB_Callback[GPIOB_PINS_CNT];*/ 29 | 30 | void attachInterrupt(uint16_t pin, gpio_irq_callback callback, uint16_t mode); 31 | void detachInterrupt(uint16_t pin); 32 | 33 | void HAL_GPIO_EXTI_Callback(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin); 34 | 35 | #endif -------------------------------------------------------------------------------- /cores/w806/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _Debug_H_ 2 | #define _Debug_H_ 3 | 4 | #include 5 | 6 | #define DBG 0 7 | #if DBG 8 | #define AR_DBG() printf("[%s %s %d]\n", strrchr(__FILE__, '\\') + 1, __func__, __LINE__) 9 | #else 10 | #define AR_DBG() 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /cores/w806/include/arch/XT804/csi_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __CSI_CONFIG_H__ 2 | #define __CSI_CONFIG_H__ 3 | #define CONFIG_CHIP_SL04 1 4 | #define CONFIG_KERNEL_NONE 1 5 | #define CONFIG_HAVE_VIC 1 6 | #define CONFIG_SEPARATE_IRQ_SP 1 7 | #define CONFIG_ARCH_INTERRUPTSTACK 4096 8 | #define CONFIG_IRQ_VECTOR_SIZE 256 9 | #define USE_UART0_PRINT 0 // UART0 printf, 0:OFF, 1:ON 10 | 11 | #if USE_UART0_PRINT 12 | #define USE_UART0_AUTO_DL 0 // Auto download, 0:OFF, 1:ON 13 | #else 14 | 15 | #endif 16 | 17 | #define USE_IRQ_UART_TX 1 // UART transfer using interrupt 18 | 19 | #ifdef CONFIG_KERNEL_NONE 20 | #define CONFIG_SYSTEM_SECURE 1 21 | #endif 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /cores/w806/include/arch/XT804/csi_core/csi_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /****************************************************************************** 18 | * @file csi_core.h 19 | * @brief CSI Core Layer Header File 20 | * @version V1.0 21 | * @date 02. June 2017 22 | ******************************************************************************/ 23 | 24 | #ifndef _CORE_H_ 25 | #define _CORE_H_ 26 | 27 | #include 28 | 29 | #if defined(__CK801__) || defined(__E801__) 30 | #include 31 | #elif defined(__CK802__) || defined(__E802__) || defined(__S802__) 32 | #include 33 | #elif defined(__E803__) || defined(__S803__) 34 | #include 35 | #elif defined(__CK803__) || defined(__CK804__) || defined(__E804__) || defined(__E804D__) || defined(__E804F__) || defined (__E804DF__) 36 | #include 37 | #elif defined(__CK805__) || defined(__I805__) || defined(__I805F__) 38 | #include 39 | #elif defined(__CK610__) 40 | #include 41 | #elif defined(__CK810__) || defined(__C810__) || defined(__C810V__) 42 | #include 43 | #elif defined(__CK807__) || defined(__C807__) || defined(__C807F__) || defined(__C807FV__) 44 | #include 45 | #elif defined(__riscv) 46 | #include 47 | #endif 48 | 49 | #ifdef __riscv 50 | #include 51 | #else 52 | #include "csi_gcc.h" 53 | #endif 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* _CORE_H_ */ 64 | -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_cpu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file wm_cpu.h 3 | * 4 | * @brief cpu driver module 5 | * 6 | * @author dave 7 | * 8 | * @copyright (c) 2014 Winner Microelectronics Co., Ltd. 9 | */ 10 | #ifndef __WM_CPU_H__ 11 | #define __WM_CPU_H__ 12 | 13 | #include "wm_hal.h" 14 | 15 | /**BASE PLL CLOCK*/ 16 | #define W806_PLL_CLK_MHZ (480) 17 | 18 | #define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= (IRQn_Type)0x00U) 19 | 20 | enum CPU_CLK{ 21 | CPU_CLK_240M = 2, 22 | CPU_CLK_160M = 3, 23 | CPU_CLK_80M = 6, 24 | CPU_CLK_40M = 12, 25 | CPU_CLK_2M = 240, 26 | }; 27 | 28 | typedef union { 29 | struct { 30 | uint32_t CPU: 8; /*!< bit: 0.. 7 cpu clock divider */ 31 | uint32_t WLAN: 8; /*!< bit: 8.. 15 Wlan clock divider */ 32 | uint32_t BUS2: 8; /*!< bit: 16.. 23 clock dividing ratio of bus2 & bus1 */ 33 | uint32_t PD: 4; /*!< bit: 24.. 27 peripheral divider */ 34 | uint32_t RSV: 3; /*!< bit: 28.. 30 Reserved */ 35 | uint32_t DIV_EN: 1; /*!< bit: 31 divide frequency enable */ 36 | } b; 37 | uint32_t w; 38 | } clk_div_reg; 39 | 40 | #define UNIT_MHZ (1000000) 41 | 42 | 43 | typedef struct{ 44 | uint32_t apbclk; 45 | uint32_t cpuclk; 46 | uint32_t wlanclk; 47 | }wm_sys_clk; 48 | 49 | typedef enum 50 | { 51 | HAL_TICK_FREQ_10HZ = 10, 52 | HAL_TICK_FREQ_100HZ = 100, 53 | HAL_TICK_FREQ_1KHZ = 1000, 54 | HAL_TICK_FREQ_1MHZ = 1000000, // Системные тики в 1 мкс 55 | HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1MHZ 56 | } HAL_TickFreqTypeDef; 57 | 58 | 59 | #ifdef __cplusplus 60 | extern "C"{ 61 | #endif 62 | void SystemClock_Config(uint32_t clk); 63 | void SystemClock_Get(wm_sys_clk *sysclk); 64 | 65 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority); 66 | void HAL_IncTick(void); 67 | uint32_t HAL_GetTick(void); 68 | void HAL_Delay(uint32_t Delay); 69 | 70 | void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t Priority); 71 | void HAL_NVIC_EnableIRQ(IRQn_Type IRQn); 72 | void HAL_NVIC_DisableIRQ(IRQn_Type IRQn); 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* WM_CPU_H */ 78 | -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_hal.h: -------------------------------------------------------------------------------- 1 | #ifndef __WM_HAL_H__ 2 | #define __WM_HAL_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "../wm_type_def.h" 9 | #include "../wm_regs.h" 10 | #include "wm_cpu.h" 11 | #include "wm_gpio.h" 12 | #include "wm_gpio_ex.h" 13 | #include "wm_uart.h" 14 | #include "wm_rcc.h" 15 | #include "wm_spi.h" 16 | #include "wm_wdg.h" 17 | #include "wm_tim.h" 18 | #include "wm_internal_flash.h" 19 | #include "wm_adc.h" 20 | #include "wm_pwm.h" 21 | #include "wm_pmu.h" 22 | #include "wm_spi_flash.h" 23 | #include "wm_i2c.h" 24 | #include "wm_touch.h" 25 | #include "wm_i2s.h" 26 | #include "wm_dma.h" 27 | #include "wm_sdio.h" 28 | #include "wm_psram.h" 29 | 30 | #define VER "0.6.0" 31 | 32 | #define __HAL_LOCK(__HANDLE__) \ 33 | do{ \ 34 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 35 | { \ 36 | return HAL_BUSY; \ 37 | } \ 38 | else \ 39 | { \ 40 | (__HANDLE__)->Lock = HAL_LOCKED; \ 41 | } \ 42 | }while (0) 43 | 44 | #define __HAL_UNLOCK(__HANDLE__) \ 45 | do{ \ 46 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 47 | }while (0) 48 | 49 | 50 | HAL_StatusTypeDef HAL_Init(void); 51 | HAL_StatusTypeDef HAL_DeInit(void); 52 | void HAL_MspInit(void); 53 | void HAL_MspDeInit(void); 54 | 55 | #ifdef USE_FULL_ASSERT 56 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) 57 | void assert_failed(uint8_t* file, uint32_t line); 58 | #else 59 | #define assert_param(expr) ((void)0U) 60 | #endif 61 | 62 | #endif -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_i2c.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 IOsetting 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef __WM_I2C_H__ 16 | #define __WM_I2C_H__ 17 | 18 | #include "wm_hal.h" 19 | 20 | typedef struct __I2C_HandleTypeDef 21 | { 22 | I2C_TypeDef *Instance; /*!< I2C registers base address */ 23 | uint32_t Frequency; 24 | HAL_LockTypeDef Lock; /*!< Object lock */ 25 | __IO uint32_t ErrorCode; /*!< I2C Error code */ 26 | } I2C_HandleTypeDef; 27 | 28 | #define I2C ((I2C_TypeDef *)I2C_BASE) 29 | 30 | #ifdef __cplusplus 31 | extern "C"{ 32 | #endif 33 | 34 | HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c); 35 | HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c); 36 | void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c); 37 | void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c); 38 | 39 | 40 | HAL_StatusTypeDef HAL_I2C_Write(I2C_HandleTypeDef *hi2c, uint8_t DevAddress, uint8_t MemAddress, uint8_t *pData, uint16_t Size); 41 | HAL_StatusTypeDef HAL_I2C_Read(I2C_HandleTypeDef *hi2c, uint8_t DevAddress, uint8_t MemAddress, uint8_t *pData, uint16_t Size); 42 | 43 | // Низкоуровневые прототипы 44 | void HAL_I2C_Write_Byte(I2C_HandleTypeDef *hi2c, uint8_t dat, uint8_t ifstart); 45 | uint8_t HAL_I2C_Read_Byte(I2C_HandleTypeDef *hi2c, uint8_t ifack, uint8_t ifstop); 46 | int HAL_I2C_Wait_Ack(I2C_HandleTypeDef *hi2c); 47 | void HAL_I2C_Stop(I2C_HandleTypeDef *hi2c); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_pmu.h: -------------------------------------------------------------------------------- 1 | #ifndef __WM_PMU_H__ 2 | #define __WM_PMU_H__ 3 | 4 | #include "wm_hal.h" 5 | 6 | typedef struct 7 | { 8 | uint8_t Year; // range [0, 99] 9 | uint8_t Month; // range [1, 12] 10 | uint8_t Date; // range [1, 31] 11 | uint8_t Hours; // range [0, 23] 12 | uint8_t Minutes; // range [0, 59] 13 | uint8_t Seconds; // range [0, 59] 14 | } RTC_TimeTypeDef; 15 | 16 | typedef struct 17 | { 18 | PMU_TypeDef *Instance; 19 | uint32_t ClkSource; /* This parameter can be a value of @ref PMU_ClkSource_Definitions */ 20 | } PMU_HandleTypeDef; 21 | 22 | #define PMU ((PMU_TypeDef *)PMU_BASE) 23 | 24 | // PMU_ClkSource_Definitions 25 | #define PMU_CLKSOURCE_32RC PMU_CR_32KRC_CAL_EN 26 | #define PMU_CLKSOURCE_32RCBYPASS PMU_CR_32KRCBYPASS 27 | 28 | #define IS_PMU_ALL_INSTANCE(INSTANCE) ((INSTANCE) == PMU) 29 | 30 | #define IS_PMU_TIMPERIOD(__PERIOD__) (((__PERIOD__) >= 0x0000) && ((__PERIOD__) <= 0x0FFFF)) 31 | 32 | #define IS_PMU_CLKSOURCE(SOURCE) (((SOURCE) == PMU_CR_32KRC_CAL_EN) || ((SOURCE) == PMU_CR_32KRCBYPASS)) 33 | #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U) 34 | #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U) 35 | #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U) 36 | #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U) 37 | #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U)) 38 | #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U)) 39 | 40 | 41 | #ifdef __cplusplus 42 | extern "C"{ 43 | #endif 44 | 45 | HAL_StatusTypeDef HAL_PMU_Init(PMU_HandleTypeDef *hpmu); 46 | HAL_StatusTypeDef HAL_PMU_DeInit(PMU_HandleTypeDef *hpmu); 47 | 48 | void HAL_PMU_MspInit(PMU_HandleTypeDef *hpmu); 49 | void HAL_PMU_MspDeInit(PMU_HandleTypeDef *hpmu); 50 | void HAL_PMU_Enter_Sleep(PMU_HandleTypeDef *hpmu); 51 | void HAL_PMU_Enter_Standby(PMU_HandleTypeDef *hpmu); 52 | 53 | /** 54 | * Set and start timer 0 55 | */ 56 | HAL_StatusTypeDef HAL_PMU_TIMER0_Start(PMU_HandleTypeDef *hpmu, uint32_t Period); 57 | HAL_StatusTypeDef HAL_PMU_TIMER0_Stop(PMU_HandleTypeDef *hpmu); 58 | 59 | /** 60 | * Set and start clock 61 | */ 62 | HAL_StatusTypeDef HAL_PMU_RTC_Start(PMU_HandleTypeDef *hpmu, RTC_TimeTypeDef *Time); 63 | HAL_StatusTypeDef HAL_PMU_RTC_Stop(PMU_HandleTypeDef *hpmu); 64 | HAL_StatusTypeDef HAL_PMU_RTC_GetTime(PMU_HandleTypeDef *hpmu, RTC_TimeTypeDef *Time); 65 | HAL_StatusTypeDef HAL_PMU_RTC_Alarm_Enable(PMU_HandleTypeDef *hpmu, RTC_TimeTypeDef *Time); 66 | HAL_StatusTypeDef HAL_PMU_RTC_Alarm_Disable(PMU_HandleTypeDef *hpmu); 67 | 68 | void HAL_PMU_Tim0_Callback(PMU_HandleTypeDef *hpmu); 69 | 70 | void HAL_PMU_IO_Callback(PMU_HandleTypeDef *hpmu); 71 | 72 | void HAL_PMU_RTC_Callback(PMU_HandleTypeDef *hpmu); 73 | 74 | void HAL_PMU_IRQHandler(PMU_HandleTypeDef *hpmu); 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_psram.h: -------------------------------------------------------------------------------- 1 | #ifndef __WM_PSRAM_H__ 2 | #define __WM_PSRAM_H__ 3 | 4 | #include "wm_hal.h" 5 | 6 | #define PSRAM_ADDR_START 0x30000000 7 | 8 | #define PSRAM ((PSRAM_TypeDef *)PSRAM_BASE) 9 | 10 | typedef struct 11 | { 12 | uint32_t Div; 13 | uint32_t Mode; 14 | 15 | } PSRAM_InitTypeDef; 16 | 17 | typedef struct 18 | { 19 | PSRAM_TypeDef *Instance; 20 | PSRAM_InitTypeDef Init; 21 | 22 | } PSRAM_HandleTypeDef; 23 | 24 | #define PSRAM_MODE_SPI (PSRAM_CR_SPI_EN) 25 | #define PSRAM_MODE_QSPI (PSRAM_CR_QUAD_EN) 26 | 27 | #define IS_PSRAM_INSTANCE(INSTANCE) ((INSTANCE) == PSRAM) 28 | #define IS_PSRAM_DIV(DIV) (((DIV) > 2) && ((DIV) <= 0x0F)) 29 | #define IS_PSRAM_MODE(MODE) (((MODE) == PSRAM_MODE_SPI) || ((MODE == PSRAM_MODE_QSPI))) 30 | 31 | #ifdef __cplusplus 32 | extern "C"{ 33 | #endif 34 | 35 | HAL_StatusTypeDef HAL_PSRAM_Init(PSRAM_HandleTypeDef *hpsram); 36 | HAL_StatusTypeDef HAL_PSRAM_DeInit(PSRAM_HandleTypeDef *hpsram); 37 | void HAL_PSRAM_MspInit(PSRAM_HandleTypeDef *hpsram); 38 | void HAL_PSRAM_MspDeInit(PSRAM_HandleTypeDef *hpsram); 39 | // Added pin configurations 40 | void HAL_PSRAM_ConfigPin(uint8_t mode); 41 | // Added dynamic memory allocation 42 | void dram_heap_init(size_t heap_size); 43 | void *dram_heap_malloc(size_t alloc_size); 44 | void dram_heap_free(void *pfree); 45 | size_t dram_heap_free_size(void); 46 | size_t dram_heap_free_size_min(void); 47 | int dram_heap_check_addr(void* addr); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_rcc.h: -------------------------------------------------------------------------------- 1 | #ifndef __WM_RCC_H__ 2 | #define __WM_RCC_H__ 3 | 4 | #define RCC ((RCC_TypeDef *)RCC_BASE) 5 | 6 | #define __HAL_RCC_ALL_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_ALL) 7 | 8 | #define __HAL_RCC_SPI_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_LSPI) 9 | 10 | #define __HAL_RCC_SPI_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_LSPI) 11 | 12 | #define __HAL_RCC_PWM_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_PWM) 13 | 14 | #define __HAL_RCC_PWM_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_PWM) 15 | 16 | #define __HAL_RCC_ADC_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_ADC) 17 | 18 | #define __HAL_RCC_ADC_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_ADC) 19 | 20 | #define __HAL_RCC_GPIO_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_GPIO) 21 | 22 | #define __HAL_RCC_GPIO_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_GPIO) 23 | 24 | #define __HAL_RCC_UART0_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_UART0) 25 | 26 | #define __HAL_RCC_UART0_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_UART0) 27 | 28 | #define __HAL_RCC_UART1_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_UART1) 29 | 30 | #define __HAL_RCC_UART1_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_UART1) 31 | 32 | #define __HAL_RCC_UART2_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_UART2) 33 | 34 | #define __HAL_RCC_UART2_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_UART2) 35 | 36 | #define __HAL_RCC_UART3_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_UART3) 37 | 38 | #define __HAL_RCC_UART3_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_UART3) 39 | 40 | #define __HAL_RCC_UART4_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_UART4) 41 | 42 | #define __HAL_RCC_UART4_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_UART4) 43 | 44 | #define __HAL_RCC_UART5_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_UART5) 45 | 46 | #define __HAL_RCC_UART5_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_UART5) 47 | 48 | #define __HAL_RCC_TIM_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_TIMER) 49 | 50 | #define __HAL_RCC_TIM_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_TIMER) 51 | 52 | #define __HAL_RCC_I2C_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_I2C) 53 | 54 | #define __HAL_RCC_I2C_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_I2C) 55 | 56 | #define __HAL_RCC_TOUCH_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_TOUCH) 57 | 58 | #define __HAL_RCC_TOUCH_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_TOUCH) 59 | 60 | #define __HAL_RCC_DMA_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_DMA) 61 | 62 | #define __HAL_RCC_DMA_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_DMA) 63 | 64 | #define __HAL_RCC_I2S_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_I2S) 65 | 66 | #define __HAL_RCC_I2S_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_I2S) 67 | 68 | #define __HAL_RCC_SDIO_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_SDIO) 69 | 70 | #define __HAL_RCC_SDIO_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_SDIO) 71 | 72 | #define __HAL_RCC_PSRAM_CLK_ENABLE() SET_BIT(RCC->CLK_EN, RCC_CLK_EN_QSRAM) 73 | 74 | #define __HAL_RCC_PSRAM_CLK_DISABLE() CLEAR_BIT(RCC->CLK_EN, RCC_CLK_EN_QSRAM) 75 | #endif -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_spi_flash.h: -------------------------------------------------------------------------------- 1 | #ifndef __WM_SPI_FLASH_H__ 2 | #define __WM_SPI_FLASH_H__ 3 | 4 | #include "wm_hal.h" 5 | 6 | #define PAGE_SIZE 256 7 | #define SECTOR_SIZE 4096 8 | 9 | #define EXFLASH_ID (0x9F) 10 | #define EXFLASH_READ_DATA (0x03) 11 | #define EXFLASH_PAGE_PROGRAM (0x02) 12 | #define EXFLASH_SECTOR_ERASE (0x20) 13 | #define EXFLASH_CIHP_ERASE (0xC7) 14 | #define EXFLASH_WRITE_ENABLE (0x06) 15 | #define EXFLASH_READ_SR1 (0x05) 16 | #define EXFLASH_READ_SR2 (0x35) 17 | 18 | #define EXFLASH_STATUS_BUSY (1 << 0) 19 | #define EXFLASH_STATUS_WEL (1 << 1) 20 | 21 | #define swap32(a) (((a & 0xFF) << 24) | ((a & 0xFF00) << 8) | ((a & 0xFF0000) >> 8) | (a >> 24)) 22 | 23 | #ifdef __cplusplus 24 | extern "C"{ 25 | #endif 26 | int SPIFLS_Init(void); 27 | 28 | int SPIFLS_Read_ID(uint8_t *id); 29 | 30 | int SPIFLS_Read(uint32_t addr, uint8_t *buf, uint32_t len); 31 | 32 | int SPIFLS_Write(uint32_t addr, uint8_t *buf, uint32_t len); 33 | 34 | int SPIFLS_Erase(uint32_t sector); 35 | 36 | int SPIFLS_Chip_Erase(void); 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_tim.h: -------------------------------------------------------------------------------- 1 | #ifndef __WM_TIM_H__ 2 | #define __WM_TIM_H__ 3 | 4 | #include "wm_hal.h" 5 | 6 | #define TIM ((TIM_TypeDef *)TIM_BASE) 7 | #define TIM0 0 8 | #define TIM1 1 9 | #define TIM2 2 10 | #define TIM3 3 11 | #define TIM4 4 12 | #define TIM5 5 13 | 14 | 15 | 16 | typedef enum 17 | { 18 | HAL_TIM_STATE_RESET = 0x00U, 19 | HAL_TIM_STATE_READY = 0x01U, 20 | HAL_TIM_STATE_BUSY = 0x02U, 21 | HAL_TIM_STATE_TIMEOUT = 0x03U, 22 | HAL_TIM_STATE_ERROR = 0x04U 23 | } HAL_TIM_StateTypeDef; 24 | 25 | typedef struct 26 | { 27 | uint32_t Unit; 28 | uint32_t AutoReload; 29 | uint32_t Period; 30 | 31 | } TIM_Base_InitTypeDef; 32 | 33 | typedef struct 34 | { 35 | uint32_t Instance; 36 | TIM_Base_InitTypeDef Init; 37 | 38 | HAL_LockTypeDef Lock; 39 | __IO HAL_TIM_StateTypeDef State; 40 | 41 | } TIM_HandleTypeDef; 42 | 43 | #define TIM_UNIT_US 0x00000000U 44 | #define TIM_UNIT_MS 0x00000001U 45 | 46 | #define TIM_AUTORELOAD_PRELOAD_DISABLE 0x00000001U 47 | #define TIM_AUTORELOAD_PRELOAD_ENABLE 0x00000000U 48 | 49 | #define IS_TIM_INSTANCE(INSTANCE)\ 50 | (((INSTANCE) == TIM0) || \ 51 | ((INSTANCE) == TIM1) || \ 52 | ((INSTANCE) == TIM2) || \ 53 | ((INSTANCE) == TIM3) || \ 54 | ((INSTANCE) == TIM4) || \ 55 | ((INSTANCE) == TIM5)) 56 | 57 | #define IS_TIM_UNIT(UNIT) (((UNIT) == TIM_UNIT_US) || \ 58 | ((UNIT) == TIM_UNIT_MS)) 59 | 60 | #define IS_TIM_AUTORELOAD(PRELOAD) (((PRELOAD) == TIM_AUTORELOAD_PRELOAD_DISABLE) || \ 61 | ((PRELOAD) == TIM_AUTORELOAD_PRELOAD_ENABLE)) 62 | 63 | #define __HAL_TIM_ENABLE(__HANDLE__) (TIM->CR |= TIM_CR_TIM_EN((__HANDLE__)->Instance - TIM0)) 64 | 65 | #define __HAL_TIM_DISABLE(__HANDLE__) (TIM->CR &= ~(TIM_CR_TIM_EN((__HANDLE__)->Instance - TIM0))) 66 | 67 | #define __HAL_TIM_ENABLE_IT(__HANDLE__) (TIM->CR |= TIM_CR_TIM_TIE((__HANDLE__)->Instance - TIM0)) 68 | 69 | #define __HAL_TIM_DISABLE_IT(__HANDLE__) (TIM->CR &= ~(TIM_CR_TIM_TIE((__HANDLE__)->Instance - TIM0))) 70 | 71 | #define __HAL_TIM_GET_FLAG(__HANDLE__) ((TIM->CR & TIM_CR_TIM_TIF((__HANDLE__)->Instance - TIM0)) == \ 72 | TIM_CR_TIM_TIF((__HANDLE__)->Instance - TIM0)) 73 | 74 | #define __HAL_TIM_CLEAR_IT(__HANDLE__) (TIM->CR |= TIM_CR_TIM_TIF((__HANDLE__)->Instance - TIM0)) 75 | 76 | #ifdef __cplusplus 77 | extern "C"{ 78 | #endif 79 | HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim); 80 | HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim); 81 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim); 82 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim); 83 | 84 | HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim); 85 | HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim); 86 | 87 | HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim); 88 | HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim); 89 | 90 | HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim); 91 | 92 | void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim); 93 | 94 | void HAL_TIM_Callback(TIM_HandleTypeDef *htim); 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /cores/w806/include/driver/wm_wdg.h: -------------------------------------------------------------------------------- 1 | #ifndef __WM_WDG_H__ 2 | #define __WM_WDG_H__ 3 | 4 | #include "wm_hal.h" 5 | 6 | #define WDG ((WDG_TypeDef *)WDG_BASE) 7 | 8 | typedef struct 9 | { 10 | uint32_t Reload; // unit: us 11 | 12 | } WDG_InitTypeDef; 13 | 14 | typedef struct 15 | { 16 | WDG_TypeDef *Instance; 17 | 18 | WDG_InitTypeDef Init; 19 | 20 | } WDG_HandleTypeDef; 21 | 22 | 23 | #define IS_WDG_ALL_INSTANCE(INSTANCE) ((INSTANCE) == WDG) 24 | 25 | #define IS_WDG_RELOAD(__RELOAD__) ((__RELOAD__) <= WDG_LD) 26 | 27 | #define __HAL_WDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLR = __FLAG__) 28 | 29 | #ifdef __cplusplus 30 | extern "C"{ 31 | #endif 32 | HAL_StatusTypeDef HAL_WDG_Init(WDG_HandleTypeDef *hwdg); 33 | 34 | void HAL_WDG_MspInit(WDG_HandleTypeDef* hwdg); 35 | 36 | HAL_StatusTypeDef HAL_WDG_DeInit(WDG_HandleTypeDef *hwdg); 37 | 38 | void HAL_WDG_IRQHandler(WDG_HandleTypeDef *hwdg); 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /cores/w806/include/wm_type_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file wm_type_def.h 3 | * 4 | * @brief WM type redefine 5 | * 6 | * @author winnermicro 7 | * 8 | * Copyright (c) 2015 Winner Microelectronics Co., Ltd. 9 | */ 10 | #ifndef __WM_TYPE_DEF_H__ 11 | #define __WM_TYPE_DEF_H__ 12 | 13 | 14 | #include 15 | #include 16 | 17 | typedef enum 18 | { 19 | HAL_OK = 0x00U, 20 | HAL_ERROR = 0x01U, 21 | HAL_BUSY = 0x02U, 22 | HAL_TIMEOUT = 0x03U 23 | } HAL_StatusTypeDef; 24 | 25 | typedef enum 26 | { 27 | HAL_UNLOCKED = 0x00U, 28 | HAL_LOCKED = 0x01U 29 | } HAL_LockTypeDef; 30 | 31 | typedef enum 32 | { 33 | RESET = 0, 34 | SET = !RESET 35 | } FlagStatus, ITStatus; 36 | 37 | #define UNUSED(X) (void)X 38 | 39 | #ifndef NULL 40 | #define NULL ((void *)0) 41 | #endif 42 | 43 | #define HAL_MAX_DELAY 0xFFFFFFFF 44 | 45 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != 0U) 46 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 47 | 48 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 49 | do{ \ 50 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 51 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 52 | } while(0U) 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /cores/w806/inttypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _IntTypes_H_ 2 | #define _IntTypes_H_ 3 | 4 | /* Added for compatibility */ 5 | 6 | #include 7 | 8 | #define PRId32 "d" 9 | #define PRIu32 "u" 10 | 11 | #endif -------------------------------------------------------------------------------- /cores/w806/lib/arch/XT804/bsp/Makefile: -------------------------------------------------------------------------------- 1 | TOP_DIR = ../../../.. 2 | sinclude $(TOP_DIR)/tools/W806/conf.mk 3 | 4 | ifndef PDIR 5 | GEN_LIBS = libwmbsp$(LIB_EXT) 6 | endif 7 | 8 | #DEFINES += 9 | 10 | sinclude $(TOP_DIR)/tools/W806/rules.mk 11 | INCLUDES := $(INCLUDES) -I $(PDIR)include 12 | PDIR := ../$(PDIR) 13 | sinclude $(PDIR)Makefile -------------------------------------------------------------------------------- /cores/w806/lib/arch/XT804/bsp/system.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /****************************************************************************** 18 | * @file system.c 19 | * @brief CSI Device System Source File 20 | * @version V1.0 21 | * @date 02. June 2017 22 | ******************************************************************************/ 23 | 24 | #include 25 | #include "csi_core.h" 26 | 27 | /** 28 | * @brief initialize the system 29 | * Initialize the psr and vbr. 30 | * @param None 31 | * @return None 32 | */ 33 | extern int __dtor_end__; 34 | extern int __ctor_end__; 35 | extern int __ctor_start__; 36 | typedef void (*func_ptr)(void); 37 | __attribute__((weak)) void cxx_system_init(void) 38 | { 39 | func_ptr *p; 40 | for (p = (func_ptr *)&__ctor_end__ -1; p >= (func_ptr *)&__ctor_start__; p--) 41 | { 42 | (*p)(); 43 | } 44 | } 45 | 46 | void SystemInit(void) 47 | { 48 | __set_VBR((uint32_t) & (irq_vectors)); 49 | 50 | #if defined(CONFIG_SEPARATE_IRQ_SP) && !defined(CONFIG_KERNEL_NONE) 51 | /* 801 not supported */ 52 | extern int32_t g_top_irqstack; 53 | __set_Int_SP((uint32_t)&g_top_irqstack); 54 | __set_CHR(__get_CHR() | CHR_ISE_Msk); 55 | VIC->TSPR = 0xFF; 56 | #endif 57 | 58 | __set_CHR(__get_CHR() | CHR_IAE_Msk); 59 | 60 | /* Clear active and pending IRQ */ 61 | VIC->IABR[0] = 0x0; 62 | VIC->ICPR[0] = 0xFFFFFFFF; 63 | cxx_system_init(); 64 | #ifdef CONFIG_KERNEL_NONE 65 | __enable_excp_irq(); 66 | #endif 67 | } 68 | -------------------------------------------------------------------------------- /cores/w806/lib/arch/XT804/bsp/trap_c.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /****************************************************************************** 18 | * @file trap_c.c 19 | * @brief source file for the trap process 20 | * @version V1.0 21 | * @date 12. December 2017 22 | ******************************************************************************/ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | void trap_c(uint32_t *regs) 30 | { 31 | int i; 32 | uint32_t vec = 0; 33 | asm volatile( 34 | "mfcr %0, psr \n" 35 | "lsri %0, 16 \n" 36 | "sextb %0 \n" 37 | :"=r"(vec):); 38 | //while (1); 39 | printf("CPU Exception : %u", vec); 40 | printf("\n"); 41 | 42 | for (i = 0; i < 16; i++) { 43 | printf("r%d: %08x\t", i, regs[i]); 44 | 45 | if ((i % 5) == 4) { 46 | printf("\n"); 47 | } 48 | } 49 | 50 | printf("\n"); 51 | printf("epsr: %8x\n", regs[16]); 52 | printf("epc : %8x\n", regs[17]); 53 | 54 | while (1); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /cores/w806/lib/arch/XT804/libc/Makefile: -------------------------------------------------------------------------------- 1 | TOP_DIR = ../../../.. 2 | sinclude $(TOP_DIR)/tools/W806/conf.mk 3 | 4 | ifndef PDIR 5 | GEN_LIBS = libwmlibc$(LIB_EXT) 6 | endif 7 | 8 | #DEFINES += 9 | 10 | sinclude $(TOP_DIR)/tools/W806/rules.mk 11 | INCLUDES := $(INCLUDES) -I $(PDIR)include 12 | PDIR := ../$(PDIR) 13 | sinclude $(PDIR)Makefile -------------------------------------------------------------------------------- /cores/w806/lib/drivers/wm_hal.c: -------------------------------------------------------------------------------- 1 | #include "wm_hal.h" 2 | 3 | HAL_StatusTypeDef HAL_Init(void) 4 | { 5 | HAL_MspInit(); 6 | return HAL_OK; 7 | } 8 | 9 | HAL_StatusTypeDef HAL_DeInit(void) 10 | { 11 | return HAL_OK; 12 | } 13 | 14 | __attribute__((weak)) void HAL_MspInit(void) 15 | { 16 | 17 | } 18 | 19 | __attribute__((weak)) void HAL_MspDeInit(void) 20 | { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /cores/w806/lib/drivers/wm_tim.c: -------------------------------------------------------------------------------- 1 | #include "wm_tim.h" 2 | 3 | HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim) 4 | { 5 | uint32_t offset = 0; 6 | wm_sys_clk sysclk; 7 | 8 | if (htim == NULL) 9 | { 10 | return HAL_ERROR; 11 | } 12 | 13 | assert_param(IS_TIM_INSTANCE(htim->Instance)); 14 | assert_param(IS_TIM_UNIT(htim->Init.unit)); 15 | assert_param(IS_TIM_AUTORELOAD(htim->Init.AutoReload)); 16 | 17 | if (htim->State == HAL_TIM_STATE_RESET) 18 | { 19 | htim->Lock = HAL_UNLOCKED; 20 | HAL_TIM_Base_MspInit(htim); 21 | } 22 | htim->State = HAL_TIM_STATE_BUSY; 23 | 24 | SystemClock_Get(&sysclk); 25 | WRITE_REG(TIM->TMR_CONFIG, sysclk.apbclk-1); 26 | offset = htim->Instance - TIM0; 27 | MODIFY_REG(TIM->CR, (TIM_CR_TIM_MODE(offset) | TIM_CR_TIM_UNIT(offset)), 28 | ((htim->Init.AutoReload << TIM_CR_TIM_MODE_Pos(offset)) | (htim->Init.Unit << TIM_CR_TIM_UNIT_Pos(offset)))); 29 | 30 | WRITE_REG(*(uint32_t *)(&(TIM->TIM0_PRD) + offset), htim->Init.Period); 31 | htim->State = HAL_TIM_STATE_READY; 32 | 33 | return HAL_OK; 34 | } 35 | 36 | HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim) 37 | { 38 | assert_param(IS_TIM_INSTANCE(htim->Instance)); 39 | 40 | htim->State = HAL_TIM_STATE_BUSY; 41 | __HAL_TIM_DISABLE(htim); 42 | HAL_TIM_Base_MspDeInit(htim); 43 | htim->State = HAL_TIM_STATE_RESET; 44 | __HAL_UNLOCK(htim); 45 | 46 | return HAL_OK; 47 | } 48 | 49 | __attribute__((weak)) void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) 50 | { 51 | UNUSED(htim); 52 | 53 | } 54 | 55 | __attribute__((weak)) void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim) 56 | { 57 | UNUSED(htim); 58 | } 59 | 60 | HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim) 61 | { 62 | assert_param(IS_TIM_INSTANCE(htim->Instance)); 63 | 64 | if (htim->State != HAL_TIM_STATE_READY) 65 | { 66 | return HAL_ERROR; 67 | } 68 | 69 | htim->State = HAL_TIM_STATE_BUSY; 70 | __HAL_TIM_ENABLE(htim); 71 | 72 | return HAL_OK; 73 | } 74 | 75 | HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim) 76 | { 77 | assert_param(IS_TIM_INSTANCE(htim->Instance)); 78 | 79 | __HAL_TIM_DISABLE(htim); 80 | 81 | htim->State = HAL_TIM_STATE_READY; 82 | 83 | return HAL_OK; 84 | } 85 | 86 | HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim) 87 | { 88 | assert_param(IS_TIM_INSTANCE(htim->Instance)); 89 | 90 | if (htim->State != HAL_TIM_STATE_READY) 91 | { 92 | return HAL_ERROR; 93 | } 94 | htim->State = HAL_TIM_STATE_BUSY; 95 | __HAL_TIM_ENABLE_IT(htim); 96 | __HAL_TIM_ENABLE(htim); 97 | 98 | return HAL_OK; 99 | } 100 | 101 | HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim) 102 | { 103 | assert_param(IS_TIM_INSTANCE(htim->Instance)); 104 | 105 | __HAL_TIM_DISABLE_IT(htim); 106 | __HAL_TIM_DISABLE(htim); 107 | htim->State = HAL_TIM_STATE_READY; 108 | 109 | return HAL_OK; 110 | } 111 | 112 | HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim) 113 | { 114 | return htim->State; 115 | } 116 | 117 | __attribute__((weak)) void HAL_TIM_Callback(TIM_HandleTypeDef *htim) 118 | { 119 | 120 | UNUSED(htim); 121 | 122 | } 123 | 124 | void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim) 125 | { 126 | if (__HAL_TIM_GET_FLAG(htim) != RESET) 127 | { 128 | __HAL_TIM_CLEAR_IT(htim); 129 | HAL_TIM_Callback(htim); 130 | } 131 | } 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /cores/w806/lib/drivers/wm_touch.c: -------------------------------------------------------------------------------- 1 | #include "wm_touch.h" 2 | 3 | // 在使用TOUCH功能时,TOUCH0(PA7)必须复用为TOUCH功能,不可以作为其他功能!!! 4 | 5 | 6 | HAL_StatusTypeDef HAL_TOUCH_Init(TOUCH_HandleTypeDef *htouch) 7 | { 8 | int i; 9 | 10 | if (htouch == NULL) 11 | { 12 | return HAL_ERROR; 13 | } 14 | assert_param(IS_TOUCH_INSTANCE(htouch->Instance)); 15 | assert_param(IS_TOUCH_CHANNELS(htouch->Init.Channel)); 16 | assert_param(IS_TOUCH_WINDOW(htouch->Init.Window)); 17 | assert_param(IS_TOUCH_SCANPERIOD(htouch->Init.ScanPeriod)); 18 | 19 | HAL_TOUCH_MspInit(htouch); 20 | WRITE_REG(htouch->Instance->CR, 0); 21 | WRITE_REG(htouch->Instance->IE_IF, 0x0000FFFF); 22 | for (i = 0; i < 16; i++) 23 | { 24 | if (htouch->Init.Channel & (1 << i)) 25 | { 26 | assert_param(IS_TOUCH_THRESHOLD(htouch->Init.Threshold[i])); 27 | MODIFY_REG(*((&(htouch->Instance->CH0CR)) + i), TOUCH_CH0CR_THRESHOLD, htouch->Init.Threshold[i]); 28 | if (htouch->Init.Irq_en & (1 << i)) 29 | { 30 | SET_BIT(htouch->Instance->IE_IF, (1 << (16 + i))); 31 | } 32 | } 33 | } 34 | WRITE_REG(htouch->Instance->CR, ((htouch->Init.Channel << TOUCH_CR_CH_SEL_Pos) | 35 | (htouch->Init.ScanPeriod << TOUCH_CR_SCAN_PERIOD_Pos) | 36 | (htouch->Init.Window << TOUCH_CR_CAPDET_CNT_Pos) | 37 | TOUCH_CR_EN)); 38 | 39 | return HAL_OK; 40 | } 41 | 42 | HAL_StatusTypeDef HAL_TOUCH_DeInit(TOUCH_HandleTypeDef *htouch) 43 | { 44 | if (htouch == NULL) 45 | { 46 | return HAL_ERROR; 47 | } 48 | CLEAR_BIT(htouch->Instance->CR, TOUCH_CR_EN); 49 | HAL_TOUCH_MspDeInit(htouch); 50 | 51 | return HAL_OK; 52 | } 53 | 54 | __attribute__((weak)) void HAL_TOUCH_MspInit(TOUCH_HandleTypeDef *htouch) 55 | { 56 | UNUSED(htouch); 57 | } 58 | 59 | __attribute__((weak)) void HAL_TOUCH_MspDeInit(TOUCH_HandleTypeDef *htouch) 60 | { 61 | UNUSED(htouch); 62 | } 63 | 64 | __attribute__((weak)) void HAL_TOUCH_Callback(TOUCH_HandleTypeDef *htouch, uint16_t Flag) 65 | { 66 | UNUSED(htouch); 67 | } 68 | 69 | void HAL_TOUCH_IRQHandler(TOUCH_HandleTypeDef *htouch) 70 | { 71 | uint32_t flag = __HAL_TOUCH_GET_FLAG(htouch); 72 | if (flag != RESET) 73 | { 74 | __HAL_TOUCH_CLEAR_IT(htouch, flag); 75 | HAL_TOUCH_Callback(htouch, flag & TOUCH_IE_IF_FLAG); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /cores/w806/lib/drivers/wm_wdg.c: -------------------------------------------------------------------------------- 1 | #include "wm_wdg.h" 2 | 3 | HAL_StatusTypeDef HAL_WDG_Init(WDG_HandleTypeDef *hwdg) 4 | { 5 | wm_sys_clk sysclk; 6 | 7 | if (hwdg == NULL) 8 | { 9 | return HAL_ERROR; 10 | } 11 | 12 | assert_param(IS_WDG_ALL_INSTANCE(hwdg->Instance)); 13 | assert_param(IS_WDG_COUNTER(hwdg->Init.Reload)); 14 | 15 | HAL_WDG_MspInit(hwdg); 16 | 17 | SystemClock_Get(&sysclk); 18 | WRITE_REG(hwdg->Instance->LD, (sysclk.apbclk * hwdg->Init.Reload)); 19 | WRITE_REG(hwdg->Instance->CR, 0x03); 20 | 21 | return HAL_OK; 22 | } 23 | 24 | HAL_StatusTypeDef HAL_WDG_DeInit(WDG_HandleTypeDef *hwdg) 25 | { 26 | HAL_NVIC_DisableIRQ(WDG_IRQn); 27 | WRITE_REG(hwdg->Instance->CR, 0); 28 | __HAL_WDG_CLEAR_FLAG(hwdg, WDG_CLR); 29 | 30 | return HAL_OK; 31 | } 32 | 33 | __attribute__((weak)) void HAL_WDG_MspInit(WDG_HandleTypeDef *hwdg) 34 | { 35 | UNUSED(hwdg); 36 | } 37 | 38 | void HAL_WDG_IRQHandler(WDG_HandleTypeDef *hwdg) 39 | { 40 | __HAL_WDG_CLEAR_FLAG(hwdg, WDG_CLR); // 如果不清除中断,不会立即复位,在下一个周期中断到来时才复位。 41 | // 例如定时5s,第一次来中断时没清除,则5s后下一个中断到来才复位 42 | } -------------------------------------------------------------------------------- /cores/w806/lib/libdsp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/cores/w806/lib/libdsp.a -------------------------------------------------------------------------------- /cores/w806/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Arduino.h" 3 | #include "wm_hal.h" 4 | //#include "Stream.h" 5 | 6 | void Error_Handler(void); 7 | static volatile bool _loop = false; 8 | 9 | /*TIM_HandleTypeDef htim0; 10 | TIM_HandleTypeDef htim1; 11 | TIM_HandleTypeDef htim2; 12 | TIM_HandleTypeDef htim3; 13 | TIM_HandleTypeDef htim4; 14 | TIM_HandleTypeDef htim5;*/ 15 | 16 | int main(void) 17 | { 18 | #if (F_CPU == 240000000) 19 | uint32_t f_cpu_dir = (uint32_t)CPU_CLK_240M; 20 | #elif (F_CPU == 80000000) 21 | uint32_t f_cpu_dir = (uint32_t)CPU_CLK_80M; 22 | #elif (F_CPU == 4000000) 23 | uint32_t f_cpu_dir = (uint32_t)CPU_CLK_40M; 24 | #elif (F_CPU == 2000000) 25 | uint32_t f_cpu_dir = (uint32_t)CPU_CLK_2M; 26 | #else 27 | uint32_t f_cpu_dir = (uint32_t)CPU_CLK_240M; 28 | #endif 29 | 30 | SystemClock_Config(f_cpu_dir); 31 | setup(); 32 | //setup_pwm(); 33 | //setup_adc(); 34 | 35 | for (;;) { 36 | _loop = true; 37 | loop(); 38 | } 39 | 40 | return 0; 41 | } 42 | 43 | //bool is_loop(){return _loop;} 44 | //void set_loop(bool param) {_loop = param;} 45 | 46 | void Error_Handler(void) 47 | { 48 | while (1) 49 | { 50 | printf("System failure... Nuclear explosion in 1 minute. \r\n"); 51 | } 52 | } 53 | 54 | void assert_failed(uint8_t *file, uint32_t line) 55 | { 56 | printf("Wrong parameters value: file %s on line %d\r\n", file, line); 57 | } 58 | 59 | extern "C" void __cxa_pure_virtual() { while (1); } 60 | -------------------------------------------------------------------------------- /cores/w806/stdlib_noniso.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDLIB_NONISO_H_ 2 | #define _STDLIB_NONISO_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | // Not implemented yet 8 | int atoi(const char *s); 9 | 10 | //long atol(const char* s); 11 | 12 | //double atof(const char* s); 13 | 14 | char* itoa (int val, char *s, int radix); 15 | 16 | char* ltoa (long val, char *s, int radix); 17 | 18 | char* utoa (unsigned int val, char *s, int radix); 19 | 20 | char* ultoa (unsigned long val, char *s, int radix); 21 | 22 | char* dtostrf (double val, signed char width, unsigned char prec, char *s); 23 | 24 | void reverse(char* begin, char* end); 25 | 26 | #ifdef __cplusplus 27 | } // extern "C" 28 | #endif 29 | 30 | 31 | #endif//_STDLIB_NONISO_H_ -------------------------------------------------------------------------------- /cores/w806/wiring_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_private.h - Internal header file. 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #ifndef WiringPrivate_h 24 | #define WiringPrivate_h 25 | 26 | #include 27 | #include 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /cores/w806/wm_fifo.c: -------------------------------------------------------------------------------- 1 | 2 | #include "wm_fifo.h" 3 | //#include "string.h" 4 | 5 | 6 | 7 | int FifoInit(_fifo_str *p, uint8_t *fifo_addr, uint32_t fifo_size) 8 | { 9 | //_fifo_str *p = &fifo_str; 10 | 11 | if(fifo_addr == NULL || fifo_size == 0) 12 | return -1; 13 | 14 | memset((char *)p, 0, sizeof(_fifo_str)); 15 | p->buf = fifo_addr; 16 | p->in = 0; 17 | p->out = 0; 18 | p->size = fifo_size; 19 | return 0; 20 | } 21 | 22 | int FifoDataLen(_fifo_str *p) 23 | { 24 | //_fifo_str *p = &fifo_str; 25 | 26 | return (p->in - p->out); 27 | } 28 | 29 | int FifoSpaceLen(_fifo_str *p) 30 | { 31 | // _fifo_str *p = &fifo_str; 32 | 33 | return (p->size - (p->in - p->out)); 34 | } 35 | 36 | int FifoRead(_fifo_str *p, uint8_t *buf, uint32_t len) 37 | { 38 | uint32_t i = 0, j = 0; 39 | //_fifo_str *p = &fifo_str; 40 | 41 | j = (p->out % p->size); 42 | len = min(len, p->in - p->out); 43 | i = min(len, p->size - j); 44 | memcpy(buf, p->buf + j, i); 45 | memcpy(buf + i, p->buf, len - i); 46 | p->out += len; 47 | return len; 48 | } 49 | int FifoReadChar(_fifo_str *p, uint8_t *buf) 50 | { 51 | uint32_t j = 0; 52 | //_fifo_str *p = &fifo_str; 53 | if (p->in - p->out) { 54 | j = (p->out % p->size); 55 | *buf = *(p->buf + j); 56 | p->out += 1; 57 | return 1; 58 | } 59 | 60 | 61 | return 0; 62 | } 63 | 64 | int FifoWriteChar(_fifo_str *p, uint8_t b) 65 | { 66 | uint32_t j = 0; 67 | //_fifo_str *p = &fifo_str; 68 | if (p->size - p->in + p->out) 69 | { 70 | j = p->in % p->size; 71 | *(p->buf + j) = b; 72 | p->in += 1; 73 | return 1; 74 | } 75 | 76 | return 0; 77 | } 78 | 79 | int FifoWrite(_fifo_str *p, uint8_t *buf, uint32_t len) 80 | { 81 | uint32_t i = 0, j = 0; 82 | //_fifo_str *p = &fifo_str; 83 | 84 | j = p->in % p->size; 85 | len = min(len, p->size - p->in + p->out); 86 | i = min(len, p->size - j); 87 | memcpy(p->buf + j, buf, i); 88 | memcpy(p->buf, buf + i, len - i); 89 | p->in += len; 90 | 91 | return len; 92 | } 93 | 94 | void FifoClear(_fifo_str *p) 95 | { 96 | //_fifo_str *p = &fifo_str; 97 | 98 | p->in = 0; 99 | p->out = 0; 100 | } 101 | 102 | 103 | -------------------------------------------------------------------------------- /cores/w806/wm_fifo.h: -------------------------------------------------------------------------------- 1 | #ifndef _FIF0_H_ 2 | #define _FIFO_H_ 3 | 4 | //#include "wm_hal.h" 5 | #include "Common.h" 6 | 7 | typedef struct fifo_t { 8 | uint8_t *buf; 9 | uint32_t size; 10 | volatile uint32_t in; 11 | volatile uint32_t out; 12 | } _fifo_str; 13 | 14 | //#define min(x,y) ((x) < (y)?(x):(y)) 15 | 16 | int FifoInit(_fifo_str *p, uint8_t *fifo_addr, uint32_t fifo_size); 17 | 18 | int FifoDataLen(_fifo_str *p); 19 | 20 | int FifoSpaceLen(_fifo_str *p); 21 | 22 | int FifoRead(_fifo_str *p, uint8_t *buf, uint32_t len); 23 | 24 | int FifoReadChar(_fifo_str *p, uint8_t *buf); 25 | 26 | int FifoWriteChar(_fifo_str *p, uint8_t b); 27 | 28 | int FifoWrite(_fifo_str *p, uint8_t *buf, uint32_t len); 29 | 30 | void FifoClear(_fifo_str *p); 31 | 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /cores/w806/wm_it.c: -------------------------------------------------------------------------------- 1 | #include "wm_hal.h" 2 | 3 | extern TIM_HandleTypeDef htim0; 4 | extern TIM_HandleTypeDef htim1; 5 | extern TIM_HandleTypeDef htim2; 6 | extern TIM_HandleTypeDef htim3; 7 | extern TIM_HandleTypeDef htim4; 8 | extern TIM_HandleTypeDef htim5; 9 | 10 | extern UART_HandleTypeDef huart0; 11 | extern UART_HandleTypeDef huart1; 12 | extern UART_HandleTypeDef huart2; 13 | extern UART_HandleTypeDef huart3; 14 | extern UART_HandleTypeDef huart4; 15 | extern UART_HandleTypeDef huart5; 16 | 17 | extern uint32_t GPIOA_CallbackFlag; 18 | extern uint32_t GPIOB_CallbackFlag; 19 | 20 | //extern DMA_HandleTypeDef hdma_channel0; 21 | 22 | extern I2S_HandleTypeDef hi2s; 23 | 24 | 25 | __attribute__((weak)) void HAL_PWM_IRQHandler(void); 26 | 27 | 28 | #define readl(addr) ({unsigned int __v = (*(volatile unsigned int *) (addr)); __v;}) 29 | __attribute__((isr)) void CORET_IRQHandler(void) 30 | { 31 | readl(0xE000E010); 32 | HAL_IncTick(); 33 | } 34 | __attribute__((isr)) void GPIOA_IRQHandler(void) 35 | { 36 | if ((GPIOA->MIS & GPIOA_CallbackFlag) != 0) { 37 | HAL_GPIO_EXTI_IRQHandler(GPIOA, GPIOA->MIS); 38 | } 39 | else { 40 | HAL_GPIO_EXTI_IRQHandler(GPIOA, GPIO_PIN_ALL); 41 | } 42 | } 43 | 44 | __attribute__((isr)) void GPIOB_IRQHandler(void) 45 | { 46 | if ((GPIOB->MIS & GPIOB_CallbackFlag) != 0) { 47 | HAL_GPIO_EXTI_IRQHandler(GPIOB, GPIOB->MIS); 48 | } 49 | else { 50 | HAL_GPIO_EXTI_IRQHandler(GPIOB, GPIO_PIN_ALL); 51 | } 52 | } 53 | 54 | __attribute__((isr)) void TIM0_5_IRQHandler(void) 55 | { 56 | 57 | HAL_TIM_IRQHandler(&htim0); 58 | HAL_TIM_IRQHandler(&htim1); 59 | HAL_TIM_IRQHandler(&htim2); 60 | HAL_TIM_IRQHandler(&htim3); 61 | HAL_TIM_IRQHandler(&htim4); 62 | HAL_TIM_IRQHandler(&htim5); 63 | } 64 | 65 | __attribute__((isr)) void UART0_IRQHandler(void) 66 | { 67 | HAL_UART_IRQHandler(&huart0); 68 | } 69 | 70 | __attribute__((isr)) void UART1_IRQHandler(void) 71 | { 72 | HAL_UART_IRQHandler(&huart1); 73 | } 74 | 75 | __attribute__((isr)) void UART2_5_IRQHandler(void) 76 | { 77 | HAL_UART_IRQHandler(&huart2); 78 | HAL_UART_IRQHandler(&huart3); 79 | HAL_UART_IRQHandler(&huart4); 80 | HAL_UART_IRQHandler(&huart5); 81 | } 82 | 83 | __attribute__((isr)) void PWM_IRQHandler(void) 84 | { 85 | HAL_PWM_IRQHandler(); 86 | } 87 | 88 | __attribute__((weak)) void HAL_PWM_IRQHandler(void) 89 | { 90 | 91 | } 92 | 93 | 94 | __attribute__((isr)) void I2S_IRQHandler(void) 95 | { 96 | HAL_I2S_IRQHandler(&hi2s); 97 | } 98 | -------------------------------------------------------------------------------- /cores/w806/wm_it.h: -------------------------------------------------------------------------------- 1 | #ifndef __WM_IT_H__ 2 | #define __WM_IT_H__ 3 | 4 | void CORET_IRQHandler(void); 5 | void GPIOA_IRQHandler(void); 6 | void GPIOB_IRQHandler(void); 7 | void UART0_IRQHandler(void); 8 | void UART1_IRQHandler(void); 9 | void UART2_5_IRQHandler(void); 10 | void WDG_IRQHandler(void); 11 | void TIM0_5_IRQHandler(void); 12 | void ADC_IRQHandler(void); 13 | void PMU_IRQHandler(void); 14 | void TOUCH_IRQHandler(void); 15 | void PWM_IRQHandler(void); 16 | 17 | void I2S_IRQHandler(void); 18 | 19 | 20 | #endif 21 | 22 | 23 | #if 0 24 | /* Macro to define default handlers. Default handler 25 | * will be weak symbol and just dead loops. They can be 26 | * overwritten by other handlers */ 27 | .macro def_irq_handler handler_name 28 | .weak \handler_name 29 | .globl \handler_name 30 | .set \handler_name, Default_Handler 31 | .endm 32 | 33 | def_irq_handler tspend_handler 34 | def_irq_handler SDIO_IRQHandler /* 0: SDIO */ 35 | def_irq_handler MAC_IRQHandler /* 1: MAC */ 36 | def_irq_handler RF_Cfg_IRQHandler /* 2: RF Cfg */ 37 | def_irq_handler SEC_IRQHandler /* 3: SEC */ 38 | def_irq_handler DMA_Channel0_IRQHandler /* 4: DMA_Channel0 */ 39 | def_irq_handler DMA_Channel1_IRQHandler /* 5: DMA_Channel1 */ 40 | def_irq_handler DMA_Channel2_IRQHandler /* 6: DMA_Channel2 */ 41 | def_irq_handler DMA_Channel3_IRQHandler /* 7: DMA_Channel3 */ 42 | def_irq_handler DMA_Channel4_7_IRQHandler /* 8: DMA_Channel4_7 */ 43 | def_irq_handler DMA_BRUST_IRQHandler /* 9: DMA_BRUST */ 44 | def_irq_handler I2C_IRQHandler /* 10: IIC */ 45 | def_irq_handler ADC_IRQHandler /* 11: SD ADC */ 46 | def_irq_handler SPI_LS_IRQHandler /* 12: LS SPI */ 47 | def_irq_handler SPI_HS_IRQHandler /* 13: HS SPI */ 48 | def_irq_handler GPIOA_IRQHandler /* 14: GPIOA */ 49 | def_irq_handler GPIOB_IRQHandler /* 15: GPIOB */ 50 | def_irq_handler UART0_IRQHandler /* 16: UART0 */ 51 | def_irq_handler UART1_IRQHandler /* 17: UART1 */ 52 | def_irq_handler TOUCH_IRQHandler /* 18: TOUCH SENSOR */ 53 | def_irq_handler UART2_5_IRQHandler /* 19: UART2_5 */ 54 | def_irq_handler BLE_IRQHandler /* 20: BLE */ 55 | def_irq_handler BT_IRQHandler /* 21: BT */ 56 | def_irq_handler PWM_IRQHandler /* 22: PWM */ 57 | def_irq_handler I2S_IRQHandler /* 23: I2S */ 58 | def_irq_handler SDIO_HOST_IRQHandler /* 24: SDIO HOST */ 59 | def_irq_handler CORET_IRQHandler /* 25: CoreTIM */ 60 | def_irq_handler RSA_IRQHandler /* 26: RSA */ 61 | def_irq_handler GPSEC_IRQHandler /* 27: GPSEC */ 62 | def_irq_handler FLASH_IRQHandler /* 28: Flash */ 63 | def_irq_handler PMU_IRQHandler /* 29: PMU */ 64 | def_irq_handler TIM0_5_IRQHandler /* 30: Timer0_5 */ 65 | def_irq_handler WDG_IRQHandler /* 31: Watch dog */ 66 | #endif -------------------------------------------------------------------------------- /doc/Air101_pinout.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/Air101_pinout.JPG -------------------------------------------------------------------------------- /doc/Air103_Board_V1.2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/Air103_Board_V1.2.pdf -------------------------------------------------------------------------------- /doc/Air103_MCU_V1.2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/Air103_MCU_V1.2.pdf -------------------------------------------------------------------------------- /doc/Air103_pinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/Air103_pinout.png -------------------------------------------------------------------------------- /doc/SPI.md: -------------------------------------------------------------------------------- 1 | ## SPI (Serial Peripheral Interface) 2 | 3 | The W80x controller family has one high-speed SPI interface with frequency up to 20 MHz. 4 | SPI bus is supported by the `SPI` library in master mode. 5 | 6 | Default SPI pins for W806, W801 and Air103 boards are: 7 | 8 | ``` 9 | #define PIN_SPI_SCK PB15 10 | #define PIN_SPI_MISO PB16 11 | #define PIN_SPI_MOSI PB17 12 | ``` 13 | 14 | Alternative pinouts can be set by using the following method: 15 | 16 | ##### **`SPI.setSPIpins(uint8_t mosi, uint8_t miso, uint8_t sck);`** 17 | 18 | Valid SPI pins should be as follows: 19 | 20 | ### Hardware SPI pins table 21 | 22 | | **SPI signal** | **Default pins** | **Alternative pins** | 23 | |:---------|:----------------:|:--------------:| 24 | | SCK | **PB15** | PB1, PB2, PB24 | 25 | | MISO | **PB16** | PB0, PB3, PB25 | 26 | | MOSI | **PB17** | PA7, PB5, PB26 | 27 | | SS | **PB14** | PA0, PB4, PB23 | 28 | 29 | The function returns true after success pin remap and false otherwise. 30 | Note that you need call **SPI.begin()** before any SPI operation after changing the pins. 31 | 32 | ### Hardware and software CS select 33 | 34 | Note that the ``CS`` pin can be hardware or software controlled by the sketch. 35 | The library uses software CS control by default. To change this you need call **SPI.setHardCS(uint8_t cs)** with one of predefined CS pins above. To switch hardware CS off, use the call **SPI.useSoftCS()**. 36 | 37 | ### Using interrupts 38 | 39 | The current library does not supports the interrupt calls `usingInterrupt`, `notUsingInterrupt`, `attachInterrupt`, and `detachInterrpt`. 40 | 41 | ### Documentation 42 | 43 | For a detailed overview of the basic SPI interface methods see the Arduino [SPI documentation](https://www.arduino.cc/en/reference/SPI). 44 | 45 | 46 | -------------------------------------------------------------------------------- /doc/W801-KIT-V1.0-schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/W801-KIT-V1.0-schematic.pdf -------------------------------------------------------------------------------- /doc/W801_pinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/W801_pinout.png -------------------------------------------------------------------------------- /doc/W806-KIT-V1.0-schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/W806-KIT-V1.0-schematic.png -------------------------------------------------------------------------------- /doc/W806_datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/W806_datasheet.pdf -------------------------------------------------------------------------------- /doc/W806_pinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/W806_pinout.png -------------------------------------------------------------------------------- /doc/W_DMA.md: -------------------------------------------------------------------------------- 1 | ## Minimal implementation of W80x DMA support 2 | The W80x controllers has an eight equivalent DMA channels. Every channel can be used for 3 | every type of DMA transfers. This library is intended to help the user configure the DMA for some typical Memory-to-Periph or Periph-to-Memory application modes. 4 | 5 | ### **Usage** 6 | To add DMA functionality to your sketch you'll need a three simple steps. 7 | 8 | #### 1. Get number of next unused DMA channel. 9 | 10 | **`dma_ch = claim_unused_dma_channel();`** 11 | 12 | Returns channel number 0-7 or (-1) if no free channel available. 13 | 14 | #### 2. Configure the channel to work with selected peripheral. 15 | 16 | **`DMA_HandleTypeDef* hdma = dma_simple_config(dma_ch, request_src);`** 17 | 18 | Where `dma_ch` is channel number, obtained in step 1. Parameter `request_src` should be one of: 19 | * DMA_REQUEST_SOURCE_SPI_RX 20 | * DMA_REQUEST_SOURCE_SPI_TX 21 | * DMA_REQUEST_SOURCE_ADC_CH0 22 | * DMA_REQUEST_SOURCE_ADC_CH1 23 | * DMA_REQUEST_SOURCE_ADC_CH2 24 | * DMA_REQUEST_SOURCE_ADC_CH3 25 | * DMA_REQUEST_SOURCE_I2S_RX 26 | * DMA_REQUEST_SOURCE_I2S_TX 27 | * DMA_REQUEST_SOURCE_SDIO_RX 28 | * DMA_REQUEST_SOURCE_SDIO_TX 29 | 30 | The method returns a pointer to preconfigured DMA handle. 31 | 32 | #### 3. Init the hardware with prepared configuration 33 | 34 | **`result = dma_init(hdma);`** 35 | 36 | The method returns `HAL_OK` if success or `HAL_ERROR` in case of any issue. 37 | 38 | Congratulation! Now the DMA channel is configured and initialized, you can attach it to selected peripheral transfer. 39 | 40 | #### Examples of using: 41 | 42 | * [Wav_SD_Player.ino](/libraries/I2S/examples/Wav_SD_Player/Wav_SD_Player.ino) 43 | * [Spi_tx_dma.ino](/libraries/SPI/Spi_tx_dma/Spi_tx_dma.ino) 44 | 45 | 46 | -------------------------------------------------------------------------------- /doc/arduino_preferences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/arduino_preferences.png -------------------------------------------------------------------------------- /doc/board_chioce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/board_chioce.png -------------------------------------------------------------------------------- /doc/board_manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/board_manager.png -------------------------------------------------------------------------------- /doc/board_manager_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/board_manager_zh.png -------------------------------------------------------------------------------- /doc/board_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/board_select.png -------------------------------------------------------------------------------- /doc/option_zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/option_zh.png -------------------------------------------------------------------------------- /doc/rect7811.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/doc/rect7811.png -------------------------------------------------------------------------------- /libraries/BasicsExamples/BasicsExamples.h: -------------------------------------------------------------------------------- 1 | // This file intentionally left blank 2 | // This file is required to make the Arduino IDE recognize the folder as a library and thus display the examples under the File > Examples > BseicsExamples menu after a w80x_duino board is selected 3 | -------------------------------------------------------------------------------- /libraries/BasicsExamples/examples/Adc/Adc.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | /* 3 | * HLK-W80x Analog read example. 4 | * 5 | * W80x boards has four analog ports. 6 | * You can access it from Arduino code by pin numbers PA1-PA4 7 | * or by short names A1-A4. 8 | * 9 | * Name A0 is alias to A1, added for compatibility. 10 | * 11 | */ 12 | void setup() 13 | { 14 | pinMode(A2,ANALOG_INPUT); // or pinMode(PA2,ANALOG_INPUT); 15 | Serial.begin(115200); 16 | } 17 | 18 | 19 | void loop() 20 | { 21 | float volt = 0; 22 | volt = analogRead(A2); 23 | Serial.printf("ADC millivolt [%f]\r\n", volt); 24 | delay (1000); 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /libraries/BasicsExamples/examples/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int led = LED_BUILTIN_1; 4 | 5 | // the setup routine runs once when you press reset: 6 | void setup() { 7 | // initialize the digital pin as an output. 8 | pinMode(led, OUTPUT); 9 | } 10 | 11 | // the loop routine runs over and over again forever: 12 | void loop() { 13 | digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) 14 | delay(1000); // wait for a second 15 | digitalWrite(led, LOW); // turn the LED off by making the voltage LOW 16 | delay(1000); // wait for a second 17 | } -------------------------------------------------------------------------------- /libraries/BasicsExamples/examples/Gpio_interrupt/Gpio_interrupt.ino: -------------------------------------------------------------------------------- 1 | // *** Gpio interrupt example *** 2 | 3 | volatile uint8_t key_flag = 0; 4 | 5 | 6 | // user irq function 7 | void _irq_routine() { 8 | key_flag = 1; 9 | } 10 | 11 | 12 | void setup() { 13 | pinMode(LED_BUILTIN_1, OUTPUT); 14 | pinMode(PB10, INPUT_PULLUP); 15 | 16 | /* attach interrupt to pin, with mode, using callback 17 | * available modes: 18 | * RISING or GPIO_MODE_IT_RISING 19 | * FALLING or GPIO_MODE_IT_FALLING 20 | * CHANGE or GPIO_MODE_IT_RISING_FALLING 21 | * HIGH_LEVEL or GPIO_MODE_IT_HIGH_LEVEL 22 | * LOW_LEVEL or GPIO_MODE_IT_LOW_LEVEL */ 23 | 24 | attachInterrupt(PB10, &_irq_routine, FALLING); 25 | 26 | // Also available 27 | // detachInterrupt(pin); 28 | } 29 | 30 | void loop() { 31 | if (key_flag == 1) { 32 | delay(200); // debounce 33 | digitalToggle(LED_BUILTIN_1); 34 | key_flag = 0; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /libraries/BasicsExamples/examples/PSRAM_test/PSRAM_test.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | 3 | // Tested on Air103,W806,W801 boards with APS6404L-3SQR-SN chip 4 | // For W806,W801 use pins PB0...PB5 5 | 6 | PSRAM_HandleTypeDef hpsram; 7 | 8 | static void PSRAM_Init(void); 9 | 10 | 11 | uint8_t *psram_buf ; 12 | 13 | void setup() 14 | { 15 | Serial.begin(115200); 16 | // setup PSRAM HEAP size 17 | dram_heap_init(1024 * 1024); 18 | 19 | psram_buf = (uint8_t *)dram_heap_malloc(100); 20 | PSRAM_Init(); 21 | } 22 | 23 | 24 | void loop() 25 | { 26 | uint8_t temp[100]; 27 | int i = 0; 28 | 29 | memset(psram_buf, 0, 100); 30 | for(i = 0; i < 100; i++) 31 | { 32 | Serial.printf("%x ", psram_buf[i]); 33 | } 34 | Serial.printf("\r\n"); 35 | 36 | for(i = 0; i < 100; i++) 37 | { 38 | temp[i] = i % 256; 39 | } 40 | 41 | memcpy(psram_buf, temp, 100); 42 | for(i = 0; i < 100; i++) 43 | { 44 | Serial.printf("%x ", psram_buf[i]); 45 | } 46 | Serial.printf("\r\n"); 47 | 48 | delay(1000); 49 | } 50 | 51 | static void PSRAM_Init(void) 52 | { 53 | // 0 - Air103 54 | // 1 - W801,W806 55 | HAL_PSRAM_ConfigPin(1); 56 | hpsram.Instance = PSRAM; 57 | hpsram.Init.Div = 3; 58 | hpsram.Init.Mode = PSRAM_MODE_QSPI; 59 | 60 | if (HAL_PSRAM_Init(&hpsram) != HAL_OK) 61 | { 62 | Serial.printf("Init error...\r\n"); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /libraries/BasicsExamples/examples/Pwm/Pwm.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #define DUTY_MAX 240 5 | #define DUTY_MIN 50 6 | 7 | // Note: on W801 board only two LEDs are connetcted to PWM pins, so PB5 led won't lit 8 | 9 | int m[3] = { 0 }, d[3] = { DUTY_MIN, (DUTY_MIN + DUTY_MAX) / 2, DUTY_MAX - 1 }; 10 | 11 | int pwm_pin[3] = { LED_BUILTIN_1, LED_BUILTIN_2, LED_BUILTIN_3 }; 12 | 13 | void setup() { 14 | for (int i = 0; i < 3; i++) pinMode(pwm_pin[i], PWM_OUT); 15 | } 16 | 17 | void loop() { 18 | 19 | for (int i = 0; i < 3; i++) { 20 | if (m[i] == 0) // Increasing 21 | { 22 | analogWrite(pwm_pin[i], d[i]++); 23 | if (d[i] == DUTY_MAX) m[i] = 1; 24 | } else // Decreasing 25 | { 26 | analogWrite(pwm_pin[i], d[i]--); 27 | if (d[i] == DUTY_MIN) m[i] = 0; 28 | } 29 | } 30 | delay(5); 31 | } 32 | -------------------------------------------------------------------------------- /libraries/BasicsExamples/examples/Servo/Servo.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | // Tested on Air103 with SG90 servo 3 | // Uses advanced PWM signal control 4 | // see PWM.md in DOC folder 5 | 6 | // Pin definition 7 | #define servo_pin PB0 8 | 9 | //Function prototype 10 | void setAngle(uint8_t, uint8_t); 11 | 12 | //Variables 13 | PWM_HandleTypeDef *hpwm; 14 | 15 | void setup() { 16 | 17 | pinMode(servo_pin,PWM_OUT); 18 | hpwm = getPWMHandle(servo_pin); 19 | // SG90 can operate at 350 hertz 20 | setPWM_Freq(hpwm, 350); 21 | 22 | } 23 | 24 | void loop() { 25 | for (uint8_t angle = 0; angle<=180; angle++) setAngle(servo_pin,angle); 26 | delay(200); 27 | } 28 | 29 | void setAngle(uint8_t pin,uint8_t angle){ 30 | // duty from 40 to 230 corresponds to changing 31 | // the angle from 0 to 180 degrees in steps of about 0.9 32 | uint8_t duty = map(angle,0,180,40,230); 33 | analogWrite(pin, duty); 34 | } -------------------------------------------------------------------------------- /libraries/BasicsExamples/examples/randomNumber/randomNumber.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | /* 3 | * This code illustrates using of true random numeric generator(TRNG), 4 | * part of w80x inboard cryptomodule 5 | * 6 | * Std lib random functions also supported 7 | * 8 | */ 9 | void setup() { 10 | Serial.begin(115200); 11 | trngInit(); // TRNG init 12 | randomSeed(rngGet()); 13 | } 14 | 15 | 16 | void loop() { 17 | Serial.printf("true random number is:%d \n\r",rngGet()); 18 | Serial.printf("stdlib random number is:%d \n\r",random(0xFFFF)); 19 | } 20 | -------------------------------------------------------------------------------- /libraries/BasicsExamples/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Ultrasound 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | EEPROM KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | read KEYWORD2 15 | write KEYWORD2 16 | read32 KEYWORD2 17 | write32 KEYWORD2 18 | readSWM KEYWORD2 19 | writeSWM KEYWORD2 20 | 21 | ####################################### 22 | # Constants (LITERAL1) 23 | ####################################### 24 | 25 | -------------------------------------------------------------------------------- /libraries/BasicsExamples/library.properties: -------------------------------------------------------------------------------- 1 | name=BasicsExamples 2 | version=0.0.0 3 | author=null-jun 4 | maintainer=nulllab 5 | sentence=Example sketches for the nulllab w80x Arduino Hardware Support Package 6 | paragraph= 7 | category=Other 8 | url=https://github.com/nulllaborg/nulllab_w80x_duino 9 | architectures=XT804 10 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/EEPROM/EEPROM.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | EEPROMClass W_EEPROM; // initialize EEPROM with default size = 2048 bytes 6 | //EEPROMClass W_EEPROM(4096); // or you can choose different size 7 | 8 | 9 | // sample data sctructure 10 | struct data_storage 11 | { 12 | uint32_t offset; 13 | uint8_t data1; 14 | uint16_t data2; 15 | float data3; 16 | }; 17 | 18 | // sample data values 19 | data_storage ds = { 20 | .offset = 200, 21 | .data1 = 155, 22 | .data2 = 0x8000, 23 | .data3 = 39.14f 24 | }; 25 | data_storage ds1; 26 | uint8_t a1 = 122; 27 | uint8_t a2 = 255; 28 | 29 | void setup() { 30 | 31 | Serial.begin(115200); 32 | Serial.printf("\nInit EEPROM size = %d bytes\n", W_EEPROM.length()); 33 | 34 | // storing data 35 | Serial.printf("Write to EEPROM:\n"); 36 | if (! W_EEPROM.write(0, a1)) // store single byte 37 | { Serial.printf("EEPROM error!\n");} 38 | 39 | W_EEPROM.put(10, ds); // store whole structure 40 | 41 | Serial.printf("DS offset = %d, data1 = %d, data2 = %d, data3 = %f\n", ds.offset, ds.data1, ds.data2, ds.data3); 42 | delay(500); 43 | 44 | // reading data 45 | Serial.printf("\nRead from EEPROM:\n"); 46 | a2 = W_EEPROM.read(0); // read single byte 47 | Serial.printf("Byte a2 = %d\n", a2); 48 | W_EEPROM.get(10, ds1); // read structure 49 | Serial.printf("DS1 offset = %d, data1 = %d, data2 = %d, data3 = %f\n", ds1.offset, ds1.data1, ds1.data2, ds1.data3); 50 | 51 | } 52 | 53 | void loop() { 54 | // put your main code here, to run repeatedly: 55 | 56 | } -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/Image converter/BITmaper-outdated.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/libraries/GyverOLED-w80x/Image converter/BITmaper-outdated.zip -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/Image converter/ImageProcessor/download.txt: -------------------------------------------------------------------------------- 1 | https://github.com/AlexGyver/imageProcessor -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 AlexGyver 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/GyverOLED-w80x/examples/bitmap_move_fast/bitmap_move_fast.ino: -------------------------------------------------------------------------------- 1 | // работаем с буфером. Выводим битмап, обновляем только в области изменения 2 | // получаем огромную скорость обновления! 3 | 4 | const uint8_t bitmap_32x32[] PROGMEM = { 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0x70, 0x70, 0x30, 0x30, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF0, 0x70, 0x30, 0x30, 0x20, 0x00, 0x00, 6 | 0x00, 0x30, 0x78, 0xFC, 0x7F, 0x3F, 0x0F, 0x0F, 0x1F, 0x3C, 0x78, 0xF0, 0xE0, 0xC0, 0x80, 0x80, 0x80, 0x40, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0x7F, 0x33, 0x13, 0x1E, 0x1C, 0x1C, 0x0E, 0x07, 0x00, 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xF7, 0xEF, 0x5F, 0x3F, 0x7F, 0xFE, 0xFD, 0xFB, 0xF1, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1E, 0x33, 0x33, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x1F, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 9 | }; 10 | 11 | #include 12 | GyverOLED oled; 13 | // можно передать адрес: GyverOLED oled(0x3C); 14 | 15 | void setup() { 16 | oled.init(); 17 | Wire.setClock(400000L); 18 | } 19 | 20 | int posX = 64, posY = 32; // начальная позиция 21 | int velX = 4, velY = 3; // скорость 22 | void loop() { 23 | // движение с отскоками. Заходим на половину за стенки! Для теста 24 | posX += velX; 25 | posY += velY; 26 | if (posX >= 128 - 16 || posX <= -16) velX = -velX; 27 | if (posY >= 64 - 16 || posY <= -16) velY = -velY; 28 | 29 | // выводим картинку 30 | oled.drawBitmap(posX, posY, bitmap_32x32, 32, 32); 31 | 32 | // обновляем буфер только в области изменения (+-4х и +-3y от рисования) 33 | oled.update(posX - 4, posY - 3, posX + 32 + 4, posY + 32 + 3); 34 | 35 | // очищаем буфер 36 | oled.clear(posX, posY, posX + 32, posY + 32); 37 | } 38 | -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/examples/bitmap_move_fast_nobuf/bitmap_move_fast_nobuf.ino: -------------------------------------------------------------------------------- 1 | // работаем с буфером. Выводим битмап, обновляем только в области изменения 2 | // получаем огромную скорость обновления! 3 | 4 | const uint8_t bitmap_32x32[] PROGMEM = { 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0x70, 0x70, 0x30, 0x30, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF0, 0x70, 0x30, 0x30, 0x20, 0x00, 0x00, 6 | 0x00, 0x30, 0x78, 0xFC, 0x7F, 0x3F, 0x0F, 0x0F, 0x1F, 0x3C, 0x78, 0xF0, 0xE0, 0xC0, 0x80, 0x80, 0x80, 0x40, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0x7F, 0x33, 0x13, 0x1E, 0x1C, 0x1C, 0x0E, 0x07, 0x00, 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xF7, 0xEF, 0x5F, 0x3F, 0x7F, 0xFE, 0xFD, 0xFB, 0xF1, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1E, 0x33, 0x33, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x1F, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 9 | }; 10 | 11 | #include 12 | GyverOLED oled; 13 | // можно передать адрес: GyverOLED oled(0x3C); 14 | 15 | void setup() { 16 | oled.init(); 17 | Wire.setClock(400000L); 18 | } 19 | 20 | int posX = 64, posY = 32; // начальная позиция 21 | int velX = 4, velY = 3; // скорость 22 | void loop() { 23 | // движение с отскоками. Заходим на половину за стенки! Для теста 24 | posX += velX; 25 | posY += velY; 26 | if (posX >= 128 - 16 || posX <= -16) velX = -velX; 27 | if (posY >= 64 - 16 || posY <= -16) velY = -velY; 28 | 29 | // выводим картинку 30 | oled.drawBitmap(posX, posY, bitmap_32x32, 32, 32); 31 | 32 | delay(50); 33 | 34 | // очищаем только область картинки 35 | oled.clear(posX, posY, posX + 32, posY + 32); 36 | } 37 | -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/examples/drawBattery/drawBattery.ino: -------------------------------------------------------------------------------- 1 | #include 2 | //GyverOLED oled; 3 | //GyverOLED oled; 4 | //GyverOLED oled; 5 | //GyverOLED oled; 6 | //GyverOLED oled; 7 | GyverOLED oled; 8 | // можно передать адрес: GyverOLED oled(0x3C); 9 | 10 | void setup() { 11 | oled.init(); // инициализация 12 | oled.clear(); 13 | } 14 | 15 | void loop() { 16 | for (byte i = 0; i < 100; i += 5) { 17 | oled.clear(); 18 | oled.setCursorXY(0, 0); 19 | drawBattery(i); 20 | oled.update(); 21 | delay(50); 22 | } 23 | for (int i = 100; i > 0; i -= 5) { 24 | oled.clear(); 25 | oled.setCursorXY(0, 0); 26 | drawBattery(i); 27 | oled.update(); 28 | delay(50); 29 | } 30 | } 31 | 32 | void drawBattery(byte percent) { 33 | oled.drawByte(0b00111100); // пипка 34 | oled.drawByte(0b00111100); 35 | oled.drawByte(0b11111111); // стенка 36 | for (byte i = 0; i < 100 / 8; i++) { 37 | if (i < (100 - percent) / 8) oled.drawByte(0b10000001); 38 | else oled.drawByte(0b11111111); 39 | } 40 | oled.drawByte(0b11111111); // попка 41 | } 42 | -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/examples/drawIcons/drawIcons.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | GyverOLED oled; 4 | 5 | const static uint8_t icons_7x7[][7] PROGMEM = { 6 | {0x7f, 0x45, 0x49, 0x51, 0x49, 0x45, 0x7f}, //0 email 7 | {0x40, 0x60, 0x77, 0x77, 0x77, 0x60, 0x40}, //1 user 8 | {0x70, 0x7e, 0x71, 0x51, 0x71, 0x7e, 0x70}, //2 lock, password 9 | }; 10 | 11 | const static uint8_t icons_8x8[][8] PROGMEM = { 12 | {0x7e, 0x81, 0x81, 0x91, 0x88, 0x85, 0x83, 0x77}, //0 maximize 13 | {0x7c, 0x44, 0xe7, 0xa5, 0xa5, 0xe7, 0x44, 0x7c}, //1 printer 14 | {0x7e, 0x81, 0x91, 0xa1, 0x91, 0x89, 0x84, 0x72}, //2 checked 15 | {0x7e, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x7e}, //3 unchecked 16 | {0x1c, 0x3e, 0x73, 0xe1, 0xe1, 0x73, 0x3e, 0x1c}, //4 map 17 | }; 18 | 19 | void setup() { 20 | 21 | oled.init(); // инициализация 22 | 23 | // ускорим вывод, ВЫЗЫВАТЬ ПОСЛЕ oled.init()!!! 24 | Wire.setClock(400000L); // макс. 800'000 25 | 26 | oled.clear(); 27 | oled.home(); 28 | 29 | drawIcon7x7(0); 30 | oled.setCursor(1 << 3, 0); 31 | drawIcon7x7(1); 32 | oled.setCursor(2 << 3, 0); 33 | drawIcon7x7(2); 34 | 35 | oled.setCursor(0 << 3, 2); 36 | drawIcon8x8(0); 37 | oled.setCursor(2 << 3, 2); 38 | drawIcon8x8(1); 39 | oled.setCursor(4 << 3, 2); 40 | drawIcon8x8(2); 41 | oled.setCursor(6 << 3, 2); 42 | drawIcon8x8(3); 43 | oled.setCursor(8 << 3, 2); 44 | drawIcon8x8(4); 45 | } 46 | 47 | void loop() { 48 | } 49 | 50 | 51 | void drawIcon7x7(byte index) { 52 | size_t s = sizeof icons_7x7[index];//можно так, а можно просто 7 53 | for(unsigned int i = 0; i < s; i++) { 54 | oled.drawByte(pgm_read_byte(&(icons_7x7[index][i]))); 55 | } 56 | } 57 | 58 | void drawIcon8x8(byte index) { 59 | size_t s = sizeof icons_8x8[index];//можна так, а можна просто 8 60 | for(unsigned int i = 0; i < s; i++) { 61 | oled.drawByte(pgm_read_byte(&(icons_8x8[index][i]))); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/examples/menuButton/menuButton.ino: -------------------------------------------------------------------------------- 1 | #include 2 | //GyverOLED oled; 3 | //GyverOLED oled; 4 | //GyverOLED oled; 5 | //GyverOLED oled; 6 | //GyverOLED oled; 7 | GyverOLED oled; 8 | // можно передать адрес: GyverOLED oled(0x3C); 9 | 10 | void setup() { 11 | Serial.begin(9600); 12 | oled.init(); // инициализация 13 | Wire.setClock(400000L); 14 | oled.clear(); 15 | oled.update(); 16 | 17 | byte textPos1 = 8; 18 | byte textPos2 = 32; 19 | 20 | oled.createBuffer(5, 0, 66, textPos2 + 8 + 2); 21 | 22 | oled.roundRect(5, textPos1 - 4, 65, textPos1 + 8 + 2, OLED_STROKE); 23 | oled.setCursorXY(10, textPos1); 24 | oled.print("SET MODE"); 25 | 26 | oled.roundRect(5, textPos2 - 4, 65, textPos2 + 8 + 2, OLED_FILL); 27 | oled.setCursorXY(10, textPos2); 28 | oled.invertText(true); 29 | oled.print("LOL KEK"); 30 | 31 | oled.sendBuffer(); 32 | oled.update(); 33 | } 34 | -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/icons/icons7x7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/libraries/GyverOLED-w80x/icons/icons7x7.png -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/icons/icons8x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/libraries/GyverOLED-w80x/icons/icons8x8.png -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/icons/readme.txt: -------------------------------------------------------------------------------- 1 | В библиотеке есть файлы icons_7x7.h и icons_8x8.h, в них по 150 иконок кодом 2 | Можно вставить в свой код и использовать, смотри пример drawIcons 3 | Как выглядят иконки - смотри в этой папке (где readme) 4 | В папке iconsVisualiser лежит программа на processing, из которой получены картинки иконок -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For GyverOLED 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | GyverOLED KEYWORD1 9 | OLED_NO_PRINT KEYWORD1 10 | OLED_SPI_SPEED LITERAL1 KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | init KEYWORD2 16 | clear KEYWORD2 17 | setContrast KEYWORD2 18 | flipH KEYWORD2 19 | flipV KEYWORD2 20 | setScale KEYWORD2 21 | invertText KEYWORD2 22 | invertDisplay KEYWORD2 23 | autoPrintln KEYWORD2 24 | textMode KEYWORD2 25 | 26 | home KEYWORD2 27 | setCursor KEYWORD2 28 | setCursorXY KEYWORD2 29 | 30 | dot KEYWORD2 31 | line KEYWORD2 32 | rect KEYWORD2 33 | roundRect KEYWORD2 34 | circle KEYWORD2 35 | fill KEYWORD2 36 | drawByte KEYWORD2 37 | drawBitmap KEYWORD2 38 | 39 | update KEYWORD2 40 | createBuf KEYWORD2 41 | sendBuf KEYWORD2 42 | 43 | ####################################### 44 | # Constants (LITERAL1) 45 | ####################################### 46 | SSD1306_128x32 LITERAL1 47 | SSD1306_128x64 LITERAL1 48 | SSH1106_128x64 LITERAL1 49 | 50 | OLED_BUFFER LITERAL1 51 | OLED_NO_BUFFER LITERAL1 52 | 53 | OLED_STROKE LITERAL1 54 | OLED_FILL LITERAL1 55 | OLED_CLEAR LITERAL1 56 | OLED_INVERT LITERAL1 57 | 58 | BUF_ADD LITERAL1 59 | BUF_SUBTRACT LITERAL1 60 | BUF_REPLACE LITERAL1 61 | 62 | BITMAP_NORMAL LITERAL1 63 | BITMAP_INVERT LITERAL1 64 | 65 | USE_MICRO_WIRE LITERAL1 66 | 67 | OLED_I2C LITERAL1 68 | OLED_SPI LITERAL1 -------------------------------------------------------------------------------- /libraries/GyverOLED-w80x/library.properties: -------------------------------------------------------------------------------- 1 | name=GyverOLED 2 | version=1.6.1 3 | author=AlexGyver 4 | maintainer=AlexGyver 5 | sentence=Fast and light library for SSD1306/SSH1106 OLED display 6 | paragraph=Fast and light library for SSD1306/SSH1106 OLED display 7 | category=Display 8 | url=https://github.com/GyverLibs/GyverOLED 9 | architectures=* 10 | -------------------------------------------------------------------------------- /libraries/HAL_Examples/examples/hal_gpio_led_interrupt/hal_gpio_led_interrupt.ino: -------------------------------------------------------------------------------- 1 | /* 2 | For HLK-W806-KIT 3 | Briefly close the contacts GND and PB5, the LEDs will light up 4 | */ 5 | #include 6 | #include 7 | 8 | static volatile uint8_t key_flag = 0; 9 | 10 | static void GPIO_Init(void) { 11 | GPIO_InitTypeDef GPIO_InitStruct = { 0 }; 12 | 13 | __HAL_RCC_GPIO_CLK_ENABLE(); 14 | 15 | GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2; 16 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT; 17 | GPIO_InitStruct.Pull = GPIO_NOPULL; 18 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 19 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, GPIO_PIN_SET); 20 | 21 | GPIO_InitStruct.Pin = GPIO_PIN_5; 22 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 23 | GPIO_InitStruct.Pull = GPIO_PULLUP; 24 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 25 | 26 | HAL_NVIC_SetPriority(GPIOB_IRQn, 0); 27 | HAL_NVIC_EnableIRQ(GPIOB_IRQn); 28 | } 29 | 30 | void HAL_GPIO_EXTI_Callback(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin) { 31 | if ((GPIOx == GPIOB) && (GPIO_Pin == GPIO_PIN_5)) { 32 | key_flag = 1; 33 | } 34 | } 35 | 36 | void setup() { 37 | HAL_Init(); 38 | GPIO_Init(); 39 | } 40 | 41 | void loop() { 42 | if (key_flag == 1) { 43 | HAL_Delay(20); 44 | if (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_5) == GPIO_PIN_RESET) { 45 | HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2); 46 | } 47 | key_flag = 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /libraries/HAL_Examples/examples/hal_i2c_rw_eeprom/hal_i2c_rw_eeprom.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | 3 | /* 4 | * Read/Write external i2c EEPROM chip 5 | * i.e. 24с02 6 | */ 7 | #define ADRS_BYTES 2 // Address length in bytes, i.e. 1-24с02, 2-24с1024 8 | 9 | I2C_HandleTypeDef hi2c; 10 | 11 | void I2C_Init(void); 12 | void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, char data ); 13 | uint8_t i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ); 14 | 15 | #define DEVICE_ADDR 0x50 16 | 17 | void setup() { 18 | Serial.begin(115200); 19 | char w_buf[] = "AT24CXX I2C WRITE THEN READ TEST"; // Data for write 20 | uint8_t len = strlen(w_buf); 21 | 22 | I2C_Init(); 23 | 24 | // Writing 25 | if (ADRS_BYTES == 2) { 26 | for (int i=0; i < len; i++) i2c_eeprom_write_byte(DEVICE_ADDR,i,w_buf[i]); 27 | } else { 28 | for (int i = 0; i < len; i++) HAL_I2C_Write(&hi2c, (DEVICE_ADDR << 1), i, (uint8_t *)(w_buf + i), 1); 29 | } 30 | uint8_t b; 31 | 32 | // Reading 33 | if (ADRS_BYTES == 2) { 34 | for (int i=0; i < len; i++) { 35 | b = i2c_eeprom_read_byte(DEVICE_ADDR, i); 36 | Serial.printf("%c",(char)b); 37 | } 38 | Serial.printf("\r\n"); 39 | } else { 40 | for (int i=0; i < len; i++) { 41 | HAL_I2C_Read(&hi2c, (DEVICE_ADDR << 1), i, &b, 1); 42 | Serial.printf("%c",(char)b); 43 | } 44 | Serial.printf("\r\n"); 45 | } 46 | 47 | } 48 | 49 | void loop() { 50 | 51 | } 52 | 53 | uint8_t i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) 54 | { 55 | HAL_I2C_Write_Byte(&hi2c, ((deviceaddress << 1) & 0xFE), 1); 56 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) goto OUT; 57 | HAL_I2C_Write_Byte(&hi2c, (int)(eeaddress >> 8), 0); 58 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) goto OUT; 59 | HAL_I2C_Write_Byte(&hi2c, (int)(eeaddress & 0xFF), 0); 60 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) goto OUT; 61 | HAL_I2C_Write_Byte(&hi2c, ((deviceaddress << 1) | 0x01), 1); 62 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) goto OUT; 63 | return HAL_I2C_Read_Byte(&hi2c, 0, 1); 64 | OUT: 65 | HAL_I2C_Stop(&hi2c); 66 | return 0; 67 | } 68 | 69 | void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, char data ) 70 | { 71 | HAL_I2C_Write_Byte(&hi2c, ((deviceaddress << 1) & 0xFE), 1); 72 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) goto OUT; 73 | HAL_I2C_Write_Byte(&hi2c, (int)(eeaddress >> 8), 0); 74 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) goto OUT; 75 | HAL_I2C_Write_Byte(&hi2c, (int)(eeaddress & 0xFF), 0); 76 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) goto OUT; 77 | HAL_I2C_Write_Byte(&hi2c, data, 0); 78 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) goto OUT; 79 | OUT: 80 | HAL_I2C_Stop(&hi2c); 81 | delay(3); 82 | } 83 | 84 | void I2C_Init(void) 85 | { 86 | __HAL_RCC_I2C_CLK_ENABLE(); // Turn on i2c clock 87 | __HAL_AFIO_REMAP_I2C_SCL(GPIOA, GPIO_PIN_1); // Pin remap 88 | __HAL_AFIO_REMAP_I2C_SDA(GPIOA, GPIO_PIN_4); // to i2c 89 | hi2c.Instance = I2C; 90 | hi2c.Frequency = 100000; // i2c clock frequency (up to 1 MHz) 91 | HAL_I2C_Init(&hi2c); 92 | } -------------------------------------------------------------------------------- /libraries/HAL_Examples/examples/hal_internal_flash/hal_internal_flash.ino: -------------------------------------------------------------------------------- 1 | #define INTERNAL_STORAGE_ADDR 0x80FF7FF 2 | 3 | struct data_storage 4 | { 5 | uint32_t offset; 6 | uint8_t data1; 7 | uint16_t data2; 8 | float data3; 9 | }; 10 | 11 | 12 | data_storage ds = { 13 | .offset = 200, 14 | .data1 = 15, 15 | .data2 = 0xE5E5, 16 | .data3 = 3.14f 17 | }; 18 | data_storage ds1; 19 | 20 | void setup() { 21 | Serial.begin(115200); 22 | 23 | // Storing structure ds 24 | HAL_FLASH_Write(INTERNAL_STORAGE_ADDR, (uint8_t *) &ds, sizeof(data_storage)); 25 | 26 | // Restore data to ds1; 27 | HAL_FLASH_Read(INTERNAL_STORAGE_ADDR, (uint8_t *) &ds1, sizeof(data_storage)); 28 | Serial.printf("DS1 offset = %d, data1 = %d, data2 = %d, data3 = %f\n", ds1.offset, ds1.data1, ds1.data2, ds1.data3); 29 | } 30 | 31 | void loop() { 32 | 33 | } -------------------------------------------------------------------------------- /libraries/HAL_Examples/examples/hal_led/hal_led.ino: -------------------------------------------------------------------------------- 1 | /* 2 | For HLK-W806-KIT 3 | */ 4 | #include 5 | #include 6 | 7 | static volatile uint8_t key_flag = 0; 8 | 9 | static void GPIO_Init(void) 10 | { 11 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 12 | 13 | __HAL_RCC_GPIO_CLK_ENABLE(); 14 | 15 | GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2; 16 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT; 17 | GPIO_InitStruct.Pull = GPIO_NOPULL; 18 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 19 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, GPIO_PIN_SET); 20 | 21 | GPIO_InitStruct.Pin = GPIO_PIN_5; 22 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 23 | GPIO_InitStruct.Pull = GPIO_PULLUP; 24 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 25 | } 26 | 27 | void setup() { 28 | Serial.begin(115200); 29 | Serial.printf("Led Demo\r\n"); 30 | GPIO_Init(); 31 | } 32 | 33 | void loop() { 34 | 35 | delay(500); 36 | key_flag++; 37 | 38 | if (key_flag % 3 == 0) 39 | { 40 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, (GPIO_PinState)0); 41 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, (GPIO_PinState)1); 42 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, (GPIO_PinState)1); 43 | } 44 | else if (key_flag % 3 == 1) 45 | { 46 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, (GPIO_PinState)1); 47 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, (GPIO_PinState)0); 48 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, (GPIO_PinState)1); 49 | } 50 | else 51 | { 52 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, (GPIO_PinState)1); 53 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, (GPIO_PinState)1); 54 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, (GPIO_PinState)0); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /libraries/HAL_Examples/examples/hal_pwm_led/hal_pwm_led.ino: -------------------------------------------------------------------------------- 1 | // For HLK-806-KIT 2 | 3 | #include 4 | #include 5 | 6 | #define DUTY_MAX 250 7 | #define DUTY_MIN 50 8 | 9 | PWM_HandleTypeDef hal_pwm[3]; 10 | 11 | int i, j, m[3] = { 0 }, d[3] = { DUTY_MIN, (DUTY_MIN + DUTY_MAX) / 2, DUTY_MAX - 1 }; 12 | 13 | static void initPWM(PWM_HandleTypeDef *hpwm, uint32_t channel); 14 | 15 | 16 | void setup() { 17 | 18 | __HAL_RCC_PWM_CLK_ENABLE(); 19 | 20 | // Remapping pin PB0,PB1,PB2 to PWM module 21 | 22 | __HAL_AFIO_REMAP_PWM0(GPIOB, GPIO_PIN_0); 23 | __HAL_AFIO_REMAP_PWM1(GPIOB, GPIO_PIN_1); 24 | __HAL_AFIO_REMAP_PWM2(GPIOB, GPIO_PIN_2); 25 | 26 | // Starting each instance of PWM channel 27 | for (i = 2; i >= 0; i--) { 28 | initPWM(&hal_pwm[i], PWM_CHANNEL_0 + i); 29 | HAL_PWM_Start(&hal_pwm[i]); 30 | } 31 | } 32 | 33 | void loop() { 34 | for (i = 0; i < 3; i++) { 35 | if (m[i] == 0) // Increasing 36 | { 37 | HAL_PWM_Duty_Set(&hal_pwm[i], d[i]++); 38 | if (d[i] == DUTY_MAX) { 39 | m[i] = 1; 40 | } 41 | } else // Decreasing 42 | { 43 | HAL_PWM_Duty_Set(&hal_pwm[i], d[i]--); 44 | if (d[i] == DUTY_MIN) { 45 | m[i] = 0; 46 | } 47 | } 48 | } 49 | delay(10); 50 | } 51 | 52 | static void initPWM(PWM_HandleTypeDef *hpwm, uint32_t channel) { 53 | hpwm->Instance = PWM; 54 | hpwm->Init.AutoReloadPreload = PWM_AUTORELOAD_PRELOAD_ENABLE; 55 | hpwm->Init.CounterMode = PWM_COUNTERMODE_EDGEALIGNED_DOWN; 56 | hpwm->Init.Prescaler = 4; 57 | hpwm->Init.Period = 255; 58 | hpwm->Init.Pulse = 19; 59 | hpwm->Init.OutMode = PWM_OUT_MODE_INDEPENDENT; 60 | hpwm->Channel = channel; 61 | HAL_PWM_Init(hpwm); 62 | } -------------------------------------------------------------------------------- /libraries/HAL_Examples/examples/hal_tim_irq/hal_tim_irq.ino: -------------------------------------------------------------------------------- 1 | /* 2 | For HLK-W806-KIT 3 | */ 4 | #include 5 | #include 6 | 7 | 8 | // Define Timer handle 9 | TIM_HandleTypeDef htim1; 10 | static volatile uint8_t key_flag = 0; 11 | void tim_irq_routine(); 12 | 13 | void Error_Handler_tim(void) 14 | { 15 | while (1); 16 | } 17 | 18 | // redefine system MspInit method 19 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) 20 | { 21 | //UNUSED(htim); 22 | __HAL_RCC_TIM_CLK_ENABLE(); 23 | HAL_NVIC_SetPriority(TIM_IRQn, 0); 24 | HAL_NVIC_EnableIRQ(TIM_IRQn); 25 | } 26 | 27 | //redefine system HAL_TIM_Callback method 28 | void HAL_TIM_Callback(TIM_HandleTypeDef *htim) 29 | { 30 | // UNUSED(htim); 31 | if (htim == &htim1) tim_irq_routine(); 32 | } 33 | 34 | // function that will be called by timer IRQ 35 | void tim_irq_routine() { 36 | 37 | key_flag++; 38 | if (key_flag % 3 == 0) 39 | { 40 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_24, (GPIO_PinState)0); 41 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_25, (GPIO_PinState)1); 42 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_26, (GPIO_PinState)1); 43 | } 44 | else if (key_flag % 3 == 1) 45 | { 46 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_24, (GPIO_PinState)1); 47 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_25, (GPIO_PinState)0); 48 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_26, (GPIO_PinState)1); 49 | } 50 | else 51 | { 52 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_24, (GPIO_PinState)1); 53 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_25, (GPIO_PinState)1); 54 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_26, (GPIO_PinState)0); 55 | } 56 | } 57 | 58 | // configure GPIOs for LEDs 59 | static void GPIO_Init(void) 60 | { 61 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 62 | 63 | __HAL_RCC_GPIO_CLK_ENABLE(); 64 | 65 | GPIO_InitStruct.Pin = GPIO_PIN_24 | GPIO_PIN_25 | GPIO_PIN_26; 66 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT; 67 | GPIO_InitStruct.Pull = GPIO_NOPULL; 68 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 69 | } 70 | 71 | // timer configuration 72 | static void TIM1_Init(void) 73 | { 74 | htim1.Instance = TIM1; 75 | htim1.Init.Unit = TIM_UNIT_MS; 76 | htim1.Init.Period = 1000; 77 | htim1.Init.AutoReload = TIM_AUTORELOAD_PRELOAD_ENABLE; 78 | if (HAL_TIM_Base_Init(&htim1) != HAL_OK) 79 | { 80 | Serial.printf("TIM init error\r\n"); 81 | Error_Handler_tim(); 82 | } 83 | if (HAL_TIM_Base_Start_IT(&htim1) != HAL_OK) 84 | { 85 | Serial.printf("TIM start_it error\r\n"); 86 | Error_Handler_tim(); 87 | } 88 | } 89 | 90 | void setup() { 91 | Serial.begin(115200); 92 | printf("Timer Led Demo\r\n"); 93 | 94 | 95 | GPIO_Init(); 96 | TIM1_Init(); 97 | 98 | } 99 | 100 | void loop() { 101 | 102 | HAL_Delay(500); 103 | } -------------------------------------------------------------------------------- /libraries/HAL_Examples/hal_examples.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/libraries/HAL_Examples/hal_examples.h -------------------------------------------------------------------------------- /libraries/HardwareTimer/HardwareTimer.cpp: -------------------------------------------------------------------------------- 1 | #include "HardwareTimer.h" 2 | #include "W_IRQ_Priority.h" 3 | 4 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) 5 | { 6 | //UNUSED(htim); 7 | __HAL_RCC_TIM_CLK_ENABLE(); 8 | HAL_NVIC_SetPriority(TIM_IRQn, TIM_IRQn_PRIORITY); 9 | HAL_NVIC_EnableIRQ(TIM_IRQn); 10 | } 11 | 12 | 13 | 14 | void HAL_TIM_Callback(TIM_HandleTypeDef *htim) 15 | { 16 | // UNUSED(htim); 17 | if (timer_callback[htim->Instance] != NULL) (* (timer_callback[htim->Instance])) (); 18 | } 19 | 20 | 21 | TIM_HandleTypeDef* timer_devices[TIMER_COUNT] = {&htim0,&htim1,&htim2,&htim3,&htim4,&htim5}; 22 | timer_irq_callback timer_callback[TIMER_COUNT] = {0}; -------------------------------------------------------------------------------- /libraries/HardwareTimer/examples/Tim_Led_Irq/Tim_Led_Irq.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // initialize a new HardwareTimer, using mcu timer 2. 5 | // You can use up to six timers with numbers 0..5. 6 | HardwareTimer MyTim(2); 7 | static volatile uint8_t key_flag = 0; 8 | 9 | // Timer irq handler function 10 | void tim_irq_routine() { 11 | 12 | 13 | key_flag++; 14 | if (key_flag % 3 == 0) 15 | { 16 | digitalWrite(LED_BUILTIN_1, LOW); 17 | digitalWrite(LED_BUILTIN_2, HIGH); 18 | digitalWrite(LED_BUILTIN_3, HIGH); 19 | 20 | } 21 | else if (key_flag % 3 == 1) 22 | { 23 | digitalWrite(LED_BUILTIN_1, HIGH); 24 | digitalWrite(LED_BUILTIN_2, LOW); 25 | digitalWrite(LED_BUILTIN_3, HIGH); 26 | } 27 | else 28 | { 29 | digitalWrite(LED_BUILTIN_1, HIGH); 30 | digitalWrite(LED_BUILTIN_2, HIGH); 31 | digitalWrite(LED_BUILTIN_3, LOW); 32 | } 33 | } 34 | 35 | 36 | void setup() { 37 | // Led pins init 38 | pinMode(LED_BUILTIN_1, OUTPUT); 39 | pinMode(LED_BUILTIN_2, OUTPUT); 40 | pinMode(LED_BUILTIN_3, OUTPUT); 41 | 42 | // Configure the timer with period 1000 milliseconds, auto reload mode 43 | MyTim.configure(1000, TIM_UNIT_MS, TIM_AUTORELOAD_PRELOAD_ENABLE); 44 | // Enable timer interrupt and attach the handler 45 | MyTim.attachInterrupt( (timer_irq_callback) &tim_irq_routine); 46 | // start the timer 47 | MyTim.start(); 48 | } 49 | 50 | 51 | void loop() { 52 | // put your main code here, to run repeatedly: 53 | 54 | 55 | } -------------------------------------------------------------------------------- /libraries/I2S/I2S.h: -------------------------------------------------------------------------------- 1 | // This file intentionally left blank 2 | // This file is required to make the Arduino IDE recognize the folder as a library and thus display the examples under the File > Examples > BseicsExamples menu after a w80x_duino board is selected 3 | -------------------------------------------------------------------------------- /libraries/I2S/Readme.md: -------------------------------------------------------------------------------- 1 | ## Example of using W80x I2s interface 2 | 3 | In the `example` folder there is a simple example to demonstrate the basic usage of W80x i2s interface for outputs digital audio data. The code plays WAV file from SD card using asynchronically I2S DMA transfer. To keep this simple the WAV must be 16bit samples. The Mono/Stereo and Samples Per second reads from the file and can be anything. To test place the wav file in the root folder of the SD card. The name of the file must match the "8.3" scheme. 4 | 5 | To play the audio data you need a I2S audio module such as MAX98357A. 6 | 7 | The `wav_files` folder contains a few example WAV files, that can used with **Wav_SD_Player** code: 8 | 9 | * one_tone.wav - single music tone, 44 KHz, Mono, 16 bits, about 2.5 sec 10 | * music.wav - CantinaBand music sample, 22 KHz, Mono, 16 bits, about 3 secs 11 | 12 | -------------------------------------------------------------------------------- /libraries/I2S/wav_files/music.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/libraries/I2S/wav_files/music.wav -------------------------------------------------------------------------------- /libraries/I2S/wav_files/one_tone.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/libraries/I2S/wav_files/one_tone.wav -------------------------------------------------------------------------------- /libraries/ILI9341_Fast_SDIO_SPI/README.md: -------------------------------------------------------------------------------- 1 | # ILI9341_Fast 2 | Fast SPI library for the ILI9341 240x320 TFT display 3 | 4 | Significantly optimized for hlk-w80x , Air103 boards 5 | 6 | 7 | ## Extra Features 8 | - invertDisplay() 9 | - sleepDisplay() 10 | - enableDisplay() 11 | - resetDisplay() - software reset 12 | - partialDisplay() and setPartArea() - limiting display area for power saving 13 | - setScrollArea() and setScroll() - smooth vertical scrolling 14 | - very fast drawImage() from RAM 15 | - fast drawImage() from flash (PROGMEM) 16 | 17 | 18 | -------------------------------------------------------------------------------- /libraries/ILI9341_Fast_SDIO_SPI/README.txt: -------------------------------------------------------------------------------- 1 | This is fast SPI library for ILI9341 320x240 SPI display. 2 | 3 | Optimized for the best performance for w80x boards. 4 | Requires Adafruit_GFX library for Arduino. 5 | -------------------------------------------------------------------------------- /libraries/ILI9341_Fast_SDIO_SPI/examples/SDIO_TFT_Test/SDIO_TFT_Test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "lcd.h" 3 | 4 | // Basic SDIO -> SPI driver example 5 | // 6 | // The code just fill the display with solid colors using the custom LCD driver 7 | // Tested on Air103 board with ILI9341 240*320 SPI TFT 8 | 9 | /* ILI9341 240x320 3.2" V1.0 SPI LCD pinout (header at the top, from left): 10 | #1 MISO -> NC 11 | #2 LED -> 3.3V (5v) 12 | #3 SCK -> PB6 13 | #4 SDI -> PB7 14 | #5 DC -> PB9 15 | #6 RESET -> PB10 16 | #7 CS -> PB14 17 | #8 GND -> GND 18 | #9 VCC -> 3.3V (5v) 19 | */ 20 | 21 | 22 | uint8_t index = 0; 23 | uint16_t buff[] = { BLACK, RED, GREEN, BLUE, YELLOW, PURPLE, CYAN, MAGENTA, WHITE, GREENYELLOW, VIOLET, AQUA }; 24 | 25 | void setup() { 26 | Lcd_Init(); 27 | Lcd_Orientation(scr_normal); 28 | } 29 | 30 | 31 | void loop() { 32 | for (index = 0; index < sizeof(buff); index++) { 33 | Lcd_Clear(buff[index]); 34 | delay(1500); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /libraries/ILI9341_Fast_SDIO_SPI/keywords.txt: -------------------------------------------------------------------------------- 1 | ILI9341 KEYWORD3 2 | 3 | init KEYWORD2 4 | invertDisplay KEYWORD2 5 | partialDisplay KEYWORD2 6 | sleepDisplay KEYWORD2 7 | enableDisplay KEYWORD2 8 | idleDisplay KEYWORD2 9 | resetDisplay KEYWORD2 10 | setScrollArea KEYWORD2 11 | setScroll KEYWORD2 12 | setPartArea KEYWORD2 13 | powerSave KEYWORD2 14 | rgbWheel KEYWORD2 15 | RGBto565 KEYWORD2 16 | drawImage KEYWORD2 17 | drawImageF KEYWORD2 18 | -------------------------------------------------------------------------------- /libraries/ILI9341_Fast_SDIO_SPI/library.properties: -------------------------------------------------------------------------------- 1 | name=Fast ILI9341 Library 2 | version=1.0.2 3 | author=Pawel A. Hernik 4 | maintainer=Pawel A. Hernik 5 | sentence=Fast SPI library for ILI9341 320x240 LCD 6 | paragraph=Fast SPI library for ILI9341 320x240 LCD 7 | category=Display 8 | url=https://github.com/cbm80amiga/ILI9341_Fast 9 | architectures=C-SKY XT-804 (W80X) 10 | -------------------------------------------------------------------------------- /libraries/ILI9341_Fast_SDIO_SPI/src/driver.h: -------------------------------------------------------------------------------- 1 | #ifndef __SDIO_SPI_DRIVER_H__ 2 | #define __SDIO_SPI_DRIVER_H__ 3 | 4 | // Basic SDIO -> SPI driver 5 | // Adapted by AnatolSher from original WinnerMicro code 6 | // for test purposes. 7 | 8 | #include "Arduino.h" 9 | 10 | #define SDIO_HOST ((SDIO_TypeDef *)SDIO_BASE) 11 | 12 | // Data transfer pins SDIO/CLK & SDIO/CMD. See datasheet for alternatives. 13 | // Tested on Air103 board 14 | 15 | #define LCD_SCL_PIN PB6 // SCL 16 | #define LCD_MOSI_PIN PB7 // MOSI 17 | 18 | void init_sdio_spi_mode() 19 | { 20 | __HAL_RCC_SDIO_CLK_ENABLE(); 21 | 22 | __HAL_AFIO_REMAP_SDIO_CLK(pin_Map[LCD_SCL_PIN].pPort, pin_Map[LCD_SCL_PIN].halPin); /*CK*/ 23 | __HAL_AFIO_REMAP_SDIO_CMD(pin_Map[LCD_MOSI_PIN].pPort, pin_Map[LCD_MOSI_PIN].halPin); /*CMD*/ 24 | 25 | CLEAR_BIT(RCC->RST, RCC_RST_SDIO); // SDIO controller reset 26 | SET_BIT(RCC->RST, RCC_RST_SDIO); 27 | while (READ_BIT(RCC->RST, RCC_RST_SDIO) == 0); 28 | // SDIO clock calculated based on cpuclk 29 | // We use cpuclk/2 30 | wm_sys_clk sysclk; 31 | SystemClock_Get(&sysclk); 32 | SDIO_HOST->SEL = 0xC0 | (sysclk.cpuclk / 2 - 1); // enable module, enable mmcclk 33 | 34 | //SDIO_HOST->CR = 0x542 | 0 << 3;// auto transfer, mmc mode. 35 | SDIO_HOST->CR = 0x542 | (1 << 3); 36 | //SDIO_HOST->CR = 0x542 | (0b111 << 3); // 111 1/16 for debug 37 | SDIO_HOST->IM = 0x100; // unmask sdio data interrupt. 38 | SDIO_HOST->CRCCTL = 0x00; 39 | SDIO_HOST->TIMEOUT = 0; 40 | SDIO_HOST->BYTECNT = 0; 41 | } 42 | 43 | void sdio_spi_put(uint8_t d) // Transfer single byte 44 | { 45 | SDIO_HOST->BUFCR = 0x4820; 46 | SDIO_HOST->DATABUF[0] = d; 47 | 48 | SDIO_HOST->BYTECNT = 1; 49 | SDIO_HOST->IO = 0x01; 50 | while (1) { 51 | if ((SDIO_HOST->IO & 0x01) == 0x00) 52 | break; 53 | } 54 | } 55 | void sdio_spi_put16(uint16_t d) //Transfer two bytes 56 | { 57 | SDIO_HOST->BUFCR = 0x4820; 58 | SDIO_HOST->DATABUF[0] = d; 59 | 60 | SDIO_HOST->BYTECNT = 2; 61 | SDIO_HOST->IO = 0x01; 62 | while (1) { 63 | if ((SDIO_HOST->IO & 0x01) == 0x00) 64 | break; 65 | } 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/README.adoc: -------------------------------------------------------------------------------- 1 | = Liquid Crystal Library for Arduino = 2 | 3 | This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. 4 | 5 | For more information about this library please visit us at 6 | http://www.arduino.cc/en/Reference/LiquidCrystal 7 | 8 | == License == 9 | 10 | Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. 11 | Copyright (c) 2010 Arduino LLC. All right reserved. 12 | 13 | This library is free software; you can redistribute it and/or 14 | modify it under the terms of the GNU Lesser General Public 15 | License as published by the Free Software Foundation; either 16 | version 2.1 of the License, or (at your option) any later version. 17 | 18 | This library is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | Lesser General Public License for more details. 22 | 23 | You should have received a copy of the GNU Lesser General Public 24 | License along with this library; if not, write to the Free Software 25 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Autoscroll 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch demonstrates the use of the autoscroll() 10 | and noAutoscroll() functions to make new text scroll or not. 11 | 12 | The circuit for w80x: 13 | * LCD RS pin to digital pin PB0 14 | * LCD Enable pin to digital pin PB4 15 | * LCD D4 pin to digital pin PB1 16 | * LCD D5 pin to digital pin PB3 17 | * LCD D6 pin to digital pin PB5 18 | * LCD D7 pin to digital pin PB2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | * 26 | Library originally added 18 Apr 2008 27 | by David A. Mellis 28 | library modified 5 Jul 2009 29 | by Limor Fried (http://www.ladyada.net) 30 | example added 9 Jul 2009 31 | by Tom Igoe 32 | modified 22 Nov 2010 33 | by Tom Igoe 34 | modified 7 Nov 2016 35 | by Arturo Guadalupi 36 | 37 | This example code is in the public domain. 38 | 39 | http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll 40 | 41 | */ 42 | 43 | // include the library code: 44 | #include "Arduino.h" 45 | #include "LiquidCrystal.h" 46 | 47 | // initialize the library by associating any needed LCD interface pin 48 | // with the arduino pin number it is connected to 49 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 50 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 51 | 52 | void setup() { 53 | // set up the LCD's number of columns and rows: 54 | lcd.begin(16, 2); 55 | } 56 | 57 | void loop() { 58 | // set the cursor to (0,0): 59 | lcd.setCursor(0, 0); 60 | // print from 0 to 9: 61 | for (int thisChar = 0; thisChar < 10; thisChar++) { 62 | lcd.print(thisChar); 63 | delay(500); 64 | } 65 | 66 | // set the cursor to (16,1): 67 | lcd.setCursor(16, 1); 68 | // set the display to automatically scroll: 69 | lcd.autoscroll(); 70 | // print from 0 to 9: 71 | for (int thisChar = 0; thisChar < 10; thisChar++) { 72 | lcd.print(thisChar); 73 | delay(500); 74 | } 75 | // turn off automatic scrolling 76 | lcd.noAutoscroll(); 77 | 78 | // clear screen for the next loop: 79 | lcd.clear(); 80 | } 81 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Blink 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD and makes the 10 | cursor block blink. 11 | 12 | The circuit for w80x: 13 | * LCD RS pin to digital pin PB0 14 | * LCD Enable pin to digital pin PB4 15 | * LCD D4 pin to digital pin PB1 16 | * LCD D5 pin to digital pin PB3 17 | * LCD D6 pin to digital pin PB5 18 | * LCD D7 pin to digital pin PB2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | * 26 | 27 | Library originally added 18 Apr 2008 28 | by David A. Mellis 29 | library modified 5 Jul 2009 30 | by Limor Fried (http://www.ladyada.net) 31 | example added 9 Jul 2009 32 | by Tom Igoe 33 | modified 22 Nov 2010 34 | by Tom Igoe 35 | modified 7 Nov 2016 36 | by Arturo Guadalupi 37 | 38 | This example code is in the public domain. 39 | 40 | http://www.arduino.cc/en/Tutorial/LiquidCrystalBlink 41 | 42 | */ 43 | 44 | // include the library code: 45 | #include "Arduino.h" 46 | #include "LiquidCrystal.h" 47 | 48 | // initialize the library by associating any needed LCD interface pin 49 | // with the arduino pin number it is connected to 50 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 51 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 52 | 53 | void setup() { 54 | // set up the LCD's number of columns and rows: 55 | lcd.begin(16, 2); 56 | // Print a message to the LCD. 57 | lcd.print("hello, world!"); 58 | } 59 | 60 | void loop() { 61 | // Turn off the blinking cursor: 62 | lcd.noBlink(); 63 | delay(3000); 64 | // Turn on the blinking cursor: 65 | lcd.blink(); 66 | delay(3000); 67 | } 68 | 69 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/Cursor/Cursor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Cursor 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD and 10 | uses the cursor() and noCursor() methods to turn 11 | on and off the cursor. 12 | 13 | The circuit for w80x: 14 | * LCD RS pin to digital pin PB0 15 | * LCD Enable pin to digital pin PB4 16 | * LCD D4 pin to digital pin PB1 17 | * LCD D5 pin to digital pin PB3 18 | * LCD D6 pin to digital pin PB5 19 | * LCD D7 pin to digital pin PB2 20 | * LCD R/W pin to ground 21 | * LCD VSS pin to ground 22 | * LCD VCC pin to 5V 23 | * 10K resistor: 24 | * ends to +5V and ground 25 | * wiper to LCD VO pin (pin 3) 26 | * 27 | 28 | Library originally added 18 Apr 2008 29 | by David A. Mellis 30 | library modified 5 Jul 2009 31 | by Limor Fried (http://www.ladyada.net) 32 | example added 9 Jul 2009 33 | by Tom Igoe 34 | modified 22 Nov 2010 35 | by Tom Igoe 36 | modified 7 Nov 2016 37 | by Arturo Guadalupi 38 | 39 | This example code is in the public domain. 40 | 41 | http://www.arduino.cc/en/Tutorial/LiquidCrystalCursor 42 | 43 | */ 44 | 45 | // include the library code: 46 | #include "Arduino.h" 47 | #include "LiquidCrystal.h" 48 | 49 | // initialize the library by associating any needed LCD interface pin 50 | // with the arduino pin number it is connected to 51 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 52 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 53 | 54 | void setup() { 55 | // set up the LCD's number of columns and rows: 56 | lcd.begin(16, 2); 57 | // Print a message to the LCD. 58 | lcd.print("hello, world!"); 59 | } 60 | 61 | void loop() { 62 | // Turn off the cursor: 63 | lcd.noCursor(); 64 | delay(500); 65 | // Turn on the cursor: 66 | lcd.cursor(); 67 | delay(500); 68 | } 69 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/Display/Display.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - display() and noDisplay() 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD and uses the 10 | display() and noDisplay() functions to turn on and off 11 | the display. 12 | 13 | The circuit for w80x: 14 | * LCD RS pin to digital pin PB0 15 | * LCD Enable pin to digital pin PB4 16 | * LCD D4 pin to digital pin PB1 17 | * LCD D5 pin to digital pin PB3 18 | * LCD D6 pin to digital pin PB5 19 | * LCD D7 pin to digital pin PB2 20 | * LCD R/W pin to ground 21 | * LCD VSS pin to ground 22 | * LCD VCC pin to 5V 23 | * 10K resistor: 24 | * ends to +5V and ground 25 | * wiper to LCD VO pin (pin 3) 26 | * 27 | 28 | Library originally added 18 Apr 2008 29 | by David A. Mellis 30 | library modified 5 Jul 2009 31 | by Limor Fried (http://www.ladyada.net) 32 | example added 9 Jul 2009 33 | by Tom Igoe 34 | modified 22 Nov 2010 35 | by Tom Igoe 36 | modified 7 Nov 2016 37 | by Arturo Guadalupi 38 | 39 | This example code is in the public domain. 40 | 41 | http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay 42 | 43 | */ 44 | 45 | // include the library code: 46 | #include "Arduino.h" 47 | #include "LiquidCrystal.h" 48 | 49 | // initialize the library by associating any needed LCD interface pin 50 | // with the arduino pin number it is connected to 51 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 52 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 53 | 54 | void setup() { 55 | // set up the LCD's number of columns and rows: 56 | lcd.begin(16, 2); 57 | // Print a message to the LCD. 58 | lcd.print("hello, world!"); 59 | } 60 | 61 | void loop() { 62 | // Turn off the display: 63 | lcd.noDisplay(); 64 | delay(500); 65 | // Turn on the display: 66 | lcd.display(); 67 | delay(500); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Hello World 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD 10 | and shows the time. 11 | 12 | The circuit for w80x: 13 | * LCD RS pin to digital pin PB0 14 | * LCD Enable pin to digital pin PB4 15 | * LCD D4 pin to digital pin PB1 16 | * LCD D5 pin to digital pin PB3 17 | * LCD D6 pin to digital pin PB5 18 | * LCD D7 pin to digital pin PB2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | 26 | Library originally added 18 Apr 2008 27 | by David A. Mellis 28 | library modified 5 Jul 2009 29 | by Limor Fried (http://www.ladyada.net) 30 | example added 9 Jul 2009 31 | by Tom Igoe 32 | modified 22 Nov 2010 33 | by Tom Igoe 34 | modified 7 Nov 2016 35 | by Arturo Guadalupi 36 | 37 | This example code is in the public domain. 38 | 39 | http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld 40 | 41 | */ 42 | 43 | // include the library code: 44 | #include "Arduino.h" 45 | #include "LiquidCrystal.h" 46 | 47 | // initialize the library by associating any needed LCD interface pin 48 | // with the arduino pin number it is connected to 49 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 50 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 51 | 52 | void setup() { 53 | // set up the LCD's number of columns and rows: 54 | lcd.begin(16, 2); 55 | // Print a message to the LCD. 56 | lcd.print("hello, Air103!"); 57 | } 58 | 59 | void loop() { 60 | // set the cursor to column 0, line 1 61 | // (note: line 1 is the second row, since counting begins with 0): 62 | lcd.setCursor(0, 1); 63 | // print the number of seconds since reset: 64 | lcd.print(millis() / 1000); 65 | } -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/Scroll/Scroll.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD and uses the 10 | scrollDisplayLeft() and scrollDisplayRight() methods to scroll 11 | the text. 12 | 13 | The circuit for w80x: 14 | * LCD RS pin to digital pin PB0 15 | * LCD Enable pin to digital pin PB4 16 | * LCD D4 pin to digital pin PB1 17 | * LCD D5 pin to digital pin PB3 18 | * LCD D6 pin to digital pin PB5 19 | * LCD D7 pin to digital pin PB2 20 | * LCD R/W pin to ground 21 | * LCD VSS pin to ground 22 | * LCD VCC pin to 5V 23 | * 10K resistor: 24 | * ends to +5V and ground 25 | * wiper to LCD VO pin (pin 3) 26 | * 27 | 28 | Library originally added 18 Apr 2008 29 | by David A. Mellis 30 | library modified 5 Jul 2009 31 | by Limor Fried (http://www.ladyada.net) 32 | example added 9 Jul 2009 33 | by Tom Igoe 34 | modified 22 Nov 2010 35 | by Tom Igoe 36 | modified 7 Nov 2016 37 | by Arturo Guadalupi 38 | 39 | This example code is in the public domain. 40 | 41 | http://www.arduino.cc/en/Tutorial/LiquidCrystalScroll 42 | 43 | */ 44 | 45 | // include the library code: 46 | #include "Arduino.h" 47 | #include "LiquidCrystal.h" 48 | 49 | // initialize the library by associating any needed LCD interface pin 50 | // with the arduino pin number it is connected to 51 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 52 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 53 | 54 | void setup() { 55 | // set up the LCD's number of columns and rows: 56 | lcd.begin(16, 2); 57 | // Print a message to the LCD. 58 | lcd.print("hello, world!"); 59 | delay(1000); 60 | } 61 | 62 | void loop() { 63 | // scroll 13 positions (string length) to the left 64 | // to move it offscreen left: 65 | for (int positionCounter = 0; positionCounter < 13; positionCounter++) { 66 | // scroll one position left: 67 | lcd.scrollDisplayLeft(); 68 | // wait a bit: 69 | delay(150); 70 | } 71 | 72 | // scroll 29 positions (string length + display length) to the right 73 | // to move it offscreen right: 74 | for (int positionCounter = 0; positionCounter < 29; positionCounter++) { 75 | // scroll one position right: 76 | lcd.scrollDisplayRight(); 77 | // wait a bit: 78 | delay(150); 79 | } 80 | 81 | // scroll 16 positions (display length + string length) to the left 82 | // to move it back to center: 83 | for (int positionCounter = 0; positionCounter < 16; positionCounter++) { 84 | // scroll one position left: 85 | lcd.scrollDisplayLeft(); 86 | // wait a bit: 87 | delay(150); 88 | } 89 | 90 | // delay at the end of the full loop: 91 | delay(1000); 92 | 93 | } 94 | 95 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Serial Input 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch displays text sent over the serial port 10 | (e.g. from the Serial Monitor) on an attached LCD. 11 | 12 | The circuit for w80x: 13 | * LCD RS pin to digital pin PB0 14 | * LCD Enable pin to digital pin PB4 15 | * LCD D4 pin to digital pin PB1 16 | * LCD D5 pin to digital pin PB3 17 | * LCD D6 pin to digital pin PB5 18 | * LCD D7 pin to digital pin PB2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | * 26 | 27 | Library originally added 18 Apr 2008 28 | by David A. Mellis 29 | library modified 5 Jul 2009 30 | by Limor Fried (http://www.ladyada.net) 31 | example added 9 Jul 2009 32 | by Tom Igoe 33 | modified 22 Nov 2010 34 | by Tom Igoe 35 | modified 7 Nov 2016 36 | by Arturo Guadalupi 37 | 38 | This example code is in the public domain. 39 | 40 | http://www.arduino.cc/en/Tutorial/LiquidCrystalSerialDisplay 41 | 42 | */ 43 | 44 | // include the library code: 45 | #include "Arduino.h" 46 | #include "LiquidCrystal.h" 47 | 48 | // initialize the library by associating any needed LCD interface pin 49 | // with the arduino pin number it is connected to 50 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 51 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 52 | 53 | void setup() { 54 | // set up the LCD's number of columns and rows: 55 | lcd.begin(16, 2); 56 | // initialize the serial communications: 57 | Serial.begin(115200); 58 | } 59 | 60 | void loop() { 61 | // when characters arrive over the serial port... 62 | if (Serial.available()) { 63 | // wait a bit for the entire message to arrive 64 | delay(100); 65 | // clear the screen 66 | lcd.clear(); 67 | // read all the available characters 68 | while (Serial.available() > 0) { 69 | // display each character to the LCD 70 | lcd.write(Serial.read()); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - TextDirection 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch demonstrates how to use leftToRight() and rightToLeft() 10 | to move the cursor. 11 | 12 | The circuit for w80x: 13 | * LCD RS pin to digital pin PB0 14 | * LCD Enable pin to digital pin PB4 15 | * LCD D4 pin to digital pin PB1 16 | * LCD D5 pin to digital pin PB3 17 | * LCD D6 pin to digital pin PB5 18 | * LCD D7 pin to digital pin PB2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | * 26 | 27 | Library originally added 18 Apr 2008 28 | by David A. Mellis 29 | library modified 5 Jul 2009 30 | by Limor Fried (http://www.ladyada.net) 31 | example added 9 Jul 2009 32 | by Tom Igoe 33 | modified 22 Nov 2010 34 | by Tom Igoe 35 | modified 7 Nov 2016 36 | by Arturo Guadalupi 37 | 38 | This example code is in the public domain. 39 | 40 | http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection 41 | 42 | */ 43 | 44 | // include the library code: 45 | #include "Arduino.h" 46 | #include "LiquidCrystal.h" 47 | 48 | // initialize the library by associating any needed LCD interface pin 49 | // with the arduino pin number it is connected to 50 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 51 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 52 | 53 | int thisChar = 'a'; 54 | 55 | void setup() { 56 | // set up the LCD's number of columns and rows: 57 | lcd.begin(16, 2); 58 | // turn on the cursor: 59 | lcd.cursor(); 60 | } 61 | 62 | void loop() { 63 | // reverse directions at 'm': 64 | if (thisChar == 'm') { 65 | // go right for the next letter 66 | lcd.rightToLeft(); 67 | } 68 | // reverse again at 's': 69 | if (thisChar == 's') { 70 | // go left for the next letter 71 | lcd.leftToRight(); 72 | } 73 | // reset at 'z': 74 | if (thisChar > 'z') { 75 | // go to (0,0): 76 | lcd.home(); 77 | // start again at 0 78 | thisChar = 'a'; 79 | } 80 | // print the character 81 | lcd.write(thisChar); 82 | // wait a second: 83 | delay(1000); 84 | // increment the letter: 85 | thisChar++; 86 | } 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/examples/setCursor/setCursor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - setCursor 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints to all the positions of the LCD using the 10 | setCursor() method: 11 | 12 | The circuit for w80x: 13 | * LCD RS pin to digital pin PB0 14 | * LCD Enable pin to digital pin PB4 15 | * LCD D4 pin to digital pin PB1 16 | * LCD D5 pin to digital pin PB3 17 | * LCD D6 pin to digital pin PB5 18 | * LCD D7 pin to digital pin PB2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | * 26 | 27 | Library originally added 18 Apr 2008 28 | by David A. Mellis 29 | library modified 5 Jul 2009 30 | by Limor Fried (http://www.ladyada.net) 31 | example added 9 Jul 2009 32 | by Tom Igoe 33 | modified 22 Nov 2010 34 | by Tom Igoe 35 | modified 7 Nov 2016 36 | by Arturo Guadalupi 37 | 38 | This example code is in the public domain. 39 | 40 | http://www.arduino.cc/en/Tutorial/LiquidCrystalSetCursor 41 | 42 | */ 43 | 44 | // include the library code: 45 | #include "Arduino.h" 46 | #include "LiquidCrystal.h" 47 | 48 | // initialize the library by associating any needed LCD interface pin 49 | // with the arduino pin number it is connected to 50 | const int rs = PB0, en = PB4, d4 = PB1, d5 = PB3, d6 = PB5, d7 = PB2; 51 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 52 | 53 | // these constants won't change. But you can change the size of 54 | // your LCD using them: 55 | const int numRows = 2; 56 | const int numCols = 16; 57 | 58 | void setup() { 59 | // set up the LCD's number of columns and rows: 60 | lcd.begin(numCols, numRows); 61 | } 62 | 63 | void loop() { 64 | // loop from ASCII 'a' to ASCII 'z': 65 | for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) { 66 | // loop over the columns: 67 | for (int thisRow = 0; thisRow < numRows; thisRow++) { 68 | // loop over the rows: 69 | for (int thisCol = 0; thisCol < numCols; thisCol++) { 70 | // set the cursor position: 71 | lcd.setCursor(thisCol, thisRow); 72 | // print the letter: 73 | lcd.write(thisLetter); 74 | delay(200); 75 | } 76 | } 77 | } 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For LiquidCrystal 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | LiquidCrystal KEYWORD1 LiquidCrystal 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | clear KEYWORD2 17 | home KEYWORD2 18 | print KEYWORD2 19 | setCursor KEYWORD2 20 | cursor KEYWORD2 21 | noCursor KEYWORD2 22 | blink KEYWORD2 23 | noBlink KEYWORD2 24 | display KEYWORD2 25 | noDisplay KEYWORD2 26 | autoscroll KEYWORD2 27 | noAutoscroll KEYWORD2 28 | leftToRight KEYWORD2 29 | rightToLeft KEYWORD2 30 | scrollDisplayLeft KEYWORD2 31 | scrollDisplayRight KEYWORD2 32 | createChar KEYWORD2 33 | setRowOffsets KEYWORD2 34 | 35 | ####################################### 36 | # Constants (LITERAL1) 37 | ####################################### 38 | 39 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/library.properties: -------------------------------------------------------------------------------- 1 | name=LiquidCrystal 2 | version=1.0.7 3 | author=Arduino, Adafruit 4 | maintainer=Arduino 5 | sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). 6 | paragraph=This library allows an Arduino/Genuino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). 7 | category=Display 8 | url=http://www.arduino.cc/en/Reference/LiquidCrystal 9 | architectures=* 10 | -------------------------------------------------------------------------------- /libraries/LiquidCrystal/src/LiquidCrystal.h: -------------------------------------------------------------------------------- 1 | #ifndef LiquidCrystal_h 2 | #define LiquidCrystal_h 3 | 4 | #include 5 | #include "Print.h" 6 | 7 | // commands 8 | #define LCD_CLEARDISPLAY 0x01 9 | #define LCD_RETURNHOME 0x02 10 | #define LCD_ENTRYMODESET 0x04 11 | #define LCD_DISPLAYCONTROL 0x08 12 | #define LCD_CURSORSHIFT 0x10 13 | #define LCD_FUNCTIONSET 0x20 14 | #define LCD_SETCGRAMADDR 0x40 15 | #define LCD_SETDDRAMADDR 0x80 16 | 17 | // flags for display entry mode 18 | #define LCD_ENTRYRIGHT 0x00 19 | #define LCD_ENTRYLEFT 0x02 20 | #define LCD_ENTRYSHIFTINCREMENT 0x01 21 | #define LCD_ENTRYSHIFTDECREMENT 0x00 22 | 23 | // flags for display on/off control 24 | #define LCD_DISPLAYON 0x04 25 | #define LCD_DISPLAYOFF 0x00 26 | #define LCD_CURSORON 0x02 27 | #define LCD_CURSOROFF 0x00 28 | #define LCD_BLINKON 0x01 29 | #define LCD_BLINKOFF 0x00 30 | 31 | // flags for display/cursor shift 32 | #define LCD_DISPLAYMOVE 0x08 33 | #define LCD_CURSORMOVE 0x00 34 | #define LCD_MOVERIGHT 0x04 35 | #define LCD_MOVELEFT 0x00 36 | 37 | // flags for function set 38 | #define LCD_8BITMODE 0x10 39 | #define LCD_4BITMODE 0x00 40 | #define LCD_2LINE 0x08 41 | #define LCD_1LINE 0x00 42 | #define LCD_5x10DOTS 0x04 43 | #define LCD_5x8DOTS 0x00 44 | 45 | class LiquidCrystal : public Print { 46 | public: 47 | LiquidCrystal(uint8_t rs, uint8_t enable, 48 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 49 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); 50 | LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, 51 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 52 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); 53 | LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, 54 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); 55 | LiquidCrystal(uint8_t rs, uint8_t enable, 56 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); 57 | 58 | void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, 59 | uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 60 | uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); 61 | 62 | void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); 63 | 64 | void clear(); 65 | void home(); 66 | 67 | void noDisplay(); 68 | void display(); 69 | void noBlink(); 70 | void blink(); 71 | void noCursor(); 72 | void cursor(); 73 | void scrollDisplayLeft(); 74 | void scrollDisplayRight(); 75 | void leftToRight(); 76 | void rightToLeft(); 77 | void autoscroll(); 78 | void noAutoscroll(); 79 | 80 | void setRowOffsets(int row1, int row2, int row3, int row4); 81 | void createChar(uint8_t, uint8_t[]); 82 | void setCursor(uint8_t, uint8_t); 83 | virtual size_t write(uint8_t); 84 | void command(uint8_t); 85 | 86 | using Print::write; 87 | private: 88 | void send(uint8_t, uint8_t); 89 | void write4bits(uint8_t); 90 | void write8bits(uint8_t); 91 | void pulseEnable(); 92 | 93 | uint8_t _rs_pin; // LOW: command. HIGH: character. 94 | uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. 95 | uint8_t _enable_pin; // activated by a HIGH pulse. 96 | uint8_t _data_pins[8]; 97 | 98 | uint8_t _displayfunction; 99 | uint8_t _displaycontrol; 100 | uint8_t _displaymode; 101 | 102 | uint8_t _initialized; 103 | 104 | uint8_t _numlines; 105 | uint8_t _row_offsets[4]; 106 | }; 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /libraries/SD/README.adoc: -------------------------------------------------------------------------------- 1 | = SD Library for Arduino = 2 | 3 | image:https://travis-ci.org/arduino-libraries/SD.svg?branch=master[Build Status, link=https://travis-ci.org/arduino-libraries/SD] 4 | 5 | The SD library allows for reading from and writing to SD cards. 6 | 7 | For more information about this library please visit us at 8 | http://www.arduino.cc/en/Reference/SD 9 | 10 | == License == 11 | 12 | Copyright (C) 2009 by William Greiman 13 | Copyright (c) 2010 SparkFun Electronics 14 | 15 | This program is free software: you can redistribute it and/or modify 16 | it under the terms of the GNU General Public License as published by 17 | the Free Software Foundation, either version 3 of the License, or 18 | (at your option) any later version. 19 | 20 | This program is distributed in the hope that it will be useful, 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | GNU General Public License for more details. 24 | 25 | You should have received a copy of the GNU General Public License 26 | along with this program. If not, see . 27 | -------------------------------------------------------------------------------- /libraries/SD/examples/Datalogger/Datalogger.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card datalogger 3 | 4 | This example shows how to log data from three analog sensors 5 | to an SD card using the SD library. 6 | 7 | The circuit: 8 | analog sensors on analog ins 0, 1, and 2 9 | SD card attached to SPI bus as follows: 10 | ** MOSI - pin 11 11 | ** MISO - pin 12 12 | ** CLK - pin 13 13 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN) 14 | 15 | created 24 Nov 2010 16 | modified 9 Apr 2012 17 | by Tom Igoe 18 | 19 | This example code is in the public domain. 20 | 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | const int chipSelect = 4; 27 | 28 | void setup() { 29 | // Open serial communications and wait for port to open: 30 | Serial.begin(9600); 31 | while (!Serial) { 32 | ; // wait for serial port to connect. Needed for native USB port only 33 | } 34 | 35 | 36 | Serial.print("Initializing SD card..."); 37 | 38 | // see if the card is present and can be initialized: 39 | if (!SD.begin(chipSelect)) { 40 | Serial.println("Card failed, or not present"); 41 | // don't do anything more: 42 | while (1); 43 | } 44 | Serial.println("card initialized."); 45 | } 46 | 47 | void loop() { 48 | // make a string for assembling the data to log: 49 | String dataString = ""; 50 | 51 | // read three sensors and append to the string: 52 | for (int analogPin = 0; analogPin < 3; analogPin++) { 53 | int sensor = analogRead(analogPin); 54 | dataString += String(sensor); 55 | if (analogPin < 2) { 56 | dataString += ","; 57 | } 58 | } 59 | 60 | // open the file. note that only one file can be open at a time, 61 | // so you have to close this one before opening another. 62 | File dataFile = SD.open("datalog.txt", FILE_WRITE); 63 | 64 | // if the file is available, write to it: 65 | if (dataFile) { 66 | dataFile.println(dataString); 67 | dataFile.close(); 68 | // print to the serial port too: 69 | Serial.println(dataString); 70 | } 71 | // if the file isn't open, pop up an error: 72 | else { 73 | Serial.println("error opening datalog.txt"); 74 | } 75 | } 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /libraries/SD/examples/DumpFile/DumpFile.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card file dump 3 | 4 | This example shows how to read a file from the SD card using the 5 | SD library and send it over the serial port. 6 | 7 | The circuit: 8 | SD card attached to SPI bus as follows: 9 | ** MOSI - pin 11 10 | ** MISO - pin 12 11 | ** CLK - pin 13 12 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN) 13 | 14 | created 22 December 2010 15 | by Limor Fried 16 | modified 9 Apr 2012 17 | by Tom Igoe 18 | 19 | This example code is in the public domain. 20 | 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | const int chipSelect = 4; 27 | 28 | void setup() { 29 | // Open serial communications and wait for port to open: 30 | Serial.begin(9600); 31 | while (!Serial) { 32 | ; // wait for serial port to connect. Needed for native USB port only 33 | } 34 | 35 | 36 | Serial.print("Initializing SD card..."); 37 | 38 | // see if the card is present and can be initialized: 39 | if (!SD.begin(chipSelect)) { 40 | Serial.println("Card failed, or not present"); 41 | // don't do anything more: 42 | while (1); 43 | } 44 | Serial.println("card initialized."); 45 | 46 | // open the file. note that only one file can be open at a time, 47 | // so you have to close this one before opening another. 48 | File dataFile = SD.open("datalog.txt"); 49 | 50 | // if the file is available, write to it: 51 | if (dataFile) { 52 | while (dataFile.available()) { 53 | Serial.write(dataFile.read()); 54 | } 55 | dataFile.close(); 56 | } 57 | // if the file isn't open, pop up an error: 58 | else { 59 | Serial.println("error opening datalog.txt"); 60 | } 61 | } 62 | 63 | void loop() { 64 | } 65 | 66 | -------------------------------------------------------------------------------- /libraries/SD/examples/Files/Files.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card basic file example 3 | 4 | This example shows how to create and destroy an SD card file 5 | The circuit: 6 | SD card attached to SPI bus as follows: 7 | ** MOSI - pin 11 8 | ** MISO - pin 12 9 | ** CLK - pin 13 10 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN) 11 | 12 | created Nov 2010 13 | by David A. Mellis 14 | modified 9 Apr 2012 15 | by Tom Igoe 16 | 17 | This example code is in the public domain. 18 | 19 | */ 20 | #include 21 | #include 22 | 23 | File myFile; 24 | 25 | void setup() { 26 | // Open serial communications and wait for port to open: 27 | Serial.begin(9600); 28 | while (!Serial) { 29 | ; // wait for serial port to connect. Needed for native USB port only 30 | } 31 | 32 | 33 | Serial.print("Initializing SD card..."); 34 | 35 | if (!SD.begin(4)) { 36 | Serial.println("initialization failed!"); 37 | while (1); 38 | } 39 | Serial.println("initialization done."); 40 | 41 | if (SD.exists("example.txt")) { 42 | Serial.println("example.txt exists."); 43 | } else { 44 | Serial.println("example.txt doesn't exist."); 45 | } 46 | 47 | // open a new file and immediately close it: 48 | Serial.println("Creating example.txt..."); 49 | myFile = SD.open("example.txt", FILE_WRITE); 50 | myFile.close(); 51 | 52 | // Check to see if the file exists: 53 | if (SD.exists("example.txt")) { 54 | Serial.println("example.txt exists."); 55 | } else { 56 | Serial.println("example.txt doesn't exist."); 57 | } 58 | 59 | // delete the file: 60 | Serial.println("Removing example.txt..."); 61 | SD.remove("example.txt"); 62 | 63 | if (SD.exists("example.txt")) { 64 | Serial.println("example.txt exists."); 65 | } else { 66 | Serial.println("example.txt doesn't exist."); 67 | } 68 | } 69 | 70 | void loop() { 71 | // nothing happens after setup finishes. 72 | } 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /libraries/SD/examples/NonBlockingWrite/NonBlockingWrite.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Non-blocking Write 3 | 4 | This example demonstrates how to perform non-blocking writes 5 | to a file on a SD card. The file will contain the current millis() 6 | value every 10ms. If the SD card is busy, the data will be buffered 7 | in order to not block the sketch. 8 | 9 | NOTE: myFile.availableForWrite() will automatically sync the 10 | file contents as needed. You may lose some unsynced data 11 | still if myFile.sync() or myFile.close() is not called. 12 | 13 | The circuit: 14 | - Arduino MKR Zero board 15 | - micro SD card attached 16 | 17 | This example code is in the public domain. 18 | */ 19 | 20 | #include 21 | 22 | // file name to use for writing 23 | const char filename[] = "demo.txt"; 24 | 25 | // File object to represent file 26 | File txtFile; 27 | 28 | // string to buffer output 29 | String buffer; 30 | 31 | unsigned long lastMillis = 0; 32 | 33 | void setup() { 34 | Serial.begin(9600); 35 | while (!Serial); 36 | 37 | // reserve 1kB for String used as a buffer 38 | buffer.reserve(1024); 39 | 40 | // set LED pin to output, used to blink when writing 41 | pinMode(LED_BUILTIN, OUTPUT); 42 | 43 | // init the SD card 44 | if (!SD.begin()) { 45 | Serial.println("Card failed, or not present"); 46 | // don't do anything more: 47 | while (1); 48 | } 49 | 50 | // If you want to start from an empty file, 51 | // uncomment the next line: 52 | // SD.remove(filename); 53 | 54 | // try to open the file for writing 55 | txtFile = SD.open(filename, FILE_WRITE); 56 | if (!txtFile) { 57 | Serial.print("error opening "); 58 | Serial.println(filename); 59 | while (1); 60 | } 61 | 62 | // add some new lines to start 63 | txtFile.println(); 64 | txtFile.println("Hello World!"); 65 | } 66 | 67 | void loop() { 68 | // check if it's been over 10 ms since the last line added 69 | unsigned long now = millis(); 70 | if ((now - lastMillis) >= 10) { 71 | // add a new line to the buffer 72 | buffer += "Hello "; 73 | buffer += now; 74 | buffer += "\r\n"; 75 | 76 | lastMillis = now; 77 | } 78 | 79 | // check if the SD card is available to write data without blocking 80 | // and if the buffered data is enough for the full chunk size 81 | unsigned int chunkSize = txtFile.availableForWrite(); 82 | if (chunkSize && buffer.length() >= chunkSize) { 83 | // write to file and blink LED 84 | digitalWrite(LED_BUILTIN, HIGH); 85 | txtFile.write(buffer.c_str(), chunkSize); 86 | digitalWrite(LED_BUILTIN, LOW); 87 | 88 | // remove written data from buffer 89 | buffer.remove(0, chunkSize); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /libraries/SD/examples/ReadWrite/ReadWrite.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card read/write 3 | 4 | This example shows how to read and write data to and from an SD card file 5 | The circuit: 6 | SD card attached to SPI bus as follows: 7 | ** MOSI - pin 11 8 | ** MISO - pin 12 9 | ** CLK - pin 13 10 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN) 11 | 12 | created Nov 2010 13 | by David A. Mellis 14 | modified 9 Apr 2012 15 | by Tom Igoe 16 | 17 | This example code is in the public domain. 18 | 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | File myFile; 25 | 26 | void setup() { 27 | // Open serial communications and wait for port to open: 28 | Serial.begin(9600); 29 | while (!Serial) { 30 | ; // wait for serial port to connect. Needed for native USB port only 31 | } 32 | 33 | 34 | Serial.print("Initializing SD card..."); 35 | 36 | if (!SD.begin(4)) { 37 | Serial.println("initialization failed!"); 38 | while (1); 39 | } 40 | Serial.println("initialization done."); 41 | 42 | // open the file. note that only one file can be open at a time, 43 | // so you have to close this one before opening another. 44 | myFile = SD.open("test.txt", FILE_WRITE); 45 | 46 | // if the file opened okay, write to it: 47 | if (myFile) { 48 | Serial.print("Writing to test.txt..."); 49 | myFile.println("testing 1, 2, 3."); 50 | // close the file: 51 | myFile.close(); 52 | Serial.println("done."); 53 | } else { 54 | // if the file didn't open, print an error: 55 | Serial.println("error opening test.txt"); 56 | } 57 | 58 | // re-open the file for reading: 59 | myFile = SD.open("test.txt"); 60 | if (myFile) { 61 | Serial.println("test.txt:"); 62 | 63 | // read from the file until there's nothing else in it: 64 | while (myFile.available()) { 65 | Serial.write(myFile.read()); 66 | } 67 | // close the file: 68 | myFile.close(); 69 | } else { 70 | // if the file didn't open, print an error: 71 | Serial.println("error opening test.txt"); 72 | } 73 | } 74 | 75 | void loop() { 76 | // nothing happens after setup 77 | } 78 | 79 | 80 | -------------------------------------------------------------------------------- /libraries/SD/examples/listfiles/listfiles.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Listfiles 3 | 4 | This example shows how print out the files in a 5 | directory on a SD card 6 | 7 | The circuit: 8 | SD card attached to SPI bus as follows: 9 | ** MOSI - pin 11 10 | ** MISO - pin 12 11 | ** CLK - pin 13 12 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN) 13 | 14 | created Nov 2010 15 | by David A. Mellis 16 | modified 9 Apr 2012 17 | by Tom Igoe 18 | modified 2 Feb 2014 19 | by Scott Fitzgerald 20 | 21 | This example code is in the public domain. 22 | 23 | */ 24 | #include 25 | #include 26 | 27 | File root; 28 | 29 | void setup() { 30 | // Open serial communications and wait for port to open: 31 | Serial.begin(9600); 32 | while (!Serial) { 33 | ; // wait for serial port to connect. Needed for native USB port only 34 | } 35 | 36 | Serial.print("Initializing SD card..."); 37 | 38 | if (!SD.begin(4)) { 39 | Serial.println("initialization failed!"); 40 | while (1); 41 | } 42 | Serial.println("initialization done."); 43 | 44 | root = SD.open("/"); 45 | 46 | printDirectory(root, 0); 47 | 48 | Serial.println("done!"); 49 | } 50 | 51 | void loop() { 52 | // nothing happens after setup finishes. 53 | } 54 | 55 | void printDirectory(File dir, int numTabs) { 56 | while (true) { 57 | 58 | File entry = dir.openNextFile(); 59 | if (! entry) { 60 | // no more files 61 | break; 62 | } 63 | for (uint8_t i = 0; i < numTabs; i++) { 64 | Serial.print('\t'); 65 | } 66 | Serial.print(entry.name()); 67 | if (entry.isDirectory()) { 68 | Serial.println("/"); 69 | printDirectory(entry, numTabs + 1); 70 | } else { 71 | // files have sizes, directories do not 72 | Serial.print("\t\t"); 73 | Serial.println(entry.size(), DEC); 74 | } 75 | entry.close(); 76 | } 77 | } 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /libraries/SD/extras/codespell-ignore-words-list.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/libraries/SD/extras/codespell-ignore-words-list.txt -------------------------------------------------------------------------------- /libraries/SD/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map SD 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SD KEYWORD1 SD 10 | File KEYWORD1 SD 11 | SDFile KEYWORD1 SD 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | begin KEYWORD2 17 | exists KEYWORD2 18 | mkdir KEYWORD2 19 | remove KEYWORD2 20 | rmdir KEYWORD2 21 | open KEYWORD2 22 | close KEYWORD2 23 | seek KEYWORD2 24 | position KEYWORD2 25 | size KEYWORD2 26 | 27 | ####################################### 28 | # Constants (LITERAL1) 29 | ####################################### 30 | FILE_READ LITERAL1 31 | FILE_WRITE LITERAL1 32 | -------------------------------------------------------------------------------- /libraries/SD/library.properties: -------------------------------------------------------------------------------- 1 | name=SD 2 | version=1.2.4 3 | author=Arduino, SparkFun 4 | maintainer=Arduino 5 | sentence=Enables reading and writing on SD cards. 6 | paragraph=Once an SD memory card is connected to the SPI interface of the Arduino or Genuino board you can create files and read/write on them. You can also move through directories on the SD card. 7 | category=Data Storage 8 | url=http://www.arduino.cc/en/Reference/SD 9 | architectures=* 10 | -------------------------------------------------------------------------------- /libraries/SD/src/File.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SD - a slightly more friendly wrapper for sdfatlib 4 | 5 | This library aims to expose a subset of SD card functionality 6 | in the form of a higher level "wrapper" object. 7 | 8 | License: GNU General Public License V3 9 | (Because sdfatlib is licensed with this.) 10 | 11 | (C) Copyright 2010 SparkFun Electronics 12 | 13 | */ 14 | 15 | #include 16 | 17 | /* for debugging file open/close leaks 18 | uint8_t nfilecount=0; 19 | */ 20 | 21 | File::File(SdFile f, const char *n) { 22 | // oh man you are kidding me, new() doesn't exist? Ok we do it by hand! 23 | _file = (SdFile *)malloc(sizeof(SdFile)); 24 | if (_file) { 25 | memcpy(_file, &f, sizeof(SdFile)); 26 | 27 | strncpy(_name, n, 12); 28 | _name[12] = 0; 29 | 30 | /* for debugging file open/close leaks 31 | nfilecount++; 32 | Serial.print("Created \""); 33 | Serial.print(n); 34 | Serial.print("\": "); 35 | Serial.println(nfilecount, DEC); 36 | */ 37 | } 38 | } 39 | 40 | File::File(void) { 41 | _file = 0; 42 | _name[0] = 0; 43 | //Serial.print("Created empty file object"); 44 | } 45 | 46 | // returns a pointer to the file name 47 | char *File::name(void) { 48 | return _name; 49 | } 50 | 51 | // a directory is a special type of file 52 | boolean File::isDirectory(void) { 53 | return (_file && _file->isDir()); 54 | } 55 | 56 | 57 | size_t File::write(uint8_t val) { 58 | return write(&val, 1); 59 | } 60 | 61 | size_t File::write(const uint8_t *buf, size_t size) { 62 | size_t t; 63 | if (!_file) { 64 | setWriteError(); 65 | return 0; 66 | } 67 | _file->clearWriteError(); 68 | t = _file->write(buf, size); 69 | if (_file->getWriteError()) { 70 | setWriteError(); 71 | return 0; 72 | } 73 | return t; 74 | } 75 | 76 | int File::availableForWrite() { 77 | if (_file) { 78 | return _file->availableForWrite(); 79 | } 80 | return 0; 81 | } 82 | 83 | int File::peek() { 84 | if (! _file) { 85 | return 0; 86 | } 87 | 88 | int c = _file->read(); 89 | if (c != -1) { 90 | _file->seekCur(-1); 91 | } 92 | return c; 93 | } 94 | 95 | int File::read() { 96 | if (_file) { 97 | return _file->read(); 98 | } 99 | return -1; 100 | } 101 | 102 | // buffered read for more efficient, high speed reading 103 | int File::read(void *buf, uint16_t nbyte) { 104 | if (_file) { 105 | return _file->read(buf, nbyte); 106 | } 107 | return 0; 108 | } 109 | 110 | int File::available() { 111 | if (! _file) { 112 | return 0; 113 | } 114 | 115 | uint32_t n = size() - position(); 116 | 117 | return n > 0X7FFF ? 0X7FFF : n; 118 | } 119 | 120 | void File::flush() { 121 | if (_file) { 122 | _file->sync(); 123 | } 124 | } 125 | 126 | boolean File::seek(uint32_t pos) { 127 | if (! _file) { 128 | return false; 129 | } 130 | 131 | return _file->seekSet(pos); 132 | } 133 | 134 | uint32_t File::position() { 135 | if (! _file) { 136 | return -1; 137 | } 138 | return _file->curPosition(); 139 | } 140 | 141 | uint32_t File::size() { 142 | if (! _file) { 143 | return 0; 144 | } 145 | return _file->fileSize(); 146 | } 147 | 148 | void File::close() { 149 | if (_file) { 150 | _file->close(); 151 | free(_file); 152 | _file = 0; 153 | 154 | /* for debugging file open/close leaks 155 | nfilecount--; 156 | Serial.print("Deleted "); 157 | Serial.println(nfilecount, DEC); 158 | */ 159 | } 160 | } 161 | 162 | File::operator bool() { 163 | if (_file) { 164 | return _file->isOpen(); 165 | } 166 | return false; 167 | } 168 | 169 | -------------------------------------------------------------------------------- /libraries/SD/src/README.txt: -------------------------------------------------------------------------------- 1 | 2 | ** SD - a slightly more friendly wrapper for sdfatlib ** 3 | 4 | This library aims to expose a subset of SD card functionality in the 5 | form of a higher level "wrapper" object. 6 | 7 | License: GNU General Public License V3 8 | (Because sdfatlib is licensed with this.) 9 | 10 | (C) Copyright 2010 SparkFun Electronics 11 | 12 | Now better than ever with optimization, multiple file support, directory handling, etc - ladyada! 13 | 14 | -------------------------------------------------------------------------------- /libraries/SD/src/utility/SdFatUtil.h: -------------------------------------------------------------------------------- 1 | /* Arduino SdFat Library 2 | Copyright (C) 2008 by William Greiman 3 | 4 | This file is part of the Arduino SdFat Library 5 | 6 | This Library is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with the Arduino SdFat Library. If not, see 18 | . 19 | */ 20 | #ifndef SdFatUtil_h 21 | #define SdFatUtil_h 22 | /** 23 | \file 24 | Useful utility functions. 25 | */ 26 | #include 27 | #ifdef __AVR__ 28 | #include 29 | /** Store and print a string in flash memory.*/ 30 | #define PgmPrint(x) SerialPrint_P(PSTR(x)) 31 | /** Store and print a string in flash memory followed by a CR/LF.*/ 32 | #define PgmPrintln(x) SerialPrintln_P(PSTR(x)) 33 | /** Defined so doxygen works for function definitions. */ 34 | #endif 35 | #define NOINLINE __attribute__((noinline,unused)) 36 | #define UNUSEDOK __attribute__((unused)) 37 | //------------------------------------------------------------------------------ 38 | /** Return the number of bytes currently free in RAM. */ 39 | static UNUSEDOK int FreeRam(void) { 40 | extern int __bss_end; 41 | extern int* __brkval; 42 | int free_memory; 43 | if (reinterpret_cast(__brkval) == 0) { 44 | // if no heap use from end of bss section 45 | free_memory = reinterpret_cast(&free_memory) 46 | - reinterpret_cast(&__bss_end); 47 | } else { 48 | // use from top of stack to heap 49 | free_memory = reinterpret_cast(&free_memory) 50 | - reinterpret_cast(__brkval); 51 | } 52 | return free_memory; 53 | } 54 | #ifdef __AVR__ 55 | //------------------------------------------------------------------------------ 56 | /** 57 | %Print a string in flash memory to the serial port. 58 | 59 | \param[in] str Pointer to string stored in flash memory. 60 | */ 61 | static NOINLINE void SerialPrint_P(PGM_P str) { 62 | for (uint8_t c; (c = pgm_read_byte(str)); str++) { 63 | Serial.write(c); 64 | } 65 | } 66 | //------------------------------------------------------------------------------ 67 | /** 68 | %Print a string in flash memory followed by a CR/LF. 69 | 70 | \param[in] str Pointer to string stored in flash memory. 71 | */ 72 | static NOINLINE void SerialPrintln_P(PGM_P str) { 73 | SerialPrint_P(str); 74 | Serial.println(); 75 | } 76 | #endif // __AVR__ 77 | #endif // #define SdFatUtil_h 78 | -------------------------------------------------------------------------------- /libraries/SPI/DigitalPotControl/DigitalPotControl.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Digital Pot Control 3 | 4 | This example controls an Analog Devices AD5206 digital potentiometer. 5 | The AD5206 has 6 potentiometer channels. Each channel's pins are labeled 6 | A - connect this to voltage 7 | W - this is the pot's wiper, which changes when you set it 8 | B - connect this to ground. 9 | 10 | The AD5206 is SPI-compatible,and to command it, you send two bytes, 11 | one with the channel number (0 - 5) and one with the resistance value for the 12 | channel (0 - 255). 13 | 14 | The circuit: 15 | * All A pins of AD5206 connected to +5V 16 | * All B pins of AD5206 connected to ground 17 | * An LED and a 220-ohm resisor in series connected from each W pin to ground 18 | * CS - to digital pin 10 (SS pin) 19 | * SDI - to digital pin 11 (MOSI pin) 20 | * CLK - to digital pin 13 (SCK pin) 21 | 22 | created 10 Aug 2010 23 | by Tom Igoe 24 | 25 | Thanks to Heather Dewey-Hagborg for the original tutorial, 2005 26 | 27 | */ 28 | 29 | 30 | // inslude the SPI library: 31 | #include 32 | 33 | 34 | // set pin 10 as the slave select for the digital pot: 35 | const int slaveSelectPin = 10; 36 | 37 | void setup() { 38 | // set the slaveSelectPin as an output: 39 | pinMode(slaveSelectPin, OUTPUT); 40 | // initialize SPI: 41 | SPI.begin(); 42 | } 43 | 44 | void loop() { 45 | 46 | } 47 | 48 | void digitalPotWrite(int address, int value) { 49 | 50 | 51 | // send in the address and value via SPI: 52 | SPI.transfer(address); 53 | SPI.transfer(value); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /libraries/SPI/Spi_tx_dma/Spi_tx_dma.ino: -------------------------------------------------------------------------------- 1 | // W80x SPI & DMA libraries example 2 | // 3 | // Transfer data buffer via SPI asynchonically 4 | // 5 | // Dmitry Dmitriev (c) 2023 6 | 7 | 8 | #include 9 | #include 10 | 11 | // Data array to be send 12 | #define DATASIZE 128 13 | uint8_t pData[DATASIZE] = {0}; 14 | 15 | void setup() { 16 | SPI.begin(); 17 | Serial.begin(115200); 18 | 19 | // get hardware SPI handle, will used for setup dma transfer 20 | SPI_HandleTypeDef *hspi = SPI.getHalhandle(); 21 | 22 | // populate the data array 23 | for (int i = 0; i < DATASIZE; i++ ) { 24 | pData[i] = i; 25 | } 26 | 27 | //setup dma 28 | uint8_t dma_ch = claim_unused_dma_channel(); 29 | if (dma_ch != -1) { // dma channel available? 30 | 31 | // configure dma channel to be used in SPI_TX direction transfer 32 | DMA_HandleTypeDef* hdma = dma_simple_config(dma_ch, DMA_REQUEST_SOURCE_SPI_TX); 33 | 34 | // link dma channel with hspi handle 35 | __HAL_LINKDMA(hspi, hdmatx, *hdma); 36 | 37 | // init preconfigured dma channel 38 | dma_init(hdma); 39 | } 40 | 41 | //enable SPI interrupt 42 | HAL_NVIC_SetPriority(SPI_LS_IRQn, 1); 43 | HAL_NVIC_EnableIRQ(SPI_LS_IRQn); 44 | 45 | // transfer pData array via SPI with dma 46 | uint32_t res = HAL_SPI_Transmit_DMA(hspi, pData, sizeof(pData)); 47 | 48 | if (res == 0) Serial.printf("Data transferred successfully!\n"); 49 | else Serial.printf("Tranfer failed, HAL error code = %d\n", res); 50 | 51 | delay(200); 52 | 53 | // next.... 54 | /* 55 | res = HAL_SPI_Transmit_DMA(hspi, pData, sizeof(pData)); 56 | Serial.printf("HAL error code = %d\n", res); 57 | */ 58 | } 59 | 60 | void loop() { 61 | // put your main code here, to run repeatedly: 62 | delay(100); 63 | } 64 | -------------------------------------------------------------------------------- /libraries/SPI/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map SPI 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SPI KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | begin KEYWORD2 15 | end KEYWORD2 16 | transfer KEYWORD2 17 | #setBitOrder KEYWORD2 18 | setDataMode KEYWORD2 19 | setClockDivider KEYWORD2 20 | setMISO KEYWORD2 21 | setMOSI KEYWORD2 22 | setSCLK KEYWORD2 23 | setSSEL KEYWORD2 24 | 25 | ####################################### 26 | # Constants (LITERAL1) 27 | ####################################### 28 | SPI_MODE0 LITERAL1 29 | SPI_MODE1 LITERAL1 30 | SPI_MODE2 LITERAL1 31 | SPI_MODE3 LITERAL1 32 | 33 | SPI_CONTINUE LITERAL1 34 | SPI_LAST LITERAL1 35 | -------------------------------------------------------------------------------- /libraries/Wire/HardwareI2C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HardwareI2C.h" 3 | 4 | HardwareI2C::HardwareI2C() {} 5 | HardwareI2C::~HardwareI2C() {} 6 | 7 | void HardwareI2C::begin() { 8 | 9 | __HAL_RCC_I2C_CLK_ENABLE(); // Тактирование i2c контроллера 10 | __HAL_AFIO_REMAP_I2C_SCL(GPIOA, GPIO_PIN_1); // Переключение выводов 11 | __HAL_AFIO_REMAP_I2C_SDA(GPIOA, GPIO_PIN_4); // на I2C контроллер 12 | hi2c.Instance = I2C; 13 | hi2c.Frequency = 100000; // Частота тактирования по умолчанию 14 | HAL_I2C_Init(&hi2c); 15 | 16 | } 17 | void HardwareI2C::setClock(int clockFrequency) { 18 | 19 | hi2c.Frequency = clockFrequency; 20 | HAL_I2C_Init(&hi2c); 21 | 22 | } 23 | uchar HardwareI2C::beginTransmission(uchar addr) { 24 | 25 | HAL_I2C_Write_Byte(&hi2c, ((addr << 1) & 0xFE), 1); // Предваряя START сигнал 26 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) 27 | {HAL_I2C_Stop(&hi2c); 28 | return GETNAK;} 29 | else 30 | return GETACK; 31 | } 32 | uchar HardwareI2C::endTransmission() { 33 | 34 | HAL_I2C_Stop(&hi2c); 35 | return 0; 36 | } 37 | uchar HardwareI2C::write(uchar dta) { 38 | HAL_I2C_Write_Byte(&hi2c, dta, 0); // Без сигнала START 39 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) 40 | {HAL_I2C_Stop(&hi2c); 41 | return GETNAK;} 42 | else 43 | return GETACK; 44 | } 45 | uchar HardwareI2C::write(uint16_t len, uchar* dta) { 46 | for (uint16_t i = 0; i < len; i++) { 47 | HAL_I2C_Write_Byte(&hi2c, dta[i], 0); // Без сигнала START 48 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) 49 | { HAL_I2C_Stop(&hi2c); 50 | return GETNAK; 51 | } 52 | } 53 | return GETACK; 54 | } 55 | uchar HardwareI2C::requestFrom(uchar addr, uint16_t len) { 56 | 57 | recv_len = len; 58 | HAL_I2C_Write_Byte(&hi2c, ((addr << 1) | 0x01), 1); //Режим чтения 59 | if (HAL_I2C_Wait_Ack(&hi2c) != HAL_OK) 60 | {HAL_I2C_Stop(&hi2c); 61 | recv_len = 0; 62 | return GETNAK;} 63 | else 64 | return GETACK; 65 | 66 | } 67 | uchar HardwareI2C::read() { 68 | uchar dta; 69 | if (recv_len <= 0) { 70 | return 0; 71 | } 72 | recv_len--; 73 | if (recv_len > 0) dta = HAL_I2C_Read_Byte(&hi2c, 1, 0); // Отправляем ACK без сигнала STOP 74 | else dta = HAL_I2C_Read_Byte(&hi2c, 0, 1); // Последний принимаемый байт - Отправляем NAK и сигнал STOP 75 | return dta; 76 | } -------------------------------------------------------------------------------- /libraries/Wire/HardwareI2C.h: -------------------------------------------------------------------------------- 1 | #ifndef _HARDWAREI2C_H_ 2 | #define _HARDWAREI2C_H_ 3 | 4 | #include "Arduino.h" 5 | #include "Wire_base.h" 6 | 7 | 8 | /*#define GETACK 1 // get ack 9 | #define GETNAK 0 // get nak 10 | 11 | 12 | #ifndef uchar 13 | #define uchar unsigned char 14 | #endif*/ 15 | 16 | 17 | class HardwareI2C : public WireBase { 18 | private: 19 | 20 | I2C_HandleTypeDef hi2c; 21 | unsigned int recv_len; 22 | private: 23 | 24 | public: 25 | HardwareI2C(); 26 | ~HardwareI2C(); 27 | void begin(); // Инициализация контроллера i2c. Используются выводы PA1-SCL и PA4-SDA. Альтернативные выводы заняты под системные нужды (UART0) 28 | void setClock(int clockFrequency); // Установка тактовой частоты в герцах. Возможные значения от 100кГц до 1000кГц 29 | uchar beginTransmission(uchar addr); 30 | uchar endTransmission(); 31 | uchar write(uchar dta); 32 | uchar write(uint16_t len, uchar* dta); 33 | uchar requestFrom(uchar addr, uint16_t len); 34 | uchar read(); 35 | uchar available() {return recv_len;} 36 | /* NOT IMPLEMENTED YET */ 37 | //onReceive() 38 | //onRequest() 39 | //setWireTimeout() 40 | //clearWireTimeoutFlag() 41 | //getWireTimeoutFlag() 42 | 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /libraries/Wire/MPU_QMC_Test/YMFC-32_document_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/board707/w80x_arduino/3423446b2efcc2ef56a06394973327b9765179e6/libraries/Wire/MPU_QMC_Test/YMFC-32_document_1.pdf -------------------------------------------------------------------------------- /libraries/Wire/SoftwareI2C.h: -------------------------------------------------------------------------------- 1 | /* 2 | SoftwareI2C.h 3 | 2012 Copyright (c) Seeed Technology Inc. All right reserved. 4 | 5 | Author:Loovee 6 | 2013-11-1 7 | 8 | This is a Software I2C Library, can act as I2c master mode. 9 | 10 | 11 | This library is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU Lesser General Public 13 | License as published by the Free Software Foundation; either 14 | version 2.1 of the License, or (at your option) any later version. 15 | 16 | This library is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this library; if not, write to the Free Software 23 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | 26 | #ifndef _SOFTWAREI2C_H_ 27 | #define _SOFTWAREI2C_H_ 28 | 29 | #include "Arduino.h" 30 | #include "Wire_base.h" 31 | 32 | /* 33 | #define GETACK 1 // get ack 34 | #define GETNAK 0 // get nak 35 | 36 | #ifndef HIGH 37 | #define HIGH 1 38 | #endif 39 | #ifndef LOW 40 | #define LOW 0 41 | #endif 42 | 43 | #ifndef uchar 44 | #define uchar unsigned char 45 | #endif 46 | */ 47 | 48 | class SoftwareI2C : public WireBase{ 49 | private: 50 | 51 | int pinSda; 52 | int pinScl; 53 | int recv_len; 54 | int sda_in_out; 55 | 56 | private: 57 | 58 | inline void sdaSet(uchar ucDta); 59 | inline void sclSet(uchar ucDta); 60 | 61 | inline void sendStart(void); 62 | inline void sendStop(void); 63 | inline uchar getAck(void); 64 | inline void sendByte(uchar ucDta); 65 | inline uchar sendByteAck(uchar ucDta); // send byte and get ack 66 | 67 | public: 68 | 69 | SoftwareI2C(); 70 | ~SoftwareI2C(); 71 | 72 | void begin(int Sda, int Scl); 73 | uchar beginTransmission(uchar addr) override; 74 | uchar endTransmission() override; 75 | 76 | uchar write(uchar dta) override; 77 | uchar write(uint16_t len, uchar* dta) override; 78 | uchar requestFrom(uchar addr, uint16_t len) override; 79 | uchar read() override; 80 | uchar available() {return recv_len;}; 81 | void setClock(int clockFrequency) override {}; 82 | /* NOT IMPLEMENTED YET */ 83 | //setClock() 84 | //onReceive() 85 | //onRequest() 86 | //setWireTimeout() 87 | //clearWireTimeoutFlag() 88 | //getWireTimeoutFlag() 89 | }; 90 | 91 | #endif 92 | /********************************************************************************************************* 93 | END FILE 94 | *********************************************************************************************************/ 95 | -------------------------------------------------------------------------------- /libraries/Wire/TinyRTC_RW_eeprom/TinyRTC_RW_eeprom.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "Wire.h" 3 | 4 | #define TinyRTC_EEPROM 0x50 5 | 6 | void i2c_eeprom_write_page( int deviceaddress, unsigned int eeaddresspage, char* data, char length ) { 7 | Wire.beginTransmission(deviceaddress); 8 | Wire.write((int)(eeaddresspage >> 8)); // MSB 9 | Wire.write((int)(eeaddresspage & 0xFF)); // LSB 10 | uint8_t c; 11 | for ( c = 0; c < length; c++) 12 | Wire.write(data[c]); 13 | delayMicroseconds(10); // AT24C32 не успевает ответить 14 | Wire.endTransmission(); 15 | } 16 | 17 | char i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) { 18 | char rdata = 0xFF; 19 | Wire.beginTransmission(deviceaddress); 20 | Wire.write((int)(eeaddress >> 8)); // MSB 21 | Wire.write((int)(eeaddress & 0xFF)); // LSB 22 | Wire.endTransmission(); 23 | delayMicroseconds(10); // AT24C32 не успевает ответить 24 | Wire.requestFrom(deviceaddress, 1); 25 | if (Wire.available()) rdata = Wire.read(); 26 | return rdata; 27 | } 28 | 29 | void setup() 30 | { 31 | char somedata[] = "This is data from the eeprom"; // data to write 32 | 33 | Wire.begin(); // Hardware I2C (PA4 = SDA, PA1 = SCL by default) 34 | //Wire.begin(PA12,PA14); // Software I2C (SDA, SCL) - any pins 35 | 36 | i2c_eeprom_write_page(TinyRTC_EEPROM, 0, (char *)somedata, sizeof(somedata)); // write to EEPROM 37 | Serial.begin(115200); 38 | } 39 | 40 | void loop() 41 | { 42 | int addr = 0; //first address 43 | char b = i2c_eeprom_read_byte(TinyRTC_EEPROM, 0); // access the first address from the memory 44 | 45 | while (b != 0) 46 | { 47 | Serial.printf("%c", (char)b); //print content to serial port 48 | addr++; //increase address 49 | b = i2c_eeprom_read_byte(TinyRTC_EEPROM, addr); //access an address from the memory 50 | 51 | } 52 | Serial.printf(" \n\r"); 53 | delay(2000); 54 | } -------------------------------------------------------------------------------- /libraries/Wire/Wire.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file WireBase.h 3 | * 4 | * @author Dmitry DMitriev 5 | * @brief Wire library for Arduino. 6 | * Provides a 'standard' interface to I2C 7 | */ 8 | 9 | 10 | #ifndef _WIRE_H_ 11 | #define _WIRE_H_ 12 | 13 | #include "Arduino.h" 14 | #include "HardwareI2C.h" 15 | #include "SoftwareI2C.h" 16 | 17 | #define BUFFER_LENGTH 64 18 | 19 | #define Hard_I2C 0 20 | #define Soft_I2C 1 21 | 22 | 23 | class TwoWire { 24 | protected: 25 | WireBase* i2c_dev = NULL; 26 | bool i2c_type = Hard_I2C; 27 | bool is_initialized = false; 28 | uint8_t addr; 29 | 30 | uint8_t rx_buf[BUFFER_LENGTH]; /* receive buffer */ 31 | uint8_t rx_buf_st; /* first unread idx in rx_buf */ 32 | uint8_t rx_buf_end; /* last unread byte in buf */ 33 | 34 | uint8_t tx_buf[BUFFER_LENGTH]; /* transmit buffer */ 35 | uint8_t tx_buf_idx; // next idx available in tx_buf 36 | //bool tx_buf_overflow; 37 | 38 | 39 | public: 40 | TwoWire(); 41 | ~TwoWire(); 42 | 43 | /* 44 | * Initialises the class interface 45 | */ 46 | 47 | void begin(void); 48 | void begin(uint8_t Sda, uint8_t Scl); 49 | 50 | /* 51 | * Sets up the transmission message to be processed 52 | */ 53 | void beginTransmission(uint8_t); 54 | void beginTransmission(int); 55 | 56 | /* 57 | * Process TX buffer 58 | */ 59 | uint8_t endTransmission(bool); 60 | uint8_t endTransmission(void); 61 | 62 | /* 63 | * Request bytes from a slave device and process the request, 64 | * storing into the receiving buffer. 65 | */ 66 | uint8_t requestFrom(uint8_t, int); 67 | uint8_t requestFrom(int, int); 68 | // added for compatibility 69 | uint8_t requestFrom(int addr, int len, int stop) { 70 | UNUSED(stop); 71 | return requestFrom(addr, len); 72 | } 73 | /* 74 | * Stack up bytes to be sent when transmitting 75 | */ 76 | 77 | uint8_t write(uint8_t); 78 | uint8_t write(uint8_t*, int); 79 | uint8_t write(int); 80 | 81 | // added for compatibility 82 | uint8_t write(const uint8_t* data, int len) { 83 | uint8_t* dt = (uint8_t*)data; 84 | return write(dt, len); 85 | } 86 | 87 | 88 | /* 89 | * Stack up bytes from a string to be sent when transmitting 90 | */ 91 | uint8_t write(char*); 92 | 93 | /* 94 | * Return the amount of bytes that is currently in the receiving buffer 95 | */ 96 | uint8_t available(); 97 | 98 | /* 99 | * Return the value of byte in the receiving buffer that is currently being 100 | * pointed to 101 | */ 102 | int read(); 103 | 104 | void setClock(int clockFrequency); 105 | 106 | /* 107 | * Deinitialize the Wire interface. 108 | * Do nothing yet. Added for compatibility. 109 | * 110 | */ 111 | void end() {} 112 | 113 | }; 114 | 115 | extern TwoWire Wire; 116 | #endif // _WIRE_H_ 117 | -------------------------------------------------------------------------------- /libraries/Wire/Wire_base.cpp: -------------------------------------------------------------------------------- 1 | #include "Wire_base.h" 2 | 3 | //WireBase::~WireBase() {} 4 | WireBase::WireBase() {} 5 | WireBase::~WireBase() {} 6 | //extern "C" void __cxa_pure_virtual() { while (1); } 7 | -------------------------------------------------------------------------------- /libraries/Wire/Wire_base.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _WIREBASE_H_ 3 | #define _WIREBASE_H_ 4 | 5 | #include "Arduino.h" 6 | 7 | #define GETACK 1 // get ack 8 | #define GETNAK 0 // get nak 9 | 10 | #ifndef HIGH 11 | #define HIGH 1 12 | #endif 13 | #ifndef LOW 14 | #define LOW 0 15 | #endif 16 | 17 | #ifndef uchar 18 | #define uchar unsigned char 19 | #endif 20 | 21 | class WireBase { 22 | 23 | 24 | public: 25 | 26 | //void begin(int Sda, int Scl); 27 | WireBase(); 28 | virtual ~WireBase(); 29 | virtual uchar beginTransmission(uchar addr) {return 0;}; 30 | virtual uchar endTransmission() {return 0;}; 31 | 32 | virtual uchar write(uchar dta) {return 0;}; 33 | virtual uchar write(uint16_t len, uchar* dta) {return 0;}; 34 | virtual uchar requestFrom(uchar addr, uint16_t len) {return 0;}; 35 | virtual uchar read() {return 0;}; 36 | //uchar available() {return recv_len;} 37 | virtual void setClock(int clockFrequency) {};// Установка тактовой частоты в герцах. Возможные значения от 100кГц до 1000кГц 38 | 39 | }; 40 | #endif 41 | -------------------------------------------------------------------------------- /libraries/Wire/i2c_scanner/i2c_scanner.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "Wire.h" 3 | 4 | uint8_t dev_i2c[128] = {0}; 5 | 6 | void setup() 7 | { 8 | Wire.begin(); // Hardware I2C (PA4 = SDA, PA1 = SCL by default) 9 | //Wire.begin(PA12,PA14); // Software I2C (SDA, SCL) - any pins 10 | Serial.begin(115200); // Arduino Serial communication. Recommended speed for w80x 11 | Serial.println("I2C Scanner"); 12 | } 13 | 14 | 15 | void loop() 16 | { 17 | uint8_t error, address; 18 | int nDevices; 19 | 20 | Serial.println("Scanning..."); 21 | 22 | nDevices = 0; 23 | for (address = 1; address < 127; address++ ) 24 | { 25 | // The i2c_scanner uses the return value of 26 | // the Write.endTransmisstion to see if 27 | // a device did acknowledge to the address. 28 | delayMicroseconds(10); //Timeout must be! 29 | Wire.beginTransmission(address); 30 | error = Wire.endTransmission(); 31 | 32 | if (error == 0) 33 | { 34 | dev_i2c[nDevices] = address; 35 | nDevices++; 36 | } 37 | else if (error == 4) 38 | { 39 | Serial.print("Unknown error at address [0x"); 40 | Serial.print(address, HEX); 41 | Serial.println("]"); 42 | } 43 | } 44 | if (nDevices == 0) Serial.println("No I2C devices found."); 45 | else { 46 | Serial.println("Scan complete..."); 47 | for (address = 0; address < nDevices; address++) { 48 | Serial.print("Found i2c device at address [0x"); 49 | Serial.print(dev_i2c[address], HEX); 50 | Serial.println("]"); 51 | } 52 | Serial.println("done..."); 53 | } 54 | delay(5000); // wait 5 seconds for next scan 55 | } -------------------------------------------------------------------------------- /libraries/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Ultrasound 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | digitalToggle KEYWORD2 13 | sysClock KEYWORD2 14 | sysClockPrescale KEYWORD2 15 | sysClockOutput KEYWORD2 16 | 17 | ####################################### 18 | # Constants (LITERAL1) 19 | ####################################### 20 | E0 LITERAL1 21 | E1 LITERAL1 22 | E2 LITERAL1 23 | E3 LITERAL1 24 | E4 LITERAL1 25 | E5 LITERAL1 26 | E6 LITERAL1 27 | E7 LITERAL1 28 | B6 LITERAL1 29 | B7 LITERAL1 30 | C7 LITERAL1 31 | F0 LITERAL1 32 | F1 LITERAL1 33 | F2 LITERAL1 34 | F3 LITERAL1 35 | F4 LITERAL1 36 | F5 LITERAL1 37 | F6 LITERAL1 38 | F7 LITERAL1 39 | INT_OSC_32K LITERAL1 40 | INT_OSC_32M LITERAL1 41 | SYSCLK_DIV_0 LITERAL1 42 | SYSCLK_DIV_2 LITERAL1 43 | SYSCLK_DIV_4 LITERAL1 44 | SYSCLK_DIV_8 LITERAL1 45 | SYSCLK_DIV_16 LITERAL1 46 | SYSCLK_DIV_32 LITERAL1 47 | SYSCLK_DIV_64 LITERAL1 48 | SYSCLK_DIV_128 LITERAL1 49 | ADC10BIT LITERAL1 50 | ADC12BIT LITERAL1 51 | DEFAULT LITERAL1 52 | EXTERNAL LITERAL1 53 | INTERNAL1V024 LITERAL1 54 | INTERNAL2V048 LITERAL1 55 | INTERNAL4V096 LITERAL1 56 | -------------------------------------------------------------------------------- /libraries/w80x_test_lvgl/driver.h: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #define SDIO_HOST ((SDIO_TypeDef *)SDIO_BASE) 3 | 4 | #define LCD_SCL_PIN PB6 // SCL 5 | #define LCD_MOSI_PIN PB7 // MOSI 6 | 7 | static DMA_HandleTypeDef hdma_sdspi_tx; 8 | 9 | void init_sdio_spi_mode() 10 | { 11 | __HAL_RCC_SDIO_CLK_ENABLE(); 12 | __HAL_RCC_DMA_CLK_ENABLE(); 13 | __HAL_AFIO_REMAP_SDIO_CLK(pin_Map[LCD_SCL_PIN].pPort, pin_Map[LCD_SCL_PIN].halPin); /*CK*/ 14 | __HAL_AFIO_REMAP_SDIO_CMD(pin_Map[LCD_MOSI_PIN].pPort, pin_Map[LCD_MOSI_PIN].halPin); /*CMD*/ 15 | 16 | hdma_sdspi_tx.Instance = DMA_Channel0; 17 | hdma_sdspi_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; 18 | hdma_sdspi_tx.Init.DestInc = DMA_DINC_DISABLE; 19 | hdma_sdspi_tx.Init.SrcInc = DMA_SINC_ENABLE; 20 | hdma_sdspi_tx.Init.DataAlignment = DMA_DATAALIGN_WORD; 21 | hdma_sdspi_tx.Init.Mode = DMA_MODE_NORMAL_SINGLE; 22 | hdma_sdspi_tx.Init.RequestSourceSel = DMA_REQUEST_SOURCE_SDIO; 23 | 24 | HAL_DMA_Init(&hdma_sdspi_tx); 25 | 26 | CLEAR_BIT(RCC->RST, RCC_RST_SDIO); // Программный сброс контроллера SDIO 27 | SET_BIT(RCC->RST, RCC_RST_SDIO); 28 | while (READ_BIT(RCC->RST, RCC_RST_SDIO) == 0); 29 | // Тактирование расчитывается исходя из тактовой частоты процессора. 30 | // В данном случае cpuclk/2 31 | wm_sys_clk sysclk; 32 | SystemClock_Get(&sysclk); 33 | SDIO_HOST->SEL = 0xC0 | (sysclk.cpuclk / 2 - 1); // enable module, enable mmcclk 34 | SDIO_HOST->CR = 0x542 | 1 << 3;// auto transfer, mmc mode. 35 | //SDIO_HOST->CR = 0x542 | (0b111 << 3); // 111 1/16 for debug 36 | SDIO_HOST->IM = 0x100; // unmask sdio data interrupt. 37 | SDIO_HOST->CRCCTL = 0x00; 38 | SDIO_HOST->TIMEOUT = 0; 39 | SDIO_HOST->BYTECNT = 0; 40 | } 41 | 42 | void sdio_spi_put(uint8_t d) //Transfer one byte 43 | { 44 | SDIO_HOST->BUFCR = 0x4820; 45 | SDIO_HOST->DATABUF[0] = d; 46 | 47 | SDIO_HOST->BYTECNT = 1; 48 | SDIO_HOST->IO = 0x01; 49 | while (1) { 50 | if ((SDIO_HOST->IO & 0x01) == 0x00) 51 | break; 52 | } 53 | } 54 | 55 | void write_sdio_spi_dma(uint32_t* data, uint32_t len) 56 | { 57 | while(1){ 58 | if ((SDIO_HOST->IO & 0x01) == 0x00) 59 | break; 60 | } 61 | uint32_t offset=0; 62 | while(len>0){ 63 | int datalen=len; 64 | if(len>0xfffc) 65 | datalen=0xfffc; 66 | len-=datalen; 67 | SDIO_HOST->BUFCR = 0x4000; //disable dma, 68 | HAL_DMA_Start(&hdma_sdspi_tx, (uint32_t) (data+offset), (uint32_t)(SDIO_HOST->DATABUF), datalen); 69 | SDIO_HOST->BUFCR = 0xC20; //enable dma, write 70 | SDIO_HOST->IF |= 0x7ff; // clear all firstly 71 | SDIO_HOST->BYTECNT = datalen; 72 | SDIO_HOST->IO = 0x01; 73 | offset+=datalen/4; 74 | HAL_DMA_PollForTransfer(&hdma_sdspi_tx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY); 75 | while(1){ 76 | if ((SDIO_HOST->BUFCR & 0x400) == 0x00) // Ожидание завершения передачи блока 77 | break; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /libraries/w80x_test_lvgl/w80x_test_lvgl.ino: -------------------------------------------------------------------------------- 1 | /*Using LVGL with Arduino requires some extra steps: 2 | *Be sure to read the docs here: https://docs.lvgl.io/master/get-started/platforms/arduino.html */ 3 | 4 | /* 5 | Connect your TFT display like this: 6 | TFT_VCC to power 7 | TFT_GND to ground 8 | TFT_CS to ground 9 | TFT_LED to power 10 | TFT_SCL PB6 11 | TFT_MOSI PB7 12 | TFT_DC PB8 13 | TFT_RST PB9 14 | */ 15 | 16 | #include 17 | #include "ILI9341_Fast_SDIO.h" 18 | #include "Arduino.h" 19 | 20 | static const uint16_t screenWidth = LCD_WIDTH; 21 | static const uint16_t screenHeight = LCD_HEIGHT; 22 | 23 | 24 | static lv_disp_draw_buf_t draw_buf ; 25 | static lv_color_t buf[ screenWidth * screenHeight / 10 ]; 26 | 27 | #define TFT_DC PB8 28 | #define TFT_RST PB9 29 | 30 | /* Display flushing */ 31 | void my_disp_flush( lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p ) 32 | { 33 | Lcd_Draw_Rect(area->x1,area->y1,area->x2 - area->x1 + 1,area->y2 - area->y1 + 1,(uint16_t*)color_p); 34 | lv_disp_flush_ready( disp_drv ); 35 | } 36 | 37 | void setup() 38 | { 39 | Serial.begin( 115200 ); /* prepare for possible serial debug */ 40 | 41 | String LVGL_Arduino = "Hello Arduino! "; 42 | LVGL_Arduino += String('V') + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch(); 43 | 44 | Serial.println( LVGL_Arduino ); 45 | Serial.println( "I am LVGL_Arduino" ); 46 | 47 | lv_init(); 48 | 49 | Lcd_Init(TFT_DC, TFT_RST); /* TFT init. TFT_CS pin on GND*/ 50 | Lcd_Orientation(3); /* Landscape orientation, flipped */ 51 | lv_disp_draw_buf_init( &draw_buf, buf, NULL, screenWidth * screenHeight/10 ); 52 | 53 | /*Initialize the display*/ 54 | static lv_disp_drv_t disp_drv; 55 | lv_disp_drv_init( &disp_drv ); 56 | /*Change the following line to your display resolution*/ 57 | disp_drv.hor_res = screenWidth; 58 | disp_drv.ver_res = screenHeight; 59 | disp_drv.flush_cb = my_disp_flush; 60 | disp_drv.draw_buf = &draw_buf; 61 | lv_disp_drv_register( &disp_drv ); 62 | 63 | Serial.println( "Setup done" ); 64 | 65 | lv_obj_t * label1 = lv_label_create(lv_scr_act()); 66 | lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/ 67 | lv_label_set_recolor(label1, true); /*Enable re-coloring by commands in the text*/ 68 | lv_label_set_text(label1, "#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center " 69 | "and wrap long text automatically."); 70 | lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/ 71 | lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0); 72 | lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40); 73 | 74 | lv_obj_t * label2 = lv_label_create(lv_scr_act()); 75 | lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/ 76 | lv_obj_set_width(label2, 150); 77 | lv_label_set_text(label2, "It is a circularly scrolling text. "); 78 | lv_obj_align(label2, LV_ALIGN_CENTER, 0, 40); 79 | 80 | } 81 | 82 | void loop() 83 | { 84 | lv_timer_handler(); /* let the GUI do its work */ 85 | delay( 5 ); 86 | } 87 | -------------------------------------------------------------------------------- /variants/air101/pins_arduino.h: -------------------------------------------------------------------------------- 1 | // pin description for Air101 board 2 | #ifndef Pins_Arduino_h 3 | #define Pins_Arduino_h 4 | 5 | #include "./include/driver/wm_hal.h" 6 | #include 7 | 8 | // pin enum - index of an array of possible alternatives 9 | enum pins 10 | { 11 | PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PA8,PA9,PA10,PA11,PA12,PA13,PA14,PA15, 12 | PB0,PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8,PB9,PB10,PB11,PB12,PB13,PB14,PB15, 13 | PB16,PB17,PB18,PB19,PB20,PB21,PB22,PB23,PB24,PB25,PB26,PB27 14 | }; 15 | 16 | // Arduino macros for analog inputs 17 | #define A0 PA1 18 | #define A1 PA4 19 | 20 | // pin mux macros for Air101 21 | #define MUX_PA0 (NONE) // Boot 22 | #define MUX_PA1 (DIO | ADC1 | PWM3) // JTAG_CK 23 | #define MUX_PA2 (NONE) 24 | #define MUX_PA3 (NONE) 25 | #define MUX_PA4 (DIO | ADC2 | PWM4) // JTAG_SWO 26 | #define MUX_PA5 (NONE) 27 | #define MUX_PA6 (NONE) 28 | #define MUX_PA7 (DIO | PWM4 | _SPI_MOSI) 29 | #define MUX_PA8 (NONE) 30 | #define MUX_PA9 (NONE) 31 | #define MUX_PA10 (NONE) 32 | #define MUX_PA11 (NONE) 33 | #define MUX_PA12 (NONE) 34 | #define MUX_PA13 (NONE) 35 | #define MUX_PA14 (NONE) 36 | #define MUX_PA15 (NONE) 37 | 38 | #define MUX_PB0 (DIO | PWM0 | _SPI_MISO) 39 | #define MUX_PB1 (DIO | PWM1 | _SPI_SCK) 40 | #define MUX_PB2 (DIO | PWM2 | _SPI_SCK) 41 | #define MUX_PB3 (DIO | PWM3 | _SPI_MISO) 42 | #define MUX_PB4 (DIO | _SPI_SS) 43 | #define MUX_PB5 (DIO | _SPI_MOSI) 44 | #define MUX_PB6 (DIO) 45 | #define MUX_PB7 (DIO) 46 | #define MUX_PB8 (DIO) //LED_BUILTIN1 47 | #define MUX_PB9 (DIO) //LED_BUILTIN2 48 | #define MUX_PB10 (DIO) //LED_BUILTIN3 49 | #define MUX_PB11 (DIO) 50 | #define MUX_PB12 (NONE) 51 | #define MUX_PB13 (NONE) 52 | #define MUX_PB14 (NONE) 53 | #define MUX_PB15 (NONE) 54 | #define MUX_PB16 (NONE) 55 | #define MUX_PB17 (NONE) 56 | #define MUX_PB18 (NONE) 57 | #define MUX_PB19 (NONE) // TX0: used to download firmware and output to console 58 | #define MUX_PB20 (NONE) // RX0: debug data via printf() 59 | #define MUX_PB21 (NONE) 60 | #define MUX_PB22 (NONE) 61 | #define MUX_PB23 (NONE) 62 | #define MUX_PB24 (NONE) 63 | #define MUX_PB25 (NONE) 64 | #define MUX_PB26 (NONE) 65 | #define MUX_PB27 (NONE) 66 | 67 | extern const PIN_MAP pin_Map[]; 68 | 69 | // Additional board settings 70 | #include "variant.h" 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /variants/air101/variant.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARIANT_ARDUINO_Air101_ 2 | #define _VARIANT_ARDUINO_Air101_ 3 | 4 | #define LED_BUILTIN_1 PB8 5 | #define LED_BUILTIN_2 PB9 6 | #define LED_BUILTIN_3 PB10 7 | #define LED_BUILTIN LED_BUILTIN_1 8 | 9 | // SPI 10 | #define PIN_SPI_SS (PB4) 11 | #define PIN_SPI_SCK (PB2) 12 | #define PIN_SPI_MISO (PB3) 13 | #define PIN_SPI_MOSI (PB5) 14 | 15 | #define PINS_COUNT (44U) // pins in total 16 | #define ADC_COUNT (2U) // number of ADC channels 17 | #define PWM_COUNT (5U) // number of PWM channels 18 | 19 | #endif /* _VARIANT_ARDUINO_W801_ */ 20 | -------------------------------------------------------------------------------- /variants/air103/pins_arduino.h: -------------------------------------------------------------------------------- 1 | // pin description for Air103 board 2 | #ifndef Pins_Arduino_h 3 | #define Pins_Arduino_h 4 | 5 | #include "./include/driver/wm_hal.h" 6 | #include 7 | 8 | // pin enum - index of an array of possible alternatives 9 | enum pins 10 | { 11 | PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PA8,PA9,PA10,PA11,PA12,PA13,PA14,PA15, 12 | PB0,PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8,PB9,PB10,PB11,PB12,PB13,PB14,PB15, 13 | PB16,PB17,PB18,PB19,PB20,PB21,PB22,PB23,PB24,PB25,PB26,PB27 14 | }; 15 | 16 | // Arduino style analog inputs 17 | #define A1 PA1 18 | #define A2 PA2 19 | #define A3 PA3 20 | #define A4 PA4 21 | 22 | // add A0 as alias to A1 for compatibility 23 | #define A0 A1 24 | 25 | // pin mux macros for Air103 26 | #define MUX_PA0 (DIO | PWM2 | _SPI_SS) // Boot 27 | #define MUX_PA1 (DIO | ADC1 | PWM3) // JTAG_CK 28 | #define MUX_PA2 (DIO | ADC4 | PWM0) 29 | #define MUX_PA3 (DIO | ADC3 | PWM1) 30 | #define MUX_PA4 (DIO | ADC2 | PWM4) // JTAG_SWO 31 | #define MUX_PA5 (NONE) // not connected on PCB 32 | #define MUX_PA6 (NONE) // not connected on PCB 33 | #define MUX_PA7 (DIO | PWM4 | _SPI_MOSI) 34 | #define MUX_PA8 (DIO) 35 | #define MUX_PA9 (DIO) 36 | #define MUX_PA10 (DIO | PWM0) 37 | #define MUX_PA11 (DIO | PWM1) 38 | #define MUX_PA12 (DIO | PWM2) 39 | #define MUX_PA13 (DIO | PWM3) 40 | #define MUX_PA14 (DIO | PWM4) 41 | #define MUX_PA15 (DIO) // only connected to PSRAM SCLK 42 | 43 | #define MUX_PB0 (DIO | PWM0 | _SPI_MISO) 44 | #define MUX_PB1 (DIO | PWM1 | _SPI_SCK) 45 | #define MUX_PB2 (DIO | PWM2 | _SPI_SCK) // connected to PSRAM SI/SIO0 46 | #define MUX_PB3 (DIO | PWM3 | _SPI_MISO) // connected to PSRAM SI/SIO1 47 | #define MUX_PB4 (DIO | _SPI_SS) // connected to PSRAM SI/SIO2 48 | #define MUX_PB5 (DIO | _SPI_MOSI) // connected to PSRAM SI/SIO4 49 | #define MUX_PB6 (DIO) 50 | #define MUX_PB7 (DIO) 51 | #define MUX_PB8 (DIO) 52 | #define MUX_PB9 (DIO) 53 | #define MUX_PB10 (DIO) 54 | #define MUX_PB11 (DIO) 55 | #define MUX_PB12 (DIO | PWM0) 56 | #define MUX_PB13 (DIO | PWM1) 57 | #define MUX_PB14 (DIO | PWM2 | _SPI_SS) // PIN_SPI_SS 58 | #define MUX_PB15 (DIO | PWM3 | _SPI_SCK) // PIN_SPI_SCK 59 | #define MUX_PB16 (DIO | _SPI_MISO) // PIN_SPI_MISO 60 | #define MUX_PB17 (DIO | _SPI_MOSI) // PIN_SPI_MOSI 61 | #define MUX_PB18 (DIO) 62 | #define MUX_PB19 (NONE) // TX0: used to download firmware and output to console 63 | #define MUX_PB20 (NONE) // RX0: debug data via printf() 64 | #define MUX_PB21 (NONE) // not connected on PCB 65 | #define MUX_PB22 (NONE) // not connected on PCB 66 | #define MUX_PB23 (NONE) // no pin for PB23 on W806 package 67 | #define MUX_PB24 (DIO | PWM2) // only connected to LED_BUILTIN_1 68 | #define MUX_PB25 (DIO | PWM3) // only connected to LED_BUILTIN_2 69 | #define MUX_PB26 (DIO | PWM4) // only connected to LED_BUILTIN_3 70 | #define MUX_PB27 (DIO) // only connected to PSRAM CS 71 | 72 | extern const PIN_MAP pin_Map[]; 73 | 74 | // Additional board settings 75 | #include "variant.h" 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /variants/air103/variant.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARIANT_ARDUINO_Air103_ 2 | #define _VARIANT_ARDUINO_Air103_ 3 | 4 | #define LED_BUILTIN_1 PB24 5 | #define LED_BUILTIN_2 PB25 6 | #define LED_BUILTIN_3 PB26 7 | #define LED_BUILTIN LED_BUILTIN_1 8 | 9 | // SPI 10 | #define PIN_SPI_SS (PB14) 11 | #define PIN_SPI_SCK (PB15) 12 | #define PIN_SPI_MISO (PB16) 13 | #define PIN_SPI_MOSI (PB17) 14 | 15 | #define PINS_COUNT (44U) // pins in total, PA5, PA6, PB19, PB20, PB21, PB22 and PB23 are not used 16 | #define ADC_COUNT (4U) // number of ADC channels 17 | #define PWM_COUNT (5U) // number of PWM channels 18 | 19 | #endif /* _VARIANT_ARDUINO_Air103_ */ 20 | -------------------------------------------------------------------------------- /variants/w800/pins_arduino.h: -------------------------------------------------------------------------------- 1 | // pin description for HLK-W800-KIT board 2 | #ifndef Pins_Arduino_h 3 | #define Pins_Arduino_h 4 | 5 | #include "./include/driver/wm_hal.h" 6 | #include 7 | 8 | // pin enum - index of an array of possible alternatives 9 | enum pins 10 | { 11 | PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PA8,PA9,PA10,PA11,PA12,PA13,PA14,PA15, 12 | PB0,PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8,PB9,PB10,PB11,PB12,PB13,PB14,PB15, 13 | PB16,PB17,PB18,PB19,PB20,PB21,PB22,PB23,PB24,PB25,PB26,PB27 14 | }; 15 | 16 | // Arduino macros for analog inputs 17 | #define A1 PA1 18 | #define A2 PA2 19 | #define A3 PA3 20 | #define A4 PA4 21 | 22 | // add A0 as alias to A1 for compatibility 23 | #define A0 A1 24 | 25 | // pin mux macros for W806 26 | #define MUX_PA0 (PWM2| _SPI_SS) // Boot 27 | #define MUX_PA1 (DIO | ADC1 | PWM3) // JTAG_CK 28 | #define MUX_PA2 (NONE) 29 | #define MUX_PA3 (NONE) 30 | #define MUX_PA4 (DIO | ADC2 | PWM4) // JTAG_SWO 31 | #define MUX_PA5 (NONE) 32 | #define MUX_PA6 (NONE) 33 | #define MUX_PA7 (DIO | PWM4 | _SPI_MOSI) 34 | #define MUX_PA8 (NONE) 35 | #define MUX_PA9 (NONE) 36 | #define MUX_PA10 (NONE) 37 | #define MUX_PA11 (NONE) 38 | #define MUX_PA12 (NONE) 39 | #define MUX_PA13 (NONE) 40 | #define MUX_PA14 (NONE) 41 | #define MUX_PA15 (NONE) 42 | 43 | #define MUX_PB0 (DIO | PWM0 | _SPI_MISO) // LED_BUILTIN_1 44 | #define MUX_PB1 (DIO | PWM1 | _SPI_SCK) // LED_BUILTIN_2 45 | #define MUX_PB2 (DIO | PWM2 | _SPI_SCK) // LED_BUILTIN_3 46 | #define MUX_PB3 (DIO | PWM3 | _SPI_MISO) 47 | #define MUX_PB4 (DIO | _SPI_SS) 48 | #define MUX_PB5 (DIO | _SPI_MOSI) 49 | #define MUX_PB6 (DIO) 50 | #define MUX_PB7 (DIO) 51 | #define MUX_PB8 (DIO) 52 | #define MUX_PB9 (DIO) 53 | #define MUX_PB10 (DIO) 54 | #define MUX_PB11 (DIO) 55 | #define MUX_PB12 (NONE) 56 | #define MUX_PB13 (NONE) 57 | #define MUX_PB14 (NONE) 58 | #define MUX_PB15 (NONE) 59 | #define MUX_PB16 (NONE) 60 | #define MUX_PB17 (NONE) 61 | #define MUX_PB18 (NONE) 62 | #define MUX_PB19 (NONE) // TX0: used to download firmware and output to console 63 | #define MUX_PB20 (NONE) // RX0: debug data via printf() 64 | #define MUX_PB21 (NONE) 65 | #define MUX_PB22 (NONE) 66 | #define MUX_PB23 (NONE) // no pin for PB23 on W806 package 67 | #define MUX_PB24 (NONE) 68 | #define MUX_PB25 (NONE) 69 | #define MUX_PB26 (NONE) 70 | #define MUX_PB27 (NONE) 71 | 72 | extern const PIN_MAP pin_Map[]; 73 | 74 | // Additional board settings 75 | #include "variant.h" 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /variants/w800/variant.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARIANT_ARDUINO_W800_ 2 | #define _VARIANT_ARDUINO_W800_ 3 | 4 | #define LED_BUILTIN_1 PB0 5 | #define LED_BUILTIN_2 PB1 6 | #define LED_BUILTIN_3 PB2 7 | #define LED_BUILTIN LED_BUILTIN_1 8 | 9 | // SPI 10 | #define PIN_SPI_SS (PB4) 11 | #define PIN_SPI_SCK (PB1) 12 | #define PIN_SPI_MISO (PB0) 13 | #define PIN_SPI_MOSI (PB5) 14 | 15 | #define PINS_COUNT (44U) // pins in total, PB19, PB20 and PB23 are not used 16 | #define ADC_COUNT (4U) // number of ADC channels 17 | #define PWM_COUNT (5U) // number of PWM channels 18 | 19 | #endif /* _VARIANT_ARDUINO_W800_ */ 20 | -------------------------------------------------------------------------------- /variants/w801/pins_arduino.h: -------------------------------------------------------------------------------- 1 | // pin description for W801 board 2 | #ifndef Pins_Arduino_h 3 | #define Pins_Arduino_h 4 | 5 | #include "./include/driver/wm_hal.h" 6 | #include 7 | 8 | // pin enum - index of an array of possible alternatives 9 | enum pins 10 | { 11 | PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PA8,PA9,PA10,PA11,PA12,PA13,PA14,PA15, 12 | PB0,PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8,PB9,PB10,PB11,PB12,PB13,PB14,PB15, 13 | PB16,PB17,PB18,PB19,PB20,PB21,PB22,PB23,PB24,PB25,PB26,PB27 14 | }; 15 | 16 | // Arduino macros for analog inputs 17 | #define A1 PA1 18 | #define A2 PA2 19 | #define A3 PA3 20 | #define A4 PA4 21 | 22 | // add A0 as alias to A1 for compatibility 23 | #define A0 A1 24 | 25 | // pin mux macros for W801 26 | #define MUX_PA0 (DIO | PWM2 | _SPI_SS) // Boot 27 | #define MUX_PA1 (DIO | ADC1 | PWM3) // JTAG_CK 28 | #define MUX_PA2 (DIO | ADC4 | PWM0) 29 | #define MUX_PA3 (DIO | ADC3 | PWM1) 30 | #define MUX_PA4 (DIO | ADC2 | PWM4) // JTAG_SWO 31 | #define MUX_PA5 (DIO) 32 | #define MUX_PA6 (DIO) 33 | #define MUX_PA7 (DIO | PWM4 | _SPI_MOSI) 34 | #define MUX_PA8 (DIO) 35 | #define MUX_PA9 (DIO) 36 | #define MUX_PA10 (DIO | PWM0) 37 | #define MUX_PA11 (DIO | PWM1) 38 | #define MUX_PA12 (DIO | PWM2) 39 | #define MUX_PA13 (DIO | PWM3) 40 | #define MUX_PA14 (DIO | PWM4) 41 | #define MUX_PA15 (DIO) 42 | 43 | #define MUX_PB0 (DIO | PWM0 | _SPI_MISO) 44 | #define MUX_PB1 (DIO | PWM1 | _SPI_SCK) 45 | #define MUX_PB2 (DIO | PWM2 | _SPI_SCK) 46 | #define MUX_PB3 (DIO | PWM3 | _SPI_MISO) 47 | #define MUX_PB4 (DIO | _SPI_SS) 48 | #define MUX_PB5 (DIO | _SPI_MOSI) // LED_BUILTIN_1 49 | #define MUX_PB6 (DIO) 50 | #define MUX_PB7 (DIO) 51 | #define MUX_PB8 (DIO) 52 | #define MUX_PB9 (DIO) 53 | #define MUX_PB10 (DIO) 54 | #define MUX_PB11 (DIO) // LED_BUILTIN_7 55 | #define MUX_PB12 (DIO | PWM0) 56 | #define MUX_PB13 (DIO | PWM1) 57 | #define MUX_PB14 (DIO | PWM2 | _SPI_SS) // PIN_SPI_SS 58 | #define MUX_PB15 (DIO | PWM3 | _SPI_SCK) // PIN_SPI_SCK 59 | #define MUX_PB16 (DIO | PWM4 | _SPI_MISO) // PIN_SPI_MISO / LED_BUILTIN_6 60 | #define MUX_PB17 (DIO | _SPI_MOSI) // PIN_SPI_MOSI / LED_BUILTIN_5 61 | #define MUX_PB18 (DIO) // LED_BUILTIN_4 62 | #define MUX_PB19 (NONE) // TX0: used to download firmware and output to console 63 | #define MUX_PB20 (NONE) // RX0: debug data via printf() 64 | #define MUX_PB21 (DIO) 65 | #define MUX_PB22 (DIO) 66 | #define MUX_PB23 (DIO | _SPI_SS) 67 | #define MUX_PB24 (DIO | PWM2 | _SPI_SCK) 68 | #define MUX_PB25 (DIO | PWM3 | _SPI_MISO) // LED_BUILTIN_2 69 | #define MUX_PB26 (DIO | PWM4 | _SPI_MOSI) // LED_BUILTIN_3 70 | #define MUX_PB27 (DIO) 71 | 72 | extern const PIN_MAP pin_Map[]; 73 | 74 | // Additional board settings 75 | #include "variant.h" 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /variants/w801/variant.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARIANT_ARDUINO_W801_ 2 | #define _VARIANT_ARDUINO_W801_ 3 | 4 | #define LED_BUILTIN_1 PB5 5 | #define LED_BUILTIN_2 PB25 6 | #define LED_BUILTIN_3 PB26 7 | #define LED_BUILTIN_4 PB18 8 | #define LED_BUILTIN_5 PB17 9 | #define LED_BUILTIN_6 PB16 10 | #define LED_BUILTIN_7 PB11 11 | #define LED_BUILTIN LED_BUILTIN_1 12 | 13 | // SPI 14 | #define PIN_SPI_SS (PB14) 15 | #define PIN_SPI_SCK (PB15) 16 | #define PIN_SPI_MISO (PB16) 17 | #define PIN_SPI_MOSI (PB17) 18 | 19 | #define PINS_COUNT (44U) // pins in total, PB19, PB20 and PB23 are not used 20 | #define ADC_COUNT (4U) // number of ADC channels 21 | #define PWM_COUNT (5U) // number of PWM channels 22 | 23 | #endif /* _VARIANT_ARDUINO_W801_ */ 24 | -------------------------------------------------------------------------------- /variants/w802/pins_arduino.h: -------------------------------------------------------------------------------- 1 | // pin description for W802 board 2 | #ifndef Pins_Arduino_h 3 | #define Pins_Arduino_h 4 | 5 | #include "./include/driver/wm_hal.h" 6 | #include 7 | 8 | // pin enum - index of an array of possible alternatives 9 | enum pins 10 | { 11 | PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PA8,PA9,PA10,PA11,PA12,PA13,PA14,PA15, 12 | PB0,PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8,PB9,PB10,PB11,PB12,PB13,PB14,PB15, 13 | PB16,PB17,PB18,PB19,PB20,PB21,PB22,PB23,PB24,PB25,PB26,PB27,PB28,PB29 14 | }; 15 | 16 | // Arduino macros for analog inputs 17 | #define A1 PA1 18 | #define A2 PA2 19 | #define A3 PA3 20 | #define A4 PA4 21 | 22 | // add A0 as alias to A1 for compatibility 23 | #define A0 A1 24 | 25 | // pin mux macros for W801 26 | #define MUX_PA0 (DIO | PWM2 | _SPI_SS) // Boot 27 | #define MUX_PA1 (DIO | ADC1 | PWM3) // JTAG_CK 28 | #define MUX_PA2 (DIO | ADC4 | PWM0) 29 | #define MUX_PA3 (DIO | ADC3 | PWM1) 30 | #define MUX_PA4 (DIO | ADC2 | PWM4) // JTAG_SWO 31 | #define MUX_PA5 (NONE) // Internal used - qspi 32 | #define MUX_PA6 (NONE) // Internal used - qspi 33 | #define MUX_PA7 (DIO | PWM4 | _SPI_MOSI) // LCD_RST 34 | #define MUX_PA8 (NONE) // Internal used - qspi 35 | #define MUX_PA9 (DIO) // LCD_SCL 36 | #define MUX_PA10 (DIO | PWM0) // LCD_SDI 37 | #define MUX_PA11 (NONE) // Internal used - qspi 38 | #define MUX_PA12 (DIO | PWM2) // LCD_RS 39 | #define MUX_PA13 (NONE) // Internal used - qspi 40 | #define MUX_PA14 (DIO | PWM4) // LCD_CS 41 | #define MUX_PA15 (NONE) // Internal used - qspi 42 | 43 | #define MUX_PB0 (NONE) // Internal used - psram 44 | #define MUX_PB1 (NONE) // Internal used - psram 45 | #define MUX_PB2 (NONE) // Internal used - psram 46 | #define MUX_PB3 (NONE) // Internal used - psram 47 | #define MUX_PB4 (NONE) // Internal used - psram 48 | #define MUX_PB5 (NONE) // Internal used - psram 49 | #define MUX_PB6 (DIO) 50 | #define MUX_PB7 (DIO) 51 | #define MUX_PB8 (DIO) // LCD_LED 52 | #define MUX_PB9 (DIO) 53 | #define MUX_PB10 (DIO) 54 | #define MUX_PB11 (DIO) 55 | #define MUX_PB12 (DIO | PWM0) 56 | #define MUX_PB13 (DIO | PWM1) 57 | #define MUX_PB14 (DIO | PWM2 | _SPI_SS) // PIN_SPI_SS 58 | #define MUX_PB15 (DIO | PWM3 | _SPI_SCK) // PIN_SPI_SCK 59 | #define MUX_PB16 (DIO | _SPI_MISO) // PIN_SPI_MISO 60 | #define MUX_PB17 (DIO | _SPI_MOSI) // PIN_SPI_MOSI 61 | #define MUX_PB18 (DIO) 62 | #define MUX_PB19 (NONE) // TX0: used to download firmware and output to console 63 | #define MUX_PB20 (NONE) // RX0: debug data via printf() 64 | #define MUX_PB21 (DIO) 65 | #define MUX_PB22 (DIO) 66 | #define MUX_PB23 (NONE) 67 | #define MUX_PB24 (DIO | PWM2 | _SPI_SCK) 68 | #define MUX_PB25 (DIO | PWM3 | _SPI_MISO) 69 | #define MUX_PB26 (DIO | PWM4 | _SPI_MOSI) 70 | #define MUX_PB27 (NONE) 71 | #define MUX_PB28 (NONE) 72 | #define MUX_PB29 (DIO) // LCD_TE 73 | 74 | extern const PIN_MAP pin_Map[]; 75 | 76 | // Additional board settings 77 | #include "variant.h" 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /variants/w802/variant.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARIANT_ARDUINO_W802_ 2 | #define _VARIANT_ARDUINO_W802_ 3 | 4 | // TFT LCD CONNECTOR 5 | #define PIN_TFT_RST (PA7) 6 | #define PIN_TFT_RS (PA12) 7 | #define PIN_TFT_CS (PA14) 8 | #define PIN_TFT_SCL (PA9) 9 | #define PIN_TFT_SDI (PA10) 10 | #define PIN_TFT_LED (PB8) 11 | #define PIN_TFT_TE (PB29) 12 | 13 | // SPI 14 | #define PIN_SPI_SS (PB14) 15 | #define PIN_SPI_SCK (PB15) 16 | #define PIN_SPI_MISO (PB16) 17 | #define PIN_SPI_MOSI (PB17) 18 | 19 | #define PINS_COUNT (44U) // pins in total, PB19, PB20 and PB23 are not used 20 | #define ADC_COUNT (4U) // number of ADC channels 21 | #define PWM_COUNT (5U) // number of PWM channels 22 | 23 | #endif /* _VARIANT_ARDUINO_W802_ */ 24 | -------------------------------------------------------------------------------- /variants/w806/pins_arduino.h: -------------------------------------------------------------------------------- 1 | // pin description for HLK-W806-KIT board 2 | #ifndef Pins_Arduino_h 3 | #define Pins_Arduino_h 4 | 5 | #include "./include/driver/wm_hal.h" 6 | #include 7 | 8 | // pin enum - index of an array of possible alternatives 9 | enum pins 10 | { 11 | PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PA8,PA9,PA10,PA11,PA12,PA13,PA14,PA15, 12 | PB0,PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8,PB9,PB10,PB11,PB12,PB13,PB14,PB15, 13 | PB16,PB17,PB18,PB19,PB20,PB21,PB22,PB23,PB24,PB25,PB26,PB27 14 | }; 15 | 16 | // Arduino macros for analog inputs 17 | #define A1 PA1 18 | #define A2 PA2 19 | #define A3 PA3 20 | #define A4 PA4 21 | 22 | // add A0 as alias to A1 for compatibility 23 | #define A0 A1 24 | 25 | // pin mux macros for W806 26 | #define MUX_PA0 (DIO | PWM2 | _SPI_SS) // Boot 27 | #define MUX_PA1 (DIO | ADC1 | PWM3) // JTAG_CK 28 | #define MUX_PA2 (DIO | ADC4 | PWM0) 29 | #define MUX_PA3 (DIO | ADC3 | PWM1) 30 | #define MUX_PA4 (DIO | ADC2 | PWM4) // JTAG_SWO 31 | #define MUX_PA5 (DIO) 32 | #define MUX_PA6 (DIO) 33 | #define MUX_PA7 (DIO | PWM4 | _SPI_MOSI) 34 | #define MUX_PA8 (DIO) 35 | #define MUX_PA9 (DIO) 36 | #define MUX_PA10 (DIO | PWM0) 37 | #define MUX_PA11 (DIO | PWM1) 38 | #define MUX_PA12 (DIO | PWM2) 39 | #define MUX_PA13 (DIO | PWM3) 40 | #define MUX_PA14 (DIO | PWM4) 41 | #define MUX_PA15 (DIO) 42 | 43 | #define MUX_PB0 (DIO | PWM0 | _SPI_MISO) // LED_BUILTIN_1 44 | #define MUX_PB1 (DIO | PWM1 | _SPI_SCK) // LED_BUILTIN_2 45 | #define MUX_PB2 (DIO | PWM2 | _SPI_SCK) // LED_BUILTIN_3 46 | #define MUX_PB3 (DIO | PWM3 | _SPI_MISO) 47 | #define MUX_PB4 (DIO | _SPI_SS) 48 | #define MUX_PB5 (DIO | _SPI_MOSI) 49 | #define MUX_PB6 (DIO) 50 | #define MUX_PB7 (DIO) 51 | #define MUX_PB8 (DIO) 52 | #define MUX_PB9 (DIO) 53 | #define MUX_PB10 (DIO) 54 | #define MUX_PB11 (DIO) 55 | #define MUX_PB12 (DIO | PWM0) 56 | #define MUX_PB13 (DIO | PWM1) 57 | #define MUX_PB14 (DIO | PWM2 | _SPI_SS) 58 | #define MUX_PB15 (DIO | PWM3 | _SPI_SCK) 59 | #define MUX_PB16 (DIO | _SPI_MISO) 60 | #define MUX_PB17 (DIO | _SPI_MOSI) 61 | #define MUX_PB18 (DIO) 62 | #define MUX_PB19 (NONE) // TX0: used to download firmware and output to console 63 | #define MUX_PB20 (NONE) // RX0: debug data via printf() 64 | #define MUX_PB21 (DIO) 65 | #define MUX_PB22 (DIO) 66 | #define MUX_PB23 (NONE) // no pin for PB23 on W806 package 67 | #define MUX_PB24 (DIO | PWM2 | _SPI_SCK) 68 | #define MUX_PB25 (DIO | PWM3 | _SPI_MISO) 69 | #define MUX_PB26 (DIO | PWM4 | _SPI_MOSI) 70 | #define MUX_PB27 (DIO) 71 | 72 | extern const PIN_MAP pin_Map[]; 73 | 74 | // Additional board settings 75 | #include "variant.h" 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /variants/w806/variant.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARIANT_ARDUINO_W806_ 2 | #define _VARIANT_ARDUINO_W806_ 3 | 4 | #define LED_BUILTIN_1 PB0 5 | #define LED_BUILTIN_2 PB1 6 | #define LED_BUILTIN_3 PB2 7 | #define LED_BUILTIN LED_BUILTIN_1 8 | 9 | // SPI 10 | #define PIN_SPI_SS (PB14) 11 | #define PIN_SPI_SCK (PB15) 12 | #define PIN_SPI_MISO (PB16) 13 | #define PIN_SPI_MOSI (PB17) 14 | 15 | #define PINS_COUNT (44U) // pins in total, PB19, PB20 and PB23 are not used 16 | #define ADC_COUNT (4U) // number of ADC channels 17 | #define PWM_COUNT (5U) // number of PWM channels 18 | 19 | #endif /* _VARIANT_ARDUINO_W806_ */ 20 | --------------------------------------------------------------------------------