diff --git a/.gitmodules b/.gitmodules index 0d6d30a..a7eba26 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,3 @@ [submodule "tools/src/texane-stlink"] path = tools/src/texane-stlink url = https://github.com/texane/stlink -[submodule "STM32duino-bootloader"] - path = STM32duino-bootloader - url = https://github.com/rogerclarkmelbourne/STM32duino-bootloader.git diff --git a/GD32F1/boards.txt b/GD32F1/boards.txt deleted file mode 100644 index e1ed019..0000000 --- a/GD32F1/boards.txt +++ /dev/null @@ -1,74 +0,0 @@ -# GD32 Boards - - -menu.device_variant=Variant -menu.bootloader_version=Bootloader version -menu.upload_method=Upload method -menu.cpu_speed=CPU Speed(MHz) - - -###################### Generic GD32F103C ######################################## - -genericGD32F103C.name=Generic GD32F103C series -genericGD32F103C.build.variant=generic_GD32f103c -genericGD32F103C.build.vect=VECT_TAB_ADDR=0x8000000 -genericGD32F103C.build.core=maple -genericGD32F103C.build.board=GENERIC_GD32F103C -genericGD32F103C.upload.use_1200bps_touch=false -genericGD32F103C.upload.file_type=bin -genericGD32F103C.upload.auto_reset=true -genericGD32F103C.build.cpu_flags=-DMCU_STM32F103CB -genericGD32F103C.build.f_cpu=72000000L - -## GD32F103CB ------------------------- -genericGD32F103C.menu.device_variant.GD32F103CB=GD32F103CB (20k RAM. 128k Flash) -genericGD32F103C.menu.device_variant.GD32F103CB.build.ldscript=ld/jtag.ld -genericGD32F103C.menu.device_variant.GD32F103CB.upload.maximum_size=131072 -genericGD32F103C.menu.device_variant.GD32F103CB.upload.ram.maximum_size=20480 -genericGD32F103C.menu.device_variant.GD32F103CB.upload.flash.maximum_size=131072 - - -## GD32F103C8 ------------------------- -genericGD32F103C.menu.device_variant.GD32F103C8=GD32F103C8 (20k RAM. 64k Flash) -genericGD32F103C.menu.device_variant.GD32F103C8.build.ldscript=ld/jtag_c8.ld -genericGD32F103C.menu.device_variant.GD32F103C8.upload.maximum_size=65536 -genericGD32F103C.menu.device_variant.GD32F103C8.upload.ram.maximum_size=20480 -genericGD32F103C.menu.device_variant.GD32F103C8.upload.flash.maximum_size=65536 - -#---------------------------- UPLOAD METHODS --------------------------- - -genericGD32F103C.menu.upload_method.DFUUploadMethod=GD32duino bootloader - -genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu -genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload -genericGD32F103C.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER -genericGD32F103C.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000 -genericGD32F103C.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld -genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003 -genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.altID=2 - -genericGD32F103C.menu.upload_method.serialMethod=Serial -genericGD32F103C.menu.upload_method.serialMethod.upload.protocol=maple_serial -genericGD32F103C.menu.upload_method.serialMethod.upload.tool=serial_upload - - -genericGD32F103C.menu.upload_method.STLinkMethod=STLink -genericGD32F103C.menu.upload_method.STLinkMethod.upload.protocol=STLink -genericGD32F103C.menu.upload_method.STLinkMethod.upload.tool=stlink_upload -genericGD32F103C.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER - - -genericGD32F103C.menu.upload_method.BMPMethod=BMP (Black Magic Probe) -genericGD32F103C.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp -genericGD32F103C.menu.upload_method.BMPMethod.upload.tool=bmp_upload -genericGD32F103C.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG - -genericGD32F103C.menu.cpu_speed.speed_120mhz=120Mhz (overdrive) -genericGD32F103C.menu.cpu_speed.speed_120mhz.build.f_cpu=120000000L - -genericGD32F103C.menu.cpu_speed.speed_96mhz=96Mhz (Stable) -genericGD32F103C.menu.cpu_speed.speed_96mhz.build.f_cpu=96000000L - -genericGD32F103C.menu.cpu_speed.speed_72mhz=72Mhz (compatibility) -genericGD32F103C.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L - diff --git a/GD32F1/cores/maple/Arduino.h b/GD32F1/cores/maple/Arduino.h deleted file mode 100644 index 63432a1..0000000 --- a/GD32F1/cores/maple/Arduino.h +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#ifndef _WIRISH_WPROGRAM_H_ -#define _WIRISH_WPROGRAM_H_ - -#include "wirish.h" - -void setup(); -void loop(); -#ifdef __cplusplus -extern "C"{ -#endif // __cplusplus -void yield(void); -#ifdef __cplusplus -} -#endif // __cplusplus - -#include "variant.h" - -#endif diff --git a/GD32F1/cores/maple/HardwareSerial.cpp b/GD32F1/cores/maple/HardwareSerial.cpp deleted file mode 100644 index 4cd67c3..0000000 --- a/GD32F1/cores/maple/HardwareSerial.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/HardwareSerial.cpp - * @brief Wirish serial port implementation. - */ - -#include "HardwareSerial.h" - -#include -#include -#include -#include - -#if 0 - - #define DEFINE_HWSERIAL(name, n) \ - HardwareSerial name(USART##n, \ - BOARD_USART##n##_TX_PIN, \ - BOARD_USART##n##_RX_PIN) - - #define DEFINE_HWSERIAL_UART(name, n) \ - HardwareSerial name(UART##n, \ - BOARD_USART##n##_TX_PIN, \ - BOARD_USART##n##_RX_PIN) - - #ifdef SERIAL_USB - #if BOARD_HAVE_USART1 - DEFINE_HWSERIAL(Serial1, 1); - #endif - #if BOARD_HAVE_USART2 - DEFINE_HWSERIAL(Serial2, 2); - #endif - #if BOARD_HAVE_USART3 - DEFINE_HWSERIAL(Serial3, 3); - #endif - #if BOARD_HAVE_UART4 - DEFINE_HWSERIAL_UART(Serial4, 4); - #endif - #if BOARD_HAVE_UART5 - DEFINE_HWSERIAL_UART(Serial5, 5); - #endif - #if BOARD_HAVE_USART6 - DEFINE_HWSERIAL_UART(Serial6, 6); - #endif - #else - #if BOARD_HAVE_USART1 - DEFINE_HWSERIAL(Serial, 1); - #endif - #if BOARD_HAVE_USART2 - DEFINE_HWSERIAL(Serial1, 2); - #endif - #if BOARD_HAVE_USART3 - DEFINE_HWSERIAL(Serial2, 3); - #endif - #if BOARD_HAVE_UART4 - DEFINE_HWSERIAL_UART(Serial3, 4); - #endif - #if BOARD_HAVE_UART5 - DEFINE_HWSERIAL_UART(Serial4, 5); - #endif - #if BOARD_HAVE_USART6 - DEFINE_HWSERIAL_UART(Serial5, 6); - #endif - #endif - -#endif -HardwareSerial::HardwareSerial(usart_dev *usart_device, - uint8 tx_pin, - uint8 rx_pin) { - this->usart_device = usart_device; - this->tx_pin = tx_pin; - this->rx_pin = rx_pin; -} - -/* - * Set up/tear down - */ - -#if STM32_MCU_SERIES == STM32_SERIES_F1 -/* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict - * on this GPIO bit. */ -static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) { - if (dev != NULL) { - timer_set_mode(dev, ch, TIMER_DISABLED); - } -} -#elif (STM32_MCU_SERIES == STM32_SERIES_F2) || \ - (STM32_MCU_SERIES == STM32_SERIES_F4) -#define disable_timer_if_necessary(dev, ch) ((void)0) -#else -#warning "Unsupported STM32 series; timer conflicts are possible" -#endif - -void HardwareSerial::begin(uint32 baud) -{ - begin(baud,SERIAL_8N1); -} -/* - * Roger Clark. - * Note. The config parameter is not currently used. This is a work in progress. - * Code needs to be written to set the config of the hardware serial control register in question. - * -*/ - -void HardwareSerial::begin(uint32 baud, uint8_t config) -{ - // ASSERT(baud <= this->usart_device->max_baud);// Roger Clark. Assert doesn't do anything useful, we may as well save the space in flash and ram etc - - if (baud > this->usart_device->max_baud) { - return; - } - - const stm32_pin_info *txi = &PIN_MAP[this->tx_pin]; - const stm32_pin_info *rxi = &PIN_MAP[this->rx_pin]; - - disable_timer_if_necessary(txi->timer_device, txi->timer_channel); - - usart_config_gpios_async(this->usart_device, - rxi->gpio_device, rxi->gpio_bit, - txi->gpio_device, txi->gpio_bit, - config); - usart_init(this->usart_device); - usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud); - usart_enable(this->usart_device); -} - -void HardwareSerial::end(void) { - usart_disable(this->usart_device); -} - -/* - * I/O - */ - -int HardwareSerial::read(void) { - // Block until a byte becomes available, to save user confusion. - while (!this->available()) - ; - return usart_getc(this->usart_device); -} - -int HardwareSerial::available(void) { - return usart_data_available(this->usart_device); -} - -/* Roger Clark. Added function missing from LibMaple code */ - -int HardwareSerial::peek(void) -{ - return usart_peek(this->usart_device); -} - -int HardwareSerial::availableForWrite(void) -{ -/* Roger Clark. - * Currently there isn't an output ring buffer, chars are sent straight to the hardware. - * so just return 1, meaning that 1 char can be written - * This will be slower than a ring buffer implementation, but it should at least work ! - */ - return 1; -} - -size_t HardwareSerial::write(unsigned char ch) { - - usart_putc(this->usart_device, ch); - return 1; -} - -void HardwareSerial::flush(void) { - usart_reset_rx(this->usart_device); -} diff --git a/GD32F1/cores/maple/HardwareSerial.h b/GD32F1/cores/maple/HardwareSerial.h deleted file mode 100644 index e4f363c..0000000 --- a/GD32F1/cores/maple/HardwareSerial.h +++ /dev/null @@ -1,221 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/HardwareSerial.h - * @brief Wirish serial port interface. - */ - -#ifndef _WIRISH_HARDWARESERIAL_H_ -#define _WIRISH_HARDWARESERIAL_H_ - -#include - -#include "Print.h" -#include "boards.h" -#include "Stream.h" -/* - * IMPORTANT: - * - * This class documented "by hand" (i.e., not using Doxygen) in the - * leaflabs-docs/ repository. - * - * If you alter the public HardwareSerial interface, you MUST update - * the documentation accordingly. - */ - - - -// Define constants and variables for buffering incoming serial data. We're -// using a ring buffer (I think), in which head is the index of the location -// to which to write the next incoming character and tail is the index of the -// location from which to read. -#if !(defined(SERIAL_TX_BUFFER_SIZE) && defined(SERIAL_RX_BUFFER_SIZE)) -#if (RAMEND < 1000) -#define SERIAL_TX_BUFFER_SIZE 16 -#define SERIAL_RX_BUFFER_SIZE 16 -#else -#define SERIAL_TX_BUFFER_SIZE 64 -#define SERIAL_RX_BUFFER_SIZE 64 -#endif -#endif -#if (SERIAL_TX_BUFFER_SIZE>256) -typedef uint16_t tx_buffer_index_t; -#else -typedef uint8_t tx_buffer_index_t; -#endif -#if (SERIAL_RX_BUFFER_SIZE>256) -typedef uint16_t rx_buffer_index_t; -#else -typedef uint8_t rx_buffer_index_t; -#endif - -struct usart_dev; - -/* Roger Clark - * - * Added config defines from AVR - * Note. The values will need to be changed to match STM32 USART config register values, these are just place holders. - */ -// Define config for Serial.begin(baud, config); -// Note. STM32 doesn't support as many different Serial modes as AVR or SAM cores. - -#define SERIAL_8N1 0B00000000 -#define SERIAL_8N2 0B00100000 -#define SERIAL_9N1 0B00001000 -#define SERIAL_9N2 0B00101000 - -#define SERIAL_8E1 0B00000010 -#define SERIAL_8E2 0B00100010 -#define SERIAL_9E1 0B00001010 -#define SERIAL_9E2 0B00101010 - -#define SERIAL_8O1 0B00000011 -#define SERIAL_8O2 0B00100011 -#define SERIAL_9O1 0B00001011 -#define SERIAL_9O2 0B00101011 - - -/* Roger Clark - * Moved macros from hardwareSerial.cpp - */ - -#define DEFINE_HWSERIAL(name, n) \ - HardwareSerial name(USART##n, \ - BOARD_USART##n##_TX_PIN, \ - BOARD_USART##n##_RX_PIN) - -#define DEFINE_HWSERIAL_UART(name, n) \ - HardwareSerial name(UART##n, \ - BOARD_USART##n##_TX_PIN, \ - BOARD_USART##n##_RX_PIN) - - -/* Roger clark. Changed class inheritance from Print to Stream. - * Also added new functions for peek() and availableForWrite() - * Note. AvailableForWrite is only a stub function in the cpp - */ -class HardwareSerial : public Stream { - -public: - HardwareSerial(struct usart_dev *usart_device, - uint8 tx_pin, - uint8 rx_pin); - - /* Set up/tear down */ - void begin(uint32 baud); - void begin(uint32 baud,uint8_t config); - void end(); - virtual int available(void); - virtual int peek(void); - virtual int read(void); - int availableForWrite(void); - virtual void flush(void); - virtual size_t write(uint8_t); - inline size_t write(unsigned long n) { return write((uint8_t)n); } - inline size_t write(long n) { return write((uint8_t)n); } - inline size_t write(unsigned int n) { return write((uint8_t)n); } - inline size_t write(int n) { return write((uint8_t)n); } - using Print::write; - - /* Pin accessors */ - int txPin(void) { return this->tx_pin; } - int rxPin(void) { return this->rx_pin; } - - operator bool() { return true; } - - /* Escape hatch into libmaple */ - /* FIXME [0.0.13] documentation */ - struct usart_dev* c_dev(void) { return this->usart_device; } -private: - struct usart_dev *usart_device; - uint8 tx_pin; - uint8 rx_pin; - protected: -#if 0 - volatile uint8_t * const _ubrrh; - volatile uint8_t * const _ubrrl; - volatile uint8_t * const _ucsra; - volatile uint8_t * const _ucsrb; - volatile uint8_t * const _ucsrc; - volatile uint8_t * const _udr; - // Has any byte been written to the UART since begin() - bool _written; - - volatile rx_buffer_index_t _rx_buffer_head; - volatile rx_buffer_index_t _rx_buffer_tail; - volatile tx_buffer_index_t _tx_buffer_head; - volatile tx_buffer_index_t _tx_buffer_tail; - // Don't put any members after these buffers, since only the first - // 32 bytes of this struct can be accessed quickly using the ldd - // instruction. - unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE]; - unsigned char _tx_buffer[SERIAL_TX_BUFFER_SIZE]; -#endif -}; - -#ifdef SERIAL_USB - #if BOARD_HAVE_USART1 - extern HardwareSerial Serial1; - #endif - #if BOARD_HAVE_USART2 - extern HardwareSerial Serial2; - #endif - #if BOARD_HAVE_USART3 - extern HardwareSerial Serial3; - #endif - #if BOARD_HAVE_UART4 - extern HardwareSerial Serial4; - #endif - #if BOARD_HAVE_UART5 - extern HardwareSerial Serial5; - #endif - #if BOARD_HAVE_USART6 - extern HardwareSerial Serial6; - #endif -#else - #if BOARD_HAVE_USART1 - extern HardwareSerial Serial; - #endif - #if BOARD_HAVE_USART2 - extern HardwareSerial Serial1; - #endif - #if BOARD_HAVE_USART3 - extern HardwareSerial Serial2; - #endif - #if BOARD_HAVE_UART4 - extern HardwareSerial Serial3; - #endif - #if BOARD_HAVE_UART5 - extern HardwareSerial Serial4; - #endif - #if BOARD_HAVE_USART6 - extern HardwareSerial Serial5; - #endif -#endif - -#endif diff --git a/GD32F1/cores/maple/HardwareTimer.cpp b/GD32F1/cores/maple/HardwareTimer.cpp deleted file mode 100644 index dc8f2b6..0000000 --- a/GD32F1/cores/maple/HardwareTimer.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Bryan Newbold. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#include "HardwareTimer.h" - -#include -#include "ext_interrupts.h" // for noInterrupts(), interrupts() -#include "wirish_math.h" -#include // for CYCLES_PER_MICROSECOND - -// TODO [0.1.0] Remove deprecated pieces - -/* - * Evil hack to infer this->dev from timerNum in the HardwareTimer - * constructor. See: - * - * http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2 - * http://yosefk.com/c++fqa/function.html#fqa-33.2 - */ - -extern "C" { - static timer_dev **this_devp; - static rcc_clk_id this_id; - static void set_this_dev(timer_dev *dev) { - if (dev->clk_id == this_id) { - *this_devp = dev; - } - } -} - -/* - * HardwareTimer routines - */ - -HardwareTimer::HardwareTimer(uint8 timerNum) { - rcc_clk_id timerID = (rcc_clk_id)(RCC_TIMER1 + (timerNum - 1)); - this->dev = NULL; - noInterrupts(); // Hack to ensure we're the only ones using - // set_this_dev() and friends. TODO: use a lock. - this_id = timerID; - this_devp = &this->dev; - timer_foreach(set_this_dev); - interrupts(); - ASSERT(this->dev != NULL); -} - -void HardwareTimer::pause(void) { - timer_pause(this->dev); -} - -void HardwareTimer::resume(void) { - timer_resume(this->dev); -} - -uint32 HardwareTimer::getPrescaleFactor(void) { - return timer_get_prescaler(this->dev) + 1; -} - -void HardwareTimer::setPrescaleFactor(uint32 factor) { - timer_set_prescaler(this->dev, (uint16)(factor - 1)); -} - -uint16 HardwareTimer::getOverflow() { - return timer_get_reload(this->dev); -} - -void HardwareTimer::setOverflow(uint16 val) { - timer_set_reload(this->dev, val); -} - -uint16 HardwareTimer::getCount(void) { - return timer_get_count(this->dev); -} - -void HardwareTimer::setCount(uint16 val) { - uint16 ovf = this->getOverflow(); - timer_set_count(this->dev, min(val, ovf)); -} - -#define MAX_RELOAD ((1 << 16) - 1) -uint16 HardwareTimer::setPeriod(uint32 microseconds) { - // Not the best way to handle this edge case? - if (!microseconds) { - this->setPrescaleFactor(1); - this->setOverflow(1); - return this->getOverflow(); - } - - uint32 period_cyc = microseconds * CYCLES_PER_MICROSECOND; - uint16 prescaler = (uint16)(period_cyc / MAX_RELOAD + 1); - uint16 overflow = (uint16)((period_cyc + (prescaler / 2)) / prescaler); - this->setPrescaleFactor(prescaler); - this->setOverflow(overflow); - return overflow; -} - -void HardwareTimer::setMode(int channel, timer_mode mode) { - timer_set_mode(this->dev, (uint8)channel, (timer_mode)mode); -} - -uint16 HardwareTimer::getCompare(int channel) { - return timer_get_compare(this->dev, (uint8)channel); -} - -void HardwareTimer::setCompare(int channel, uint16 val) { - uint16 ovf = this->getOverflow(); - timer_set_compare(this->dev, (uint8)channel, min(val, ovf)); -} - -void HardwareTimer::attachInterrupt(int channel, voidFuncPtr handler) { - timer_attach_interrupt(this->dev, (uint8)channel, handler); -} - -void HardwareTimer::detachInterrupt(int channel) { - timer_detach_interrupt(this->dev, (uint8)channel); -} - -void HardwareTimer::refresh(void) { - timer_generate_update(this->dev); -} - -/* -- Deprecated predefined instances -------------------------------------- */ - -HardwareTimer Timer1(1); -HardwareTimer Timer2(2); -HardwareTimer Timer3(3); -HardwareTimer Timer4(4); -#ifdef STM32_HIGH_DENSITY -HardwareTimer Timer5(5); -HardwareTimer Timer6(6); -HardwareTimer Timer7(7); -HardwareTimer Timer8(8); -#endif diff --git a/GD32F1/cores/maple/HardwareTimer.h b/GD32F1/cores/maple/HardwareTimer.h deleted file mode 100644 index 22aa010..0000000 --- a/GD32F1/cores/maple/HardwareTimer.h +++ /dev/null @@ -1,337 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Bryan Newbold. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @brief Wirish timer class. - */ - -#ifndef _WIRISH_HARDWARETIMER_H_ -#define _WIRISH_HARDWARETIMER_H_ - -// TODO [0.1.0] Remove deprecated pieces, pick a better API - -#include - -/** Timer mode. */ -typedef timer_mode TimerMode; - -/** - * @brief Interface to one of the 16-bit timer peripherals. - */ -class HardwareTimer { -private: - timer_dev *dev; - -public: - /** - * @brief Construct a new HardwareTimer instance. - * @param timerNum number of the timer to control. - */ - HardwareTimer(uint8 timerNum); - - /** - * @brief Stop the counter, without affecting its configuration. - * - * @see HardwareTimer::resume() - */ - void pause(void); - - /** - * @brief Resume a paused timer, without affecting its configuration. - * - * The timer will resume counting and firing interrupts as - * appropriate. - * - * Note that there is some function call overhead associated with - * using this method, so using it in concert with - * HardwareTimer::pause() is not a robust way to align multiple - * timers to the same count value. - * - * @see HardwareTimer::pause() - */ - void resume(void); - - /** - * @brief Get the timer's prescale factor. - * @return Timer prescaler, from 1 to 65,536. - * @see HardwareTimer::setPrescaleFactor() - */ - uint32 getPrescaleFactor(); - - /** - * @brief Set the timer's prescale factor. - * - * The new value won't take effect until the next time the counter - * overflows. You can force the counter to reset using - * HardwareTimer::refresh(). - * - * @param factor The new prescale value to set, from 1 to 65,536. - * @see HardwareTimer::refresh() - */ - void setPrescaleFactor(uint32 factor); - - /** - * @brief Get the timer overflow value. - * @see HardwareTimer::setOverflow() - */ - uint16 getOverflow(); - - /** - * @brief Set the timer overflow (or "reload") value. - * - * The new value won't take effect until the next time the counter - * overflows. You can force the counter to reset using - * HardwareTimer::refresh(). - * - * @param val The new overflow value to set - * @see HardwareTimer::refresh() - */ - void setOverflow(uint16 val); - - /** - * @brief Get the current timer count. - * - * @return The timer's current count value - */ - uint16 getCount(void); - - /** - * @brief Set the current timer count. - * - * @param val The new count value to set. If this value exceeds - * the timer's overflow value, it is truncated to the - * overflow value. - */ - void setCount(uint16 val); - - /** - * @brief Set the timer's period in microseconds. - * - * Configures the prescaler and overflow values to generate a timer - * reload with a period as close to the given number of - * microseconds as possible. - * - * @param microseconds The desired period of the timer. This must be - * greater than zero. - * @return The new overflow value. - */ - uint16 setPeriod(uint32 microseconds); - - /** - * @brief Configure a timer channel's mode. - * @param channel Timer channel, from 1 to 4 - * @param mode Mode to set - */ - void setMode(int channel, timer_mode mode); - - /** - * @brief Get the compare value for the given channel. - * @see HardwareTimer::setCompare() - */ - uint16 getCompare(int channel); - - /** - * @brief Set the compare value for the given channel. - * - * @param channel the channel whose compare to set, from 1 to 4. - * @param compare The compare value to set. If greater than this - * timer's overflow value, it will be truncated to - * the overflow value. - * - * @see timer_mode - * @see HardwareTimer::setMode() - * @see HardwareTimer::attachInterrupt() - */ - void setCompare(int channel, uint16 compare); - - /** - * @brief Attach an interrupt handler to the given channel. - * - * This interrupt handler will be called when the timer's counter - * reaches the given channel compare value. - * - * @param channel the channel to attach the ISR to, from 1 to 4. - * @param handler The ISR to attach to the given channel. - * @see voidFuncPtr - */ - void attachInterrupt(int channel, voidFuncPtr handler); - - /** - * @brief Remove the interrupt handler attached to the given - * channel, if any. - * - * The handler will no longer be called by this timer. - * - * @param channel the channel whose interrupt to detach, from 1 to 4. - * @see HardwareTimer::attachInterrupt() - */ - void detachInterrupt(int channel); - - /** - * @brief Reset the counter, and update the prescaler and overflow - * values. - * - * This will reset the counter to 0 in upcounting mode (the - * default). It will also update the timer's prescaler and - * overflow, if you have set them up to be changed using - * HardwareTimer::setPrescaleFactor() or - * HardwareTimer::setOverflow(). - * - * @see HardwareTimer::setPrescaleFactor() - * @see HardwareTimer::setOverflow() - */ - void refresh(void); - - /* Escape hatch */ - - /** - * @brief Get a pointer to the underlying libmaple timer_dev for - * this HardwareTimer instance. - */ - timer_dev* c_dev(void) { return this->dev; } - -/* -- The rest of this file is deprecated. --------------------------------- */ - - /** @brief Deprecated; use setMode(channel, mode) instead. */ - void setChannelMode(int channel, timer_mode mode) { - setMode(channel, mode); - } - - /** @brief Deprecated; use setMode(TIMER_CH1, mode) instead. */ - void setChannel1Mode(timer_mode mode) { setMode(TIMER_CH1, mode); } - - /** @brief Deprecated; use setMode(TIMER_CH2, mode) instead. */ - void setChannel2Mode(timer_mode mode) { setMode(TIMER_CH2, mode); } - - /** @brief Deprecated; use setMode(TIMER_CH3, mode) instead. */ - void setChannel3Mode(timer_mode mode) { setMode(TIMER_CH3, mode); } - - /** @brief Deprecated; use setMode(TIMER_CH4, mode) instead. */ - void setChannel4Mode(timer_mode mode) { setMode(TIMER_CH4, mode); } - - /** @brief Deprecated; use return getCompare(TIMER_CH1) instead. */ - uint16 getCompare1() { return getCompare(TIMER_CH1); } - - /** @brief Deprecated; use return getCompare(TIMER_CH2) instead. */ - uint16 getCompare2() { return getCompare(TIMER_CH2); } - - /** @brief Deprecated; use return getCompare(TIMER_CH3) instead. */ - uint16 getCompare3() { return getCompare(TIMER_CH3); } - - /** @brief Deprecated; use return getCompare(TIMER_CH4) instead. */ - uint16 getCompare4() { return getCompare(TIMER_CH4); } - - /** @brief Deprecated; use setCompare(TIMER_CH1, compare) instead. */ - void setCompare1(uint16 compare) { setCompare(TIMER_CH1, compare); } - - /** @brief Deprecated; use setCompare(TIMER_CH2, compare) instead. */ - void setCompare2(uint16 compare) { setCompare(TIMER_CH2, compare); } - - /** @brief Deprecated; use setCompare(TIMER_CH3, compare) instead. */ - void setCompare3(uint16 compare) { setCompare(TIMER_CH3, compare); } - - /** @brief Deprecated; use setCompare(TIMER_CH4, compare) instead. */ - void setCompare4(uint16 compare) { setCompare(TIMER_CH4, compare); } - - /** @brief Deprecated; use attachInterrupt(TIMER_CH1, handler) instead. */ - void attachCompare1Interrupt(voidFuncPtr handler) { - attachInterrupt(TIMER_CH1, handler); - } - - /** @brief Deprecated; use attachInterrupt(TIMER_CH2, handler) instead. */ - void attachCompare2Interrupt(voidFuncPtr handler) { - attachInterrupt(TIMER_CH2, handler); - } - - /** @brief Deprecated; use attachInterrupt(TIMER_CH3, handler) instead. */ - void attachCompare3Interrupt(voidFuncPtr handler) { - attachInterrupt(TIMER_CH3, handler); - } - - /** @brief Deprecated; use attachInterrupt(TIMER_CH4, handler) instead. */ - void attachCompare4Interrupt(voidFuncPtr handler) { - attachInterrupt(TIMER_CH4, handler); - } - - /** @brief Deprecated; use detachInterrupt(TIMER_CH1) instead. */ - void detachCompare1Interrupt(void) { detachInterrupt(TIMER_CH1); } - - /** @brief Deprecated; use detachInterrupt(TIMER_CH2) instead. */ - void detachCompare2Interrupt(void) { detachInterrupt(TIMER_CH2); } - - /** @brief Deprecated; use detachInterrupt(TIMER_CH3) instead. */ - void detachCompare3Interrupt(void) { detachInterrupt(TIMER_CH3); } - - /** @brief Deprecated; use detachInterrupt(TIMER_CH4) instead. */ - void detachCompare4Interrupt(void) { detachInterrupt(TIMER_CH4); } - - /** @brief Deprecated; use refresh() instead. */ - void generateUpdate(void) { refresh(); } -}; - -/** @brief Deprecated; use TIMER_OUTPUT_COMPARE instead. */ -#define TIMER_OUTPUTCOMPARE TIMER_OUTPUT_COMPARE - -/** - * @brief Deprecated. - * - * Pre-instantiated timer. - */ -extern HardwareTimer Timer1; -/** - * @brief Deprecated. - * - * Pre-instantiated timer. - */ -extern HardwareTimer Timer2; -/** - * @brief Deprecated. - * - * Pre-instantiated timer. - */ -extern HardwareTimer Timer3; -/** - * @brief Deprecated. - * - * Pre-instantiated timer. - */ -extern HardwareTimer Timer4; -#if (STM32_MCU_SERIES == STM32_SERIES_F1) && defined(STM32_HIGH_DENSITY) -/** - * @brief Deprecated. - * - * Pre-instantiated timer. - */ -extern HardwareTimer Timer5; -/** - * @brief Deprecated. - * - * Pre-instantiated timer. - */ -extern HardwareTimer Timer8; -#endif - -#endif diff --git a/GD32F1/cores/maple/Print.cpp b/GD32F1/cores/maple/Print.cpp deleted file mode 100644 index a973659..0000000 --- a/GD32F1/cores/maple/Print.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Print.cpp - Base class that provides print() and println() - * Copyright (c) 2008 David A. Mellis. All right reserved. - * Copyright (c) 2011 LeafLabs, LLC. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - * Modified 23 November 2006 by David A. Mellis - * Modified 12 April 2011 by Marti Bolivar - */ - -#include "Print.h" - -#include "wirish_math.h" -#include "limits.h" - -#ifndef LLONG_MAX -/* - * Note: - * - * At time of writing (12 April 2011), the limits.h that came with the - * newlib we distributed didn't include LLONG_MAX. Because we're - * staying away from using templates (see /notes/coding_standard.rst, - * "Language Features and Compiler Extensions"), this value was - * copy-pasted from a println() of the value - * - * std::numeric_limits::max(). - */ -#define LLONG_MAX 9223372036854775807LL -#endif - -/* - * Public methods - */ - -size_t Print::write(const char *str) { - size_t n = 0; - while (*str) { - write(*str++); - n++; - } - return n; -} - -size_t Print::write(const void *buffer, uint32 size) { - size_t n = 0; - uint8 *ch = (uint8*)buffer; - while (size--) { - write(*ch++); - } - return n; -} - -size_t Print::print(uint8 b, int base) { - return print((uint64)b, base); -} - -size_t Print::print(const String &s) -{ - return write(s.c_str(), s.length()); -} - -size_t Print::print(char c) { - return write(c); -} - -size_t Print::print(const char str[]) { - return write(str); -} - -size_t Print::print(int n, int base) { - return print((long long)n, base); -} - -size_t Print::print(unsigned int n, int base) { - return print((unsigned long long)n, base); -} - -size_t Print::print(long n, int base) { - return print((long long)n, base); -} - -size_t Print::print(unsigned long n, int base) { - return print((unsigned long long)n, base); -} - -size_t Print::print(long long n, int base) { - if (base == BYTE) - { - return write((uint8)n); - } - if (n < 0) { - print('-'); - n = -n; - } - return printNumber(n, base); -} - -size_t Print::print(unsigned long long n, int base) { -size_t c=0; - if (base == BYTE) { - c= write((uint8)n); - } else { - c= printNumber(n, base); - } - return c; -} - -size_t Print::print(double n, int digits) { - return printFloat(n, digits); -} - -size_t Print::println(void) -{ - size_t n = print('\r'); - n += print('\n'); - return n; -} - -size_t Print::println(const String &s) -{ - size_t n = print(s); - n += println(); - return n; -} - -size_t Print::println(char c) { - size_t n = print(c); - n += println(); - return n; -} - -size_t Print::println(const char c[]) { - size_t n = print(c); - n += println(); - return n; -} - -size_t Print::println(uint8 b, int base) { - size_t n = print(b, base); - n += println(); - return n; -} - -size_t Print::println(int n, int base) { - size_t s = print(n, base); - s += println(); - return s; -} - -size_t Print::println(unsigned int n, int base) { - size_t s = print(n, base); - s += println(); - return s; -} - -size_t Print::println(long n, int base) { - size_t s = print((long long)n, base); - s += println(); - return s; -} - -size_t Print::println(unsigned long n, int base) { - size_t s = print((unsigned long long)n, base); - s += println(); - return s; -} - -size_t Print::println(long long n, int base) { - size_t s = print(n, base); - s += println(); - return s; -} - -size_t Print::println(unsigned long long n, int base) { - size_t s = print(n, base); - s += println(); - return s; -} - -size_t Print::println(double n, int digits) { - size_t s = print(n, digits); - s += println(); - return s; -} - -#ifdef SUPPORTS_PRINTF -#include -#include -// Work in progress to support printf. -// Need to implement stream FILE to write individual chars to chosen serial port -int Print::printf (__const char *__restrict __format, ...) - { -FILE *__restrict __stream; - int ret_status = 0; - - - va_list args; - va_start(args,__format); - ret_status = vfprintf(__stream, __format, args); - va_end(args); - return ret_status; - } - #endif - -/* - * Private methods - */ - -size_t Print::printNumber(unsigned long long n, uint8 base) { - unsigned char buf[CHAR_BIT * sizeof(long long)]; - unsigned long i = 0; - size_t s=0; - if (n == 0) { - print('0'); - return 1; - } - - while (n > 0) { - buf[i++] = n % base; - n /= base; - } - - for (; i > 0; i--) { - s += print((char)(buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10)); - } - return s; -} - - -/* According to snprintf(), - * - * nextafter((double)numeric_limits::max(), 0.0) ~= 9.22337e+18 - * - * This slightly smaller value was picked semi-arbitrarily. */ -#define LARGE_DOUBLE_TRESHOLD (9.1e18) - -/* THIS FUNCTION SHOULDN'T BE USED IF YOU NEED ACCURATE RESULTS. - * - * This implementation is meant to be simple and not occupy too much - * code size. However, printing floating point values accurately is a - * subtle task, best left to a well-tested library function. - * - * See Steele and White 2003 for more details: - * - * http://kurtstephens.com/files/p372-steele.pdf - */ -size_t Print::printFloat(double number, uint8 digits) { -size_t s=0; - // Hackish fail-fast behavior for large-magnitude doubles - if (abs(number) >= LARGE_DOUBLE_TRESHOLD) { - if (number < 0.0) { - s=print('-'); - } - s+=print(""); - return s; - } - - // Handle negative numbers - if (number < 0.0) { - s+=print('-'); - number = -number; - } - - // Simplistic rounding strategy so that e.g. print(1.999, 2) - // prints as "2.00" - double rounding = 0.5; - for (uint8 i = 0; i < digits; i++) { - rounding /= 10.0; - } - number += rounding; - - // Extract the integer part of the number and print it - long long int_part = (long long)number; - double remainder = number - int_part; - s+=print(int_part); - - // Print the decimal point, but only if there are digits beyond - if (digits > 0) { - s+=print("."); - } - - // Extract digits from the remainder one at a time - while (digits-- > 0) { - remainder *= 10.0; - int to_print = (int)remainder; - s+=print(to_print); - remainder -= to_print; - } - return s; -} - diff --git a/GD32F1/cores/maple/Print.h b/GD32F1/cores/maple/Print.h deleted file mode 100644 index 5961a02..0000000 --- a/GD32F1/cores/maple/Print.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Print.h - Base class that provides print() and println() - * Copyright (c) 2008 David A. Mellis. All right reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA. - * - * Modified 12 April 2011 by Marti Bolivar - */ - -#ifndef _WIRISH_PRINT_H_ -#define _WIRISH_PRINT_H_ - -#include -#include "WString.h" - -enum { - BYTE = 0, - BIN = 2, - OCT = 8, - DEC = 10, - HEX = 16 -}; - -class Print { -public: - virtual size_t write(uint8 ch) = 0; - virtual size_t write(const char *str); - virtual size_t write(const void *buf, uint32 len); - - size_t print(const String &); - size_t print(char); - size_t print(const char[]); - size_t print(uint8, int=DEC); - size_t print(int, int=DEC); - size_t print(unsigned int, int=DEC); - size_t print(long, int=DEC); - size_t print(unsigned long, int=DEC); - size_t print(long long, int=DEC); - size_t print(unsigned long long, int=DEC); - size_t print(double, int=2); - size_t println(void); - size_t println(const String &s); - size_t println(char); - size_t println(const char[]); - size_t println(uint8, int=DEC); - size_t println(int, int=DEC); - size_t println(unsigned int, int=DEC); - size_t println(long, int=DEC); - size_t println(unsigned long, int=DEC); - size_t println(long long, int=DEC); - size_t println(unsigned long long, int=DEC); - size_t println(double, int=2); -#ifdef SUPPORTS_PRINTF -// Roger Clark. Work in progress to add printf support - int printf(const char * format, ...); -#endif - Print() : write_error(0) {} - - int getWriteError() { return write_error; } - void clearWriteError() { setWriteError(0); } - - protected: - void setWriteError(int err = 1) { write_error = err; } - -private: - int write_error; - size_t printNumber(unsigned long long, uint8); - size_t printFloat(double, uint8); -}; - -#endif diff --git a/GD32F1/cores/maple/Stream.cpp b/GD32F1/cores/maple/Stream.cpp deleted file mode 100644 index 9c581be..0000000 --- a/GD32F1/cores/maple/Stream.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* - Stream.cpp - adds parsing methods to Stream class - Copyright (c) 2008 David A. Mellis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Created July 2011 - parsing functions based on TextFinder library by Michael Margolis - */ - -#include "Arduino.h" -#include "Stream.h" - -#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait -#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field - -// private method to read stream with timeout -int Stream::timedRead() -{ - int c; - _startMillis = millis(); - do { - c = read(); - if (c >= 0) return c; - } while(millis() - _startMillis < _timeout); - return -1; // -1 indicates timeout -} - -// private method to peek stream with timeout -int Stream::timedPeek() -{ - int c; - _startMillis = millis(); - do { - c = peek(); - if (c >= 0) return c; - } while(millis() - _startMillis < _timeout); - return -1; // -1 indicates timeout -} - -// returns peek of the next digit in the stream or -1 if timeout -// discards non-numeric characters -int Stream::peekNextDigit() -{ - int c; - while (1) { - c = timedPeek(); - if (c < 0) return c; // timeout - if (c == '-') return c; - if (c >= '0' && c <= '9') return c; - read(); // discard non-numeric - } -} - -// Public Methods -////////////////////////////////////////////////////////////// - -void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait -{ - _timeout = timeout; -} - - // find returns true if the target string is found -bool Stream::find(char *target) -{ - return findUntil(target, (char*)""); -} - -// reads data from the stream until the target string of given length is found -// returns true if target string is found, false if timed out -bool Stream::find(char *target, size_t length) -{ - return findUntil(target, length, NULL, 0); -} - -// as find but search ends if the terminator string is found -bool Stream::findUntil(char *target, char *terminator) -{ - return findUntil(target, strlen(target), terminator, strlen(terminator)); -} - -// reads data from the stream until the target string of the given length is found -// search terminated if the terminator string is found -// returns true if target string is found, false if terminated or timed out -bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen) -{ - size_t index = 0; // maximum target string length is 64k bytes! - size_t termIndex = 0; - int c; - - if( *target == 0) - return true; // return true if target is a null string - while( (c = timedRead()) > 0){ - - if(c != target[index]) - index = 0; // reset index if any char does not match - - if( c == target[index]){ - //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); - if(++index >= targetLen){ // return true if all chars in the target match - return true; - } - } - - if(termLen > 0 && c == terminator[termIndex]){ - if(++termIndex >= termLen) - return false; // return false if terminate string found before target string - } - else - termIndex = 0; - } - return false; -} - - -// returns the first valid (long) integer value from the current position. -// initial characters that are not digits (or the minus sign) are skipped -// function is terminated by the first character that is not a digit. -long Stream::parseInt() -{ - return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) -} - -// as above but a given skipChar is ignored -// this allows format characters (typically commas) in values to be ignored -long Stream::parseInt(char skipChar) -{ - boolean isNegative = false; - long value = 0; - int c; - - c = peekNextDigit(); - // ignore non numeric leading characters - if(c < 0) - return 0; // zero returned if timeout - - do{ - if(c == skipChar) - ; // ignore this charactor - else if(c == '-') - isNegative = true; - else if(c >= '0' && c <= '9') // is c a digit? - value = value * 10 + c - '0'; - read(); // consume the character we got with peek - c = timedPeek(); - } - while( (c >= '0' && c <= '9') || c == skipChar ); - - if(isNegative) - value = -value; - return value; -} - - -// as parseInt but returns a floating point value -float Stream::parseFloat() -{ - return parseFloat(NO_SKIP_CHAR); -} - -// as above but the given skipChar is ignored -// this allows format characters (typically commas) in values to be ignored -float Stream::parseFloat(char skipChar){ - boolean isNegative = false; - boolean isFraction = false; - long value = 0; - int c; - float fraction = 1.0; - - c = peekNextDigit(); - // ignore non numeric leading characters - if(c < 0) - return 0; // zero returned if timeout - - do{ - if(c == skipChar) - ; // ignore - else if(c == '-') - isNegative = true; - else if (c == '.') - isFraction = true; - else if(c >= '0' && c <= '9') { // is c a digit? - value = value * 10 + c - '0'; - if(isFraction) - fraction *= 0.1; - } - read(); // consume the character we got with peek - c = timedPeek(); - } - while( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); - - if(isNegative) - value = -value; - if(isFraction) - return value * fraction; - else - return value; -} - -// read characters from stream into buffer -// terminates if length characters have been read, or timeout (see setTimeout) -// returns the number of characters placed in the buffer -// the buffer is NOT null terminated. -// -size_t Stream::readBytes(char *buffer, size_t length) -{ - size_t count = 0; - while (count < length) { - int c = timedRead(); - if (c < 0) break; - *buffer++ = (char)c; - count++; - } - return count; -} - - -// as readBytes with terminator character -// terminates if length characters have been read, timeout, or if the terminator character detected -// returns the number of characters placed in the buffer (0 means no valid data found) - -size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) -{ - if (length < 1) return 0; - size_t index = 0; - while (index < length) { - int c = timedRead(); - if (c < 0 || c == terminator) break; - *buffer++ = (char)c; - index++; - } - return index; // return number of characters, not including null terminator -} - -String Stream::readString() -{ - String ret; - int c = timedRead(); - while (c >= 0) - { - ret += (char)c; - c = timedRead(); - } - return ret; -} - -String Stream::readStringUntil(char terminator) -{ - String ret; - int c = timedRead(); - while (c >= 0 && c != terminator) - { - ret += (char)c; - c = timedRead(); - } - return ret; -} - diff --git a/GD32F1/cores/maple/Stream.h b/GD32F1/cores/maple/Stream.h deleted file mode 100644 index 5cf5ddf..0000000 --- a/GD32F1/cores/maple/Stream.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - Stream.h - base class for character-based streams. - Copyright (c) 2010 David A. Mellis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - parsing functions based on TextFinder library by Michael Margolis -*/ - -#ifndef Stream_h -#define Stream_h - -#include -#include "Print.h" - -// compatability macros for testing -/* -#define getInt() parseInt() -#define getInt(skipChar) parseInt(skipchar) -#define getFloat() parseFloat() -#define getFloat(skipChar) parseFloat(skipChar) -#define getString( pre_string, post_string, buffer, length) -readBytesBetween( pre_string, terminator, buffer, length) -*/ - -class Stream : public Print -{ - protected: - unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read - unsigned long _startMillis; // used for timeout measurement - int timedRead(); // private method to read stream with timeout - int timedPeek(); // private method to peek stream with timeout - int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout - - public: - virtual int available() = 0; - virtual int read() = 0; - virtual int peek() = 0; - virtual void flush() = 0; - - Stream() {_timeout=1000;} - -// parsing methods - - void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second - - bool find(char *target); // reads data from the stream until the target string is found - bool find(uint8_t *target) { return find ((char *)target); } - // returns true if target string is found, false if timed out (see setTimeout) - - bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found - bool find(uint8_t *target, size_t length) { return find ((char *)target, length); } - // returns true if target string is found, false if timed out - - bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found - bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); } - - bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found - bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); } - - - long parseInt(); // returns the first valid (long) integer value from the current position. - // initial characters that are not digits (or the minus sign) are skipped - // integer is terminated by the first character that is not a digit. - - float parseFloat(); // float version of parseInt - - size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer - size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); } - // terminates if length characters have been read or timeout (see setTimeout) - // returns the number of characters placed in the buffer (0 means no valid data found) - - size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character - size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); } - // terminates if length characters have been read, timeout, or if the terminator character detected - // returns the number of characters placed in the buffer (0 means no valid data found) - - // Arduino String functions to be added here - String readString(); - String readStringUntil(char terminator); - - protected: - long parseInt(char skipChar); // as above but the given skipChar is ignored - // as above but the given skipChar is ignored - // this allows format characters (typically commas) in values to be ignored - - float parseFloat(char skipChar); // as above but the given skipChar is ignored -}; - -#endif diff --git a/GD32F1/cores/maple/WProgram.h b/GD32F1/cores/maple/WProgram.h deleted file mode 100644 index 4e476d4..0000000 --- a/GD32F1/cores/maple/WProgram.h +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#ifndef _WIRISH_WPROGRAM_H_ -#define _WIRISH_WPROGRAM_H_ - -#include - -void setup(); -void loop(); - -#endif diff --git a/GD32F1/cores/maple/WString.cpp b/GD32F1/cores/maple/WString.cpp deleted file mode 100644 index 939ca0e..0000000 --- a/GD32F1/cores/maple/WString.cpp +++ /dev/null @@ -1,746 +0,0 @@ -/* - WString.cpp - String library for Wiring & Arduino - ...mostly rewritten by Paul Stoffregen... - Copyright (c) 2009-10 Hernando Barragan. All rights reserved. - Copyright 2011, Paul Stoffregen, paul@pjrc.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "WString.h" -#include "itoa.h" -#include "avr/dtostrf.h" - -/*********************************************/ -/* Constructors */ -/*********************************************/ - -String::String(const char *cstr) -{ - init(); - if (cstr) copy(cstr, strlen(cstr)); -} - -String::String(const String &value) -{ - init(); - *this = value; -} - -String::String(const __FlashStringHelper *pstr) -{ - init(); - *this = pstr; -} - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -String::String(String &&rval) -{ - init(); - move(rval); -} -String::String(StringSumHelper &&rval) -{ - init(); - move(rval); -} -#endif - -String::String(char c) -{ - init(); - char buf[2]; - buf[0] = c; - buf[1] = 0; - *this = buf; -} - -String::String(unsigned char value, unsigned char base) -{ - init(); - char buf[1 + 8 * sizeof(unsigned char)]; - utoa(value, buf, base); - *this = buf; -} - -String::String(int value, unsigned char base) -{ - init(); - char buf[2 + 8 * sizeof(int)]; - itoa(value, buf, base); - *this = buf; -} - -String::String(unsigned int value, unsigned char base) -{ - init(); - char buf[1 + 8 * sizeof(unsigned int)]; - utoa(value, buf, base); - *this = buf; -} - -String::String(long value, unsigned char base) -{ - init(); - char buf[2 + 8 * sizeof(long)]; - ltoa(value, buf, base); - *this = buf; -} - -String::String(unsigned long value, unsigned char base) -{ - init(); - char buf[1 + 8 * sizeof(unsigned long)]; - ultoa(value, buf, base); - *this = buf; -} - -String::String(float value, unsigned char decimalPlaces) -{ - init(); - char buf[33]; - *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); -} - -String::String(double value, unsigned char decimalPlaces) -{ - init(); - char buf[33]; - *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); -} - -String::~String() -{ - free(buffer); -} - -/*********************************************/ -/* Memory Management */ -/*********************************************/ - -inline void String::init(void) -{ - buffer = NULL; - capacity = 0; - len = 0; -} - -void String::invalidate(void) -{ - if (buffer) free(buffer); - buffer = NULL; - capacity = len = 0; -} - -unsigned char String::reserve(unsigned int size) -{ - if (buffer && capacity >= size) return 1; - if (changeBuffer(size)) { - if (len == 0) buffer[0] = 0; - return 1; - } - return 0; -} - -unsigned char String::changeBuffer(unsigned int maxStrLen) -{ - char *newbuffer = (char *)realloc(buffer, maxStrLen + 1); - if (newbuffer) { - buffer = newbuffer; - capacity = maxStrLen; - return 1; - } - return 0; -} - -/*********************************************/ -/* Copy and Move */ -/*********************************************/ - -String & String::copy(const char *cstr, unsigned int length) -{ - if (!reserve(length)) { - invalidate(); - return *this; - } - len = length; - strcpy(buffer, cstr); - return *this; -} - -String & String::copy(const __FlashStringHelper *pstr, unsigned int length) -{ - if (!reserve(length)) { - invalidate(); - return *this; - } - len = length; - strcpy_P(buffer, (PGM_P)pstr); - return *this; -} - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -void String::move(String &rhs) -{ - if (buffer) { - if (capacity >= rhs.len) { - strcpy(buffer, rhs.buffer); - len = rhs.len; - rhs.len = 0; - return; - } else { - free(buffer); - } - } - buffer = rhs.buffer; - capacity = rhs.capacity; - len = rhs.len; - rhs.buffer = NULL; - rhs.capacity = 0; - rhs.len = 0; -} -#endif - -String & String::operator = (const String &rhs) -{ - if (this == &rhs) return *this; - - if (rhs.buffer) copy(rhs.buffer, rhs.len); - else invalidate(); - - return *this; -} - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -String & String::operator = (String &&rval) -{ - if (this != &rval) move(rval); - return *this; -} - -String & String::operator = (StringSumHelper &&rval) -{ - if (this != &rval) move(rval); - return *this; -} -#endif - -String & String::operator = (const char *cstr) -{ - if (cstr) copy(cstr, strlen(cstr)); - else invalidate(); - - return *this; -} - -String & String::operator = (const __FlashStringHelper *pstr) -{ - if (pstr) copy(pstr, strlen_P((PGM_P)pstr)); - else invalidate(); - - return *this; -} - -/*********************************************/ -/* concat */ -/*********************************************/ - -unsigned char String::concat(const String &s) -{ - return concat(s.buffer, s.len); -} - -unsigned char String::concat(const char *cstr, unsigned int length) -{ - unsigned int newlen = len + length; - if (!cstr) return 0; - if (length == 0) return 1; - if (!reserve(newlen)) return 0; - strcpy(buffer + len, cstr); - len = newlen; - return 1; -} - -unsigned char String::concat(const char *cstr) -{ - if (!cstr) return 0; - return concat(cstr, strlen(cstr)); -} - -unsigned char String::concat(char c) -{ - char buf[2]; - buf[0] = c; - buf[1] = 0; - return concat(buf, 1); -} - -unsigned char String::concat(unsigned char num) -{ - char buf[1 + 3 * sizeof(unsigned char)]; - itoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(int num) -{ - char buf[2 + 3 * sizeof(int)]; - itoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(unsigned int num) -{ - char buf[1 + 3 * sizeof(unsigned int)]; - utoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(long num) -{ - char buf[2 + 3 * sizeof(long)]; - ltoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(unsigned long num) -{ - char buf[1 + 3 * sizeof(unsigned long)]; - ultoa(num, buf, 10); - return concat(buf, strlen(buf)); -} - -unsigned char String::concat(float num) -{ - char buf[20]; - char* string = dtostrf(num, 4, 2, buf); - return concat(string, strlen(string)); -} - -unsigned char String::concat(double num) -{ - char buf[20]; - char* string = dtostrf(num, 4, 2, buf); - return concat(string, strlen(string)); -} - -unsigned char String::concat(const __FlashStringHelper * str) -{ - if (!str) return 0; - int length = strlen_P((const char *) str); - if (length == 0) return 1; - unsigned int newlen = len + length; - if (!reserve(newlen)) return 0; - strcpy_P(buffer + len, (const char *) str); - len = newlen; - return 1; -} - -/*********************************************/ -/* Concatenate */ -/*********************************************/ - -StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(rhs.buffer, rhs.len)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr) -{ - StringSumHelper &a = const_cast(lhs); - if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, char c) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(c)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, int num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, long num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, float num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, double num) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(num)) a.invalidate(); - return a; -} - -StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs) -{ - StringSumHelper &a = const_cast(lhs); - if (!a.concat(rhs)) a.invalidate(); - return a; -} - -/*********************************************/ -/* Comparison */ -/*********************************************/ - -int String::compareTo(const String &s) const -{ - if (!buffer || !s.buffer) { - if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer; - if (buffer && len > 0) return *(unsigned char *)buffer; - return 0; - } - return strcmp(buffer, s.buffer); -} - -unsigned char String::equals(const String &s2) const -{ - return (len == s2.len && compareTo(s2) == 0); -} - -unsigned char String::equals(const char *cstr) const -{ - if (len == 0) return (cstr == NULL || *cstr == 0); - if (cstr == NULL) return buffer[0] == 0; - return strcmp(buffer, cstr) == 0; -} - -unsigned char String::operator<(const String &rhs) const -{ - return compareTo(rhs) < 0; -} - -unsigned char String::operator>(const String &rhs) const -{ - return compareTo(rhs) > 0; -} - -unsigned char String::operator<=(const String &rhs) const -{ - return compareTo(rhs) <= 0; -} - -unsigned char String::operator>=(const String &rhs) const -{ - return compareTo(rhs) >= 0; -} - -unsigned char String::equalsIgnoreCase( const String &s2 ) const -{ - if (this == &s2) return 1; - if (len != s2.len) return 0; - if (len == 0) return 1; - const char *p1 = buffer; - const char *p2 = s2.buffer; - while (*p1) { - if (tolower(*p1++) != tolower(*p2++)) return 0; - } - return 1; -} - -unsigned char String::startsWith( const String &s2 ) const -{ - if (len < s2.len) return 0; - return startsWith(s2, 0); -} - -unsigned char String::startsWith( const String &s2, unsigned int offset ) const -{ - if (offset > len - s2.len || !buffer || !s2.buffer) return 0; - return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0; -} - -unsigned char String::endsWith( const String &s2 ) const -{ - if ( len < s2.len || !buffer || !s2.buffer) return 0; - return strcmp(&buffer[len - s2.len], s2.buffer) == 0; -} - -/*********************************************/ -/* Character Access */ -/*********************************************/ - -char String::charAt(unsigned int loc) const -{ - return operator[](loc); -} - -void String::setCharAt(unsigned int loc, char c) -{ - if (loc < len) buffer[loc] = c; -} - -char & String::operator[](unsigned int index) -{ - static char dummy_writable_char; - if (index >= len || !buffer) { - dummy_writable_char = 0; - return dummy_writable_char; - } - return buffer[index]; -} - -char String::operator[]( unsigned int index ) const -{ - if (index >= len || !buffer) return 0; - return buffer[index]; -} - -void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const -{ - if (!bufsize || !buf) return; - if (index >= len) { - buf[0] = 0; - return; - } - unsigned int n = bufsize - 1; - if (n > len - index) n = len - index; - strncpy((char *)buf, buffer + index, n); - buf[n] = 0; -} - -/*********************************************/ -/* Search */ -/*********************************************/ - -int String::indexOf(char c) const -{ - return indexOf(c, 0); -} - -int String::indexOf( char ch, unsigned int fromIndex ) const -{ - if (fromIndex >= len) return -1; - const char* temp = strchr(buffer + fromIndex, ch); - if (temp == NULL) return -1; - return temp - buffer; -} - -int String::indexOf(const String &s2) const -{ - return indexOf(s2, 0); -} - -int String::indexOf(const String &s2, unsigned int fromIndex) const -{ - if (fromIndex >= len) return -1; - const char *found = strstr(buffer + fromIndex, s2.buffer); - if (found == NULL) return -1; - return found - buffer; -} - -int String::lastIndexOf( char theChar ) const -{ - return lastIndexOf(theChar, len - 1); -} - -int String::lastIndexOf(char ch, unsigned int fromIndex) const -{ - if (fromIndex >= len) return -1; - char tempchar = buffer[fromIndex + 1]; - buffer[fromIndex + 1] = '\0'; - char* temp = strrchr( buffer, ch ); - buffer[fromIndex + 1] = tempchar; - if (temp == NULL) return -1; - return temp - buffer; -} - -int String::lastIndexOf(const String &s2) const -{ - return lastIndexOf(s2, len - s2.len); -} - -int String::lastIndexOf(const String &s2, unsigned int fromIndex) const -{ - if (s2.len == 0 || len == 0 || s2.len > len) return -1; - if (fromIndex >= len) fromIndex = len - 1; - int found = -1; - for (char *p = buffer; p <= buffer + fromIndex; p++) { - p = strstr(p, s2.buffer); - if (!p) break; - if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer; - } - return found; -} - -String String::substring(unsigned int left, unsigned int right) const -{ - if (left > right) { - unsigned int temp = right; - right = left; - left = temp; - } - String out; - if (left > len) return out; - if (right > len) right = len; - char temp = buffer[right]; // save the replaced character - buffer[right] = '\0'; - out = buffer + left; // pointer arithmetic - buffer[right] = temp; //restore character - return out; -} - -/*********************************************/ -/* Modification */ -/*********************************************/ - -void String::replace(char find, char replace) -{ - if (!buffer) return; - for (char *p = buffer; *p; p++) { - if (*p == find) *p = replace; - } -} - -void String::replace(const String& find, const String& replace) -{ - if (len == 0 || find.len == 0) return; - int diff = replace.len - find.len; - char *readFrom = buffer; - char *foundAt; - if (diff == 0) { - while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { - memcpy(foundAt, replace.buffer, replace.len); - readFrom = foundAt + replace.len; - } - } else if (diff < 0) { - char *writeTo = buffer; - while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { - unsigned int n = foundAt - readFrom; - memcpy(writeTo, readFrom, n); - writeTo += n; - memcpy(writeTo, replace.buffer, replace.len); - writeTo += replace.len; - readFrom = foundAt + find.len; - len += diff; - } - strcpy(writeTo, readFrom); - } else { - unsigned int size = len; // compute size needed for result - while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { - readFrom = foundAt + find.len; - size += diff; - } - if (size == len) return; - if (size > capacity && !changeBuffer(size)) return; // XXX: tell user! - int index = len - 1; - while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { - readFrom = buffer + index + find.len; - memmove(readFrom + diff, readFrom, len - (readFrom - buffer)); - len += diff; - buffer[len] = 0; - memcpy(buffer + index, replace.buffer, replace.len); - index--; - } - } -} - -void String::remove(unsigned int index){ - if (index >= len) { return; } - int count = len - index; - remove(index, count); -} - -void String::remove(unsigned int index, unsigned int count){ - if (index >= len) { return; } - if (count <= 0) { return; } - if (index + count > len) { count = len - index; } - char *writeTo = buffer + index; - len = len - count; - strncpy(writeTo, buffer + index + count,len - index); - buffer[len] = 0; -} - -void String::toLowerCase(void) -{ - if (!buffer) return; - for (char *p = buffer; *p; p++) { - *p = tolower(*p); - } -} - -void String::toUpperCase(void) -{ - if (!buffer) return; - for (char *p = buffer; *p; p++) { - *p = toupper(*p); - } -} - -void String::trim(void) -{ - if (!buffer || len == 0) return; - char *begin = buffer; - while (isspace(*begin)) begin++; - char *end = buffer + len - 1; - while (isspace(*end) && end >= begin) end--; - len = end + 1 - begin; - if (begin > buffer) memcpy(buffer, begin, len); - buffer[len] = 0; -} - -/*********************************************/ -/* Parsing / Conversion */ -/*********************************************/ - -long String::toInt(void) const -{ - if (buffer) return atol(buffer); - return 0; -} - -float String::toFloat(void) const -{ - if (buffer) return float(atof(buffer)); - return 0; -} diff --git a/GD32F1/cores/maple/WString.h b/GD32F1/cores/maple/WString.h deleted file mode 100644 index 7402430..0000000 --- a/GD32F1/cores/maple/WString.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - WString.h - String library for Wiring & Arduino - ...mostly rewritten by Paul Stoffregen... - Copyright (c) 2009-10 Hernando Barragan. All right reserved. - Copyright 2011, Paul Stoffregen, paul@pjrc.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef String_class_h -#define String_class_h -#ifdef __cplusplus - -#include -#include -#include -#include - -// When compiling programs with this class, the following gcc parameters -// dramatically increase performance and memory (RAM) efficiency, typically -// with little or no increase in code size. -// -felide-constructors -// -std=c++0x - -class __FlashStringHelper; -#define F(string_literal) (reinterpret_cast(PSTR(string_literal))) - -// An inherited class for holding the result of a concatenation. These -// result objects are assumed to be writable by subsequent concatenations. -class StringSumHelper; - -// The string class -class String -{ - // use a function pointer to allow for "if (s)" without the - // complications of an operator bool(). for more information, see: - // http://www.artima.com/cppsource/safebool.html - typedef void (String::*StringIfHelperType)() const; - void StringIfHelper() const {} - -public: - // constructors - // creates a copy of the initial value. - // if the initial value is null or invalid, or if memory allocation - // fails, the string will be marked as invalid (i.e. "if (s)" will - // be false). - String(const char *cstr = ""); - String(const String &str); - String(const __FlashStringHelper *str); - #ifdef __GXX_EXPERIMENTAL_CXX0X__ - String(String &&rval); - String(StringSumHelper &&rval); - #endif - explicit String(char c); - explicit String(unsigned char, unsigned char base=10); - explicit String(int, unsigned char base=10); - explicit String(unsigned int, unsigned char base=10); - explicit String(long, unsigned char base=10); - explicit String(unsigned long, unsigned char base=10); - explicit String(float, unsigned char decimalPlaces=2); - explicit String(double, unsigned char decimalPlaces=2); - ~String(void); - - // memory management - // return true on success, false on failure (in which case, the string - // is left unchanged). reserve(0), if successful, will validate an - // invalid string (i.e., "if (s)" will be true afterwards) - unsigned char reserve(unsigned int size); - inline unsigned int length(void) const {return len;} - - // creates a copy of the assigned value. if the value is null or - // invalid, or if the memory allocation fails, the string will be - // marked as invalid ("if (s)" will be false). - String & operator = (const String &rhs); - String & operator = (const char *cstr); - String & operator = (const __FlashStringHelper *str); - #ifdef __GXX_EXPERIMENTAL_CXX0X__ - String & operator = (String &&rval); - String & operator = (StringSumHelper &&rval); - #endif - - // concatenate (works w/ built-in types) - - // returns true on success, false on failure (in which case, the string - // is left unchanged). if the argument is null or invalid, the - // concatenation is considered unsucessful. - unsigned char concat(const String &str); - unsigned char concat(const char *cstr); - unsigned char concat(char c); - unsigned char concat(unsigned char c); - unsigned char concat(int num); - unsigned char concat(unsigned int num); - unsigned char concat(long num); - unsigned char concat(unsigned long num); - unsigned char concat(float num); - unsigned char concat(double num); - unsigned char concat(const __FlashStringHelper * str); - - // if there's not enough memory for the concatenated value, the string - // will be left unchanged (but this isn't signalled in any way) - String & operator += (const String &rhs) {concat(rhs); return (*this);} - String & operator += (const char *cstr) {concat(cstr); return (*this);} - String & operator += (char c) {concat(c); return (*this);} - String & operator += (unsigned char num) {concat(num); return (*this);} - String & operator += (int num) {concat(num); return (*this);} - String & operator += (unsigned int num) {concat(num); return (*this);} - String & operator += (long num) {concat(num); return (*this);} - String & operator += (unsigned long num) {concat(num); return (*this);} - String & operator += (float num) {concat(num); return (*this);} - String & operator += (double num) {concat(num); return (*this);} - String & operator += (const __FlashStringHelper *str){concat(str); return (*this);} - - friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); - friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr); - friend StringSumHelper & operator + (const StringSumHelper &lhs, char c); - friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, int num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, long num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, float num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, double num); - friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs); - - // comparison (only works w/ Strings and "strings") - operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; } - int compareTo(const String &s) const; - unsigned char equals(const String &s) const; - unsigned char equals(const char *cstr) const; - unsigned char operator == (const String &rhs) const {return equals(rhs);} - unsigned char operator == (const char *cstr) const {return equals(cstr);} - unsigned char operator != (const String &rhs) const {return !equals(rhs);} - unsigned char operator != (const char *cstr) const {return !equals(cstr);} - unsigned char operator < (const String &rhs) const; - unsigned char operator > (const String &rhs) const; - unsigned char operator <= (const String &rhs) const; - unsigned char operator >= (const String &rhs) const; - unsigned char equalsIgnoreCase(const String &s) const; - unsigned char startsWith( const String &prefix) const; - unsigned char startsWith(const String &prefix, unsigned int offset) const; - unsigned char endsWith(const String &suffix) const; - - // character acccess - char charAt(unsigned int index) const; - void setCharAt(unsigned int index, char c); - char operator [] (unsigned int index) const; - char& operator [] (unsigned int index); - void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const; - void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const - {getBytes((unsigned char *)buf, bufsize, index);} - const char * c_str() const { return buffer; } - - // search - int indexOf( char ch ) const; - int indexOf( char ch, unsigned int fromIndex ) const; - int indexOf( const String &str ) const; - int indexOf( const String &str, unsigned int fromIndex ) const; - int lastIndexOf( char ch ) const; - int lastIndexOf( char ch, unsigned int fromIndex ) const; - int lastIndexOf( const String &str ) const; - int lastIndexOf( const String &str, unsigned int fromIndex ) const; - String substring( unsigned int beginIndex ) const { return substring(beginIndex, len); }; - String substring( unsigned int beginIndex, unsigned int endIndex ) const; - - // modification - void replace(char find, char replace); - void replace(const String& find, const String& replace); - void remove(unsigned int index); - void remove(unsigned int index, unsigned int count); - void toLowerCase(void); - void toUpperCase(void); - void trim(void); - - // parsing/conversion - long toInt(void) const; - float toFloat(void) const; - -protected: - char *buffer; // the actual char array - unsigned int capacity; // the array length minus one (for the '\0') - unsigned int len; // the String length (not counting the '\0') -protected: - void init(void); - void invalidate(void); - unsigned char changeBuffer(unsigned int maxStrLen); - unsigned char concat(const char *cstr, unsigned int length); - - // copy and move - String & copy(const char *cstr, unsigned int length); - String & copy(const __FlashStringHelper *pstr, unsigned int length); - #ifdef __GXX_EXPERIMENTAL_CXX0X__ - void move(String &rhs); - #endif -}; - -class StringSumHelper : public String -{ -public: - StringSumHelper(const String &s) : String(s) {} - StringSumHelper(const char *p) : String(p) {} - StringSumHelper(char c) : String(c) {} - StringSumHelper(unsigned char num) : String(num) {} - StringSumHelper(int num) : String(num) {} - StringSumHelper(unsigned int num) : String(num) {} - StringSumHelper(long num) : String(num) {} - StringSumHelper(unsigned long num) : String(num) {} - StringSumHelper(float num) : String(num) {} - StringSumHelper(double num) : String(num) {} -}; - -#endif // __cplusplus -#endif // String_class_h diff --git a/GD32F1/cores/maple/avr/dtostrf.c b/GD32F1/cores/maple/avr/dtostrf.c deleted file mode 100644 index 7f90154..0000000 --- a/GD32F1/cores/maple/avr/dtostrf.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - dtostrf - Emulation for dtostrf function from avr-libc - Copyright (c) 2013 Arduino. All rights reserved. - Written by Cristian Maglie - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include - -char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { - char fmt[20]; - sprintf(fmt, "%%%d.%df", width, prec); - sprintf(sout, fmt, val); - return sout; -} - diff --git a/GD32F1/cores/maple/avr/dtostrf.h b/GD32F1/cores/maple/avr/dtostrf.h deleted file mode 100644 index 0bf9f57..0000000 --- a/GD32F1/cores/maple/avr/dtostrf.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - dtostrf - Emulation for dtostrf function from avr-libc - Copyright (c) 2013 Arduino. All rights reserved. - Written by Cristian Maglie - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -char *dtostrf (double val, signed char width, unsigned char prec, char *sout); - -#ifdef __cplusplus -} -#endif diff --git a/GD32F1/cores/maple/avr/interrupt.h b/GD32F1/cores/maple/avr/interrupt.h deleted file mode 100644 index e69de29..0000000 diff --git a/GD32F1/cores/maple/avr/pgmspace.h b/GD32F1/cores/maple/avr/pgmspace.h deleted file mode 100644 index 9b344c9..0000000 --- a/GD32F1/cores/maple/avr/pgmspace.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __PGMSPACE_H_ -#define __PGMSPACE_H_ 1 - -#include - -#define PROGMEM -#define PGM_P const char * -#define PSTR(str) (str) - -#define _SFR_BYTE(n) (n) - -typedef void prog_void; -typedef char prog_char; -typedef unsigned char prog_uchar; -typedef int8_t prog_int8_t; -typedef uint8_t prog_uint8_t; -typedef int16_t prog_int16_t; -typedef uint16_t prog_uint16_t; -typedef int32_t prog_int32_t; -typedef uint32_t prog_uint32_t; - -#define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) -#define strcpy_P(dest, src) strcpy((dest), (src)) -#define strcat_P(dest, src) strcat((dest), (src)) -#define strcmp_P(a, b) strcmp((a), (b)) -#define strstr_P(a, b) strstr((a), (b)) -#define strlen_P(a) strlen((a)) -#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) - -#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) -#define pgm_read_word(addr) (*(const unsigned short *)(addr)) -#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) -#define pgm_read_float(addr) (*(const float *)(addr)) - -#define pgm_read_byte_near(addr) pgm_read_byte(addr) -#define pgm_read_word_near(addr) pgm_read_word(addr) -#define pgm_read_dword_near(addr) pgm_read_dword(addr) -#define pgm_read_float_near(addr) pgm_read_float(addr) -#define pgm_read_byte_far(addr) pgm_read_byte(addr) -#define pgm_read_word_far(addr) pgm_read_word(addr) -#define pgm_read_dword_far(addr) pgm_read_dword(addr) -#define pgm_read_float_far(addr) pgm_read_float(addr) - -#endif diff --git a/GD32F1/cores/maple/bit_constants.h b/GD32F1/cores/maple/bit_constants.h deleted file mode 100644 index 4638f76..0000000 --- a/GD32F1/cores/maple/bit_constants.h +++ /dev/null @@ -1,579 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @brief BIT[n] and binary literal defines, for Arduino - * compatibility. - */ - -#ifndef _WIRISH_BIT_CONSTANTS_H_ -#define _WIRISH_BIT_CONSTANTS_H_ - -#define BIT0 (1 << 0) -#define BIT1 (1 << 1) -#define BIT2 (1 << 2) -#define BIT3 (1 << 3) -#define BIT4 (1 << 4) -#define BIT5 (1 << 5) -#define BIT6 (1 << 6) -#define BIT7 (1 << 7) -#define BIT8 (1 << 8) -#define BIT9 (1 << 9) -#define BIT10 (1 << 10) -#define BIT11 (1 << 11) -#define BIT12 (1 << 12) -#define BIT13 (1 << 13) -#define BIT14 (1 << 14) -#define BIT15 (1 << 15) -#define BIT16 (1 << 16) -#define BIT17 (1 << 17) -#define BIT18 (1 << 18) -#define BIT19 (1 << 19) -#define BIT20 (1 << 20) -#define BIT21 (1 << 21) -#define BIT22 (1 << 22) -#define BIT23 (1 << 23) -#define BIT24 (1 << 24) -#define BIT25 (1 << 25) -#define BIT26 (1 << 26) -#define BIT27 (1 << 27) -#define BIT28 (1 << 28) -#define BIT29 (1 << 29) -#define BIT30 (1 << 30) -#define BIT31 (1 << 31) - -#define B0 0 -#define B00 0 -#define B000 0 -#define B0000 0 -#define B00000 0 -#define B000000 0 -#define B0000000 0 -#define B00000000 0 -#define B1 1 -#define B01 1 -#define B001 1 -#define B0001 1 -#define B00001 1 -#define B000001 1 -#define B0000001 1 -#define B00000001 1 -#define B10 2 -#define B010 2 -#define B0010 2 -#define B00010 2 -#define B000010 2 -#define B0000010 2 -#define B00000010 2 -#define B11 3 -#define B011 3 -#define B0011 3 -#define B00011 3 -#define B000011 3 -#define B0000011 3 -#define B00000011 3 -#define B100 4 -#define B0100 4 -#define B00100 4 -#define B000100 4 -#define B0000100 4 -#define B00000100 4 -#define B101 5 -#define B0101 5 -#define B00101 5 -#define B000101 5 -#define B0000101 5 -#define B00000101 5 -#define B110 6 -#define B0110 6 -#define B00110 6 -#define B000110 6 -#define B0000110 6 -#define B00000110 6 -#define B111 7 -#define B0111 7 -#define B00111 7 -#define B000111 7 -#define B0000111 7 -#define B00000111 7 -#define B1000 8 -#define B01000 8 -#define B001000 8 -#define B0001000 8 -#define B00001000 8 -#define B1001 9 -#define B01001 9 -#define B001001 9 -#define B0001001 9 -#define B00001001 9 -#define B1010 10 -#define B01010 10 -#define B001010 10 -#define B0001010 10 -#define B00001010 10 -#define B1011 11 -#define B01011 11 -#define B001011 11 -#define B0001011 11 -#define B00001011 11 -#define B1100 12 -#define B01100 12 -#define B001100 12 -#define B0001100 12 -#define B00001100 12 -#define B1101 13 -#define B01101 13 -#define B001101 13 -#define B0001101 13 -#define B00001101 13 -#define B1110 14 -#define B01110 14 -#define B001110 14 -#define B0001110 14 -#define B00001110 14 -#define B1111 15 -#define B01111 15 -#define B001111 15 -#define B0001111 15 -#define B00001111 15 -#define B10000 16 -#define B010000 16 -#define B0010000 16 -#define B00010000 16 -#define B10001 17 -#define B010001 17 -#define B0010001 17 -#define B00010001 17 -#define B10010 18 -#define B010010 18 -#define B0010010 18 -#define B00010010 18 -#define B10011 19 -#define B010011 19 -#define B0010011 19 -#define B00010011 19 -#define B10100 20 -#define B010100 20 -#define B0010100 20 -#define B00010100 20 -#define B10101 21 -#define B010101 21 -#define B0010101 21 -#define B00010101 21 -#define B10110 22 -#define B010110 22 -#define B0010110 22 -#define B00010110 22 -#define B10111 23 -#define B010111 23 -#define B0010111 23 -#define B00010111 23 -#define B11000 24 -#define B011000 24 -#define B0011000 24 -#define B00011000 24 -#define B11001 25 -#define B011001 25 -#define B0011001 25 -#define B00011001 25 -#define B11010 26 -#define B011010 26 -#define B0011010 26 -#define B00011010 26 -#define B11011 27 -#define B011011 27 -#define B0011011 27 -#define B00011011 27 -#define B11100 28 -#define B011100 28 -#define B0011100 28 -#define B00011100 28 -#define B11101 29 -#define B011101 29 -#define B0011101 29 -#define B00011101 29 -#define B11110 30 -#define B011110 30 -#define B0011110 30 -#define B00011110 30 -#define B11111 31 -#define B011111 31 -#define B0011111 31 -#define B00011111 31 -#define B100000 32 -#define B0100000 32 -#define B00100000 32 -#define B100001 33 -#define B0100001 33 -#define B00100001 33 -#define B100010 34 -#define B0100010 34 -#define B00100010 34 -#define B100011 35 -#define B0100011 35 -#define B00100011 35 -#define B100100 36 -#define B0100100 36 -#define B00100100 36 -#define B100101 37 -#define B0100101 37 -#define B00100101 37 -#define B100110 38 -#define B0100110 38 -#define B00100110 38 -#define B100111 39 -#define B0100111 39 -#define B00100111 39 -#define B101000 40 -#define B0101000 40 -#define B00101000 40 -#define B101001 41 -#define B0101001 41 -#define B00101001 41 -#define B101010 42 -#define B0101010 42 -#define B00101010 42 -#define B101011 43 -#define B0101011 43 -#define B00101011 43 -#define B101100 44 -#define B0101100 44 -#define B00101100 44 -#define B101101 45 -#define B0101101 45 -#define B00101101 45 -#define B101110 46 -#define B0101110 46 -#define B00101110 46 -#define B101111 47 -#define B0101111 47 -#define B00101111 47 -#define B110000 48 -#define B0110000 48 -#define B00110000 48 -#define B110001 49 -#define B0110001 49 -#define B00110001 49 -#define B110010 50 -#define B0110010 50 -#define B00110010 50 -#define B110011 51 -#define B0110011 51 -#define B00110011 51 -#define B110100 52 -#define B0110100 52 -#define B00110100 52 -#define B110101 53 -#define B0110101 53 -#define B00110101 53 -#define B110110 54 -#define B0110110 54 -#define B00110110 54 -#define B110111 55 -#define B0110111 55 -#define B00110111 55 -#define B111000 56 -#define B0111000 56 -#define B00111000 56 -#define B111001 57 -#define B0111001 57 -#define B00111001 57 -#define B111010 58 -#define B0111010 58 -#define B00111010 58 -#define B111011 59 -#define B0111011 59 -#define B00111011 59 -#define B111100 60 -#define B0111100 60 -#define B00111100 60 -#define B111101 61 -#define B0111101 61 -#define B00111101 61 -#define B111110 62 -#define B0111110 62 -#define B00111110 62 -#define B111111 63 -#define B0111111 63 -#define B00111111 63 -#define B1000000 64 -#define B01000000 64 -#define B1000001 65 -#define B01000001 65 -#define B1000010 66 -#define B01000010 66 -#define B1000011 67 -#define B01000011 67 -#define B1000100 68 -#define B01000100 68 -#define B1000101 69 -#define B01000101 69 -#define B1000110 70 -#define B01000110 70 -#define B1000111 71 -#define B01000111 71 -#define B1001000 72 -#define B01001000 72 -#define B1001001 73 -#define B01001001 73 -#define B1001010 74 -#define B01001010 74 -#define B1001011 75 -#define B01001011 75 -#define B1001100 76 -#define B01001100 76 -#define B1001101 77 -#define B01001101 77 -#define B1001110 78 -#define B01001110 78 -#define B1001111 79 -#define B01001111 79 -#define B1010000 80 -#define B01010000 80 -#define B1010001 81 -#define B01010001 81 -#define B1010010 82 -#define B01010010 82 -#define B1010011 83 -#define B01010011 83 -#define B1010100 84 -#define B01010100 84 -#define B1010101 85 -#define B01010101 85 -#define B1010110 86 -#define B01010110 86 -#define B1010111 87 -#define B01010111 87 -#define B1011000 88 -#define B01011000 88 -#define B1011001 89 -#define B01011001 89 -#define B1011010 90 -#define B01011010 90 -#define B1011011 91 -#define B01011011 91 -#define B1011100 92 -#define B01011100 92 -#define B1011101 93 -#define B01011101 93 -#define B1011110 94 -#define B01011110 94 -#define B1011111 95 -#define B01011111 95 -#define B1100000 96 -#define B01100000 96 -#define B1100001 97 -#define B01100001 97 -#define B1100010 98 -#define B01100010 98 -#define B1100011 99 -#define B01100011 99 -#define B1100100 100 -#define B01100100 100 -#define B1100101 101 -#define B01100101 101 -#define B1100110 102 -#define B01100110 102 -#define B1100111 103 -#define B01100111 103 -#define B1101000 104 -#define B01101000 104 -#define B1101001 105 -#define B01101001 105 -#define B1101010 106 -#define B01101010 106 -#define B1101011 107 -#define B01101011 107 -#define B1101100 108 -#define B01101100 108 -#define B1101101 109 -#define B01101101 109 -#define B1101110 110 -#define B01101110 110 -#define B1101111 111 -#define B01101111 111 -#define B1110000 112 -#define B01110000 112 -#define B1110001 113 -#define B01110001 113 -#define B1110010 114 -#define B01110010 114 -#define B1110011 115 -#define B01110011 115 -#define B1110100 116 -#define B01110100 116 -#define B1110101 117 -#define B01110101 117 -#define B1110110 118 -#define B01110110 118 -#define B1110111 119 -#define B01110111 119 -#define B1111000 120 -#define B01111000 120 -#define B1111001 121 -#define B01111001 121 -#define B1111010 122 -#define B01111010 122 -#define B1111011 123 -#define B01111011 123 -#define B1111100 124 -#define B01111100 124 -#define B1111101 125 -#define B01111101 125 -#define B1111110 126 -#define B01111110 126 -#define B1111111 127 -#define B01111111 127 -#define B10000000 128 -#define B10000001 129 -#define B10000010 130 -#define B10000011 131 -#define B10000100 132 -#define B10000101 133 -#define B10000110 134 -#define B10000111 135 -#define B10001000 136 -#define B10001001 137 -#define B10001010 138 -#define B10001011 139 -#define B10001100 140 -#define B10001101 141 -#define B10001110 142 -#define B10001111 143 -#define B10010000 144 -#define B10010001 145 -#define B10010010 146 -#define B10010011 147 -#define B10010100 148 -#define B10010101 149 -#define B10010110 150 -#define B10010111 151 -#define B10011000 152 -#define B10011001 153 -#define B10011010 154 -#define B10011011 155 -#define B10011100 156 -#define B10011101 157 -#define B10011110 158 -#define B10011111 159 -#define B10100000 160 -#define B10100001 161 -#define B10100010 162 -#define B10100011 163 -#define B10100100 164 -#define B10100101 165 -#define B10100110 166 -#define B10100111 167 -#define B10101000 168 -#define B10101001 169 -#define B10101010 170 -#define B10101011 171 -#define B10101100 172 -#define B10101101 173 -#define B10101110 174 -#define B10101111 175 -#define B10110000 176 -#define B10110001 177 -#define B10110010 178 -#define B10110011 179 -#define B10110100 180 -#define B10110101 181 -#define B10110110 182 -#define B10110111 183 -#define B10111000 184 -#define B10111001 185 -#define B10111010 186 -#define B10111011 187 -#define B10111100 188 -#define B10111101 189 -#define B10111110 190 -#define B10111111 191 -#define B11000000 192 -#define B11000001 193 -#define B11000010 194 -#define B11000011 195 -#define B11000100 196 -#define B11000101 197 -#define B11000110 198 -#define B11000111 199 -#define B11001000 200 -#define B11001001 201 -#define B11001010 202 -#define B11001011 203 -#define B11001100 204 -#define B11001101 205 -#define B11001110 206 -#define B11001111 207 -#define B11010000 208 -#define B11010001 209 -#define B11010010 210 -#define B11010011 211 -#define B11010100 212 -#define B11010101 213 -#define B11010110 214 -#define B11010111 215 -#define B11011000 216 -#define B11011001 217 -#define B11011010 218 -#define B11011011 219 -#define B11011100 220 -#define B11011101 221 -#define B11011110 222 -#define B11011111 223 -#define B11100000 224 -#define B11100001 225 -#define B11100010 226 -#define B11100011 227 -#define B11100100 228 -#define B11100101 229 -#define B11100110 230 -#define B11100111 231 -#define B11101000 232 -#define B11101001 233 -#define B11101010 234 -#define B11101011 235 -#define B11101100 236 -#define B11101101 237 -#define B11101110 238 -#define B11101111 239 -#define B11110000 240 -#define B11110001 241 -#define B11110010 242 -#define B11110011 243 -#define B11110100 244 -#define B11110101 245 -#define B11110110 246 -#define B11110111 247 -#define B11111000 248 -#define B11111001 249 -#define B11111010 250 -#define B11111011 251 -#define B11111100 252 -#define B11111101 253 -#define B11111110 254 -#define B11111111 255 - -#endif /* _BIT_CONSTANTS_H_ */ diff --git a/GD32F1/cores/maple/bits.h b/GD32F1/cores/maple/bits.h deleted file mode 100644 index 6b27f80..0000000 --- a/GD32F1/cores/maple/bits.h +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* Note: Use of this header file is deprecated. Use bit_constants.h - instead. */ - -#ifndef _WIRISH_BITS_H_ -#define _WIRISH_BITS_H_ - -#include - -#endif diff --git a/GD32F1/cores/maple/boards.h b/GD32F1/cores/maple/boards.h deleted file mode 100644 index 16a9670..0000000 --- a/GD32F1/cores/maple/boards.h +++ /dev/null @@ -1,172 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Bryan Newbold. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/boards.h - * @author Bryan Newbold , - * Marti Bolivar - * @brief init() and board-specific pin information. - */ - -#ifndef _WIRISH_BOARDS_H_ -#define _WIRISH_BOARDS_H_ - -#include -#include -#include - -/* Set of all possible pin names; not all boards have all these (note - * that we use the Dx convention since all of the Maple's pins are - * "digital" pins (e.g. can be used with digitalRead() and - * digitalWrite()), but not all of them are connected to ADCs. */ -enum { - D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, - D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30, D31, - D32, D33, D34, D35, D36, D37, D38, D39, D40, D41, D42, D43, D44, D45, D46, - D47, D48, D49, D50, D51, D52, D53, D54, D55, D56, D57, D58, D59, D60, D61, - D62, D63, D64, D65, D66, D67, D68, D69, D70, D71, D72, D73, D74, D75, D76, - D77, D78, D79, D80, D81, D82, D83, D84, D85, D86, D87, D88, D89, D90, D91, - D92, D93, D94, D95, D96, D97, D98, D99, D100, D101, D102, D103, D104, D105, - D106, D107, D108, D109, D110, D111, }; - -/** - * @brief Maps each Maple pin to a corresponding stm32_pin_info. - * @see stm32_pin_info - */ -extern const stm32_pin_info PIN_MAP[]; - -/** - * @brief Pins capable of PWM output. - * - * Its length is BOARD_NR_PWM_PINS. - */ -extern const uint8 boardPWMPins[]; - -/** - * @brief Array of pins capable of analog input. - * - * Its length is BOARD_NR_ADC_PINS. - */ -extern const uint8 boardADCPins[]; - -/** - * @brief Pins which are connected to external hardware. - * - * For example, on Maple boards, it always at least includes - * PB1 for the LED. Its length is BOARD_NR_USED_PINS. - */ -extern const uint8 boardUsedPins[]; - -/** - * @brief Generic board initialization function. - * - * This function is called before main(). It ensures that the clocks - * and peripherals are configured properly for use with wirish, then - * calls boardInit(). - * - * @see boardInit() - */ -void init(void); - -/** - * @brief Board-specific initialization function. - * - * This function is called from init() after all generic board - * initialization has been performed. Each board is required to - * define its own. - * - * @see init() - */ -extern void boardInit(void); - -/** - * @brief Test if a pin is used for a special purpose on your board. - * @param pin Pin to test - * @return true if the given pin is in boardUsedPins, and false otherwise. - * @see boardUsedPins - */ -bool boardUsesPin(uint8 pin); - -/* - * Derived and default board definitions - */ - -#define CLOCK_SPEED_MHZ CYCLES_PER_MICROSECOND -#define CLOCK_SPEED_HZ (CLOCK_SPEED_MHZ * 1000000UL) - - -#ifndef BOARD_BUTTON_PRESSED_LEVEL -#define BOARD_BUTTON_PRESSED_LEVEL HIGH -#endif - -/** - * @brief Does the board break out a USART/UART's RX and TX pins? - * - * BOARD_HAVE_USART(n) is nonzero iff USARTn is available (n must be - * an integer literal, 1 through 6). Also see BOARD_HAVE_USART1, ..., - * BOARD_HAVE_UART4 (sic), etc. - */ -#define BOARD_HAVE_USART(n) (defined(BOARD_USART##n##_TX_PIN) && \ - defined(BOARD_USART##n##_RX_PIN)) -/** Feature test: nonzero iff the board has USART1. */ -#define BOARD_HAVE_USART1 BOARD_HAVE_USART(1) -/** Feature test: nonzero iff the board has USART2, 0 otherwise. */ -#define BOARD_HAVE_USART2 BOARD_HAVE_USART(2) -/** Feature test: nonzero iff the board has USART3, 0 otherwise. */ -#define BOARD_HAVE_USART3 BOARD_HAVE_USART(3) -/** Feature test: nonzero iff the board has UART4, 0 otherwise. */ -#define BOARD_HAVE_UART4 BOARD_HAVE_USART(4) -/** Feature test: nonzero iff the board has UART5, 0 otherwise. */ -#define BOARD_HAVE_UART5 BOARD_HAVE_USART(5) -/** Feature test: nonzero iff the board has USART6, 0 otherwise. */ -#define BOARD_HAVE_USART6 BOARD_HAVE_USART(6) - -/** - * @brief Does the board break out a SPI peripheral's pins? - * - * BOARD_HAVE_SPI(n) is nonzero iff SPIn is available (n must be an - * integer literal: 1, 2, or 3). Also see BOARD_HAVE_SPI1, - * BOARD_HAVE_SPI2, BOARD_HAVE_SPI3. */ -#define BOARD_HAVE_SPI(n) (defined(BOARD_SPI##n##_NSS_PIN) && \ - defined(BOARD_SPI##n##_SCK_PIN) && \ - defined(BOARD_SPI##n##_MISO_PIN) && \ - defined(BOARD_SPI##n##_MOSI_PIN)) -/** Feature test: nonzero iff the board has SPI1. */ -#define BOARD_HAVE_SPI1 BOARD_HAVE_SPI(1) -/** Feature test: nonzero iff the board has SPI2. */ -#define BOARD_HAVE_SPI2 BOARD_HAVE_SPI(2) -/** Feature test: nonzero iff the board has SPI3. */ -#define BOARD_HAVE_SPI3 BOARD_HAVE_SPI(3) - -/** - * @brief Feature test: nonzero iff the board has SerialUSB. - */ - //Roger Clark. Change so that BOARD_HAVE_SERIALUSB is always true, so that it can be controller by -DSERIAL_USB -#define BOARD_HAVE_SERIALUSB 1 - -/*(defined(BOARD_USB_DISC_DEV) && defined(BOARD_USB_DISC_BIT))*/ - -#endif diff --git a/GD32F1/cores/maple/boards_private.h b/GD32F1/cores/maple/boards_private.h deleted file mode 100644 index 49867ca..0000000 --- a/GD32F1/cores/maple/boards_private.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/boards_private.h - * @author Marti Bolivar - * @brief Private board support header. - * - * This file declares chip-specific variables and functions which - * determine how init() behaves. It is not part of the public Wirish - * API, and can change without notice. - */ - -#ifndef _WIRISH_BOARDS_PRIVATE_H_ -#define _WIRISH_BOARDS_PRIVATE_H_ - -#include -#include - -/* Makes the PIN_MAP rows more human-readable. */ -#define PMAP_ROW(gpio_dev, gpio_bit, timer_dev, timer_ch, adc_dev, adc_ch) \ - { gpio_dev, timer_dev, adc_dev, gpio_bit, timer_ch, adc_ch } - -namespace wirish { - namespace priv { - - /* - * Chip-specific initialization data - */ - - extern rcc_pll_cfg w_board_pll_cfg; - extern adc_prescaler w_adc_pre; - extern adc_smp_rate w_adc_smp; - - /* - * Chip-specific initialization routines and helper functions. - */ - - void board_reset_pll(void); - void board_setup_clock_prescalers(void); - void board_setup_gpio(void); - void board_setup_usb(void); - void series_init(void); - - } -} - -#endif diff --git a/GD32F1/cores/maple/cxxabi-compat.cpp b/GD32F1/cores/maple/cxxabi-compat.cpp deleted file mode 100644 index 516b112..0000000 --- a/GD32F1/cores/maple/cxxabi-compat.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/* We compile with nodefaultlibs, so we need to provide an error - * handler for an empty pure virtual function */ -extern "C" void __cxa_pure_virtual(void) { - while(1) - ; -} diff --git a/GD32F1/cores/maple/ext_interrupts.cpp b/GD32F1/cores/maple/ext_interrupts.cpp deleted file mode 100644 index c78912f..0000000 --- a/GD32F1/cores/maple/ext_interrupts.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/ext_interrupts.cpp - * @brief Wiring-like interface for external interrupts - */ - -#include "ext_interrupts.h" - -#include -#include - -#include "boards.h" - -static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode); - -void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode) { - if (pin >= BOARD_NR_GPIO_PINS || !handler) { - return; - } - - exti_trigger_mode outMode = exti_out_mode(mode); - - exti_attach_interrupt((exti_num)(PIN_MAP[pin].gpio_bit), - gpio_exti_port(PIN_MAP[pin].gpio_device), - handler, - outMode); -} - -void attachInterrupt(uint8 pin, voidArgumentFuncPtr handler, void *arg, - ExtIntTriggerMode mode) { - if (pin >= BOARD_NR_GPIO_PINS || !handler) { - return; - } - - exti_trigger_mode outMode = exti_out_mode(mode); - - exti_attach_callback((exti_num)(PIN_MAP[pin].gpio_bit), - gpio_exti_port(PIN_MAP[pin].gpio_device), - handler, - arg, - outMode); -} - -void detachInterrupt(uint8 pin) { - if (pin >= BOARD_NR_GPIO_PINS) { - return; - } - - exti_detach_interrupt((exti_num)(PIN_MAP[pin].gpio_bit)); -} - -static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode) { - switch (mode) { - case RISING: - return EXTI_RISING; - case FALLING: - return EXTI_FALLING; - case CHANGE: - return EXTI_RISING_FALLING; - } - // Can't happen - ASSERT(0); - return (exti_trigger_mode)0; -} diff --git a/GD32F1/cores/maple/ext_interrupts.h b/GD32F1/cores/maple/ext_interrupts.h deleted file mode 100644 index ce1ca03..0000000 --- a/GD32F1/cores/maple/ext_interrupts.h +++ /dev/null @@ -1,128 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/ext_interrupts.h - * @brief Wiring-like external interrupt prototypes and types. - */ - -#ifndef _WIRISH_EXT_INTERRUPTS_H_ -#define _WIRISH_EXT_INTERRUPTS_H_ - -#include -#include - -/** - * The kind of transition on an external pin which should trigger an - * interrupt. - */ -typedef enum ExtIntTriggerMode { - RISING, /**< To trigger an interrupt when the pin transitions LOW - to HIGH */ - FALLING, /**< To trigger an interrupt when the pin transitions - HIGH to LOW */ - CHANGE /**< To trigger an interrupt when the pin transitions from - LOW to HIGH or HIGH to LOW (i.e., when the pin - changes). */ -} ExtIntTriggerMode; - -/** - * @brief Registers an interrupt handler on a pin. - * - * The interrupt will be triggered on a given transition on the pin, - * as specified by the mode parameter. The handler runs in interrupt - * context. The new handler will replace whatever handler is - * currently registered for the pin, if any. - * - * @param pin Pin number - * @param handler Function to run upon external interrupt trigger. - * The handler should take no arguments, and have void - * return type. - * @param mode Type of transition to trigger on, e.g. falling, rising, etc. - * - * @sideeffect Registers a handler - * @see detachInterrupt() - */ -void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode); - -/** - * @brief Registers an interrupt handler on a pin. - * - * The interrupt will be triggered on a given transition on the pin, - * as specified by the mode parameter. The handler runs in interrupt - * context. The new handler will replace whatever handler is - * currently registered for the pin, if any. - * - * @param pin Pin number - * @param handler Static class member function to run upon external interrupt - * trigger. The handler should take 1 argument and return void - * @param arg Argument that the handler will be passed when it's called. One - * use of this is to pass the specific instance of the class that - * will handle the interrupt. - * @param mode Type of transition to trigger on, e.g. falling, rising, etc. - * - * @sideeffect Registers a handler - * @see detachInterrupt() - */ -void attachInterrupt(uint8 pin, voidArgumentFuncPtr handler, void *arg, - ExtIntTriggerMode mode); - -/** - * @brief Disable any registered external interrupt. - * @param pin Maple pin number - * @sideeffect unregisters external interrupt handler - * @see attachInterrupt() - */ -void detachInterrupt(uint8 pin); - -/** - * Re-enable interrupts. - * - * Call this after noInterrupts() to re-enable interrupt handling, - * after you have finished with a timing-critical section of code. - * - * @see noInterrupts() - */ -static __always_inline void interrupts() { - nvic_globalirq_enable(); -} - -/** - * Disable interrupts. - * - * After calling this function, all user-programmable interrupts will - * be disabled. You can call this function before a timing-critical - * section of code, then call interrupts() to re-enable interrupt - * handling. - * - * @see interrupts() - */ -static __always_inline void noInterrupts() { - nvic_globalirq_disable(); -} - -#endif - diff --git a/GD32F1/cores/maple/hooks.c b/GD32F1/cores/maple/hooks.c deleted file mode 100644 index 641eabc..0000000 --- a/GD32F1/cores/maple/hooks.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (c) 2012 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -/** - * Empty yield() hook. - * - * This function is intended to be used by library writers to build - * libraries or sketches that supports cooperative threads. - * - * Its defined as a weak symbol and it can be redefined to implement a - * real cooperative scheduler. - */ -static void __empty() { - // Empty -} -void yield(void) __attribute__ ((weak, alias("__empty"))); diff --git a/GD32F1/cores/maple/io.h b/GD32F1/cores/maple/io.h deleted file mode 100644 index ce54461..0000000 --- a/GD32F1/cores/maple/io.h +++ /dev/null @@ -1,163 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/io.h - * @brief Wiring-style pin I/O interface. - */ - -#ifndef _WIRISH_IO_H_ -#define _WIRISH_IO_H_ - -#include -#include - -/** - * Specifies a GPIO pin behavior. - * @see pinMode() - */ -typedef enum WiringPinMode { - OUTPUT, /**< Basic digital output: when the pin is HIGH, the - voltage is held at +3.3v (Vcc) and when it is LOW, it - is pulled down to ground. */ - - OUTPUT_OPEN_DRAIN, /**< In open drain mode, the pin indicates - "low" by accepting current flow to ground - and "high" by providing increased - impedance. An example use would be to - connect a pin to a bus line (which is pulled - up to a positive voltage by a separate - supply through a large resistor). When the - pin is high, not much current flows through - to ground and the line stays at positive - voltage; when the pin is low, the bus - "drains" to ground with a small amount of - current constantly flowing through the large - resistor from the external supply. In this - mode, no current is ever actually sourced - from the pin. */ - - INPUT, /**< Basic digital input. The pin voltage is sampled; when - it is closer to 3.3v (Vcc) the pin status is high, and - when it is closer to 0v (ground) it is low. If no - external circuit is pulling the pin voltage to high or - low, it will tend to randomly oscillate and be very - sensitive to noise (e.g., a breath of air across the pin - might cause the state to flip). */ - - INPUT_ANALOG, /**< This is a special mode for when the pin will be - used for analog (not digital) reads. Enables ADC - conversion to be performed on the voltage at the - pin. */ - - INPUT_PULLUP, /**< The state of the pin in this mode is reported - the same way as with INPUT, but the pin voltage - is gently "pulled up" towards +3.3v. This means - the state will be high unless an external device - is specifically pulling the pin down to ground, - in which case the "gentle" pull up will not - affect the state of the input. */ - - INPUT_PULLDOWN, /**< The state of the pin in this mode is reported - the same way as with INPUT, but the pin voltage - is gently "pulled down" towards 0v. This means - the state will be low unless an external device - is specifically pulling the pin up to 3.3v, in - which case the "gentle" pull down will not - affect the state of the input. */ - - INPUT_FLOATING, /**< Synonym for INPUT. */ - - PWM, /**< This is a special mode for when the pin will be used for - PWM output (a special case of digital output). */ - - PWM_OPEN_DRAIN, /**< Like PWM, except that instead of alternating - cycles of LOW and HIGH, the voltage on the pin - consists of alternating cycles of LOW and - floating (disconnected). */ -} WiringPinMode; - -/** - * Configure behavior of a GPIO pin. - * - * @param pin Number of pin to configure. - * @param mode Mode corresponding to desired pin behavior. - * @see WiringPinMode - */ -void pinMode(uint8 pin, WiringPinMode mode); - -#define HIGH 0x1 -#define LOW 0x0 - -/** - * Writes a (digital) value to a pin. The pin must have its - * mode set to OUTPUT or OUTPUT_OPEN_DRAIN. - * - * @param pin Pin to write to. - * @param value Either LOW (write a 0) or HIGH (write a 1). - * @see pinMode() - */ -void digitalWrite(uint8 pin, uint8 value); - -/** - * Read a digital value from a pin. The pin must have its mode set to - * one of INPUT, INPUT_PULLUP, and INPUT_PULLDOWN. - * - * @param pin Pin to read from. - * @return LOW or HIGH. - * @see pinMode() - */ -uint32 digitalRead(uint8 pin); - -/** - * Read an analog value from pin. This function blocks during ADC - * conversion, and has 12 bits of resolution. The pin must have its - * mode set to INPUT_ANALOG. - * - * @param pin Pin to read from. - * @return Converted voltage, in the range 0--4095, (i.e. a 12-bit ADC - * conversion). - * @see pinMode() - */ -uint16 analogRead(uint8 pin); - -/** - * Shift out a byte of data, one bit at a time. - * - * This function starts at either the most significant or least - * significant bit in a byte value, and shifts out each byte in order - * onto a data pin. After each bit is written to the data pin, a - * separate clock pin is pulsed to indicate that the new bit is - * available. - * - * @param dataPin Pin to shift data out on - * @param clockPin Pin to pulse after each bit is shifted out - * @param bitOrder Either MSBFIRST (big-endian) or LSBFIRST (little-endian). - * @param value Value to shift out - */ -void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 value); - -#endif diff --git a/GD32F1/cores/maple/itoa.c b/GD32F1/cores/maple/itoa.c deleted file mode 100644 index fc35766..0000000 --- a/GD32F1/cores/maple/itoa.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - Copyright (c) 2011 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "itoa.h" -#include - -#ifdef __cplusplus -extern "C"{ -#endif // __cplusplus - -#if 0 -/* reverse: reverse string s in place */ -static void reverse( char s[] ) -{ - int i, j ; - char c ; - - for ( i = 0, j = strlen(s)-1 ; i < j ; i++, j-- ) - { - c = s[i] ; - s[i] = s[j] ; - s[j] = c ; - } -} - -/* itoa: convert n to characters in s */ -extern void itoa( int n, char s[] ) -{ - int i, sign ; - - if ( (sign = n) < 0 ) /* record sign */ - { - n = -n; /* make n positive */ - } - - i = 0; - do - { /* generate digits in reverse order */ - s[i++] = n % 10 + '0'; /* get next digit */ - } while ((n /= 10) > 0) ; /* delete it */ - - if (sign < 0 ) - { - s[i++] = '-'; - } - - s[i] = '\0'; - - reverse( s ) ; -} - -#else - -extern char* itoa( int value, char *string, int radix ) -{ - return ltoa( value, string, radix ) ; -} - -extern char* ltoa( long value, char *string, int radix ) -{ - char tmp[33]; - char *tp = tmp; - long i; - unsigned long v; - int sign; - char *sp; - - if ( string == NULL ) - { - return 0 ; - } - - if (radix > 36 || radix <= 1) - { - return 0 ; - } - - sign = (radix == 10 && value < 0); - if (sign) - { - v = -value; - } - else - { - v = (unsigned long)value; - } - - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } - - sp = string; - - if (sign) - *sp++ = '-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - - return string; -} - -extern char* utoa( unsigned long value, char *string, int radix ) -{ - return ultoa( value, string, radix ) ; -} - -extern char* ultoa( unsigned long value, char *string, int radix ) -{ - char tmp[33]; - char *tp = tmp; - long i; - unsigned long v = value; - char *sp; - - if ( string == NULL ) - { - return 0; - } - - if (radix > 36 || radix <= 1) - { - return 0; - } - - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } - - sp = string; - - - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - - return string; -} -#endif /* 0 */ - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus diff --git a/GD32F1/cores/maple/itoa.h b/GD32F1/cores/maple/itoa.h deleted file mode 100644 index 59af109..0000000 --- a/GD32F1/cores/maple/itoa.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (c) 2011 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _ITOA_ -#define _ITOA_ - -#ifdef __cplusplus -extern "C"{ -#endif // __cplusplus - -#if 0 - -extern void itoa( int n, char s[] ) ; - -#else - -extern char* itoa( int value, char *string, int radix ) ; -extern char* ltoa( long value, char *string, int radix ) ; -extern char* utoa( unsigned long value, char *string, int radix ) ; -extern char* ultoa( unsigned long value, char *string, int radix ) ; -#endif /* 0 */ - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif // _ITOA_ diff --git a/GD32F1/cores/maple/libmaple/adc.c b/GD32F1/cores/maple/libmaple/adc.c deleted file mode 100644 index 7ea85dd..0000000 --- a/GD32F1/cores/maple/libmaple/adc.c +++ /dev/null @@ -1,109 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/adc.c - * @author Marti Bolivar , - * Perry Hung - * @brief Analog to digital converter routines - */ - -#include -#include -#include - -/** - * @brief Initialize an ADC peripheral. - * - * Initializes the RCC clock line for the given peripheral. Resets - * ADC device registers. - * - * @param dev ADC peripheral to initialize - */ -void adc_init(const adc_dev *dev) { - rcc_clk_enable(dev->clk_id); - rcc_reset_dev(dev->clk_id); -} - -/** - * @brief Set external event select for regular group - * @param dev ADC device - * @param event Event used to trigger the start of conversion. - * @see adc_extsel_event - */ -void adc_set_extsel(const adc_dev *dev, adc_extsel_event event) { - uint32 cr2 = dev->regs->CR2; - cr2 &= ~ADC_CR2_EXTSEL; - cr2 |= event; - dev->regs->CR2 = cr2; -} - -/** - * @brief Set the sample rate for all channels on an ADC device. - * - * Don't call this during conversion. - * - * @param dev adc device - * @param smp_rate sample rate to set - * @see adc_smp_rate - */ -void adc_set_sample_rate(const adc_dev *dev, adc_smp_rate smp_rate) { - uint32 adc_smpr1_val = 0, adc_smpr2_val = 0; - int i; - - for (i = 0; i < 10; i++) { - if (i < 8) { - /* ADC_SMPR1 determines sample time for channels [10,17] */ - adc_smpr1_val |= smp_rate << (i * 3); - } - /* ADC_SMPR2 determines sample time for channels [0,9] */ - adc_smpr2_val |= smp_rate << (i * 3); - } - - dev->regs->SMPR1 = adc_smpr1_val; - dev->regs->SMPR2 = adc_smpr2_val; -} - -/** - * @brief Perform a single synchronous software triggered conversion on a - * channel. - * @param dev ADC device to use for reading. - * @param channel channel to convert - * @return conversion result - */ -uint16 adc_read(const adc_dev *dev, uint8 channel) { - adc_reg_map *regs = dev->regs; - - adc_set_reg_seqlen(dev, 1); - - regs->SQR3 = channel; - regs->CR2 |= ADC_CR2_SWSTART; - while (!(regs->SR & ADC_SR_EOC)) - ; - - return (uint16)(regs->DR & ADC_DR_DATA); -} diff --git a/GD32F1/cores/maple/libmaple/adc_f1.c b/GD32F1/cores/maple/libmaple/adc_f1.c deleted file mode 100644 index 68b74e0..0000000 --- a/GD32F1/cores/maple/libmaple/adc_f1.c +++ /dev/null @@ -1,115 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/adc.c - * @author Marti Bolivar , - * Perry Hung - * @brief STM32F1 ADC support. - */ - -#include -#include - -/* - * Devices - */ - -adc_dev adc1 = { - .regs = ADC1_BASE, - .clk_id = RCC_ADC1, -}; -/** ADC1 device. */ -const adc_dev *ADC1 = &adc1; - -adc_dev adc2 = { - .regs = ADC2_BASE, - .clk_id = RCC_ADC2, -}; -/** ADC2 device. */ -const adc_dev *ADC2 = &adc2; - -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -adc_dev adc3 = { - .regs = ADC3_BASE, - .clk_id = RCC_ADC3, -}; -/** ADC3 device. */ -const adc_dev *ADC3 = &adc3; -#endif - -/* - * STM32F1 routines - */ - -/** - * @brief Calibrate an ADC peripheral - * - * Availability: STM32F1. - * - * @param dev adc device - */ -void adc_calibrate(const adc_dev *dev) { - __io uint32 *rstcal_bit = bb_perip(&(dev->regs->CR2), 3); - __io uint32 *cal_bit = bb_perip(&(dev->regs->CR2), 2); - - *rstcal_bit = 1; - while (*rstcal_bit) - ; - - *cal_bit = 1; - while (*cal_bit) - ; -} - -/* - * Common routines - */ - -void adc_set_prescaler(adc_prescaler pre) { - rcc_set_prescaler(RCC_PRESCALER_ADC, (uint32)pre); -} - -void adc_foreach(void (*fn)(const adc_dev*)) { - fn(ADC1); - fn(ADC2); -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) - fn(ADC3); -#endif -} - -void adc_config_gpio(const adc_dev *ignored, gpio_dev *gdev, uint8 bit) { - gpio_set_mode(gdev, bit, GPIO_INPUT_ANALOG); -} - -void adc_enable_single_swstart(const adc_dev *dev) { - adc_init(dev); - adc_set_extsel(dev, ADC_SWSTART); - adc_set_exttrig(dev, 1); - adc_enable(dev); - adc_calibrate(dev); -} diff --git a/GD32F1/cores/maple/libmaple/bkp_f1.c b/GD32F1/cores/maple/libmaple/bkp_f1.c deleted file mode 100644 index 01ad419..0000000 --- a/GD32F1/cores/maple/libmaple/bkp_f1.c +++ /dev/null @@ -1,129 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/bkp.c - * @brief STM32F1 Backup register support. - */ - -#include -#include -#include -#include - -static inline __io uint32* data_register(uint8 reg); - -bkp_dev bkp = { - .regs = BKP_BASE, -}; -/** Backup device. */ -const bkp_dev *BKP = &bkp; - -/** - * @brief Initialize backup interface. - * - * Enables the power and backup interface clocks, and resets the - * backup device. - */ -void bkp_init(void) { - /* Don't call pwr_init(), or you'll reset the device. We just - * need the clock. */ - rcc_clk_enable(RCC_PWR); - rcc_clk_enable(RCC_BKP); - rcc_reset_dev(RCC_BKP); -} - -/** - * Enable write access to the backup registers. Backup interface must - * be initialized for subsequent register writes to work. - * @see bkp_init() - */ -void bkp_enable_writes(void) { - *bb_perip(&PWR_BASE->CR, PWR_CR_DBP_BIT) = 1; -} - -/** - * Disable write access to the backup registers. - */ -void bkp_disable_writes(void) { - *bb_perip(&PWR_BASE->CR, PWR_CR_DBP_BIT) = 0; -} - -/** - * Read a value from given backup data register. - * @param reg Data register to read, from 1 to BKP_NR_DATA_REGS (10 on - * medium-density devices, 42 on high-density devices). - */ -uint16 bkp_read(uint8 reg) { - __io uint32* dr = data_register(reg); - if (!dr) { - ASSERT(0); /* nonexistent register */ - return 0; - } - return (uint16)*dr; -} - -/** - * @brief Write a value to given data register. - * - * Write access to backup registers must be enabled. - * - * @param reg Data register to write, from 1 to BKP_NR_DATA_REGS (10 - * on medium-density devices, 42 on high-density devices). - * @param val Value to write into the register. - * @see bkp_enable_writes() - */ -void bkp_write(uint8 reg, uint16 val) { - __io uint32* dr = data_register(reg); - if (!dr) { - ASSERT(0); /* nonexistent register */ - return; - } - *dr = (uint32)val; -} - -/* - * Data register memory layout is not contiguous. It's split up from - * 1--NR_LOW_DRS, beginning at BKP_BASE->DR1, through to - * (NR_LOW_DRS+1)--BKP_NR_DATA_REGS, beginning at BKP_BASE->DR11. - */ -#define NR_LOW_DRS 10 - -static inline __io uint32* data_register(uint8 reg) { - if (reg < 1 || reg > BKP_NR_DATA_REGS) { - return 0; - } - -#if BKP_NR_DATA_REGS == NR_LOW_DRS - return (uint32*)BKP_BASE + reg; -#else - if (reg <= NR_LOW_DRS) { - return (uint32*)BKP_BASE + reg; - } else { - return (uint32*)&(BKP_BASE->DR11) + (reg - NR_LOW_DRS - 1); - } -#endif -} diff --git a/GD32F1/cores/maple/libmaple/dac.c b/GD32F1/cores/maple/libmaple/dac.c deleted file mode 100644 index d802d2b..0000000 --- a/GD32F1/cores/maple/libmaple/dac.c +++ /dev/null @@ -1,120 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Bryan Newbold. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/dac.c - * @brief Digital to analog converter support. - */ - -#include -#include -#include - -#if STM32_HAVE_DAC -dac_dev dac = { - .regs = DAC_BASE, -}; -const dac_dev *DAC = &dac; -#endif - -/** - * @brief Initialize the digital to analog converter - * @param dev DAC device - * @param flags Flags: - * DAC_CH1: Enable channel 1 - * DAC_CH2: Enable channel 2 - * @sideeffect May set PA4 or PA5 to INPUT_ANALOG - */ -void dac_init(const dac_dev *dev, uint32 flags) { - /* First turn on the clock */ - rcc_clk_enable(RCC_DAC); - rcc_reset_dev(RCC_DAC); - - if (flags & DAC_CH1) { - dac_enable_channel(dev, 1); - } - - if (flags & DAC_CH2) { - dac_enable_channel(dev, 2); - } -} - -/** - * @brief Write a 12-bit value to the DAC to output - * @param dev DAC device - * @param channel channel to select (1 or 2) - * @param val value to write - */ -void dac_write_channel(const dac_dev *dev, uint8 channel, uint16 val) { - switch(channel) { - case 1: - dev->regs->DHR12R1 = DAC_DHR12R1_DACC1DHR & val; - break; - case 2: - dev->regs->DHR12R2 = DAC_DHR12R2_DACC2DHR & val; - break; - } -} - -/** - * @brief Enable a DAC channel - * @param dev DAC device - * @param channel channel to enable, either 1 or 2 - * @sideeffect May change pin mode of PA4 or PA5 - */ -void dac_enable_channel(const dac_dev *dev, uint8 channel) { - /* - * Setup ANALOG mode on PA4 and PA5. This mapping is consistent - * across all supported STM32s with a DAC. - */ - switch (channel) { - case 1: - gpio_set_mode(GPIOA, 4, GPIO_MODE_ANALOG); - dev->regs->CR |= DAC_CR_EN1; - break; - case 2: - gpio_set_mode(GPIOA, 5, GPIO_MODE_ANALOG); - dev->regs->CR |= DAC_CR_EN2; - break; - } -} - -/** - * @brief Disable a DAC channel - * @param dev DAC device - * @param channel channel to disable, either 1 or 2 - */ -void dac_disable_channel(const dac_dev *dev, uint8 channel) { - switch (channel) { - case 1: - dev->regs->CR &= ~DAC_CR_EN1; - break; - case 2: - dev->regs->CR &= ~DAC_CR_EN2; - break; - } -} diff --git a/GD32F1/cores/maple/libmaple/dma.c b/GD32F1/cores/maple/libmaple/dma.c deleted file mode 100644 index d13de10..0000000 --- a/GD32F1/cores/maple/libmaple/dma.c +++ /dev/null @@ -1,82 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Michael Hope. - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/dma.c - * @author Marti Bolivar ; - * Original implementation by Michael Hope - * @brief Portable DMA routines. - */ - -#include -#include "dma_private.h" -#include "stm32_private.h" - -/* - * Convenience routines - */ - -/** - * @brief Initialize a DMA device. - * @param dev Device to initialize. - */ -void dma_init(dma_dev *dev) { - rcc_clk_enable(dev->clk_id); -} - -/* - * Private API - */ - -enum dma_atype _dma_addr_type(__io void *addr) { - switch (stm32_block_purpose((void*)addr)) { - /* Notice we're treating the code block as memory here. That's - * correct for addresses in Flash and in [0x0, 0x7FFFFFF] - * (provided that those addresses are aliased to Flash, SRAM, or - * FSMC, depending on BOOT[01] and possibly SYSCFG_MEMRMP). It's - * not correct for other addresses in the code block, but those - * will (hopefully) just fail-fast with transfer or bus errors. If - * lots of people get confused, it might be worth being more - * careful here. */ - case STM32_BLOCK_CODE: /* Fall through */ - case STM32_BLOCK_SRAM: /* ... */ - case STM32_BLOCK_FSMC_1_2: /* ... */ - case STM32_BLOCK_FSMC_3_4: - return DMA_ATYPE_MEM; - case STM32_BLOCK_PERIPH: - return DMA_ATYPE_PER; - case STM32_BLOCK_FSMC_REG: /* Fall through */ - /* Is this right? I can't think of a reason to DMA into or out - * of the FSMC registers. [mbolivar] */ - case STM32_BLOCK_UNUSED: /* ... */ - case STM32_BLOCK_CORTEX_INTERNAL: /* ... */ - return DMA_ATYPE_OTHER; - default: - ASSERT(0); /* Can't happen */ - return DMA_ATYPE_OTHER; - } -} diff --git a/GD32F1/cores/maple/libmaple/dma_f1.c b/GD32F1/cores/maple/libmaple/dma_f1.c deleted file mode 100644 index 6400d15..0000000 --- a/GD32F1/cores/maple/libmaple/dma_f1.c +++ /dev/null @@ -1,413 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Michael Hope. - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/dma.c - * @author Marti Bolivar ; - * Original implementation by Michael Hope - * @brief STM32F1 DMA support. - */ - -#include -#include - -/* Hack to ensure inlining in dma_irq_handler() */ -#define DMA_GET_HANDLER(dev, tube) (dev->handlers[tube - 1].handler) -#include "dma_private.h" - -/* - * Devices - */ - -static dma_dev dma1 = { - .regs = DMA1_BASE, - .clk_id = RCC_DMA1, - .handlers = {{ .handler = NULL, .irq_line = NVIC_DMA_CH1 }, - { .handler = NULL, .irq_line = NVIC_DMA_CH2 }, - { .handler = NULL, .irq_line = NVIC_DMA_CH3 }, - { .handler = NULL, .irq_line = NVIC_DMA_CH4 }, - { .handler = NULL, .irq_line = NVIC_DMA_CH5 }, - { .handler = NULL, .irq_line = NVIC_DMA_CH6 }, - { .handler = NULL, .irq_line = NVIC_DMA_CH7 }}, -}; -/** STM32F1 DMA1 device */ -dma_dev *DMA1 = &dma1; - -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -static dma_dev dma2 = { - .regs = DMA2_BASE, - .clk_id = RCC_DMA2, - .handlers = {{ .handler = NULL, .irq_line = NVIC_DMA2_CH1 }, - { .handler = NULL, .irq_line = NVIC_DMA2_CH2 }, - { .handler = NULL, .irq_line = NVIC_DMA2_CH3 }, - { .handler = NULL, .irq_line = NVIC_DMA2_CH_4_5 }, - { .handler = NULL, .irq_line = NVIC_DMA2_CH_4_5 }}, /* !@#$ */ -}; -/** STM32F1 DMA2 device */ -dma_dev *DMA2 = &dma2; -#endif - -/* - * Auxiliary routines - */ - -/* Can channel serve cfg->tube_req_src? */ -static int cfg_req_ok(dma_channel channel, dma_tube_config *cfg) { - return (cfg->tube_req_src & 0x7) == channel; -} - -/* Can dev serve cfg->tube_req_src? */ -static int cfg_dev_ok(dma_dev *dev, dma_tube_config *cfg) { - return (rcc_clk_id)(cfg->tube_req_src >> 3) == dev->clk_id; -} - -/* Is addr acceptable for use as DMA src/dst? */ -static int cfg_mem_ok(__io void *addr) { - enum dma_atype atype = _dma_addr_type(addr); - return atype == DMA_ATYPE_MEM || atype == DMA_ATYPE_PER; -} - -/* Is the direction implied by src->dst supported? */ -static int cfg_dir_ok(dma_tube_config *cfg) { - /* We can't do peripheral->peripheral transfers. */ - return ((_dma_addr_type(cfg->tube_src) == DMA_ATYPE_MEM) || - (_dma_addr_type(cfg->tube_dst) == DMA_ATYPE_MEM)); -} - -static int preconfig_check(dma_dev *dev, dma_channel channel, - dma_tube_config *cfg) { - if (!cfg_req_ok(channel, cfg)) { - return -DMA_TUBE_CFG_EREQ; - } - if (cfg->tube_nr_xfers > 65535) { - return -DMA_TUBE_CFG_ENDATA; - } - if (!cfg_dev_ok(dev, cfg)) { - return -DMA_TUBE_CFG_EDEV; - } - if (!cfg_mem_ok(cfg->tube_src)) { - return -DMA_TUBE_CFG_ESRC; - } - if (!cfg_mem_ok(cfg->tube_dst)) { - return -DMA_TUBE_CFG_EDST; - } - if (!cfg_dir_ok(cfg)) { - return -DMA_TUBE_CFG_EDIR; - } - return DMA_TUBE_CFG_SUCCESS; -} - -static inline void set_ccr(dma_tube_reg_map *chregs, - dma_xfer_size msize, int minc, - dma_xfer_size psize, int pinc, - uint32 other_flags) { - chregs->CCR = ((msize << 10) | (psize << 8) | - (minc ? DMA_CCR_MINC : 0) | (pinc ? DMA_CCR_PINC : 0) | - other_flags); -} - -static inline uint32 cfg_ccr_flags(unsigned tube_flags) { - /* DMA_CFG_SRC_INC and DMA_CFG_DST_INC are special */ - return tube_flags & ~(DMA_CFG_SRC_INC | DMA_CFG_DST_INC); -} - -/* Configure chregs according to cfg, where cfg->tube_dst is peripheral. */ -static int config_to_per(dma_tube_reg_map *chregs, dma_tube_config *cfg) { - /* Check that ->tube_src is memory (if it's anything else, we - * shouldn't have been called). */ - ASSERT(_dma_addr_type(cfg->tube_src) == DMA_ATYPE_MEM); - - set_ccr(chregs, - cfg->tube_src_size, cfg->tube_flags & DMA_CFG_SRC_INC, - cfg->tube_dst_size, cfg->tube_flags & DMA_CFG_DST_INC, - (cfg_ccr_flags(cfg->tube_flags) | DMA_CCR_DIR_FROM_MEM)); - chregs->CNDTR = cfg->tube_nr_xfers; - chregs->CMAR = (uint32)cfg->tube_src; - chregs->CPAR = (uint32)cfg->tube_dst; - return DMA_TUBE_CFG_SUCCESS; -} - -/* Configure chregs according to cfg, where cfg->tube_dst is memory. */ -static int config_to_mem(dma_tube_reg_map *chregs, dma_tube_config *cfg) { - uint32 mem2mem; - - if ((_dma_addr_type(cfg->tube_src) == DMA_ATYPE_MEM) && - (cfg->tube_flags & DMA_CFG_CIRC)) { - /* Can't do mem-to-mem and circular mode */ - return -DMA_TUBE_CFG_ECFG; - } - - mem2mem = (_dma_addr_type(cfg->tube_src) == DMA_ATYPE_MEM ? - DMA_CCR_MEM2MEM : 0); - set_ccr(chregs, - cfg->tube_dst_size, cfg->tube_flags & DMA_CFG_DST_INC, - cfg->tube_src_size, cfg->tube_flags & DMA_CFG_SRC_INC, - (cfg_ccr_flags(cfg->tube_flags) | - DMA_CCR_DIR_FROM_PER | - mem2mem)); - chregs->CNDTR = cfg->tube_nr_xfers; - chregs->CMAR = (uint32)cfg->tube_dst; - chregs->CPAR = (uint32)cfg->tube_src; - return DMA_TUBE_CFG_SUCCESS; -} - -/* - * Routines - */ - -int dma_tube_cfg(dma_dev *dev, dma_channel channel, dma_tube_config *cfg) { - dma_tube_reg_map *chregs; - int ret = preconfig_check(dev, channel, cfg); - - if (ret < 0) { - return ret; - } - - dma_disable(dev, channel); /* Must disable before reconfiguring */ - dma_clear_isr_bits(dev, channel); /* For sanity and consistency - * with STM32F2. */ - - chregs = dma_tube_regs(dev, channel); - switch (_dma_addr_type(cfg->tube_dst)) { - case DMA_ATYPE_PER: - ret = config_to_per(chregs, cfg); - break; - case DMA_ATYPE_MEM: - ret = config_to_mem(chregs, cfg); - break; - default: - /* Can't happen */ - ASSERT(0); - return -DMA_TUBE_CFG_ECFG; - } - if (ret < 0) { - return ret; - } - chregs->CNDTR = cfg->tube_nr_xfers; - return DMA_TUBE_CFG_SUCCESS; -} - -void dma_set_priority(dma_dev *dev, - dma_channel channel, - dma_priority priority) { - dma_channel_reg_map *channel_regs; - uint32 ccr; - - ASSERT_FAULT(!dma_is_channel_enabled(dev, channel)); - - channel_regs = dma_channel_regs(dev, channel); - ccr = channel_regs->CCR; - ccr &= ~DMA_CCR_PL; - ccr |= (priority << 12); - channel_regs->CCR = ccr; -} - -void dma_set_num_transfers(dma_dev *dev, - dma_channel channel, - uint16 num_transfers) { - dma_channel_reg_map *channel_regs; - - ASSERT_FAULT(!dma_is_channel_enabled(dev, channel)); - - channel_regs = dma_channel_regs(dev, channel); - channel_regs->CNDTR = num_transfers; -} - -void dma_attach_interrupt(dma_dev *dev, dma_channel channel, - void (*handler)(void)) { - DMA_GET_HANDLER(dev, channel) = handler; - nvic_irq_enable(dev->handlers[channel - 1].irq_line); -} - -void dma_detach_interrupt(dma_dev *dev, dma_channel channel) { - /* Don't use nvic_irq_disable()! Think about DMA2 channels 4 and 5. */ - dma_channel_regs(dev, channel)->CCR &= ~0xF; - DMA_GET_HANDLER(dev, channel) = NULL; -} - -void dma_enable(dma_dev *dev, dma_channel channel) { - dma_channel_reg_map *chan_regs = dma_channel_regs(dev, channel); - bb_peri_set_bit(&chan_regs->CCR, DMA_CCR_EN_BIT, 1); -} - -void dma_disable(dma_dev *dev, dma_channel channel) { - dma_channel_reg_map *chan_regs = dma_channel_regs(dev, channel); - bb_peri_set_bit(&chan_regs->CCR, DMA_CCR_EN_BIT, 0); -} - -dma_irq_cause dma_get_irq_cause(dma_dev *dev, dma_channel channel) { - /* Grab and clear the ISR bits. */ - uint8 status_bits = dma_get_isr_bits(dev, channel); - dma_clear_isr_bits(dev, channel); - - /* If the channel global interrupt flag is cleared, then - * something's very wrong. */ - ASSERT(status_bits & 0x1); - /* If GIF is set, then some other flag should be set, barring - * something unexpected (e.g. the user making an unforeseen IFCR - * write). */ - ASSERT(status_bits != 0x1); - - /* ISR flags get set even if the corresponding interrupt enable - * bits in the channel's configuration register are cleared, so we - * can't use a switch here. - * - * Don't change the order of these if statements. */ - if (status_bits & 0x8) { - return DMA_TRANSFER_ERROR; - } else if (status_bits & 0x2) { - return DMA_TRANSFER_COMPLETE; - } else if (status_bits & 0x4) { - return DMA_TRANSFER_HALF_COMPLETE; - } - - /* If we get here, one of our assumptions has been violated, but - * the debug level is too low for the above ASSERTs() to have had - * any effect. In order to fail fast, mimic the DMA controller's - * behavior when an error occurs. */ - dma_disable(dev, channel); - return DMA_TRANSFER_ERROR; -} - -void dma_set_mem_addr(dma_dev *dev, dma_channel channel, __io void *addr) { - dma_channel_reg_map *chan_regs; - - ASSERT_FAULT(!dma_is_channel_enabled(dev, channel)); - - chan_regs = dma_channel_regs(dev, channel); - chan_regs->CMAR = (uint32)addr; -} - -void dma_set_per_addr(dma_dev *dev, dma_channel channel, __io void *addr) { - dma_channel_reg_map *chan_regs; - - ASSERT_FAULT(!dma_is_channel_enabled(dev, channel)); - - chan_regs = dma_channel_regs(dev, channel); - chan_regs->CPAR = (uint32)addr; -} - -/** - * @brief Deprecated. Use dma_tube_cfg() instead. - * - * Set up a DMA transfer. - * - * The channel will be disabled before being reconfigured. The - * transfer will have low priority by default. You may choose another - * priority before the transfer begins using dma_set_priority(), as - * well as performing any other configuration you desire. When the - * channel is configured to your liking, enable it using dma_enable(). - * - * @param dev DMA device. - * @param channel DMA channel. - * @param peripheral_address Base address of peripheral data register - * involved in the transfer. - * @param peripheral_size Peripheral data transfer size. - * @param memory_address Base memory address involved in the transfer. - * @param memory_size Memory data transfer size. - * @param mode Logical OR of dma_mode_flags - * - * @see dma_tube_cfg() - * - * @sideeffect Disables the given DMA channel. - * @see dma_xfer_size - * @see dma_mode_flags - * @see dma_set_num_transfers() - * @see dma_set_priority() - * @see dma_attach_interrupt() - * @see dma_enable() - */ -__deprecated -void dma_setup_transfer(dma_dev *dev, - dma_channel channel, - __io void *peripheral_address, - dma_xfer_size peripheral_size, - __io void *memory_address, - dma_xfer_size memory_size, - uint32 mode) { - dma_channel_reg_map *channel_regs = dma_channel_regs(dev, channel); - - dma_disable(dev, channel); /* can't write to CMAR/CPAR otherwise */ - channel_regs->CCR = (memory_size << 10) | (peripheral_size << 8) | mode; - channel_regs->CMAR = (uint32)memory_address; - channel_regs->CPAR = (uint32)peripheral_address; -} - -/* - * IRQ handlers - */ - -void __irq_dma1_channel1(void) { - dma_irq_handler(DMA1, DMA_CH1); -} - -void __irq_dma1_channel2(void) { - dma_irq_handler(DMA1, DMA_CH2); -} - -void __irq_dma1_channel3(void) { - dma_irq_handler(DMA1, DMA_CH3); -} - -void __irq_dma1_channel4(void) { - dma_irq_handler(DMA1, DMA_CH4); -} - -void __irq_dma1_channel5(void) { - dma_irq_handler(DMA1, DMA_CH5); -} - -void __irq_dma1_channel6(void) { - dma_irq_handler(DMA1, DMA_CH6); -} - -void __irq_dma1_channel7(void) { - dma_irq_handler(DMA1, DMA_CH7); -} - -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -void __irq_dma2_channel1(void) { - dma_irq_handler(DMA2, DMA_CH1); -} - -void __irq_dma2_channel2(void) { - dma_irq_handler(DMA2, DMA_CH2); -} - -void __irq_dma2_channel3(void) { - dma_irq_handler(DMA2, DMA_CH3); -} - -void __irq_dma2_channel4_5(void) { - if ((DMA2_BASE->CCR4 & DMA_CCR_EN) && (DMA2_BASE->ISR & DMA_ISR_GIF4)) { - dma_irq_handler(DMA2, DMA_CH4); - } - if ((DMA2_BASE->CCR5 & DMA_CCR_EN) && (DMA2_BASE->ISR & DMA_ISR_GIF5)) { - dma_irq_handler(DMA2, DMA_CH5); - } -} -#endif diff --git a/GD32F1/cores/maple/libmaple/exc.S b/GD32F1/cores/maple/libmaple/exc.S deleted file mode 100644 index 7631e48..0000000 --- a/GD32F1/cores/maple/libmaple/exc.S +++ /dev/null @@ -1,101 +0,0 @@ -/* ***************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * ****************************************************************************/ - -# On an exception, push a fake stack thread mode stack frame and redirect -# thread execution to a thread mode error handler - -# From RM008: -# The SP is decremented by eight words by the completion of the stack push. -# Figure 5-1 shows the contents of the stack after an exception pre-empts the -# current program flow. -# -# Old SP--> -# xPSR -# PC -# LR -# r12 -# r3 -# r2 -# r1 -# SP--> r0 - -.text -.globl __exc_hardfault -.globl __exc_nmi -.globl __exc_hardfault -.globl __exc_memmanage -.globl __exc_busfault -.globl __exc_usagefault - -.code 16 -.thumb_func -__exc_nmi: - mov r0, #1 - b __default_exc - -.thumb_func -__exc_hardfault: - mov r0, #2 - b __default_exc - -.thumb_func -__exc_memmanage: - mov r0, #3 - b __default_exc - -.thumb_func -__exc_busfault: - mov r0, #4 - b __default_exc - -.thumb_func -__exc_usagefault: - mov r0, #5 - b __default_exc - -.thumb_func -__default_exc: - ldr r2, NVIC_CCR @ Enable returning to thread mode even if there are - mov r1 ,#1 @ pending exceptions. See flag NONEBASETHRDENA. - str r1, [r2] - cpsid i @ Disable global interrupts - ldr r2, SYSTICK_CSR @ Disable systick handler - mov r1, #0 - str r1, [r2] - ldr r1, CPSR_MASK @ Set default CPSR - push {r1} - ldr r1, TARGET_PC @ Set target pc - push {r1} - sub sp, sp, #24 @ Don't care - ldr r1, EXC_RETURN @ Return to thread mode - mov lr, r1 - bx lr @ Exception exit - -.align 4 -CPSR_MASK: .word 0x61000000 -EXC_RETURN: .word 0xFFFFFFF9 -TARGET_PC: .word __error -NVIC_CCR: .word 0xE000ED14 @ NVIC configuration control register -SYSTICK_CSR: .word 0xE000E010 @ Systick control register - diff --git a/GD32F1/cores/maple/libmaple/exti.c b/GD32F1/cores/maple/libmaple/exti.c deleted file mode 100644 index f8ee8c3..0000000 --- a/GD32F1/cores/maple/libmaple/exti.c +++ /dev/null @@ -1,292 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/exti.c - * @brief External interrupt control routines - */ - -#include -#include -#include -#include - -static inline void dispatch_single_exti(uint32 exti_num); -static inline void dispatch_extis(uint32 start, uint32 stop); - -/* - * Internal state - */ - -typedef struct exti_channel { - void (*handler)(void *); - void *arg; -} exti_channel; - -static exti_channel exti_channels[] = { - { .handler = NULL, .arg = NULL }, // EXTI0 - { .handler = NULL, .arg = NULL }, // EXTI1 - { .handler = NULL, .arg = NULL }, // EXTI2 - { .handler = NULL, .arg = NULL }, // EXTI3 - { .handler = NULL, .arg = NULL }, // EXTI4 - { .handler = NULL, .arg = NULL }, // EXTI5 - { .handler = NULL, .arg = NULL }, // EXTI6 - { .handler = NULL, .arg = NULL }, // EXTI7 - { .handler = NULL, .arg = NULL }, // EXTI8 - { .handler = NULL, .arg = NULL }, // EXTI9 - { .handler = NULL, .arg = NULL }, // EXTI10 - { .handler = NULL, .arg = NULL }, // EXTI11 - { .handler = NULL, .arg = NULL }, // EXTI12 - { .handler = NULL, .arg = NULL }, // EXTI13 - { .handler = NULL, .arg = NULL }, // EXTI14 - { .handler = NULL, .arg = NULL }, // EXTI15 -}; - -/* - * Portable routines - */ - -/** - * @brief Register a handler to run upon external interrupt. - * - * This function assumes that the interrupt request corresponding to - * the given external interrupt is masked. - * - * @param num External interrupt line number. - * @param port Port to use as source input for external interrupt. - * @param handler Function handler to execute when interrupt is triggered. - * @param mode Type of transition to trigger on, one of: - * EXTI_RISING, EXTI_FALLING, EXTI_RISING_FALLING. - * @see exti_num - * @see exti_cfg - * @see voidFuncPtr - * @see exti_trigger_mode - */ -void exti_attach_interrupt(exti_num num, - exti_cfg port, - voidFuncPtr handler, - exti_trigger_mode mode) { - // Call callback version with arg being null - exti_attach_callback(num, port, (voidArgumentFuncPtr)handler, NULL, mode); -} - -/** - * @brief Register a handler with an argument to run upon external interrupt. - * - * This function assumes that the interrupt request corresponding to - * the given external interrupt is masked. - * - * @param num External interrupt line number. - * @param port Port to use as source input for external interrupt. - * @param handler Function handler to execute when interrupt is triggered. - * @param arg Argument to pass to the interrupt handler. - * @param mode Type of transition to trigger on, one of: - * EXTI_RISING, EXTI_FALLING, EXTI_RISING_FALLING. - * @see exti_num - * @see exti_cfg - * @see voidFuncPtr - * @see exti_trigger_mode - */ -void exti_attach_callback(exti_num num, - exti_cfg port, - voidArgumentFuncPtr handler, - void *arg, - exti_trigger_mode mode) { - ASSERT(handler); - - /* Register the handler */ - exti_channels[num].handler = handler; - exti_channels[num].arg = arg; - - /* Set trigger mode */ - switch (mode) { - case EXTI_RISING: - bb_peri_set_bit(&EXTI_BASE->RTSR, num, 1); - break; - case EXTI_FALLING: - bb_peri_set_bit(&EXTI_BASE->FTSR, num, 1); - break; - case EXTI_RISING_FALLING: - bb_peri_set_bit(&EXTI_BASE->RTSR, num, 1); - bb_peri_set_bit(&EXTI_BASE->FTSR, num, 1); - break; - } - - /* Use the chip-specific exti_select() to map num to port */ - exti_select(num, port); - - /* Unmask external interrupt request */ - bb_peri_set_bit(&EXTI_BASE->IMR, num, 1); - - /* Enable the interrupt line */ - switch(num) - { - case EXTI0: - nvic_irq_enable(NVIC_EXTI0); - break; - case EXTI1: - nvic_irq_enable(NVIC_EXTI1); - break; - case EXTI2: - nvic_irq_enable(NVIC_EXTI2); - break; - case EXTI3: - nvic_irq_enable(NVIC_EXTI3); - break; - case EXTI4: - nvic_irq_enable(NVIC_EXTI4); - break; - case EXTI5: - case EXTI6: - case EXTI7: - case EXTI8: - case EXTI9: - nvic_irq_enable(NVIC_EXTI_9_5); - break; - case EXTI10: - case EXTI11: - case EXTI12: - case EXTI13: - case EXTI14: - case EXTI15: - nvic_irq_enable(NVIC_EXTI_15_10); - break; - } -} - -/** - * @brief Unregister an external interrupt handler - * @param num External interrupt line to disable. - * @see exti_num - */ -void exti_detach_interrupt(exti_num num) { - /* First, mask the interrupt request */ - bb_peri_set_bit(&EXTI_BASE->IMR, num, 0); - - /* Then, clear the trigger selection registers */ - bb_peri_set_bit(&EXTI_BASE->FTSR, num, 0); - bb_peri_set_bit(&EXTI_BASE->RTSR, num, 0); - - /* Finally, unregister the user's handler */ - exti_channels[num].handler = NULL; - exti_channels[num].arg = NULL; -} - -/* - * Private routines - */ - -void exti_do_select(__io uint32 *exti_cr, exti_num num, exti_cfg port) { - uint32 shift = 4 * (num % 4); - uint32 cr = *exti_cr; - cr &= ~(0xF << shift); - cr |= port << shift; - *exti_cr = cr; -} - -/* - * Interrupt handlers - */ - -void __irq_exti0(void) { - dispatch_single_exti(EXTI0); -} - -void __irq_exti1(void) { - dispatch_single_exti(EXTI1); -} - -void __irq_exti2(void) { - dispatch_single_exti(EXTI2); -} - -void __irq_exti3(void) { - dispatch_single_exti(EXTI3); -} - -void __irq_exti4(void) { - dispatch_single_exti(EXTI4); -} - -void __irq_exti9_5(void) { - dispatch_extis(5, 9); -} - -void __irq_exti15_10(void) { - dispatch_extis(10, 15); -} - -/* - * Auxiliary functions - */ - -/* Clear the pending bits for EXTIs whose bits are set in exti_msk. - * - * If a pending bit is cleared as the last instruction in an ISR, it - * won't actually be cleared in time and the ISR will fire again. To - * compensate, this function NOPs for 2 cycles after clearing the - * pending bits to ensure it takes effect. */ -static __always_inline void clear_pending_msk(uint32 exti_msk) { - EXTI_BASE->PR = exti_msk; - asm volatile("nop"); - asm volatile("nop"); -} - -/* This dispatch routine is for non-multiplexed EXTI lines only; i.e., - * it doesn't check EXTI_PR. */ -static __always_inline void dispatch_single_exti(uint32 exti) { - voidArgumentFuncPtr handler = exti_channels[exti].handler; - - if (!handler) { - return; - } - - handler(exti_channels[exti].arg); - clear_pending_msk(1U << exti); -} - -/* Dispatch routine for EXTIs which share an IRQ. */ -static __always_inline void dispatch_extis(uint32 start, uint32 stop) { - uint32 pr = EXTI_BASE->PR; - uint32 handled_msk = 0; - uint32 exti; - - /* Dispatch user handlers for pending EXTIs. */ - for (exti = start; exti <= stop; exti++) { - uint32 eb = (1U << exti); - if (pr & eb) { - voidArgumentFuncPtr handler = exti_channels[exti].handler; - if (handler) { - handler(exti_channels[exti].arg); - handled_msk |= eb; - } - } - } - - /* Clear the pending bits for handled EXTIs. */ - clear_pending_msk(handled_msk); -} diff --git a/GD32F1/cores/maple/libmaple/exti_f1.c b/GD32F1/cores/maple/libmaple/exti_f1.c deleted file mode 100644 index b9ff401..0000000 --- a/GD32F1/cores/maple/libmaple/exti_f1.c +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*****************************************************************************/ - -#include -#include "exti_private.h" - -void exti_select(exti_num num, exti_cfg port) { - exti_do_select(&AFIO_BASE->EXTICR1 + num / 4, num, port); -} diff --git a/GD32F1/cores/maple/libmaple/flash.c b/GD32F1/cores/maple/libmaple/flash.c deleted file mode 100644 index c57bbbf..0000000 --- a/GD32F1/cores/maple/libmaple/flash.c +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/flash.c - * @brief Flash management functions - */ - -#include -#include - -/** - * @brief Set flash wait states - * - * Note that not all wait states are available on every MCU. See the - * Flash programming manual for your MCU for restrictions on the - * allowed value of wait_states for a given system clock (SYSCLK) - * frequency. - * - * @param wait_states number of wait states (one of - * FLASH_WAIT_STATE_0, FLASH_WAIT_STATE_1, - * ..., FLASH_WAIT_STATE_7). - */ -void flash_set_latency(uint32 wait_states) { - uint32 val = FLASH_BASE->ACR; - - val &= ~FLASH_ACR_LATENCY; - val |= wait_states; - - FLASH_BASE->ACR = val; -} diff --git a/GD32F1/cores/maple/libmaple/fsmc_f1.c b/GD32F1/cores/maple/libmaple/fsmc_f1.c deleted file mode 100644 index 210f0be..0000000 --- a/GD32F1/cores/maple/libmaple/fsmc_f1.c +++ /dev/null @@ -1,95 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * Copyright (c) 2010 Bryan Newbold. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/fsmc.c - * @author Marti Bolivar , - * Bryan Newbold - * @brief STM32F1 FSMC support. - */ - -#include - -#if STM32_HAVE_FSMC /* Don't try building the rest for MCUs without FSMC */ - -#include -#include - -void fsmc_sram_init_gpios(void) { - /* Data lines... */ - gpio_set_mode(GPIOD, 0, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOD, 1, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOD, 8, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOD, 9, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOD, 10, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOD, 14, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOD, 15, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 7, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 8, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 9, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 10, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 11, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 12, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 13, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 14, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOE, 15, GPIO_AF_OUTPUT_PP); - - /* Address lines... */ - gpio_set_mode(GPIOD, 11, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOD, 12, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOD, 13, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 0, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 1, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 2, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 3, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 4, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 5, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 12, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 13, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 14, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOF, 15, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOG, 0, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOG, 1, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOG, 2, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOG, 3, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOG, 4, GPIO_AF_OUTPUT_PP); - gpio_set_mode(GPIOG, 5, GPIO_AF_OUTPUT_PP); - - /* And control lines... */ - gpio_set_mode(GPIOD, 4, GPIO_AF_OUTPUT_PP); // NOE - gpio_set_mode(GPIOD, 5, GPIO_AF_OUTPUT_PP); // NWE - - gpio_set_mode(GPIOD, 7, GPIO_AF_OUTPUT_PP); // NE1 - gpio_set_mode(GPIOG, 9, GPIO_AF_OUTPUT_PP); // NE2 - gpio_set_mode(GPIOG, 10, GPIO_AF_OUTPUT_PP); // NE3 - gpio_set_mode(GPIOG, 12, GPIO_AF_OUTPUT_PP); // NE4 - - gpio_set_mode(GPIOE, 0, GPIO_AF_OUTPUT_PP); // NBL0 - gpio_set_mode(GPIOE, 1, GPIO_AF_OUTPUT_PP); // NBL1 -} - -#endif /* STM32_HAVE_FSMC */ diff --git a/GD32F1/cores/maple/libmaple/gpio.c b/GD32F1/cores/maple/libmaple/gpio.c deleted file mode 100644 index 6e63d2f..0000000 --- a/GD32F1/cores/maple/libmaple/gpio.c +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/gpio.c - * @brief Generic STM32 GPIO support. - */ - -#include -#include - -/* - * GPIO routines - */ - -/** - * Initialize a GPIO device. - * - * Enables the clock for and resets the given device. - * - * @param dev GPIO device to initialize. - */ -void gpio_init(gpio_dev *dev) { - rcc_clk_enable(dev->clk_id); - rcc_reset_dev(dev->clk_id); -} diff --git a/GD32F1/cores/maple/libmaple/gpio_f1.c b/GD32F1/cores/maple/libmaple/gpio_f1.c deleted file mode 100644 index ecd015d..0000000 --- a/GD32F1/cores/maple/libmaple/gpio_f1.c +++ /dev/null @@ -1,183 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/gpio.c - * @brief STM32F1 GPIO support. - */ - -#include -#include - -/* - * GPIO devices - */ - -gpio_dev gpioa = { - .regs = GPIOA_BASE, - .clk_id = RCC_GPIOA, - .exti_port = EXTI_PA, -}; -/** GPIO port A device. */ -gpio_dev* const GPIOA = &gpioa; - -gpio_dev gpiob = { - .regs = GPIOB_BASE, - .clk_id = RCC_GPIOB, - .exti_port = EXTI_PB, -}; -/** GPIO port B device. */ -gpio_dev* const GPIOB = &gpiob; - -gpio_dev gpioc = { - .regs = GPIOC_BASE, - .clk_id = RCC_GPIOC, - .exti_port = EXTI_PC, -}; -/** GPIO port C device. */ -gpio_dev* const GPIOC = &gpioc; - -gpio_dev gpiod = { - .regs = GPIOD_BASE, - .clk_id = RCC_GPIOD, - .exti_port = EXTI_PD, -}; -/** GPIO port D device. */ -gpio_dev* const GPIOD = &gpiod; - -#ifdef STM32_HIGH_DENSITY -gpio_dev gpioe = { - .regs = GPIOE_BASE, - .clk_id = RCC_GPIOE, - .exti_port = EXTI_PE, -}; -/** GPIO port E device. */ -gpio_dev* const GPIOE = &gpioe; - -gpio_dev gpiof = { - .regs = GPIOF_BASE, - .clk_id = RCC_GPIOF, - .exti_port = EXTI_PF, -}; -/** GPIO port F device. */ -gpio_dev* const GPIOF = &gpiof; - -gpio_dev gpiog = { - .regs = GPIOG_BASE, - .clk_id = RCC_GPIOG, - .exti_port = EXTI_PG, -}; -/** GPIO port G device. */ -gpio_dev* const GPIOG = &gpiog; -#endif - -/* - * GPIO routines - */ - -/** - * Initialize and reset all available GPIO devices. - */ -void gpio_init_all(void) { - gpio_init(GPIOA); - gpio_init(GPIOB); - gpio_init(GPIOC); - gpio_init(GPIOD); -#ifdef STM32_HIGH_DENSITY - gpio_init(GPIOE); - gpio_init(GPIOF); - gpio_init(GPIOG); -#endif -} - -/** - * Set the mode of a GPIO pin. - * - * @param dev GPIO device. - * @param pin Pin on the device whose mode to set, 0--15. - * @param mode General purpose or alternate function mode to set the pin to. - * @see gpio_pin_mode - */ -void gpio_set_mode(gpio_dev *dev, uint8 pin, gpio_pin_mode mode) { - gpio_reg_map *regs = dev->regs; - __io uint32 *cr = ®s->CRL + (pin >> 3); - uint32 shift = (pin & 0x7) * 4; - uint32 tmp = *cr; - - tmp &= ~(0xF << shift); - tmp |= (mode == GPIO_INPUT_PU ? GPIO_INPUT_PD : mode) << shift; - *cr = tmp; - - if (mode == GPIO_INPUT_PD) { - regs->ODR &= ~(1U << pin); - } else if (mode == GPIO_INPUT_PU) { - regs->ODR |= (1U << pin); - } -} - -gpio_pin_mode gpio_get_mode(gpio_dev *dev, uint8 pin) { - gpio_reg_map *regs = dev->regs; - __io uint32 *cr = ®s->CRL + (pin >> 3); - uint32 shift = (pin & 0x7) * 4; - uint32 tmp = *cr; - - uint32 crMode = (*cr>>shift) & 0x0F; - - // could be pull up or pull down. Nee to check the ODR - if (crMode==GPIO_INPUT_PD && ((regs->ODR >> pin) & 0x01) !=0 ) - { - crMode = GPIO_INPUT_PU; - } - - return(crMode); -} - -/* - * AFIO - */ - -/** - * @brief Initialize the AFIO clock, and reset the AFIO registers. - */ -void afio_init(void) { - rcc_clk_enable(RCC_AFIO); - rcc_reset_dev(RCC_AFIO); -} - -#define AFIO_EXTI_SEL_MASK 0xF - -/** - * @brief Perform an alternate function remap. - * @param remapping Remapping to perform. - */ -void afio_remap(afio_remap_peripheral remapping) { - if (remapping & AFIO_REMAP_USE_MAPR2) { - remapping &= ~AFIO_REMAP_USE_MAPR2; - AFIO_BASE->MAPR2 |= remapping; - } else { - AFIO_BASE->MAPR |= remapping; - } -} diff --git a/GD32F1/cores/maple/libmaple/i2c.c b/GD32F1/cores/maple/libmaple/i2c.c deleted file mode 100644 index c4ed245..0000000 --- a/GD32F1/cores/maple/libmaple/i2c.c +++ /dev/null @@ -1,520 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/i2c.c - * @author Perry Hung - * @brief Inter-Integrated Circuit (I2C) support. - * - * Currently, only master mode is supported. - */ - -#include "i2c_private.h" - -#include -#include -#include -#include -#include -#include - -#include - -static inline int32 wait_for_state_change(i2c_dev *dev, - i2c_state state, - uint32 timeout); -static void set_ccr_trise(i2c_dev *dev, uint32 flags); - -/** - * @brief Fill data register with slave address - * @param dev I2C device - * @param addr Slave address - * @param rw Read/write bit - */ -static inline void i2c_send_slave_addr(i2c_dev *dev, uint32 addr, uint32 rw) { - dev->regs->DR = (addr << 1) | rw; -} - -/* - * Simple debugging trail. Define I2C_DEBUG to turn on. - */ -#ifdef I2C_DEBUG - -#define NR_CRUMBS 128 -static struct crumb crumbs[NR_CRUMBS]; -static uint32 cur_crumb = 0; - -static inline void i2c_drop_crumb(uint32 event, uint32 arg0, uint32 arg1) { - if (cur_crumb < NR_CRUMBS) { - struct crumb *crumb = &crumbs[cur_crumb++]; - crumb->event = event; - crumb->arg0 = arg0; - crumb->arg1 = arg1; - } -} -#define I2C_CRUMB(event, arg0, arg1) i2c_drop_crumb(event, arg0, arg1) - -#else -#define I2C_CRUMB(event, arg0, arg1) -#endif - -struct crumb { - uint32 event; - uint32 arg0; - uint32 arg1; -}; - -enum { - IRQ_ENTRY = 1, - TXE_ONLY = 2, - TXE_BTF = 3, - STOP_SENT = 4, - TEST = 5, - RX_ADDR_START = 6, - RX_ADDR_STOP = 7, - RXNE_ONLY = 8, - RXNE_SENDING = 9, - RXNE_START_SENT = 10, - RXNE_STOP_SENT = 11, - RXNE_DONE = 12, - ERROR_ENTRY = 13, -}; - -/** - * @brief Reset an I2C bus. - * - * Reset is accomplished by clocking out pulses until any hung slaves - * release SDA and SCL, then generating a START condition, then a STOP - * condition. - * - * @param dev I2C device - */ -void i2c_bus_reset(const i2c_dev *dev) { - /* Release both lines */ - i2c_master_release_bus(dev); - - /* - * Make sure the bus is free by clocking it until any slaves release the - * bus. - */ - while (!gpio_read_bit(sda_port(dev), dev->sda_pin)) { - /* Wait for any clock stretching to finish */ - while (!gpio_read_bit(scl_port(dev), dev->scl_pin)) - ; - delay_us(10); - - /* Pull low */ - gpio_write_bit(scl_port(dev), dev->scl_pin, 0); - delay_us(10); - - /* Release high again */ - gpio_write_bit(scl_port(dev), dev->scl_pin, 1); - delay_us(10); - } - - /* Generate start then stop condition */ - gpio_write_bit(sda_port(dev), dev->sda_pin, 0); - delay_us(10); - gpio_write_bit(scl_port(dev), dev->scl_pin, 0); - delay_us(10); - gpio_write_bit(scl_port(dev), dev->scl_pin, 1); - delay_us(10); - gpio_write_bit(sda_port(dev), dev->sda_pin, 1); -} - -/** - * @brief Initialize an I2C device and reset its registers to their - * default values. - * @param dev Device to initialize. - */ -void i2c_init(i2c_dev *dev) { - rcc_reset_dev(dev->clk_id); - rcc_clk_enable(dev->clk_id); -} - -/* Hack for deprecated bit of STM32F1 functionality */ -#ifndef _I2C_HAVE_DEPRECATED_I2C_REMAP -#define _i2c_handle_remap(dev, flags) ((void)0) -#endif - -/** - * @brief Initialize an I2C device as bus master - * @param dev Device to enable - * @param flags Bitwise or of the following I2C options: - * I2C_FAST_MODE: 400 khz operation, - * I2C_DUTY_16_9: 16/9 Tlow/Thigh duty cycle (only applicable for - * fast mode), - * I2C_BUS_RESET: Reset the bus and clock out any hung slaves on - * initialization, - * I2C_10BIT_ADDRESSING: Enable 10-bit addressing, - * I2C_REMAP: (deprecated, STM32F1 only) Remap I2C1 to SCL/PB8 - * SDA/PB9. - */ -void i2c_master_enable(i2c_dev *dev, uint32 flags) { - /* PE must be disabled to configure the device */ - ASSERT(!(dev->regs->CR1 & I2C_CR1_PE)); - - /* Ugh */ - _i2c_handle_remap(dev, flags); - - /* Reset the bus. Clock out any hung slaves. */ - if (flags & I2C_BUS_RESET) { - i2c_bus_reset(dev); - } - - /* Turn on clock and set GPIO modes */ - i2c_init(dev); - i2c_config_gpios(dev); - - /* Configure clock and rise time */ - set_ccr_trise(dev, flags); - - /* Enable event and buffer interrupts */ - nvic_irq_enable(dev->ev_nvic_line); - nvic_irq_enable(dev->er_nvic_line); - i2c_enable_irq(dev, I2C_IRQ_EVENT | I2C_IRQ_BUFFER | I2C_IRQ_ERROR); - - /* Make it go! */ - i2c_peripheral_enable(dev); - - dev->state = I2C_STATE_IDLE; -} - -/** - * @brief Process an i2c transaction. - * - * Transactions are composed of one or more i2c_msg's, and may be read - * or write tranfers. Multiple i2c_msg's will generate a repeated - * start in between messages. - * - * @param dev I2C device - * @param msgs Messages to send/receive - * @param num Number of messages to send/receive - * @param timeout Bus idle timeout in milliseconds before aborting the - * transfer. 0 denotes no timeout. - * @return 0 on success, - * I2C_ERROR_PROTOCOL if there was a protocol error, - * I2C_ERROR_TIMEOUT if the transfer timed out. - */ -int32 i2c_master_xfer(i2c_dev *dev, - i2c_msg *msgs, - uint16 num, - uint32 timeout) { - int32 rc; - - ASSERT(dev->state == I2C_STATE_IDLE); - - dev->msg = msgs; - dev->msgs_left = num; - dev->timestamp = systick_uptime(); - dev->state = I2C_STATE_BUSY; - - i2c_enable_irq(dev, I2C_IRQ_EVENT); - i2c_start_condition(dev); - - rc = wait_for_state_change(dev, I2C_STATE_XFER_DONE, timeout); - if (rc < 0) { - goto out; - } - - dev->state = I2C_STATE_IDLE; -out: - return rc; -} - -/** - * @brief Wait for an I2C event, or time out in case of error. - * @param dev I2C device - * @param state I2C_state state to wait for - * @param timeout Timeout, in milliseconds - * @return 0 if target state is reached, a negative value on error. - */ -static inline int32 wait_for_state_change(i2c_dev *dev, - i2c_state state, - uint32 timeout) { - i2c_state tmp; - - while (1) { - tmp = dev->state; - - if (tmp == I2C_STATE_ERROR) { - return I2C_STATE_ERROR; - } - - if (tmp == state) { - return 0; - } - - if (timeout) { - if (systick_uptime() > (dev->timestamp + timeout)) { - /* TODO: overflow? */ - /* TODO: racy? */ - return I2C_ERROR_TIMEOUT; - } - } - } -} - -/* - * Private API - */ - -/* - * IRQ handler for I2C master. Handles transmission/reception. - */ -void _i2c_irq_handler(i2c_dev *dev) { - /* WTFs: - * - Where is I2C_MSG_10BIT_ADDR handled? - */ - i2c_msg *msg = dev->msg; - - uint8 read = msg->flags & I2C_MSG_READ; - - uint32 sr1 = dev->regs->SR1; - uint32 sr2 = dev->regs->SR2; - I2C_CRUMB(IRQ_ENTRY, sr1, sr2); - - /* - * Reset timeout counter - */ - dev->timestamp = systick_uptime(); - - /* - * EV5: Start condition sent - */ - if (sr1 & I2C_SR1_SB) { - msg->xferred = 0; - i2c_enable_irq(dev, I2C_IRQ_BUFFER); - - /* - * Master receiver - */ - if (read) { - i2c_enable_ack(dev); - } - - i2c_send_slave_addr(dev, msg->addr, read); - sr1 = sr2 = 0; - } - - /* - * EV6: Slave address sent - */ - if (sr1 & I2C_SR1_ADDR) { - /* - * Special case event EV6_1 for master receiver. - * Generate NACK and restart/stop condition after ADDR - * is cleared. - */ - if (read) { - if (msg->length == 1) { - i2c_disable_ack(dev); - if (dev->msgs_left > 1) { - i2c_start_condition(dev); - I2C_CRUMB(RX_ADDR_START, 0, 0); - } else { - i2c_stop_condition(dev); - I2C_CRUMB(RX_ADDR_STOP, 0, 0); - } - } - } else { - /* - * Master transmitter: write first byte to fill shift - * register. We should get another TXE interrupt - * immediately to fill DR again. - */ - if (msg->length > 1) { - i2c_write(dev, msg->data[msg->xferred++]); - } else if (msg->length == 0) { /* We're just sending an address */ - i2c_stop_condition(dev); - /* - * Turn off event interrupts to keep BTF from firing until - * the end of the stop condition. Why on earth they didn't - * have a start/stop condition request clear BTF is beyond - * me. - */ - i2c_disable_irq(dev, I2C_IRQ_EVENT); - I2C_CRUMB(STOP_SENT, 0, 0); - dev->state = I2C_STATE_XFER_DONE; - } /* else we're just sending one byte */ - } - sr1 = sr2 = 0; - } - - /* - * EV8: Master transmitter - * Transmit buffer empty, but we haven't finished transmitting the last - * byte written. - */ - if ((sr1 & I2C_SR1_TXE) && !(sr1 & I2C_SR1_BTF)) { - I2C_CRUMB(TXE_ONLY, 0, 0); - if (dev->msgs_left) { - i2c_write(dev, msg->data[msg->xferred++]); - if (msg->xferred == msg->length) { - /* - * End of this message. Turn off TXE/RXNE and wait for - * BTF to send repeated start or stop condition. - */ - i2c_disable_irq(dev, I2C_IRQ_BUFFER); - dev->msgs_left--; - } - } else { - /* - * This should be impossible... - */ - ASSERT(0); - } - sr1 = sr2 = 0; - } - - /* - * EV8_2: Master transmitter - * Last byte sent, program repeated start/stop - */ - if ((sr1 & I2C_SR1_TXE) && (sr1 & I2C_SR1_BTF)) { - I2C_CRUMB(TXE_BTF, 0, 0); - if (dev->msgs_left) { - I2C_CRUMB(TEST, 0, 0); - /* - * Repeated start insanity: We can't disable ITEVTEN or else SB - * won't interrupt, but if we don't disable ITEVTEN, BTF will - * continually interrupt us. What the fuck ST? - */ - i2c_start_condition(dev); - while (!(dev->regs->SR1 & I2C_SR1_SB)) - ; - dev->msg++; - } else { - i2c_stop_condition(dev); - - /* - * Turn off event interrupts to keep BTF from firing until - * the end of the stop condition. Why on earth they didn't - * have a start/stop condition request clear BTF is beyond - * me. - */ - i2c_disable_irq(dev, I2C_IRQ_EVENT); - I2C_CRUMB(STOP_SENT, 0, 0); - dev->state = I2C_STATE_XFER_DONE; - } - sr1 = sr2 = 0; - } - - /* - * EV7: Master Receiver - */ - if (sr1 & I2C_SR1_RXNE) { - I2C_CRUMB(RXNE_ONLY, 0, 0); - msg->data[msg->xferred++] = dev->regs->DR; - - /* - * EV7_1: Second to last byte in the reception? Set NACK and generate - * stop/restart condition in time for the last byte. We'll get one more - * RXNE interrupt before shutting things down. - */ - if (msg->xferred == (msg->length - 1)) { - i2c_disable_ack(dev); - if (dev->msgs_left > 2) { - i2c_start_condition(dev); - I2C_CRUMB(RXNE_START_SENT, 0, 0); - } else { - i2c_stop_condition(dev); - I2C_CRUMB(RXNE_STOP_SENT, 0, 0); - } - } else if (msg->xferred == msg->length) { - dev->msgs_left--; - if (dev->msgs_left == 0) { - /* - * We're done. - */ - I2C_CRUMB(RXNE_DONE, 0, 0); - dev->state = I2C_STATE_XFER_DONE; - } else { - dev->msg++; - } - } - } -} - -/* - * Interrupt handler for I2C error conditions. Aborts any pending I2C - * transactions. - */ -void _i2c_irq_error_handler(i2c_dev *dev) { - I2C_CRUMB(ERROR_ENTRY, dev->regs->SR1, dev->regs->SR2); - - dev->error_flags = dev->regs->SR1 & (I2C_SR1_BERR | - I2C_SR1_ARLO | - I2C_SR1_AF | - I2C_SR1_OVR); - /* Clear flags */ - dev->regs->SR1 = 0; - dev->regs->SR2 = 0; - - i2c_stop_condition(dev); - i2c_disable_irq(dev, I2C_IRQ_BUFFER | I2C_IRQ_EVENT | I2C_IRQ_ERROR); - dev->state = I2C_STATE_ERROR; -} - -/* - * CCR/TRISE configuration helper - */ -static void set_ccr_trise(i2c_dev *dev, uint32 flags) { - uint32 ccr = 0; - uint32 trise = 0; - uint32 clk_mhz = _i2c_bus_clk(dev); - uint32 clk_hz = clk_mhz * (1000 * 1000); - - i2c_set_input_clk(dev, clk_mhz); - - if (flags & I2C_FAST_MODE) { - ccr |= I2C_CCR_FS; - - if (flags & I2C_DUTY_16_9) { - /* Tlow/Thigh = 16/9 */ - ccr |= I2C_CCR_DUTY_16_9; - ccr |= clk_hz / (400000 * 25); - } else { - /* Tlow/Thigh = 2 */ - ccr |= clk_hz / (400000 * 3); - } - - trise = (300 * clk_mhz / 1000) + 1; - } else { - /* Tlow/Thigh = 1 */ - ccr = clk_hz / (100000 * 2); - trise = clk_mhz + 1; - } - - /* Set minimum required value if CCR < 1*/ - if ((ccr & I2C_CCR_CCR) == 0) { - ccr |= 0x1; - } - - i2c_set_clk_control(dev, ccr); - i2c_set_trise(dev, trise); -} diff --git a/GD32F1/cores/maple/libmaple/i2c_f1.c b/GD32F1/cores/maple/libmaple/i2c_f1.c deleted file mode 100644 index 8439793..0000000 --- a/GD32F1/cores/maple/libmaple/i2c_f1.c +++ /dev/null @@ -1,129 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/i2c.c - * @brief STM32F1 I2C support - */ - -#include "i2c_private.h" -#include - -/* - * Devices - */ - -static i2c_dev i2c1 = I2C_DEV_OLD(1, &gpiob, 7, 6); -static i2c_dev i2c2 = I2C_DEV_OLD(2, &gpiob, 11, 10); - -/** STM32F1 I2C device 1 */ -i2c_dev* const I2C1 = &i2c1; -/** STM32F1 I2C device 2 */ -i2c_dev* const I2C2 = &i2c2; - -/* - * Routines - */ - -static int i2c1_wants_remap(const i2c_dev *dev) { - /* Check if we've got I2C1 configured for SDA/SCL remap on PB9/PB8 */ - return (dev->clk_id == RCC_I2C1) && - (scl_port(dev)->clk_id == RCC_GPIOB) && - (sda_port(dev)->clk_id == RCC_GPIOB) && - (dev->sda_pin == 9) && - (dev->scl_pin == 8); -} - -void i2c_config_gpios(const i2c_dev *dev) { - if (i2c1_wants_remap(dev)) { - afio_remap(AFIO_REMAP_I2C1); - } - gpio_set_mode(sda_port(dev), dev->sda_pin, GPIO_AF_OUTPUT_OD); - gpio_set_mode(scl_port(dev), dev->scl_pin, GPIO_AF_OUTPUT_OD); -} - -void i2c_master_release_bus(const i2c_dev *dev) { - gpio_write_bit(scl_port(dev), dev->scl_pin, 1); - gpio_write_bit(sda_port(dev), dev->sda_pin, 1); - gpio_set_mode(scl_port(dev), dev->scl_pin, GPIO_OUTPUT_OD); - gpio_set_mode(sda_port(dev), dev->sda_pin, GPIO_OUTPUT_OD); -} - -/* - * IRQ handlers - */ - -void __irq_i2c1_ev(void) { - _i2c_irq_handler(I2C1); -} - -void __irq_i2c2_ev(void) { - _i2c_irq_handler(I2C2); -} - -void __irq_i2c1_er(void) { - _i2c_irq_error_handler(I2C1); -} - -void __irq_i2c2_er(void) { - _i2c_irq_error_handler(I2C2); -} - -/* - * Internal APIs - */ - -void _i2c_irq_priority_fixup(i2c_dev *dev) { - /* - * Important STM32 Errata: - * - * See STM32F10xx8 and STM32F10xxB Errata sheet (Doc ID 14574 Rev 8), - * Section 2.11.1, 2.11.2. - * - * 2.11.1: - * When the EV7, EV7_1, EV6_1, EV6_3, EV2, EV8, and EV3 events are not - * managed before the current byte is being transferred, problems may be - * encountered such as receiving an extra byte, reading the same data twice - * or missing data. - * - * 2.11.2: - * In Master Receiver mode, when closing the communication using - * method 2, the content of the last read data can be corrupted. - * - * If the user software is not able to read the data N-1 before the STOP - * condition is generated on the bus, the content of the shift register - * (data N) will be corrupted. (data N is shifted 1-bit to the left). - * - * ---------------------------------------------------------------------- - * - * In order to ensure that events are not missed, the i2c interrupt must - * not be preempted. We set the i2c interrupt priority to be the highest - * interrupt in the system (priority level 0). All other interrupts have - * been initialized to priority level 16. See nvic_init(). - */ - nvic_irq_set_priority(dev->ev_nvic_line, 0); - nvic_irq_set_priority(dev->er_nvic_line, 0); -} diff --git a/GD32F1/cores/maple/libmaple/iwdg.c b/GD32F1/cores/maple/libmaple/iwdg.c deleted file mode 100644 index 2456235..0000000 --- a/GD32F1/cores/maple/libmaple/iwdg.c +++ /dev/null @@ -1,62 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Michael Hope. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/iwdg.c - * @brief Independent watchdog (IWDG) support - */ - -#include - -/** - * @brief Initialise and start the watchdog - * - * The prescaler and reload set the timeout. For example, a prescaler - * of IWDG_PRE_32 divides the 40 kHz clock by 32 and gives roughly 1 - * ms per reload. - * - * @param prescaler Prescaler for the 40 kHz IWDG clock. - * @param reload Independent watchdog counter reload value. - */ -void iwdg_init(iwdg_prescaler prescaler, uint16 reload) { - IWDG_BASE->KR = IWDG_KR_UNLOCK; - IWDG_BASE->PR = prescaler; - IWDG_BASE->RLR = reload; - - /* Start things off */ - IWDG_BASE->KR = IWDG_KR_START; - iwdg_feed(); -} - -/** - * @brief Reset the IWDG counter. - * - * Calling this function will cause the IWDG counter to be reset to - * its reload value. - */ -void iwdg_feed(void) { - IWDG_BASE->KR = IWDG_KR_FEED; -} diff --git a/GD32F1/cores/maple/libmaple/nvic.c b/GD32F1/cores/maple/libmaple/nvic.c deleted file mode 100644 index 149e780..0000000 --- a/GD32F1/cores/maple/libmaple/nvic.c +++ /dev/null @@ -1,103 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/nvic.c - * @brief Nested vector interrupt controller support. - */ - -#include -#include -#include - -/** - * @brief Set interrupt priority for an interrupt line - * - * Note: The STM32 only implements 4 bits of priority, ignoring the - * lower 4 bits. This means there are only 16 levels of priority. - * Bits[3:0] read as zero and ignore writes. - * - * @param irqn device to set - * @param priority Priority to set, 0 being highest priority and 15 - * being lowest. - */ -void nvic_irq_set_priority(nvic_irq_num irqn, uint8 priority) { - if (irqn < 0) { - /* This interrupt is in the system handler block */ - SCB_BASE->SHP[((uint32)irqn & 0xF) - 4] = (priority & 0xF) << 4; - } else { - NVIC_BASE->IP[irqn] = (priority & 0xF) << 4; - } -} - -/** - * @brief Initialize the NVIC, setting interrupts to a default priority. - */ -void nvic_init(uint32 address, uint32 offset) { - uint32 i; - - nvic_set_vector_table(address, offset); - - /* - * Lower priority level for all peripheral interrupts to lowest - * possible. - */ - for (i = 0; i < STM32_NR_INTERRUPTS; i++) { - nvic_irq_set_priority((nvic_irq_num)i, 0xF); - } - - /* Lower systick interrupt priority to lowest level */ - nvic_irq_set_priority(NVIC_SYSTICK, 0xF); -} - -/** - * @brief Set the vector table base address. - * - * For stand-alone products, the vector table base address is normally - * the start of Flash (0x08000000). - * - * @param address Vector table base address. - * @param offset Offset from address. Some restrictions apply to the - * use of nonzero offsets; see the ARM Cortex M3 - * Technical Reference Manual. - */ -void nvic_set_vector_table(uint32 address, uint32 offset) { - SCB_BASE->VTOR = address | (offset & 0x1FFFFF80); -} - -/** - * @brief Force a system reset. - * - * Resets all major system components, excluding debug. - */ -void nvic_sys_reset() { - uint32 prigroup = SCB_BASE->AIRCR & SCB_AIRCR_PRIGROUP; - SCB_BASE->AIRCR = SCB_AIRCR_VECTKEY | SCB_AIRCR_SYSRESETREQ | prigroup; - asm volatile("dsb"); - while (1) - ; -} diff --git a/GD32F1/cores/maple/libmaple/pwr.c b/GD32F1/cores/maple/libmaple/pwr.c deleted file mode 100644 index 3cf170f..0000000 --- a/GD32F1/cores/maple/libmaple/pwr.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/pwr.c - * @brief Power control (PWR) support. - */ - -#include -#include - -/** - * Enables the power interface clock, and resets the power device. - */ -void pwr_init(void) { - rcc_clk_enable(RCC_PWR); - rcc_reset_dev(RCC_PWR); -} diff --git a/GD32F1/cores/maple/libmaple/rcc.c b/GD32F1/cores/maple/libmaple/rcc.c deleted file mode 100644 index 8e7d1ea..0000000 --- a/GD32F1/cores/maple/libmaple/rcc.c +++ /dev/null @@ -1,169 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/rcc.c - * @brief Portable RCC routines. - */ - -#include - -#include "rcc_private.h" - -/** - * @brief Get a peripheral's clock domain - * @param id Clock ID of the peripheral whose clock domain to return - * @return Clock source for the given clock ID - */ -rcc_clk_domain rcc_dev_clk(rcc_clk_id id) { - return rcc_dev_table[id].clk_domain; -} - -/** - * @brief Switch the clock used as the source of the system clock. - * - * After switching the source, this function blocks until the new - * clock source is in use. - * - * @param sysclk_src New system clock source. - * @see rcc_sysclk_src - */ -void rcc_switch_sysclk(rcc_sysclk_src sysclk_src) { - uint32 cfgr = RCC_BASE->CFGR; - cfgr &= ~RCC_CFGR_SW; - cfgr |= sysclk_src; - - /* Switch SYSCLK source. */ - RCC_BASE->CFGR = cfgr; - - /* Wait for new source to come into use. */ - while ((RCC_BASE->CFGR & RCC_CFGR_SWS) != (sysclk_src << 2)) - ; -} - -/* - * Turning clocks off and on, querying their status. - */ - -/* IMPORTANT NOTE FOR IMPLEMENTORS: - * - * libmaple assumes that enum rcc_clk enumerators are two-byte - * values, stored in a uint16, in the following way: - * - * - The high-order byte is the byte offset (from RCC_BASE) of the register - * to touch when turning on or off the given clock. - * - * - The low-order byte is the bit in that register that turns the - * clock on or off. - * - * Example for STM32F1: Turning on the high-speed external clock (HSE) - * involves setting HSEON, bit 16, of RCC_CR. The high-order byte is - * then offsetof(struct rcc_reg_map, CR) = 0, and the low-order byte - * is 16. - * - * The corresponding value of RCC_CLK_HSE is thus (0 << 8) | 16 = 16. - * - * On all known STM32 series, this encoding has the property that - * adding one to the low byte also gives the bit to check to determine - * if the clock is ready. For example, on STM32F1, RCC_CR_HSERDY is - * bit 17. If that's not the case on your series, rcc_is_clk_ready() - * won't work for you. */ - -/* Returns the RCC register which controls the clock source. */ -static inline __io uint32* rcc_clk_reg(rcc_clk clock) { - return (__io uint32*)((__io uint8*)RCC_BASE + (clock >> 8)); -} - -/* Returns a mask in rcc_clk_reg(clock) to be used for turning the - * clock on and off */ -static inline uint32 rcc_clk_on_mask(rcc_clk clock) { - return 1 << (clock & 0xFF); -} - -/* Returns a mask in rcc_clk_reg(clock) to be used when checking the - * readiness of the clock. */ -static inline uint32 rcc_clk_ready_mask(rcc_clk clock) { - return rcc_clk_on_mask(clock) << 1; -} - -/** - * @brief Turn on a clock source. - * - * After this routine exits, callers should ensure that the clock - * source is ready by waiting until rcc_is_clk_ready(clock) returns - * true. - * - * @param clock Clock to turn on. - * @see rcc_turn_off_clk() - * @see rcc_is_clk_ready() - */ -void rcc_turn_on_clk(rcc_clk clock) { - *rcc_clk_reg(clock) |= rcc_clk_on_mask(clock); -} - -/** - * @brief Turn off a clock source. - * - * In certain configurations, certain clock sources cannot be safely - * turned off. (For example, the main PLL on STM32F1 devices cannot be - * turned off if it has been selected as the SYSCLK source). Consult - * the reference material for your MCU to ensure it is safe to call - * this function. - * - * @param clock Clock to turn off. - * @see rcc_turn_on_clk() - * @see rcc_is_clk_ready() - */ -void rcc_turn_off_clk(rcc_clk clock) { - *rcc_clk_reg(clock) &= ~rcc_clk_on_mask(clock); -} - -/** - * @brief Check if a clock is on. - * @param clock Clock to check. - * @return 1 if the clock is on, 0 if the clock is off. - */ -int rcc_is_clk_on(rcc_clk clock) { - return !!(*rcc_clk_reg(clock) & rcc_clk_on_mask(clock)); -} - -/** - * @brief Check if a clock source is ready. - * - * In general, it is not safe to rely on a clock source unless this - * function returns nonzero. Also note that this function may return - * nonzero for a short period of time after a clock has been turned - * off. Consult the reference material for your MCU for more details. - * - * @param clock Clock whose readiness to check for. - * @return Nonzero if the clock is ready, zero otherwise. - * @see rcc_turn_on_clk() - * @see rcc_turn_off_clk() - */ -int rcc_is_clk_ready(rcc_clk clock) { - return (int)(*rcc_clk_reg(clock) & rcc_clk_ready_mask(clock)); -} diff --git a/GD32F1/cores/maple/libmaple/rcc_f1.c b/GD32F1/cores/maple/libmaple/rcc_f1.c deleted file mode 100644 index f45f670..0000000 --- a/GD32F1/cores/maple/libmaple/rcc_f1.c +++ /dev/null @@ -1,173 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/rcc.c - * @brief STM32F1 RCC. - */ - -#include -#include -#include - -#include "rcc_private.h" - -#define APB1 RCC_APB1 -#define APB2 RCC_APB2 -#define AHB RCC_AHB - -/* Device descriptor table, maps rcc_clk_id onto bus and enable/reset - * register bit numbers. */ -const struct rcc_dev_info rcc_dev_table[] = { - [RCC_GPIOA] = { .clk_domain = APB2, .line_num = 2 }, - [RCC_GPIOB] = { .clk_domain = APB2, .line_num = 3 }, - [RCC_GPIOC] = { .clk_domain = APB2, .line_num = 4 }, - [RCC_GPIOD] = { .clk_domain = APB2, .line_num = 5 }, - [RCC_AFIO] = { .clk_domain = APB2, .line_num = 0 }, - [RCC_ADC1] = { .clk_domain = APB2, .line_num = 9 }, - [RCC_ADC2] = { .clk_domain = APB2, .line_num = 10 }, - [RCC_ADC3] = { .clk_domain = APB2, .line_num = 15 }, - [RCC_USART1] = { .clk_domain = APB2, .line_num = 14 }, - [RCC_USART2] = { .clk_domain = APB1, .line_num = 17 }, - [RCC_USART3] = { .clk_domain = APB1, .line_num = 18 }, - [RCC_TIMER1] = { .clk_domain = APB2, .line_num = 11 }, - [RCC_TIMER2] = { .clk_domain = APB1, .line_num = 0 }, - [RCC_TIMER3] = { .clk_domain = APB1, .line_num = 1 }, - [RCC_TIMER4] = { .clk_domain = APB1, .line_num = 2 }, - [RCC_SPI1] = { .clk_domain = APB2, .line_num = 12 }, - [RCC_SPI2] = { .clk_domain = APB1, .line_num = 14 }, - [RCC_DMA1] = { .clk_domain = AHB, .line_num = 0 }, - [RCC_PWR] = { .clk_domain = APB1, .line_num = 28}, - [RCC_BKP] = { .clk_domain = APB1, .line_num = 27}, - [RCC_I2C1] = { .clk_domain = APB1, .line_num = 21 }, - [RCC_I2C2] = { .clk_domain = APB1, .line_num = 22 }, - [RCC_CRC] = { .clk_domain = AHB, .line_num = 6}, - [RCC_FLITF] = { .clk_domain = AHB, .line_num = 4}, - [RCC_SRAM] = { .clk_domain = AHB, .line_num = 2}, - [RCC_USB] = { .clk_domain = APB1, .line_num = 23}, -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) - [RCC_GPIOE] = { .clk_domain = APB2, .line_num = 6 }, - [RCC_GPIOF] = { .clk_domain = APB2, .line_num = 7 }, - [RCC_GPIOG] = { .clk_domain = APB2, .line_num = 8 }, - [RCC_UART4] = { .clk_domain = APB1, .line_num = 19 }, - [RCC_UART5] = { .clk_domain = APB1, .line_num = 20 }, - [RCC_TIMER5] = { .clk_domain = APB1, .line_num = 3 }, - [RCC_TIMER6] = { .clk_domain = APB1, .line_num = 4 }, - [RCC_TIMER7] = { .clk_domain = APB1, .line_num = 5 }, - [RCC_TIMER8] = { .clk_domain = APB2, .line_num = 13 }, - [RCC_FSMC] = { .clk_domain = AHB, .line_num = 8 }, - [RCC_DAC] = { .clk_domain = APB1, .line_num = 29 }, - [RCC_DMA2] = { .clk_domain = AHB, .line_num = 1 }, - [RCC_SDIO] = { .clk_domain = AHB, .line_num = 10 }, - [RCC_SPI3] = { .clk_domain = APB1, .line_num = 15 }, -#endif -#ifdef STM32_XL_DENSITY - [RCC_TIMER9] = { .clk_domain = APB2, .line_num = 19 }, - [RCC_TIMER10] = { .clk_domain = APB2, .line_num = 20 }, - [RCC_TIMER11] = { .clk_domain = APB2, .line_num = 21 }, - [RCC_TIMER12] = { .clk_domain = APB1, .line_num = 6 }, - [RCC_TIMER13] = { .clk_domain = APB1, .line_num = 7 }, - [RCC_TIMER14] = { .clk_domain = APB1, .line_num = 8 }, -#endif -}; - -__deprecated -void rcc_clk_init(rcc_sysclk_src sysclk_src, - rcc_pllsrc pll_src, - rcc_pll_multiplier pll_mul) { - /* Assume that we're going to clock the chip off the PLL, fed by - * the HSE */ - ASSERT(sysclk_src == RCC_CLKSRC_PLL && - pll_src == RCC_PLLSRC_HSE); - - RCC_BASE->CFGR = pll_src | pll_mul | (0x3<<22); - - /* Turn on, and wait for, HSE. */ - rcc_turn_on_clk(RCC_CLK_HSE); - while (!rcc_is_clk_ready(RCC_CLK_HSE)) - ; - - /* Do the same for the main PLL. */ - rcc_turn_on_clk(RCC_CLK_PLL); - while(!rcc_is_clk_ready(RCC_CLK_PLL)) - ; - - /* Finally, switch over to the PLL. */ - rcc_switch_sysclk(RCC_CLKSRC_PLL); -} - -/* pll_cfg->data must point to a valid struct stm32f1_rcc_pll_data. */ -void rcc_configure_pll(rcc_pll_cfg *pll_cfg) { - stm32f1_rcc_pll_data *data = pll_cfg->data; - rcc_pll_multiplier pll_mul = data->pll_mul; - uint32 cfgr; - /* Check that the PLL is disabled. */ - ASSERT_FAULT(!rcc_is_clk_on(RCC_CLK_PLL)); - - cfgr = RCC_BASE->CFGR; - cfgr &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL); - cfgr |= pll_cfg->pllsrc | pll_mul; - - RCC_BASE->CFGR = cfgr; -} - -void rcc_clk_enable(rcc_clk_id id) { - static __io uint32* enable_regs[] = { - [APB1] = &RCC_BASE->APB1ENR, - [APB2] = &RCC_BASE->APB2ENR, - [AHB] = &RCC_BASE->AHBENR, - }; - rcc_do_clk_enable(enable_regs, id); -} - -void rcc_reset_dev(rcc_clk_id id) { - static __io uint32* reset_regs[] = { - [APB1] = &RCC_BASE->APB1RSTR, - [APB2] = &RCC_BASE->APB2RSTR, - }; - rcc_do_reset_dev(reset_regs, id); -} - -void rcc_set_prescaler(rcc_prescaler prescaler, uint32 divider) { - static const uint32 masks[] = { - [RCC_PRESCALER_AHB] = RCC_CFGR_HPRE, - [RCC_PRESCALER_APB1] = RCC_CFGR_PPRE1, - [RCC_PRESCALER_APB2] = RCC_CFGR_PPRE2, - [RCC_PRESCALER_USB] = RCC_CFGR_USBPRE, - [RCC_PRESCALER_ADC] = RCC_CFGR_ADCPRE, - }; - rcc_do_set_prescaler(masks, prescaler, divider); -} - -void rcc_clk_disable(rcc_clk_id id) { - static __io uint32* enable_regs[] = { - [APB1] = &RCC_BASE->APB1ENR, - [APB2] = &RCC_BASE->APB2ENR, - [AHB] = &RCC_BASE->AHBENR, - }; - rcc_do_clk_disable(enable_regs, id); -} \ No newline at end of file diff --git a/GD32F1/cores/maple/libmaple/spi.c b/GD32F1/cores/maple/libmaple/spi.c deleted file mode 100644 index 194a82e..0000000 --- a/GD32F1/cores/maple/libmaple/spi.c +++ /dev/null @@ -1,164 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/spi.c - * @author Marti Bolivar - * @brief Serial Peripheral Interface (SPI) support. - * Currently, there is no Integrated Interchip Sound (I2S) support. - */ - -#include -#include - -static void spi_reconfigure(spi_dev *dev, uint32 cr1_config); - -/* - * SPI convenience routines - */ - -/** - * @brief Initialize and reset a SPI device. - * @param dev Device to initialize and reset. - */ -void spi_init(spi_dev *dev) { - rcc_clk_enable(dev->clk_id); - rcc_reset_dev(dev->clk_id); -} - -/** - * @brief Configure and enable a SPI device as bus master. - * - * The device's peripheral will be disabled before being reconfigured. - * - * @param dev Device to configure as bus master - * @param baud Bus baud rate - * @param mode SPI mode - * @param flags Logical OR of spi_cfg_flag values. - * @see spi_cfg_flag - */ -void spi_master_enable(spi_dev *dev, - spi_baud_rate baud, - spi_mode mode, - uint32 flags) { - spi_reconfigure(dev, baud | flags | SPI_CR1_MSTR | mode); -} - -/** - * @brief Configure and enable a SPI device as a bus slave. - * - * The device's peripheral will be disabled before being reconfigured. - * - * @param dev Device to configure as a bus slave - * @param mode SPI mode - * @param flags Logical OR of spi_cfg_flag values. - * @see spi_cfg_flag - */ -void spi_slave_enable(spi_dev *dev, spi_mode mode, uint32 flags) { - spi_reconfigure(dev, flags | mode); -} - -/** - * @brief Nonblocking SPI transmit. - * @param dev SPI port to use for transmission - * @param buf Buffer to transmit. The sizeof buf's elements are - * inferred from dev's data frame format (i.e., are - * correctly treated as 8-bit or 16-bit quantities). - * @param len Maximum number of elements to transmit. - * @return Number of elements transmitted. - */ -uint32 spi_tx(spi_dev *dev, const void *buf, uint32 len) { - uint32 txed = 0; - uint8 byte_frame = spi_dff(dev) == SPI_DFF_8_BIT; - while (spi_is_tx_empty(dev) && (txed < len)) { - if (byte_frame) { - dev->regs->DR = ((const uint8*)buf)[txed++]; - } else { - dev->regs->DR = ((const uint16*)buf)[txed++]; - } - } - return txed; -} - -/** - * @brief Enable a SPI peripheral - * @param dev Device to enable - */ -void spi_peripheral_enable(spi_dev *dev) { - bb_peri_set_bit(&dev->regs->CR1, SPI_CR1_SPE_BIT, 1); -} - -/** - * @brief Disable a SPI peripheral - * @param dev Device to disable - */ -void spi_peripheral_disable(spi_dev *dev) { - bb_peri_set_bit(&dev->regs->CR1, SPI_CR1_SPE_BIT, 0); -} - -/** - * @brief Enable DMA requests whenever the transmit buffer is empty - * @param dev SPI device on which to enable TX DMA requests - */ -void spi_tx_dma_enable(spi_dev *dev) { - bb_peri_set_bit(&dev->regs->CR2, SPI_CR2_TXDMAEN_BIT, 1); -} - -/** - * @brief Disable DMA requests whenever the transmit buffer is empty - * @param dev SPI device on which to disable TX DMA requests - */ -void spi_tx_dma_disable(spi_dev *dev) { - bb_peri_set_bit(&dev->regs->CR2, SPI_CR2_TXDMAEN_BIT, 0); -} - -/** - * @brief Enable DMA requests whenever the receive buffer is empty - * @param dev SPI device on which to enable RX DMA requests - */ -void spi_rx_dma_enable(spi_dev *dev) { - bb_peri_set_bit(&dev->regs->CR2, SPI_CR2_RXDMAEN_BIT, 1); -} - -/** - * @brief Disable DMA requests whenever the receive buffer is empty - * @param dev SPI device on which to disable RX DMA requests - */ -void spi_rx_dma_disable(spi_dev *dev) { - bb_peri_set_bit(&dev->regs->CR2, SPI_CR2_RXDMAEN_BIT, 0); -} - -/* - * SPI auxiliary routines - */ - -static void spi_reconfigure(spi_dev *dev, uint32 cr1_config) { - spi_irq_disable(dev, SPI_INTERRUPTS_ALL); - spi_peripheral_disable(dev); - dev->regs->CR1 = cr1_config; - spi_peripheral_enable(dev); -} diff --git a/GD32F1/cores/maple/libmaple/spi_f1.c b/GD32F1/cores/maple/libmaple/spi_f1.c deleted file mode 100644 index bbea5a4..0000000 --- a/GD32F1/cores/maple/libmaple/spi_f1.c +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/spi.c - * @author Marti Bolivar - * @brief STM32F1 SPI/I2S. - */ - -#include -#include -#include "spi_private.h" - -/* - * Devices - */ - -static spi_dev spi1 = SPI_DEV(1); -static spi_dev spi2 = SPI_DEV(2); - -spi_dev *SPI1 = &spi1; -spi_dev *SPI2 = &spi2; - -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -static spi_dev spi3 = SPI_DEV(3); -spi_dev *SPI3 = &spi3; -#endif - -/* - * Routines - */ - -void spi_config_gpios(spi_dev *ignored, - uint8 as_master, - gpio_dev *nss_dev, - uint8 nss_bit, - gpio_dev *comm_dev, - uint8 sck_bit, - uint8 miso_bit, - uint8 mosi_bit) { - if (as_master) { - // gpio_set_mode(nss_dev, nss_bit, GPIO_AF_OUTPUT_PP);// Roger Clark. Commented out, so that NSS can be driven as a normal GPIO pin during SPI use - gpio_set_mode(comm_dev, sck_bit, GPIO_AF_OUTPUT_PP); - gpio_set_mode(comm_dev, miso_bit, GPIO_INPUT_FLOATING); - gpio_set_mode(comm_dev, mosi_bit, GPIO_AF_OUTPUT_PP); - } else { - gpio_set_mode(nss_dev, nss_bit, GPIO_INPUT_FLOATING); - gpio_set_mode(comm_dev, sck_bit, GPIO_INPUT_FLOATING); - gpio_set_mode(comm_dev, miso_bit, GPIO_AF_OUTPUT_PP); - gpio_set_mode(comm_dev, mosi_bit, GPIO_INPUT_FLOATING); - } -} - -void spi_foreach(void (*fn)(spi_dev*)) { - fn(SPI1); - fn(SPI2); -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) - fn(SPI3); -#endif -} diff --git a/GD32F1/cores/maple/libmaple/stm32f1/performance/isrs.S b/GD32F1/cores/maple/libmaple/stm32f1/performance/isrs.S deleted file mode 100644 index 8c1a44f..0000000 --- a/GD32F1/cores/maple/libmaple/stm32f1/performance/isrs.S +++ /dev/null @@ -1,262 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* STM32F1 performance line ISR weak declarations */ - -#include - - .thumb - -/* Default handler for all non-overridden interrupts and exceptions */ - .globl __default_handler - .type __default_handler, %function - -__default_handler: - b . - - .weak __exc_nmi - .globl __exc_nmi - .set __exc_nmi, __default_handler - .weak __exc_hardfault - .globl __exc_hardfault - .set __exc_hardfault, __default_handler - .weak __exc_memmanage - .globl __exc_memmanage - .set __exc_memmanage, __default_handler - .weak __exc_busfault - .globl __exc_busfault - .set __exc_busfault, __default_handler - .weak __exc_usagefault - .globl __exc_usagefault - .set __exc_usagefault, __default_handler - .weak __stm32reservedexception7 - .globl __stm32reservedexception7 - .set __stm32reservedexception7, __default_handler - .weak __stm32reservedexception8 - .globl __stm32reservedexception8 - .set __stm32reservedexception8, __default_handler - .weak __stm32reservedexception9 - .globl __stm32reservedexception9 - .set __stm32reservedexception9, __default_handler - .weak __stm32reservedexception10 - .globl __stm32reservedexception10 - .set __stm32reservedexception10, __default_handler - .weak __exc_svc - .globl __exc_svc - .set __exc_svc, __default_handler - .weak __exc_debug_monitor - .globl __exc_debug_monitor - .set __exc_debug_monitor, __default_handler - .weak __stm32reservedexception13 - .globl __stm32reservedexception13 - .set __stm32reservedexception13, __default_handler - .weak __exc_pendsv - .globl __exc_pendsv - .set __exc_pendsv, __default_handler - .weak __exc_systick - .globl __exc_systick - .set __exc_systick, __default_handler - .weak __irq_wwdg - .globl __irq_wwdg - .set __irq_wwdg, __default_handler - .weak __irq_pvd - .globl __irq_pvd - .set __irq_pvd, __default_handler - .weak __irq_tamper - .globl __irq_tamper - .set __irq_tamper, __default_handler - .weak __irq_rtc - .globl __irq_rtc - .set __irq_rtc, __default_handler - .weak __irq_flash - .globl __irq_flash - .set __irq_flash, __default_handler - .weak __irq_rcc - .globl __irq_rcc - .set __irq_rcc, __default_handler - .weak __irq_exti0 - .globl __irq_exti0 - .set __irq_exti0, __default_handler - .weak __irq_exti1 - .globl __irq_exti1 - .set __irq_exti1, __default_handler - .weak __irq_exti2 - .globl __irq_exti2 - .set __irq_exti2, __default_handler - .weak __irq_exti3 - .globl __irq_exti3 - .set __irq_exti3, __default_handler - .weak __irq_exti4 - .globl __irq_exti4 - .set __irq_exti4, __default_handler - .weak __irq_dma1_channel1 - .globl __irq_dma1_channel1 - .set __irq_dma1_channel1, __default_handler - .weak __irq_dma1_channel2 - .globl __irq_dma1_channel2 - .set __irq_dma1_channel2, __default_handler - .weak __irq_dma1_channel3 - .globl __irq_dma1_channel3 - .set __irq_dma1_channel3, __default_handler - .weak __irq_dma1_channel4 - .globl __irq_dma1_channel4 - .set __irq_dma1_channel4, __default_handler - .weak __irq_dma1_channel5 - .globl __irq_dma1_channel5 - .set __irq_dma1_channel5, __default_handler - .weak __irq_dma1_channel6 - .globl __irq_dma1_channel6 - .set __irq_dma1_channel6, __default_handler - .weak __irq_dma1_channel7 - .globl __irq_dma1_channel7 - .set __irq_dma1_channel7, __default_handler - .weak __irq_adc - .globl __irq_adc - .set __irq_adc, __default_handler - .weak __irq_usb_hp_can_tx - .globl __irq_usb_hp_can_tx - .set __irq_usb_hp_can_tx, __default_handler - .weak __irq_usb_lp_can_rx0 - .globl __irq_usb_lp_can_rx0 - .set __irq_usb_lp_can_rx0, __default_handler - .weak __irq_can_rx1 - .globl __irq_can_rx1 - .set __irq_can_rx1, __default_handler - .weak __irq_can_sce - .globl __irq_can_sce - .set __irq_can_sce, __default_handler - .weak __irq_exti9_5 - .globl __irq_exti9_5 - .set __irq_exti9_5, __default_handler - .weak __irq_tim1_brk - .globl __irq_tim1_brk - .set __irq_tim1_brk, __default_handler - .weak __irq_tim1_up - .globl __irq_tim1_up - .set __irq_tim1_up, __default_handler - .weak __irq_tim1_trg_com - .globl __irq_tim1_trg_com - .set __irq_tim1_trg_com, __default_handler - .weak __irq_tim1_cc - .globl __irq_tim1_cc - .set __irq_tim1_cc, __default_handler - - .weakref __irq_tim2, __default_handler - .globl __irq_tim2 - .weakref __irq_tim3, __default_handler - .globl __irq_tim3 - .weakref __irq_tim4, __default_handler - .globl __irq_tim4 - - .weak __irq_i2c1_ev - .globl __irq_i2c1_ev - .set __irq_i2c1_ev, __default_handler - .weak __irq_i2c1_er - .globl __irq_i2c1_er - .set __irq_i2c1_er, __default_handler - .weak __irq_i2c2_ev - .globl __irq_i2c2_ev - .set __irq_i2c2_ev, __default_handler - .weak __irq_i2c2_er - .globl __irq_i2c2_er - .set __irq_i2c2_er, __default_handler - .weak __irq_spi1 - .globl __irq_spi1 - .set __irq_spi1, __default_handler - .weak __irq_spi2 - .globl __irq_spi2 - .set __irq_spi2, __default_handler - .weak __irq_usart1 - .globl __irq_usart1 - .set __irq_usart1, __default_handler - .weak __irq_usart2 - .globl __irq_usart2 - .set __irq_usart2, __default_handler - .weak __irq_usart3 - .globl __irq_usart3 - .set __irq_usart3, __default_handler - .weak __irq_exti15_10 - .globl __irq_exti15_10 - .set __irq_exti15_10, __default_handler - .weak __irq_rtcalarm - .globl __irq_rtcalarm - .set __irq_rtcalarm, __default_handler - .weak __irq_usbwakeup - .globl __irq_usbwakeup - .set __irq_usbwakeup, __default_handler -#if defined (STM32_HIGH_DENSITY) - .weak __irq_tim8_brk - .globl __irq_tim8_brk - .set __irq_tim8_brk, __default_handler - .weak __irq_tim8_up - .globl __irq_tim8_up - .set __irq_tim8_up, __default_handler - .weak __irq_tim8_trg_com - .globl __irq_tim8_trg_com - .set __irq_tim8_trg_com, __default_handler - .weak __irq_tim8_cc - .globl __irq_tim8_cc - .set __irq_tim8_cc, __default_handler - .weak __irq_adc3 - .globl __irq_adc3 - .set __irq_adc3, __default_handler - .weak __irq_fsmc - .globl __irq_fsmc - .set __irq_fsmc, __default_handler - .weak __irq_sdio - .globl __irq_sdio - .set __irq_sdio, __default_handler - .weak __irq_tim5 - .globl __irq_tim5 - .set __irq_tim5, __default_handler - .weak __irq_spi3 - .globl __irq_spi3 - .set __irq_spi3, __default_handler - .weak __irq_uart4 - .globl __irq_uart4 - .set __irq_uart4, __default_handler - .weak __irq_uart5 - .globl __irq_uart5 - .set __irq_uart5, __default_handler - .weak __irq_tim6 - .globl __irq_tim6 - .set __irq_tim6, __default_handler - .weak __irq_tim7 - .globl __irq_tim7 - .set __irq_tim7, __default_handler - .weak __irq_dma2_channel1 - .globl __irq_dma2_channel1 - .set __irq_dma2_channel1, __default_handler - .weak __irq_dma2_channel2 - .globl __irq_dma2_channel2 - .set __irq_dma2_channel2, __default_handler - .weak __irq_dma2_channel3 - .globl __irq_dma2_channel3 - .set __irq_dma2_channel3, __default_handler - .weak __irq_dma2_channel4_5 - .globl __irq_dma2_channel4_5 - .set __irq_dma2_channel4_5, __default_handler -#endif /* STM32_HIGH_DENSITY */ \ No newline at end of file diff --git a/GD32F1/cores/maple/libmaple/stm32f1/performance/vector_table.S b/GD32F1/cores/maple/libmaple/stm32f1/performance/vector_table.S deleted file mode 100644 index 8be3fa6..0000000 --- a/GD32F1/cores/maple/libmaple/stm32f1/performance/vector_table.S +++ /dev/null @@ -1,118 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* STM32F1 performance line vector table */ - -#include - - .section ".stm32.interrupt_vector" - - .globl __stm32_vector_table - .type __stm32_vector_table, %object - -__stm32_vector_table: -/* CM3 core interrupts */ - .long __msp_init - .long __exc_reset - .long __exc_nmi - .long __exc_hardfault - .long __exc_memmanage - .long __exc_busfault - .long __exc_usagefault - .long __stm32reservedexception7 - .long __stm32reservedexception8 - .long __stm32reservedexception9 - .long __stm32reservedexception10 - .long __exc_svc - .long __exc_debug_monitor - .long __stm32reservedexception13 - .long __exc_pendsv - .long __exc_systick -/* Peripheral interrupts */ - .long __irq_wwdg - .long __irq_pvd - .long __irq_tamper - .long __irq_rtc - .long __irq_flash - .long __irq_rcc - .long __irq_exti0 - .long __irq_exti1 - .long __irq_exti2 - .long __irq_exti3 - .long __irq_exti4 - .long __irq_dma1_channel1 - .long __irq_dma1_channel2 - .long __irq_dma1_channel3 - .long __irq_dma1_channel4 - .long __irq_dma1_channel5 - .long __irq_dma1_channel6 - .long __irq_dma1_channel7 - .long __irq_adc - .long __irq_usb_hp_can_tx - .long __irq_usb_lp_can_rx0 - .long __irq_can_rx1 - .long __irq_can_sce - .long __irq_exti9_5 - .long __irq_tim1_brk - .long __irq_tim1_up - .long __irq_tim1_trg_com - .long __irq_tim1_cc - .long __irq_tim2 - .long __irq_tim3 - .long __irq_tim4 - .long __irq_i2c1_ev - .long __irq_i2c1_er - .long __irq_i2c2_ev - .long __irq_i2c2_er - .long __irq_spi1 - .long __irq_spi2 - .long __irq_usart1 - .long __irq_usart2 - .long __irq_usart3 - .long __irq_exti15_10 - .long __irq_rtcalarm - .long __irq_usbwakeup -#if defined (STM32_HIGH_DENSITY) - .long __irq_tim8_brk - .long __irq_tim8_up - .long __irq_tim8_trg_com - .long __irq_tim8_cc - .long __irq_adc3 - .long __irq_fsmc - .long __irq_sdio - .long __irq_tim5 - .long __irq_spi3 - .long __irq_uart4 - .long __irq_uart5 - .long __irq_tim6 - .long __irq_tim7 - .long __irq_dma2_channel1 - .long __irq_dma2_channel2 - .long __irq_dma2_channel3 - .long __irq_dma2_channel4_5 -#endif /* STM32_HIGH_DENSITY */ - - .size __stm32_vector_table, . - __stm32_vector_table diff --git a/GD32F1/cores/maple/libmaple/systick.c b/GD32F1/cores/maple/libmaple/systick.c deleted file mode 100644 index 7568abe..0000000 --- a/GD32F1/cores/maple/libmaple/systick.c +++ /dev/null @@ -1,88 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2010, 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/systick.c - * @brief System timer (SysTick). - */ - -#include - -volatile uint32 systick_uptime_millis; -static void (*systick_user_callback)(void); - -/** - * @brief Initialize and enable SysTick. - * - * Clocks the system timer with the core clock, turns it on, and - * enables interrupts. - * - * @param reload_val Appropriate reload counter to tick every 1 ms. - */ -void systick_init(uint32 reload_val) { - SYSTICK_BASE->RVR = reload_val; - systick_enable(); -} - -/** - * Clock the system timer with the core clock, but don't turn it - * on or enable interrupt. - */ -void systick_disable() { - SYSTICK_BASE->CSR = SYSTICK_CSR_CLKSOURCE_CORE; -} - -/** - * Clock the system timer with the core clock and turn it on; - * interrupt every 1 ms, for systick_timer_millis. - */ -void systick_enable() { - /* re-enables init registers without changing reload val */ - SYSTICK_BASE->CSR = (SYSTICK_CSR_CLKSOURCE_CORE | - SYSTICK_CSR_ENABLE | - SYSTICK_CSR_TICKINT_PEND); -} - -/** - * @brief Attach a callback to be called from the SysTick exception handler. - * - * To detach a callback, call this function again with a null argument. - */ -void systick_attach_callback(void (*callback)(void)) { - systick_user_callback = callback; -} - -/* - * SysTick ISR - */ - -void __exc_systick(void) { - systick_uptime_millis++; - if (systick_user_callback) { - systick_user_callback(); - } -} diff --git a/GD32F1/cores/maple/libmaple/timer.c b/GD32F1/cores/maple/libmaple/timer.c deleted file mode 100644 index 59674f9..0000000 --- a/GD32F1/cores/maple/libmaple/timer.c +++ /dev/null @@ -1,512 +0,0 @@ - -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/timer.c - * @author Marti Bolivar - * @brief Portable timer routines. - */ - -#include -#include -#include "timer_private.h" - -static void disable_channel(timer_dev *dev, uint8 channel); -static void pwm_mode(timer_dev *dev, uint8 channel); -static void output_compare_mode(timer_dev *dev, uint8 channel); - -static inline void enable_irq(timer_dev *dev, timer_interrupt_id iid); - -/* - * Devices - * - * Defer to the timer_private API for declaring these. - */ - -#if STM32_HAVE_TIMER(1) -timer_dev timer1 = ADVANCED_TIMER(1); -/** Timer 1 device (advanced) */ -timer_dev *const TIMER1 = &timer1; -#endif -#if STM32_HAVE_TIMER(2) -timer_dev timer2 = GENERAL_TIMER(2); -/** Timer 2 device (general-purpose) */ -timer_dev *const TIMER2 = &timer2; -#endif -#if STM32_HAVE_TIMER(3) -timer_dev timer3 = GENERAL_TIMER(3); -/** Timer 3 device (general-purpose) */ -timer_dev *const TIMER3 = &timer3; -#endif -#if STM32_HAVE_TIMER(4) -timer_dev timer4 = GENERAL_TIMER(4); -/** Timer 4 device (general-purpose) */ -timer_dev *const TIMER4 = &timer4; -#endif -#if STM32_HAVE_TIMER(5) -timer_dev timer5 = GENERAL_TIMER(5); -/** Timer 5 device (general-purpose) */ -timer_dev *const TIMER5 = &timer5; -#endif -#if STM32_HAVE_TIMER(6) -timer_dev timer6 = BASIC_TIMER(6); -/** Timer 6 device (basic) */ -timer_dev *const TIMER6 = &timer6; -#endif -#if STM32_HAVE_TIMER(7) -timer_dev timer7 = BASIC_TIMER(7); -/** Timer 7 device (basic) */ -timer_dev *const TIMER7 = &timer7; -#endif -#if STM32_HAVE_TIMER(8) -timer_dev timer8 = ADVANCED_TIMER(8); -/** Timer 8 device (advanced) */ -timer_dev *const TIMER8 = &timer8; -#endif -#if STM32_HAVE_TIMER(9) -timer_dev timer9 = RESTRICTED_GENERAL_TIMER(9, TIMER_DIER_TIE_BIT); -/** Timer 9 device (general-purpose) */ -timer_dev *const TIMER9 = &timer9; -#endif -#if STM32_HAVE_TIMER(10) -timer_dev timer10 = RESTRICTED_GENERAL_TIMER(10, TIMER_DIER_CC1IE_BIT); -/** Timer 10 device (general-purpose) */ -timer_dev *const TIMER10 = &timer10; -#endif -#if STM32_HAVE_TIMER(11) -timer_dev timer11 = RESTRICTED_GENERAL_TIMER(11, TIMER_DIER_CC1IE_BIT); -/** Timer 11 device (general-purpose) */ -timer_dev *const TIMER11 = &timer11; -#endif -#if STM32_HAVE_TIMER(12) -timer_dev timer12 = RESTRICTED_GENERAL_TIMER(12, TIMER_DIER_TIE_BIT); -/** Timer 12 device (general-purpose) */ -timer_dev *const TIMER12 = &timer12; -#endif -#if STM32_HAVE_TIMER(13) -timer_dev timer13 = RESTRICTED_GENERAL_TIMER(13, TIMER_DIER_CC1IE_BIT); -/** Timer 13 device (general-purpose) */ -timer_dev *const TIMER13 = &timer13; -#endif -#if STM32_HAVE_TIMER(14) -timer_dev timer14 = RESTRICTED_GENERAL_TIMER(14, TIMER_DIER_CC1IE_BIT); -/** Timer 14 device (general-purpose) */ -timer_dev *const TIMER14 = &timer14; -#endif - -/* - * Routines - */ - -/** - * @brief Call a function on timer devices. - * @param fn Function to call on each timer device. - */ -void timer_foreach(void (*fn)(timer_dev*)) { -#if STM32_HAVE_TIMER(1) - fn(TIMER1); -#endif -#if STM32_HAVE_TIMER(2) - fn(TIMER2); -#endif -#if STM32_HAVE_TIMER(3) - fn(TIMER3); -#endif -#if STM32_HAVE_TIMER(4) - fn(TIMER4); -#endif -#if STM32_HAVE_TIMER(5) - fn(TIMER5); -#endif -#if STM32_HAVE_TIMER(6) - fn(TIMER6); -#endif -#if STM32_HAVE_TIMER(7) - fn(TIMER7); -#endif -#if STM32_HAVE_TIMER(8) - fn(TIMER8); -#endif -#if STM32_HAVE_TIMER(9) - fn(TIMER9); -#endif -#if STM32_HAVE_TIMER(10) - fn(TIMER10); -#endif -#if STM32_HAVE_TIMER(11) - fn(TIMER11); -#endif -#if STM32_HAVE_TIMER(12) - fn(TIMER12); -#endif -#if STM32_HAVE_TIMER(13) - fn(TIMER13); -#endif -#if STM32_HAVE_TIMER(14) - fn(TIMER14); -#endif -} - -/** - * Initialize a timer, and reset its register map. - * @param dev Timer to initialize - */ -void timer_init(timer_dev *dev) { - rcc_clk_enable(dev->clk_id); - rcc_reset_dev(dev->clk_id); -} - -/** - * @brief Disable a timer. - * - * The timer will stop counting, all DMA requests and interrupts will - * be disabled, and no state changes will be output. - * - * @param dev Timer to disable. - */ -void timer_disable(timer_dev *dev) { - (dev->regs).bas->CR1 = 0; - (dev->regs).bas->DIER = 0; - switch (dev->type) { - case TIMER_ADVANCED: /* fall-through */ - case TIMER_GENERAL: - (dev->regs).gen->CCER = 0; - break; - case TIMER_BASIC: - break; - } -} - -/** - * Sets the mode of an individual timer channel. - * - * Note that not all timers can be configured in every mode. For - * example, basic timers cannot be configured to output compare mode. - * Be sure to use a timer which is appropriate for the mode you want. - * - * @param dev Timer whose channel mode to set - * @param channel Relevant channel - * @param mode New timer mode for channel - */ -void timer_set_mode(timer_dev *dev, uint8 channel, timer_mode mode) { - ASSERT_FAULT(channel > 0 && channel <= 4); - - /* TODO decide about the basic timers */ - ASSERT(dev->type != TIMER_BASIC); - if (dev->type == TIMER_BASIC) - return; - - switch (mode) { - case TIMER_DISABLED: - disable_channel(dev, channel); - break; - case TIMER_PWM: - pwm_mode(dev, channel); - break; - case TIMER_OUTPUT_COMPARE: - output_compare_mode(dev, channel); - break; - } -} - -/** - * @brief Determine whether a timer has a particular capture/compare channel. - * - * Different timers have different numbers of capture/compare channels - * (and some have none at all). Use this function to test whether a - * given timer/channel combination will work. - * - * @param dev Timer device - * @param channel Capture/compare channel, from 1 to 4 - * @return Nonzero if dev has channel, zero otherwise. - */ -int timer_has_cc_channel(timer_dev *dev, uint8 channel) { - /* On all currently supported series: advanced and "full-featured" - * general purpose timers have all four channels. Of the - * restricted general timers, timers 9 and 12 have channels 1 and - * 2; the others have channel 1 only. Basic timers have none. */ - rcc_clk_id id = dev->clk_id; - ASSERT((1 <= channel) && (channel <= 4)); - if (id <= RCC_TIMER5 || id == RCC_TIMER8) { - return 1; /* 1 and 8 are advanced, 2-5 are "full" general */ - } else if (id <= RCC_TIMER7) { - return 0; /* 6 and 7 are basic */ - } - /* The rest are restricted general. */ - return (((id == RCC_TIMER9 || id == RCC_TIMER12) && channel <= 2) || - channel == 1); -} - -/** - * @brief Attach a timer interrupt. - * @param dev Timer device - * @param interrupt Interrupt number to attach to; this may be any - * timer_interrupt_id or timer_channel value appropriate - * for the timer. - * @param handler Handler to attach to the given interrupt. - * @see timer_interrupt_id - * @see timer_channel - */ -void timer_attach_interrupt(timer_dev *dev, - uint8 interrupt, - voidFuncPtr handler) { - dev->handlers[interrupt] = handler; - timer_enable_irq(dev, interrupt); - enable_irq(dev, interrupt); -} - -/** - * @brief Detach a timer interrupt. - * @param dev Timer device - * @param interrupt Interrupt number to detach; this may be any - * timer_interrupt_id or timer_channel value appropriate - * for the timer. - * @see timer_interrupt_id - * @see timer_channel - */ -void timer_detach_interrupt(timer_dev *dev, uint8 interrupt) { - timer_disable_irq(dev, interrupt); - dev->handlers[interrupt] = NULL; -} - -/* - * Utilities - */ - -static void disable_channel(timer_dev *dev, uint8 channel) { - timer_detach_interrupt(dev, channel); - timer_cc_disable(dev, channel); -} - -static void pwm_mode(timer_dev *dev, uint8 channel) { - timer_disable_irq(dev, channel); - timer_oc_set_mode(dev, channel, TIMER_OC_MODE_PWM_1, TIMER_OC_PE); - timer_cc_enable(dev, channel); -} - -static void output_compare_mode(timer_dev *dev, uint8 channel) { - timer_oc_set_mode(dev, channel, TIMER_OC_MODE_ACTIVE_ON_MATCH, 0); - timer_cc_enable(dev, channel); -} - -static void enable_adv_irq(timer_dev *dev, timer_interrupt_id id); -static void enable_bas_gen_irq(timer_dev *dev); - -static inline void enable_irq(timer_dev *dev, timer_interrupt_id iid) { - if (dev->type == TIMER_ADVANCED) { - enable_adv_irq(dev, iid); - } else { - enable_bas_gen_irq(dev); - } -} - -/* Advanced control timers have several IRQ lines corresponding to - * different timer interrupts. - * - * Note: This function assumes that the only advanced timers are TIM1 - * and TIM8, and needs the obvious changes if that assumption is - * violated by a later STM32 series. */ -static void enable_adv_irq(timer_dev *dev, timer_interrupt_id id) { - uint8 is_tim1 = dev->clk_id == RCC_TIMER1; - nvic_irq_num irq_num; - switch (id) { - case TIMER_UPDATE_INTERRUPT: - irq_num = (is_tim1 ? - NVIC_TIMER1_UP_TIMER10 : - NVIC_TIMER8_UP_TIMER13); - break; - case TIMER_CC1_INTERRUPT: /* Fall through */ - case TIMER_CC2_INTERRUPT: /* ... */ - case TIMER_CC3_INTERRUPT: /* ... */ - case TIMER_CC4_INTERRUPT: - irq_num = is_tim1 ? NVIC_TIMER1_CC : NVIC_TIMER8_CC; - break; - case TIMER_COM_INTERRUPT: /* Fall through */ - case TIMER_TRG_INTERRUPT: - irq_num = (is_tim1 ? - NVIC_TIMER1_TRG_COM_TIMER11 : - NVIC_TIMER8_TRG_COM_TIMER14); - break; - case TIMER_BREAK_INTERRUPT: - irq_num = (is_tim1 ? - NVIC_TIMER1_BRK_TIMER9 : - NVIC_TIMER8_BRK_TIMER12); - break; - default: - /* Can't happen, but placate the compiler */ - ASSERT(0); - return; - } - nvic_irq_enable(irq_num); -} - -/* Basic and general purpose timers have a single IRQ line, which is - * shared by all interrupts supported by a particular timer. */ -static void enable_bas_gen_irq(timer_dev *dev) { - nvic_irq_num irq_num; - switch (dev->clk_id) { - case RCC_TIMER2: - irq_num = NVIC_TIMER2; - break; - case RCC_TIMER3: - irq_num = NVIC_TIMER3; - break; - case RCC_TIMER4: - irq_num = NVIC_TIMER4; - break; - case RCC_TIMER5: - irq_num = NVIC_TIMER5; - break; - case RCC_TIMER6: - irq_num = NVIC_TIMER6; - break; - case RCC_TIMER7: - irq_num = NVIC_TIMER7; - break; - case RCC_TIMER9: - irq_num = NVIC_TIMER1_BRK_TIMER9; - break; - case RCC_TIMER10: - irq_num = NVIC_TIMER1_UP_TIMER10; - break; - case RCC_TIMER11: - irq_num = NVIC_TIMER1_TRG_COM_TIMER11; - break; - case RCC_TIMER12: - irq_num = NVIC_TIMER8_BRK_TIMER12; - break; - case RCC_TIMER13: - irq_num = NVIC_TIMER8_UP_TIMER13; - break; - case RCC_TIMER14: - irq_num = NVIC_TIMER8_TRG_COM_TIMER14; - break; - default: - ASSERT_FAULT(0); - return; - } - nvic_irq_enable(irq_num); -} - - -/* Note. - * - * 2015/07/06 Roger Clark - * - * The IRQ handlers were initially in timer_f1.c however this seems to cause problems - * in which the compiler / linker doesn't always link all the required handlers. - * The work around was to move the handlers into this file - */ - -/* - * IRQ handlers - * - * Defer to the timer_private dispatch API. - * - * FIXME: The names of these handlers are inaccurate since XL-density - * devices came out. Update these to match the STM32F2 names, maybe - * using some weak symbol magic to preserve backwards compatibility if - * possible. Once that's done, we can just move the IRQ handlers into - * the top-level libmaple/timer.c, and there will be no need for this - * file. - */ - -void __irq_tim1_brk(void) { - dispatch_adv_brk(TIMER1); -#if STM32_HAVE_TIMER(9) - dispatch_tim_9_12(TIMER9); -#endif -} - -void __irq_tim1_up(void) { - dispatch_adv_up(TIMER1); -#if STM32_HAVE_TIMER(10) - dispatch_tim_10_11_13_14(TIMER10); -#endif -} - -void __irq_tim1_trg_com(void) { - dispatch_adv_trg_com(TIMER1); -#if STM32_HAVE_TIMER(11) - dispatch_tim_10_11_13_14(TIMER11); -#endif -} - -void __irq_tim1_cc(void) { - dispatch_adv_cc(TIMER1); -} - -void __irq_tim2(void) { - dispatch_general(TIMER2); -} - -void __irq_tim3(void) { - dispatch_general(TIMER3); -} - -void __irq_tim4(void) { - dispatch_general(TIMER4); -} - -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -void __irq_tim5(void) { - dispatch_general(TIMER5); -} - -void __irq_tim6(void) { - dispatch_basic(TIMER6); -} - -void __irq_tim7(void) { - dispatch_basic(TIMER7); -} - -void __irq_tim8_brk(void) { - dispatch_adv_brk(TIMER8); -#if STM32_HAVE_TIMER(12) - dispatch_tim_9_12(TIMER12); -#endif -} - -void __irq_tim8_up(void) { - dispatch_adv_up(TIMER8); -#if STM32_HAVE_TIMER(13) - dispatch_tim_10_11_13_14(TIMER13); -#endif -} - -void __irq_tim8_trg_com(void) { - dispatch_adv_trg_com(TIMER8); -#if STM32_HAVE_TIMER(14) - dispatch_tim_10_11_13_14(TIMER14); -#endif -} - -void __irq_tim8_cc(void) { - dispatch_adv_cc(TIMER8); -} -#endif /* defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) */ \ No newline at end of file diff --git a/GD32F1/cores/maple/libmaple/timer_f1.c b/GD32F1/cores/maple/libmaple/timer_f1.c deleted file mode 100644 index d67cf3f..0000000 --- a/GD32F1/cores/maple/libmaple/timer_f1.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/timer.c - * @author Marti Bolivar - * @brief STM32F1 timer. - */ - -/* - * 2015/07/06 - * Note. The IRQ handlers which were initially in this file have been moved to timer.c - * to resolve a linker issue in where some IRQ handlers were not being linked even though - * they were being used. - * This file has been retains for historical reasons, but can be moved at some time in the future - * when full testing of the code in the new location has been completed. - */ - diff --git a/GD32F1/cores/maple/libmaple/usart.c b/GD32F1/cores/maple/libmaple/usart.c deleted file mode 100644 index 99a083d..0000000 --- a/GD32F1/cores/maple/libmaple/usart.c +++ /dev/null @@ -1,137 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/usart.c - * @author Marti Bolivar , - * Perry Hung - * @brief Portable USART routines - */ - -#include - -/** - * @brief Initialize a serial port. - * @param dev Serial port to be initialized - */ -void usart_init(usart_dev *dev) { - rb_init(dev->rb, USART_RX_BUF_SIZE, dev->rx_buf); - rcc_clk_enable(dev->clk_id); - nvic_irq_enable(dev->irq_num); -} - -/** - * @brief Enable a serial port. - * - * USART is enabled in single buffer transmission mode, multibuffer - * receiver mode, 8n1. - * - * Serial port must have a baud rate configured to work properly. - * - * @param dev Serial port to enable. - * @see usart_set_baud_rate() - */ -void usart_enable(usart_dev *dev) { - usart_reg_map *regs = dev->regs; - regs->CR1 |= (USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE);// don't change the word length etc, and 'or' in the patten not overwrite |USART_CR1_M_8N1); - regs->CR1 |= USART_CR1_UE; -} - -/** - * @brief Turn off a serial port. - * @param dev Serial port to be disabled - */ -void usart_disable(usart_dev *dev) { - /* FIXME this misbehaves (on F1) if you try to use PWM on TX afterwards */ - usart_reg_map *regs = dev->regs; - - /* TC bit must be high before disabling the USART */ - while((regs->CR1 & USART_CR1_UE) && !(regs->SR & USART_SR_TC)) - ; - - /* Disable UE */ - regs->CR1 &= ~USART_CR1_UE; - - /* Clean up buffer */ - usart_reset_rx(dev); -} - -/** - * @brief Nonblocking USART transmit - * @param dev Serial port to transmit over - * @param buf Buffer to transmit - * @param len Maximum number of bytes to transmit - * @return Number of bytes transmitted - */ -uint32 usart_tx(usart_dev *dev, const uint8 *buf, uint32 len) { - usart_reg_map *regs = dev->regs; - uint32 txed = 0; - while ((regs->SR & USART_SR_TXE) && (txed < len)) { - regs->DR = buf[txed++]; - } - return txed; -} - -/** - * @brief Nonblocking USART receive. - * @param dev Serial port to receive bytes from - * @param buf Buffer to store received bytes into - * @param len Maximum number of bytes to store - * @return Number of bytes received - */ -uint32 usart_rx(usart_dev *dev, uint8 *buf, uint32 len) { - uint32 rxed = 0; - while (usart_data_available(dev) && rxed < len) { - *buf++ = usart_getc(dev); - rxed++; - } - return rxed; -} - -/** - * @brief Transmit an unsigned integer to the specified serial port in - * decimal format. - * - * This function blocks until the integer's digits have been - * completely transmitted. - * - * @param dev Serial port to send on - * @param val Number to print - */ -void usart_putudec(usart_dev *dev, uint32 val) { - char digits[12]; - int i = 0; - - do { - digits[i++] = val % 10 + '0'; - val /= 10; - } while (val > 0); - - while (--i >= 0) { - usart_putc(dev, digits[i]); - } -} diff --git a/GD32F1/cores/maple/libmaple/usart_f1.c b/GD32F1/cores/maple/libmaple/usart_f1.c deleted file mode 100644 index 09835b4..0000000 --- a/GD32F1/cores/maple/libmaple/usart_f1.c +++ /dev/null @@ -1,214 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/usart.c - * @author Marti Bolivar , - * Perry Hung - * @brief STM32F1 USART. - */ - -#include -#include -#include "usart_private.h" - -/* - * Devices - */ - -static ring_buffer usart1_rb; -static usart_dev usart1 = { - .regs = USART1_BASE, - .rb = &usart1_rb, - .max_baud = 4500000UL, - .clk_id = RCC_USART1, - .irq_num = NVIC_USART1, -}; -/** USART1 device */ -usart_dev *USART1 = &usart1; - -static ring_buffer usart2_rb; -static usart_dev usart2 = { - .regs = USART2_BASE, - .rb = &usart2_rb, - .max_baud = 2250000UL, - .clk_id = RCC_USART2, - .irq_num = NVIC_USART2, -}; -/** USART2 device */ -usart_dev *USART2 = &usart2; - -static ring_buffer usart3_rb; -static usart_dev usart3 = { - .regs = USART3_BASE, - .rb = &usart3_rb, - .max_baud = 2250000UL, - .clk_id = RCC_USART3, - .irq_num = NVIC_USART3, -}; -/** USART3 device */ -usart_dev *USART3 = &usart3; - -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -static ring_buffer uart4_rb; -static usart_dev uart4 = { - .regs = UART4_BASE, - .rb = &uart4_rb, - .max_baud = 2250000UL, - .clk_id = RCC_UART4, - .irq_num = NVIC_UART4, -}; -/** UART4 device */ -usart_dev *UART4 = &uart4; - -static ring_buffer uart5_rb; -static usart_dev uart5 = { - .regs = UART5_BASE, - .rb = &uart5_rb, - .max_baud = 2250000UL, - .clk_id = RCC_UART5, - .irq_num = NVIC_UART5, -}; -/** UART5 device */ -usart_dev *UART5 = &uart5; -#endif - -/* - * Routines - */ - -void usart_config_gpios_async(usart_dev *udev, - gpio_dev *rx_dev, uint8 rx, - gpio_dev *tx_dev, uint8 tx, - unsigned flags) { - gpio_set_mode(rx_dev, rx, GPIO_INPUT_FLOATING); - gpio_set_mode(tx_dev, tx, GPIO_AF_OUTPUT_PP); -/* - -CR1 bit 12 Word length 0=8 1=9 -CR1 bit 11 wake (default value is 0) we can safely set this value to 0 (zero) each time -CR1 bit 10 parity enable (1 = enabled) -CR1 bit 9 Parity selection 0 = Even 1 = Odd -CR2 bits 13 and 12 00 = 1 01 = 0.5 10 = 2 11 = 1.5 -Not all USARTs support 1.5 or 0.5 bits so its best to avoid them. - CR2 CR1 - 0B00 0000 - 0B10 0000 - 0B00 1000 - 0B10 1000 - - 0B00 0010 - 0B10 0010 - 0B00 1010 - 0B10 1010 - - 0B00 0011 - 0B10 0011 - 0B00 1011 - 0B10 1011 - -#define SERIAL_8N1 0B 0000 0000 -#define SERIAL_8N2 0B 0010 0000 -#define SERIAL_9N1 0B 0000 1000 -#define SERIAL_9N2 0B 0010 1000 - -#define SERIAL_8E1 0B 0000 0010 -#define SERIAL_8E2 0B 0010 0010 -#define SERIAL_9E1 0B 0000 1010 -#define SERIAL_9E2 0B 0010 1010 - -#define SERIAL_8O1 0B 0000 0011 -#define SERIAL_8O2 0B 0010 0011 -#define SERIAL_9O1 0B 0000 1011 -#define SERIAL_9O2 0B 0010 1011 - - */ - - - udev->regs->CR1 = udev->regs->CR1 ^ ((udev->regs->CR1 ^ (flags&0x0F)<<9 ) & 0B0001111000000000); - udev->regs->CR2 = udev->regs->CR2 ^ ((udev->regs->CR2 ^ (flags&0xF0)<<8 ) & 0B0011000000000000); -} - -void usart_set_baud_rate(usart_dev *dev, uint32 clock_speed, uint32 baud) { - uint32 integer_part; - uint32 fractional_part; - uint32 tmp; - - /* Figure out the clock speed, if the user doesn't give one. */ - if (clock_speed == 0) { - clock_speed = _usart_clock_freq(dev); - } - ASSERT(clock_speed); - - /* Convert desired baud rate to baud rate register setting. */ - integer_part = (25 * clock_speed) / (4 * baud); - tmp = (integer_part / 100) << 4; - fractional_part = integer_part - (100 * (tmp >> 4)); - tmp |= (((fractional_part * 16) + 50) / 100) & ((uint8)0x0F); - - dev->regs->BRR = (uint16)tmp; -} - -/** - * @brief Call a function on each USART. - * @param fn Function to call. - */ -void usart_foreach(void (*fn)(usart_dev*)) { - fn(USART1); - fn(USART2); - fn(USART3); -#ifdef STM32_HIGH_DENSITY - fn(UART4); - fn(UART5); -#endif -} - -/* - * Interrupt handlers. - */ - -void __irq_usart1(void) { - usart_irq(&usart1_rb, USART1_BASE); -} - -void __irq_usart2(void) { - usart_irq(&usart2_rb, USART2_BASE); -} - -void __irq_usart3(void) { - usart_irq(&usart3_rb, USART3_BASE); -} - -#ifdef STM32_HIGH_DENSITY -void __irq_uart4(void) { - usart_irq(&uart4_rb, UART4_BASE); -} - -void __irq_uart5(void) { - usart_irq(&uart5_rb, UART5_BASE); -} -#endif diff --git a/GD32F1/cores/maple/libmaple/usart_private.c b/GD32F1/cores/maple/libmaple/usart_private.c deleted file mode 100644 index 0eaacdf..0000000 --- a/GD32F1/cores/maple/libmaple/usart_private.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/usart_private.c - * @author Marti Bolivar - * @brief Private USART routines. - */ - -#include "usart_private.h" -#include -#include - -uint32 _usart_clock_freq(usart_dev *dev) { - rcc_clk_domain domain = rcc_dev_clk(dev->clk_id); - return (domain == RCC_APB1 ? STM32_PCLK1 : - (domain == RCC_APB2 ? STM32_PCLK2 : 0)); -} diff --git a/GD32F1/cores/maple/libmaple/usb/README b/GD32F1/cores/maple/libmaple/usb/README deleted file mode 100644 index d0fca8d..0000000 --- a/GD32F1/cores/maple/libmaple/usb/README +++ /dev/null @@ -1,63 +0,0 @@ -The USB submodule of libmaple is a separate piece of the codebase for -reasons that are largely historical. - -Current Status: - - There's only support for the USB device peripheral found on - STM32F103s. - - We rely on the low level core library provided by ST to implement - the USB transfer protocol for control endpoint transfers. - - The virtual com port (which is exposed via - ) serves two important purposes. - - 1) It allows serial data transfers between user sketches an a - host computer. - - 2) It allows the host PC to issue a system reset into the DFU - bootloader with the DTR + RTS + "1EAF" sequence (see - leaflabs.com/docs/bootloader.html for more information on - this). - - After reset, Maple will run the DFU bootloader for a few seconds, - during which the user can begin a DFU upload operation (uploads - application binary into RAM/FLASH). Thus, without this virtual com - port, it would be necessary to find an alternative means to reset - the chip in order to enable the bootloader. - - If you would like to develop your own USB application for whatever - reason (e.g. to use faster isochronous enpoints for streaming - audio, or implement the USB HID or Mass Storage specs), then - ensure that you leave some hook for resetting Maple remotely in - order to spin up the DFU bootloader. Please make sure to get - yourself a unique vendor/product ID pair for your application, as - some operating systems will assign a host-side driver based on - these tags. - - It would be possible to build a compound USB device, that - implements endpoints for both the virtual COM port as well as some - other components (mass storage etc.). However, this turns out to - be a burden from the host driver side, as Windows and *nix handle - compound USB devices quite differently. - - Be mindful that enabling the USB peripheral isn't "free." The - device must respond to periodic bus activity (every few - milliseconds) by servicing an ISR. Therefore, the USB application - should be disabled inside of timing critical applications. - - In order to disconnect the device from the host, a USB_DISC pin is - asserted (e.g. on Maple, this is PC12). Alternatively, the NVIC - can be directly configured to disable the USB LP/HP IRQ's. - - The files inside of usb_lib were provided by ST and are subject to - their own license, all other files were written by the LeafLabs - team and fall under the MIT license. - -TODO: - - - Generic USB driver core with series-provided backends, like - libopencm3 has. - - Strip out ST code. - - Integration with a high level USB library (like LUFA/MyUSB) to - allow users to write custom USB applications. diff --git a/GD32F1/cores/maple/libmaple/usb/rules.mk b/GD32F1/cores/maple/libmaple/usb/rules.mk deleted file mode 100644 index e8ccc15..0000000 --- a/GD32F1/cores/maple/libmaple/usb/rules.mk +++ /dev/null @@ -1,45 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -# Local flags -CFLAGS_$(d) = -I$(d) -I$(d)/$(MCU_SERIES) -I$(d)/usb_lib $(LIBMAPLE_INCLUDES) $(LIBMAPLE_PRIVATE_INCLUDES) -Wall - -# Add usblib and series subdirectory to BUILDDIRS. -BUILDDIRS += $(BUILD_PATH)/$(d)/$(MCU_SERIES) -BUILDDIRS += $(BUILD_PATH)/$(d)/usb_lib - -# Local rules and targets -sSRCS_$(d) := -cSRCS_$(d) := -# We currently only have F1 performance line support. Sigh. -ifeq ($(MCU_SERIES), stm32f1) -ifeq ($(MCU_F1_LINE), performance) -cSRCS_$(d) += $(MCU_SERIES)/usb.c -cSRCS_$(d) += $(MCU_SERIES)/usb_reg_map.c -cSRCS_$(d) += $(MCU_SERIES)/usb_cdcacm.c -cSRCS_$(d) += usb_lib/usb_core.c -cSRCS_$(d) += usb_lib/usb_init.c -cSRCS_$(d) += usb_lib/usb_mem.c -cSRCS_$(d) += usb_lib/usb_regs.c -endif -endif - -sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \ - $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) -$(OBJS_$(d)): TGT_ASFLAGS := - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) diff --git a/GD32F1/cores/maple/libmaple/usb/stm32f1/usb.c b/GD32F1/cores/maple/libmaple/usb/stm32f1/usb.c deleted file mode 100644 index f694f04..0000000 --- a/GD32F1/cores/maple/libmaple/usb/stm32f1/usb.c +++ /dev/null @@ -1,387 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/usb/stm32f1/usb.c - * @brief USB support. - * - * This is a mess. - */ - -#include - -#include -#include - -/* Private headers */ -#include "usb_reg_map.h" -#include "usb_lib_globals.h" - -/* usb_lib headers */ -#include "usb_type.h" -#include "usb_core.h" - -static void dispatch_ctr_lp(void); - -/* - * usb_lib/ globals - */ - -uint16 SaveTState; /* caches TX status for later use */ -uint16 SaveRState; /* caches RX status for later use */ - -/* - * Other state - */ - -typedef enum { - RESUME_EXTERNAL, - RESUME_INTERNAL, - RESUME_LATER, - RESUME_WAIT, - RESUME_START, - RESUME_ON, - RESUME_OFF, - RESUME_ESOF -} RESUME_STATE; - -struct { - volatile RESUME_STATE eState; - volatile uint8 bESOFcnt; -} ResumeS; - -static usblib_dev usblib = { - .irq_mask = USB_ISR_MSK, - .state = USB_UNCONNECTED, - .prevState = USB_UNCONNECTED, - .clk_id = RCC_USB, -}; -usblib_dev *USBLIB = &usblib; - -/* - * Routines - */ - -void usb_init_usblib(usblib_dev *dev, - void (**ep_int_in)(void), - void (**ep_int_out)(void)) { - rcc_clk_enable(dev->clk_id); - - dev->ep_int_in = ep_int_in; - dev->ep_int_out = ep_int_out; - - /* usb_lib/ declares both and then assumes that pFoo points to Foo - * (even though the names don't always match), which is stupid for - * all of the obvious reasons, but whatever. Here we are. */ - pInformation = &Device_Info; - pProperty = &Device_Property; - pUser_Standard_Requests = &User_Standard_Requests; - - pInformation->ControlState = 2; /* FIXME [0.0.12] use - CONTROL_STATE enumerator */ - pProperty->Init(); -} - -static void usb_suspend(void) { - uint16 cntr; - - /* TODO decide if read/modify/write is really what we want - * (e.g. usb_resume_init() reconfigures CNTR). */ - cntr = USB_BASE->CNTR; - cntr |= USB_CNTR_FSUSP; - USB_BASE->CNTR = cntr; - cntr |= USB_CNTR_LP_MODE; - USB_BASE->CNTR = cntr; - - USBLIB->prevState = USBLIB->state; - USBLIB->state = USB_SUSPENDED; -} - -static void usb_resume_init(void) { - uint16 cntr; - - cntr = USB_BASE->CNTR; - cntr &= ~USB_CNTR_LP_MODE; - USB_BASE->CNTR = cntr; - - /* Enable interrupt lines */ - USB_BASE->CNTR = USB_ISR_MSK; -} - -static void usb_resume(RESUME_STATE eResumeSetVal) { - uint16 cntr; - - if (eResumeSetVal != RESUME_ESOF) { - ResumeS.eState = eResumeSetVal; - } - - switch (ResumeS.eState) { - case RESUME_EXTERNAL: - usb_resume_init(); - ResumeS.eState = RESUME_OFF; - USBLIB->state = USBLIB->prevState; - break; - case RESUME_INTERNAL: - usb_resume_init(); - ResumeS.eState = RESUME_START; - break; - case RESUME_LATER: - ResumeS.bESOFcnt = 2; - ResumeS.eState = RESUME_WAIT; - break; - case RESUME_WAIT: - ResumeS.bESOFcnt--; - if (ResumeS.bESOFcnt == 0) { - ResumeS.eState = RESUME_START; - } - break; - case RESUME_START: - cntr = USB_BASE->CNTR; - cntr |= USB_CNTR_RESUME; - USB_BASE->CNTR = cntr; - ResumeS.eState = RESUME_ON; - ResumeS.bESOFcnt = 10; - break; - case RESUME_ON: - ResumeS.bESOFcnt--; - if (ResumeS.bESOFcnt == 0) { - cntr = USB_BASE->CNTR; - cntr &= ~USB_CNTR_RESUME; - USB_BASE->CNTR = cntr; - USBLIB->state = USBLIB->prevState; - ResumeS.eState = RESUME_OFF; - } - break; - case RESUME_OFF: - case RESUME_ESOF: - default: - ResumeS.eState = RESUME_OFF; - break; - } -} - -#define SUSPEND_ENABLED 1 -void __irq_usb_lp_can_rx0(void) { - uint16 istr = USB_BASE->ISTR; - - /* Use USB_ISR_MSK to only include code for bits we care about. */ - -#if (USB_ISR_MSK & USB_ISTR_RESET) - if (istr & USB_ISTR_RESET & USBLIB->irq_mask) { - USB_BASE->ISTR = ~USB_ISTR_RESET; - pProperty->Reset(); - } -#endif - -#if (USB_ISR_MSK & USB_ISTR_PMAOVR) - if (istr & ISTR_PMAOVR & USBLIB->irq_mask) { - USB_BASE->ISTR = ~USB_ISTR_PMAOVR; - } -#endif - -#if (USB_ISR_MSK & USB_ISTR_ERR) - if (istr & USB_ISTR_ERR & USBLIB->irq_mask) { - USB_BASE->ISTR = ~USB_ISTR_ERR; - } -#endif - -#if (USB_ISR_MSK & USB_ISTR_WKUP) - if (istr & USB_ISTR_WKUP & USBLIB->irq_mask) { - USB_BASE->ISTR = ~USB_ISTR_WKUP; - usb_resume(RESUME_EXTERNAL); - } -#endif - -#if (USB_ISR_MSK & USB_ISTR_SUSP) - if (istr & USB_ISTR_SUSP & USBLIB->irq_mask) { - /* check if SUSPEND is possible */ - if (SUSPEND_ENABLED) { - usb_suspend(); - } else { - /* if not possible then resume after xx ms */ - usb_resume(RESUME_LATER); - } - /* clear of the ISTR bit must be done after setting of CNTR_FSUSP */ - USB_BASE->ISTR = ~USB_ISTR_SUSP; - } -#endif - -#if (USB_ISR_MSK & USB_ISTR_SOF) - if (istr & USB_ISTR_SOF & USBLIB->irq_mask) { - USB_BASE->ISTR = ~USB_ISTR_SOF; - } -#endif - -#if (USB_ISR_MSK & USB_ISTR_ESOF) - if (istr & USB_ISTR_ESOF & USBLIB->irq_mask) { - USB_BASE->ISTR = ~USB_ISTR_ESOF; - /* resume handling timing is made with ESOFs */ - usb_resume(RESUME_ESOF); /* request without change of the machine state */ - } -#endif - - /* - * Service the correct transfer interrupt. - */ - -#if (USB_ISR_MSK & USB_ISTR_CTR) - if (istr & USB_ISTR_CTR & USBLIB->irq_mask) { - dispatch_ctr_lp(); - } -#endif -} - -/* - * Auxiliary routines - */ - -static inline uint8 dispatch_endpt_zero(uint16 istr_dir); -static inline void dispatch_endpt(uint8 ep); -static inline void set_rx_tx_status0(uint16 rx, uint16 tx); - -static void handle_setup0(void); -static void handle_in0(void); -static void handle_out0(void); - -static void dispatch_ctr_lp() { - uint16 istr; - while (((istr = USB_BASE->ISTR) & USB_ISTR_CTR) != 0) { - /* TODO WTF, figure this out: RM0008 says CTR is read-only, - * but ST's firmware claims it's clear-only, and emphasizes - * the importance of clearing it in more than one place. */ - USB_BASE->ISTR = ~USB_ISTR_CTR; - uint8 ep_id = istr & USB_ISTR_EP_ID; - if (ep_id == 0) { - /* TODO figure out why it's OK to break out of the loop - * once we're done serving endpoint zero, but not okay if - * there are multiple nonzero endpoint transfers to - * handle. */ - if (dispatch_endpt_zero(istr & USB_ISTR_DIR)) { - return; - } - } else { - dispatch_endpt(ep_id); - } - } -} - -/* FIXME Dataflow on endpoint 0 RX/TX status is based off of ST's - * code, and is ugly/confusing in its use of SaveRState/SaveTState. - * Fixing this requires filling in handle_in0(), handle_setup0(), - * handle_out0(). */ -static inline uint8 dispatch_endpt_zero(uint16 istr_dir) { - uint32 epr = (uint16)USB_BASE->EP[0]; - - if (!(epr & (USB_EP_CTR_TX | USB_EP_SETUP | USB_EP_CTR_RX))) { - return 0; - } - - /* Cache RX/TX statuses in SaveRState/SaveTState, respectively. - * The various handle_foo0() may clobber these values - * before we reset them at the end of this routine. */ - SaveRState = epr & USB_EP_STAT_RX; - SaveTState = epr & USB_EP_STAT_TX; - - /* Set actual RX/TX statuses to NAK while we're thinking */ - set_rx_tx_status0(USB_EP_STAT_RX_NAK, USB_EP_STAT_TX_NAK); - - if (istr_dir == 0) { - /* ST RM0008: "If DIR bit=0, CTR_TX bit is set in the USB_EPnR - * register related to the interrupting endpoint. The - * interrupting transaction is of IN type (data transmitted by - * the USB peripheral to the host PC)." */ - ASSERT_FAULT(epr & USB_EP_CTR_TX); - usb_clear_ctr_tx(USB_EP0); - handle_in0(); - } else { - /* RM0008: "If DIR bit=1, CTR_RX bit or both CTR_TX/CTR_RX - * are set in the USB_EPnR register related to the - * interrupting endpoint. The interrupting transaction is of - * OUT type (data received by the USB peripheral from the host - * PC) or two pending transactions are waiting to be - * processed." - * - * [mbolivar] Note how the following control flow (which - * replicates ST's) doesn't seem to actually handle both - * interrupts that are ostensibly pending when both CTR_RX and - * CTR_TX are set. - * - * TODO sort this mess out. - */ - if (epr & USB_EP_CTR_TX) { - usb_clear_ctr_tx(USB_EP0); - handle_in0(); - } else { /* SETUP or CTR_RX */ - /* SETUP is held constant while CTR_RX is set, so clear it - * either way */ - usb_clear_ctr_rx(USB_EP0); - if (epr & USB_EP_SETUP) { - handle_setup0(); - } else { /* CTR_RX */ - handle_out0(); - } - } - } - - set_rx_tx_status0(SaveRState, SaveTState); - return 1; -} - -static inline void dispatch_endpt(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - /* If ISTR_CTR is set and the ISTR gave us this EP_ID to handle, - * then presumably at least one of CTR_RX and CTR_TX is set, but - * again, ST's control flow allows for the possibility of neither. - * - * TODO try to find out if neither being set is possible. */ - if (epr & USB_EP_CTR_RX) { - usb_clear_ctr_rx(ep); - (USBLIB->ep_int_out[ep - 1])(); - } - if (epr & USB_EP_CTR_TX) { - usb_clear_ctr_tx(ep); - (USBLIB->ep_int_in[ep - 1])(); - } -} - -static inline void set_rx_tx_status0(uint16 rx, uint16 tx) { - usb_set_ep_rx_stat(USB_EP0, rx); - usb_set_ep_tx_stat(USB_EP0, tx); -} - -/* TODO Rip out usb_lib/ dependency from the following functions: */ - -static void handle_setup0(void) { - Setup0_Process(); -} - -static void handle_in0(void) { - In0_Process(); -} - -static void handle_out0(void) { - Out0_Process(); -} diff --git a/GD32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c b/GD32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c deleted file mode 100644 index 679f3fb..0000000 --- a/GD32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c +++ /dev/null @@ -1,751 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/usb/stm32f1/usb_cdcacm.c - * @brief USB CDC ACM (a.k.a. virtual serial terminal, VCOM). - * - * FIXME: this works on the STM32F1 USB peripherals, and probably no - * place else. Nonportable bits really need to be factored out, and - * the result made cleaner. - */ - -#include - -#include -#include -#include - -/* Private headers */ -#include "usb_lib_globals.h" -#include "usb_reg_map.h" - -/* usb_lib headers */ -#include "usb_type.h" -#include "usb_core.h" -#include "usb_def.h" - -/****************************************************************************** - ****************************************************************************** - *** - *** HACK ALERT! FIXME FIXME FIXME FIXME! - *** - *** A bunch of LeafLabs-specific configuration lives in here for - *** now. This mess REALLY needs to get teased apart, with - *** appropriate pieces moved into Wirish. - *** - ****************************************************************************** - *****************************************************************************/ - -#if !(defined(BOARD_maple) || defined(BOARD_maple_RET6) || \ - defined(BOARD_maple_mini) || defined(BOARD_maple_native)) -#warning USB CDC ACM relies on LeafLabs board-specific configuration.\ - You may have problems on non-LeafLabs boards. -#endif - -static void vcomDataTxCb(void); -static void vcomDataRxCb(void); -static uint8* vcomGetSetLineCoding(uint16); - -static void usbInit(void); -static void usbReset(void); -static RESULT usbDataSetup(uint8 request); -static RESULT usbNoDataSetup(uint8 request); -static RESULT usbGetInterfaceSetting(uint8 interface, uint8 alt_setting); -static uint8* usbGetDeviceDescriptor(uint16 length); -static uint8* usbGetConfigDescriptor(uint16 length); -static uint8* usbGetStringDescriptor(uint16 length); -static void usbSetConfiguration(void); -static void usbSetDeviceAddress(void); - -/* - * Descriptors - */ - -/* FIXME move to Wirish */ -#define LEAFLABS_ID_VENDOR 0x1EAF -#define MAPLE_ID_PRODUCT 0x0004 -static const usb_descriptor_device usbVcomDescriptor_Device = - USB_CDCACM_DECLARE_DEV_DESC(LEAFLABS_ID_VENDOR, MAPLE_ID_PRODUCT); - -typedef struct { - usb_descriptor_config_header Config_Header; - usb_descriptor_interface CCI_Interface; - CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_IntHeader; - CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_CallManagement; - CDC_FUNCTIONAL_DESCRIPTOR(1) CDC_Functional_ACM; - CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_Union; - usb_descriptor_endpoint ManagementEndpoint; - usb_descriptor_interface DCI_Interface; - usb_descriptor_endpoint DataOutEndpoint; - usb_descriptor_endpoint DataInEndpoint; -} __packed usb_descriptor_config; - -#define MAX_POWER (100 >> 1) -static const usb_descriptor_config usbVcomDescriptor_Config = { - .Config_Header = { - .bLength = sizeof(usb_descriptor_config_header), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CONFIGURATION, - .wTotalLength = sizeof(usb_descriptor_config), - .bNumInterfaces = 0x02, - .bConfigurationValue = 0x01, - .iConfiguration = 0x00, - .bmAttributes = (USB_CONFIG_ATTR_BUSPOWERED | - USB_CONFIG_ATTR_SELF_POWERED), - .bMaxPower = MAX_POWER, - }, - - .CCI_Interface = { - .bLength = sizeof(usb_descriptor_interface), - .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE, - .bInterfaceNumber = 0x00, - .bAlternateSetting = 0x00, - .bNumEndpoints = 0x01, - .bInterfaceClass = USB_INTERFACE_CLASS_CDC, - .bInterfaceSubClass = USB_INTERFACE_SUBCLASS_CDC_ACM, - .bInterfaceProtocol = 0x01, /* Common AT Commands */ - .iInterface = 0x00, - }, - - .CDC_Functional_IntHeader = { - .bLength = CDC_FUNCTIONAL_DESCRIPTOR_SIZE(2), - .bDescriptorType = 0x24, - .SubType = 0x00, - .Data = {0x01, 0x10}, - }, - - .CDC_Functional_CallManagement = { - .bLength = CDC_FUNCTIONAL_DESCRIPTOR_SIZE(2), - .bDescriptorType = 0x24, - .SubType = 0x01, - .Data = {0x03, 0x01}, - }, - - .CDC_Functional_ACM = { - .bLength = CDC_FUNCTIONAL_DESCRIPTOR_SIZE(1), - .bDescriptorType = 0x24, - .SubType = 0x02, - .Data = {0x06}, - }, - - .CDC_Functional_Union = { - .bLength = CDC_FUNCTIONAL_DESCRIPTOR_SIZE(2), - .bDescriptorType = 0x24, - .SubType = 0x06, - .Data = {0x00, 0x01}, - }, - - .ManagementEndpoint = { - .bLength = sizeof(usb_descriptor_endpoint), - .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT, - .bEndpointAddress = (USB_DESCRIPTOR_ENDPOINT_IN | - USB_CDCACM_MANAGEMENT_ENDP), - .bmAttributes = USB_EP_TYPE_INTERRUPT, - .wMaxPacketSize = USB_CDCACM_MANAGEMENT_EPSIZE, - .bInterval = 0xFF, - }, - - .DCI_Interface = { - .bLength = sizeof(usb_descriptor_interface), - .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE, - .bInterfaceNumber = 0x01, - .bAlternateSetting = 0x00, - .bNumEndpoints = 0x02, - .bInterfaceClass = USB_INTERFACE_CLASS_DIC, - .bInterfaceSubClass = 0x00, /* None */ - .bInterfaceProtocol = 0x00, /* None */ - .iInterface = 0x00, - }, - - .DataOutEndpoint = { - .bLength = sizeof(usb_descriptor_endpoint), - .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT, - .bEndpointAddress = (USB_DESCRIPTOR_ENDPOINT_OUT | - USB_CDCACM_RX_ENDP), - .bmAttributes = USB_EP_TYPE_BULK, - .wMaxPacketSize = USB_CDCACM_RX_EPSIZE, - .bInterval = 0x00, - }, - - .DataInEndpoint = { - .bLength = sizeof(usb_descriptor_endpoint), - .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT, - .bEndpointAddress = (USB_DESCRIPTOR_ENDPOINT_IN | USB_CDCACM_TX_ENDP), - .bmAttributes = USB_EP_TYPE_BULK, - .wMaxPacketSize = USB_CDCACM_TX_EPSIZE, - .bInterval = 0x00, - }, -}; - -/* - String Descriptors: - - we may choose to specify any or none of the following string - identifiers: - - iManufacturer: LeafLabs - iProduct: Maple - iSerialNumber: NONE - iConfiguration: NONE - iInterface(CCI): NONE - iInterface(DCI): NONE - -*/ - -/* Unicode language identifier: 0x0409 is US English */ -/* FIXME move to Wirish */ -static const usb_descriptor_string usbVcomDescriptor_LangID = { - .bLength = USB_DESCRIPTOR_STRING_LEN(1), - .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, - .bString = {0x09, 0x04}, -}; - -/* FIXME move to Wirish */ -static const usb_descriptor_string usbVcomDescriptor_iManufacturer = { - .bLength = USB_DESCRIPTOR_STRING_LEN(8), - .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, - .bString = {'L', 0, 'e', 0, 'a', 0, 'f', 0, - 'L', 0, 'a', 0, 'b', 0, 's', 0}, -}; - -/* FIXME move to Wirish */ -static const usb_descriptor_string usbVcomDescriptor_iProduct = { - .bLength = USB_DESCRIPTOR_STRING_LEN(5), - .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, - .bString = {'M', 0, 'a', 0, 'p', 0, 'l', 0, 'e', 0}, -}; - -static ONE_DESCRIPTOR Device_Descriptor = { - (uint8*)&usbVcomDescriptor_Device, - sizeof(usb_descriptor_device) -}; - -static ONE_DESCRIPTOR Config_Descriptor = { - (uint8*)&usbVcomDescriptor_Config, - sizeof(usb_descriptor_config) -}; - -#define N_STRING_DESCRIPTORS 3 -static ONE_DESCRIPTOR String_Descriptor[N_STRING_DESCRIPTORS] = { - {(uint8*)&usbVcomDescriptor_LangID, USB_DESCRIPTOR_STRING_LEN(1)}, - {(uint8*)&usbVcomDescriptor_iManufacturer,USB_DESCRIPTOR_STRING_LEN(8)}, - {(uint8*)&usbVcomDescriptor_iProduct, USB_DESCRIPTOR_STRING_LEN(5)} -}; - -/* - * Etc. - */ - -/* I/O state */ - -#define CDC_SERIAL_BUFFER_SIZE 512 - -/* Received data */ -static volatile uint8 vcomBufferRx[CDC_SERIAL_BUFFER_SIZE]; -/* Read index into vcomBufferRx */ -static volatile uint32 rx_offset = 0; -/* Number of bytes left to transmit */ -static volatile uint32 n_unsent_bytes = 0; -/* Are we currently sending an IN packet? */ -static volatile uint8 transmitting = 0; -/* Number of unread bytes */ -static volatile uint32 n_unread_bytes = 0; - -/* Other state (line coding, DTR/RTS) */ - -static volatile usb_cdcacm_line_coding line_coding = { - /* This default is 115200 baud, 8N1. */ - .dwDTERate = 115200, - .bCharFormat = USB_CDCACM_STOP_BITS_1, - .bParityType = USB_CDCACM_PARITY_NONE, - .bDataBits = 8, -}; - -/* DTR in bit 0, RTS in bit 1. */ -static volatile uint8 line_dtr_rts = 0; - -/* - * Endpoint callbacks - */ - -static void (*ep_int_in[7])(void) = - {vcomDataTxCb, - NOP_Process, - NOP_Process, - NOP_Process, - NOP_Process, - NOP_Process, - NOP_Process}; - -static void (*ep_int_out[7])(void) = - {NOP_Process, - NOP_Process, - vcomDataRxCb, - NOP_Process, - NOP_Process, - NOP_Process, - NOP_Process}; - -/* - * Globals required by usb_lib/ - * - * Mark these weak so they can be overriden to implement other USB - * functionality. - */ - -#define NUM_ENDPTS 0x04 -__weak DEVICE Device_Table = { - .Total_Endpoint = NUM_ENDPTS, - .Total_Configuration = 1 -}; - -#define MAX_PACKET_SIZE 0x40 /* 64B, maximum for USB FS Devices */ -__weak DEVICE_PROP Device_Property = { - .Init = usbInit, - .Reset = usbReset, - .Process_Status_IN = NOP_Process, - .Process_Status_OUT = NOP_Process, - .Class_Data_Setup = usbDataSetup, - .Class_NoData_Setup = usbNoDataSetup, - .Class_Get_Interface_Setting = usbGetInterfaceSetting, - .GetDeviceDescriptor = usbGetDeviceDescriptor, - .GetConfigDescriptor = usbGetConfigDescriptor, - .GetStringDescriptor = usbGetStringDescriptor, - .RxEP_buffer = NULL, - .MaxPacketSize = MAX_PACKET_SIZE -}; - -__weak USER_STANDARD_REQUESTS User_Standard_Requests = { - .User_GetConfiguration = NOP_Process, - .User_SetConfiguration = usbSetConfiguration, - .User_GetInterface = NOP_Process, - .User_SetInterface = NOP_Process, - .User_GetStatus = NOP_Process, - .User_ClearFeature = NOP_Process, - .User_SetEndPointFeature = NOP_Process, - .User_SetDeviceFeature = NOP_Process, - .User_SetDeviceAddress = usbSetDeviceAddress -}; - -/* - * User hooks - */ - -static void (*rx_hook)(unsigned, void*) = 0; -static void (*iface_setup_hook)(unsigned, void*) = 0; - -void usb_cdcacm_set_hooks(unsigned hook_flags, void (*hook)(unsigned, void*)) { - if (hook_flags & USB_CDCACM_HOOK_RX) { - rx_hook = hook; - } - if (hook_flags & USB_CDCACM_HOOK_IFACE_SETUP) { - iface_setup_hook = hook; - } -} - -/* - * CDC ACM interface - */ - -void usb_cdcacm_enable(gpio_dev *disc_dev, uint8 disc_bit) { - /* Present ourselves to the host. Writing 0 to "disc" pin must - * pull USB_DP pin up while leaving USB_DM pulled down by the - * transceiver. See USB 2.0 spec, section 7.1.7.3. */ - gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP); - gpio_write_bit(disc_dev, disc_bit, 0); - - /* Initialize the USB peripheral. */ - usb_init_usblib(USBLIB, ep_int_in, ep_int_out); -} - -void usb_cdcacm_disable(gpio_dev *disc_dev, uint8 disc_bit) { - /* Turn off the interrupt and signal disconnect (see e.g. USB 2.0 - * spec, section 7.1.7.3). */ - nvic_irq_disable(NVIC_USB_LP_CAN_RX0); - gpio_write_bit(disc_dev, disc_bit, 1); -} - -void usb_cdcacm_putc(char ch) { - while (!usb_cdcacm_tx((uint8*)&ch, 1)) - ; -} - -/* This function is non-blocking. - * - * It copies data from a usercode buffer into the USB peripheral TX - * buffer, and returns the number of bytes copied. */ -uint32 usb_cdcacm_tx(const uint8* buf, uint32 len) { - /* Last transmission hasn't finished, so abort. */ - if (usb_cdcacm_is_transmitting()) { - return 0; - } - - /* We can only put USB_CDCACM_TX_EPSIZE bytes in the buffer. */ - if (len > USB_CDCACM_TX_EPSIZE) { - len = USB_CDCACM_TX_EPSIZE; - } - - /* Queue bytes for sending. */ - if (len) { - usb_copy_to_pma(buf, len, USB_CDCACM_TX_ADDR); - } - // We still need to wait for the interrupt, even if we're sending - // zero bytes. (Sending zero-size packets is useful for flushing - // host-side buffers.) - usb_set_ep_tx_count(USB_CDCACM_TX_ENDP, len); - n_unsent_bytes = len; - transmitting = 1; - usb_set_ep_tx_stat(USB_CDCACM_TX_ENDP, USB_EP_STAT_TX_VALID); - - return len; -} - - - -uint32 usb_cdcacm_data_available(void) { - return n_unread_bytes; -} - -uint8 usb_cdcacm_is_transmitting(void) { - return transmitting; -} - -uint16 usb_cdcacm_get_pending(void) { - return n_unsent_bytes; -} - -/* Nonblocking byte receive. - * - * Copies up to len bytes from our private data buffer (*NOT* the PMA) - * into buf and deq's the FIFO. */ -uint32 usb_cdcacm_rx(uint8* buf, uint32 len) { - /* Copy bytes to buffer. */ - uint32 n_copied = usb_cdcacm_peek(buf, len); - - /* Mark bytes as read. */ - n_unread_bytes -= n_copied; - rx_offset = (rx_offset + n_copied) % CDC_SERIAL_BUFFER_SIZE; - - /* If all bytes have been read, re-enable the RX endpoint, which - * was set to NAK when the current batch of bytes was received. */ - if (n_unread_bytes <= (CDC_SERIAL_BUFFER_SIZE - USB_CDCACM_RX_EPSIZE)) { - usb_set_ep_rx_count(USB_CDCACM_RX_ENDP, USB_CDCACM_RX_EPSIZE); - usb_set_ep_rx_stat(USB_CDCACM_RX_ENDP, USB_EP_STAT_RX_VALID); - } - - return n_copied; -} - -/* Nonblocking byte lookahead. - * - * Looks at unread bytes without marking them as read. */ -uint32 usb_cdcacm_peek(uint8* buf, uint32 len) { - int i; - uint32 head = rx_offset; - - if (len > n_unread_bytes) { - len = n_unread_bytes; - } - - for (i = 0; i < len; i++) { - buf[i] = vcomBufferRx[head]; - head = (head + 1) % CDC_SERIAL_BUFFER_SIZE; - } - - return len; -} - -uint32 usb_cdcacm_peek_ex(uint8* buf, uint32 offset, uint32 len) { - int i; - uint32 head = (rx_offset + offset) % CDC_SERIAL_BUFFER_SIZE; - - if (len + offset > n_unread_bytes) { - len = n_unread_bytes - offset; - } - - for (i = 0; i < len; i++) { - buf[i] = vcomBufferRx[head]; - head = (head + 1) % CDC_SERIAL_BUFFER_SIZE; - } - - return len; -} - -/* Roger Clark. Added. for Arduino 1.0 API support of Serial.peek() */ -int usb_cdcacm_peek_char() -{ - if (n_unread_bytes == 0) - { - return -1; - } - - return vcomBufferRx[rx_offset]; -} - -uint8 usb_cdcacm_get_dtr() { - return ((line_dtr_rts & USB_CDCACM_CONTROL_LINE_DTR) != 0); -} - -uint8 usb_cdcacm_get_rts() { - return ((line_dtr_rts & USB_CDCACM_CONTROL_LINE_RTS) != 0); -} - -void usb_cdcacm_get_line_coding(usb_cdcacm_line_coding *ret) { - ret->dwDTERate = line_coding.dwDTERate; - ret->bCharFormat = line_coding.bCharFormat; - ret->bParityType = line_coding.bParityType; - ret->bDataBits = line_coding.bDataBits; -} - -int usb_cdcacm_get_baud(void) { - return line_coding.dwDTERate; -} - -int usb_cdcacm_get_stop_bits(void) { - return line_coding.bCharFormat; -} - -int usb_cdcacm_get_parity(void) { - return line_coding.bParityType; -} - -int usb_cdcacm_get_n_data_bits(void) { - return line_coding.bDataBits; -} - - -/* - * Callbacks - */ - -static void vcomDataTxCb(void) { - n_unsent_bytes = 0; - transmitting = 0; -} - -static void vcomDataRxCb(void) { - uint32 ep_rx_size; - uint32 tail = (rx_offset + n_unread_bytes) % CDC_SERIAL_BUFFER_SIZE; - uint8 ep_rx_data[USB_CDCACM_RX_EPSIZE]; - uint32 i; - - usb_set_ep_rx_stat(USB_CDCACM_RX_ENDP, USB_EP_STAT_RX_NAK); - ep_rx_size = usb_get_ep_rx_count(USB_CDCACM_RX_ENDP); - /* This copy won't overwrite unread bytes, since we've set the RX - * endpoint to NAK, and will only set it to VALID when all bytes - * have been read. */ - usb_copy_from_pma((uint8*)ep_rx_data, ep_rx_size, - USB_CDCACM_RX_ADDR); - - for (i = 0; i < ep_rx_size; i++) { - vcomBufferRx[tail] = ep_rx_data[i]; - tail = (tail + 1) % CDC_SERIAL_BUFFER_SIZE; - } - - n_unread_bytes += ep_rx_size; - - if (n_unread_bytes <= (CDC_SERIAL_BUFFER_SIZE - USB_CDCACM_RX_EPSIZE)) { - usb_set_ep_rx_count(USB_CDCACM_RX_ENDP, USB_CDCACM_RX_EPSIZE); - usb_set_ep_rx_stat(USB_CDCACM_RX_ENDP, USB_EP_STAT_RX_VALID); - } - - if (rx_hook) { - rx_hook(USB_CDCACM_HOOK_RX, 0); - } -} - -static uint8* vcomGetSetLineCoding(uint16 length) { - if (length == 0) { - pInformation->Ctrl_Info.Usb_wLength = sizeof(struct usb_cdcacm_line_coding); - } - return (uint8*)&line_coding; -} - -static void usbInit(void) { - pInformation->Current_Configuration = 0; - - USB_BASE->CNTR = USB_CNTR_FRES; - - USBLIB->irq_mask = 0; - USB_BASE->CNTR = USBLIB->irq_mask; - USB_BASE->ISTR = 0; - USBLIB->irq_mask = USB_CNTR_RESETM | USB_CNTR_SUSPM | USB_CNTR_WKUPM; - USB_BASE->CNTR = USBLIB->irq_mask; - - USB_BASE->ISTR = 0; - USBLIB->irq_mask = USB_ISR_MSK; - USB_BASE->CNTR = USBLIB->irq_mask; - - nvic_irq_enable(NVIC_USB_LP_CAN_RX0); - USBLIB->state = USB_UNCONNECTED; -} - -#define BTABLE_ADDRESS 0x00 -static void usbReset(void) { - pInformation->Current_Configuration = 0; - - /* current feature is current bmAttributes */ - pInformation->Current_Feature = (USB_CONFIG_ATTR_BUSPOWERED | - USB_CONFIG_ATTR_SELF_POWERED); - - USB_BASE->BTABLE = BTABLE_ADDRESS; - - /* setup control endpoint 0 */ - usb_set_ep_type(USB_EP0, USB_EP_EP_TYPE_CONTROL); - usb_set_ep_tx_stat(USB_EP0, USB_EP_STAT_TX_STALL); - usb_set_ep_rx_addr(USB_EP0, USB_CDCACM_CTRL_RX_ADDR); - usb_set_ep_tx_addr(USB_EP0, USB_CDCACM_CTRL_TX_ADDR); - usb_clear_status_out(USB_EP0); - - usb_set_ep_rx_count(USB_EP0, pProperty->MaxPacketSize); - usb_set_ep_rx_stat(USB_EP0, USB_EP_STAT_RX_VALID); - - /* setup management endpoint 1 */ - usb_set_ep_type(USB_CDCACM_MANAGEMENT_ENDP, USB_EP_EP_TYPE_INTERRUPT); - usb_set_ep_tx_addr(USB_CDCACM_MANAGEMENT_ENDP, - USB_CDCACM_MANAGEMENT_ADDR); - usb_set_ep_tx_stat(USB_CDCACM_MANAGEMENT_ENDP, USB_EP_STAT_TX_NAK); - usb_set_ep_rx_stat(USB_CDCACM_MANAGEMENT_ENDP, USB_EP_STAT_RX_DISABLED); - - /* TODO figure out differences in style between RX/TX EP setup */ - - /* set up data endpoint OUT (RX) */ - usb_set_ep_type(USB_CDCACM_RX_ENDP, USB_EP_EP_TYPE_BULK); - usb_set_ep_rx_addr(USB_CDCACM_RX_ENDP, USB_CDCACM_RX_ADDR); - usb_set_ep_rx_count(USB_CDCACM_RX_ENDP, USB_CDCACM_RX_EPSIZE); - usb_set_ep_rx_stat(USB_CDCACM_RX_ENDP, USB_EP_STAT_RX_VALID); - - /* set up data endpoint IN (TX) */ - usb_set_ep_type(USB_CDCACM_TX_ENDP, USB_EP_EP_TYPE_BULK); - usb_set_ep_tx_addr(USB_CDCACM_TX_ENDP, USB_CDCACM_TX_ADDR); - usb_set_ep_tx_stat(USB_CDCACM_TX_ENDP, USB_EP_STAT_TX_NAK); - usb_set_ep_rx_stat(USB_CDCACM_TX_ENDP, USB_EP_STAT_RX_DISABLED); - - USBLIB->state = USB_ATTACHED; - SetDeviceAddress(0); - - /* Reset the RX/TX state */ - n_unread_bytes = 0; - n_unsent_bytes = 0; - rx_offset = 0; - transmitting = 0; -} - -static RESULT usbDataSetup(uint8 request) { - uint8* (*CopyRoutine)(uint16) = 0; - - if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) { - switch (request) { - case USB_CDCACM_GET_LINE_CODING: - CopyRoutine = vcomGetSetLineCoding; - break; - case USB_CDCACM_SET_LINE_CODING: - CopyRoutine = vcomGetSetLineCoding; - break; - default: - break; - } - - /* Call the user hook. */ - if (iface_setup_hook) { - uint8 req_copy = request; - iface_setup_hook(USB_CDCACM_HOOK_IFACE_SETUP, &req_copy); - } - } - - if (CopyRoutine == NULL) { - return USB_UNSUPPORT; - } - - pInformation->Ctrl_Info.CopyData = CopyRoutine; - pInformation->Ctrl_Info.Usb_wOffset = 0; - (*CopyRoutine)(0); - return USB_SUCCESS; -} - -static RESULT usbNoDataSetup(uint8 request) { - RESULT ret = USB_UNSUPPORT; - - if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) { - switch (request) { - case USB_CDCACM_SET_COMM_FEATURE: - /* We support set comm. feature, but don't handle it. */ - ret = USB_SUCCESS; - break; - case USB_CDCACM_SET_CONTROL_LINE_STATE: - /* Track changes to DTR and RTS. */ - line_dtr_rts = (pInformation->USBwValues.bw.bb0 & - (USB_CDCACM_CONTROL_LINE_DTR | - USB_CDCACM_CONTROL_LINE_RTS)); - ret = USB_SUCCESS; - break; - } - - /* Call the user hook. */ - if (iface_setup_hook) { - uint8 req_copy = request; - iface_setup_hook(USB_CDCACM_HOOK_IFACE_SETUP, &req_copy); - } - } - return ret; -} - -static RESULT usbGetInterfaceSetting(uint8 interface, uint8 alt_setting) { - if (alt_setting > 0) { - return USB_UNSUPPORT; - } else if (interface > 1) { - return USB_UNSUPPORT; - } - - return USB_SUCCESS; -} - -static uint8* usbGetDeviceDescriptor(uint16 length) { - return Standard_GetDescriptorData(length, &Device_Descriptor); -} - -static uint8* usbGetConfigDescriptor(uint16 length) { - return Standard_GetDescriptorData(length, &Config_Descriptor); -} - -static uint8* usbGetStringDescriptor(uint16 length) { - uint8 wValue0 = pInformation->USBwValue0; - - if (wValue0 > N_STRING_DESCRIPTORS) { - return NULL; - } - return Standard_GetDescriptorData(length, &String_Descriptor[wValue0]); -} - -static void usbSetConfiguration(void) { - if (pInformation->Current_Configuration != 0) { - USBLIB->state = USB_CONFIGURED; - } -} - -static void usbSetDeviceAddress(void) { - USBLIB->state = USB_ADDRESSED; -} diff --git a/GD32F1/cores/maple/libmaple/usb/stm32f1/usb_reg_map.c b/GD32F1/cores/maple/libmaple/usb/stm32f1/usb_reg_map.c deleted file mode 100644 index ea60cb3..0000000 --- a/GD32F1/cores/maple/libmaple/usb/stm32f1/usb_reg_map.c +++ /dev/null @@ -1,88 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#include "usb_reg_map.h" - -/* TODO these could use some improvement; they're fairly - * straightforward ports of the analogous ST code. The PMA blit - * routines in particular are obvious targets for performance - * measurement and tuning. */ - -void usb_copy_to_pma(const uint8 *buf, uint16 len, uint16 pma_offset) { - uint16 *dst = (uint16*)usb_pma_ptr(pma_offset); - uint16 n = len >> 1; - uint16 i; - for (i = 0; i < n; i++) { - *dst = (uint16)(*buf) | *(buf + 1) << 8; - buf += 2; - dst += 2; - } - if (len & 1) { - *dst = *buf; - } -} - -void usb_copy_from_pma(uint8 *buf, uint16 len, uint16 pma_offset) { - uint32 *src = (uint32*)usb_pma_ptr(pma_offset); - uint16 *dst = (uint16*)buf; - uint16 n = len >> 1; - uint16 i; - for (i = 0; i < n; i++) { - *dst++ = *src++; - } - if (len & 1) { - *dst = *src & 0xFF; - } -} - -static void usb_set_ep_rx_count_common(uint32 *rxc, uint16 count) { - uint16 nblocks; - if (count > 62) { - /* use 32-byte memory block size */ - nblocks = count >> 5; - if ((count & 0x1F) == 0) { - nblocks--; - } - *rxc = (nblocks << 10) | 0x8000; - } else { - /* use 2-byte memory block size */ - nblocks = count >> 1; - if ((count & 0x1) != 0) { - nblocks++; - } - *rxc = nblocks << 10; - } -} - -void usb_set_ep_rx_buf0_count(uint8 ep, uint16 count) { - uint32 *rxc = usb_ep_rx_buf0_count_ptr(ep); - usb_set_ep_rx_count_common(rxc, count); -} - -void usb_set_ep_rx_count(uint8 ep, uint16 count) { - uint32 *rxc = usb_ep_rx_count_ptr(ep); - usb_set_ep_rx_count_common(rxc, count); -} diff --git a/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_core.c b/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_core.c deleted file mode 100644 index 5cf9e87..0000000 --- a/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_core.c +++ /dev/null @@ -1,1013 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_core.c -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Standard protocol processing (USB v2.0) -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Includes ------------------------------------------------------------------*/ -#include "usb_lib.h" -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -#define ValBit(VAR,Place) (VAR & (1 << Place)) -#define SetBit(VAR,Place) (VAR |= (1 << Place)) -#define ClrBit(VAR,Place) (VAR &= ((1 << Place) ^ 255)) - -#define Send0LengthData() { _SetEPTxCount(ENDP0, 0); \ - vSetEPTxStatus(EP_TX_VALID); \ - } - -#define vSetEPRxStatus(st) (SaveRState = st) -#define vSetEPTxStatus(st) (SaveTState = st) - -#define USB_StatusIn() Send0LengthData() -#define USB_StatusOut() vSetEPRxStatus(EP_RX_VALID) - -#define StatusInfo0 StatusInfo.bw.bb1 /* Reverse bb0 & bb1 */ -#define StatusInfo1 StatusInfo.bw.bb0 - -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -u16_u8 StatusInfo; -USB_Bool Data_Mul_MaxPacketSize = FALSE; -/* Private function prototypes -----------------------------------------------*/ -static void DataStageOut(void); -static void DataStageIn(void); -static void NoData_Setup0(void); -static void Data_Setup0(void); -/* Private functions ---------------------------------------------------------*/ - -/******************************************************************************* -* Function Name : Standard_GetConfiguration. -* Description : Return the current configuration variable address. -* Input : Length - How many bytes are needed. -* Output : None. -* Return : Return 1 , if the request is invalid when "Length" is 0. -* Return "Buffer" if the "Length" is not 0. -*******************************************************************************/ -u8 *Standard_GetConfiguration(u16 Length) -{ - if (Length == 0) - { - pInformation->Ctrl_Info.Usb_wLength = - sizeof(pInformation->Current_Configuration); - return 0; - } - pUser_Standard_Requests->User_GetConfiguration(); - return (u8 *)&pInformation->Current_Configuration; -} - -/******************************************************************************* -* Function Name : Standard_SetConfiguration. -* Description : This routine is called to set the configuration value -* Then each class should configure device themself. -* Input : None. -* Output : None. -* Return : Return USB_SUCCESS, if the request is performed. -* Return USB_UNSUPPORT, if the request is invalid. -*******************************************************************************/ -RESULT Standard_SetConfiguration(void) -{ - - if ((pInformation->USBwValue0 <= - Device_Table.Total_Configuration) && (pInformation->USBwValue1 == 0) - && (pInformation->USBwIndex == 0)) /*call Back usb spec 2.0*/ - { - pInformation->Current_Configuration = pInformation->USBwValue0; - pUser_Standard_Requests->User_SetConfiguration(); - return USB_SUCCESS; - } - else - { - return USB_UNSUPPORT; - } -} - -/******************************************************************************* -* Function Name : Standard_GetInterface. -* Description : Return the Alternate Setting of the current interface. -* Input : Length - How many bytes are needed. -* Output : None. -* Return : Return 0, if the request is invalid when "Length" is 0. -* Return "Buffer" if the "Length" is not 0. -*******************************************************************************/ -u8 *Standard_GetInterface(u16 Length) -{ - if (Length == 0) - { - pInformation->Ctrl_Info.Usb_wLength = - sizeof(pInformation->Current_AlternateSetting); - return 0; - } - pUser_Standard_Requests->User_GetInterface(); - return (u8 *)&pInformation->Current_AlternateSetting; -} - -/******************************************************************************* -* Function Name : Standard_SetInterface. -* Description : This routine is called to set the interface. -* Then each class should configure the interface them self. -* Input : None. -* Output : None. -* Return : - Return USB_SUCCESS, if the request is performed. -* - Return USB_UNSUPPORT, if the request is invalid. -*******************************************************************************/ -RESULT Standard_SetInterface(void) -{ - RESULT Re; - /*Test if the specified Interface and Alternate Setting are supported by - the application Firmware*/ - Re = (*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, pInformation->USBwValue0); - - if (pInformation->Current_Configuration != 0) - { - if ((Re != USB_SUCCESS) || (pInformation->USBwIndex1 != 0) - || (pInformation->USBwValue1 != 0)) - { - return USB_UNSUPPORT; - } - else if (Re == USB_SUCCESS) - { - pUser_Standard_Requests->User_SetInterface(); - pInformation->Current_Interface = pInformation->USBwIndex0; - pInformation->Current_AlternateSetting = pInformation->USBwValue0; - return USB_SUCCESS; - } - - } - - return USB_UNSUPPORT; -} - -/******************************************************************************* -* Function Name : Standard_GetStatus. -* Description : Copy the device request data to "StatusInfo buffer". -* Input : - Length - How many bytes are needed. -* Output : None. -* Return : Return 0, if the request is at end of data block, -* or is invalid when "Length" is 0. -*******************************************************************************/ -u8 *Standard_GetStatus(u16 Length) -{ - if (Length == 0) - { - pInformation->Ctrl_Info.Usb_wLength = 2; - return 0; - } - - StatusInfo.w = 0; - /* Reset Status Information */ - - if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) - { - /*Get Device Status */ - u8 Feature = pInformation->Current_Feature; - - /* Remote Wakeup enabled */ - if (ValBit(Feature, 5)) - { - SetBit(StatusInfo0, 1); - } - - /* Bus-powered */ - if (ValBit(Feature, 6)) - { - ClrBit(StatusInfo0, 0); - } - else /* Self-powered */ - { - SetBit(StatusInfo0, 0); - } - } - /*Interface Status*/ - else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) - { - return (u8 *)&StatusInfo; - } - /*Get EndPoint Status*/ - else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) - { - u8 Related_Endpoint; - u8 wIndex0 = pInformation->USBwIndex0; - - Related_Endpoint = (wIndex0 & 0x0f); - if (ValBit(wIndex0, 7)) - { - /* IN endpoint */ - if (_GetTxStallStatus(Related_Endpoint)) - { - SetBit(StatusInfo0, 0); /* IN Endpoint stalled */ - } - } - else - { - /* OUT endpoint */ - if (_GetRxStallStatus(Related_Endpoint)) - { - SetBit(StatusInfo0, 0); /* OUT Endpoint stalled */ - } - } - - } - else - { - return NULL; - } - pUser_Standard_Requests->User_GetStatus(); - return (u8 *)&StatusInfo; -} - -/******************************************************************************* -* Function Name : Standard_ClearFeature. -* Description : Clear or disable a specific feature. -* Input : None. -* Output : None. -* Return : - Return USB_SUCCESS, if the request is performed. -* - Return USB_UNSUPPORT, if the request is invalid. -*******************************************************************************/ -RESULT Standard_ClearFeature(void) -{ - u32 Type_Rec = Type_Recipient; - u32 Status; - - - if (Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT)) - {/*Device Clear Feature*/ - ClrBit(pInformation->Current_Feature, 5); - return USB_SUCCESS; - } - else if (Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) - {/*EndPoint Clear Feature*/ - DEVICE* pDev; - u32 Related_Endpoint; - u32 wIndex0; - u32 rEP; - - if ((pInformation->USBwValue != ENDPOINT_STALL) - || (pInformation->USBwIndex1 != 0)) - { - return USB_UNSUPPORT; - } - - pDev = &Device_Table; - wIndex0 = pInformation->USBwIndex0; - rEP = wIndex0 & ~0x80; - Related_Endpoint = ENDP0 + rEP; - - if (ValBit(pInformation->USBwIndex0, 7)) - { - /*Get Status of endpoint & stall the request if the related_ENdpoint - is Disabled*/ - Status = _GetEPTxStatus(Related_Endpoint); - } - else - { - Status = _GetEPRxStatus(Related_Endpoint); - } - - if ((rEP >= pDev->Total_Endpoint) || (Status == 0) - || (pInformation->Current_Configuration == 0)) - { - return USB_UNSUPPORT; - } - - - if (wIndex0 & 0x80) - { - /* IN endpoint */ - if (_GetTxStallStatus(Related_Endpoint )) - { - ClearDTOG_TX(Related_Endpoint); - SetEPTxStatus(Related_Endpoint, EP_TX_VALID); - } - } - else - { - /* OUT endpoint */ - if (_GetRxStallStatus(Related_Endpoint)) - { - if (Related_Endpoint == ENDP0) - { - /* After clear the STALL, enable the default endpoint receiver */ - SetEPRxCount(Related_Endpoint, Device_Property.MaxPacketSize); - _SetEPRxStatus(Related_Endpoint, EP_RX_VALID); - } - else - { - ClearDTOG_RX(Related_Endpoint); - _SetEPRxStatus(Related_Endpoint, EP_RX_VALID); - } - } - } - pUser_Standard_Requests->User_ClearFeature(); - return USB_SUCCESS; - } - - return USB_UNSUPPORT; -} - -/******************************************************************************* -* Function Name : Standard_SetEndPointFeature -* Description : Set or enable a specific feature of EndPoint -* Input : None. -* Output : None. -* Return : - Return USB_SUCCESS, if the request is performed. -* - Return USB_UNSUPPORT, if the request is invalid. -*******************************************************************************/ -RESULT Standard_SetEndPointFeature(void) -{ - u32 wIndex0; - u32 Related_Endpoint; - u32 rEP; - u32 Status; - - wIndex0 = pInformation->USBwIndex0; - rEP = wIndex0 & ~0x80; - Related_Endpoint = ENDP0 + rEP; - - if (ValBit(pInformation->USBwIndex0, 7)) - { - /* get Status of endpoint & stall the request if the related_ENdpoint - is Disabled*/ - Status = _GetEPTxStatus(Related_Endpoint); - } - else - { - Status = _GetEPRxStatus(Related_Endpoint); - } - - if (Related_Endpoint >= Device_Table.Total_Endpoint - || pInformation->USBwValue != 0 || Status == 0 - || pInformation->Current_Configuration == 0) - { - return USB_UNSUPPORT; - } - else - { - if (wIndex0 & 0x80) - { - /* IN endpoint */ - _SetEPTxStatus(Related_Endpoint, EP_TX_STALL); - } - - else - { - /* OUT endpoint */ - _SetEPRxStatus(Related_Endpoint, EP_RX_STALL); - } - } - pUser_Standard_Requests->User_SetEndPointFeature(); - return USB_SUCCESS; -} - -/******************************************************************************* -* Function Name : Standard_SetDeviceFeature. -* Description : Set or enable a specific feature of Device. -* Input : None. -* Output : None. -* Return : - Return USB_SUCCESS, if the request is performed. -* - Return USB_UNSUPPORT, if the request is invalid. -*******************************************************************************/ -RESULT Standard_SetDeviceFeature(void) -{ - SetBit(pInformation->Current_Feature, 5); - pUser_Standard_Requests->User_SetDeviceFeature(); - return USB_SUCCESS; -} - -/******************************************************************************* -* Function Name : Standard_GetDescriptorData. -* Description : Standard_GetDescriptorData is used for descriptors transfer. -* : This routine is used for the descriptors resident in Flash -* or RAM -* pDesc can be in either Flash or RAM -* The purpose of this routine is to have a versatile way to -* response descriptors request. It allows user to generate -* certain descriptors with software or read descriptors from -* external storage part by part. -* Input : - Length - Length of the data in this transfer. -* - pDesc - A pointer points to descriptor struct. -* The structure gives the initial address of the descriptor and -* its original size. -* Output : None. -* Return : Address of a part of the descriptor pointed by the Usb_ -* wOffset The buffer pointed by this address contains at least -* Length bytes. -*******************************************************************************/ -u8 *Standard_GetDescriptorData(u16 Length, ONE_DESCRIPTOR *pDesc) -{ - u32 wOffset; - - wOffset = pInformation->Ctrl_Info.Usb_wOffset; - if (Length == 0) - { - pInformation->Ctrl_Info.Usb_wLength = pDesc->Descriptor_Size - wOffset; - return 0; - } - - return pDesc->Descriptor + wOffset; -} - -/******************************************************************************* -* Function Name : DataStageOut. -* Description : Data stage of a Control Write Transfer. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -void DataStageOut(void) -{ - ENDPOINT_INFO *pEPinfo = &pInformation->Ctrl_Info; - u32 save_rLength; - - save_rLength = pEPinfo->Usb_rLength; - - if (pEPinfo->CopyData && save_rLength) - { - u8 *Buffer; - u32 Length; - - Length = pEPinfo->PacketSize; - if (Length > save_rLength) - { - Length = save_rLength; - } - - Buffer = (*pEPinfo->CopyData)(Length); - pEPinfo->Usb_rLength -= Length; - pEPinfo->Usb_rOffset += Length; - - PMAToUserBufferCopy(Buffer, GetEPRxAddr(ENDP0), Length); - } - - if (pEPinfo->Usb_rLength != 0) - { - vSetEPRxStatus(EP_RX_VALID);/* re-enable for next data reception */ - SetEPTxCount(ENDP0, 0); - vSetEPTxStatus(EP_TX_VALID);/* Expect the host to abort the data OUT stage */ - } - /* Set the next State*/ - if (pEPinfo->Usb_rLength >= pEPinfo->PacketSize) - { - pInformation->ControlState = OUT_DATA; - } - else - { - if (pEPinfo->Usb_rLength > 0) - { - pInformation->ControlState = LAST_OUT_DATA; - } - else if (pEPinfo->Usb_rLength == 0) - { - pInformation->ControlState = WAIT_STATUS_IN; - USB_StatusIn(); - } - } -} - -/******************************************************************************* -* Function Name : DataStageIn. -* Description : Data stage of a Control Read Transfer. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -void DataStageIn(void) -{ - ENDPOINT_INFO *pEPinfo = &pInformation->Ctrl_Info; - u32 save_wLength = pEPinfo->Usb_wLength; - u32 ControlState = pInformation->ControlState; - - u8 *DataBuffer; - u32 Length; - - if ((save_wLength == 0) && (ControlState == LAST_IN_DATA)) - { - if(Data_Mul_MaxPacketSize == TRUE) - { - /* No more data to send and empty packet */ - Send0LengthData(); - ControlState = LAST_IN_DATA; - Data_Mul_MaxPacketSize = FALSE; - } - else - { - /* No more data to send so STALL the TX Status*/ - ControlState = WAIT_STATUS_OUT; - vSetEPTxStatus(EP_TX_STALL); - } - - goto Expect_Status_Out; - } - - Length = pEPinfo->PacketSize; - ControlState = (save_wLength <= Length) ? LAST_IN_DATA : IN_DATA; - - if (Length > save_wLength) - { - Length = save_wLength; - } - - DataBuffer = (*pEPinfo->CopyData)(Length); - - UserToPMABufferCopy(DataBuffer, GetEPTxAddr(ENDP0), Length); - - SetEPTxCount(ENDP0, Length); - - pEPinfo->Usb_wLength -= Length; - pEPinfo->Usb_wOffset += Length; - vSetEPTxStatus(EP_TX_VALID); - - USB_StatusOut();/* Expect the host to abort the data IN stage */ - -Expect_Status_Out: - pInformation->ControlState = ControlState; -} - -/******************************************************************************* -* Function Name : NoData_Setup0. -* Description : Proceed the processing of setup request without data stage. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -void NoData_Setup0(void) -{ - RESULT Result = USB_UNSUPPORT; - u32 RequestNo = pInformation->USBbRequest; - u32 ControlState; - - if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) - { - /* Device Request*/ - /* SET_CONFIGURATION*/ - if (RequestNo == SET_CONFIGURATION) - { - Result = Standard_SetConfiguration(); - } - - /*SET ADDRESS*/ - else if (RequestNo == SET_ADDRESS) - { - if ((pInformation->USBwValue0 > 127) || (pInformation->USBwValue1 != 0) - || (pInformation->USBwIndex != 0) - || (pInformation->Current_Configuration != 0)) - /* Device Address should be 127 or less*/ - { - ControlState = STALLED; - goto exit_NoData_Setup0; - } - else - { - Result = USB_SUCCESS; - } - } - /*SET FEATURE for Device*/ - else if (RequestNo == SET_FEATURE) - { - if ((pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP) - && (pInformation->USBwIndex == 0) - && (ValBit(pInformation->Current_Feature, 5))) - { - Result = Standard_SetDeviceFeature(); - } - else - { - Result = USB_UNSUPPORT; - } - } - /*Clear FEATURE for Device */ - else if (RequestNo == CLEAR_FEATURE) - { - if (pInformation->USBwValue0 == DEVICE_REMOTE_WAKEUP - && pInformation->USBwIndex == 0 - && ValBit(pInformation->Current_Feature, 5)) - { - Result = Standard_ClearFeature(); - } - else - { - Result = USB_UNSUPPORT; - } - } - - } - - /* Interface Request*/ - else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) - { - /*SET INTERFACE*/ - if (RequestNo == SET_INTERFACE) - { - Result = Standard_SetInterface(); - } - } - - /* EndPoint Request*/ - else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) - { - /*CLEAR FEATURE for EndPoint*/ - if (RequestNo == CLEAR_FEATURE) - { - Result = Standard_ClearFeature(); - } - /* SET FEATURE for EndPoint*/ - else if (RequestNo == SET_FEATURE) - { - Result = Standard_SetEndPointFeature(); - } - } - else - { - Result = USB_UNSUPPORT; - } - - - if (Result != USB_SUCCESS) - { - Result = (*pProperty->Class_NoData_Setup)(RequestNo); - if (Result == USB_NOT_READY) - { - ControlState = PAUSE; - goto exit_NoData_Setup0; - } - } - - if (Result != USB_SUCCESS) - { - ControlState = STALLED; - goto exit_NoData_Setup0; - } - - ControlState = WAIT_STATUS_IN;/* After no data stage SETUP */ - - USB_StatusIn(); - -exit_NoData_Setup0: - pInformation->ControlState = ControlState; - return; -} - -/******************************************************************************* -* Function Name : Data_Setup0. -* Description : Proceed the processing of setup request with data stage. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -void Data_Setup0(void) -{ - u8 *(*CopyRoutine)(u16); - RESULT Result; - u32 Request_No = pInformation->USBbRequest; - - u32 Related_Endpoint, Reserved; - u32 wOffset, Status; - - - - CopyRoutine = NULL; - wOffset = 0; - - if (Request_No == GET_DESCRIPTOR) - { - if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) - { - u8 wValue1 = pInformation->USBwValue1; - if (wValue1 == DEVICE_DESCRIPTOR) - { - CopyRoutine = pProperty->GetDeviceDescriptor; - } - else if (wValue1 == CONFIG_DESCRIPTOR) - { - CopyRoutine = pProperty->GetConfigDescriptor; - } - else if (wValue1 == STRING_DESCRIPTOR) - { - CopyRoutine = pProperty->GetStringDescriptor; - } /* End of GET_DESCRIPTOR */ - } - } - - /*GET STATUS*/ - else if ((Request_No == GET_STATUS) && (pInformation->USBwValue == 0) - && (pInformation->USBwLength == 0x0002) - && (pInformation->USBwIndex1 == 0)) - { - /* GET STATUS for Device*/ - if ((Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) - && (pInformation->USBwIndex == 0)) - { - CopyRoutine = Standard_GetStatus; - } - - /* GET STATUS for Interface*/ - else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) - { - if (((*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, 0) == USB_SUCCESS) - && (pInformation->Current_Configuration != 0)) - { - CopyRoutine = Standard_GetStatus; - } - } - - /* GET STATUS for EndPoint*/ - else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) - { - Related_Endpoint = (pInformation->USBwIndex0 & 0x0f); - Reserved = pInformation->USBwIndex0 & 0x70; - - if (ValBit(pInformation->USBwIndex0, 7)) - { - /*Get Status of endpoint & stall the request if the related_ENdpoint - is Disabled*/ - Status = _GetEPTxStatus(Related_Endpoint); - } - else - { - Status = _GetEPRxStatus(Related_Endpoint); - } - - if ((Related_Endpoint < Device_Table.Total_Endpoint) && (Reserved == 0) - && (Status != 0)) - { - CopyRoutine = Standard_GetStatus; - } - } - - } - - /*GET CONFIGURATION*/ - else if (Request_No == GET_CONFIGURATION) - { - if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT)) - { - CopyRoutine = Standard_GetConfiguration; - } - } - /*GET INTERFACE*/ - else if (Request_No == GET_INTERFACE) - { - if ((Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) - && (pInformation->Current_Configuration != 0) && (pInformation->USBwValue == 0) - && (pInformation->USBwIndex1 == 0) && (pInformation->USBwLength == 0x0001) - && ((*pProperty->Class_Get_Interface_Setting)(pInformation->USBwIndex0, 0) == USB_SUCCESS)) - { - CopyRoutine = Standard_GetInterface; - } - - } - - if (CopyRoutine) - { - pInformation->Ctrl_Info.Usb_wOffset = wOffset; - pInformation->Ctrl_Info.CopyData = CopyRoutine; - /* sb in the original the cast to word was directly */ - /* now the cast is made step by step */ - (*CopyRoutine)(0); - Result = USB_SUCCESS; - } - else - { - Result = (*pProperty->Class_Data_Setup)(pInformation->USBbRequest); - if (Result == USB_NOT_READY) - { - pInformation->ControlState = PAUSE; - return; - } - } - - if (pInformation->Ctrl_Info.Usb_wLength == 0xFFFF) - { - /* Data is not ready, wait it */ - pInformation->ControlState = PAUSE; - return; - } - if ((Result == USB_UNSUPPORT) || (pInformation->Ctrl_Info.Usb_wLength == 0)) - { - /* Unsupported request */ - pInformation->ControlState = STALLED; - return; - } - - - if (ValBit(pInformation->USBbmRequestType, 7)) - { - /* Device ==> Host */ - vu32 wLength = pInformation->USBwLength; - - /* Restrict the data length to be the one host asks */ - if (pInformation->Ctrl_Info.Usb_wLength > wLength) - { - pInformation->Ctrl_Info.Usb_wLength = wLength; - } - - else if (pInformation->Ctrl_Info.Usb_wLength < pInformation->USBwLength) - { - if (pInformation->Ctrl_Info.Usb_wLength < pProperty->MaxPacketSize) - { - Data_Mul_MaxPacketSize = FALSE; - } - else if ((pInformation->Ctrl_Info.Usb_wLength % pProperty->MaxPacketSize) == 0) - { - Data_Mul_MaxPacketSize = TRUE; - } - } - - pInformation->Ctrl_Info.PacketSize = pProperty->MaxPacketSize; - DataStageIn(); - } - else - { - pInformation->ControlState = OUT_DATA; - vSetEPRxStatus(EP_RX_VALID); /* enable for next data reception */ - } - - return; -} - -/******************************************************************************* -* Function Name : Setup0_Process -* Description : Get the device request data and dispatch to individual process. -* Input : None. -* Output : None. -* Return : Post0_Process. -*******************************************************************************/ -u8 Setup0_Process(void) -{ - - union - { - u8* b; - u16* w; - } pBuf; - - pBuf.b = PMAAddr + (u8 *)(_GetEPRxAddr(ENDP0) * 2); /* *2 for 32 bits addr */ - - if (pInformation->ControlState != PAUSE) - { - pInformation->USBbmRequestType = *pBuf.b++; /* bmRequestType */ - pInformation->USBbRequest = *pBuf.b++; /* bRequest */ - pBuf.w++; /* word not accessed because of 32 bits addressing */ - pInformation->USBwValue = ByteSwap(*pBuf.w++); /* wValue */ - pBuf.w++; /* word not accessed because of 32 bits addressing */ - pInformation->USBwIndex = ByteSwap(*pBuf.w++); /* wIndex */ - pBuf.w++; /* word not accessed because of 32 bits addressing */ - pInformation->USBwLength = *pBuf.w; /* wLength */ - } - - pInformation->ControlState = SETTING_UP; - if (pInformation->USBwLength == 0) - { - /* Setup with no data stage */ - NoData_Setup0(); - } - else - { - /* Setup with data stage */ - Data_Setup0(); - } - return Post0_Process(); -} - -/******************************************************************************* -* Function Name : In0_Process -* Description : Process the IN token on all default endpoint. -* Input : None. -* Output : None. -* Return : Post0_Process. -*******************************************************************************/ -u8 In0_Process(void) -{ - u32 ControlState = pInformation->ControlState; - - if ((ControlState == IN_DATA) || (ControlState == LAST_IN_DATA)) - { - DataStageIn(); - /* ControlState may be changed outside the function */ - ControlState = pInformation->ControlState; - } - - else if (ControlState == WAIT_STATUS_IN) - { - if ((pInformation->USBbRequest == SET_ADDRESS) && - (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))) - { - SetDeviceAddress(pInformation->USBwValue0); - pUser_Standard_Requests->User_SetDeviceAddress(); - } - (*pProperty->Process_Status_IN)(); - ControlState = STALLED; - } - - else - { - ControlState = STALLED; - } - - pInformation->ControlState = ControlState; - - return Post0_Process(); -} - -/******************************************************************************* -* Function Name : Out0_Process -* Description : Process the OUT token on all default endpoint. -* Input : None. -* Output : None. -* Return : Post0_Process. -*******************************************************************************/ -u8 Out0_Process(void) -{ - u32 ControlState = pInformation->ControlState; - - if ((ControlState == OUT_DATA) || (ControlState == LAST_OUT_DATA)) - { - DataStageOut(); - ControlState = pInformation->ControlState; /* may be changed outside the function */ - } - - else if (ControlState == WAIT_STATUS_OUT) - { - (*pProperty->Process_Status_OUT)(); - ControlState = STALLED; - } - - else if ((ControlState == IN_DATA) || (ControlState == LAST_IN_DATA)) - { - /* host aborts the transfer before finish */ - ControlState = STALLED; - } - - /* Unexpect state, STALL the endpoint */ - else - { - ControlState = STALLED; - } - - pInformation->ControlState = ControlState; - - return Post0_Process(); -} - -/******************************************************************************* -* Function Name : Post0_Process -* Description : Stall the Endpoint 0 in case of error. -* Input : None. -* Output : None. -* Return : - 0 if the control State is in PAUSE -* - 1 if not. -*******************************************************************************/ -u8 Post0_Process(void) -{ - SetEPRxCount(ENDP0, Device_Property.MaxPacketSize); - - if (pInformation->ControlState == STALLED) - { - vSetEPRxStatus(EP_RX_STALL); - vSetEPTxStatus(EP_TX_STALL); - } - - return (pInformation->ControlState == PAUSE); -} - -/******************************************************************************* -* Function Name : SetDeviceAddress. -* Description : Set the device and all the used Endpoints addresses. -* Input : - Val: device adress. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetDeviceAddress(u8 Val) -{ - u32 i; - u32 nEP = Device_Table.Total_Endpoint; - - /* set address in every used endpoint */ - for (i = 0; i < nEP; i++) - { - _SetEPAddress((u8)i, (u8)i); - } /* for */ - _SetDADDR(Val | DADDR_EF); /* set device address and enable function */ -} - -/******************************************************************************* -* Function Name : NOP_Process -* Description : No operation function. -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -void NOP_Process(void) -{ -} - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_init.c b/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_init.c deleted file mode 100644 index 94f3a83..0000000 --- a/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_init.c +++ /dev/null @@ -1,64 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_init.c -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Initialization routines & global variables -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Includes ------------------------------------------------------------------*/ -#include "usb_lib.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* The number of current endpoint, it will be used to specify an endpoint */ - u8 EPindex; -/* The number of current device, it is an index to the Device_Table */ -/* u8 Device_no; */ -/* Points to the DEVICE_INFO structure of current device */ -/* The purpose of this register is to speed up the execution */ -DEVICE_INFO *pInformation; -/* Points to the DEVICE_PROP structure of current device */ -/* The purpose of this register is to speed up the execution */ -DEVICE_PROP *pProperty; -/* Temporary save the state of Rx & Tx status. */ -/* Whenever the Rx or Tx state is changed, its value is saved */ -/* in this variable first and will be set to the EPRB or EPRA */ -/* at the end of interrupt process */ -u16 SaveState ; -u16 wInterrupt_Mask; -DEVICE_INFO Device_Info; -USER_STANDARD_REQUESTS *pUser_Standard_Requests; - -/* Extern variables ----------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ - -/******************************************************************************* -* Function Name : USB_Init -* Description : USB system initialization -* Input : None. -* Output : None. -* Return : None. -*******************************************************************************/ -void USB_Init(void) -{ - pInformation = &Device_Info; - pInformation->ControlState = 2; - pProperty = &Device_Property; - pUser_Standard_Requests = &User_Standard_Requests; - /* Initialize devices one by one */ - - pProperty->Init(); -} - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_mem.c b/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_mem.c deleted file mode 100644 index ad9740a..0000000 --- a/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_mem.c +++ /dev/null @@ -1,73 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_mem.c -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Utility functions for memory transfers to/from PMA -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Includes ------------------------------------------------------------------*/ -#include "usb_lib.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Extern variables ----------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ -/******************************************************************************* -* Function Name : UserToPMABufferCopy -* Description : Copy a buffer from user memory area to packet memory area (PMA) -* Input : - pbUsrBuf: pointer to user memory area. -* - wPMABufAddr: address into PMA. -* - wNBytes: no. of bytes to be copied. -* Output : None. -* Return : None . -*******************************************************************************/ -void UserToPMABufferCopy(const u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes) -{ - u32 n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */ - u32 i, temp1, temp2; - u16 *pdwVal; - pdwVal = (u16 *)(wPMABufAddr * 2 + PMAAddr); - for (i = n; i != 0; i--) - { - temp1 = (u16) * pbUsrBuf; - pbUsrBuf++; - temp2 = temp1 | (u16) * pbUsrBuf << 8; - *pdwVal++ = temp2; - pdwVal++; - pbUsrBuf++; - } -} -/******************************************************************************* -* Function Name : PMAToUserBufferCopy -* Description : Copy a buffer from user memory area to packet memory area (PMA) -* Input : - pbUsrBuf = pointer to user memory area. -* - wPMABufAddr = address into PMA. -* - wNBytes = no. of bytes to be copied. -* Output : None. -* Return : None. -*******************************************************************************/ -void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes) -{ - u32 n = (wNBytes + 1) >> 1;/* /2*/ - u32 i; - u32 *pdwVal; - pdwVal = (u32 *)(wPMABufAddr * 2 + PMAAddr); - for (i = n; i != 0; i--) - { - *(u16*)pbUsrBuf++ = *pdwVal++; - pbUsrBuf++; - } -} - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_regs.c b/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_regs.c deleted file mode 100644 index c7e0276..0000000 --- a/GD32F1/cores/maple/libmaple/usb/usb_lib/usb_regs.c +++ /dev/null @@ -1,748 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_regs.c -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Interface functions to USB cell registers -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Includes ------------------------------------------------------------------*/ -#include "usb_lib.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Extern variables ----------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ - -/******************************************************************************* -* Function Name : SetCNTR. -* Description : Set the CNTR register value. -* Input : wRegValue: new register value. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetCNTR(u16 wRegValue) -{ - _SetCNTR(wRegValue); -} - -/******************************************************************************* -* Function Name : GetCNTR. -* Description : returns the CNTR register value. -* Input : None. -* Output : None. -* Return : CNTR register Value. -*******************************************************************************/ -u16 GetCNTR(void) -{ - return(_GetCNTR()); -} - -/******************************************************************************* -* Function Name : SetISTR. -* Description : Set the ISTR register value. -* Input : wRegValue: new register value. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetISTR(u16 wRegValue) -{ - _SetISTR(wRegValue); -} - -/******************************************************************************* -* Function Name : GetISTR -* Description : Returns the ISTR register value. -* Input : None. -* Output : None. -* Return : ISTR register Value -*******************************************************************************/ -u16 GetISTR(void) -{ - return(_GetISTR()); -} - -/******************************************************************************* -* Function Name : GetFNR -* Description : Returns the FNR register value. -* Input : None. -* Output : None. -* Return : FNR register Value -*******************************************************************************/ -u16 GetFNR(void) -{ - return(_GetFNR()); -} - -/******************************************************************************* -* Function Name : SetDADDR -* Description : Set the DADDR register value. -* Input : wRegValue: new register value. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetDADDR(u16 wRegValue) -{ - _SetDADDR(wRegValue); -} - -/******************************************************************************* -* Function Name : GetDADDR -* Description : Returns the DADDR register value. -* Input : None. -* Output : None. -* Return : DADDR register Value -*******************************************************************************/ -u16 GetDADDR(void) -{ - return(_GetDADDR()); -} - -/******************************************************************************* -* Function Name : SetBTABLE -* Description : Set the BTABLE. -* Input : wRegValue: New register value. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetBTABLE(u16 wRegValue) -{ - _SetBTABLE(wRegValue); -} - -/******************************************************************************* -* Function Name : GetBTABLE. -* Description : Returns the BTABLE register value. -* Input : None. -* Output : None. -* Return : BTABLE address. -*******************************************************************************/ -u16 GetBTABLE(void) -{ - return(_GetBTABLE()); -} - -/******************************************************************************* -* Function Name : SetENDPOINT -* Description : Setthe Endpoint register value. -* Input : bEpNum: Endpoint Number. -* wRegValue. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetENDPOINT(u8 bEpNum, u16 wRegValue) -{ - _SetENDPOINT(bEpNum, wRegValue); -} - -/******************************************************************************* -* Function Name : GetENDPOINT -* Description : Return the Endpoint register value. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Endpoint register value. -*******************************************************************************/ -u16 GetENDPOINT(u8 bEpNum) -{ - return(_GetENDPOINT(bEpNum)); -} - -/******************************************************************************* -* Function Name : SetEPType -* Description : sets the type in the endpoint register. -* Input : bEpNum: Endpoint Number. -* wType: type definition. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPType(u8 bEpNum, u16 wType) -{ - _SetEPType(bEpNum, wType); -} - -/******************************************************************************* -* Function Name : GetEPType -* Description : Returns the endpoint type. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Endpoint Type -*******************************************************************************/ -u16 GetEPType(u8 bEpNum) -{ - return(_GetEPType(bEpNum)); -} - -/******************************************************************************* -* Function Name : SetEPTxStatus -* Description : Set the status of Tx endpoint. -* Input : bEpNum: Endpoint Number. -* wState: new state. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPTxStatus(u8 bEpNum, u16 wState) -{ - _SetEPTxStatus(bEpNum, wState); -} - -/******************************************************************************* -* Function Name : SetEPRxStatus -* Description : Set the status of Rx endpoint. -* Input : bEpNum: Endpoint Number. -* wState: new state. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPRxStatus(u8 bEpNum, u16 wState) -{ - _SetEPRxStatus(bEpNum, wState); -} - -/******************************************************************************* -* Function Name : SetDouBleBuffEPStall -* Description : sets the status for Double Buffer Endpoint to STALL -* Input : bEpNum: Endpoint Number. -* bDir: Endpoint direction. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetDouBleBuffEPStall(u8 bEpNum, u8 bDir) -{ - u16 Endpoint_DTOG_Status; - Endpoint_DTOG_Status = GetENDPOINT(bEpNum); - if (bDir == EP_DBUF_OUT) - { /* OUT double buffered endpoint */ - _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPRX_DTOG1); - } - else if (bDir == EP_DBUF_IN) - { /* IN double buffered endpoint */ - _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPTX_DTOG1); - } -} - -/******************************************************************************* -* Function Name : GetEPTxStatus -* Description : Returns the endpoint Tx status. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Endpoint TX Status -*******************************************************************************/ -u16 GetEPTxStatus(u8 bEpNum) -{ - return(_GetEPTxStatus(bEpNum)); -} - -/******************************************************************************* -* Function Name : GetEPRxStatus -* Description : Returns the endpoint Rx status. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Endpoint RX Status -*******************************************************************************/ -u16 GetEPRxStatus(u8 bEpNum) -{ - return(_GetEPRxStatus(bEpNum)); -} - -/******************************************************************************* -* Function Name : SetEPTxValid -* Description : Valid the endpoint Tx Status. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPTxValid(u8 bEpNum) -{ - _SetEPTxStatus(bEpNum, EP_TX_VALID); -} - -/******************************************************************************* -* Function Name : SetEPRxValid -* Description : Valid the endpoint Rx Status. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPRxValid(u8 bEpNum) -{ - _SetEPRxStatus(bEpNum, EP_RX_VALID); -} - -/******************************************************************************* -* Function Name : SetEP_KIND -* Description : Clear the EP_KIND bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEP_KIND(u8 bEpNum) -{ - _SetEP_KIND(bEpNum); -} - -/******************************************************************************* -* Function Name : ClearEP_KIND -* Description : set the EP_KIND bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void ClearEP_KIND(u8 bEpNum) -{ - _ClearEP_KIND(bEpNum); -} -/******************************************************************************* -* Function Name : Clear_Status_Out -* Description : Clear the Status Out of the related Endpoint -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void Clear_Status_Out(u8 bEpNum) -{ - _ClearEP_KIND(bEpNum); -} -/******************************************************************************* -* Function Name : Set_Status_Out -* Description : Set the Status Out of the related Endpoint -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void Set_Status_Out(u8 bEpNum) -{ - _SetEP_KIND(bEpNum); -} -/******************************************************************************* -* Function Name : SetEPDoubleBuff -* Description : Enable the double buffer feature for the endpoint. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPDoubleBuff(u8 bEpNum) -{ - _SetEP_KIND(bEpNum); -} -/******************************************************************************* -* Function Name : ClearEPDoubleBuff -* Description : Disable the double buffer feature for the endpoint. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void ClearEPDoubleBuff(u8 bEpNum) -{ - _ClearEP_KIND(bEpNum); -} -/******************************************************************************* -* Function Name : GetTxStallStatus -* Description : Returns the Stall status of the Tx endpoint. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Tx Stall status. -*******************************************************************************/ -u16 GetTxStallStatus(u8 bEpNum) -{ - return(_GetTxStallStatus(bEpNum)); -} -/******************************************************************************* -* Function Name : GetRxStallStatus -* Description : Returns the Stall status of the Rx endpoint. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Rx Stall status. -*******************************************************************************/ -u16 GetRxStallStatus(u8 bEpNum) -{ - return(_GetRxStallStatus(bEpNum)); -} -/******************************************************************************* -* Function Name : ClearEP_CTR_RX -* Description : Clear the CTR_RX bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void ClearEP_CTR_RX(u8 bEpNum) -{ - _ClearEP_CTR_RX(bEpNum); -} -/******************************************************************************* -* Function Name : ClearEP_CTR_TX -* Description : Clear the CTR_TX bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void ClearEP_CTR_TX(u8 bEpNum) -{ - _ClearEP_CTR_TX(bEpNum); -} -/******************************************************************************* -* Function Name : ToggleDTOG_RX -* Description : Toggle the DTOG_RX bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void ToggleDTOG_RX(u8 bEpNum) -{ - _ToggleDTOG_RX(bEpNum); -} -/******************************************************************************* -* Function Name : ToggleDTOG_TX -* Description : Toggle the DTOG_TX bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void ToggleDTOG_TX(u8 bEpNum) -{ - _ToggleDTOG_TX(bEpNum); -} -/******************************************************************************* -* Function Name : ClearDTOG_RX. -* Description : Clear the DTOG_RX bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void ClearDTOG_RX(u8 bEpNum) -{ - _ClearDTOG_RX(bEpNum); -} -/******************************************************************************* -* Function Name : ClearDTOG_TX. -* Description : Clear the DTOG_TX bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -void ClearDTOG_TX(u8 bEpNum) -{ - _ClearDTOG_TX(bEpNum); -} -/******************************************************************************* -* Function Name : SetEPAddress -* Description : Set the endpoint address. -* Input : bEpNum: Endpoint Number. -* bAddr: New endpoint address. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPAddress(u8 bEpNum, u8 bAddr) -{ - _SetEPAddress(bEpNum, bAddr); -} -/******************************************************************************* -* Function Name : GetEPAddress -* Description : Get the endpoint address. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Endpoint address. -*******************************************************************************/ -u8 GetEPAddress(u8 bEpNum) -{ - return(_GetEPAddress(bEpNum)); -} -/******************************************************************************* -* Function Name : SetEPTxAddr -* Description : Set the endpoint Tx buffer address. -* Input : bEpNum: Endpoint Number. -* wAddr: new address. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPTxAddr(u8 bEpNum, u16 wAddr) -{ - _SetEPTxAddr(bEpNum, wAddr); -} -/******************************************************************************* -* Function Name : SetEPRxAddr -* Description : Set the endpoint Rx buffer address. -* Input : bEpNum: Endpoint Number. -* wAddr: new address. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPRxAddr(u8 bEpNum, u16 wAddr) -{ - _SetEPRxAddr(bEpNum, wAddr); -} -/******************************************************************************* -* Function Name : GetEPTxAddr -* Description : Returns the endpoint Tx buffer address. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Rx buffer address. -*******************************************************************************/ -u16 GetEPTxAddr(u8 bEpNum) -{ - return(_GetEPTxAddr(bEpNum)); -} -/******************************************************************************* -* Function Name : GetEPRxAddr. -* Description : Returns the endpoint Rx buffer address. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Rx buffer address. -*******************************************************************************/ -u16 GetEPRxAddr(u8 bEpNum) -{ - return(_GetEPRxAddr(bEpNum)); -} -/******************************************************************************* -* Function Name : SetEPTxCount. -* Description : Set the Tx count. -* Input : bEpNum: Endpoint Number. -* wCount: new count value. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPTxCount(u8 bEpNum, u16 wCount) -{ - _SetEPTxCount(bEpNum, wCount); -} -/******************************************************************************* -* Function Name : SetEPCountRxReg. -* Description : Set the Count Rx Register value. -* Input : *pdwReg: point to the register. -* wCount: the new register value. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPCountRxReg(u32 *pdwReg, u16 wCount) -{ - _SetEPCountRxReg(dwReg, wCount); -} -/******************************************************************************* -* Function Name : SetEPRxCount -* Description : Set the Rx count. -* Input : bEpNum: Endpoint Number. -* wCount: the new count value. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPRxCount(u8 bEpNum, u16 wCount) -{ - _SetEPRxCount(bEpNum, wCount); -} -/******************************************************************************* -* Function Name : GetEPTxCount -* Description : Get the Tx count. -* Input : bEpNum: Endpoint Number. -* Output : None -* Return : Tx count value. -*******************************************************************************/ -u16 GetEPTxCount(u8 bEpNum) -{ - return(_GetEPTxCount(bEpNum)); -} -/******************************************************************************* -* Function Name : GetEPRxCount -* Description : Get the Rx count. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Rx count value. -*******************************************************************************/ -u16 GetEPRxCount(u8 bEpNum) -{ - return(_GetEPRxCount(bEpNum)); -} -/******************************************************************************* -* Function Name : SetEPDblBuffAddr -* Description : Set the addresses of the buffer 0 and 1. -* Input : bEpNum: Endpoint Number. -* wBuf0Addr: new address of buffer 0. -* wBuf1Addr: new address of buffer 1. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPDblBuffAddr(u8 bEpNum, u16 wBuf0Addr, u16 wBuf1Addr) -{ - _SetEPDblBuffAddr(bEpNum, wBuf0Addr, wBuf1Addr); -} -/******************************************************************************* -* Function Name : SetEPDblBuf0Addr -* Description : Set the Buffer 1 address. -* Input : bEpNum: Endpoint Number -* wBuf0Addr: new address. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPDblBuf0Addr(u8 bEpNum, u16 wBuf0Addr) -{ - _SetEPDblBuf0Addr(bEpNum, wBuf0Addr); -} -/******************************************************************************* -* Function Name : SetEPDblBuf1Addr -* Description : Set the Buffer 1 address. -* Input : bEpNum: Endpoint Number -* wBuf1Addr: new address. -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPDblBuf1Addr(u8 bEpNum, u16 wBuf1Addr) -{ - _SetEPDblBuf1Addr(bEpNum, wBuf1Addr); -} -/******************************************************************************* -* Function Name : GetEPDblBuf0Addr -* Description : Returns the address of the Buffer 0. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -u16 GetEPDblBuf0Addr(u8 bEpNum) -{ - return(_GetEPDblBuf0Addr(bEpNum)); -} -/******************************************************************************* -* Function Name : GetEPDblBuf1Addr -* Description : Returns the address of the Buffer 1. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Address of the Buffer 1. -*******************************************************************************/ -u16 GetEPDblBuf1Addr(u8 bEpNum) -{ - return(_GetEPDblBuf1Addr(bEpNum)); -} -/******************************************************************************* -* Function Name : SetEPDblBuffCount -* Description : Set the number of bytes for a double Buffer -* endpoint. -* Input : bEpNum,bDir, wCount -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPDblBuffCount(u8 bEpNum, u8 bDir, u16 wCount) -{ - _SetEPDblBuffCount(bEpNum, bDir, wCount); -} -/******************************************************************************* -* Function Name : SetEPDblBuf0Count -* Description : Set the number of bytes in the buffer 0 of a double Buffer -* endpoint. -* Input : bEpNum, bDir, wCount -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPDblBuf0Count(u8 bEpNum, u8 bDir, u16 wCount) -{ - _SetEPDblBuf0Count(bEpNum, bDir, wCount); -} -/******************************************************************************* -* Function Name : SetEPDblBuf1Count -* Description : Set the number of bytes in the buffer 0 of a double Buffer -* endpoint. -* Input : bEpNum, bDir, wCount -* Output : None. -* Return : None. -*******************************************************************************/ -void SetEPDblBuf1Count(u8 bEpNum, u8 bDir, u16 wCount) -{ - _SetEPDblBuf1Count(bEpNum, bDir, wCount); -} -/******************************************************************************* -* Function Name : GetEPDblBuf0Count -* Description : Returns the number of byte received in the buffer 0 of a double -* Buffer endpoint. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Endpoint Buffer 0 count -*******************************************************************************/ -u16 GetEPDblBuf0Count(u8 bEpNum) -{ - return(_GetEPDblBuf0Count(bEpNum)); -} -/******************************************************************************* -* Function Name : GetEPDblBuf1Count -* Description : Returns the number of data received in the buffer 1 of a double -* Buffer endpoint. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Endpoint Buffer 1 count. -*******************************************************************************/ -u16 GetEPDblBuf1Count(u8 bEpNum) -{ - return(_GetEPDblBuf1Count(bEpNum)); -} -/******************************************************************************* -* Function Name : GetEPDblBufDir -* Description : gets direction of the double buffered endpoint -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : EP_DBUF_OUT, EP_DBUF_IN, -* EP_DBUF_ERR if the endpoint counter not yet programmed. -*******************************************************************************/ -EP_DBUF_DIR GetEPDblBufDir(u8 bEpNum) -{ - if ((u16)(*_pEPRxCount(bEpNum) & 0xFC00) != 0) - return(EP_DBUF_OUT); - else if (((u16)(*_pEPTxCount(bEpNum)) & 0x03FF) != 0) - return(EP_DBUF_IN); - else - return(EP_DBUF_ERR); -} -/******************************************************************************* -* Function Name : FreeUserBuffer -* Description : free buffer used from the application realizing it to the line - toggles bit SW_BUF in the double buffered endpoint register -* Input : bEpNum, bDir -* Output : None. -* Return : None. -*******************************************************************************/ -void FreeUserBuffer(u8 bEpNum, u8 bDir) -{ - if (bDir == EP_DBUF_OUT) - { /* OUT double buffered endpoint */ - _ToggleDTOG_TX(bEpNum); - } - else if (bDir == EP_DBUF_IN) - { /* IN double buffered endpoint */ - _ToggleDTOG_RX(bEpNum); - } -} - -/******************************************************************************* -* Function Name : ToWord -* Description : merge two byte in a word. -* Input : bh: byte high, bl: bytes low. -* Output : None. -* Return : resulted word. -*******************************************************************************/ -u16 ToWord(u8 bh, u8 bl) -{ - u16 wRet; - wRet = (u16)bl | ((u16)bh << 8); - return(wRet); -} -/******************************************************************************* -* Function Name : ByteSwap -* Description : Swap two byte in a word. -* Input : wSwW: word to Swap. -* Output : None. -* Return : resulted word. -*******************************************************************************/ -u16 ByteSwap(u16 wSwW) -{ - u8 bTemp; - u16 wRet; - bTemp = (u8)(wSwW & 0xff); - wRet = (wSwW >> 8) | ((u16)bTemp << 8); - return(wRet); -} - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/cores/maple/libmaple/util.c b/GD32F1/cores/maple/libmaple/util.c deleted file mode 100644 index ae63220..0000000 --- a/GD32F1/cores/maple/libmaple/util.c +++ /dev/null @@ -1,152 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/util.c - * @brief Utility procedures for debugging - */ - -#include -#include -#include -#include - -/* (Undocumented) hooks used by Wirish to direct our behavior here */ -extern __weak void __lm_error(void); -extern __weak usart_dev* __lm_enable_error_usart(void); - -/* If you define ERROR_LED_PORT and ERROR_LED_PIN, then a failed - * ASSERT() will also throb() an LED connected to that port and pin. - */ -#if defined(ERROR_LED_PORT) && defined(ERROR_LED_PIN) -#define HAVE_ERROR_LED -#endif - -/* (Called from exc.S with global interrupts disabled.) */ -__attribute__((noreturn)) void __error(void) { - if (__lm_error) { - __lm_error(); - } - /* Reenable global interrupts */ - nvic_globalirq_enable(); - throb(); -} - -/* - * Print an error message on a UART upon a failed assertion (if one is - * available), and punt to __error(). - * - * @param file Source file of failed assertion - * @param line Source line of failed assertion - * @param exp String representation of failed assertion - * @sideeffect Turns of all peripheral interrupts except USB. - */ -void _fail(const char* file, int line, const char* exp) { - if (__lm_enable_error_usart) { - /* Initialize the error USART */ - usart_dev *err_usart = __lm_enable_error_usart(); - - /* Print failed assert message */ - usart_putstr(err_usart, "ERROR: FAILED ASSERT("); - usart_putstr(err_usart, exp); - usart_putstr(err_usart, "): "); - usart_putstr(err_usart, file); - usart_putstr(err_usart, ": "); - usart_putudec(err_usart, line); - usart_putc(err_usart, '\n'); - usart_putc(err_usart, '\r'); - } - /* Shutdown and error fade */ - __error(); -} - -/* - * Provide an __assert_func handler to libc so that calls to assert() - * get redirected to _fail. - */ -void __assert_func(const char* file, int line, const char* method, - const char* expression) { - _fail(file, line, expression); -} - -/* - * Provide an abort() implementation that aborts execution and punts - * to __error(). - */ -void abort() { - if (__lm_enable_error_usart) { - /* Initialize the error USART */ - usart_dev *err_usart = __lm_enable_error_usart(); - /* Print abort message. */ - usart_putstr(err_usart, "ERROR: PROGRAM ABORTED VIA abort()\r\n"); - } - - /* Shutdown and error fade */ - __error(); -} - -/* This was public as of v0.0.12, so we've got to keep it public. */ -/** - * @brief Fades the error LED on and off - * @sideeffect Sets output push-pull on ERROR_LED_PIN. - */ -__attribute__((noreturn)) void throb(void) { -#ifdef HAVE_ERROR_LED - int32 slope = 1; - uint32 CC = 0x0000; - uint32 TOP_CNT = 0x0200; - uint32 i = 0; - volatile int dly; - - gpio_set_mode(ERROR_LED_PORT, ERROR_LED_PIN, GPIO_MODE_OUTPUT); - /* Error fade. */ - while (1) { - if (CC == TOP_CNT) { - slope = -1; - } else if (CC == 0) { - slope = 1; - } - - if (i == TOP_CNT) { - CC += slope; - i = 0; - } - - if (i < CC) { - gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 1); - } else { - gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 0); - } - i++; - for( dly=0;dly<10;dly++); - } -#else - /* No error LED is defined; do nothing. */ - while (1) - ; -#endif -} diff --git a/GD32F1/cores/maple/main.cpp b/GD32F1/cores/maple/main.cpp deleted file mode 100644 index 3d78443..0000000 --- a/GD32F1/cores/maple/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -extern void setup(void); -extern void loop(void); -extern void init(void); - -// Force init to be called *first*, i.e. before static object allocation. -// Otherwise, statically allocated objects that need libmaple may fail. - __attribute__(( constructor (101))) void premain() { - init(); -} - -int main(void) { - setup(); - - while (1) { - loop(); - } - return 0; -} diff --git a/GD32F1/cores/maple/pwm.cpp b/GD32F1/cores/maple/pwm.cpp deleted file mode 100644 index 6977fd6..0000000 --- a/GD32F1/cores/maple/pwm.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/pwm.cpp - * @brief Wiring-style pwmWrite(). - */ - -#include "pwm.h" - -#include -#include - -#include "boards.h" -#include "io.h" - -void pwmWrite(uint8 pin, uint16 duty_cycle) { - if (pin >= BOARD_NR_GPIO_PINS) { - return; - } - timer_dev *dev = PIN_MAP[pin].timer_device; - uint8 cc_channel = PIN_MAP[pin].timer_channel; - ASSERT(dev && cc_channel); - timer_set_compare(dev, cc_channel, duty_cycle); -} - -/* - * Roger Clark. Added new function to replicate more closely what the Arduino API does - * Note. This implementation is currently slower than it could be, - * because pinMode needs to be called to set the special (new) mode of PWM - * Some optimisation may be possible with pinMode or even in this function - */ -void analogWrite(uint8 pin, int duty_cycle8) -{ - pinMode(pin,PWM); - pwmWrite(pin,duty_cycle8 * 257);// 257 maps 255 to 65535 (i.e 255*257 = 65535) -} diff --git a/GD32F1/cores/maple/pwm.h b/GD32F1/cores/maple/pwm.h deleted file mode 100644 index 7775102..0000000 --- a/GD32F1/cores/maple/pwm.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/pwm.h - * @brief Wiring-style PWM interface. - */ - -#ifndef _WIRISH_PWM_H_ -#define _WIRISH_PWM_H_ - -#include - -/** - * Set the PWM duty on the given pin. - * - * User code is expected to determine and honor the maximum value - * (based on the configured period). - * - * @param pin PWM output pin - * @param duty_cycle Duty cycle to set. (Range is 0 to 65535) - */ -void pwmWrite(uint8 pin, uint16 duty_cycle16); - -/** - * Roger Clark. 20140103 - * Added function to replicate the Arduino PWM functionality or range 0 to 255 - * User code is expected to determine and honor the maximum value - * (based on the configured period). - * - * @param pin PWM output pin - * @param duty_cycle Duty cycle to set. (Range is 0 to 255) - */ -void analogWrite(uint8 pin, int duty_cycle8); -#endif - diff --git a/GD32F1/cores/maple/rules.mk b/GD32F1/cores/maple/rules.mk deleted file mode 100644 index 1cac74a..0000000 --- a/GD32F1/cores/maple/rules.mk +++ /dev/null @@ -1,62 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -# Add board directory and MCU-specific directory to BUILDDIRS. These -# are in subdirectories, but they're logically part of the Wirish -# submodule. -WIRISH_BOARD_PATH := boards/$(BOARD) -BUILDDIRS += $(BUILD_PATH)/$(d)/$(WIRISH_BOARD_PATH) -BUILDDIRS += $(BUILD_PATH)/$(d)/$(MCU_SERIES) - -# Safe includes for Wirish. -WIRISH_INCLUDES := -I$(d)/include -I$(d)/$(WIRISH_BOARD_PATH)/include - -# Local flags. Add -I$(d) to allow for private includes. -CFLAGS_$(d) := $(LIBMAPLE_INCLUDES) $(WIRISH_INCLUDES) -I$(d) - -# Local rules and targets -sSRCS_$(d) := start.S -cSRCS_$(d) := start_c.c -cSRCS_$(d) += syscalls.c -cSRCS_$(d) += $(MCU_SERIES)/util_hooks.c -cppSRCS_$(d) := boards.cpp -cppSRCS_$(d) += cxxabi-compat.cpp -cppSRCS_$(d) += ext_interrupts.cpp -cppSRCS_$(d) += HardwareSerial.cpp -cppSRCS_$(d) += HardwareTimer.cpp -cppSRCS_$(d) += Print.cpp -cppSRCS_$(d) += pwm.cpp -ifeq ($(MCU_SERIES), stm32f1) -cppSRCS_$(d) += usb_serial.cpp # HACK: this is currently STM32F1 only. -cppSRCS_$(d) += HardwareSPI.cpp # FIXME: port to F2 and fix wirish.h -endif -cppSRCS_$(d) += wirish_analog.cpp -cppSRCS_$(d) += wirish_digital.cpp -cppSRCS_$(d) += wirish_math.cpp -cppSRCS_$(d) += wirish_shift.cpp -cppSRCS_$(d) += wirish_time.cpp -cppSRCS_$(d) += $(MCU_SERIES)/boards_setup.cpp -cppSRCS_$(d) += $(MCU_SERIES)/wirish_digital.cpp -cppSRCS_$(d) += $(MCU_SERIES)/wirish_debug.cpp -cppSRCS_$(d) += $(WIRISH_BOARD_PATH)/board.cpp - -sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \ - $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ - $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) diff --git a/GD32F1/cores/maple/stm32f1/util_hooks.c b/GD32F1/cores/maple/stm32f1/util_hooks.c deleted file mode 100644 index 506844b..0000000 --- a/GD32F1/cores/maple/stm32f1/util_hooks.c +++ /dev/null @@ -1,83 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung (from libmaple/util.c). - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* - * STM32F1 implementations for libmaple/util.c hooks - * - * These need more love and attention before being made public API - * (this includes being easily overridable by user code). - */ - -#include -#include -#include -#include -#include -#include - -/* Failed ASSERT()s send out a message using this USART config. */ -#ifndef ERROR_USART -#define ERROR_USART USART1 -#define ERROR_USART_BAUD 9600 -#define ERROR_TX_PORT GPIOA -#define ERROR_TX_PIN 2 -#endif - -/* - * Disables all peripheral interrupts except USB (when available), - * turns off commonly-used peripherals. Called by __error() with - * global interrupts disabled. - */ -void __lm_error(void) { - /* Turn off peripheral interrupts */ - nvic_irq_disable_all(); - - /* Turn off timers */ - timer_disable_all(); - - /* Turn off ADC */ - adc_disable_all(); - - /* Turn off all USARTs */ - usart_disable_all(); - -#if STM32_HAVE_USB - /* Turn the USB interrupt back on so the bootloader keeps on functioning */ - nvic_irq_enable(NVIC_USB_HP_CAN_TX); - nvic_irq_enable(NVIC_USB_LP_CAN_RX0); -#endif -} - -/* - * Enable the error USART for writing. - */ -usart_dev* __lm_enable_error_usart() { - gpio_set_mode(ERROR_TX_PORT, ERROR_TX_PIN, GPIO_AF_OUTPUT_PP); - usart_init(ERROR_USART); - usart_set_baud_rate(ERROR_USART, USART_USE_PCLK, ERROR_USART_BAUD); - return ERROR_USART; -} diff --git a/GD32F1/cores/maple/stm32f1/wiring_pulse_f1.cpp b/GD32F1/cores/maple/stm32f1/wiring_pulse_f1.cpp deleted file mode 100644 index 9ca4d7f..0000000 --- a/GD32F1/cores/maple/stm32f1/wiring_pulse_f1.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include "boards.h" -/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH - * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds - * to 3 minutes in length, but must be called at least a few dozen microseconds - * before the start of the pulse. */ - - - /* - * Roger Clark - * - * Note. The API spec for this function published on http://www.arduino.cc/en/Reference/PulseIn - * doesn't reflect what either the AVR or SAM version of this function actualy do with regard to the timeout value - * - * "timeout (optional): the number of microseconds to wait for the pulse to start; default is one second (unsigned long) " - * - * Because the timeout, is actually coded as the total time to both wait while the input is in the state requested - * then wait for the opposite state duration - * then count the length of the pulse when it has the value of state (HIGH or LOW) - * - * So I think the code for both the AVR and the Due is wrong in that it doesnt match the spec - * - * I have done basically the same as the AVR and Due code, except to make the timeout a bit more accurate I have put in a dummy volatile varable - * dummyWidth so that both the waiting while loops take the same number of clock cycles to execute as the acount width counting loop - * - * to be slighly more accurate the maxLoops variable really needs to take into account the loop setup code, but its probably as good as necessary - * - */ -uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout ) -{ - // cache the port and bit of the pin in order to speed up the - // pulse width measuring loop and achieve finer resolution. calling - // digitalRead() instead yields much coarser resolution. - - gpio_dev *dev=PIN_MAP[pin].gpio_device; - uint32_t bit = (1U << PIN_MAP[pin].gpio_bit); - - - uint32_t width = 0; // keep initialization out of time critical area - - // convert the timeout from microseconds to a number of times through - // the initial loop; it takes 16 clock cycles per iteration. - uint32_t numloops = 0; - uint32_t maxloops = timeout * ( F_CPU / 16000000); - volatile uint32_t dummyWidth=0; - - // wait for any previous pulse to end - while ( (dev->regs->IDR & bit) == bit) { - if (numloops++ == maxloops) { - return 0; - } - dummyWidth++; - } - - // wait for the pulse to start - while ((dev->regs->IDR & bit) != bit) { - if (numloops++ == maxloops) { - return 0; - } - dummyWidth++; - } - - // wait for the pulse to stop - while ((dev->regs->IDR & bit) == bit) { - if (numloops++ == maxloops) { - return 0; - } - width++; - } - - // Excluding time taking up by the interrupts, it needs 16 clock cycles to look through the last while loop - // 5 is added as a fiddle factor to correct for interrupts etc. But ultimately this would only be accurate if it was done ona hardware timer - - return (uint32_t)( ( (unsigned long long)(width+5) * (unsigned long long) 16000000.0) /(unsigned long long)F_CPU ) ; -} diff --git a/GD32F1/cores/maple/stm32f1/wirish_debug.cpp b/GD32F1/cores/maple/stm32f1/wirish_debug.cpp deleted file mode 100644 index f057616..0000000 --- a/GD32F1/cores/maple/stm32f1/wirish_debug.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/stm32f1/wirish_debug.cpp - * @brief High level debug port configuration - */ - -#include -#include - -void disableDebugPorts(void) { - afio_cfg_debug_ports(AFIO_DEBUG_NONE); -} - -void enableDebugPorts(void) { - afio_cfg_debug_ports(AFIO_DEBUG_FULL_SWJ); -} diff --git a/GD32F1/cores/maple/stm32f1/wirish_digital_f1.cpp b/GD32F1/cores/maple/stm32f1/wirish_digital_f1.cpp deleted file mode 100644 index f16181d..0000000 --- a/GD32F1/cores/maple/stm32f1/wirish_digital_f1.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* - * STM32F1 implementations for basic GPIO functionality. - */ - -#include - -#include -#include - -#include - -void pinMode(uint8 pin, WiringPinMode mode) { - gpio_pin_mode outputMode; - bool pwm = false; - - if (pin >= BOARD_NR_GPIO_PINS) { - return; - } - - switch(mode) { - case OUTPUT: - outputMode = GPIO_OUTPUT_PP; - break; - case OUTPUT_OPEN_DRAIN: - outputMode = GPIO_OUTPUT_OD; - break; - case INPUT: - case INPUT_FLOATING: - outputMode = GPIO_INPUT_FLOATING; - break; - case INPUT_ANALOG: - outputMode = GPIO_INPUT_ANALOG; - break; - case INPUT_PULLUP: - outputMode = GPIO_INPUT_PU; - break; - case INPUT_PULLDOWN: - outputMode = GPIO_INPUT_PD; - break; - case PWM: - outputMode = GPIO_AF_OUTPUT_PP; - pwm = true; - break; - case PWM_OPEN_DRAIN: - outputMode = GPIO_AF_OUTPUT_OD; - pwm = true; - break; - default: - ASSERT(0); - return; - } - - gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, outputMode); - - if (PIN_MAP[pin].timer_device != NULL) { - /* Enable/disable timer channels if we're switching into or - * out of PWM. */ - timer_set_mode(PIN_MAP[pin].timer_device, - PIN_MAP[pin].timer_channel, - pwm ? TIMER_PWM : TIMER_DISABLED); - } -} diff --git a/GD32F1/cores/maple/usb_serial.cpp b/GD32F1/cores/maple/usb_serial.cpp deleted file mode 100644 index fcc39b1..0000000 --- a/GD32F1/cores/maple/usb_serial.cpp +++ /dev/null @@ -1,354 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @brief USB virtual serial terminal - */ - -#include "usb_serial.h" - -#include "string.h" -#include "stdint.h" - -#include -#include -#include -#include - -#include "wirish.h" - -/* - * Hooks used for bootloader reset signalling - */ - -#if BOARD_HAVE_SERIALUSB -static void rxHook(unsigned, void*); -static void ifaceSetupHook(unsigned, void*); -#endif - -/* - * USBSerial interface - */ - -#define USB_TIMEOUT 50 - -USBSerial::USBSerial(void) { -#if !BOARD_HAVE_SERIALUSB - ASSERT(0); -#endif -} - -void USBSerial::begin(void) { -#if BOARD_HAVE_SERIALUSB - usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); - usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, rxHook); - usb_cdcacm_set_hooks(USB_CDCACM_HOOK_IFACE_SETUP, ifaceSetupHook); -#endif -} - -//Roger Clark. Two new begin functions has been added so that normal Arduino Sketches that use Serial.begin(xxx) will compile. -void USBSerial::begin(unsigned long ignoreBaud) -{ -volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud; - - ignoreBaud=removeCompilerWarningsIgnoreBaud; -} -void USBSerial::begin(unsigned long ignoreBaud, uint8_t ignore) -{ -volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud; -volatile uint8_t removeCompilerWarningsIgnore=ignore; - - ignoreBaud=removeCompilerWarningsIgnoreBaud; - ignore=removeCompilerWarningsIgnore; -} - -void USBSerial::end(void) { -#if BOARD_HAVE_SERIALUSB - usb_cdcacm_disable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); - usb_cdcacm_remove_hooks(USB_CDCACM_HOOK_RX | USB_CDCACM_HOOK_IFACE_SETUP); -#endif -} - -size_t USBSerial::write(uint8 ch) { -size_t n = 0; - this->write(&ch, 1); - return n; -} - -size_t USBSerial::write(const char *str) { -size_t n = 0; - this->write(str, strlen(str)); - return n; -} - -size_t USBSerial::write(const void *buf, uint32 len) { -size_t n = 0; - if (!this->isConnected() || !buf) { - return 0; - } - - uint32 txed = 0; - uint32 old_txed = 0; - uint32 start = millis(); - - uint32 sent = 0; - - while (txed < len && (millis() - start < USB_TIMEOUT)) { - sent = usb_cdcacm_tx((const uint8*)buf + txed, len - txed); - txed += sent; - if (old_txed != txed) { - start = millis(); - } - old_txed = txed; - } - - - if (sent == USB_CDCACM_TX_EPSIZE) { - while (usb_cdcacm_is_transmitting() != 0) { - } - /* flush out to avoid having the pc wait for more data */ - usb_cdcacm_tx(NULL, 0); - } - return n; -} - -int USBSerial::available(void) { - return usb_cdcacm_data_available(); -} - -int USBSerial::peek(void) -{ - uint8 b; - if (usb_cdcacm_peek(&b, 1)==1) - { - return b; - } - else - { - return -1; - } -} - -void USBSerial::flush(void) -{ -/*Roger Clark. Rather slow method. Need to improve this */ - uint8 b; - while(usb_cdcacm_data_available()) - { - this->read(&b, 1); - } - return; -} - -uint32 USBSerial::read(void *buf, uint32 len) { - if (!buf) { - return 0; - } - - uint32 rxed = 0; - while (rxed < len) { - rxed += usb_cdcacm_rx((uint8*)buf + rxed, len - rxed); - } - - return rxed; -} - -/* Blocks forever until 1 byte is received */ -int USBSerial::read(void) { - uint8 b; - /* - this->read(&b, 1); - return b; - */ - - if (usb_cdcacm_rx(&b, 1)==0) - { - return -1; - } - else - { - return b; - } -} - -uint8 USBSerial::pending(void) { - return usb_cdcacm_get_pending(); -} - -uint8 USBSerial::isConnected(void) { - return usb_is_connected(USBLIB) && usb_is_configured(USBLIB); -} - -uint8 USBSerial::getDTR(void) { - return usb_cdcacm_get_dtr(); -} - -uint8 USBSerial::getRTS(void) { - return usb_cdcacm_get_rts(); -} - -#if BOARD_HAVE_SERIALUSB - #ifdef SERIAL_USB - USBSerial Serial; - #endif -#endif - -/* - * Bootloader hook implementations - */ - -#if BOARD_HAVE_SERIALUSB - -enum reset_state_t { - DTR_UNSET, - DTR_HIGH, - DTR_NEGEDGE, - DTR_LOW -}; - -static reset_state_t reset_state = DTR_UNSET; - -static void ifaceSetupHook(unsigned hook, void *requestvp) { - uint8 request = *(uint8*)requestvp; - - // Ignore requests we're not interested in. - if (request != USB_CDCACM_SET_CONTROL_LINE_STATE) { - return; - } - -#ifdef SERIAL_USB - // We need to see a negative edge on DTR before we start looking - // for the in-band magic reset byte sequence. - uint8 dtr = usb_cdcacm_get_dtr(); - switch (reset_state) { - case DTR_UNSET: - reset_state = dtr ? DTR_HIGH : DTR_LOW; - break; - case DTR_HIGH: - reset_state = dtr ? DTR_HIGH : DTR_NEGEDGE; - break; - case DTR_NEGEDGE: - reset_state = dtr ? DTR_HIGH : DTR_LOW; - break; - case DTR_LOW: - reset_state = dtr ? DTR_HIGH : DTR_LOW; - break; - } -#endif - -#if defined(BOOTLOADER_robotis) - uint8 dtr = usb_cdcacm_get_dtr(); - uint8 rts = usb_cdcacm_get_rts(); - - if (rts && !dtr) { - reset_state = DTR_NEGEDGE; - } -#endif - - if ((usb_cdcacm_get_baud() == 1200) && (reset_state == DTR_NEGEDGE)) { - iwdg_init(IWDG_PRE_4, 10); - while (1); - } -} - -#define RESET_DELAY 100000 -#ifdef SERIAL_USB -static void wait_reset(void) { - delay_us(RESET_DELAY); - nvic_sys_reset(); -} -#endif - -#define STACK_TOP 0x20000800 -#define EXC_RETURN 0xFFFFFFF9 -#define DEFAULT_CPSR 0x61000000 -static void rxHook(unsigned hook, void *ignored) { - /* FIXME this is mad buggy; we need a new reset sequence. E.g. NAK - * after each RX means you can't reset if any bytes are waiting. */ - if (reset_state == DTR_NEGEDGE) { - reset_state = DTR_LOW; - - if (usb_cdcacm_data_available() >= 4) { - // The magic reset sequence is "1EAF". -#ifdef SERIAL_USB - static const uint8 magic[4] = {'1', 'E', 'A', 'F'}; -#else - #if defined(BOOTLOADER_robotis) - static const uint8 magic[4] = {'C', 'M', '9', 'X'}; - #else - static const uint8 magic[4] = {'1', 'E', 'A', 'F'}; - #endif -#endif - - uint8 chkBuf[4]; - - // Peek at the waiting bytes, looking for reset sequence, - // bailing on mismatch. - usb_cdcacm_peek_ex(chkBuf, usb_cdcacm_data_available() - 4, 4); - for (unsigned i = 0; i < sizeof(magic); i++) { - if (chkBuf[i] != magic[i]) { - return; - } - } - -#ifdef SERIAL_USB - // Got the magic sequence -> reset, presumably into the bootloader. - // Return address is wait_reset, but we must set the thumb bit. - uintptr_t target = (uintptr_t)wait_reset | 0x1; - asm volatile("mov r0, %[stack_top] \n\t" // Reset stack - "mov sp, r0 \n\t" - "mov r0, #1 \n\t" - "mov r1, %[target_addr] \n\t" - "mov r2, %[cpsr] \n\t" - "push {r2} \n\t" // Fake xPSR - "push {r1} \n\t" // PC target addr - "push {r0} \n\t" // Fake LR - "push {r0} \n\t" // Fake R12 - "push {r0} \n\t" // Fake R3 - "push {r0} \n\t" // Fake R2 - "push {r0} \n\t" // Fake R1 - "push {r0} \n\t" // Fake R0 - "mov lr, %[exc_return] \n\t" - "bx lr" - : - : [stack_top] "r" (STACK_TOP), - [target_addr] "r" (target), - [exc_return] "r" (EXC_RETURN), - [cpsr] "r" (DEFAULT_CPSR) - : "r0", "r1", "r2"); -#endif - -#if defined(BOOTLOADER_robotis) - iwdg_init(IWDG_PRE_4, 10); -#endif - - /* Can't happen. */ - ASSERT_FAULT(0); - } - } -} - -#endif // BOARD_HAVE_SERIALUSB diff --git a/GD32F1/cores/maple/usb_serial.h b/GD32F1/cores/maple/usb_serial.h deleted file mode 100644 index 740ab0f..0000000 --- a/GD32F1/cores/maple/usb_serial.h +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @brief Wirish USB virtual serial port (SerialUSB). - */ - -#ifndef _WIRISH_USB_SERIAL_H_ -#define _WIRISH_USB_SERIAL_H_ - -#include "Print.h" -#include "boards.h" -#include "Stream.h" - -/** - * @brief Virtual serial terminal. - */ -class USBSerial : public Stream { -public: - USBSerial(void); - - void begin(void); - - // Roger Clark. Added dummy function so that existing Arduino sketches which specify baud rate will compile. - void begin(unsigned long); - void begin(unsigned long, uint8_t); - void end(void); - - operator bool() { return true; } // Roger Clark. This is needed because in cardinfo.ino it does if (!Serial) . It seems to be a work around for the Leonardo that we needed to implement just to be compliant with the API - - virtual int available(void);// Changed to virtual - - uint32 read(void *buf, uint32 len); - // uint8 read(void); - - // Roger Clark. added functions to support Arduino 1.0 API - virtual int peek(void); - virtual int read(void); - int availableForWrite(void); - virtual void flush(void); - - - size_t write(uint8); - size_t write(const char *str); - size_t write(const void*, uint32); - - uint8 getRTS(); - uint8 getDTR(); - uint8 isConnected(); - uint8 pending(); -}; - -#ifdef SERIAL_USB - extern USBSerial Serial; -#endif - -#endif - diff --git a/GD32F1/cores/maple/wiring_private.h b/GD32F1/cores/maple/wiring_private.h deleted file mode 100644 index 88fd009..0000000 --- a/GD32F1/cores/maple/wiring_private.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef WiringPrivate_h -#define WiringPrivate_h - -#endif \ No newline at end of file diff --git a/GD32F1/cores/maple/wiring_pulse.h b/GD32F1/cores/maple/wiring_pulse.h deleted file mode 100644 index abc2463..0000000 --- a/GD32F1/cores/maple/wiring_pulse.h +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2015 Roger Clark - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - - - -#ifndef _WIRISH_PULSE_H_ -#define _WIRISH_PULSE_H_ - -#include - -uint32_t pulseIn( uint32_t ulPin, uint32_t ulState, uint32_t ulTimeout = 1000000L ) ; - - -#endif diff --git a/GD32F1/cores/maple/wirish.h b/GD32F1/cores/maple/wirish.h deleted file mode 100644 index a8264f2..0000000 --- a/GD32F1/cores/maple/wirish.h +++ /dev/null @@ -1,102 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @brief Main include file for the Wirish core. - * - * Includes most of Wirish, and (transitively or otherwise) - * substantial pieces of libmaple proper. - */ - -#ifndef _WIRISH_WIRISH_H_ -#define _WIRISH_WIRISH_H_ - -/* - * 20141030. Roger Clark - Added the block of includes up to avr/interrupt so that stdlib functions like memcpy would be included and could be used. - */ -#include -#include - - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if STM32_MCU_SERIES == STM32_SERIES_F1 /* FIXME [0.0.13?] port to F2 */ -//#include -#endif - -#include -#include -#include -#include - -#include - -#include - - -#define SS BOARD_SPI1_NSS_PIN -#define MOSI BOARD_SPI1_MOSI_PIN -#define MISO BOARD_SPI1_MISO_PIN -#define SCK BOARD_SPI1_SCK_PIN - - -typedef unsigned int word; -// typedef uint16 word;// definition from Arduino website, now appears to be incorrect for 32 bit devices - -/* Wiring macros and bit defines */ - -#define true 0x1 -#define false 0x0 - -#define lowByte(w) ((w) & 0xFF) -#define highByte(w) (((w) >> 8) & 0xFF) -#define bitRead(value, bit) (((value) >> (bit)) & 0x01) -#define bitSet(value, bit) ((value) |= (1UL << (bit))) -#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) -#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : \ - bitClear(value, bit)) -#define bit(b) (1UL << (b)) - -#endif - diff --git a/GD32F1/cores/maple/wirish_analog.cpp b/GD32F1/cores/maple/wirish_analog.cpp deleted file mode 100644 index 9a8bec7..0000000 --- a/GD32F1/cores/maple/wirish_analog.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/wirish_analog.cpp - * @brief Wiring-style analogRead() implementation. - */ - -#include "io.h" -#include -#include "boards.h" - -/* Unlike Wiring and Arduino, this assumes that the pin's mode is set - * to INPUT_ANALOG. That's faster, but it does require some extra work - * on the user's part. Not too much, we think ;). */ -uint16 analogRead(uint8 pin) { - const adc_dev *dev = PIN_MAP[pin].adc_device; - if (dev == NULL) { - return 0; - } - - return adc_read(dev, PIN_MAP[pin].adc_channel); -} diff --git a/GD32F1/cores/maple/wirish_constants.h b/GD32F1/cores/maple/wirish_constants.h deleted file mode 100644 index 06a85ae..0000000 --- a/GD32F1/cores/maple/wirish_constants.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _WIRING_CONSTANTS_ -#define _WIRING_CONSTANTS_ - -#ifdef __cplusplus -extern "C"{ -#endif - -enum BitOrder { - LSBFIRST = 0, - MSBFIRST = 1 -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/cores/maple/wirish_debug.h b/GD32F1/cores/maple/wirish_debug.h deleted file mode 100644 index 4edfd27..0000000 --- a/GD32F1/cores/maple/wirish_debug.h +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/wirish_debug.h - * @brief High level debug port configuration - */ - -#ifndef _WIRISH_WIRISH_DEBUG_H_ -#define _WIRISH_WIRISH_DEBUG_H_ - -#include - -/** - * @brief Disable the JTAG and Serial Wire (SW) debug ports. - * - * You can call this function in order to use the JTAG and SW debug - * pins as ordinary GPIOs. - * - * @see enableDebugPorts() - */ -void disableDebugPorts(void); - -/** - * @brief Enable the JTAG and Serial Wire (SW) debug ports. - * - * After you call this function, the JTAG and SW debug pins will no - * longer be usable as GPIOs. - * - * @see disableDebugPorts() - */ -void enableDebugPorts(void); - -#endif diff --git a/GD32F1/cores/maple/wirish_digital.cpp b/GD32F1/cores/maple/wirish_digital.cpp deleted file mode 100644 index 53bd69b..0000000 --- a/GD32F1/cores/maple/wirish_digital.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* - * Arduino-compatible digital I/O implementation. - */ - -#include "io.h" - -#include -#include - -#include "wirish_time.h" -#include "boards.h" - -uint32 digitalRead(uint8 pin) { - if (pin >= BOARD_NR_GPIO_PINS) { - return 0; - } - - return gpio_read_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit) ? - HIGH : LOW; -} - -void digitalWrite(uint8 pin, uint8 val) { - if (pin >= BOARD_NR_GPIO_PINS) { - return; - } - - gpio_write_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, val); -} - -#if FALSE -// Roger Clark. Deprecated these functions as they are not part of the standard Arduino API -void togglePin(uint8 pin) { - if (pin >= BOARD_NR_GPIO_PINS) { - return; - } - - gpio_toggle_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit); -} - -#define BUTTON_DEBOUNCE_DELAY 1 - -uint8 isButtonPressed(uint8 pin, uint32 pressedLevel) { - if (digitalRead(pin) == pressedLevel) { - delay(BUTTON_DEBOUNCE_DELAY); - while (digitalRead(pin) == pressedLevel) - ; - return true; - } - return false; -} - -uint8 waitForButtonPress(uint32 timeout) { - uint32 start = millis(); - uint32 time; - if (timeout == 0) { - while (!isButtonPressed()) - ; - return true; - } - do { - time = millis(); - /* properly handle wrap-around */ - if ((start > time && time + (0xffffffffU - start) > timeout) || - time - start > timeout) { - return false; - } - } while (!isButtonPressed()); - return true; -} -#endif \ No newline at end of file diff --git a/GD32F1/cores/maple/wirish_math.cpp b/GD32F1/cores/maple/wirish_math.cpp deleted file mode 100644 index 3b682d3..0000000 --- a/GD32F1/cores/maple/wirish_math.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Modified by LeafLabs, LLC. - * - * Part of the Wiring project - http://wiring.org.co Copyright (c) - * 2004-06 Hernando Barragan Modified 13 August 2006, David A. Mellis - * for Arduino - http://www.arduino.cc/ - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "stdlib.h" -#include "wirish_math.h" - -void randomSeed(unsigned int seed) { - if (seed != 0) { - srand(seed); - } -} - -long random(long howbig) { - if (howbig == 0) { - return 0; - } - - return rand() % howbig; -} - -long random(long howsmall, long howbig) { - if (howsmall >= howbig) { - return howsmall; - } - - long diff = howbig - howsmall; - return random(diff) + howsmall; -} - diff --git a/GD32F1/cores/maple/wirish_math.h b/GD32F1/cores/maple/wirish_math.h deleted file mode 100644 index d103d86..0000000 --- a/GD32F1/cores/maple/wirish_math.h +++ /dev/null @@ -1,164 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/wirish_math.h - * @brief Includes ; provides Wiring-compatible math routines. - */ - -#ifndef _WIRISH_WIRISH_MATH_H_ -#define _WIRISH_WIRISH_MATH_H_ - -#include - -/** - * @brief Initialize the pseudo-random number generator. - * @param seed the number used to initialize the seed; cannot be zero. - */ -void randomSeed(unsigned int seed); - -/** - * @brief Generate a pseudo-random number with upper bound. - * @param max An upper bound on the returned value, exclusive. - * @return A pseudo-random number in the range [0,max). - * @see randomSeed() - */ -long random(long max); - -/** - * @brief Generate a pseudo-random number with lower and upper bounds. - * @param min Lower bound on the returned value, inclusive. - * @param max Upper bound on the returned value, exclusive. - * @return A pseudo-random number in the range [min, max). - * @see randomSeed() - */ -long random(long min, long max); - -/** - * @brief Remap a number from one range to another. - * - * That is, a value equal to fromStart gets mapped to toStart, a value - * of fromEnd to toEnd, and other values are mapped proportionately. - * - * Does not constrain value to lie within [fromStart, fromEnd]. - * - * If a "start" value is larger than its corresponding "end", the - * ranges are reversed, so map(n, 1, 10, 10, 1) would reverse the - * range [1,10]. - * - * Negative numbers may appear as any argument. - * - * @param value the value to map. - * @param fromStart the beginning of the value's current range. - * @param fromEnd the end of the value's current range. - * @param toStart the beginning of the value's mapped range. - * @param toEnd the end of the value's mapped range. - * @return the mapped value. - */ -static inline long map(long value, long fromStart, long fromEnd, - long toStart, long toEnd) { - return (value - fromStart) * (toEnd - toStart) / (fromEnd - fromStart) + - toStart; -} - -#define PI 3.1415926535897932384626433832795 -#define HALF_PI 1.5707963267948966192313216916398 -#define TWO_PI 6.283185307179586476925286766559 -#define DEG_TO_RAD 0.017453292519943295769236907684886 -#define RAD_TO_DEG 57.295779513082320876798154814105 - - -/* - * Roger Clark 20141113 - * - * Added BitOrder definition from SAM wiring_constants.h, as its needed for SPI - * as Maple doesn't have a wiring_constants file (though it probably should have in the long term to make it more compatible with the Arduino 1.0 + API - * also added definition for EULER and SERIAL and DISPLAY, also from the same SAM header - */ - -#define EULER 2.718281828459045235360287471352 -#define SERIAL 0x0 -#define DISPLAY 0x1 - -#define min(a,b) ((a)<(b)?(a):(b)) -#define max(a,b) ((a)>(b)?(a):(b)) -#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) -#define radians(deg) ((deg)*DEG_TO_RAD) -#define degrees(rad) ((rad)*RAD_TO_DEG) -#define sq(x) ((x)*(x)) - -/* undefine stdlib's abs if encountered */ -#ifdef abs -#undef abs -#endif -#define abs(x) (((x) > 0) ? (x) : -(x)) - -/* Following are duplicate declarations (with Doxygen comments) for - * some of the math.h functions; this is for the convenience of the - * Sphinx docs. - */ - -/** - * Compute the cosine of an angle, in radians. - * @param x The radian measure of the angle. - * @return The cosine of x. This value will be between -1 and 1. - */ -double cos(double x); - -/** - * Compute the sine of an angle, in radians. - * @param x The radian measure of the angle. - * @return The sine of x. This value will be between -1 and 1. - */ -double sin(double x); - -/** - * Compute the tangent of an angle, in radians. - * @param x The radian measure of the angle. - * @return The tangent of x. There are no limits on the return value - * of this function. - */ -double tan(double x); - -/** - * Compute the square root of a number. - * @param x The number whose square root to find. This value cannot - * be negative. - * @return The square root of x. The return value is never negative. - */ -double sqrt(double x); - -/** - * Compute an exponentiation. - * @param x the base. This value cannot be zero if y <= 0. This value - * cannot be negative if y is not an integral value. - * @param y the exponent. - * @return x raised to the power y. - */ -double pow(double x, double y); - -#endif diff --git a/GD32F1/cores/maple/wirish_shift.cpp b/GD32F1/cores/maple/wirish_shift.cpp deleted file mode 100644 index 2825507..0000000 --- a/GD32F1/cores/maple/wirish_shift.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#include "wirish.h" - -void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 value) { - digitalWrite(clockPin, LOW); - for (int i = 0; i < 8; i++) { - int bit = bitOrder == LSBFIRST ? i : (7 - i); - digitalWrite(dataPin, (value >> bit) & 0x1); - gpio_toggle_bit(PIN_MAP[clockPin].gpio_device, PIN_MAP[clockPin].gpio_bit);// togglePin(clockPin); - gpio_toggle_bit(PIN_MAP[clockPin].gpio_device, PIN_MAP[clockPin].gpio_bit);// togglePin(clockPin); - } -} diff --git a/GD32F1/cores/maple/wirish_time.cpp b/GD32F1/cores/maple/wirish_time.cpp deleted file mode 100644 index 5faa1e4..0000000 --- a/GD32F1/cores/maple/wirish_time.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @brief Delay implementation. - */ - -#include "wirish_time.h" - -#include -#include - -void delay(unsigned long ms) { - uint32 i; - for (i = 0; i < ms; i++) { - delayMicroseconds(1000); - } -} - -void delayMicroseconds(uint32 us) { - delay_us(us); -} diff --git a/GD32F1/cores/maple/wirish_time.h b/GD32F1/cores/maple/wirish_time.h deleted file mode 100644 index 1703957..0000000 --- a/GD32F1/cores/maple/wirish_time.h +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/wirish_time.h - * @brief Timing and delay functions. - */ - -#ifndef _WIRISH_WIRISH_TIME_H_ -#define _WIRISH_WIRISH_TIME_H_ - -#include -#include - -#include - -/** - * Returns time (in milliseconds) since the beginning of program - * execution. On overflow, restarts at 0. - * @see micros() - */ -static inline uint32 millis(void) { - return systick_uptime(); -} - -/** - * Returns time (in microseconds) since the beginning of program - * execution. On overflow, restarts at 0. - * @see millis() - */ -static inline uint32 micros(void) { - uint32 ms; - uint32 cycle_cnt; - - do { - ms = millis(); - cycle_cnt = systick_get_count(); - asm volatile("nop"); //allow interrupt to fire - asm volatile("nop"); - } while (ms != millis()); - -#define US_PER_MS 1000 - /* SYSTICK_RELOAD_VAL is 1 less than the number of cycles it - * actually takes to complete a SysTick reload */ - return ((ms * US_PER_MS) + - (SYSTICK_RELOAD_VAL + 1 - cycle_cnt) / CYCLES_PER_MICROSECOND); -#undef US_PER_MS -} - -/** - * Delay for at least the given number of milliseconds. - * - * Interrupts, etc. may cause the actual number of milliseconds to - * exceed ms. However, this function will return no less than ms - * milliseconds from the time it is called. - * - * @param ms the number of milliseconds to delay. - * @see delayMicroseconds() - */ -void delay(unsigned long ms); - -/** - * Delay for at least the given number of microseconds. - * - * Interrupts, etc. may cause the actual number of microseconds to - * exceed us. However, this function will return no less than us - * microseconds from the time it is called. - * - * @param us the number of microseconds to delay. - * @see delay() - */ -void delayMicroseconds(uint32 us); - -#endif diff --git a/GD32F1/cores/maple/wirish_types.h b/GD32F1/cores/maple/wirish_types.h deleted file mode 100644 index f1ae4a0..0000000 --- a/GD32F1/cores/maple/wirish_types.h +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/wirish_types.h - * @author Marti Bolivar - * @brief Wirish library type definitions. - */ - -#ifndef _WIRISH_WIRISH_TYPES_H_ -#define _WIRISH_WIRISH_TYPES_H_ - -#include -#include -#include -#include - -/** - * Invalid stm32_pin_info adc_channel value. - * @see stm32_pin_info - */ -#define ADCx 0xFF - -/** - * @brief Stores STM32-specific information related to a given Maple pin. - * @see PIN_MAP - */ -typedef struct stm32_pin_info { - gpio_dev *gpio_device; /**< Maple pin's GPIO device */ - timer_dev *timer_device; /**< Pin's timer device, if any. */ - const adc_dev *adc_device; /**< ADC device, if any. */ - uint8 gpio_bit; /**< Pin's GPIO port bit. */ - uint8 timer_channel; /**< Timer channel, or 0 if none. */ - uint8 adc_channel; /**< Pin ADC channel, or ADCx if none. */ - uint8 pinMode; /**< mode specific by pinMode call (Roger Clark added to optimize compatibility with Arduino API*/ -} stm32_pin_info; - -/** - * Variable attribute, instructs the linker to place the marked - * variable in Flash instead of RAM. */ -#define __FLASH__ __attr_flash - -typedef bool boolean; -typedef uint8 byte; - -#endif diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Adafruit_GFX_AS.cpp b/GD32F1/libraries/Adafruit_GFX_AS/Adafruit_GFX_AS.cpp deleted file mode 100644 index 333b122..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Adafruit_GFX_AS.cpp +++ /dev/null @@ -1,815 +0,0 @@ -/* -This is the core graphics library for all our displays, providing a common -set of graphics primitives (points, lines, circles, etc.). It needs to be -paired with a hardware-specific library for each display device we carry -(to handle the lower-level functions). - -Adafruit invests time and resources providing this open source code, please -support Adafruit & open-source hardware by purchasing products from Adafruit! - -Copyright (c) 2013 Adafruit Industries. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "Adafruit_GFX_AS.h" - -#ifdef LOAD_GLCD - #include "glcdfont.c" -#endif - -#ifdef LOAD_FONT2 - #include "Font16.h" -#endif - -#ifdef LOAD_FONT4 -#include "Font32.h" -#endif - -#ifdef LOAD_FONT6 -#include "Font64.h" -#endif - -#ifdef LOAD_FONT7 - #include "Font7s.h" -#endif - -#ifdef __AVR__ - #include -#else - #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) -#endif - -Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h): - WIDTH(w), HEIGHT(h) -{ - _width = WIDTH; - _height = HEIGHT; - rotation = 0; - cursor_y = cursor_x = 0; - textsize = 1; - textcolor = textbgcolor = 0xFFFF; - wrap = true; -} - -// Draw a circle outline -void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r, - uint16_t color) { - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - drawPixel(x0 , y0+r, color); - drawPixel(x0 , y0-r, color); - drawPixel(x0+r, y0 , color); - drawPixel(x0-r, y0 , color); - - while (x= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - drawPixel(x0 + x, y0 + y, color); - drawPixel(x0 - x, y0 + y, color); - drawPixel(x0 + x, y0 - y, color); - drawPixel(x0 - x, y0 - y, color); - drawPixel(x0 + y, y0 + x, color); - drawPixel(x0 - y, y0 + x, color); - drawPixel(x0 + y, y0 - x, color); - drawPixel(x0 - y, y0 - x, color); - } -} - -void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0, - int16_t r, uint8_t cornername, uint16_t color) { - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - while (x= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - if (cornername & 0x4) { - drawPixel(x0 + x, y0 + y, color); - drawPixel(x0 + y, y0 + x, color); - } - if (cornername & 0x2) { - drawPixel(x0 + x, y0 - y, color); - drawPixel(x0 + y, y0 - x, color); - } - if (cornername & 0x8) { - drawPixel(x0 - y, y0 + x, color); - drawPixel(x0 - x, y0 + y, color); - } - if (cornername & 0x1) { - drawPixel(x0 - y, y0 - x, color); - drawPixel(x0 - x, y0 - y, color); - } - } -} - -void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r, - uint16_t color) { - drawFastVLine(x0, y0-r, 2*r+1, color); - fillCircleHelper(x0, y0, r, 3, 0, color); -} - -// Used to do circles and roundrects -void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r, - uint8_t cornername, int16_t delta, uint16_t color) { - - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - while (x= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - if (cornername & 0x1) { - drawFastVLine(x0+x, y0-y, 2*y+1+delta, color); - drawFastVLine(x0+y, y0-x, 2*x+1+delta, color); - } - if (cornername & 0x2) { - drawFastVLine(x0-x, y0-y, 2*y+1+delta, color); - drawFastVLine(x0-y, y0-x, 2*x+1+delta, color); - } - } -} - -// Bresenham's algorithm - thx wikpedia -void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, - int16_t x1, int16_t y1, - uint16_t color) { - int16_t steep = abs(y1 - y0) > abs(x1 - x0); - if (steep) { - swap(x0, y0); - swap(x1, y1); - } - - if (x0 > x1) { - swap(x0, x1); - swap(y0, y1); - } - - int16_t dx, dy; - dx = x1 - x0; - dy = abs(y1 - y0); - - int16_t err = dx / 2; - int16_t ystep; - - if (y0 < y1) { - ystep = 1; - } else { - ystep = -1; - } - - for (; x0<=x1; x0++) { - if (steep) { - drawPixel(y0, x0, color); - } else { - drawPixel(x0, y0, color); - } - err -= dy; - if (err < 0) { - y0 += ystep; - err += dx; - } - } -} - -// Draw a rectangle -void Adafruit_GFX::drawRect(int16_t x, int16_t y, - int16_t w, int16_t h, - uint16_t color) { - drawFastHLine(x, y, w, color); - drawFastHLine(x, y+h-1, w, color); - drawFastVLine(x, y, h, color); - drawFastVLine(x+w-1, y, h, color); -} - -void Adafruit_GFX::drawFastVLine(int16_t x, int16_t y, - int16_t h, uint16_t color) { - // Update in subclasses if desired! - drawLine(x, y, x, y+h-1, color); -} - -void Adafruit_GFX::drawFastHLine(int16_t x, int16_t y, - int16_t w, uint16_t color) { - // Update in subclasses if desired! - drawLine(x, y, x+w-1, y, color); -} - -void Adafruit_GFX::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color) { - // Update in subclasses if desired! - for (int16_t i=x; i= y1 >= y0) - if (y0 > y1) { - swap(y0, y1); swap(x0, x1); - } - if (y1 > y2) { - swap(y2, y1); swap(x2, x1); - } - if (y0 > y1) { - swap(y0, y1); swap(x0, x1); - } - - if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing - a = b = x0; - if(x1 < a) a = x1; - else if(x1 > b) b = x1; - if(x2 < a) a = x2; - else if(x2 > b) b = x2; - drawFastHLine(a, y0, b-a+1, color); - return; - } - - int16_t - dx01 = x1 - x0, - dy01 = y1 - y0, - dx02 = x2 - x0, - dy02 = y2 - y0, - dx12 = x2 - x1, - dy12 = y2 - y1, - sa = 0, - sb = 0; - - // For upper part of triangle, find scanline crossings for segments - // 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1 - // is included here (and second loop will be skipped, avoiding a /0 - // error there), otherwise scanline y1 is skipped here and handled - // in the second loop...which also avoids a /0 error here if y0=y1 - // (flat-topped triangle). - if(y1 == y2) last = y1; // Include y1 scanline - else last = y1-1; // Skip it - - for(y=y0; y<=last; y++) { - a = x0 + sa / dy01; - b = x0 + sb / dy02; - sa += dx01; - sb += dx02; - /* longhand: - a = x0 + (x1 - x0) * (y - y0) / (y1 - y0); - b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); - */ - if(a > b) swap(a,b); - drawFastHLine(a, y, b-a+1, color); - } - - // For lower part of triangle, find scanline crossings for segments - // 0-2 and 1-2. This loop is skipped if y1=y2. - sa = dx12 * (y - y1); - sb = dx02 * (y - y0); - for(; y<=y2; y++) { - a = x1 + sa / dy12; - b = x0 + sb / dy02; - sa += dx12; - sb += dx02; - /* longhand: - a = x1 + (x2 - x1) * (y - y1) / (y2 - y1); - b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); - */ - if(a > b) swap(a,b); - drawFastHLine(a, y, b-a+1, color); - } -} - -void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, - const uint8_t *bitmap, int16_t w, int16_t h, - uint16_t color) { - - int16_t i, j, byteWidth = (w + 7) / 8; - - for(j=0; j> (i & 7))) { - drawPixel(x+i, y+j, color); - } - } - } -} - -//#if ARDUINO >= 100 -size_t Adafruit_GFX::write(uint8_t c) { -//#else -//void Adafruit_GFX::write(uint8_t c) { -//#endif - if (c == '\n') { - cursor_y += textsize*8; - cursor_x = 0; - } else if (c == '\r') { - // skip em - } else { - drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize); - cursor_x += textsize*6; - if (wrap && (cursor_x > (_width - textsize*6))) { - cursor_y += textsize*8; - cursor_x = 0; - } - } -//#if ARDUINO >= 100 - return 1; -//#endif -} - -// Draw a character -void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c, - uint16_t color, uint16_t bg, uint8_t size) { -#ifdef LOAD_GLCD - if((x >= _width) || // Clip right - (y >= _height) || // Clip bottom - ((x + 6 * size - 1) < 0) || // Clip left - ((y + 8 * size - 1) < 0)) // Clip top - return; - - for (int8_t i=0; i<6; i++ ) { - uint8_t line; - if (i == 5) - line = 0x0; - else - line = pgm_read_byte(font+(c*5)+i); - for (int8_t j = 0; j<8; j++) { - if (line & 0x1) { - if (size == 1) // default size - drawPixel(x+i, y+j, color); - else { // big size - fillRect(x+(i*size), y+(j*size), size, size, color); - } - } else if (bg != color) { - if (size == 1) // default size - drawPixel(x+i, y+j, bg); - else { // big size - fillRect(x+i*size, y+j*size, size, size, bg); - } - } - line >>= 1; - } - } -#endif -} - -void Adafruit_GFX::setCursor(int16_t x, int16_t y) { - cursor_x = x; - cursor_y = y; -} - -void Adafruit_GFX::setTextSize(uint8_t s) { - textsize = (s > 0) ? s : 1; -} - -void Adafruit_GFX::setTextColor(uint16_t c) { - // For 'transparent' background, we'll set the bg - // to the same as fg instead of using a flag - textcolor = textbgcolor = c; -} - -void Adafruit_GFX::setTextColor(uint16_t c, uint16_t b) { - textcolor = c; - textbgcolor = b; -} - -void Adafruit_GFX::setTextWrap(boolean w) { - wrap = w; -} - -uint8_t Adafruit_GFX::getRotation(void) { - return rotation; -} - -void Adafruit_GFX::setRotation(uint8_t x) { - rotation = (x & 3); - switch(rotation) { - case 0: - case 2: - _width = WIDTH; - _height = HEIGHT; - break; - case 1: - case 3: - _width = HEIGHT; - _height = WIDTH; - break; - } -} - -// Return the size of the display (per current rotation) -int16_t Adafruit_GFX::width(void) { - return _width; -} - -int16_t Adafruit_GFX::height(void) { - return _height; -} - -void Adafruit_GFX::invertDisplay(boolean i) { - // Do nothing, must be subclassed if supported -} - -/*************************************************************************************** -** Function name: drawUnicode -** Descriptions: draw a unicode -***************************************************************************************/ -int16_t Adafruit_GFX::drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size) -{ - - if (size) uniCode -= 32; - - uint16_t width = 0; - uint16_t height = 0; - uint32_t flash_address = 0; - int16_t gap = 0; - -// if (size == 1) { -// flash_address = pgm_read_dword(&chrtbl_f8[uniCode]); -// width = pgm_read_byte(widtbl_f8+uniCode); -// height = chr_hgt_f8; -// gap = 1; -// } -#ifdef LOAD_FONT2 - if (size == 2) { - flash_address = pgm_read_dword(&chrtbl_f16[uniCode]); - width = pgm_read_byte(widtbl_f16+uniCode); - height = chr_hgt_f16; - gap = 1; - } -#endif -// if (size == 3) { -// flash_address = pgm_read_dword(&chrtbl_f24[uniCode]); -// width = pgm_read_byte(widtbl_f24+uniCode); -// height = chr_hgt_f24; -// gap = 0; -// } -#ifdef LOAD_FONT4 - if (size == 4) { - flash_address = pgm_read_dword(&chrtbl_f32[uniCode]); - width = pgm_read_byte(widtbl_f32+uniCode); - height = chr_hgt_f32; - gap = -3; - } -#endif -// if (size == 5) { -// flash_address = pgm_read_dword(&chrtbl_f48[uniCode]); -// width = pgm_read_byte(widtbl_f48+uniCode); -// height = chr_hgt_f48; -// gap = -3; -// } -#ifdef LOAD_FONT6 - if (size == 6) { - flash_address = pgm_read_dword(&chrtbl_f64[uniCode]); - width = pgm_read_byte(widtbl_f64+uniCode); - height = chr_hgt_f64; - gap = -3; - } -#endif -#ifdef LOAD_FONT7 - if (size == 7) { - flash_address = pgm_read_dword(&chrtbl_f7s[uniCode]); - width = pgm_read_byte(widtbl_f7s+uniCode); - height = chr_hgt_f7s; - gap = 2; - } -#endif - -int16_t w = (width+7)/8; -int16_t pX = 0; -int16_t pY = y; -int16_t color = 0; -byte line = 0; - -//fillRect(x,pY,width+gap,height,textbgcolor); - -for(int16_t i=0; i0) - { - xPlus = drawChar('.',poX, poY, size); - poX += xPlus; /* Move cursor right */ - sumX += xPlus; - } - else - { - return sumX; - } - - decy = floatNumber - temp; - for(unsigned char i=0; i= 100 - #include "Arduino.h" - #include "Print.h" -#else - #include "WProgram.h" -#endif - -#define swap(a, b) { int16_t t = a; a = b; b = t; } - -class Adafruit_GFX : public Print { - - public: - - Adafruit_GFX(int16_t w, int16_t h); // Constructor - - // This MUST be defined by the subclass: - virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; - - // These MAY be overridden by the subclass to provide device-specific - // optimized code. Otherwise 'generic' versions are used. - virtual void - drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), - drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), - drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), - drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), - fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), - fillScreen(uint16_t color), - invertDisplay(boolean i); - - // These exist only with Adafruit_GFX (no subclass overrides) - void - drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), - drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, - uint16_t color), - fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), - fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, - int16_t delta, uint16_t color), - drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, - int16_t x2, int16_t y2, uint16_t color), - fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, - int16_t x2, int16_t y2, uint16_t color), - drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, - int16_t radius, uint16_t color), - fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, - int16_t radius, uint16_t color), - drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, - int16_t w, int16_t h, uint16_t color), - drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, - uint16_t bg, uint8_t size), - setCursor(int16_t x, int16_t y), - setTextColor(uint16_t c), - setTextColor(uint16_t c, uint16_t bg), - setTextSize(uint8_t s), - setTextWrap(boolean w), - setRotation(uint8_t r); - - int16_t drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size); - int16_t drawNumber(long long_num,int16_t poX, int16_t poY, int16_t size); - int16_t drawChar(char c, int16_t x, int16_t y, int16_t size); - int16_t drawString(char *string, int16_t poX, int16_t poY, int16_t size); - int16_t drawCentreString(char *string, int16_t dX, int16_t poY, int16_t size); - int16_t drawRightString(char *string, int16_t dX, int16_t poY, int16_t size); - int16_t drawFloat(float floatNumber,int16_t decimal,int16_t poX, int16_t poY, int16_t size); - -#if ARDUINO >= 100 - virtual size_t write(uint8_t); -#else - virtual void write(uint8_t); -#endif - - int16_t - height(void), - width(void); - - uint8_t getRotation(void); - - protected: - const int16_t - WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes - int16_t - _width, _height, // Display w/h as modified by current rotation - cursor_x, cursor_y; - uint16_t - textcolor, textbgcolor; - uint8_t - textsize, - rotation; - boolean - wrap; // If set, 'wrap' text at right edge of display -}; - -#endif // _ADAFRUIT_GFX_H diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Font16.c b/GD32F1/libraries/Adafruit_GFX_AS/Font16.c deleted file mode 100644 index 59eee01..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Font16.c +++ /dev/null @@ -1,527 +0,0 @@ -// Font size 2 - -#include "Font16.h" -//#include -#ifdef __AVR__ - #include - #include -#else - #define PROGMEM -#endif - -PROGMEM const unsigned char widtbl_f16[96] = // character width table -{ - 5, 2, 3, 8, 7, 8, 8, 2, // char 32 - 39 - 6, 6, 7, 5, 2, 5, 4, 6, // char 40 - 47 - 7, 7, 7, 7, 7, 7, 7, 7, // char 48 - 55 - 7, 7, 2, 2, 5, 5, 5, 7, // char 56 - 63 - 8, 7, 7, 7, 7, 7, 7, 7, // char 64 - 71 - 6, 3, 7, 7, 6, 9, 7, 7, // char 72 - 79 - 7, 7, 7, 7, 7, 7, 7, 9, // char 80 - 87 - 7, 7, 7, 3, 6, 3, 7, 8, // char 88 - 95 - 3, 6, 6, 6, 6, 6, 5, 6, // char 96 - 103 - 6, 4, 4, 5, 4, 7, 6, 7, // char 104 - 111 - 6, 7, 5, 5, 4, 6, 7, 7, // char 112 - 119 - 5, 6, 6, 4, 2, 4, 7, 5 // char 120 - 127 -}; - -// Row format, MSB left - -PROGMEM const unsigned char chr_f16_20[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_21[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // row 1 - 11 - 0x00, 0x40, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_22[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0xA0, 0xA0, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_23[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0xFF, 0x24, 0x24, 0xFF, 0x24, // row 1 - 11 - 0x24, 0x24, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_24[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x40, 0x70, 0x40, 0x70, 0x40, // row 1 - 11 - 0x40, 0xFE, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_25[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x61, 0x91, 0x92, 0x64, 0x08, 0x10, 0x26, 0x49, // row 1 - 11 - 0x89, 0x86, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_26[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x20, 0x50, 0x88, 0x88, 0x50, 0x20, 0x52, 0x8C, // row 1 - 11 - 0x8C, 0x73, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_27[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_28[16] = // 1 unsigned char per row -{ - 0x00, 0x0C, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80, 0x80, // row 1 - 11 - 0x40, 0x40, 0x20, 0x10, 0x0C // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_29[16] = // 1 unsigned char per row -{ - 0x00, 0xC0, 0x20, 0x10, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, // row 1 - 11 - 0x08, 0x08, 0x10, 0x20, 0xC0 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_2A[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x10, 0x92, 0x54, 0x38, 0x54, 0x92, 0x10, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_2B[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0xF8, 0x20, 0x20, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_2C[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0xC0, 0xC0, 0x40, 0x80, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_2D[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_2E[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0xC0, 0xC0, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_2F[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, // row 1 - 11 - 0x40, 0x80, 0x80, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_30[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x82, 0x82, 0x82, 0x82, 0x44, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_31[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x10, 0x10, // row 1 - 11 - 0x10, 0x7C, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_32[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x38, 0x44, 0x82, 0x02, 0x04, 0x18, 0x20, 0x40, // row 1 - 11 - 0x80, 0xFE, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_33[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x78, 0x84, 0x02, 0x04, 0x38, 0x04, 0x02, 0x02, // row 1 - 11 - 0x84, 0x78, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_34[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x04, 0x0C, 0x14, 0x24, 0x44, 0x84, 0xFE, 0x04, // row 1 - 11 - 0x04, 0x04, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_35[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xFC, 0x80, 0x80, 0x80, 0xF8, 0x04, 0x02, 0x02, // row 1 - 11 - 0x84, 0x78, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_36[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x3C, 0x40, 0x80, 0x80, 0xB8, 0xC4, 0x82, 0x82, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_37[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, // row 1 - 11 - 0x10, 0x10, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_38[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x38, 0x44, 0x82, 0x44, 0x38, 0x44, 0x82, 0x82, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_39[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x38, 0x44, 0x82, 0x82, 0x46, 0x3A, 0x02, 0x02, // row 1 - 11 - 0x04, 0x78, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_3A[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_3B[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, // row 1 - 11 - 0x40, 0x80, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_3C[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, // row 1 - 11 - 0x10, 0x08, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_3D[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0xF8, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_3E[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x10, 0x20, // row 1 - 11 - 0x40, 0x80, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_3F[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x38, 0x44, 0x82, 0x02, 0x04, 0x08, 0x10, 0x10, // row 1 - 11 - 0x00, 0x10, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_40[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x3C, 0x42, 0x99, 0xA5, 0xA5, 0xA5, 0xA5, 0x9E, // row 1 - 11 - 0x40, 0x3E, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_41[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x10, 0x10, 0x28, 0x28, 0x44, 0x44, 0x7C, 0x82, // row 1 - 11 - 0x82, 0x82, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_42[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xF8, 0x84, 0x82, 0x84, 0xF8, 0x84, 0x82, 0x82, // row 1 - 11 - 0x84, 0xF8, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_43[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x3C, 0x42, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // row 1 - 11 - 0x42, 0x3C, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_44[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xF8, 0x84, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, // row 1 - 11 - 0x84, 0xF8, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_45[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xFE, 0x80, 0x80, 0x80, 0xFC, 0x80, 0x80, 0x80, // row 1 - 11 - 0x80, 0xFE, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_46[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xFE, 0x80, 0x80, 0x80, 0xF8, 0x80, 0x80, 0x80, // row 1 - 11 - 0x80, 0x80, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_47[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x3C, 0x42, 0x80, 0x80, 0x80, 0x9C, 0x82, 0x82, // row 1 - 11 - 0x42, 0x3C, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_48[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0xFC, 0x84, 0x84, 0x84, // row 1 - 11 - 0x84, 0x84, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_49[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xE0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // row 1 - 11 - 0x40, 0xE0, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_4A[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_4B[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x84, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88, // row 1 - 11 - 0x84, 0x82, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_4C[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // row 1 - 11 - 0x80, 0xFC, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_4D[32] = // 2 unsigned chars per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC1, 0x80, 0xC1, 0x80, 0xA2, 0x80, // row 1 - 6 - 0xA2, 0x80, 0x94, 0x80, 0x94, 0x80, 0x88, 0x80, 0x88, 0x80, 0x80, 0x80, // row 7 - 12 - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 13 - 16 -}; -PROGMEM const unsigned char chr_f16_4E[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xC2, 0xC2, 0xA2, 0xA2, 0x92, 0x92, 0x8A, 0x8A, // row 1 - 11 - 0x86, 0x86, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_4F[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x38, 0x44, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_50[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xF8, 0x84, 0x82, 0x82, 0x82, 0x84, 0xF8, 0x80, // row 1 - 11 - 0x80, 0x80, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_51[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x38, 0x44, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, // row 1 - 11 - 0x44, 0x38, 0x08, 0x06, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_52[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xF8, 0x84, 0x82, 0x82, 0x84, 0xF8, 0x90, 0x88, // row 1 - 11 - 0x84, 0x82, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_53[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x38, 0x44, 0x82, 0x80, 0x60, 0x1C, 0x02, 0x82, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_54[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // row 1 - 11 - 0x10, 0x10, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_55[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_56[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x82, 0x82, 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, // row 1 - 11 - 0x10, 0x10, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_57[32] = // 2 unsigned chars per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // row 1 - 6 - 0x88, 0x80, 0x88, 0x80, 0x49, 0x00, 0x55, 0x00, 0x55, 0x00, 0x22, 0x00, // row 7 - 12 - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 13 - 16 -}; -PROGMEM const unsigned char chr_f16_58[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, // row 1 - 11 - 0x82, 0x82, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_59[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x82, 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, // row 1 - 11 - 0x10, 0x10, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_5A[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xFE, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x40, // row 1 - 11 - 0x80, 0xFE, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_5B[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0xE0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // row 1 - 11 - 0x80, 0x80, 0xE0, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_5C[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, // row 1 - 11 - 0x40, 0x80, 0x80, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_5D[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // row 1 - 11 - 0x20, 0x20, 0xE0, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_5E[32] = // 1 unsigned chars per row -{ - 0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_5F[32] = // 1 unsigned chars per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0xFF, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_60[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_61[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x08, 0x04, 0x74, 0x8C, // row 1 - 11 - 0x8C, 0x74, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_62[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xB0, 0xC8, 0x84, 0x84, 0x84, // row 1 - 11 - 0xC8, 0xB0, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_63[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x80, 0x80, 0x80, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_64[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x34, 0x4C, 0x84, 0x84, 0x84, // row 1 - 11 - 0x4C, 0x34, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_65[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x84, 0xF8, 0x80, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_66[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x30, 0x48, 0x40, 0x40, 0x40, 0xE0, 0x40, 0x40, // row 1 - 11 - 0x40, 0x40, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_67[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x4C, 0x84, 0x84, 0x84, // row 1 - 11 - 0x4C, 0x34, 0x04, 0x08, 0x70 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_68[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xB0, 0xC8, 0x84, 0x84, 0x84, // row 1 - 11 - 0x84, 0x84, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_69[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, // row 1 - 11 - 0x40, 0x40, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_6A[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, // row 1 - 11 - 0x10, 0x10, 0x10, 0x90, 0x60 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_6B[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x88, 0x90, 0xA0, 0xC0, 0xA0, // row 1 - 11 - 0x90, 0x88, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_6C[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0xC0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // row 1 - 11 - 0x40, 0x40, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_6D[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAC, 0xD2, 0x92, 0x92, 0x92, // row 1 - 11 - 0x92, 0x92, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_6E[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xC8, 0x84, 0x84, 0x84, // row 1 - 11 - 0x84, 0x84, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_6F[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x82, 0x82, 0x82, // row 1 - 11 - 0x44, 0x38, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_70[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xC8, 0x84, 0x84, 0x84, // row 1 - 11 - 0xC8, 0xB0, 0x80, 0x80, 0x80 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_71[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x4C, 0x84, 0x84, 0x84, // row 1 - 11 - 0x4C, 0x34, 0x04, 0x04, 0x06 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_72[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xC8, 0x80, 0x80, 0x80, // row 1 - 11 - 0x80, 0x80, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_73[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x88, 0x80, 0x70, 0x08, // row 1 - 11 - 0x88, 0x70, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_74[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x40, 0x40, // row 1 - 11 - 0x40, 0x30, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_75[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x84, // row 1 - 11 - 0x4C, 0x34, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_76[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x82, 0x82, 0x82, 0x44, // row 1 - 11 - 0x28, 0x10, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_77[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x82, 0x82, 0x92, 0x92, // row 1 - 11 - 0xAA, 0x44, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_78[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x50, 0x20, 0x50, // row 1 - 11 - 0x88, 0x88, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_79[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x84, // row 1 - 11 - 0x4C, 0x34, 0x04, 0x08, 0x70 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_7A[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x04, 0x08, 0x30, 0x40, // row 1 - 11 - 0x80, 0xFC, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_7B[16] = // 1 unsigned char per row -{ - 0x00, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x40, 0x20, 0x20, // row 1 - 11 - 0x20, 0x20, 0x20, 0x20, 0x10 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_7C[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // row 1 - 11 - 0x40, 0x40, 0x40, 0x40, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_7D[16] = // 1 unsigned char per row -{ - 0x00, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x20, 0x20, // row 1 - 11 - 0x20, 0x20, 0x20, 0x20, 0x40 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_7E[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x00, 0x32, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; -PROGMEM const unsigned char chr_f16_7F[16] = // 1 unsigned char per row -{ - 0x00, 0x00, 0x30, 0x48, 0x48, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 -}; - -PROGMEM const unsigned char* const chrtbl_f16[] = // character pointer table -{ - chr_f16_20, chr_f16_21, chr_f16_22, chr_f16_23, chr_f16_24, chr_f16_25, chr_f16_26, chr_f16_27, - chr_f16_28, chr_f16_29, chr_f16_2A, chr_f16_2B, chr_f16_2C, chr_f16_2D, chr_f16_2E, chr_f16_2F, - chr_f16_30, chr_f16_31, chr_f16_32, chr_f16_33, chr_f16_34, chr_f16_35, chr_f16_36, chr_f16_37, - chr_f16_38, chr_f16_39, chr_f16_3A, chr_f16_3B, chr_f16_3C, chr_f16_3D, chr_f16_3E, chr_f16_3F, - chr_f16_40, chr_f16_41, chr_f16_42, chr_f16_43, chr_f16_44, chr_f16_45, chr_f16_46, chr_f16_47, - chr_f16_48, chr_f16_49, chr_f16_4A, chr_f16_4B, chr_f16_4C, chr_f16_4D, chr_f16_4E, chr_f16_4F, - chr_f16_50, chr_f16_51, chr_f16_52, chr_f16_53, chr_f16_54, chr_f16_55, chr_f16_56, chr_f16_57, - chr_f16_58, chr_f16_59, chr_f16_5A, chr_f16_5B, chr_f16_5C, chr_f16_5D, chr_f16_5E, chr_f16_5F, - chr_f16_60, chr_f16_61, chr_f16_62, chr_f16_63, chr_f16_64, chr_f16_65, chr_f16_66, chr_f16_67, - chr_f16_68, chr_f16_69, chr_f16_6A, chr_f16_6B, chr_f16_6C, chr_f16_6D, chr_f16_6E, chr_f16_6F, - chr_f16_70, chr_f16_71, chr_f16_72, chr_f16_73, chr_f16_74, chr_f16_75, chr_f16_76, chr_f16_77, - chr_f16_78, chr_f16_79, chr_f16_7A, chr_f16_7B, chr_f16_7C, chr_f16_7D, chr_f16_7E, chr_f16_7F -}; diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Font16.h b/GD32F1/libraries/Adafruit_GFX_AS/Font16.h deleted file mode 100644 index 72922cd..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Font16.h +++ /dev/null @@ -1,7 +0,0 @@ -#define nr_chrs_f16 96 -#define chr_hgt_f16 16 -#define data_size_f16 8 -#define firstchr_f16 32 - -extern const unsigned char widtbl_f16[96]; -extern const unsigned char* const chrtbl_f16[96]; diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Font32.c b/GD32F1/libraries/Adafruit_GFX_AS/Font32.c deleted file mode 100644 index b044c1f..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Font32.c +++ /dev/null @@ -1,1033 +0,0 @@ -// Font size 4 - -#include "Font32.h" -//#include -#ifdef __AVR__ - #include - #include -#else - #define PROGMEM -#endif - -PROGMEM const unsigned char widtbl_f32[] = // character width table -{ - 8, 11, 11, 22, 17, 24, 20, 9, // char 32 - 39 - 11, 11, 15, 13, 10, 11, 10, 11, // char 40 - 47 - 17, 17, 17, 17, 17, 17, 17, 17, // char 48 - 55 - 17, 17, 10, 10, 17, 12, 17, 16, // char 56 - 63 - 28, 19, 20, 21, 21, 19, 18, 22, // char 64 - 71 - 21, 9, 16, 20, 16, 24, 21, 22, // char 72 - 79 - 19, 22, 20, 19, 17, 21, 18, 26, // char 80 - 87 - 18, 19, 19, 12, 16, 12, 15, 16, // char 88 - 95 - 9, 17, 18, 16, 18, 17, 11, 18, // char 96 - 103 - 18, 9, 9, 15, 9, 25, 18, 18, // char 104 - 111 - 18, 18, 11, 15, 10, 17, 15, 21, // char 112 - 119 - 16, 16, 15, 16, 16, 16, 18, 4 // char 120 - 127 -}; - -// Row format, MSB left - -PROGMEM const unsigned char chr_f32_20[] = // 1 byte per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 12 - 22 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 23 - 32 -}; -PROGMEM const unsigned char chr_f32_21[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 7 - 12 - 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 13 - 18 - 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x00, // row 19 - 24 - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_22[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, // row 7 - 12 - 0x24, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_23[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x66, 0x00, 0x00, 0x44, 0x00, 0x00, 0x44, 0x00, 0x00, 0xCC, 0x00, // row 9 - 12 - 0x00, 0x88, 0x00, 0x00, 0x88, 0x00, 0x1F, 0xFF, 0x80, 0x01, 0x10, 0x00, // row 13 - 16 - 0x01, 0x10, 0x00, 0x01, 0x10, 0x00, 0x3F, 0xFF, 0x00, 0x02, 0x20, 0x00, // row 17 - 20 - 0x02, 0x20, 0x00, 0x06, 0x60, 0x00, 0x04, 0x40, 0x00, 0x04, 0x40, 0x00, // row 21 - 24 - 0x0C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_24[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x0F, 0xC0, 0x00, 0x3F, 0xF0, 0x00, 0x38, 0x70, 0x00, 0x60, 0x18, 0x00, // row 9 - 12 - 0x60, 0x18, 0x00, 0x60, 0x00, 0x00, 0x70, 0x00, 0x00, 0x30, 0x00, 0x00, // row 13 - 16 - 0x7F, 0x80, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, // row 17 - 20 - 0x18, 0x00, 0x00, 0x30, 0x00, 0x00, 0x3F, 0x88, 0x00, 0x7F, 0xF8, 0x00, // row 21 - 24 - 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_25[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x0E, 0x01, 0x80, 0x3F, 0x81, 0x00, 0x31, 0x83, 0x00, 0x60, 0xC6, 0x00, // row 9 - 12 - 0x60, 0xC4, 0x00, 0x60, 0xCC, 0x00, 0x31, 0x88, 0x00, 0x3F, 0x90, 0x00, // row 13 - 16 - 0x0E, 0x31, 0xC0, 0x00, 0x27, 0xF0, 0x00, 0x46, 0x30, 0x00, 0xCC, 0x18, // row 17 - 20 - 0x00, 0x8C, 0x18, 0x01, 0x8C, 0x18, 0x03, 0x06, 0x30, 0x02, 0x07, 0xF0, // row 21 - 24 - 0x06, 0x01, 0xC0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_26[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, // row 5 - 8 - 0x0F, 0xE0, 0x00, 0x1C, 0x70, 0x00, 0x18, 0x30, 0x00, 0x18, 0x30, 0x00, // row 9 - 12 - 0x18, 0x70, 0x00, 0x0C, 0xE0, 0x00, 0x07, 0xC0, 0x00, 0x0F, 0x00, 0x00, // row 13 - 16 - 0x1F, 0x86, 0x00, 0x39, 0xC6, 0x00, 0x70, 0xE6, 0x00, 0x60, 0x7C, 0x00, // row 17 - 20 - 0x60, 0x3C, 0x00, 0x60, 0x18, 0x00, 0x70, 0x7E, 0x00, 0x3F, 0xE7, 0x00, // row 21 - 24 - 0x1F, 0x83, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_27[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x10, 0x00, 0x30, 0x00, // row 7 - 12 - 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_28[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x06, 0x00, 0x04, 0x00, 0x0C, 0x00, // row 7 - 12 - 0x0C, 0x00, 0x0C, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 13 - 18 - 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 19 - 24 - 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x06, 0x00, 0x02, 0x00, // row 25 - 30 - 0x03, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_29[] = // 2 bytes per row -{ - 0x00, 0x00, 0xC0, 0x00, 0x40, 0x00, 0x60, 0x00, 0x20, 0x00, 0x30, 0x00, // row 7 - 12 - 0x30, 0x00, 0x30, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 13 - 18 - 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 19 - 24 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x20, 0x00, 0x60, 0x00, 0x40, 0x00, // row 25 - 30 - 0xC0, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_2A[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x26, 0x40, 0x7F, 0xE0, // row 7 - 12 - 0x1F, 0x80, 0x0F, 0x00, 0x19, 0x80, 0x39, 0xC0, 0x10, 0x80, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_2B[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x7F, 0x80, // row 13 - 18 - 0x7F, 0x80, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_2C[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x38, 0x00, // row 19 - 24 - 0x38, 0x00, 0x08, 0x00, 0x18, 0x00, 0x10, 0x00, 0x30, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_2D[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, // row 13 - 18 - 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_2E[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x38, 0x00, // row 19 - 24 - 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_2F[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x06, 0x00, 0x06, 0x00, // row 7 - 12 - 0x04, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x08, 0x00, 0x18, 0x00, 0x18, 0x00, // row 13 - 18 - 0x10, 0x00, 0x30, 0x00, 0x30, 0x00, 0x20, 0x00, 0x60, 0x00, 0x60, 0x00, // row 19 - 24 - 0x40, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_30[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x07, 0x80, 0x00, 0x1F, 0xE0, 0x00, 0x3C, 0xF0, 0x00, 0x30, 0x30, 0x00, // row 9 - 12 - 0x70, 0x38, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, // row 13 - 16 - 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, // row 17 - 20 - 0x70, 0x38, 0x00, 0x30, 0x30, 0x00, 0x3C, 0xF0, 0x00, 0x1F, 0xE0, 0x00, // row 21 - 24 - 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_31[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x03, 0x80, 0x00, 0x1F, 0x80, 0x00, // row 9 - 12 - 0x1F, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, // row 13 - 16 - 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, // row 17 - 20 - 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, // row 21 - 24 - 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_32[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x0F, 0xC0, 0x00, 0x3F, 0xF0, 0x00, 0x38, 0x70, 0x00, 0x70, 0x18, 0x00, // row 9 - 12 - 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x38, 0x00, // row 13 - 16 - 0x00, 0xF0, 0x00, 0x03, 0xE0, 0x00, 0x0F, 0x80, 0x00, 0x1E, 0x00, 0x00, // row 17 - 20 - 0x38, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x00, 0x00, 0x7F, 0xF8, 0x00, // row 21 - 24 - 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_33[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x0F, 0xC0, 0x00, 0x1F, 0xE0, 0x00, 0x38, 0x70, 0x00, 0x30, 0x30, 0x00, // row 9 - 12 - 0x70, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x70, 0x00, 0x03, 0xE0, 0x00, // row 13 - 16 - 0x03, 0xF0, 0x00, 0x00, 0x38, 0x00, 0x00, 0x18, 0x00, 0x60, 0x18, 0x00, // row 17 - 20 - 0x60, 0x18, 0x00, 0x70, 0x38, 0x00, 0x38, 0x70, 0x00, 0x3F, 0xF0, 0x00, // row 21 - 24 - 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_34[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x60, 0x00, 0x00, 0xE0, 0x00, 0x01, 0xE0, 0x00, 0x01, 0xE0, 0x00, // row 9 - 12 - 0x03, 0x60, 0x00, 0x06, 0x60, 0x00, 0x0C, 0x60, 0x00, 0x0C, 0x60, 0x00, // row 13 - 16 - 0x18, 0x60, 0x00, 0x30, 0x60, 0x00, 0x60, 0x60, 0x00, 0x7F, 0xF8, 0x00, // row 17 - 20 - 0x7F, 0xF8, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00, // row 21 - 24 - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_35[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x3F, 0xF0, 0x00, 0x3F, 0xF0, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 9 - 12 - 0x30, 0x00, 0x00, 0x37, 0xC0, 0x00, 0x3F, 0xF0, 0x00, 0x78, 0x70, 0x00, // row 13 - 16 - 0x60, 0x38, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, // row 17 - 20 - 0x60, 0x18, 0x00, 0x70, 0x38, 0x00, 0x38, 0x70, 0x00, 0x3F, 0xF0, 0x00, // row 21 - 24 - 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_36[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x38, 0x30, 0x00, 0x30, 0x18, 0x00, // row 9 - 12 - 0x30, 0x18, 0x00, 0x60, 0x00, 0x00, 0x67, 0xC0, 0x00, 0x7F, 0xF0, 0x00, // row 13 - 16 - 0x78, 0x70, 0x00, 0x70, 0x38, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, // row 17 - 20 - 0x60, 0x18, 0x00, 0x30, 0x38, 0x00, 0x38, 0x70, 0x00, 0x1F, 0xF0, 0x00, // row 21 - 24 - 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_37[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x7F, 0xF8, 0x00, 0x7F, 0xF8, 0x00, 0x00, 0x30, 0x00, 0x00, 0x70, 0x00, // row 9 - 12 - 0x00, 0xE0, 0x00, 0x00, 0xC0, 0x00, 0x01, 0xC0, 0x00, 0x01, 0x80, 0x00, // row 13 - 16 - 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, // row 17 - 20 - 0x06, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x0C, 0x00, 0x00, // row 21 - 24 - 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_38[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x07, 0x80, 0x00, 0x1F, 0xE0, 0x00, 0x18, 0x60, 0x00, 0x30, 0x30, 0x00, // row 9 - 12 - 0x30, 0x30, 0x00, 0x30, 0x30, 0x00, 0x18, 0x60, 0x00, 0x0F, 0xC0, 0x00, // row 13 - 16 - 0x1F, 0xE0, 0x00, 0x38, 0x70, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, // row 17 - 20 - 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x38, 0x70, 0x00, 0x3F, 0xF0, 0x00, // row 21 - 24 - 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_39[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x0F, 0xC0, 0x00, 0x3F, 0xE0, 0x00, 0x38, 0x70, 0x00, 0x70, 0x30, 0x00, // row 9 - 12 - 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x70, 0x38, 0x00, // row 13 - 16 - 0x38, 0x78, 0x00, 0x3F, 0xF8, 0x00, 0x0F, 0x98, 0x00, 0x00, 0x18, 0x00, // row 17 - 20 - 0x60, 0x30, 0x00, 0x60, 0x30, 0x00, 0x30, 0x70, 0x00, 0x3F, 0xE0, 0x00, // row 21 - 24 - 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_3A[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x38, 0x00, // row 19 - 24 - 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_3B[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x38, 0x00, // row 19 - 24 - 0x38, 0x00, 0x08, 0x00, 0x18, 0x00, 0x10, 0x00, 0x30, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_3C[] = // 3 bytes per row -{ - // row 1 - 3 - // row 4 - 6 I I - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 9 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 10 - 12 - 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0xE0, 0x00, // row 13 - 15 - 0x07, 0x80, 0x00, 0x1C, 0x00, 0x00, 0x60, 0x00, 0x00, // row 16 - 18 - 0x1C, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xE0, 0x00, // row 19 - 21 - 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 22 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 27 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 28 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_3D[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_3E[] = // 4 bytes per row -{ - // row 1 - 3 - // row 4 - 6 I I - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 9 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 10 - 12 - 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x00, // row 13 - 15 - 0x07, 0x80, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x18, 0x00, // row 16 - 18 - 0x00, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x1C, 0x00, 0x00, // row 19 - 21 - 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 22 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 27 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 28 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_3F[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x0F, 0xC0, 0x3F, 0xE0, 0x38, 0x70, 0x70, 0x30, 0x60, 0x30, // row 7 - 12 - 0x60, 0x30, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x03, 0x00, // row 13 - 18 - 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, // row 19 - 24 - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_40[] = // 4 bytes per row -{ - // row 1 - 3 - // row 4 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x01, 0xC0, 0x70, 0x00, // row 7 - 9 - 0x07, 0x00, 0x18, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x18, 0x00, 0x06, 0x00, // row 10 - 12 - 0x10, 0x1E, 0x43, 0x00, 0x30, 0x63, 0xC3, 0x00, 0x30, 0xC1, 0x83, 0x00, // row 13 - 15 - 0x60, 0xC1, 0x83, 0x00, 0x61, 0x81, 0x83, 0x00, 0x61, 0x81, 0x83, 0x00, // row 16 - 18 - 0x61, 0x83, 0x06, 0x00, 0x61, 0x83, 0x06, 0x00, 0x61, 0x83, 0x0C, 0x00, // row 19 - 21 - 0x30, 0xC7, 0x18, 0x00, 0x30, 0x79, 0xF0, 0x00, 0x18, 0x00, 0x00, 0x00, // row 22 - 24 - 0x0C, 0x00, 0x00, 0x00, 0x06, 0x00, 0x18, 0x00, 0x03, 0x81, 0xE0, 0x00, // row 25 - 27 - 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 28 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_41[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 5 - 8 - 0x03, 0xC0, 0x00, 0x03, 0xC0, 0x00, 0x06, 0x60, 0x00, 0x06, 0x60, 0x00, // row 9 - 12 - 0x06, 0x60, 0x00, 0x0C, 0x30, 0x00, 0x0C, 0x30, 0x00, 0x0C, 0x30, 0x00, // row 13 - 16 - 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x1F, 0xF8, 0x00, 0x3F, 0xFC, 0x00, // row 17 - 20 - 0x30, 0x0C, 0x00, 0x30, 0x0C, 0x00, 0x60, 0x06, 0x00, 0x60, 0x06, 0x00, // row 21 - 24 - 0xE0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_42[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x3F, 0xF8, 0x00, // row 5 - 8 - 0x3F, 0xFE, 0x00, 0x30, 0x0E, 0x00, 0x30, 0x06, 0x00, 0x30, 0x06, 0x00, // row 9 - 12 - 0x30, 0x06, 0x00, 0x30, 0x06, 0x00, 0x30, 0x0E, 0x00, 0x3F, 0xF8, 0x00, // row 13 - 16 - 0x3F, 0xFE, 0x00, 0x30, 0x0E, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 17 - 20 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x0E, 0x00, 0x3F, 0xFE, 0x00, // row 21 - 24 - 0x3F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_43[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, // row 5 - 8 - 0x0F, 0xFE, 0x00, 0x1E, 0x0F, 0x00, 0x38, 0x03, 0x00, 0x30, 0x01, 0x80, // row 9 - 12 - 0x70, 0x01, 0x80, 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, // row 13 - 16 - 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x01, 0x80, 0x70, 0x01, 0x80, // row 17 - 20 - 0x30, 0x03, 0x80, 0x38, 0x03, 0x00, 0x1E, 0x0F, 0x00, 0x0F, 0xFE, 0x00, // row 21 - 24 - 0x03, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_44[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, // row 5 - 8 - 0x3F, 0xFC, 0x00, 0x30, 0x1E, 0x00, 0x30, 0x07, 0x00, 0x30, 0x03, 0x00, // row 9 - 12 - 0x30, 0x03, 0x80, 0x30, 0x01, 0x80, 0x30, 0x01, 0x80, 0x30, 0x01, 0x80, // row 13 - 16 - 0x30, 0x01, 0x80, 0x30, 0x01, 0x80, 0x30, 0x01, 0x80, 0x30, 0x03, 0x80, // row 17 - 20 - 0x30, 0x03, 0x00, 0x30, 0x07, 0x00, 0x30, 0x1E, 0x00, 0x3F, 0xFC, 0x00, // row 21 - 24 - 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_45[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x00, // row 5 - 8 - 0x3F, 0xFE, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 9 - 12 - 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x3F, 0xFC, 0x00, // row 13 - 16 - 0x3F, 0xFC, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 17 - 20 - 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x3F, 0xFE, 0x00, // row 21 - 24 - 0x3F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_46[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x00, // row 5 - 8 - 0x3F, 0xFC, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 9 - 12 - 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x3F, 0xF8, 0x00, // row 13 - 16 - 0x3F, 0xF8, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 17 - 20 - 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 21 - 24 - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_47[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, // row 5 - 8 - 0x0F, 0xFE, 0x00, 0x1C, 0x0F, 0x00, 0x38, 0x03, 0x00, 0x30, 0x03, 0x80, // row 9 - 12 - 0x70, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x7F, 0x80, // row 13 - 16 - 0x60, 0x7F, 0x80, 0x60, 0x01, 0x80, 0x60, 0x01, 0x80, 0x70, 0x01, 0x80, // row 17 - 20 - 0x30, 0x03, 0x80, 0x38, 0x07, 0x80, 0x1E, 0x0F, 0x80, 0x0F, 0xFD, 0x80, // row 21 - 24 - 0x03, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_48[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, // row 5 - 8 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 9 - 12 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x3F, 0xFF, 0x00, 0x3F, 0xFF, 0x00, // row 13 - 16 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 17 - 20 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 21 - 24 - 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_49[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 7 - 12 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 13 - 18 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 19 - 24 - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_4A[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, // row 7 - 12 - 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, // row 13 - 18 - 0x00, 0x60, 0xC0, 0x60, 0xC0, 0x60, 0xC0, 0x60, 0xE0, 0xE0, 0x7F, 0xC0, // row 19 - 24 - 0x3F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_4B[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x30, 0x07, 0x00, // row 5 - 8 - 0x30, 0x0E, 0x00, 0x30, 0x1C, 0x00, 0x30, 0x38, 0x00, 0x30, 0x70, 0x00, // row 9 - 12 - 0x30, 0xE0, 0x00, 0x31, 0xC0, 0x00, 0x33, 0x80, 0x00, 0x37, 0x80, 0x00, // row 13 - 16 - 0x3F, 0xC0, 0x00, 0x3C, 0xE0, 0x00, 0x38, 0x70, 0x00, 0x30, 0x30, 0x00, // row 17 - 20 - 0x30, 0x38, 0x00, 0x30, 0x1C, 0x00, 0x30, 0x0E, 0x00, 0x30, 0x07, 0x00, // row 21 - 24 - 0x30, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_4C[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 7 - 12 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 13 - 18 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x3F, 0xF8, // row 19 - 24 - 0x3F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_4D[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x38, 0x00, 0xE0, // row 5 - 8 - 0x3C, 0x01, 0xE0, 0x3C, 0x01, 0xE0, 0x3C, 0x01, 0xE0, 0x36, 0x03, 0x60, // row 9 - 12 - 0x36, 0x03, 0x60, 0x36, 0x03, 0x60, 0x33, 0x06, 0x60, 0x33, 0x06, 0x60, // row 13 - 16 - 0x33, 0x06, 0x60, 0x31, 0x8C, 0x60, 0x31, 0x8C, 0x60, 0x31, 0x8C, 0x60, // row 17 - 20 - 0x30, 0xD8, 0x60, 0x30, 0xD8, 0x60, 0x30, 0xF8, 0x60, 0x30, 0x70, 0x60, // row 21 - 24 - 0x30, 0x70, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_4E[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x38, 0x03, 0x00, // row 5 - 8 - 0x38, 0x03, 0x00, 0x3C, 0x03, 0x00, 0x3E, 0x03, 0x00, 0x36, 0x03, 0x00, // row 9 - 12 - 0x37, 0x03, 0x00, 0x33, 0x83, 0x00, 0x31, 0x83, 0x00, 0x31, 0xC3, 0x00, // row 13 - 16 - 0x30, 0xE3, 0x00, 0x30, 0x63, 0x00, 0x30, 0x73, 0x00, 0x30, 0x3B, 0x00, // row 17 - 20 - 0x30, 0x1B, 0x00, 0x30, 0x1F, 0x00, 0x30, 0x0F, 0x00, 0x30, 0x07, 0x00, // row 21 - 24 - 0x30, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_4F[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, // row 5 - 8 - 0x0F, 0xFE, 0x00, 0x1E, 0x0F, 0x00, 0x38, 0x03, 0x80, 0x30, 0x01, 0x80, // row 9 - 12 - 0x70, 0x01, 0xC0, 0x60, 0x00, 0xC0, 0x60, 0x00, 0xC0, 0x60, 0x00, 0xC0, // row 13 - 16 - 0x60, 0x00, 0xC0, 0x60, 0x00, 0xC0, 0x60, 0x00, 0xC0, 0x70, 0x01, 0xC0, // row 17 - 20 - 0x30, 0x01, 0x80, 0x38, 0x03, 0x80, 0x1E, 0x0F, 0x00, 0x0F, 0xFE, 0x00, // row 21 - 24 - 0x03, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_50[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x3F, 0xF8, 0x00, // row 5 - 8 - 0x3F, 0xFC, 0x00, 0x30, 0x0E, 0x00, 0x30, 0x06, 0x00, 0x30, 0x06, 0x00, // row 9 - 12 - 0x30, 0x06, 0x00, 0x30, 0x06, 0x00, 0x30, 0x0E, 0x00, 0x3F, 0xFC, 0x00, // row 13 - 16 - 0x3F, 0xF8, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 17 - 20 - 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 21 - 24 - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_51[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, // row 5 - 8 - 0x0F, 0xFE, 0x00, 0x1E, 0x0F, 0x00, 0x38, 0x03, 0x80, 0x30, 0x01, 0x80, // row 9 - 12 - 0x70, 0x01, 0xC0, 0x60, 0x00, 0xC0, 0x60, 0x00, 0xC0, 0x60, 0x00, 0xC0, // row 13 - 16 - 0x60, 0x00, 0xC0, 0x60, 0x00, 0xC0, 0x60, 0x00, 0xC0, 0x70, 0x11, 0xC0, // row 17 - 20 - 0x30, 0x39, 0x80, 0x38, 0x1F, 0x80, 0x1E, 0x0F, 0x00, 0x0F, 0xFF, 0x80, // row 21 - 24 - 0x03, 0xF9, 0xC0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_52[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x00, // row 5 - 8 - 0x3F, 0xFE, 0x00, 0x30, 0x07, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 9 - 12 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x06, 0x00, 0x3F, 0xFE, 0x00, // row 13 - 16 - 0x3F, 0xFC, 0x00, 0x30, 0x0E, 0x00, 0x30, 0x06, 0x00, 0x30, 0x07, 0x00, // row 17 - 20 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 21 - 24 - 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_53[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, // row 5 - 8 - 0x1F, 0xF8, 0x00, 0x38, 0x1C, 0x00, 0x30, 0x0C, 0x00, 0x30, 0x0C, 0x00, // row 9 - 12 - 0x30, 0x0E, 0x00, 0x38, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x0F, 0xE0, 0x00, // row 13 - 16 - 0x01, 0xF8, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x0E, 0x00, 0x70, 0x06, 0x00, // row 17 - 20 - 0x30, 0x06, 0x00, 0x30, 0x06, 0x00, 0x3C, 0x0E, 0x00, 0x1F, 0xFC, 0x00, // row 21 - 24 - 0x07, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_54[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0xFF, 0xFC, 0x00, // row 5 - 8 - 0xFF, 0xFC, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, // row 9 - 12 - 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, // row 13 - 16 - 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, // row 17 - 20 - 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, // row 21 - 24 - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_55[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x30, 0x03, 0x00, // row 5 - 8 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 9 - 12 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 13 - 16 - 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, // row 17 - 20 - 0x30, 0x03, 0x00, 0x38, 0x07, 0x00, 0x1C, 0x0E, 0x00, 0x0F, 0xFC, 0x00, // row 21 - 24 - 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_56[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0xE0, 0x0E, 0x00, // row 5 - 8 - 0x60, 0x0C, 0x00, 0x60, 0x0C, 0x00, 0x60, 0x0C, 0x00, 0x30, 0x18, 0x00, // row 9 - 12 - 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x18, 0x30, 0x00, 0x18, 0x30, 0x00, // row 13 - 16 - 0x18, 0x30, 0x00, 0x0C, 0x60, 0x00, 0x0C, 0x60, 0x00, 0x0C, 0x60, 0x00, // row 17 - 20 - 0x06, 0xC0, 0x00, 0x06, 0xC0, 0x00, 0x07, 0xC0, 0x00, 0x03, 0x80, 0x00, // row 21 - 24 - 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_57[] = // 4 bytes per row -{ - // row 1 - 3 - // row 4 - 6 - 0x00, 0x00, 0x00, 0x00, 0xE0, 0x38, 0x0E, 0x00, 0x60, 0x38, 0x0C, 0x00, // row 7 - 9 - 0x60, 0x38, 0x0C, 0x00, 0x70, 0x6C, 0x1C, 0x00, 0x30, 0x6C, 0x18, 0x00, // row 10 - 12 - 0x30, 0x6C, 0x18, 0x00, 0x30, 0x6C, 0x18, 0x00, 0x38, 0xC6, 0x38, 0x00, // row 13 - 15 - 0x18, 0xC6, 0x30, 0x00, 0x18, 0xC6, 0x30, 0x00, 0x18, 0xC6, 0x30, 0x00, // row 16 - 18 - 0x1D, 0x83, 0x70, 0x00, 0x0D, 0x83, 0x60, 0x00, 0x0D, 0x83, 0x60, 0x00, // row 19 - 21 - 0x0D, 0x83, 0x60, 0x00, 0x0F, 0x01, 0xE0, 0x00, 0x07, 0x01, 0xC0, 0x00, // row 22 - 24 - 0x07, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 27 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 28 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_58[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x60, 0x0C, 0x00, // row 5 - 8 - 0x70, 0x1C, 0x00, 0x30, 0x18, 0x00, 0x18, 0x30, 0x00, 0x1C, 0x70, 0x00, // row 9 - 12 - 0x0C, 0x60, 0x00, 0x06, 0xC0, 0x00, 0x07, 0xC0, 0x00, 0x03, 0x80, 0x00, // row 13 - 16 - 0x03, 0x80, 0x00, 0x06, 0xC0, 0x00, 0x0E, 0xE0, 0x00, 0x0C, 0x60, 0x00, // row 17 - 20 - 0x18, 0x30, 0x00, 0x38, 0x38, 0x00, 0x30, 0x18, 0x00, 0x70, 0x1C, 0x00, // row 21 - 24 - 0xE0, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_59[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0xE0, 0x07, 0x00, // row 5 - 8 - 0x70, 0x0E, 0x00, 0x30, 0x0C, 0x00, 0x38, 0x1C, 0x00, 0x18, 0x18, 0x00, // row 9 - 12 - 0x0C, 0x30, 0x00, 0x0E, 0x70, 0x00, 0x06, 0x60, 0x00, 0x03, 0xC0, 0x00, // row 13 - 16 - 0x03, 0xC0, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, // row 17 - 20 - 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, 0x01, 0x80, 0x00, // row 21 - 24 - 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_5A[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x00, // row 5 - 8 - 0x3F, 0xFE, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x38, 0x00, // row 9 - 12 - 0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0x00, 0xE0, 0x00, 0x01, 0xC0, 0x00, // row 13 - 16 - 0x03, 0x80, 0x00, 0x03, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0E, 0x00, 0x00, // row 17 - 20 - 0x1C, 0x00, 0x00, 0x38, 0x00, 0x00, 0x70, 0x00, 0x00, 0x7F, 0xFE, 0x00, // row 21 - 24 - 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_5B[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 7 - 12 - 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 13 - 18 - 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, // row 19 - 24 - 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x1F, 0x00, 0x1F, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_5C[] = // 2 bytes per row -{ - // row 1 - 6 - 0x20, 0x00, 0x20, 0x00, 0x30, 0x00, 0x10, 0x00, 0x10, 0x00, 0x18, 0x00, // row 7 - 12 - 0x08, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x04, 0x00, 0x06, 0x00, // row 13 - 18 - 0x02, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x80, // row 19 - 24 - 0x00, 0x80, 0x00, 0x80, 0x00, 0xC0, 0x00, 0x40, 0x00, 0x40, 0x00, 0x60, // row 25 - 30 - 0x00, 0x20, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_5D[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x7C, 0x00, 0x7C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, // row 7 - 12 - 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, // row 13 - 18 - 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, // row 19 - 24 - 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x7C, 0x00, 0x7C, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_5E[] = // 2 bytes per row -{ - // row 1 - 3 - // row 4 - 6 I I - 0x00, 0x00, 0x07, 0x00, 0x0D, 0x80, // row 7 - 9 - 0x18, 0xC0, 0x30, 0x60, 0x60, 0x30, // row 10 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 15 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 16 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 21 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 22 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 27 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 28 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_5F[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF8, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_60[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x30, 0x00, 0x60, 0x00, 0x40, 0x00, 0x70, 0x00, 0x70, 0x00, // row 7 - 12 - 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_61[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x0F, 0xC0, 0x00, 0x3F, 0xE0, 0x00, 0x30, 0x70, 0x00, 0x30, 0x30, 0x00, // row 13 - 16 - 0x00, 0x30, 0x00, 0x0F, 0xF0, 0x00, 0x3F, 0xF0, 0x00, 0x70, 0x30, 0x00, // row 17 - 20 - 0x60, 0x30, 0x00, 0x60, 0x30, 0x00, 0x70, 0xF0, 0x00, 0x3F, 0xBC, 0x00, // row 21 - 24 - 0x1F, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_62[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, // row 5 - 8 - 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 9 - 12 - 0x33, 0xC0, 0x00, 0x37, 0xF0, 0x00, 0x3E, 0x78, 0x00, 0x38, 0x18, 0x00, // row 13 - 16 - 0x30, 0x1C, 0x00, 0x30, 0x0C, 0x00, 0x30, 0x0C, 0x00, 0x30, 0x0C, 0x00, // row 17 - 20 - 0x30, 0x1C, 0x00, 0x38, 0x18, 0x00, 0x3E, 0x78, 0x00, 0x37, 0xF0, 0x00, // row 21 - 24 - 0x33, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_63[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x07, 0x80, 0x1F, 0xE0, 0x3C, 0xE0, 0x30, 0x30, 0x70, 0x00, 0x60, 0x00, // row 13 - 18 - 0x60, 0x00, 0x60, 0x00, 0x70, 0x30, 0x30, 0x30, 0x3C, 0xE0, 0x1F, 0xE0, // row 19 - 24 - 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_64[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, // row 5 - 8 - 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, // row 9 - 12 - 0x07, 0x98, 0x00, 0x1F, 0xD8, 0x00, 0x3C, 0xF8, 0x00, 0x30, 0x38, 0x00, // row 13 - 16 - 0x70, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, // row 17 - 20 - 0x70, 0x18, 0x00, 0x30, 0x38, 0x00, 0x3C, 0xF8, 0x00, 0x1F, 0xD8, 0x00, // row 21 - 24 - 0x07, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_65[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x07, 0x80, 0x00, 0x1F, 0xE0, 0x00, 0x3C, 0xF0, 0x00, 0x30, 0x30, 0x00, // row 13 - 16 - 0x70, 0x18, 0x00, 0x7F, 0xF8, 0x00, 0x7F, 0xF8, 0x00, 0x60, 0x00, 0x00, // row 17 - 20 - 0x70, 0x00, 0x00, 0x30, 0x38, 0x00, 0x3C, 0xF0, 0x00, 0x1F, 0xE0, 0x00, // row 21 - 24 - 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_66[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x1E, 0x00, 0x3E, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 7 - 12 - 0xFE, 0x00, 0xFE, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 13 - 18 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 19 - 24 - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_67[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x07, 0x98, 0x00, 0x1F, 0xD8, 0x00, 0x3C, 0xF8, 0x00, 0x30, 0x38, 0x00, // row 13 - 16 - 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, // row 17 - 20 - 0x70, 0x18, 0x00, 0x30, 0x38, 0x00, 0x3C, 0xF8, 0x00, 0x1F, 0xD8, 0x00, // row 21 - 24 - 0x07, 0x98, 0x00, 0x00, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x38, 0x00, // row 25 - 28 - 0x38, 0x70, 0x00, 0x3F, 0xF0, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_68[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, // row 5 - 8 - 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 9 - 12 - 0x33, 0xE0, 0x00, 0x37, 0xF0, 0x00, 0x3C, 0x38, 0x00, 0x38, 0x18, 0x00, // row 13 - 16 - 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, // row 17 - 20 - 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, // row 21 - 24 - 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_69[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 13 - 18 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 19 - 24 - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_6A[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 13 - 18 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 19 - 24 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0xF0, 0x00, // row 25 - 30 - 0xE0, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_6B[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 7 - 12 - 0x30, 0x70, 0x30, 0xE0, 0x31, 0xC0, 0x33, 0x80, 0x37, 0x00, 0x3F, 0x00, // row 13 - 18 - 0x3F, 0x80, 0x39, 0x80, 0x31, 0xC0, 0x30, 0xC0, 0x30, 0xE0, 0x30, 0x60, // row 19 - 24 - 0x30, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_6C[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 7 - 12 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 13 - 18 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 19 - 24 - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_6D[] = // 4 bytes per row -{ - // row 1 - 3 - // row 4 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 9 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 10 - 12 - 0x33, 0xC3, 0xC0, 0x00, 0x37, 0xEF, 0xE0, 0x00, 0x3C, 0x7C, 0x70, 0x00, // row 13 - 15 - 0x38, 0x38, 0x30, 0x00, 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x00, // row 16 - 18 - 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x00, // row 19 - 21 - 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x00, // row 22 - 24 - 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 27 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 28 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_6E[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x33, 0xE0, 0x00, 0x37, 0xF0, 0x00, 0x3C, 0x38, 0x00, 0x38, 0x18, 0x00, // row 13 - 16 - 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, // row 17 - 20 - 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, // row 21 - 24 - 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_6F[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x3C, 0x78, 0x00, 0x30, 0x18, 0x00, // row 13 - 16 - 0x70, 0x1C, 0x00, 0x60, 0x0C, 0x00, 0x60, 0x0C, 0x00, 0x60, 0x0C, 0x00, // row 17 - 20 - 0x70, 0x1C, 0x00, 0x30, 0x18, 0x00, 0x3C, 0x78, 0x00, 0x1F, 0xF0, 0x00, // row 21 - 24 - 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_70[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x33, 0xC0, 0x00, 0x37, 0xF0, 0x00, 0x3E, 0x78, 0x00, 0x38, 0x18, 0x00, // row 13 - 16 - 0x30, 0x1C, 0x00, 0x30, 0x0C, 0x00, 0x30, 0x0C, 0x00, 0x30, 0x0C, 0x00, // row 17 - 20 - 0x30, 0x1C, 0x00, 0x38, 0x18, 0x00, 0x3E, 0x78, 0x00, 0x37, 0xF0, 0x00, // row 21 - 24 - 0x33, 0xC0, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, // row 25 - 28 - 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_71[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x07, 0x98, 0x00, 0x1F, 0xD8, 0x00, 0x3C, 0xF8, 0x00, 0x30, 0x38, 0x00, // row 13 - 16 - 0x70, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, 0x60, 0x18, 0x00, // row 17 - 20 - 0x70, 0x18, 0x00, 0x30, 0x38, 0x00, 0x3C, 0xF8, 0x00, 0x1F, 0xD8, 0x00, // row 21 - 24 - 0x07, 0x98, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, // row 25 - 28 - 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_72[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x37, 0x00, 0x3F, 0x00, 0x38, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 13 - 18 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 19 - 24 - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_73[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x1F, 0x00, 0x3F, 0xC0, 0x70, 0xC0, 0x60, 0x60, 0x60, 0x00, 0x3E, 0x00, // row 13 - 18 - 0x1F, 0xC0, 0x03, 0xE0, 0x00, 0x60, 0x60, 0x60, 0x70, 0xE0, 0x3F, 0xC0, // row 19 - 24 - 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_74[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 7 - 12 - 0xFC, 0x00, 0xFC, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, // row 13 - 18 - 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x3C, 0x00, // row 19 - 24 - 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_75[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, // row 13 - 16 - 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, 0x30, 0x18, 0x00, // row 17 - 20 - 0x30, 0x18, 0x00, 0x30, 0x38, 0x00, 0x38, 0x78, 0x00, 0x1F, 0xD8, 0x00, // row 21 - 24 - 0x0F, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_76[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0xC0, 0x60, 0xC0, 0x60, 0x60, 0xC0, 0x60, 0xC0, 0x60, 0xC0, 0x31, 0x80, // row 13 - 18 - 0x31, 0x80, 0x31, 0x80, 0x1B, 0x00, 0x1B, 0x00, 0x1F, 0x00, 0x0E, 0x00, // row 19 - 24 - 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_77[] = // 3 bytes per row -{ - // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0xC1, 0xC1, 0x80, 0xC1, 0xC1, 0x80, 0xC1, 0x41, 0x80, 0x63, 0x63, 0x00, // row 13 - 16 - 0x63, 0x63, 0x00, 0x63, 0x63, 0x00, 0x62, 0x23, 0x00, 0x36, 0x36, 0x00, // row 17 - 20 - 0x36, 0x36, 0x00, 0x36, 0x36, 0x00, 0x1C, 0x1C, 0x00, 0x1C, 0x1C, 0x00, // row 21 - 24 - 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 29 - 32 -}; -PROGMEM const unsigned char chr_f32_78[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x60, 0x30, 0x70, 0x70, 0x30, 0x60, 0x18, 0xC0, 0x1D, 0xC0, 0x0F, 0x80, // row 13 - 18 - 0x07, 0x00, 0x0F, 0x80, 0x1D, 0xC0, 0x18, 0xC0, 0x30, 0x60, 0x70, 0x70, // row 19 - 24 - 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_79[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0xE0, 0x38, 0x60, 0x30, 0x60, 0x30, 0x30, 0x60, 0x30, 0x60, 0x30, 0x60, // row 13 - 18 - 0x18, 0xC0, 0x18, 0xC0, 0x18, 0xC0, 0x0D, 0x80, 0x0D, 0x80, 0x0D, 0x80, // row 19 - 24 - 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x06, 0x00, 0x0E, 0x00, 0x7C, 0x00, // row 25 - 30 - 0x78, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_7A[] = // 2 bytes per row -{ - // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x7F, 0xE0, 0x7F, 0xE0, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, // row 13 - 18 - 0x06, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0x7F, 0xE0, // row 19 - 24 - 0x7F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_7B[] = // 2 bytes per row -{ - // row 1 - 6 - 0x01, 0xE0, 0x03, 0x80, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // row 7 - 12 - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x06, 0x00, // row 13 - 18 - 0x1C, 0x00, 0x06, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, // row 19 - 24 - 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x80, // row 25 - 30 - 0x01, 0xE0, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_7C[] = // 2 bytes per row -{ - // row 1 - 6 - 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, // row 7 - 12 - 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, // row 13 - 18 - 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, // row 19 - 24 - 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, // row 25 - 30 - 0x06, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_7D[] = // 2 bytes per row -{ - // row 1 - 6 - 0x3C, 0x00, 0x0E, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, // row 7 - 12 - 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x03, 0x00, // row 13 - 18 - 0x01, 0xC0, 0x03, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, // row 19 - 24 - 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x0E, 0x00, // row 25 - 30 - 0x3C, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_7E[] = // 3 bytes per row -{ - // row 1 - 3 - // row 4 - 6 - 0x00, 0x00, 0x00, 0x1E, 0x01, 0x00, 0x33, 0x01, 0x00, // row 7 - 9 - 0x61, 0xC3, 0x00, 0x40, 0x66, 0x00, 0x40, 0x3C, 0x00, // row 10 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 15 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 16 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 21 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 22 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 27 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 28 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 31 - 32 -}; -PROGMEM const unsigned char chr_f32_7F[] = // 1 byte per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 12 - 22 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 23 - 32 -}; - -PROGMEM const unsigned char* const chrtbl_f32[96] = // character pointer table -{ - chr_f32_20, chr_f32_21, chr_f32_22, chr_f32_23, chr_f32_24, chr_f32_25, chr_f32_26, chr_f32_27, - chr_f32_28, chr_f32_29, chr_f32_2A, chr_f32_2B, chr_f32_2C, chr_f32_2D, chr_f32_2E, chr_f32_2F, - chr_f32_30, chr_f32_31, chr_f32_32, chr_f32_33, chr_f32_34, chr_f32_35, chr_f32_36, chr_f32_37, - chr_f32_38, chr_f32_39, chr_f32_3A, chr_f32_3B, chr_f32_3C, chr_f32_3D, chr_f32_3E, chr_f32_3F, - chr_f32_40, chr_f32_41, chr_f32_42, chr_f32_43, chr_f32_44, chr_f32_45, chr_f32_46, chr_f32_47, - chr_f32_48, chr_f32_49, chr_f32_4A, chr_f32_4B, chr_f32_4C, chr_f32_4D, chr_f32_4E, chr_f32_4F, - chr_f32_50, chr_f32_51, chr_f32_52, chr_f32_53, chr_f32_54, chr_f32_55, chr_f32_56, chr_f32_57, - chr_f32_58, chr_f32_59, chr_f32_5A, chr_f32_5B, chr_f32_5C, chr_f32_5D, chr_f32_5E, chr_f32_5F, - chr_f32_60, chr_f32_61, chr_f32_62, chr_f32_63, chr_f32_64, chr_f32_65, chr_f32_66, chr_f32_67, - chr_f32_68, chr_f32_69, chr_f32_6A, chr_f32_6B, chr_f32_6C, chr_f32_6D, chr_f32_6E, chr_f32_6F, - chr_f32_70, chr_f32_71, chr_f32_72, chr_f32_73, chr_f32_74, chr_f32_75, chr_f32_76, chr_f32_77, - chr_f32_78, chr_f32_79, chr_f32_7A, chr_f32_7B, chr_f32_7C, chr_f32_7D, chr_f32_7E, chr_f32_7F -}; diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Font32.h b/GD32F1/libraries/Adafruit_GFX_AS/Font32.h deleted file mode 100644 index f9c54d3..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Font32.h +++ /dev/null @@ -1,7 +0,0 @@ -#define nr_chrs_f32 96 -#define chr_hgt_f32 26 -#define data_size_f32 8 -#define firstchr_f32 32 - -extern const unsigned char widtbl_f32[96]; -extern const unsigned char* const chrtbl_f32[96]; diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Font64.c b/GD32F1/libraries/Adafruit_GFX_AS/Font64.c deleted file mode 100644 index 8f34091..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Font64.c +++ /dev/null @@ -1,363 +0,0 @@ -// Font size 6 is intended to display numbers and time -// This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 . : a p m -// The Pipe character | is a narrow space to aid formatting -// All other characters print as a space - -#include "Font64.h" -#ifdef __AVR__ - #include - #include -#else - #define PROGMEM -#endif - - - const unsigned char widtbl_f64[96] PROGMEM = // character width table -{ - 15, 15, 15, 15, 15, 15, 15, 15, // char 32 - 39 - 15, 15, 15, 15, 15, 20, 18, 15, // char 40 - 47 - 30, 30, 30, 30, 30, 30, 30, 30, // char 48 - 55 - 30, 30, 18, 15, 15, 15, 15, 15, // char 56 - 63 - 15, 15, 15, 15, 15, 15, 15, 15, // char 64 - 71 - 15, 15, 15, 15, 15, 15, 15, 15, // char 72 - 79 - 15, 15, 15, 15, 15, 15, 15, 15, // char 80 - 87 - 15, 15, 15, 15, 15, 15, 15, 15, // char 88 - 95 - 15, 30, 15, 15, 15, 15, 15, 15, // char 96 - 103 - 15, 15, 15, 15, 15, 45, 15, 15, // char 104 - 111 - 32, 15, 15, 15, 15, 15, 15, 15, // char 112 - 119 - 15, 15, 15, 15, 10, 15, 15, 15 // char 120 - 127 -}; - - - - - -// Row format, MSB left - - const unsigned char chr_f64_20[96] PROGMEM = // 2 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 31 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 43 - 48 -}; - const unsigned char chr_f64_2D[144] PROGMEM = // 3 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 16 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFC, 0x00, // row 17 - 20 - 0x1F, 0xFC, 0x00, 0x1F, 0xFC, 0x00, 0x1F, 0xFC, 0x00, 0x00, 0x00, 0x00, // row 21 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 29 - 32 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 33 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 40 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 41 - 44 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 45 - 48 -}; - const unsigned char chr_f64_2E[144] PROGMEM = // 3 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 9 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 16 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 17 - 20 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 21 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 28 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, // row 29 - 32 - 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, // row 33 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 40 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 41 - 44 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 45 - 48 -}; - const unsigned char chr_f64_30[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x03, 0xFF, 0xF0, 0x00, // row 1 - 3 - 0x07, 0xFF, 0xF8, 0x00, 0x0F, 0xFF, 0xFC, 0x00, 0x1F, 0xC0, 0xFE, 0x00, // row 4 - 6 - 0x1F, 0x00, 0x3E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x3E, 0x00, 0x1F, 0x00, // row 7 - 9 - 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x0F, 0x00, // row 10 - 12 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 13 - 15 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 16 - 18 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 19 - 21 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 22 - 24 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x0F, 0x00, // row 25 - 27 - 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x0F, 0x00, 0x3E, 0x00, 0x1F, 0x00, // row 28 - 30 - 0x1E, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x3E, 0x00, 0x1F, 0xC0, 0xFE, 0x00, // row 31 - 33 - 0x0F, 0xFF, 0xFC, 0x00, 0x07, 0xFF, 0xF8, 0x00, 0x03, 0xFF, 0xF0, 0x00, // row 34 - 36 - 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_31[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x01, 0xC0, 0x00, // row 1 - 3 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x07, 0xC0, 0x00, // row 4 - 6 - 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x3F, 0xC0, 0x00, 0x07, 0xFF, 0xC0, 0x00, // row 7 - 9 - 0x07, 0xFF, 0xC0, 0x00, 0x07, 0xFB, 0xC0, 0x00, 0x07, 0xC3, 0xC0, 0x00, // row 10 - 12 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 13 - 15 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 16 - 18 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 19 - 21 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 22 - 24 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 25 - 27 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 28 - 30 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 31 - 33 - 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, // row 34 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_32[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xC0, 0x00, 0x00, 0xFF, 0xF8, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFC, 0x00, 0x07, 0xFF, 0xFE, 0x00, 0x07, 0xE0, 0x7F, 0x00, // row 4 - 6 - 0x0F, 0x80, 0x1F, 0x00, 0x0F, 0x80, 0x0F, 0x00, 0x0F, 0x00, 0x0F, 0x80, // row 7 - 9 - 0x1F, 0x00, 0x07, 0x80, 0x1E, 0x00, 0x07, 0x80, 0x1E, 0x00, 0x07, 0x80, // row 10 - 12 - 0x1E, 0x00, 0x07, 0x80, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0F, 0x80, // row 13 - 15 - 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x3F, 0x00, // row 16 - 18 - 0x00, 0x00, 0x7E, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00, 0x07, 0xF8, 0x00, // row 19 - 21 - 0x00, 0x1F, 0xF0, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0xFF, 0x80, 0x00, // row 22 - 24 - 0x01, 0xFE, 0x00, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, // row 25 - 27 - 0x0F, 0xC0, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, // row 28 - 30 - 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x80, // row 31 - 33 - 0x3F, 0xFF, 0xFF, 0x80, 0x3F, 0xFF, 0xFF, 0x80, 0x3F, 0xFF, 0xFF, 0x80, // row 34 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_33[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x03, 0xFF, 0xF0, 0x00, // row 1 - 3 - 0x07, 0xFF, 0xFC, 0x00, 0x0F, 0xFF, 0xFC, 0x00, 0x1F, 0xC0, 0xFE, 0x00, // row 4 - 6 - 0x1F, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x1F, 0x00, 0x3E, 0x00, 0x1F, 0x00, // row 7 - 9 - 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x0F, 0x00, // row 10 - 12 - 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x3E, 0x00, // row 13 - 15 - 0x00, 0x00, 0x7E, 0x00, 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x3F, 0xF0, 0x00, // row 16 - 18 - 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x3F, 0xFE, 0x00, 0x00, 0x00, 0x7F, 0x00, // row 19 - 21 - 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x0F, 0x80, // row 22 - 24 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 25 - 27 - 0x7C, 0x00, 0x0F, 0x80, 0x7C, 0x00, 0x1F, 0x80, 0x3E, 0x00, 0x1F, 0x00, // row 28 - 30 - 0x3F, 0x00, 0x3F, 0x00, 0x1F, 0xC0, 0xFE, 0x00, 0x0F, 0xFF, 0xFC, 0x00, // row 31 - 33 - 0x07, 0xFF, 0xF8, 0x00, 0x03, 0xFF, 0xF0, 0x00, 0x00, 0x7F, 0x80, 0x00, // row 34 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_34[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, // row 1 - 3 - 0x00, 0x01, 0xF0, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x07, 0xF0, 0x00, // row 4 - 6 - 0x00, 0x07, 0xF0, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x1E, 0xF0, 0x00, // row 7 - 9 - 0x00, 0x1E, 0xF0, 0x00, 0x00, 0x3C, 0xF0, 0x00, 0x00, 0x78, 0xF0, 0x00, // row 10 - 12 - 0x00, 0xF8, 0xF0, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x01, 0xE0, 0xF0, 0x00, // row 13 - 15 - 0x03, 0xC0, 0xF0, 0x00, 0x07, 0xC0, 0xF0, 0x00, 0x07, 0x80, 0xF0, 0x00, // row 16 - 18 - 0x0F, 0x00, 0xF0, 0x00, 0x1F, 0x00, 0xF0, 0x00, 0x1E, 0x00, 0xF0, 0x00, // row 19 - 21 - 0x3C, 0x00, 0xF0, 0x00, 0x78, 0x00, 0xF0, 0x00, 0x7F, 0xFF, 0xFF, 0x80, // row 22 - 24 - 0x7F, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xFF, 0x80, // row 25 - 27 - 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, // row 28 - 30 - 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, // row 31 - 33 - 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, // row 34 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_35[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFE, 0x00, // row 1 - 3 - 0x07, 0xFF, 0xFE, 0x00, 0x07, 0xFF, 0xFE, 0x00, 0x07, 0xFF, 0xFE, 0x00, // row 4 - 6 - 0x07, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, // row 7 - 9 - 0x0F, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, // row 10 - 12 - 0x0E, 0x00, 0x00, 0x00, 0x1E, 0x3F, 0xC0, 0x00, 0x1E, 0xFF, 0xF0, 0x00, // row 13 - 15 - 0x1F, 0xFF, 0xF8, 0x00, 0x1F, 0xFF, 0xFC, 0x00, 0x1F, 0xC0, 0xFE, 0x00, // row 16 - 18 - 0x1F, 0x00, 0x3F, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x0F, 0x00, // row 19 - 21 - 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x07, 0x80, // row 22 - 24 - 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x07, 0x80, // row 25 - 27 - 0x3C, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x0F, 0x80, 0x3C, 0x00, 0x0F, 0x00, // row 28 - 30 - 0x3E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x3F, 0x00, 0x1F, 0xC0, 0xFE, 0x00, // row 31 - 33 - 0x0F, 0xFF, 0xFC, 0x00, 0x07, 0xFF, 0xF8, 0x00, 0x03, 0xFF, 0xF0, 0x00, // row 34 - 36 - 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_36[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x00, 0xFF, 0xF0, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xF8, 0x00, 0x07, 0xFF, 0xFC, 0x00, 0x0F, 0xE0, 0x7E, 0x00, // row 4 - 6 - 0x1F, 0x80, 0x1F, 0x00, 0x1F, 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x0F, 0x80, // row 7 - 9 - 0x3E, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x00, 0x00, // row 10 - 12 - 0x3C, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x3F, 0x80, 0x00, // row 13 - 15 - 0x78, 0xFF, 0xF0, 0x00, 0x7B, 0xFF, 0xF8, 0x00, 0x7F, 0xFF, 0xFC, 0x00, // row 16 - 18 - 0x7F, 0xC0, 0xFE, 0x00, 0x7F, 0x00, 0x3E, 0x00, 0x7E, 0x00, 0x1F, 0x00, // row 19 - 21 - 0x7C, 0x00, 0x0F, 0x00, 0x7C, 0x00, 0x0F, 0x80, 0x78, 0x00, 0x07, 0x80, // row 22 - 24 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 25 - 27 - 0x78, 0x00, 0x07, 0x80, 0x3C, 0x00, 0x0F, 0x80, 0x3C, 0x00, 0x0F, 0x00, // row 28 - 30 - 0x3E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x3F, 0x00, 0x1F, 0xC0, 0xFE, 0x00, // row 31 - 33 - 0x0F, 0xFF, 0xFC, 0x00, 0x07, 0xFF, 0xF8, 0x00, 0x01, 0xFF, 0xF0, 0x00, // row 34 - 36 - 0x00, 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_37[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x80, // row 1 - 3 - 0x3F, 0xFF, 0xFF, 0x80, 0x3F, 0xFF, 0xFF, 0x80, 0x3F, 0xFF, 0xFF, 0x80, // row 4 - 6 - 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1E, 0x00, // row 7 - 9 - 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0xF8, 0x00, // row 10 - 12 - 0x00, 0x01, 0xF0, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x03, 0xE0, 0x00, // row 13 - 15 - 0x00, 0x07, 0xC0, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x0F, 0x80, 0x00, // row 16 - 18 - 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, // row 19 - 21 - 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, // row 22 - 24 - 0x00, 0x7C, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, // row 25 - 27 - 0x00, 0xF8, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, // row 28 - 30 - 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, // row 31 - 33 - 0x01, 0xE0, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, // row 34 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_38[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xFF, 0xE0, 0x00, // row 1 - 3 - 0x07, 0xFF, 0xF8, 0x00, 0x0F, 0xFF, 0xFC, 0x00, 0x1F, 0xC0, 0xFE, 0x00, // row 4 - 6 - 0x1F, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x1F, 0x00, 0x3E, 0x00, 0x1F, 0x00, // row 7 - 9 - 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x0F, 0x00, // row 10 - 12 - 0x3E, 0x00, 0x1F, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x3E, 0x00, // row 13 - 15 - 0x0F, 0xC0, 0xFC, 0x00, 0x07, 0xFF, 0xF8, 0x00, 0x03, 0xFF, 0xF0, 0x00, // row 16 - 18 - 0x07, 0xFF, 0xF8, 0x00, 0x0F, 0xFF, 0xFC, 0x00, 0x1F, 0x80, 0x7E, 0x00, // row 19 - 21 - 0x3E, 0x00, 0x1F, 0x00, 0x3C, 0x00, 0x0F, 0x00, 0x7C, 0x00, 0x0F, 0x80, // row 22 - 24 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 25 - 27 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x7C, 0x00, 0x0F, 0x80, // row 28 - 30 - 0x7C, 0x00, 0x0F, 0x80, 0x3E, 0x00, 0x1F, 0x00, 0x3F, 0x80, 0x7F, 0x00, // row 31 - 33 - 0x1F, 0xFF, 0xFE, 0x00, 0x0F, 0xFF, 0xFC, 0x00, 0x07, 0xFF, 0xF8, 0x00, // row 34 - 36 - 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_39[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x03, 0xFF, 0xE0, 0x00, // row 1 - 3 - 0x07, 0xFF, 0xF8, 0x00, 0x0F, 0xFF, 0xFC, 0x00, 0x1F, 0xC0, 0xFE, 0x00, // row 4 - 6 - 0x3F, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x1F, 0x00, 0x3C, 0x00, 0x0F, 0x00, // row 7 - 9 - 0x7C, 0x00, 0x0F, 0x00, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 10 - 12 - 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, 0x78, 0x00, 0x07, 0x80, // row 13 - 15 - 0x7C, 0x00, 0x0F, 0x80, 0x3C, 0x00, 0x0F, 0x80, 0x3E, 0x00, 0x1F, 0x80, // row 16 - 18 - 0x1F, 0x00, 0x3F, 0x80, 0x1F, 0xC0, 0xFF, 0x80, 0x0F, 0xFF, 0xFF, 0x80, // row 19 - 21 - 0x07, 0xFF, 0xF7, 0x80, 0x03, 0xFF, 0xC7, 0x80, 0x00, 0x7F, 0x07, 0x80, // row 22 - 24 - 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, // row 25 - 27 - 0x78, 0x00, 0x0F, 0x00, 0x78, 0x00, 0x1F, 0x00, 0x7C, 0x00, 0x1E, 0x00, // row 28 - 30 - 0x3C, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x7E, 0x00, 0x1F, 0x81, 0xFC, 0x00, // row 31 - 33 - 0x0F, 0xFF, 0xF8, 0x00, 0x07, 0xFF, 0xF0, 0x00, 0x03, 0xFF, 0xC0, 0x00, // row 34 - 36 - 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_3A[144] PROGMEM = // 3 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, // row 9 - 12 - 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, // row 13 - 16 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 17 - 20 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 21 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, // row 25 - 28 - 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, 0x07, 0xC0, 0x00, // row 29 - 32 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 33 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 40 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 41 - 44 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 45 - 48 -}; - const unsigned char chr_f64_61[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 3 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 4 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 9 - 0x00, 0x7F, 0xC0, 0x00, 0x01, 0xFF, 0xF8, 0x00, 0x07, 0xFF, 0xFC, 0x00, // row 10 - 12 - 0x07, 0xFF, 0xFE, 0x00, 0x0F, 0xC0, 0x7E, 0x00, 0x1F, 0x00, 0x1F, 0x00, // row 13 - 15 - 0x1E, 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x0F, 0x00, 0x1E, 0x00, 0x0F, 0x00, // row 16 - 18 - 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x0F, 0xFF, 0x00, // row 19 - 21 - 0x01, 0xFF, 0xFF, 0x00, 0x07, 0xFF, 0xFF, 0x00, 0x0F, 0xFF, 0xCF, 0x00, // row 22 - 24 - 0x1F, 0xF0, 0x0F, 0x00, 0x1F, 0x00, 0x0F, 0x00, 0x3E, 0x00, 0x0F, 0x00, // row 25 - 27 - 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x0F, 0x00, 0x3C, 0x00, 0x1F, 0x00, // row 28 - 30 - 0x3C, 0x00, 0x3F, 0x00, 0x3E, 0x00, 0x7F, 0x00, 0x1F, 0x01, 0xFF, 0xC0, // row 31 - 33 - 0x1F, 0xFF, 0xE7, 0xC0, 0x0F, 0xFF, 0xC7, 0xC0, 0x07, 0xFF, 0x03, 0xC0, // row 34 - 36 - 0x01, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 40 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - const unsigned char chr_f64_6D[288] PROGMEM = // 6 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 2 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 3 - 4 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x1F, 0xC0, 0x00, // row 9 - 10 - 0x1E, 0x3F, 0xF0, 0x7F, 0xF0, 0x00, 0x1E, 0xFF, 0xF8, 0xFF, 0xF8, 0x00, // row 11 - 12 - 0x1E, 0xFF, 0xFD, 0xFF, 0xFC, 0x00, 0x1F, 0xE0, 0x7F, 0xE0, 0x7C, 0x00, // row 13 - 14 - 0x1F, 0x80, 0x3F, 0x80, 0x3E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1E, 0x00, // row 15 - 16 - 0x1F, 0x00, 0x1F, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 17 - 18 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 19 - 20 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 21 - 22 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 23 - 24 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 25 - 26 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 27 - 28 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 29 - 30 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 31 - 32 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 33 - 34 - 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x1E, 0x00, // row 35 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 38 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 39 - 40 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 41 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 44 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 45 - 46 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 47 - 48 -}; - const unsigned char chr_f64_70[192] PROGMEM = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 3 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 4 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 9 - 0x00, 0x0F, 0xE0, 0x00, 0x1E, 0x3F, 0xFC, 0x00, 0x1E, 0x7F, 0xFE, 0x00, // row 10 - 12 - 0x1E, 0xFF, 0xFF, 0x00, 0x1F, 0xF0, 0x3F, 0x80, 0x1F, 0xC0, 0x0F, 0x80, // row 13 - 15 - 0x1F, 0x80, 0x07, 0xC0, 0x1F, 0x00, 0x03, 0xC0, 0x1F, 0x00, 0x03, 0xC0, // row 16 - 18 - 0x1F, 0x00, 0x03, 0xE0, 0x1E, 0x00, 0x01, 0xE0, 0x1E, 0x00, 0x01, 0xE0, // row 19 - 21 - 0x1E, 0x00, 0x01, 0xE0, 0x1E, 0x00, 0x01, 0xE0, 0x1E, 0x00, 0x01, 0xE0, // row 22 - 24 - 0x1E, 0x00, 0x01, 0xE0, 0x1E, 0x00, 0x01, 0xE0, 0x1E, 0x00, 0x01, 0xE0, // row 25 - 27 - 0x1E, 0x00, 0x03, 0xE0, 0x1F, 0x00, 0x03, 0xC0, 0x1F, 0x00, 0x07, 0xC0, // row 28 - 30 - 0x1F, 0x80, 0x07, 0xC0, 0x1F, 0xC0, 0x0F, 0x80, 0x1F, 0xF0, 0x3F, 0x80, // row 31 - 33 - 0x1E, 0xFF, 0xFF, 0x00, 0x1E, 0x7F, 0xFE, 0x00, 0x1E, 0x3F, 0xFC, 0x00, // row 34 - 36 - 0x1E, 0x0F, 0xE0, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, // row 37 - 39 - 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, // row 40 - 42 - 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, // row 43 - 45 - 0x1E, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; - - const unsigned char* const chrtbl_f64[] PROGMEM = // character pointer table -{ - chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, - chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_2D, chr_f64_2E, chr_f64_20, - chr_f64_30, chr_f64_31, chr_f64_32, chr_f64_33, chr_f64_34, chr_f64_35, chr_f64_36, chr_f64_37, - chr_f64_38, chr_f64_39, chr_f64_3A, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, - chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, - chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, - chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, - chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, - chr_f64_20, chr_f64_61, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, - chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_6D, chr_f64_20, chr_f64_20, - chr_f64_70, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, - chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20 -}; diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Font64.h b/GD32F1/libraries/Adafruit_GFX_AS/Font64.h deleted file mode 100644 index c02b0a2..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Font64.h +++ /dev/null @@ -1,7 +0,0 @@ -#define nr_chrs_f64 96 -#define chr_hgt_f64 48 -#define data_size_f64 8 -#define firstchr_f64 32 - -extern const unsigned char widtbl_f64[96]; -extern const unsigned char* const chrtbl_f64[96]; diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Font7s.c b/GD32F1/libraries/Adafruit_GFX_AS/Font7s.c deleted file mode 100644 index 6ee89cb..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Font7s.c +++ /dev/null @@ -1,270 +0,0 @@ -// Font size 7 is a 7 segment font intended to display numbers and time -// This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : . -// All other characters print as a space - -#include "Font7s.h" -//#include -#ifdef __AVR__ - #include - #include -#else - #define PROGMEM -#endif - -PROGMEM const unsigned char widtbl_f7s[96] = // character width table -{ - 12, 12, 12, 12, 12, 12, 12, 12, // char 32 - 39 - 12, 12, 12, 12, 12, 12, 12, 12, // char 40 - 47 - 32, 32, 32, 32, 32, 32, 32, 32, // char 48 - 55 - 32, 32, 12, 12, 12, 12, 12, 12, // char 56 - 63 - 12, 12, 12, 12, 12, 12, 12, 12, // char 64 - 71 - 12, 12, 12, 12, 12, 12, 12, 12, // char 72 - 79 - 12, 12, 12, 12, 12, 12, 12, 12, // char 80 - 87 - 12, 12, 12, 12, 12, 12, 12, 12, // char 88 - 95 - 12, 12, 12, 12, 12, 12, 12, 12, // char 96 - 103 - 12, 12, 12, 12, 12, 12, 12, 12, // char 104 - 111 - 12, 12, 12, 12, 12, 12, 12, 12, // char 112 - 119 - 12, 12, 12, 12, 12, 12, 12, 12 // char 120 - 127 -}; - -// Row format, MSB left - -PROGMEM const unsigned char chr_f7s_20[96] = // 2 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 31 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 43 - 48 -}; -PROGMEM const unsigned char chr_f7s_2E[96] = // 2 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 31 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 42 - 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x0E, 0x00, 0x00, 0x00 // row 43 - 48 -}; -PROGMEM const unsigned char chr_f7s_30[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x20, 0x0C, 0xFF, 0xFE, 0x70, // row 4 - 6 - 0x1E, 0x00, 0x00, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 7 - 9 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 10 - 12 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 13 - 15 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 16 - 18 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0xF8, // row 19 - 21 - 0x38, 0x00, 0x00, 0x38, 0x20, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // row 22 - 24 - 0x20, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x18, 0x3E, 0x00, 0x00, 0x78, // row 25 - 27 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x1E, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x0C, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, // row 43 - 45 - 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_31[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 3 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, // row 4 - 6 - 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 7 - 9 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 10 - 12 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 13 - 15 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 16 - 18 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x78, // row 19 - 21 - 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // row 22 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x78, // row 25 - 27 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_32[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x20, 0x00, 0xFF, 0xFE, 0x70, // row 4 - 6 - 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 7 - 9 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 10 - 12 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 13 - 15 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 16 - 18 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF8, // row 19 - 21 - 0x00, 0xFF, 0xFE, 0x38, 0x03, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, // row 22 - 24 - 0x27, 0xFF, 0xFF, 0xC0, 0x39, 0xFF, 0xFF, 0x00, 0x3E, 0x00, 0x00, 0x00, // row 25 - 27 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 28 - 30 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 31 - 33 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 34 - 36 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 37 - 39 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, // row 40 - 42 - 0x0C, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, // row 43 - 45 - 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_33[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x20, 0x00, 0xFF, 0xFE, 0x70, // row 4 - 6 - 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 7 - 9 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 10 - 12 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 13 - 15 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 16 - 18 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF8, // row 19 - 21 - 0x00, 0xFF, 0xFE, 0x38, 0x03, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, // row 22 - 24 - 0x07, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x18, 0x00, 0x00, 0x00, 0x78, // row 25 - 27 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x00, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, // row 43 - 45 - 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_34[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 3 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x0C, 0x00, 0x00, 0x70, // row 4 - 6 - 0x1E, 0x00, 0x00, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 7 - 9 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 10 - 12 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 13 - 15 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 16 - 18 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0xF8, // row 19 - 21 - 0x38, 0xFF, 0xFE, 0x38, 0x23, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, // row 22 - 24 - 0x07, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x18, 0x00, 0x00, 0x00, 0x78, // row 25 - 27 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_35[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x0C, 0xFF, 0xFE, 0x00, // row 4 - 6 - 0x1E, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 7 - 9 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 10 - 12 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 13 - 15 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 16 - 18 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, // row 19 - 21 - 0x38, 0xFF, 0xFE, 0x00, 0x23, 0xFF, 0xFF, 0x80, 0x0F, 0xFF, 0xFF, 0xE0, // row 22 - 24 - 0x07, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x18, 0x00, 0x00, 0x00, 0x78, // row 25 - 27 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x00, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, // row 43 - 45 - 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_36[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x0C, 0xFF, 0xFE, 0x00, // row 4 - 6 - 0x1E, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 7 - 9 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 10 - 12 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 13 - 15 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, // row 16 - 18 - 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, // row 19 - 21 - 0x38, 0xFF, 0xFE, 0x00, 0x23, 0xFF, 0xFF, 0x80, 0x0F, 0xFF, 0xFF, 0xE0, // row 22 - 24 - 0x27, 0xFF, 0xFF, 0xC0, 0x39, 0xFF, 0xFF, 0x18, 0x3E, 0x00, 0x00, 0x78, // row 25 - 27 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x1E, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x0C, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, // row 43 - 45 - 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_37[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x20, 0x00, 0xFF, 0xFE, 0x70, // row 4 - 6 - 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 7 - 9 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 10 - 12 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 13 - 15 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 16 - 18 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF8, // row 19 - 21 - 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // row 22 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x78, // row 25 - 27 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 43 - 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_38[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x20, 0x0C, 0xFF, 0xFE, 0x70, // row 4 - 6 - 0x1E, 0x00, 0x00, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 7 - 9 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 10 - 12 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 13 - 15 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 16 - 18 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0xF8, // row 19 - 21 - 0x38, 0xFF, 0xFE, 0x38, 0x23, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, // row 22 - 24 - 0x27, 0xFF, 0xFF, 0xC0, 0x39, 0xFF, 0xFF, 0x18, 0x3E, 0x00, 0x00, 0x78, // row 25 - 27 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x1E, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x0C, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, // row 43 - 45 - 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_39[192] = // 4 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, // row 1 - 3 - 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x20, 0x0C, 0xFF, 0xFE, 0x70, // row 4 - 6 - 0x1E, 0x00, 0x00, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 7 - 9 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 10 - 12 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 13 - 15 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, // row 16 - 18 - 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0xF8, // row 19 - 21 - 0x38, 0xFF, 0xFE, 0x38, 0x23, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, // row 22 - 24 - 0x07, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x18, 0x00, 0x00, 0x00, 0x78, // row 25 - 27 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 28 - 30 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 31 - 33 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 34 - 36 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, // row 37 - 39 - 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, // row 40 - 42 - 0x00, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, // row 43 - 45 - 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00 // row 46 - 48 -}; -PROGMEM const unsigned char chr_f7s_3A[96] = // 2 bytes per row -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 1 - 6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 7 - 12 - 0x00, 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x0E, 0x00, // row 13 - 18 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 19 - 24 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 25 - 30 - 0x0E, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x0E, 0x00, 0x00, 0x00, // row 31 - 36 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 37 - 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // row 43 - 48 -}; - -PROGMEM const unsigned char* const chrtbl_f7s[96] = // character pointer table -{ - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_2E, chr_f7s_20, - chr_f7s_30, chr_f7s_31, chr_f7s_32, chr_f7s_33, chr_f7s_34, chr_f7s_35, chr_f7s_36, chr_f7s_37, - chr_f7s_38, chr_f7s_39, chr_f7s_3A, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, - chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20 -}; diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Font7s.h b/GD32F1/libraries/Adafruit_GFX_AS/Font7s.h deleted file mode 100644 index fe9210b..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Font7s.h +++ /dev/null @@ -1,7 +0,0 @@ -#define nr_chrs_f7s 96 -#define chr_hgt_f7s 48 -#define data_size_f7s 8 -#define firstchr_f7s 32 - -extern const unsigned char widtbl_f7s[96]; -extern const unsigned char* const chrtbl_f7s[96]; diff --git a/GD32F1/libraries/Adafruit_GFX_AS/Load_fonts.h b/GD32F1/libraries/Adafruit_GFX_AS/Load_fonts.h deleted file mode 100644 index e2eb42a..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/Load_fonts.h +++ /dev/null @@ -1,9 +0,0 @@ -// Comment out the #defines below with // to stop that font being loaded -// If all fonts are loaded the total space required is ablout 17890 bytes - -#define LOAD_GLCD // Standard Adafruit font needs ~1792 bytes in FLASH - -#define LOAD_FONT2 // Small font, needs ~3092 bytes in FLASH -#define LOAD_FONT4 // Medium font, needs ~8126 bytes in FLASH -#define LOAD_FONT6 // Large font, needs ~4404 bytes in FLASH -#define LOAD_FONT7 // 7 segment font, needs ~3652 bytes in FLASH diff --git a/GD32F1/libraries/Adafruit_GFX_AS/README.txt b/GD32F1/libraries/Adafruit_GFX_AS/README.txt deleted file mode 100644 index 43cf08a..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/README.txt +++ /dev/null @@ -1,14 +0,0 @@ -This library has minor modifications to support STM32. -It also was modified to include additional fonts. - -This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). - -Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information. -All text above must be included in any redistribution. - -To download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h - -Place the Adafruit_GFX library folder your /Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. diff --git a/GD32F1/libraries/Adafruit_GFX_AS/glcdfont.c b/GD32F1/libraries/Adafruit_GFX_AS/glcdfont.c deleted file mode 100644 index d016b93..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/glcdfont.c +++ /dev/null @@ -1,270 +0,0 @@ -#ifndef FONT5X7_H -#define FONT5X7_H - -#ifdef __AVR__ - #include - #include -#else - #define PROGMEM -#endif - -// Standard ASCII 5x7 font - -static const unsigned char font[] PROGMEM = { - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, - 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, - 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, - 0x18, 0x3C, 0x7E, 0x3C, 0x18, - 0x1C, 0x57, 0x7D, 0x57, 0x1C, - 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, - 0x00, 0x18, 0x3C, 0x18, 0x00, - 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, - 0x00, 0x18, 0x24, 0x18, 0x00, - 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, - 0x30, 0x48, 0x3A, 0x06, 0x0E, - 0x26, 0x29, 0x79, 0x29, 0x26, - 0x40, 0x7F, 0x05, 0x05, 0x07, - 0x40, 0x7F, 0x05, 0x25, 0x3F, - 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, - 0x7F, 0x3E, 0x1C, 0x1C, 0x08, - 0x08, 0x1C, 0x1C, 0x3E, 0x7F, - 0x14, 0x22, 0x7F, 0x22, 0x14, - 0x5F, 0x5F, 0x00, 0x5F, 0x5F, - 0x06, 0x09, 0x7F, 0x01, 0x7F, - 0x00, 0x66, 0x89, 0x95, 0x6A, - 0x60, 0x60, 0x60, 0x60, 0x60, - 0x94, 0xA2, 0xFF, 0xA2, 0x94, - 0x08, 0x04, 0x7E, 0x04, 0x08, - 0x10, 0x20, 0x7E, 0x20, 0x10, - 0x08, 0x08, 0x2A, 0x1C, 0x08, - 0x08, 0x1C, 0x2A, 0x08, 0x08, - 0x1E, 0x10, 0x10, 0x10, 0x10, - 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, - 0x30, 0x38, 0x3E, 0x38, 0x30, - 0x06, 0x0E, 0x3E, 0x0E, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0x00, 0x00, - 0x00, 0x07, 0x00, 0x07, 0x00, - 0x14, 0x7F, 0x14, 0x7F, 0x14, - 0x24, 0x2A, 0x7F, 0x2A, 0x12, - 0x23, 0x13, 0x08, 0x64, 0x62, - 0x36, 0x49, 0x56, 0x20, 0x50, - 0x00, 0x08, 0x07, 0x03, 0x00, - 0x00, 0x1C, 0x22, 0x41, 0x00, - 0x00, 0x41, 0x22, 0x1C, 0x00, - 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, - 0x08, 0x08, 0x3E, 0x08, 0x08, - 0x00, 0x80, 0x70, 0x30, 0x00, - 0x08, 0x08, 0x08, 0x08, 0x08, - 0x00, 0x00, 0x60, 0x60, 0x00, - 0x20, 0x10, 0x08, 0x04, 0x02, - 0x3E, 0x51, 0x49, 0x45, 0x3E, - 0x00, 0x42, 0x7F, 0x40, 0x00, - 0x72, 0x49, 0x49, 0x49, 0x46, - 0x21, 0x41, 0x49, 0x4D, 0x33, - 0x18, 0x14, 0x12, 0x7F, 0x10, - 0x27, 0x45, 0x45, 0x45, 0x39, - 0x3C, 0x4A, 0x49, 0x49, 0x31, - 0x41, 0x21, 0x11, 0x09, 0x07, - 0x36, 0x49, 0x49, 0x49, 0x36, - 0x46, 0x49, 0x49, 0x29, 0x1E, - 0x00, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x40, 0x34, 0x00, 0x00, - 0x00, 0x08, 0x14, 0x22, 0x41, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x00, 0x41, 0x22, 0x14, 0x08, - 0x02, 0x01, 0x59, 0x09, 0x06, - 0x3E, 0x41, 0x5D, 0x59, 0x4E, - 0x7C, 0x12, 0x11, 0x12, 0x7C, - 0x7F, 0x49, 0x49, 0x49, 0x36, - 0x3E, 0x41, 0x41, 0x41, 0x22, - 0x7F, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x49, 0x49, 0x49, 0x41, - 0x7F, 0x09, 0x09, 0x09, 0x01, - 0x3E, 0x41, 0x41, 0x51, 0x73, - 0x7F, 0x08, 0x08, 0x08, 0x7F, - 0x00, 0x41, 0x7F, 0x41, 0x00, - 0x20, 0x40, 0x41, 0x3F, 0x01, - 0x7F, 0x08, 0x14, 0x22, 0x41, - 0x7F, 0x40, 0x40, 0x40, 0x40, - 0x7F, 0x02, 0x1C, 0x02, 0x7F, - 0x7F, 0x04, 0x08, 0x10, 0x7F, - 0x3E, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x09, 0x09, 0x09, 0x06, - 0x3E, 0x41, 0x51, 0x21, 0x5E, - 0x7F, 0x09, 0x19, 0x29, 0x46, - 0x26, 0x49, 0x49, 0x49, 0x32, - 0x03, 0x01, 0x7F, 0x01, 0x03, - 0x3F, 0x40, 0x40, 0x40, 0x3F, - 0x1F, 0x20, 0x40, 0x20, 0x1F, - 0x3F, 0x40, 0x38, 0x40, 0x3F, - 0x63, 0x14, 0x08, 0x14, 0x63, - 0x03, 0x04, 0x78, 0x04, 0x03, - 0x61, 0x59, 0x49, 0x4D, 0x43, - 0x00, 0x7F, 0x41, 0x41, 0x41, - 0x02, 0x04, 0x08, 0x10, 0x20, - 0x00, 0x41, 0x41, 0x41, 0x7F, - 0x04, 0x02, 0x01, 0x02, 0x04, - 0x40, 0x40, 0x40, 0x40, 0x40, - 0x00, 0x03, 0x07, 0x08, 0x00, - 0x20, 0x54, 0x54, 0x78, 0x40, - 0x7F, 0x28, 0x44, 0x44, 0x38, - 0x38, 0x44, 0x44, 0x44, 0x28, - 0x38, 0x44, 0x44, 0x28, 0x7F, - 0x38, 0x54, 0x54, 0x54, 0x18, - 0x00, 0x08, 0x7E, 0x09, 0x02, - 0x18, 0xA4, 0xA4, 0x9C, 0x78, - 0x7F, 0x08, 0x04, 0x04, 0x78, - 0x00, 0x44, 0x7D, 0x40, 0x00, - 0x20, 0x40, 0x40, 0x3D, 0x00, - 0x7F, 0x10, 0x28, 0x44, 0x00, - 0x00, 0x41, 0x7F, 0x40, 0x00, - 0x7C, 0x04, 0x78, 0x04, 0x78, - 0x7C, 0x08, 0x04, 0x04, 0x78, - 0x38, 0x44, 0x44, 0x44, 0x38, - 0xFC, 0x18, 0x24, 0x24, 0x18, - 0x18, 0x24, 0x24, 0x18, 0xFC, - 0x7C, 0x08, 0x04, 0x04, 0x08, - 0x48, 0x54, 0x54, 0x54, 0x24, - 0x04, 0x04, 0x3F, 0x44, 0x24, - 0x3C, 0x40, 0x40, 0x20, 0x7C, - 0x1C, 0x20, 0x40, 0x20, 0x1C, - 0x3C, 0x40, 0x30, 0x40, 0x3C, - 0x44, 0x28, 0x10, 0x28, 0x44, - 0x4C, 0x90, 0x90, 0x90, 0x7C, - 0x44, 0x64, 0x54, 0x4C, 0x44, - 0x00, 0x08, 0x36, 0x41, 0x00, - 0x00, 0x00, 0x77, 0x00, 0x00, - 0x00, 0x41, 0x36, 0x08, 0x00, - 0x02, 0x01, 0x02, 0x04, 0x02, - 0x3C, 0x26, 0x23, 0x26, 0x3C, - 0x1E, 0xA1, 0xA1, 0x61, 0x12, - 0x3A, 0x40, 0x40, 0x20, 0x7A, - 0x38, 0x54, 0x54, 0x55, 0x59, - 0x21, 0x55, 0x55, 0x79, 0x41, - 0x21, 0x54, 0x54, 0x78, 0x41, - 0x21, 0x55, 0x54, 0x78, 0x40, - 0x20, 0x54, 0x55, 0x79, 0x40, - 0x0C, 0x1E, 0x52, 0x72, 0x12, - 0x39, 0x55, 0x55, 0x55, 0x59, - 0x39, 0x54, 0x54, 0x54, 0x59, - 0x39, 0x55, 0x54, 0x54, 0x58, - 0x00, 0x00, 0x45, 0x7C, 0x41, - 0x00, 0x02, 0x45, 0x7D, 0x42, - 0x00, 0x01, 0x45, 0x7C, 0x40, - 0xF0, 0x29, 0x24, 0x29, 0xF0, - 0xF0, 0x28, 0x25, 0x28, 0xF0, - 0x7C, 0x54, 0x55, 0x45, 0x00, - 0x20, 0x54, 0x54, 0x7C, 0x54, - 0x7C, 0x0A, 0x09, 0x7F, 0x49, - 0x32, 0x49, 0x49, 0x49, 0x32, - 0x32, 0x48, 0x48, 0x48, 0x32, - 0x32, 0x4A, 0x48, 0x48, 0x30, - 0x3A, 0x41, 0x41, 0x21, 0x7A, - 0x3A, 0x42, 0x40, 0x20, 0x78, - 0x00, 0x9D, 0xA0, 0xA0, 0x7D, - 0x39, 0x44, 0x44, 0x44, 0x39, - 0x3D, 0x40, 0x40, 0x40, 0x3D, - 0x3C, 0x24, 0xFF, 0x24, 0x24, - 0x48, 0x7E, 0x49, 0x43, 0x66, - 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, - 0xFF, 0x09, 0x29, 0xF6, 0x20, - 0xC0, 0x88, 0x7E, 0x09, 0x03, - 0x20, 0x54, 0x54, 0x79, 0x41, - 0x00, 0x00, 0x44, 0x7D, 0x41, - 0x30, 0x48, 0x48, 0x4A, 0x32, - 0x38, 0x40, 0x40, 0x22, 0x7A, - 0x00, 0x7A, 0x0A, 0x0A, 0x72, - 0x7D, 0x0D, 0x19, 0x31, 0x7D, - 0x26, 0x29, 0x29, 0x2F, 0x28, - 0x26, 0x29, 0x29, 0x29, 0x26, - 0x30, 0x48, 0x4D, 0x40, 0x20, - 0x38, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x38, - 0x2F, 0x10, 0xC8, 0xAC, 0xBA, - 0x2F, 0x10, 0x28, 0x34, 0xFA, - 0x00, 0x00, 0x7B, 0x00, 0x00, - 0x08, 0x14, 0x2A, 0x14, 0x22, - 0x22, 0x14, 0x2A, 0x14, 0x08, - 0xAA, 0x00, 0x55, 0x00, 0xAA, - 0xAA, 0x55, 0xAA, 0x55, 0xAA, - 0x00, 0x00, 0x00, 0xFF, 0x00, - 0x10, 0x10, 0x10, 0xFF, 0x00, - 0x14, 0x14, 0x14, 0xFF, 0x00, - 0x10, 0x10, 0xFF, 0x00, 0xFF, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x14, 0x14, 0x14, 0xFC, 0x00, - 0x14, 0x14, 0xF7, 0x00, 0xFF, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x14, 0x14, 0xF4, 0x04, 0xFC, - 0x14, 0x14, 0x17, 0x10, 0x1F, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0x1F, 0x00, - 0x10, 0x10, 0x10, 0xF0, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0xF0, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x14, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x00, 0x00, 0x1F, 0x10, 0x17, - 0x00, 0x00, 0xFC, 0x04, 0xF4, - 0x14, 0x14, 0x17, 0x10, 0x17, - 0x14, 0x14, 0xF4, 0x04, 0xF4, - 0x00, 0x00, 0xFF, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0xF7, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x17, 0x14, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0xF4, 0x14, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x00, 0x00, 0x1F, 0x10, 0x1F, - 0x00, 0x00, 0x00, 0x1F, 0x14, - 0x00, 0x00, 0x00, 0xFC, 0x14, - 0x00, 0x00, 0xF0, 0x10, 0xF0, - 0x10, 0x10, 0xFF, 0x10, 0xFF, - 0x14, 0x14, 0x14, 0xFF, 0x14, - 0x10, 0x10, 0x10, 0x1F, 0x00, - 0x00, 0x00, 0x00, 0xF0, 0x10, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x38, 0x44, 0x44, 0x38, 0x44, - 0x7C, 0x2A, 0x2A, 0x3E, 0x14, - 0x7E, 0x02, 0x02, 0x06, 0x06, - 0x02, 0x7E, 0x02, 0x7E, 0x02, - 0x63, 0x55, 0x49, 0x41, 0x63, - 0x38, 0x44, 0x44, 0x3C, 0x04, - 0x40, 0x7E, 0x20, 0x1E, 0x20, - 0x06, 0x02, 0x7E, 0x02, 0x02, - 0x99, 0xA5, 0xE7, 0xA5, 0x99, - 0x1C, 0x2A, 0x49, 0x2A, 0x1C, - 0x4C, 0x72, 0x01, 0x72, 0x4C, - 0x30, 0x4A, 0x4D, 0x4D, 0x30, - 0x30, 0x48, 0x78, 0x48, 0x30, - 0xBC, 0x62, 0x5A, 0x46, 0x3D, - 0x3E, 0x49, 0x49, 0x49, 0x00, - 0x7E, 0x01, 0x01, 0x01, 0x7E, - 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, - 0x44, 0x44, 0x5F, 0x44, 0x44, - 0x40, 0x51, 0x4A, 0x44, 0x40, - 0x40, 0x44, 0x4A, 0x51, 0x40, - 0x00, 0x00, 0xFF, 0x01, 0x03, - 0xE0, 0x80, 0xFF, 0x00, 0x00, - 0x08, 0x08, 0x6B, 0x6B, 0x08, - 0x36, 0x12, 0x36, 0x24, 0x36, - 0x06, 0x0F, 0x09, 0x0F, 0x06, - 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x10, 0x10, 0x00, - 0x30, 0x40, 0xFF, 0x01, 0x01, - 0x00, 0x1F, 0x01, 0x01, 0x1E, - 0x00, 0x19, 0x1D, 0x17, 0x12, - 0x00, 0x3C, 0x3C, 0x3C, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00 -}; -#endif // FONT5X7_H diff --git a/GD32F1/libraries/Adafruit_GFX_AS/license.txt b/GD32F1/libraries/Adafruit_GFX_AS/license.txt deleted file mode 100644 index 7492e93..0000000 --- a/GD32F1/libraries/Adafruit_GFX_AS/license.txt +++ /dev/null @@ -1,24 +0,0 @@ -Software License Agreement (BSD License) - -Copyright (c) 2012 Adafruit Industries. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/GD32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp b/GD32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp deleted file mode 100644 index 4f1e146..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp +++ /dev/null @@ -1,632 +0,0 @@ -/*************************************************** - This is our library for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - -#include "Adafruit_ILI9341.h" -#include -#include -#include "pins_arduino.h" -#include "wiring_private.h" -#include - -// Constructor when using software SPI. All output pins are configurable. -Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t mosi, - int8_t sclk, int8_t rst, int8_t miso) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { - _cs = cs; - _dc = dc; - _mosi = mosi; - _miso = miso; - _sclk = sclk; - _rst = rst; - hwSPI = false; -} - - -// Constructor when using hardware SPI. Faster, but must use SPI pins -// specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.) -Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t rst) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { - _cs = cs; - _dc = dc; - _rst = rst; - hwSPI = true; - _mosi = _sclk = 0; -} - -void Adafruit_ILI9341::spiwrite(uint8_t c) { - - //Serial.print("0x"); Serial.print(c, HEX); Serial.print(", "); - - if (hwSPI) { -#if defined (__AVR__) - uint8_t backupSPCR = SPCR; - SPCR = mySPCR; - SPDR = c; - while(!(SPSR & _BV(SPIF))); - SPCR = backupSPCR; -#elif defined(TEENSYDUINO) - SPI.transfer(c); -#elif defined (__STM32F1__) - SPI.write(c);// Faster than transfer as we don't need to read -#elif defined (__arm__) - SPI.setClockDivider(11); // 8-ish MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - SPI.transfer(c); -#endif - } else { - // Fast SPI bitbang swiped from LPD8806 library - for(uint8_t bit = 0x80; bit; bit >>= 1) { - if(c & bit) { - //digitalWrite(_mosi, HIGH); - *mosiport |= mosipinmask; - } else { - //digitalWrite(_mosi, LOW); - *mosiport &= ~mosipinmask; - } - //digitalWrite(_sclk, HIGH); - *clkport |= clkpinmask; - //digitalWrite(_sclk, LOW); - *clkport &= ~clkpinmask; - } - } -} - - -void Adafruit_ILI9341::writecommand(uint8_t c) { - *dcport &= ~dcpinmask; - *csport &= ~cspinmask; - SPI.write(c); - *csport |= cspinmask; -} - - -void Adafruit_ILI9341::writedata(uint8_t c) { - *dcport |= dcpinmask; - *csport &= ~cspinmask; - SPI.write(c); - *csport |= cspinmask; -} - -// If the SPI library has transaction support, these functions -// establish settings and protect from interference from other -// libraries. Otherwise, they simply do nothing. -#ifdef SPI_HAS_TRANSACTION -static inline void spi_begin(void) __attribute__((always_inline)); -static inline void spi_begin(void) { - SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); -} -static inline void spi_end(void) __attribute__((always_inline)); -static inline void spi_end(void) { - SPI.endTransaction(); -} -#else -#define spi_begin() -#define spi_end() -#endif - -// Rather than a bazillion writecommand() and writedata() calls, screen -// initialization commands and arguments are organized in these tables -// stored in PROGMEM. The table may look bulky, but that's mostly the -// formatting -- storage-wise this is hundreds of bytes more compact -// than the equivalent code. Companion function follows. -#define DELAY 0x80 - - -// Companion code to the above tables. Reads and issues -// a series of LCD commands stored in PROGMEM byte array. -void Adafruit_ILI9341::commandList(uint8_t *addr) { - - uint8_t numCommands, numArgs; - uint16_t ms; - - *dcport |= dcpinmask; - *csport &= ~cspinmask; - - - - - numCommands = pgm_read_byte(addr++); // Number of commands to follow - while(numCommands--) { // For each command... - writecommand(pgm_read_byte(addr++)); // Read, issue command - numArgs = pgm_read_byte(addr++); // Number of args to follow - ms = numArgs & DELAY; // If hibit set, delay follows args - numArgs &= ~DELAY; // Mask out delay bit - while(numArgs--) { // For each argument... - SPI.write(pgm_read_byte(addr++)); // Read, issue argument - } - - if(ms) { - ms = pgm_read_byte(addr++); // Read post-command delay time (ms) - if(ms == 255) ms = 500; // If 255, delay for 500 ms - delay(ms); - } - } - *csport |= cspinmask; -} - - -void Adafruit_ILI9341::begin(void) { - if (_rst > 0) { - pinMode(_rst, OUTPUT); - digitalWrite(_rst, LOW); - } - - pinMode(_dc, OUTPUT); - pinMode(_cs, OUTPUT); - csport = portOutputRegister(digitalPinToPort(_cs)); - cspinmask = digitalPinToBitMask(_cs); - dcport = portOutputRegister(digitalPinToPort(_dc)); - dcpinmask = digitalPinToBitMask(_dc); - - if(hwSPI) { // Using hardware SPI -#if defined (__AVR__) - SPI.begin(); - SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - mySPCR = SPCR; -#elif defined(TEENSYDUINO) || defined (__STM32F1__) - SPI.begin(); - SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); -#elif defined (__arm__) - SPI.begin(); - SPI.setClockDivider(11); // 8-ish MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); -#endif - } else { - pinMode(_sclk, OUTPUT); - pinMode(_mosi, OUTPUT); - pinMode(_miso, INPUT); - clkport = portOutputRegister(digitalPinToPort(_sclk)); - clkpinmask = digitalPinToBitMask(_sclk); - mosiport = portOutputRegister(digitalPinToPort(_mosi)); - mosipinmask = digitalPinToBitMask(_mosi); - *clkport &= ~clkpinmask; - *mosiport &= ~mosipinmask; - } - - // toggle RST low to reset - if (_rst > 0) { - digitalWrite(_rst, HIGH); - delay(5); - digitalWrite(_rst, LOW); - delay(20); - digitalWrite(_rst, HIGH); - delay(150); - } - - - if (hwSPI) spi_begin(); - writecommand(0xEF); - writedata(0x03); - writedata(0x80); - writedata(0x02); - - writecommand(0xCF); - writedata(0x00); - writedata(0XC1); - writedata(0X30); - - writecommand(0xED); - writedata(0x64); - writedata(0x03); - writedata(0X12); - writedata(0X81); - - writecommand(0xE8); - writedata(0x85); - writedata(0x00); - writedata(0x78); - - writecommand(0xCB); - writedata(0x39); - writedata(0x2C); - writedata(0x00); - writedata(0x34); - writedata(0x02); - - writecommand(0xF7); - writedata(0x20); - - writecommand(0xEA); - writedata(0x00); - writedata(0x00); - - writecommand(ILI9341_PWCTR1); //Power control - writedata(0x23); //VRH[5:0] - - writecommand(ILI9341_PWCTR2); //Power control - writedata(0x10); //SAP[2:0];BT[3:0] - - writecommand(ILI9341_VMCTR1); //VCM control - writedata(0x3e); //??????? - writedata(0x28); - - writecommand(ILI9341_VMCTR2); //VCM control2 - writedata(0x86); //-- - - writecommand(ILI9341_MADCTL); // Memory Access Control - writedata(0x48); - - writecommand(ILI9341_PIXFMT); - writedata(0x55); - - writecommand(ILI9341_FRMCTR1); - writedata(0x00); - writedata(0x18); - - writecommand(ILI9341_DFUNCTR); // Display Function Control - writedata(0x08); - writedata(0x82); - writedata(0x27); - - writecommand(0xF2); // 3Gamma Function Disable - writedata(0x00); - - writecommand(ILI9341_GAMMASET); //Gamma curve selected - writedata(0x01); - - writecommand(ILI9341_GMCTRP1); //Set Gamma - writedata(0x0F); - writedata(0x31); - writedata(0x2B); - writedata(0x0C); - writedata(0x0E); - writedata(0x08); - writedata(0x4E); - writedata(0xF1); - writedata(0x37); - writedata(0x07); - writedata(0x10); - writedata(0x03); - writedata(0x0E); - writedata(0x09); - writedata(0x00); - - writecommand(ILI9341_GMCTRN1); //Set Gamma - writedata(0x00); - writedata(0x0E); - writedata(0x14); - writedata(0x03); - writedata(0x11); - writedata(0x07); - writedata(0x31); - writedata(0xC1); - writedata(0x48); - writedata(0x08); - writedata(0x0F); - writedata(0x0C); - writedata(0x31); - writedata(0x36); - writedata(0x0F); - - writecommand(ILI9341_SLPOUT); //Exit Sleep - if (hwSPI) spi_end(); - delay(120); - if (hwSPI) spi_begin(); - writecommand(ILI9341_DISPON); //Display on - if (hwSPI) spi_end(); - -} - - -void Adafruit_ILI9341::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, - uint16_t y1) { - - writecommand(ILI9341_CASET); // Column addr set - *dcport |= dcpinmask; - *csport &= ~cspinmask; - SPI.write(x0 >> 8); - SPI.write(x0 & 0xFF); // XSTART - SPI.write(x1 >> 8); - SPI.write(x1 & 0xFF); // XEND - - writecommand(ILI9341_PASET); // Row addr set - *dcport |= dcpinmask; - *csport &= ~cspinmask; - SPI.write(y0>>8); - SPI.write(y0); // YSTART - SPI.write(y1>>8); - SPI.write(y1); // YEND - - writecommand(ILI9341_RAMWR); // write to RAM -} - - -void Adafruit_ILI9341::pushColor(uint16_t color) { - if (hwSPI) spi_begin(); - - *dcport |= dcpinmask; - - *csport &= ~cspinmask; - - SPI.write(color >> 8); - SPI.write(color); - - *csport |= cspinmask; - //digitalWrite(_cs, HIGH); - if (hwSPI) spi_end(); -} - -void Adafruit_ILI9341::drawPixel(int16_t x, int16_t y, uint16_t color) { - - if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return; - - if (hwSPI) spi_begin(); - setAddrWindow(x,y,x+1,y+1); - - *dcport |= dcpinmask; - *csport &= ~cspinmask; - - SPI.write(color >> 8); - SPI.write(color); - - *csport |= cspinmask; - if (hwSPI) spi_end(); -} - - -void Adafruit_ILI9341::drawFastVLine(int16_t x, int16_t y, int16_t h, - uint16_t color) { - - // Rudimentary clipping - if((x >= _width) || (y >= _height)) return; - - if((y+h-1) >= _height) - { - h = _height-y; - } - - if (hwSPI) spi_begin(); - setAddrWindow(x, y, x, y+h-1); - uint8_t hi = color >> 8, lo = color; - *dcport |= dcpinmask; - *csport &= ~cspinmask; - - while (h--) - { - SPI.write(hi); - SPI.write(lo); - } - *csport |= cspinmask; - - if (hwSPI) spi_end(); -} - - -void Adafruit_ILI9341::drawFastHLine(int16_t x, int16_t y, int16_t w, - uint16_t color) { - - // Rudimentary clipping - if((x >= _width) || (y >= _height)) return; - if((x+w-1) >= _width) w = _width-x; - if (hwSPI) spi_begin(); - setAddrWindow(x, y, x+w-1, y); - - uint8_t hi = color >> 8, lo = color; - *dcport |= dcpinmask; - *csport &= ~cspinmask; - while (w--) { - SPI.write(hi); - SPI.write(lo); - } - *csport |= cspinmask; - if (hwSPI) spi_end(); -} - -void Adafruit_ILI9341::fillScreen(uint16_t color) { - fillRect(0, 0, _width, _height, color); -} - -// fill a rectangle -void Adafruit_ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color) { - int numPixels; - // rudimentary clipping (drawChar w/big text requires this) - if((x >= _width) || (y >= _height)) return; - if((x + w - 1) >= _width) w = _width - x; - if((y + h - 1) >= _height) h = _height - y; - - if (hwSPI) spi_begin(); - setAddrWindow(x, y, x+w-1, y+h-1); - - uint8_t hi = color >> 8, lo = color; - - *dcport |= dcpinmask; - *csport &= ~cspinmask; - - for(y=h; y>0; y--) - { - for(x=w; x>0; x--) - { - SPI.write(hi); - SPI.write(lo); - } - } - - if (hwSPI) spi_end(); - *csport |= cspinmask; -} - - -// Pass 8-bit (each) R,G,B, get back 16-bit packed color -uint16_t Adafruit_ILI9341::color565(uint8_t r, uint8_t g, uint8_t b) { - return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); -} - - -#define MADCTL_MY 0x80 -#define MADCTL_MX 0x40 -#define MADCTL_MV 0x20 -#define MADCTL_ML 0x10 -#define MADCTL_RGB 0x00 -#define MADCTL_BGR 0x08 -#define MADCTL_MH 0x04 - -void Adafruit_ILI9341::setRotation(uint8_t m) { - - if (hwSPI) spi_begin(); - writecommand(ILI9341_MADCTL); - rotation = m % 4; // can't be higher than 3 - switch (rotation) { - case 0: - writedata(MADCTL_MX | MADCTL_BGR); - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - break; - case 1: - writedata(MADCTL_MV | MADCTL_BGR); - _width = ILI9341_TFTHEIGHT; - _height = ILI9341_TFTWIDTH; - break; - case 2: - writedata(MADCTL_MY | MADCTL_BGR); - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - break; - case 3: - writedata(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); - _width = ILI9341_TFTHEIGHT; - _height = ILI9341_TFTWIDTH; - break; - } - if (hwSPI) spi_end(); -} - - -void Adafruit_ILI9341::invertDisplay(boolean i) { - if (hwSPI) spi_begin(); - writecommand(i ? ILI9341_INVON : ILI9341_INVOFF); - if (hwSPI) spi_end(); -} - - -////////// stuff not actively being used, but kept for posterity - - -uint8_t Adafruit_ILI9341::spiread(void) { - uint8_t r = 0; - - if (hwSPI) { -#if defined (__AVR__) - uint8_t backupSPCR = SPCR; - SPCR = mySPCR; - SPDR = 0x00; - while(!(SPSR & _BV(SPIF))); - r = SPDR; - SPCR = backupSPCR; -#elif defined(TEENSYDUINO) || defined (__STM32F1__) - r = SPI.transfer(0x00); -#elif defined (__arm__) - SPI.setClockDivider(11); // 8-ish MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - r = SPI.transfer(0x00); -#endif - } else { - - for (uint8_t i=0; i<8; i++) { - digitalWrite(_sclk, LOW); - digitalWrite(_sclk, HIGH); - r <<= 1; - if (digitalRead(_miso)) - r |= 0x1; - } - } - //Serial.print("read: 0x"); Serial.print(r, HEX); - - return r; -} - - uint8_t Adafruit_ILI9341::readdata(void) { - digitalWrite(_dc, HIGH); - digitalWrite(_cs, LOW); - uint8_t r = spiread(); - digitalWrite(_cs, HIGH); - - return r; -} - - -uint8_t Adafruit_ILI9341::readcommand8(uint8_t c, uint8_t index) { - if (hwSPI) spi_begin(); - digitalWrite(_dc, LOW); // command - digitalWrite(_cs, LOW); - SPI.write(0xD9); // woo sekret command? - digitalWrite(_dc, HIGH); // data - SPI.write(0x10 + index); - digitalWrite(_cs, HIGH); - - digitalWrite(_dc, LOW); - digitalWrite(_sclk, LOW); - digitalWrite(_cs, LOW); - SPI.write(c); - - digitalWrite(_dc, HIGH); - uint8_t r = spiread(); - digitalWrite(_cs, HIGH); - if (hwSPI) spi_end(); - return r; -} - - - -/* - - uint16_t Adafruit_ILI9341::readcommand16(uint8_t c) { - digitalWrite(_dc, LOW); - if (_cs) - digitalWrite(_cs, LOW); - - spiwrite(c); - pinMode(_sid, INPUT); // input! - uint16_t r = spiread(); - r <<= 8; - r |= spiread(); - if (_cs) - digitalWrite(_cs, HIGH); - - pinMode(_sid, OUTPUT); // back to output - return r; - } - - uint32_t Adafruit_ILI9341::readcommand32(uint8_t c) { - digitalWrite(_dc, LOW); - if (_cs) - digitalWrite(_cs, LOW); - spiwrite(c); - pinMode(_sid, INPUT); // input! - - dummyclock(); - dummyclock(); - - uint32_t r = spiread(); - r <<= 8; - r |= spiread(); - r <<= 8; - r |= spiread(); - r <<= 8; - r |= spiread(); - if (_cs) - digitalWrite(_cs, HIGH); - - pinMode(_sid, OUTPUT); // back to output - return r; - } - - */ - diff --git a/GD32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.h b/GD32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.h deleted file mode 100644 index 1e9bf60..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/Adafruit_ILI9341.h +++ /dev/null @@ -1,170 +0,0 @@ -/*************************************************** - This is our library for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - -#ifndef _ADAFRUIT_ILI9341H_ -#define _ADAFRUIT_ILI9341H_ - -#if ARDUINO >= 100 - #include "Arduino.h" - #include "Print.h" -#else - #include "WProgram.h" -#endif -#include -#include - - -#define ILI9341_TFTWIDTH 240 -#define ILI9341_TFTHEIGHT 320 - -#define ILI9341_NOP 0x00 -#define ILI9341_SWRESET 0x01 -#define ILI9341_RDDID 0x04 -#define ILI9341_RDDST 0x09 - -#define ILI9341_SLPIN 0x10 -#define ILI9341_SLPOUT 0x11 -#define ILI9341_PTLON 0x12 -#define ILI9341_NORON 0x13 - -#define ILI9341_RDMODE 0x0A -#define ILI9341_RDMADCTL 0x0B -#define ILI9341_RDPIXFMT 0x0C -#define ILI9341_RDIMGFMT 0x0A -#define ILI9341_RDSELFDIAG 0x0F - -#define ILI9341_INVOFF 0x20 -#define ILI9341_INVON 0x21 -#define ILI9341_GAMMASET 0x26 -#define ILI9341_DISPOFF 0x28 -#define ILI9341_DISPON 0x29 - -#define ILI9341_CASET 0x2A -#define ILI9341_PASET 0x2B -#define ILI9341_RAMWR 0x2C -#define ILI9341_RAMRD 0x2E - -#define ILI9341_PTLAR 0x30 -#define ILI9341_MADCTL 0x36 -#define ILI9341_PIXFMT 0x3A - -#define ILI9341_FRMCTR1 0xB1 -#define ILI9341_FRMCTR2 0xB2 -#define ILI9341_FRMCTR3 0xB3 -#define ILI9341_INVCTR 0xB4 -#define ILI9341_DFUNCTR 0xB6 - -#define ILI9341_PWCTR1 0xC0 -#define ILI9341_PWCTR2 0xC1 -#define ILI9341_PWCTR3 0xC2 -#define ILI9341_PWCTR4 0xC3 -#define ILI9341_PWCTR5 0xC4 -#define ILI9341_VMCTR1 0xC5 -#define ILI9341_VMCTR2 0xC7 - -#define ILI9341_RDID1 0xDA -#define ILI9341_RDID2 0xDB -#define ILI9341_RDID3 0xDC -#define ILI9341_RDID4 0xDD - -#define ILI9341_GMCTRP1 0xE0 -#define ILI9341_GMCTRN1 0xE1 -/* -#define ILI9341_PWCTR6 0xFC - -*/ - -// Color definitions -#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */ -#define ILI9341_NAVY 0x000F /* 0, 0, 128 */ -#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */ -#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */ -#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */ -#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */ -#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */ -#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */ -#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */ -#define ILI9341_BLUE 0x001F /* 0, 0, 255 */ -#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */ -#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */ -#define ILI9341_RED 0xF800 /* 255, 0, 0 */ -#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */ -#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */ -#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */ -#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */ -#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ -#define ILI9341_PINK 0xF81F - -class Adafruit_ILI9341 : public Adafruit_GFX { - - public: - - Adafruit_ILI9341(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, - int8_t _RST, int8_t _MISO); - Adafruit_ILI9341(int8_t _CS, int8_t _DC, int8_t _RST = -1); - - void begin(void), - setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1), - pushColor(uint16_t color), - fillScreen(uint16_t color), - drawPixel(int16_t x, int16_t y, uint16_t color), - drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), - drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), - fillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color), - setRotation(uint8_t r), - invertDisplay(boolean i); - uint16_t color565(uint8_t r, uint8_t g, uint8_t b); - - /* These are not for current use, 8-bit protocol only! */ - uint8_t readdata(void), - readcommand8(uint8_t reg, uint8_t index = 0); - /* - uint16_t readcommand16(uint8_t); - uint32_t readcommand32(uint8_t); - void dummyclock(void); - */ - - void spiwrite(uint8_t), - writecommand(uint8_t c), - writedata(uint8_t d), - commandList(uint8_t *addr); - uint8_t spiread(void); - - private: - uint8_t tabcolor; - - - - boolean hwSPI; -#if defined (__STM32F1__) -#define RwReg uint32 -#endif - - -#if defined (__AVR__) || defined(TEENSYDUINO) - uint8_t mySPCR; - volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport; - int8_t _cs, _dc, _rst, _mosi, _miso, _sclk; - uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask; -#elif defined (__arm__) - volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport; - uint32_t _cs, _dc, _rst, _mosi, _miso, _sclk; - uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask; -#endif -}; - -#endif - diff --git a/GD32F1/libraries/Adafruit_ILI9341/README.txt b/GD32F1/libraries/Adafruit_ILI9341/README.txt deleted file mode 100644 index 58d2b57..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/README.txt +++ /dev/null @@ -1,38 +0,0 @@ -This library is based on the Adafruit ILI9341 (see original Adafuit text description below) - - -It has minor modifications to support STM32 and also one small change to use spi.write(byte) instead of spi.transfer(byte) as this gave -a useful speed improvement. - -It has been tested with standard ILI9341 from various suppliers e.g on eBay - -This library requires the Adafruit GFC library, https://github.com/adafruit/Adafruit-GFX-Library - -An addition example stm32_graphicstest has been added to show how to configure for stm32 - which uses hardware SPI and hence its not possible to -set the SCK MISO and MOSI pins. - -_________________________ Original text from Adafruit ____________________________________________ - - - -This is a library for the Adafruit ILI9341 display products - -This library works with the Adafruit 2.8" Touch Shield V2 (SPI) - ----> http://www.adafruit.com/products/1651 - -Check out the links above for our tutorials and wiring diagrams. -These displays use SPI to communicate, 4 or 5 pins are required -to interface (RST is optional). - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -MIT license, all text above must be included in any redistribution - -To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_ILI9341. Check that the Adafruit_ILI9341 folder contains Adafruit_ILI9341.cpp and Adafruit_ILI9341. - -Place the Adafruit_ILI9341 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE - -Also requires the Adafruit_GFX library for Arduino. diff --git a/GD32F1/libraries/Adafruit_ILI9341/examples/breakouttouchpaint/breakouttouchpaint.ino b/GD32F1/libraries/Adafruit_ILI9341/examples/breakouttouchpaint/breakouttouchpaint.ino deleted file mode 100644 index 298bcad..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/examples/breakouttouchpaint/breakouttouchpaint.ino +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************** - This is our touchscreen painting example for the Adafruit ILI9341 Breakout - ----> http://www.adafruit.com/products/1770 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - -/** NOT FOR USE WITH THE TOUCH SHIELD, ONLY FOR THE BREAKOUT! **/ - -#include // Core graphics library -#include -#include -#include "TouchScreen.h" - -// These are the four touchscreen analog pins -#define YP A2 // must be an analog pin, use "An" notation! -#define XM A3 // must be an analog pin, use "An" notation! -#define YM 5 // can be a digital pin -#define XP 4 // can be a digital pin - -// This is calibration data for the raw touch data to the screen coordinates -#define TS_MINX 150 -#define TS_MINY 120 -#define TS_MAXX 920 -#define TS_MAXY 940 - -#define MINPRESSURE 10 -#define MAXPRESSURE 1000 - -// The display uses hardware SPI, plus #9 & #10 -#define TFT_CS 10 -#define TFT_DC 9 -Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); - -// For better pressure precision, we need to know the resistance -// between X+ and X- Use any multimeter to read it -// For the one we're using, its 300 ohms across the X plate -TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); - -// Size of the color selection boxes and the paintbrush size -#define BOXSIZE 40 -#define PENRADIUS 3 -int oldcolor, currentcolor; - -void setup(void) { - // while (!Serial); // used for leonardo debugging - - Serial.begin(9600); - Serial.println(F("Touch Paint!")); - - tft.begin(); - tft.fillScreen(ILI9341_BLACK); - - // make the color selection boxes - tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED); - tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW); - tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN); - tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN); - tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE); - tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA); - - // select the current color 'red' - tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - currentcolor = ILI9341_RED; -} - - -void loop() -{ - // Retrieve a point - TSPoint p = ts.getPoint(); - - /* - Serial.print("X = "); Serial.print(p.x); - Serial.print("\tY = "); Serial.print(p.y); - Serial.print("\tPressure = "); Serial.println(p.z); - */ - - // we have some minimum pressure we consider 'valid' - // pressure of 0 means no pressing! - if (p.z < MINPRESSURE || p.z > MAXPRESSURE) { - return; - } - - // Scale from ~0->1000 to tft.width using the calibration #'s - p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width()); - p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height()); - - /* - Serial.print("("); Serial.print(p.x); - Serial.print(", "); Serial.print(p.y); - Serial.println(")"); - */ - - - if (p.y < BOXSIZE) { - oldcolor = currentcolor; - - if (p.x < BOXSIZE) { - currentcolor = ILI9341_RED; - tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*2) { - currentcolor = ILI9341_YELLOW; - tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*3) { - currentcolor = ILI9341_GREEN; - tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*4) { - currentcolor = ILI9341_CYAN; - tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*5) { - currentcolor = ILI9341_BLUE; - tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*6) { - currentcolor = ILI9341_MAGENTA; - tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } - - if (oldcolor != currentcolor) { - if (oldcolor == ILI9341_RED) - tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED); - if (oldcolor == ILI9341_YELLOW) - tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW); - if (oldcolor == ILI9341_GREEN) - tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN); - if (oldcolor == ILI9341_CYAN) - tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN); - if (oldcolor == ILI9341_BLUE) - tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE); - if (oldcolor == ILI9341_MAGENTA) - tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA); - } - } - if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) { - tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor); - } -} diff --git a/GD32F1/libraries/Adafruit_ILI9341/examples/graphicstest/graphicstest.ino b/GD32F1/libraries/Adafruit_ILI9341/examples/graphicstest/graphicstest.ino deleted file mode 100644 index 07ec02f..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/examples/graphicstest/graphicstest.ino +++ /dev/null @@ -1,349 +0,0 @@ -/*************************************************** - This is our GFX example for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#include "SPI.h" -#include "Adafruit_GFX.h" -#include "Adafruit_ILI9341.h" - -// For the Adafruit shield, these are the default. -#define TFT_DC 9 -#define TFT_CS 10 - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); -// If using the breakout, change pins as desired -//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); - -void setup() { - Serial.begin(9600); - Serial.println("ILI9341 Test!"); - - tft.begin(); - - // read diagnostics (optional but can help debug problems) - uint8_t x = tft.readcommand8(ILI9341_RDMODE); - Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDMADCTL); - Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDPIXFMT); - Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDIMGFMT); - Serial.print("Image Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDSELFDIAG); - Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); - - Serial.println(F("Benchmark Time (microseconds)")); - - Serial.print(F("Screen fill ")); - Serial.println(testFillScreen()); - delay(500); - - Serial.print(F("Text ")); - Serial.println(testText()); - delay(3000); - - Serial.print(F("Lines ")); - Serial.println(testLines(ILI9341_CYAN)); - delay(500); - - Serial.print(F("Horiz/Vert Lines ")); - Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE)); - delay(500); - - Serial.print(F("Rectangles (outline) ")); - Serial.println(testRects(ILI9341_GREEN)); - delay(500); - - Serial.print(F("Rectangles (filled) ")); - Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); - delay(500); - - Serial.print(F("Circles (filled) ")); - Serial.println(testFilledCircles(10, ILI9341_MAGENTA)); - - Serial.print(F("Circles (outline) ")); - Serial.println(testCircles(10, ILI9341_WHITE)); - delay(500); - - Serial.print(F("Triangles (outline) ")); - Serial.println(testTriangles()); - delay(500); - - Serial.print(F("Triangles (filled) ")); - Serial.println(testFilledTriangles()); - delay(500); - - Serial.print(F("Rounded rects (outline) ")); - Serial.println(testRoundRects()); - delay(500); - - Serial.print(F("Rounded rects (filled) ")); - Serial.println(testFilledRoundRects()); - delay(500); - - Serial.println(F("Done!")); - -} - - -void loop(void) { - for(uint8_t rotation=0; rotation<4; rotation++) { - tft.setRotation(rotation); - testText(); - delay(1000); - } -} - -unsigned long testFillScreen() { - unsigned long start = micros(); - tft.fillScreen(ILI9341_BLACK); - tft.fillScreen(ILI9341_RED); - tft.fillScreen(ILI9341_GREEN); - tft.fillScreen(ILI9341_BLUE); - tft.fillScreen(ILI9341_BLACK); - return micros() - start; -} - -unsigned long testText() { - tft.fillScreen(ILI9341_BLACK); - unsigned long start = micros(); - tft.setCursor(0, 0); - tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); - tft.println("Hello World!"); - tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2); - tft.println(1234.56); - tft.setTextColor(ILI9341_RED); tft.setTextSize(3); - tft.println(0xDEADBEEF, HEX); - tft.println(); - tft.setTextColor(ILI9341_GREEN); - tft.setTextSize(5); - tft.println("Groop"); - tft.setTextSize(2); - tft.println("I implore thee,"); - tft.setTextSize(1); - tft.println("my foonting turlingdromes."); - tft.println("And hooptiously drangle me"); - tft.println("with crinkly bindlewurdles,"); - tft.println("Or I will rend thee"); - tft.println("in the gobberwarts"); - tft.println("with my blurglecruncheon,"); - tft.println("see if I don't!"); - return micros() - start; -} - -unsigned long testLines(uint16_t color) { - unsigned long start, t; - int x1, y1, x2, y2, - w = tft.width(), - h = tft.height(); - - tft.fillScreen(ILI9341_BLACK); - - x1 = y1 = 0; - y2 = h - 1; - start = micros(); - for(x2=0; x20; i-=6) { - i2 = i / 2; - start = micros(); - tft.fillRect(cx-i2, cy-i2, i, i, color1); - t += micros() - start; - // Outlines are not included in timing results - tft.drawRect(cx-i2, cy-i2, i, i, color2); - } - - return t; -} - -unsigned long testFilledCircles(uint8_t radius, uint16_t color) { - unsigned long start; - int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; - - tft.fillScreen(ILI9341_BLACK); - start = micros(); - for(x=radius; x10; i-=5) { - start = micros(); - tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(0, i, i)); - t += micros() - start; - tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(i, i, 0)); - } - - return t; -} - -unsigned long testRoundRects() { - unsigned long start; - int w, i, i2, - cx = tft.width() / 2 - 1, - cy = tft.height() / 2 - 1; - - tft.fillScreen(ILI9341_BLACK); - w = min(tft.width(), tft.height()); - start = micros(); - for(i=0; i20; i-=6) { - i2 = i / 2; - tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); - } - - return micros() - start; -} \ No newline at end of file diff --git a/GD32F1/libraries/Adafruit_ILI9341/examples/onoffbutton/onoffbutton.ino b/GD32F1/libraries/Adafruit_ILI9341/examples/onoffbutton/onoffbutton.ino deleted file mode 100644 index 3365d33..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/examples/onoffbutton/onoffbutton.ino +++ /dev/null @@ -1,125 +0,0 @@ -//This example implements a simple sliding On/Off button. The example -// demonstrates drawing and touch operations. -// -//Thanks to Adafruit forums member Asteroid for the original sketch! -// -#include -#include -#include -#include -#include - -// This is calibration data for the raw touch data to the screen coordinates -#define TS_MINX 150 -#define TS_MINY 130 -#define TS_MAXX 3800 -#define TS_MAXY 4000 - -#define STMPE_CS 8 -Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS); -#define TFT_CS 10 -#define TFT_DC 9 -Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); - -boolean RecordOn = false; - -#define FRAME_X 210 -#define FRAME_Y 180 -#define FRAME_W 100 -#define FRAME_H 50 - -#define REDBUTTON_X FRAME_X -#define REDBUTTON_Y FRAME_Y -#define REDBUTTON_W (FRAME_W/2) -#define REDBUTTON_H FRAME_H - -#define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W) -#define GREENBUTTON_Y FRAME_Y -#define GREENBUTTON_W (FRAME_W/2) -#define GREENBUTTON_H FRAME_H - -void drawFrame() -{ - tft.drawRect(FRAME_X, FRAME_Y, FRAME_W, FRAME_H, ILI9341_BLACK); -} - -void redBtn() -{ - tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_RED); - tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_BLUE); - drawFrame(); - tft.setCursor(GREENBUTTON_X + 6 , GREENBUTTON_Y + (GREENBUTTON_H/2)); - tft.setTextColor(ILI9341_WHITE); - tft.setTextSize(2); - tft.println("ON"); - RecordOn = false; -} - -void greenBtn() -{ - tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_GREEN); - tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_BLUE); - drawFrame(); - tft.setCursor(REDBUTTON_X + 6 , REDBUTTON_Y + (REDBUTTON_H/2)); - tft.setTextColor(ILI9341_WHITE); - tft.setTextSize(2); - tft.println("OFF"); - RecordOn = true; -} - -void setup(void) -{ - Serial.begin(9600); - tft.begin(); - if (!ts.begin()) { - Serial.println("Unable to start touchscreen."); - } - else { - Serial.println("Touchscreen started."); - } - - tft.fillScreen(ILI9341_BLUE); - // origin = left,top landscape (USB left upper) - tft.setRotation(1); - redBtn(); -} - -void loop() -{ - // See if there's any touch data for us - if (!ts.bufferEmpty()) - { - // Retrieve a point - TS_Point p = ts.getPoint(); - // Scale using the calibration #'s - // and rotate coordinate system - p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height()); - p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width()); - int y = tft.height() - p.x; - int x = p.y; - - if (RecordOn) - { - if((x > REDBUTTON_X) && (x < (REDBUTTON_X + REDBUTTON_W))) { - if ((y > REDBUTTON_Y) && (y <= (REDBUTTON_Y + REDBUTTON_H))) { - Serial.println("Red btn hit"); - redBtn(); - } - } - } - else //Record is off (RecordOn == false) - { - if((x > GREENBUTTON_X) && (x < (GREENBUTTON_X + GREENBUTTON_W))) { - if ((y > GREENBUTTON_Y) && (y <= (GREENBUTTON_Y + GREENBUTTON_H))) { - Serial.println("Green btn hit"); - greenBtn(); - } - } - } - - Serial.println(RecordOn); - } -} - - - diff --git a/GD32F1/libraries/Adafruit_ILI9341/examples/onoffbutton_breakout/onoffbutton_breakout.ino b/GD32F1/libraries/Adafruit_ILI9341/examples/onoffbutton_breakout/onoffbutton_breakout.ino deleted file mode 100644 index aa8cb99..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/examples/onoffbutton_breakout/onoffbutton_breakout.ino +++ /dev/null @@ -1,133 +0,0 @@ -//This example implements a simple sliding On/Off button. The example -// demonstrates drawing and touch operations. -// -//Thanks to Adafruit forums member Asteroid for the original sketch! -// -#include -#include -#include -#include -#include - -//Touchscreen X+ X- Y+ Y- pins -#define YP A3 // must be an analog pin, use "An" notation! -#define XM A2 // must be an analog pin, use "An" notation! -#define YM 5 // can be a digital pin -#define XP 4 // can be a digital pin - -// This is calibration data for the raw touch data to the screen coordinates -#define TS_MINX 150 -#define TS_MINY 120 -#define TS_MAXX 920 -#define TS_MAXY 940 - -#define MINPRESSURE 10 -#define MAXPRESSURE 1000 - -// For better pressure precision, we need to know the resistance -// between X+ and X- Use any multimeter to read it -// For the one we're using, its 300 ohms across the X plate -TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); - - -#define TFT_CS 10 -#define TFT_DC 9 -Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); - -boolean RecordOn = false; - -#define FRAME_X 210 -#define FRAME_Y 180 -#define FRAME_W 100 -#define FRAME_H 50 - -#define REDBUTTON_X FRAME_X -#define REDBUTTON_Y FRAME_Y -#define REDBUTTON_W (FRAME_W/2) -#define REDBUTTON_H FRAME_H - -#define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W) -#define GREENBUTTON_Y FRAME_Y -#define GREENBUTTON_W (FRAME_W/2) -#define GREENBUTTON_H FRAME_H - -void drawFrame() -{ - tft.drawRect(FRAME_X, FRAME_Y, FRAME_W, FRAME_H, ILI9341_BLACK); -} - -void redBtn() -{ - tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_RED); - tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_BLUE); - drawFrame(); - tft.setCursor(GREENBUTTON_X + 6 , GREENBUTTON_Y + (GREENBUTTON_H/2)); - tft.setTextColor(ILI9341_WHITE); - tft.setTextSize(2); - tft.println("ON"); - RecordOn = false; -} - -void greenBtn() -{ - tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_GREEN); - tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_BLUE); - drawFrame(); - tft.setCursor(REDBUTTON_X + 6 , REDBUTTON_Y + (REDBUTTON_H/2)); - tft.setTextColor(ILI9341_WHITE); - tft.setTextSize(2); - tft.println("OFF"); - RecordOn = true; -} - -void setup(void) -{ - Serial.begin(9600); - tft.begin(); - - tft.fillScreen(ILI9341_BLUE); - // origin = left,top landscape (USB left upper) - tft.setRotation(1); - redBtn(); -} - -void loop() -{ - // Retrieve a point - TSPoint p = ts.getPoint(); - - // See if there's any touch data for us - if (p.z > MINPRESSURE && p.z < MAXPRESSURE) - { - // Scale using the calibration #'s - // and rotate coordinate system - p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height()); - p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width()); - int y = tft.height() - p.x; - int x = p.y; - - if (RecordOn) - { - if((x > REDBUTTON_X) && (x < (REDBUTTON_X + REDBUTTON_W))) { - if ((y > REDBUTTON_Y) && (y <= (REDBUTTON_Y + REDBUTTON_H))) { - Serial.println("Red btn hit"); - redBtn(); - } - } - } - else //Record is off (RecordOn == false) - { - if((x > GREENBUTTON_X) && (x < (GREENBUTTON_X + GREENBUTTON_W))) { - if ((y > GREENBUTTON_Y) && (y <= (GREENBUTTON_Y + GREENBUTTON_H))) { - Serial.println("Green btn hit"); - greenBtn(); - } - } - } - - Serial.println(RecordOn); - } -} - - - diff --git a/GD32F1/libraries/Adafruit_ILI9341/examples/spitftbitmap/spitftbitmap.ino b/GD32F1/libraries/Adafruit_ILI9341/examples/spitftbitmap/spitftbitmap.ino deleted file mode 100644 index f87d6f7..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/examples/spitftbitmap/spitftbitmap.ino +++ /dev/null @@ -1,189 +0,0 @@ -/*************************************************** - This is our Bitmap drawing example for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#include // Core graphics library -#include "Adafruit_ILI9341.h" // Hardware-specific library -#include -#include - -// TFT display and SD card will share the hardware SPI interface. -// Hardware SPI pins are specific to the Arduino board type and -// cannot be remapped to alternate pins. For Arduino Uno, -// Duemilanove, etc., pin 11 = MOSI, pin 12 = MISO, pin 13 = SCK. - -#define TFT_DC 9 -#define TFT_CS 10 -Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); - -#define SD_CS 4 - -void setup(void) { - Serial.begin(9600); - - tft.begin(); - tft.fillScreen(ILI9341_BLUE); - - Serial.print("Initializing SD card..."); - if (!SD.begin(SD_CS)) { - Serial.println("failed!"); - } - Serial.println("OK!"); - - bmpDraw("purple.bmp", 0, 0); -} - -void loop() { -} - -// This function opens a Windows Bitmap (BMP) file and -// displays it at the given coordinates. It's sped up -// by reading many pixels worth of data at a time -// (rather than pixel by pixel). Increasing the buffer -// size takes more of the Arduino's precious RAM but -// makes loading a little faster. 20 pixels seems a -// good balance. - -#define BUFFPIXEL 20 - -void bmpDraw(char *filename, uint8_t x, uint16_t y) { - - File bmpFile; - int bmpWidth, bmpHeight; // W+H in pixels - uint8_t bmpDepth; // Bit depth (currently must be 24) - uint32_t bmpImageoffset; // Start of image data in file - uint32_t rowSize; // Not always = bmpWidth; may have padding - uint8_t sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel) - uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer - boolean goodBmp = false; // Set to true on valid header parse - boolean flip = true; // BMP is stored bottom-to-top - int w, h, row, col; - uint8_t r, g, b; - uint32_t pos = 0, startTime = millis(); - - if((x >= tft.width()) || (y >= tft.height())) return; - - Serial.println(); - Serial.print(F("Loading image '")); - Serial.print(filename); - Serial.println('\''); - - // Open requested file on SD card - if ((bmpFile = SD.open(filename)) == NULL) { - Serial.print(F("File not found")); - return; - } - - // Parse BMP header - if(read16(bmpFile) == 0x4D42) { // BMP signature - Serial.print(F("File size: ")); Serial.println(read32(bmpFile)); - (void)read32(bmpFile); // Read & ignore creator bytes - bmpImageoffset = read32(bmpFile); // Start of image data - Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC); - // Read DIB header - Serial.print(F("Header size: ")); Serial.println(read32(bmpFile)); - bmpWidth = read32(bmpFile); - bmpHeight = read32(bmpFile); - if(read16(bmpFile) == 1) { // # planes -- must be '1' - bmpDepth = read16(bmpFile); // bits per pixel - Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth); - if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed - - goodBmp = true; // Supported BMP format -- proceed! - Serial.print(F("Image size: ")); - Serial.print(bmpWidth); - Serial.print('x'); - Serial.println(bmpHeight); - - // BMP rows are padded (if needed) to 4-byte boundary - rowSize = (bmpWidth * 3 + 3) & ~3; - - // If bmpHeight is negative, image is in top-down order. - // This is not canon but has been observed in the wild. - if(bmpHeight < 0) { - bmpHeight = -bmpHeight; - flip = false; - } - - // Crop area to be loaded - w = bmpWidth; - h = bmpHeight; - if((x+w-1) >= tft.width()) w = tft.width() - x; - if((y+h-1) >= tft.height()) h = tft.height() - y; - - // Set TFT address window to clipped image bounds - tft.setAddrWindow(x, y, x+w-1, y+h-1); - - for (row=0; row= sizeof(sdbuffer)) { // Indeed - bmpFile.read(sdbuffer, sizeof(sdbuffer)); - buffidx = 0; // Set index to beginning - } - - // Convert pixel from BMP to TFT format, push to display - b = sdbuffer[buffidx++]; - g = sdbuffer[buffidx++]; - r = sdbuffer[buffidx++]; - tft.pushColor(tft.color565(r,g,b)); - } // end pixel - } // end scanline - Serial.print(F("Loaded in ")); - Serial.print(millis() - startTime); - Serial.println(" ms"); - } // end goodBmp - } - } - - bmpFile.close(); - if(!goodBmp) Serial.println(F("BMP format not recognized.")); -} - -// These read 16- and 32-bit types from the SD card file. -// BMP data is stored little-endian, Arduino is little-endian too. -// May need to reverse subscript order if porting elsewhere. - -uint16_t read16(File &f) { - uint16_t result; - ((uint8_t *)&result)[0] = f.read(); // LSB - ((uint8_t *)&result)[1] = f.read(); // MSB - return result; -} - -uint32_t read32(File &f) { - uint32_t result; - ((uint8_t *)&result)[0] = f.read(); // LSB - ((uint8_t *)&result)[1] = f.read(); - ((uint8_t *)&result)[2] = f.read(); - ((uint8_t *)&result)[3] = f.read(); // MSB - return result; -} diff --git a/GD32F1/libraries/Adafruit_ILI9341/examples/stm32_graphicstest/stm32_graphicstest.ino b/GD32F1/libraries/Adafruit_ILI9341/examples/stm32_graphicstest/stm32_graphicstest.ino deleted file mode 100644 index c3e0d40..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/examples/stm32_graphicstest/stm32_graphicstest.ino +++ /dev/null @@ -1,348 +0,0 @@ -/*************************************************** - This is our GFX example for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#include "SPI.h" -#include "Adafruit_GFX.h" -#include "Adafruit_ILI9341.h" - -// For the Adafruit shield, these are the default. -#define TFT_CS PB4 -#define TFT_DC PA15 -#define TFT_RST PB3 - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); -// If using the breakout, change pins as desired -//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); -Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); // Use hardware SPI - -void setup() { - Serial.begin(115200); - tft.begin(); -} - - -void loop(void) { - - Serial.println("ILI9341 Test!"); - // read diagnostics (optional but can help debug problems) - uint8_t x = tft.readcommand8(ILI9341_RDMODE); - Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDMADCTL); - Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDPIXFMT); - Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDIMGFMT); - Serial.print("Image Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDSELFDIAG); - Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); - - Serial.println(F("Benchmark Time (microseconds)")); - - Serial.print(F("Screen fill ")); - Serial.println(testFillScreen()); - - - Serial.print(F("Text ")); - Serial.println(testText()); - - Serial.print(F("Lines ")); - Serial.println(testLines(ILI9341_CYAN)); - - - Serial.print(F("Horiz/Vert Lines ")); - Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE)); - - - Serial.print(F("Rectangles (outline) ")); - Serial.println(testRects(ILI9341_GREEN)); - - - Serial.print(F("Rectangles (filled) ")); - Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); - - - Serial.print(F("Circles (filled) ")); - Serial.println(testFilledCircles(10, ILI9341_MAGENTA)); - - Serial.print(F("Circles (outline) ")); - Serial.println(testCircles(10, ILI9341_WHITE)); - - - Serial.print(F("Triangles (outline) ")); - Serial.println(testTriangles()); - - - Serial.print(F("Triangles (filled) ")); - Serial.println(testFilledTriangles()); - - - Serial.print(F("Rounded rects (outline) ")); - Serial.println(testRoundRects()); - - - Serial.print(F("Rounded rects (filled) ")); - Serial.println(testFilledRoundRects()); - - - Serial.println(F("Done!")); - - for(uint8_t rotation=0; rotation<4; rotation++) { - tft.setRotation(rotation); - testText(); - } -} - -unsigned long testFillScreen() { - unsigned long start = micros(); - tft.fillScreen(ILI9341_BLACK); - tft.fillScreen(ILI9341_RED); - tft.fillScreen(ILI9341_GREEN); - tft.fillScreen(ILI9341_BLUE); - tft.fillScreen(ILI9341_BLACK); - return micros() - start; -} - -unsigned long testText() { - tft.fillScreen(ILI9341_BLACK); - unsigned long start = micros(); - tft.setCursor(0, 0); - tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); - tft.println("Hello World!"); - tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2); - tft.println(1234.56); - tft.setTextColor(ILI9341_RED); tft.setTextSize(3); - tft.println(0xDEADBEEF, HEX); - tft.println(); - tft.setTextColor(ILI9341_GREEN); - tft.setTextSize(5); - tft.println("Groop"); - tft.setTextSize(2); - tft.println("I implore thee,"); - tft.setTextSize(1); - tft.println("my foonting turlingdromes."); - tft.println("And hooptiously drangle me"); - tft.println("with crinkly bindlewurdles,"); - tft.println("Or I will rend thee"); - tft.println("in the gobberwarts"); - tft.println("with my blurglecruncheon,"); - tft.println("see if I don't!"); - return micros() - start; -} - -unsigned long testLines(uint16_t color) { - unsigned long start, t; - int x1, y1, x2, y2, - w = tft.width(), - h = tft.height(); - - tft.fillScreen(ILI9341_BLACK); - - x1 = y1 = 0; - y2 = h - 1; - start = micros(); - for(x2=0; x20; i-=6) { - i2 = i / 2; - start = micros(); - tft.fillRect(cx-i2, cy-i2, i, i, color1); - t += micros() - start; - // Outlines are not included in timing results - tft.drawRect(cx-i2, cy-i2, i, i, color2); - } - - return t; -} - -unsigned long testFilledCircles(uint8_t radius, uint16_t color) { - unsigned long start; - int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; - - tft.fillScreen(ILI9341_BLACK); - start = micros(); - for(x=radius; x10; i-=5) { - start = micros(); - tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(0, i, i)); - t += micros() - start; - tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(i, i, 0)); - } - - return t; -} - -unsigned long testRoundRects() { - unsigned long start; - int w, i, i2, - cx = tft.width() / 2 - 1, - cy = tft.height() / 2 - 1; - - tft.fillScreen(ILI9341_BLACK); - w = min(tft.width(), tft.height()); - start = micros(); - for(i=0; i20; i-=6) { - i2 = i / 2; - tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); - } - - return micros() - start; -} \ No newline at end of file diff --git a/GD32F1/libraries/Adafruit_ILI9341/examples/touchpaint/touchpaint.ino b/GD32F1/libraries/Adafruit_ILI9341/examples/touchpaint/touchpaint.ino deleted file mode 100644 index 227abdc..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341/examples/touchpaint/touchpaint.ino +++ /dev/null @@ -1,146 +0,0 @@ -/*************************************************** - This is our touchscreen painting example for the Adafruit ILI9341 Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#include // Core graphics library -#include -#include // this is needed even tho we aren't using it -#include -#include - -// This is calibration data for the raw touch data to the screen coordinates -#define TS_MINX 150 -#define TS_MINY 130 -#define TS_MAXX 3800 -#define TS_MAXY 4000 - -// The STMPE610 uses hardware SPI on the shield, and #8 -#define STMPE_CS 8 -Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS); - -// The display also uses hardware SPI, plus #9 & #10 -#define TFT_CS 10 -#define TFT_DC 9 -Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); - -// Size of the color selection boxes and the paintbrush size -#define BOXSIZE 40 -#define PENRADIUS 3 -int oldcolor, currentcolor; - -void setup(void) { - // while (!Serial); // used for leonardo debugging - - Serial.begin(9600); - Serial.println(F("Touch Paint!")); - - tft.begin(); - - if (!ts.begin()) { - Serial.println("Couldn't start touchscreen controller"); - while (1); - } - Serial.println("Touchscreen started"); - - tft.fillScreen(ILI9341_BLACK); - - // make the color selection boxes - tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED); - tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW); - tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN); - tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN); - tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE); - tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA); - - // select the current color 'red' - tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - currentcolor = ILI9341_RED; -} - - -void loop() -{ - // See if there's any touch data for us - if (ts.bufferEmpty()) { - return; - } - /* - // You can also wait for a touch - if (! ts.touched()) { - return; - } - */ - - // Retrieve a point - TS_Point p = ts.getPoint(); - - /* - Serial.print("X = "); Serial.print(p.x); - Serial.print("\tY = "); Serial.print(p.y); - Serial.print("\tPressure = "); Serial.println(p.z); - */ - - // Scale from ~0->4000 to tft.width using the calibration #'s - p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width()); - p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height()); - - /* - Serial.print("("); Serial.print(p.x); - Serial.print(", "); Serial.print(p.y); - Serial.println(")"); - */ - - if (p.y < BOXSIZE) { - oldcolor = currentcolor; - - if (p.x < BOXSIZE) { - currentcolor = ILI9341_RED; - tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*2) { - currentcolor = ILI9341_YELLOW; - tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*3) { - currentcolor = ILI9341_GREEN; - tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*4) { - currentcolor = ILI9341_CYAN; - tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*5) { - currentcolor = ILI9341_BLUE; - tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*6) { - currentcolor = ILI9341_MAGENTA; - tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } - - if (oldcolor != currentcolor) { - if (oldcolor == ILI9341_RED) - tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED); - if (oldcolor == ILI9341_YELLOW) - tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW); - if (oldcolor == ILI9341_GREEN) - tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN); - if (oldcolor == ILI9341_CYAN) - tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN); - if (oldcolor == ILI9341_BLUE) - tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE); - if (oldcolor == ILI9341_MAGENTA) - tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA); - } - } - if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) { - tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor); - } -} diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/Adafruit_ILI9341_STM.cpp b/GD32F1/libraries/Adafruit_ILI9341_STM/Adafruit_ILI9341_STM.cpp deleted file mode 100644 index 87a2334..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/Adafruit_ILI9341_STM.cpp +++ /dev/null @@ -1,821 +0,0 @@ -/* -See rights and use declaration in License.h -This library has been modified for the Maple Mini. -Includes DMA transfers on DMA1 CH2 and CH3. -*/ -#include -#include -#include -#include -#include "pins_arduino.h" -#include "wiring_private.h" -#include // Using library SPI in folder: D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI - - -// Constructor when using software SPI. All output pins are configurable. -Adafruit_ILI9341_STM::Adafruit_ILI9341_STM(int8_t cs, int8_t dc, int8_t mosi, - int8_t sclk, int8_t rst, int8_t miso) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { - _cs = cs; - _dc = dc; - _mosi = mosi; - _miso = miso; - _sclk = sclk; - _rst = rst; - hwSPI = false; -} - - -// Constructor when using hardware SPI. Faster, but must use SPI pins -// specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.) -Adafruit_ILI9341_STM::Adafruit_ILI9341_STM(int8_t cs, int8_t dc, int8_t rst) : Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { - _cs = cs; - _dc = dc; - _rst = rst; - hwSPI = true; - _mosi = _sclk = 0; -} - - -void Adafruit_ILI9341_STM::spiwrite(uint8_t c) { - - //Serial.print("0x"); Serial.print(c, HEX); Serial.print(", "); - - if (hwSPI) - { -#if defined (__AVR__) - uint8_t backupSPCR = SPCR; - SPCR = mySPCR; - SPDR = c; - while (!(SPSR & _BV(SPIF))); - SPCR = backupSPCR; -#elif defined(TEENSYDUINO) - SPI.transfer(c); -#elif defined (__STM32F1__) - SPI.write(c); -#elif defined (__arm__) - SPI.setClockDivider(11); // 8-ish MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - SPI.transfer(c); - -#endif - } else { - // Fast SPI bitbang swiped from LPD8806 library - for (uint8_t bit = 0x80; bit; bit >>= 1) { - if (c & bit) { - //digitalWrite(_mosi, HIGH); - *mosiport |= mosipinmask; - } else { - //digitalWrite(_mosi, LOW); - *mosiport &= ~mosipinmask; - } - //digitalWrite(_sclk, HIGH); - *clkport |= clkpinmask; - //digitalWrite(_sclk, LOW); - *clkport &= ~clkpinmask; - } - } -} - - -void Adafruit_ILI9341_STM::writecommand(uint8_t c) { - *dcport &= ~dcpinmask; - *csport &= ~cspinmask; - - spiwrite(c); - - *csport |= cspinmask; -} - - -void Adafruit_ILI9341_STM::writedata(uint8_t c) { - *dcport |= dcpinmask; - *csport &= ~cspinmask; - - spiwrite(c); - - *csport |= cspinmask; -} - -// If the SPI library has transaction support, these functions -// establish settings and protect from interference from other -// libraries. Otherwise, they simply do nothing. -#ifdef SPI_HAS_TRANSACTION -static inline void spi_begin(void) __attribute__((always_inline)); -static inline void spi_begin(void) { - SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); -} -static inline void spi_end(void) __attribute__((always_inline)); -static inline void spi_end(void) { - SPI.endTransaction(); -} -#else -#define spi_begin() -#define spi_end() -#endif - -// Rather than a bazillion writecommand() and writedata() calls, screen -// initialization commands and arguments are organized in these tables -// stored in PROGMEM. The table may look bulky, but that's mostly the -// formatting -- storage-wise this is hundreds of bytes more compact -// than the equivalent code. Companion function follows. -#define DELAY 0x80 - - -// Companion code to the above tables. Reads and issues -// a series of LCD commands stored in PROGMEM byte array. -void Adafruit_ILI9341_STM::commandList(uint8_t *addr) { - - uint8_t numCommands, numArgs; - uint16_t ms; - - numCommands = pgm_read_byte(addr++); // Number of commands to follow - while (numCommands--) { // For each command... - writecommand(pgm_read_byte(addr++)); // Read, issue command - numArgs = pgm_read_byte(addr++); // Number of args to follow - ms = numArgs & DELAY; // If hibit set, delay follows args - numArgs &= ~DELAY; // Mask out delay bit - while (numArgs--) { // For each argument... - writedata(pgm_read_byte(addr++)); // Read, issue argument - } - - if (ms) { - ms = pgm_read_byte(addr++); // Read post-command delay time (ms) - if (ms == 255) ms = 500; // If 255, delay for 500 ms - delay(ms); - } - } -} - - -void Adafruit_ILI9341_STM::begin(void) { - if (_rst > 0) { - pinMode(_rst, OUTPUT); - digitalWrite(_rst, LOW); - } - - pinMode(_dc, OUTPUT); - pinMode(_cs, OUTPUT); - csport = portOutputRegister(digitalPinToPort(_cs)); - cspinmask = digitalPinToBitMask(_cs); - dcport = portOutputRegister(digitalPinToPort(_dc)); - dcpinmask = digitalPinToBitMask(_dc); - - if (hwSPI) { // Using hardware SPI -#if defined (__AVR__) - SPI.begin(); - SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - mySPCR = SPCR; -#elif defined(TEENSYDUINO) - SPI.begin(); - SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); -#elif defined (__STM32F1__) - SPI.begin(); - SPI.setClockDivider(SPI_CLOCK_DIV2); - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - -#elif defined (__arm__) - SPI.begin(); - SPI.setClockDivider(11); // 8-ish MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); -#endif - } else { - pinMode(_sclk, OUTPUT); - pinMode(_mosi, OUTPUT); - pinMode(_miso, INPUT); - clkport = portOutputRegister(digitalPinToPort(_sclk)); - clkpinmask = digitalPinToBitMask(_sclk); - mosiport = portOutputRegister(digitalPinToPort(_mosi)); - mosipinmask = digitalPinToBitMask(_mosi); - *clkport &= ~clkpinmask; - *mosiport &= ~mosipinmask; - } - - // toggle RST low to reset - if (_rst > 0) { - digitalWrite(_rst, HIGH); - delay(5); - digitalWrite(_rst, LOW); - delay(20); - digitalWrite(_rst, HIGH); - delay(150); - } - - /* - uint8_t x = readcommand8(ILI9341_RDMODE); - Serial.print("\nDisplay Power Mode: 0x"); Serial.println(x, HEX); - x = readcommand8(ILI9341_RDMADCTL); - Serial.print("\nMADCTL Mode: 0x"); Serial.println(x, HEX); - x = readcommand8(ILI9341_RDPIXFMT); - Serial.print("\nPixel Format: 0x"); Serial.println(x, HEX); - x = readcommand8(ILI9341_RDIMGFMT); - Serial.print("\nImage Format: 0x"); Serial.println(x, HEX); - x = readcommand8(ILI9341_RDSELFDIAG); - Serial.print("\nSelf Diagnostic: 0x"); Serial.println(x, HEX); - */ - //if(cmdList) commandList(cmdList); - - if (hwSPI) spi_begin(); - writecommand(0xEF); - writedata(0x03); - writedata(0x80); - writedata(0x02); - - writecommand(0xCF); - writedata(0x00); - writedata(0XC1); - writedata(0X30); - - writecommand(0xED); - writedata(0x64); - writedata(0x03); - writedata(0X12); - writedata(0X81); - - writecommand(0xE8); - writedata(0x85); - writedata(0x00); - writedata(0x78); - - writecommand(0xCB); - writedata(0x39); - writedata(0x2C); - writedata(0x00); - writedata(0x34); - writedata(0x02); - - writecommand(0xF7); - writedata(0x20); - - writecommand(0xEA); - writedata(0x00); - writedata(0x00); - - writecommand(ILI9341_PWCTR1); //Power control - writedata(0x23); //VRH[5:0] - - writecommand(ILI9341_PWCTR2); //Power control - writedata(0x10); //SAP[2:0];BT[3:0] - - writecommand(ILI9341_VMCTR1); //VCM control - writedata(0x3e); //�Աȶȵ��� - writedata(0x28); - - writecommand(ILI9341_VMCTR2); //VCM control2 - writedata(0x86); //-- - - writecommand(ILI9341_MADCTL); // Memory Access Control - writedata(0x48); - - writecommand(ILI9341_PIXFMT); - writedata(0x55); - - writecommand(ILI9341_FRMCTR1); - writedata(0x00); - writedata(0x18); - - writecommand(ILI9341_DFUNCTR); // Display Function Control - writedata(0x08); - writedata(0x82); - writedata(0x27); - - writecommand(0xF2); // 3Gamma Function Disable - writedata(0x00); - - writecommand(ILI9341_GAMMASET); //Gamma curve selected - writedata(0x01); - - writecommand(ILI9341_GMCTRP1); //Set Gamma - writedata(0x0F); - writedata(0x31); - writedata(0x2B); - writedata(0x0C); - writedata(0x0E); - writedata(0x08); - writedata(0x4E); - writedata(0xF1); - writedata(0x37); - writedata(0x07); - writedata(0x10); - writedata(0x03); - writedata(0x0E); - writedata(0x09); - writedata(0x00); - - writecommand(ILI9341_GMCTRN1); //Set Gamma - writedata(0x00); - writedata(0x0E); - writedata(0x14); - writedata(0x03); - writedata(0x11); - writedata(0x07); - writedata(0x31); - writedata(0xC1); - writedata(0x48); - writedata(0x08); - writedata(0x0F); - writedata(0x0C); - writedata(0x31); - writedata(0x36); - writedata(0x0F); - - writecommand(ILI9341_SLPOUT); //Exit Sleep - if (hwSPI) spi_end(); - delay(120); - if (hwSPI) spi_begin(); - writecommand(ILI9341_DISPON); //Display on - if (hwSPI) spi_end(); - -} - - -void Adafruit_ILI9341_STM::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, - uint16_t y1) { -#if defined (__STM32F1__) - writecommand(ILI9341_CASET); // Column addr set - *dcport |= dcpinmask; - *csport &= ~cspinmask; - SPI.setDataSize (SPI_CR1_DFF); - SPI.write(x0); - SPI.write(x1); -// SPI.setDataSize (0); - - writecommand(ILI9341_PASET); // Row addr set - *dcport |= dcpinmask; - *csport &= ~cspinmask; -// SPI.setDataSize (SPI_CR1_DFF); - SPI.write(y0); - SPI.write(y1); - SPI.setDataSize (0); - - writecommand(ILI9341_RAMWR); // write to RAM - -#else - writecommand(ILI9341_CASET); // Column addr set - writedata(x0 >> 8); - writedata(x0 & 0xFF); // XSTART - writedata(x1 >> 8); - writedata(x1 & 0xFF); // XEND - - writecommand(ILI9341_PASET); // Row addr set - writedata(y0 >> 8); - writedata(y0); // YSTART - writedata(y1 >> 8); - writedata(y1); // YEND - - writecommand(ILI9341_RAMWR); // write to RAM -#endif -} - - -void Adafruit_ILI9341_STM::pushColor(uint16_t color) { - if (hwSPI) spi_begin(); - //digitalWrite(_dc, HIGH); - *dcport |= dcpinmask; - //digitalWrite(_cs, LOW); - *csport &= ~cspinmask; - - spiwrite(color >> 8); - spiwrite(color); - - *csport |= cspinmask; - //digitalWrite(_cs, HIGH); - if (hwSPI) spi_end(); -} - -void Adafruit_ILI9341_STM::drawPixel(int16_t x, int16_t y, uint16_t color) { - - if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) return; - - if (hwSPI) spi_begin(); - setAddrWindow(x, y, x + 1, y + 1); - - *dcport |= dcpinmask; - *csport &= ~cspinmask; - - spiwrite(color >> 8); - spiwrite(color); - - *csport |= cspinmask; - if (hwSPI) spi_end(); -} - - -void Adafruit_ILI9341_STM::drawFastVLine(int16_t x, int16_t y, int16_t h, - uint16_t color) { - - // Rudimentary clipping - if ((x >= _width) || (y >= _height || h < 1)) return; - - if ((y + h - 1) >= _height) - h = _height - y; - if (h < 2 ) { - drawPixel(x, y, color); - return; - } - - // if (hwSPI) spi_begin(); - setAddrWindow(x, y, x, y + h - 1); - - *dcport |= dcpinmask; - *csport &= ~cspinmask; - -#if defined (__STM32F1__) - SPI.setDataSize (SPI_CR1_DFF); // Set SPI 16bit mode - lineBuffer[0] = color; - SPI.dmaSend(lineBuffer, h, 0); - SPI.setDataSize (0); - #else - uint8_t hi = color >> 8, lo = color; - while (h--) { - spiwrite(hi); - spiwrite(lo); - } -#endif - *csport |= cspinmask; -} - - -void Adafruit_ILI9341_STM::drawFastHLine(int16_t x, int16_t y, int16_t w, - uint16_t color) { - - - // Rudimentary clipping - if ((x >= _width) || (y >= _height || w < 1)) return; - if ((x + w - 1) >= _width) w = _width - x; - if (w < 2 ) { - drawPixel(x, y, color); - return; - } - -// if (hwSPI) spi_begin(); - setAddrWindow(x, y, x + w - 1, y); - *dcport |= dcpinmask; - *csport &= ~cspinmask; - -#if defined (__STM32F1__) - SPI.setDataSize (SPI_CR1_DFF); // Set spi 16bit mode - lineBuffer[0] = color; - SPI.dmaSend(lineBuffer, w, 0); - SPI.setDataSize (0); -#else - uint8_t hi = color >> 8, lo = color; - while (w--) { - spiwrite(hi); - spiwrite(lo); - } -#endif - *csport |= cspinmask; - //digitalWrite(_cs, HIGH); -// if (hwSPI) spi_end(); -} - -void Adafruit_ILI9341_STM::fillScreen(uint16_t color) { -#if defined (__STM32F1__) - setAddrWindow(0, 0, _width - 1, _height - 1); - *dcport |= dcpinmask; - *csport &= ~cspinmask; - SPI.setDataSize (SPI_CR1_DFF); // Set spi 16bit mode - lineBuffer[0] = color; - SPI.dmaSend(lineBuffer, (65535), 0); - SPI.dmaSend(lineBuffer, ((_width * _height) - 65535), 0); - SPI.setDataSize (0); - -#else - fillRect(0, 0, _width, _height, color); -#endif -} - -// fill a rectangle -void Adafruit_ILI9341_STM::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color) { - - // rudimentary clipping (drawChar w/big text requires this) - if ((x >= _width) || (y >= _height || h < 1 || w < 1)) return; - if ((x + w - 1) >= _width) w = _width - x; - if ((y + h - 1) >= _height) h = _height - y; - if (w == 1 && h == 1) { - drawPixel(x, y, color); - return; - } - - if (hwSPI) spi_begin(); - setAddrWindow(x, y, x + w - 1, y + h - 1); - - *dcport |= dcpinmask; - *csport &= ~cspinmask; -#if defined (__STM32F1__) - SPI.setDataSize (SPI_CR1_DFF); // Set spi 16bit mode - lineBuffer[0] = color; - if (w*h <= 65535) { - SPI.dmaSend(lineBuffer, (w*h), 0); - } - else { - SPI.dmaSend(lineBuffer, (65535), 0); - SPI.dmaSend(lineBuffer, ((w*h) - 65535), 0); - } - SPI.setDataSize (0); -#else - uint8_t hi = color >> 8, lo = color; - for(y=h; y>0; y--) - { - for(x=w; x>0; x--) - { - SPI.write(hi); - SPI.write(lo); - } - } -#endif - *csport |= cspinmask; - if (hwSPI) spi_end(); -} - -/* -* Draw lines faster by calculating straight sections and drawing them with fastVline and fastHline. -*/ -#if defined (__STM32F1__) -void Adafruit_ILI9341_STM::drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color) -{ - if ((y0 < 0 && y1 <0) || (y0 > _height && y1 > _height)) return; - if ((x0 < 0 && x1 <0) || (x0 > _width && x1 > _width)) return; - if (x0 < 0) x0 = 0; - if (x1 < 0) x1 = 0; - if (y0 < 0) y0 = 0; - if (y1 < 0) y1 = 0; - - if (y0 == y1) { - if (x1 > x0) { - drawFastHLine(x0, y0, x1 - x0 + 1, color); - } - else if (x1 < x0) { - drawFastHLine(x1, y0, x0 - x1 + 1, color); - } - else { - drawPixel(x0, y0, color); - } - return; - } - else if (x0 == x1) { - if (y1 > y0) { - drawFastVLine(x0, y0, y1 - y0 + 1, color); - } - else { - drawFastVLine(x0, y1, y0 - y1 + 1, color); - } - return; - } - - bool steep = abs(y1 - y0) > abs(x1 - x0); - if (steep) { - swap(x0, y0); - swap(x1, y1); - } - if (x0 > x1) { - swap(x0, x1); - swap(y0, y1); - } - - int16_t dx, dy; - dx = x1 - x0; - dy = abs(y1 - y0); - - int16_t err = dx / 2; - int16_t ystep; - - if (y0 < y1) { - ystep = 1; - } - else { - ystep = -1; - } - - int16_t xbegin = x0; - lineBuffer[0] = color; - *csport &= ~cspinmask; - if (steep) { - for (; x0 <= x1; x0++) { - err -= dy; - if (err < 0) { - int16_t len = x0 - xbegin; - if (len) { - drawFastVLine (y0, xbegin, len + 1, color); - //writeVLine_cont_noCS_noFill(y0, xbegin, len + 1); - } - else { - drawPixel(y0, x0, color); - //writePixel_cont_noCS(y0, x0, color); - } - xbegin = x0 + 1; - y0 += ystep; - err += dx; - } - } - if (x0 > xbegin + 1) { - //writeVLine_cont_noCS_noFill(y0, xbegin, x0 - xbegin); - drawFastVLine(y0, xbegin, x0 - xbegin, color); - } - - } - else { - for (; x0 <= x1; x0++) { - err -= dy; - if (err < 0) { - int16_t len = x0 - xbegin; - if (len) { - drawFastHLine(xbegin, y0, len + 1, color); - //writeHLine_cont_noCS_noFill(xbegin, y0, len + 1); - } - else { - drawPixel(x0, y0, color); - //writePixel_cont_noCS(x0, y0, color); - } - xbegin = x0 + 1; - y0 += ystep; - err += dx; - } - } - if (x0 > xbegin + 1) { - //writeHLine_cont_noCS_noFill(xbegin, y0, x0 - xbegin); - drawFastHLine(xbegin, y0, x0 - xbegin, color); - } - } - *csport |= cspinmask; -} -#endif - - - -// Pass 8-bit (each) R,G,B, get back 16-bit packed color -uint16_t Adafruit_ILI9341_STM::color565(uint8_t r, uint8_t g, uint8_t b) { - return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); -} - - -#define MADCTL_MY 0x80 -#define MADCTL_MX 0x40 -#define MADCTL_MV 0x20 -#define MADCTL_ML 0x10 -#define MADCTL_RGB 0x00 -#define MADCTL_BGR 0x08 -#define MADCTL_MH 0x04 - -void Adafruit_ILI9341_STM::setRotation(uint8_t m) { - - if (hwSPI) spi_begin(); - writecommand(ILI9341_MADCTL); - rotation = m % 4; // can't be higher than 3 - switch (rotation) { - case 0: - writedata(MADCTL_MX | MADCTL_BGR); - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - break; - case 1: - writedata(MADCTL_MV | MADCTL_BGR); - _width = ILI9341_TFTHEIGHT; - _height = ILI9341_TFTWIDTH; - break; - case 2: - writedata(MADCTL_MY | MADCTL_BGR); - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - break; - case 3: - writedata(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); - _width = ILI9341_TFTHEIGHT; - _height = ILI9341_TFTWIDTH; - break; - } - if (hwSPI) spi_end(); -} - - -void Adafruit_ILI9341_STM::invertDisplay(boolean i) { - if (hwSPI) spi_begin(); - writecommand(i ? ILI9341_INVON : ILI9341_INVOFF); - if (hwSPI) spi_end(); -} - - -////////// stuff not actively being used, but kept for posterity - - -uint8_t Adafruit_ILI9341_STM::spiread(void) { - uint8_t r = 0; - - if (hwSPI) { -#if defined (__AVR__) - uint8_t backupSPCR = SPCR; - SPCR = mySPCR; - SPDR = 0x00; - while (!(SPSR & _BV(SPIF))); - r = SPDR; - SPCR = backupSPCR; -#elif defined(TEENSYDUINO) - r = SPI.transfer(0x00); -#elif defined (__STM32F1__) - r = SPI.transfer(0x00); -#elif defined (__arm__) - SPI.setClockDivider(11); // 8-ish MHz (full! speed!) - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - r = SPI.transfer(0x00); -#endif - } else { - - for (uint8_t i = 0; i < 8; i++) { - digitalWrite(_sclk, LOW); - digitalWrite(_sclk, HIGH); - r <<= 1; - if (digitalRead(_miso)) - r |= 0x1; - } - } - //Serial.print("read: 0x"); Serial.print(r, HEX); - - return r; -} - -uint8_t Adafruit_ILI9341_STM::readdata(void) { - digitalWrite(_dc, HIGH); - digitalWrite(_cs, LOW); - uint8_t r = spiread(); - digitalWrite(_cs, HIGH); - - return r; -} - - -uint8_t Adafruit_ILI9341_STM::readcommand8(uint8_t c, uint8_t index) { - if (hwSPI) spi_begin(); - digitalWrite(_dc, LOW); // command - digitalWrite(_cs, LOW); - spiwrite(0xD9); // woo sekret command? - digitalWrite(_dc, HIGH); // data - spiwrite(0x10 + index); - digitalWrite(_cs, HIGH); - - digitalWrite(_dc, LOW); - digitalWrite(_sclk, LOW); - digitalWrite(_cs, LOW); - spiwrite(c); - - digitalWrite(_dc, HIGH); - uint8_t r = spiread(); - digitalWrite(_cs, HIGH); - if (hwSPI) spi_end(); - return r; -} - - - -/* - - uint16_t Adafruit_ILI9341_STM::readcommand16(uint8_t c) { - digitalWrite(_dc, LOW); - if (_cs) - digitalWrite(_cs, LOW); - - spiwrite(c); - pinMode(_sid, INPUT); // input! - uint16_t r = spiread(); - r <<= 8; - r |= spiread(); - if (_cs) - digitalWrite(_cs, HIGH); - - pinMode(_sid, OUTPUT); // back to output - return r; - } - - uint32_t Adafruit_ILI9341_STM::readcommand32(uint8_t c) { - digitalWrite(_dc, LOW); - if (_cs) - digitalWrite(_cs, LOW); - spiwrite(c); - pinMode(_sid, INPUT); // input! - - dummyclock(); - dummyclock(); - - uint32_t r = spiread(); - r <<= 8; - r |= spiread(); - r <<= 8; - r |= spiread(); - r <<= 8; - r |= spiread(); - if (_cs) - digitalWrite(_cs, HIGH); - - pinMode(_sid, OUTPUT); // back to output - return r; - } - - */ diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/Adafruit_ILI9341_STM.h b/GD32F1/libraries/Adafruit_ILI9341_STM/Adafruit_ILI9341_STM.h deleted file mode 100644 index a716c27..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/Adafruit_ILI9341_STM.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -See rights and use declaration in License.h -This library has been modified for the Maple Mini -*/ - -#ifndef _ADAFRUIT_ILI9341H_ -#define _ADAFRUIT_ILI9341H_ - -#include "Arduino.h" -#include "Print.h" -#include -#include - -#define ILI9341_TFTWIDTH 240 -#define ILI9341_TFTHEIGHT 320 - -#define ILI9341_NOP 0x00 -#define ILI9341_SWRESET 0x01 -#define ILI9341_RDDID 0x04 -#define ILI9341_RDDST 0x09 - -#define ILI9341_SLPIN 0x10 -#define ILI9341_SLPOUT 0x11 -#define ILI9341_PTLON 0x12 -#define ILI9341_NORON 0x13 - -#define ILI9341_RDMODE 0x0A -#define ILI9341_RDMADCTL 0x0B -#define ILI9341_RDPIXFMT 0x0C -#define ILI9341_RDIMGFMT 0x0A -#define ILI9341_RDSELFDIAG 0x0F - -#define ILI9341_INVOFF 0x20 -#define ILI9341_INVON 0x21 -#define ILI9341_GAMMASET 0x26 -#define ILI9341_DISPOFF 0x28 -#define ILI9341_DISPON 0x29 - -#define ILI9341_CASET 0x2A -#define ILI9341_PASET 0x2B -#define ILI9341_RAMWR 0x2C -#define ILI9341_RAMRD 0x2E - -#define ILI9341_PTLAR 0x30 -#define ILI9341_MADCTL 0x36 -#define ILI9341_PIXFMT 0x3A - -#define ILI9341_FRMCTR1 0xB1 -#define ILI9341_FRMCTR2 0xB2 -#define ILI9341_FRMCTR3 0xB3 -#define ILI9341_INVCTR 0xB4 -#define ILI9341_DFUNCTR 0xB6 - -#define ILI9341_PWCTR1 0xC0 -#define ILI9341_PWCTR2 0xC1 -#define ILI9341_PWCTR3 0xC2 -#define ILI9341_PWCTR4 0xC3 -#define ILI9341_PWCTR5 0xC4 -#define ILI9341_VMCTR1 0xC5 -#define ILI9341_VMCTR2 0xC7 - -#define ILI9341_RDID1 0xDA -#define ILI9341_RDID2 0xDB -#define ILI9341_RDID3 0xDC -#define ILI9341_RDID4 0xDD - -#define ILI9341_GMCTRP1 0xE0 -#define ILI9341_GMCTRN1 0xE1 -/* -#define ILI9341_PWCTR6 0xFC - -*/ - -// Color definitions -#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */ -#define ILI9341_NAVY 0x000F /* 0, 0, 128 */ -#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */ -#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */ -#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */ -#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */ -#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */ -#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */ -#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */ -#define ILI9341_BLUE 0x001F /* 0, 0, 255 */ -#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */ -#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */ -#define ILI9341_RED 0xF800 /* 255, 0, 0 */ -#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */ -#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */ -#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */ -#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */ -#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ -#define ILI9341_PINK 0xF81F - -class Adafruit_ILI9341_STM : public Adafruit_GFX { - - public: - - Adafruit_ILI9341_STM(int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, - int8_t _RST, int8_t _MISO); - Adafruit_ILI9341_STM(int8_t _CS, int8_t _DC, int8_t _RST = -1); - - void begin(void), - setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1), - pushColor(uint16_t color), - fillScreen(uint16_t color), - #if defined (__STM32F1__) - drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color), - #endif - drawPixel(int16_t x, int16_t y, uint16_t color), - drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), - drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), - fillRect(int16_t x, int16_t y, int16_t w, int16_t h, - uint16_t color), - setRotation(uint8_t r), - invertDisplay(boolean i); - uint16_t color565(uint8_t r, uint8_t g, uint8_t b); - - /* These are not for current use, 8-bit protocol only! */ - uint8_t readdata(void), - readcommand8(uint8_t reg, uint8_t index = 0); - /* - uint16_t readcommand16(uint8_t); - uint32_t readcommand32(uint8_t); - void dummyclock(void); - */ - - void spiwrite(uint8_t), - writecommand(uint8_t c), - writedata(uint8_t d), - commandList(uint8_t *addr); - uint8_t spiread(void); - - - private: - uint8_t tabcolor; - - - - - boolean hwSPI; -#if defined (__AVR__) || defined(TEENSYDUINO) - uint8_t mySPCR; - volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport; - int8_t _cs, _dc, _rst, _mosi, _miso, _sclk; - uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask; -#elif defined (__STM32F1__) - volatile uint32 *mosiport, *clkport, *dcport, *rsport, *csport; - uint32_t _cs, _dc, _rst, _mosi, _miso, _sclk; - uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask; - uint16_t lineBuffer[ILI9341_TFTHEIGHT]; // DMA buffer. 16bit color data per pixel -#elif defined (__arm__) - volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport; - uint32_t _cs, _dc, _rst, _mosi, _miso, _sclk; - uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask; -#endif -}; - -#endif diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/License.h b/GD32F1/libraries/Adafruit_ILI9341_STM/License.h deleted file mode 100644 index b7da6b9..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/License.h +++ /dev/null @@ -1,99 +0,0 @@ -// License.h -// All tab licenses are here -// This library was modified to support DMA in Maple Mini by Victor Perez in 03/17/2015 - -/*************************************************** - This is our GFX example for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) -/* -This is the core graphics library for all our displays, providing a common -set of graphics primitives (points, lines, circles, etc.). It needs to be -paired with a hardware-specific library for each display device we carry -(to handle the lower-level functions). - -Adafruit invests time and resources providing this open source code, please -support Adafruit & open-source hardware by purchasing products from Adafruit! - -Copyright (c) 2013 Adafruit Industries. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -/*************************************************** - This is our library for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - -/* -Roughly based on Adafruit example sketch: "parsing" -Utilizes the (modified) Adafruit_GPS library https://github.com/adafruit/Adafruit-GPS-Library -20131204: GPS TimeDate with Temperature - Heavily mucked by M. Ray Burnette to simply use (most) any dumb serial TTL GPS for time-date - Tested with unit#28146 Parallax module @4800 BAUD http://www.abra-electronics.com/products/28146-Parallax-GPS-Receiver-Module.html - Tested with uBlox and external antenna @9600 BAUD http://www.ebay.com/itm/390647042336 - Tested with uBlox and internal antenna @9600 BAUD http://www.ebay.com/itm/181219728986 - -*/ -/* -SoftwareSerial.h (formerly NewSoftSerial.h) - -Multi-instance software serial library for Arduino/Wiring --- Interrupt-driven receive and other improvements by ladyada - (http://ladyada.net) --- Tuning, circular buffer, derivation from class Print/Stream, - multi-instance support, porting to 8MHz processors, - various optimizations, PROGMEM delay tables, inverse logic and - direct port writing by Mikal Hart (http://www.arduiniana.org) --- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) --- 20MHz processor support by Garrett Mace (http://www.macetech.com) --- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -The latest version of this library can always be found at -http://arduiniana.org. -*/ - diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/README.txt b/GD32F1/libraries/Adafruit_ILI9341_STM/README.txt deleted file mode 100644 index 6fa8ba8..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/README.txt +++ /dev/null @@ -1,24 +0,0 @@ -It has minor modifications to support STM32. It has been tested with the Maple Mini. -Further modifications to support DMA transfers in the STM32F1xx by Victor Perez 3/17/2015 - -This is a library for the Adafruit ILI9341 display products - -This library works with the Adafruit 2.8" Touch Shield V2 (SPI) - ----> http://www.adafruit.com/products/1651 - -Check out the links above for our tutorials and wiring diagrams. -These displays use SPI to communicate, 4 or 5 pins are required -to interface (RST is optional). - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -MIT license, all text above must be included in any redistribution - -To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_ILI9341. Check that the Adafruit_ILI9341 folder contains Adafruit_ILI9341.cpp and Adafruit_ILI9341. - -Place the Adafruit_ILI9341 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE - -Also requires the Adafruit_GFX library for Arduino. diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Clock_Digital_ILI9341/TFT_Clock_Digital_ILI9341.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Clock_Digital_ILI9341/TFT_Clock_Digital_ILI9341.ino deleted file mode 100644 index dceb56c..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Clock_Digital_ILI9341/TFT_Clock_Digital_ILI9341.ino +++ /dev/null @@ -1,147 +0,0 @@ -/* - An example digital clock using a TFT LCD screen to show the time. - Demonstrates use of the font printing routines. (Time updates but date does not.) - - For a more accurate clock, it would be better to use the RTClib library. - But this is just a demo. - - This examples uses the hardware SPI only. Non-hardware SPI - is just too slow (~8 times slower!) - - Based on clock sketch by Gilchrist 6/2/2014 1.0 - Updated to use new features by Alan Senior 18/1/2015 - - -A few colour codes: - -code color -0x0000 Black -0xFFFF White -0xBDF7 Light Gray -0x7BEF Dark Gray -0xF800 Red -0xFFE0 Yellow -0xFBE0 Orange -0x79E0 Brown -0x7E0 Green -0x7FF Cyan -0x1F Blue -0xF81F Pink - - */ - -// These are the connections for the UNO -//#define sclk 6 // Don't change -//#define mosi 4 // Don't change -#define cs 8 -#define dc 10 -#define rst 9 // you can also connect this to the Arduino reset - -#include // Core graphics library, with extra fonts. -#include // STM32 DMA Hardware-specific library -#include - -#define ILI9341_GREY 0x5AEB - -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(cs, dc, rst); // Invoke custom library - -uint32_t targetTime = 0; // for next 1 second timeout -uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6); // Get H, M, S from compile time - -byte omm = 99; -boolean initial = 1; -byte xcolon = 0; -unsigned int colour = 0; - -void setup(void) { - tft.begin(); - tft.setRotation(2); - tft.fillScreen(ILI9341_BLACK); - - tft.setTextSize(1); - tft.setTextColor(ILI9341_YELLOW, ILI9341_BLACK); - - targetTime = millis() + 1000; -} - -void loop() { - if (targetTime < millis()) { - targetTime = millis()+1000; - ss++; // Advance second - if (ss==60) { - ss=0; - omm = mm; - mm++; // Advance minute - if(mm>59) { - mm=0; - hh++; // Advance hour - if (hh>23) { - hh=0; - } - } - } - - if (ss==0 || initial) { - initial = 0; - tft.setTextColor(ILI9341_GREEN, ILI9341_BLACK); - tft.setCursor (50, 52); - tft.print(__DATE__); // This uses the standard ADAFruit small font - - tft.setTextColor(ILI9341_BLUE, ILI9341_BLACK); - tft.drawCentreString("It is windy",160,48,2); // Next size up font 2 - - tft.setTextColor(0xF81F, ILI9341_BLACK); // Pink - tft.drawCentreString("12.34",120,91,6); // Large font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 . : a p m - } - - // Update digital time - byte xpos = 50; - byte ypos = 0; - if (omm != mm) { // Only redraw every minute to minimise flicker - // Uncomment ONE of the next 2 lines, using the ghost image demonstrates text overlay as time is drawn over it - tft.setTextColor(0x39C4, ILI9341_BLACK); // Leave a 7 segment ghost image, comment out next line! - //tft.setTextColor(ILI9341_BLACK, ILI9341_BLACK); // Set font colour to back to wipe image - // Font 7 is to show a pseudo 7 segment display. - // Font 7 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : . - tft.drawString("88:88",xpos,ypos,7); // Overwrite the text to clear it - tft.setTextColor(0xFBE0); // Orange - omm = mm; - - if (hh<10) xpos+= tft.drawChar('0',xpos,ypos,7); - xpos+= tft.drawNumber(hh,xpos,ypos,7); - xcolon=xpos; - xpos+= tft.drawChar(':',xpos,ypos,7); - if (mm<10) xpos+= tft.drawChar('0',xpos,ypos,7); - tft.drawNumber(mm,xpos,ypos,7); - } - - if (ss%2) { // Flash the colon - tft.setTextColor(0x39C4, ILI9341_BLACK); - xpos+= tft.drawChar(':',xcolon,ypos,7); - tft.setTextColor(0xFBE0, ILI9341_BLACK); - } - else { - tft.drawChar(':',xcolon,ypos,7); - colour = random(0xFFFF); - // Erase the text with a rectangle - tft.fillRect (0, 64, 240, 20, ILI9341_BLACK); - tft.setTextColor(colour); - tft.drawRightString("Colour:",120,64,4); // Right justified string drawing to x position 120 - String scolour = String(colour,HEX); - scolour.toUpperCase(); - char buffer[20]; - scolour.toCharArray(buffer,20); - tft.drawString(buffer,128,64,4); - } - } -} - -static uint8_t conv2d(const char* p) { - uint8_t v = 0; - if ('0' <= *p && *p <= '9') - v = *p - '0'; - return 10 * v + *++p - '0'; -} - - - diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Clock_ILI9341/TFT_Clock_ILI9341.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Clock_ILI9341/TFT_Clock_ILI9341.ino deleted file mode 100644 index 5c0bab9..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Clock_ILI9341/TFT_Clock_ILI9341.ino +++ /dev/null @@ -1,151 +0,0 @@ -/* - An example analogue clock using a TFT LCD screen to show the time - use of some of the drawing commands with the modified Adafruit_ILI9341_AS library. - For a more accurate clock, it would be better to use the RTClib library. - But this is just a demo. - - This examples uses the hardware SPI only. Non-hardware SPI - is just too slow (~8 times slower!) - - Gilchrist 6/2/2014 1.0 - Updated by Alan Senior 18/1/2015 - */ - -//#define sclk 6 // Don't change -//#define mosi 4 // Don't change -#define cs PB4 -#define dc PA15 -#define rst PB3 -// you can also connect this to the Arduino reset - -#define TFT_CS PB4 //10 pin 3 10 -#define TFT_DC PA15 // 9 pin 5 9 -#define TFT_RST PB3 // 8 pin 4 8 - -#include // Core graphics library, with extra fonts. -#include // STM32 DMA Hardware-specific library -#include - -#define ILI9341_GREY 0x5AEB - -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(cs, dc, rst); // Invoke custom library - -float sx = 0, sy = 1, mx = 1, my = 0, hx = -1, hy = 0; // Saved H, M, S x & y multipliers -float sdeg=0, mdeg=0, hdeg=0; -uint16_t osx=120, osy=120, omx=120, omy=120, ohx=120, ohy=120; // Saved H, M, S x & y coords -uint16_t x00=0, x11=0, y00=0, y11=0; -uint32_t targetTime = 0; // for next 1 second timeout -uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6); // Get H, M, S from compile time -boolean initial = 1; - -void setup(void) { - tft.begin(); - tft.setRotation(2); - - //tft.fillScreen(ILI9341_BLACK); - //tft.fillScreen(ILI9341_RED); - //tft.fillScreen(ILI9341_GREEN); - //tft.fillScreen(ILI9341_BLUE); - //tft.fillScreen(ILI9341_BLACK); - tft.fillScreen(ILI9341_GREY); - - tft.setTextColor(ILI9341_WHITE, ILI9341_GREY); // Adding a background colour erases previous text automatically - - // Draw clock face - tft.fillCircle(120, 120, 118, ILI9341_GREEN); - tft.fillCircle(120, 120, 110, ILI9341_BLACK); - - // Draw 12 lines - for(int i = 0; i<360; i+= 30) { - sx = cos((i-90)*0.0174532925); - sy = sin((i-90)*0.0174532925); - x00 = sx*114+120; - y00 = sy*114+120; - x11 = sx*100+120; - y11 = sy*100+120; - - tft.drawLine(x00, y00, x11, y11, ILI9341_GREEN); - } - - // Draw 60 dots - for(int i = 0; i<360; i+= 6) { - sx = cos((i-90)*0.0174532925); - sy = sin((i-90)*0.0174532925); - x00 = sx*102+120; - y00 = sy*102+120; - // Draw minute markers - tft.drawPixel(x00, y00, ILI9341_WHITE); - - // Draw main quadrant dots - if(i==0 || i==180) tft.fillCircle(x00, y00, 2, ILI9341_WHITE); - if(i==90 || i==270) tft.fillCircle(x00, y00, 2, ILI9341_WHITE); - } - - tft.fillCircle(120, 121, 3, ILI9341_WHITE); - - // Draw text at position 120,260 using fonts 4 - // Only font numbers 2,4,6,7 are valid. Font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : . a p m - // Font 7 is a 7 segment font and only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : . - tft.drawCentreString("Time flies",120,260,4); - - targetTime = millis() + 1000; -} - -void loop() { - if (targetTime < millis()) { - targetTime = millis()+1000; - ss++; // Advance second - if (ss==60) { - ss=0; - mm++; // Advance minute - if(mm>59) { - mm=0; - hh++; // Advance hour - if (hh>23) { - hh=0; - } - } - } - - // Pre-compute hand degrees, x & y coords for a fast screen update - sdeg = ss*6; // 0-59 -> 0-354 - mdeg = mm*6+sdeg*0.01666667; // 0-59 -> 0-360 - includes seconds - hdeg = hh*30+mdeg*0.0833333; // 0-11 -> 0-360 - includes minutes and seconds - hx = cos((hdeg-90)*0.0174532925); - hy = sin((hdeg-90)*0.0174532925); - mx = cos((mdeg-90)*0.0174532925); - my = sin((mdeg-90)*0.0174532925); - sx = cos((sdeg-90)*0.0174532925); - sy = sin((sdeg-90)*0.0174532925); - - if (ss==0 || initial) { - initial = 0; - // Erase hour and minute hand positions every minute - tft.drawLine(ohx, ohy, 120, 121, ILI9341_BLACK); - ohx = hx*62+121; - ohy = hy*62+121; - tft.drawLine(omx, omy, 120, 121, ILI9341_BLACK); - omx = mx*84+120; - omy = my*84+121; - } - - // Redraw new hand positions, hour and minute hands not erased here to avoid flicker - tft.drawLine(osx, osy, 120, 121, ILI9341_BLACK); - osx = sx*90+121; - osy = sy*90+121; - tft.drawLine(osx, osy, 120, 121, ILI9341_RED); - tft.drawLine(ohx, ohy, 120, 121, ILI9341_WHITE); - tft.drawLine(omx, omy, 120, 121, ILI9341_WHITE); - tft.drawLine(osx, osy, 120, 121, ILI9341_RED); - - tft.fillCircle(120, 121, 3, ILI9341_RED); - } -} - -static uint8_t conv2d(const char* p) { - uint8_t v = 0; - if ('0' <= *p && *p <= '9') - v = *p - '0'; - return 10 * v + *++p - '0'; -} - diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Rainbow_ILI9341/TFT_Rainbow_ILI9341.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Rainbow_ILI9341/TFT_Rainbow_ILI9341.ino deleted file mode 100644 index b7d2489..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Rainbow_ILI9341/TFT_Rainbow_ILI9341.ino +++ /dev/null @@ -1,125 +0,0 @@ -/* - An example showing rainbow colours on a 2.2" TFT LCD screen - and to show a basic example of font use. - - The existing Adafruit font is still in the library - Only new font sizes 2,4,6 and 7 are implemented in the Adafruit_GFX library. - - This examples uses the hardware SPI only. Non-hardware SPI - is just too slow (~8 times slower!) - - Alan Senior 18/1/2015 - - */ - -// These are the connections for the UNO -//#define sclk 13 // Don't change -//#define mosi 11 // Don't change -#define cs 8 -#define dc 10 -#define rst 9 // you can also connect this to the Arduino reset - -#include // Core graphics library, with extra fonts. -#include // STM32 DMA Hardware-specific library -#include - -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(cs, dc, rst); // Invoke custom library - -unsigned long targetTime = 0; -byte red = 31; -byte green = 0; -byte blue = 0; -byte state = 0; -unsigned int colour = red << 11; - -void setup(void) { - tft.begin(); - tft.setRotation(2); - tft.fillScreen(ILI9341_BLACK); - - targetTime = millis() + 1000; -} - -void loop() { - - if (targetTime < millis()) { - targetTime = millis()+10000; - for (int i = 0; i<240; i++) { - tft.drawFastVLine(i, 0, tft.height(), colour); - switch (state) { - case 0: - green +=2; - if (green == 64) { - green=63; - state = 1; - } - break; - case 1: - red--; - if (red == 255) { - red = 0; - state = 2; - } - break; - case 2: - blue ++; - if (blue == 32) { - blue=31; - state = 3; - } - break; - case 3: - green -=2; - if (green ==255) { - green=0; - state = 4; - } - break; - case 4: - red ++; - if (red == 32) { - red = 31; - state = 5; - } - break; - case 5: - blue --; - if (blue == 255) { - blue = 0; - state = 0; - } - break; - } - colour = red<<11 | green<<5 | blue; - } - - // The standard ADAFruit font still works as berfore - tft.setTextColor(ILI9341_BLACK, ILI9341_BLACK); // Note these fonts do not plot the background colour - tft.setCursor (68, 5); - tft.print("Original ADAfruit font!"); - - // The new larger fonts do not use the .setCursor call, coords are embedded - tft.setTextColor(ILI9341_BLACK); // Do not plot the background colour - // Overlay the black text on top of the rainbow plot (the advantage of not drawing the backgorund colour!) - tft.drawCentreString("Font size 2",120,14,2); // Draw text centre at position 120, 14 using font 2 - tft.drawCentreString("Font size 4",120,30,4); // Draw text centre at position 120, 30 using font 4 - tft.drawCentreString("12.34",120,54,6); // Draw text centre at position 120, 54 using font 6 - tft.drawCentreString("12.34 is in font size 6",120,92,2); // Draw text centre at position 120, 92 using font 2 - // Note the x position is the top of the font! - - // draw a floating point number - float pi = 3.14159; // Value to print - int precision = 3; // Number of digits after decimal point - int xpos = 90; // x position - int ypos = 110; // y position - int font = 2; // font number only 2,4,6,7 valid. Font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : . a p m - xpos+=tft.drawFloat(pi,precision,xpos,ypos,font); // Draw rounded number and return new xpos delta for next print position - tft.drawString(" is pi",xpos,ypos,font); // Continue printing from new x position - } -} - - - - - - diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Show_Font_ILI9341/TFT_Show_Font_ILI9341.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Show_Font_ILI9341/TFT_Show_Font_ILI9341.ino deleted file mode 100644 index 13eee76..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/TFT_Show_Font_ILI9341/TFT_Show_Font_ILI9341.ino +++ /dev/null @@ -1,225 +0,0 @@ -/* - Sow all the fonts. - - Only font sizes 2, 4, 6 and 7 are implemented in the Adafruit_GFX library. - - This examples uses the hardware SPI only. Non-hardware SPI - is just too slow (~8 times slower!) - - Alan Senior 10/1/2015 - - Colours: - - code color - 0x0000 Black - 0xFFFF White - 0xBDF7 Light Gray - 0x7BEF Dark Gray - 0xF800 Red - 0xFFE0 Yellow - 0xFBE0 Orange - 0x79E0 Brown - 0x7E0 Green - 0x7FF Cyan - 0x1F Blue - 0xF81F Pink - - */ - -//#define sclk 6 // Don't change -//#define mosi 4 // Don't change -#define cs 8 -#define dc 10 -#define rst 9 // you can also connect this to the Arduino reset - -#include // Core graphics library, with extra fonts. -#include // STM32 DMA Hardware-specific library -#include - -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(cs, dc, rst); // Invoke custom library - -unsigned long targetTime = 0; -byte red = 31; -byte green = 0; -byte blue = 0; -byte state = 0; -unsigned int colour = red << 11; - -void setup(void) { - tft.init(); - tft.setRotation(1); -} - -void loop() { - - tft.setTextSize(1); - tft.fillScreen(ILI9341_BLACK); - tft.setTextColor(ILI9341_GREEN); - - tft.drawString(" !\"#$%&'()*+,-./0123456",0,0,2); - tft.drawString("789:;<=>?@ABCDEFGHIJKL",0,16,2); - tft.drawString("MNOPQRSTUVWXYZ[\\]^_`",0,32,2); - tft.drawString("abcdefghijklmnopqrstuvw",0,48,2); - int xpos=0; - xpos+=tft.drawString("xyz{|}~",0,64,2); - tft.drawChar(127,xpos,64,2); - delay(4000); - - tft.fillScreen(ILI9341_BLACK); - tft.setTextColor(ILI9341_GREEN); - - tft.drawString(" !\"#$%&'()*+,-.",0,0,4); - tft.drawString("/0123456789:;",0,26,4); - tft.drawString("<=>?@ABCDE",0,52,4); - tft.drawString("FGHIJKLMNO",0,78,4); - tft.drawString("PQRSTUVWX",0,104,4); - - delay(4000); - tft.fillScreen(ILI9341_BLACK); - tft.drawString("YZ[\\]^_`abc",0,0,4); - tft.drawString("defghijklmno",0,26,4); - tft.drawString("pqrstuvwxyz",0,52,4); - xpos=0; - xpos+=tft.drawString("{|}~",0,78,4); - tft.drawUnicode(127,xpos,78,4); - delay(4000); - - tft.fillScreen(ILI9341_BLACK); - tft.setTextColor(ILI9341_BLUE); - - tft.drawString("012345",0,0,6); - tft.drawString("6789",0,40,6); - tft.drawString("apm-:.",0,80,6); - delay(4000); - - tft.fillScreen(ILI9341_BLACK); - tft.setTextColor(ILI9341_RED); - - tft.drawString("0123",0,0,7); - tft.drawString("4567",0,60,7); - delay(4000); - - tft.fillScreen(ILI9341_BLACK); - tft.drawString("890:.",0,0,7); - tft.drawString("",0,60,7); - delay(4000); - - tft.setTextSize(2); - tft.fillScreen(ILI9341_BLACK); - tft.setTextColor(ILI9341_GREEN); - - tft.drawString(" !\"#$%&'()*+,-./0123456",0,0,2); - tft.drawString("789:;<=>?@ABCDEFGHIJKL",0,32,2); - tft.drawString("MNOPQRSTUVWXYZ[\\]^_`",0,64,2); - tft.drawString("abcdefghijklmnopqrstuvw",0,96,2); - xpos=0; - xpos+=tft.drawString("xyz{|}~",0,128,2); - tft.drawChar(127,xpos,128,2); - delay(4000); - - tft.fillScreen(ILI9341_BLACK); - tft.setTextColor(ILI9341_GREEN); - - tft.drawString(" !\"#$%&'()*+,-.",0,0,4); - tft.drawString("/0123456789:;",0,52,4); - tft.drawString("<=>?@ABCDE",0,104,4); - tft.drawString("FGHIJKLMNO",0,156,4); - tft.drawString("PQRSTUVWX",0,208,4); - delay(4000); - tft.fillScreen(ILI9341_BLACK); - tft.drawString("YZ[\\]^_`abc",0,0,4); - tft.drawString("defghijklmno",0,52,4); - tft.drawString("pqrstuvwxyz",0,104,4); - xpos=0; - xpos+=tft.drawString("{|}~",0,156,4); - tft.drawUnicode(127,xpos,156,4); - delay(4000); - - tft.fillScreen(ILI9341_BLACK); - tft.setTextColor(ILI9341_BLUE); - - tft.drawString("01234",0,0,6); - tft.drawString("56789",0,80,6); - tft.drawString("apm-:.",0,160,6); - delay(4000); - - tft.fillScreen(ILI9341_BLACK); - tft.setTextColor(ILI9341_RED); - - tft.drawString("0123",0,0,7); - tft.drawString("4567",0,120,7); - delay(4000); - - tft.fillScreen(ILI9341_BLACK); - tft.drawString("890:.",0,0,7); - tft.drawString("",0,120,7); - delay(4000); - - tft.setTextColor(ILI9341_MAGENTA, ILI9341_WHITE); - - tft.drawString(">>That's all<< ",0,180,4); - delay(4000); -} - -void rainbow(int ystart, int ylen) -{ - red = 31; - green = 0; - blue = 0; - state = 0; - colour = red << 11; - - for (int i = 0; i<160; i++) { - tft.drawFastVLine(i, ystart, ylen, colour); - switch (state) { - case 0: - green +=2; - if (green == 64) { - green=63; - state = 1; - } - break; - case 1: - red--; - if (red == 255) { - red = 0; - state = 2; - } - break; - case 2: - blue ++; - if (blue == 32) { - blue=31; - state = 3; - } - break; - case 3: - green -=2; - if (green ==255) { - green=0; - state = 4; - } - break; - case 4: - red ++; - if (red == 32) { - red = 31; - state = 5; - } - break; - case 5: - blue --; - if (blue == 255) { - blue = 0; - state = 0; - } - break; - } - colour = red<<11 | green<<5 | blue; - } -} - - - - - diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/breakouttouchpaint/breakouttouchpaint.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/breakouttouchpaint/breakouttouchpaint.ino deleted file mode 100644 index cd6b003..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/breakouttouchpaint/breakouttouchpaint.ino +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************** - This is our touchscreen painting example for the Adafruit ILI9341 Breakout - ----> http://www.adafruit.com/products/1770 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - -/** NOT FOR USE WITH THE TOUCH SHIELD, ONLY FOR THE BREAKOUT! **/ - -#include // Core graphics library -#include -#include -#include "TouchScreen.h" - -// These are the four touchscreen analog pins -#define YP A2 // must be an analog pin, use "An" notation! -#define XM A3 // must be an analog pin, use "An" notation! -#define YM 5 // can be a digital pin -#define XP 4 // can be a digital pin - -// This is calibration data for the raw touch data to the screen coordinates -#define TS_MINX 150 -#define TS_MINY 120 -#define TS_MAXX 920 -#define TS_MAXY 940 - -#define MINPRESSURE 10 -#define MAXPRESSURE 1000 - -// The display uses hardware SPI, plus #9 & #10 -#define TFT_CS 10 -#define TFT_DC 9 -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC); - -// For better pressure precision, we need to know the resistance -// between X+ and X- Use any multimeter to read it -// For the one we're using, its 300 ohms across the X plate -TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); - -// Size of the color selection boxes and the paintbrush size -#define BOXSIZE 40 -#define PENRADIUS 3 -int oldcolor, currentcolor; - -void setup(void) { - // while (!Serial); // used for leonardo debugging - - Serial.begin(9600); - Serial.println(F("Touch Paint!")); - - tft.begin(); - tft.fillScreen(ILI9341_BLACK); - - // make the color selection boxes - tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED); - tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW); - tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN); - tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN); - tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE); - tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA); - - // select the current color 'red' - tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - currentcolor = ILI9341_RED; -} - - -void loop() -{ - // Retrieve a point - TSPoint p = ts.getPoint(); - - /* - Serial.print("X = "); Serial.print(p.x); - Serial.print("\tY = "); Serial.print(p.y); - Serial.print("\tPressure = "); Serial.println(p.z); - */ - - // we have some minimum pressure we consider 'valid' - // pressure of 0 means no pressing! - if (p.z < MINPRESSURE || p.z > MAXPRESSURE) { - return; - } - - // Scale from ~0->1000 to tft.width using the calibration #'s - p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width()); - p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height()); - - /* - Serial.print("("); Serial.print(p.x); - Serial.print(", "); Serial.print(p.y); - Serial.println(")"); - */ - - - if (p.y < BOXSIZE) { - oldcolor = currentcolor; - - if (p.x < BOXSIZE) { - currentcolor = ILI9341_RED; - tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*2) { - currentcolor = ILI9341_YELLOW; - tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*3) { - currentcolor = ILI9341_GREEN; - tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*4) { - currentcolor = ILI9341_CYAN; - tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*5) { - currentcolor = ILI9341_BLUE; - tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*6) { - currentcolor = ILI9341_MAGENTA; - tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } - - if (oldcolor != currentcolor) { - if (oldcolor == ILI9341_RED) - tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED); - if (oldcolor == ILI9341_YELLOW) - tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW); - if (oldcolor == ILI9341_GREEN) - tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN); - if (oldcolor == ILI9341_CYAN) - tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN); - if (oldcolor == ILI9341_BLUE) - tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE); - if (oldcolor == ILI9341_MAGENTA) - tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA); - } - } - if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) { - tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor); - } -} diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/graphicstest/graphicstest.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/graphicstest/graphicstest.ino deleted file mode 100644 index c75c995..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/graphicstest/graphicstest.ino +++ /dev/null @@ -1,349 +0,0 @@ -/*************************************************** - This is our GFX example for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#include "SPI.h" -#include "Adafruit_GFX.h" -#include "Adafruit_ILI9341_STM.h" - -// For the Adafruit shield, these are the default. -#define TFT_DC 9 -#define TFT_CS 10 - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC); -// If using the breakout, change pins as desired -//Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); - -void setup() { - Serial.begin(9600); - Serial.println("ILI9341 Test!"); - - tft.begin(); - - // read diagnostics (optional but can help debug problems) - uint8_t x = tft.readcommand8(ILI9341_RDMODE); - Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDMADCTL); - Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDPIXFMT); - Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDIMGFMT); - Serial.print("Image Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDSELFDIAG); - Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); - - Serial.println(F("Benchmark Time (microseconds)")); - - Serial.print(F("Screen fill ")); - Serial.println(testFillScreen()); - delay(500); - - Serial.print(F("Text ")); - Serial.println(testText()); - delay(3000); - - Serial.print(F("Lines ")); - Serial.println(testLines(ILI9341_CYAN)); - delay(500); - - Serial.print(F("Horiz/Vert Lines ")); - Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE)); - delay(500); - - Serial.print(F("Rectangles (outline) ")); - Serial.println(testRects(ILI9341_GREEN)); - delay(500); - - Serial.print(F("Rectangles (filled) ")); - Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); - delay(500); - - Serial.print(F("Circles (filled) ")); - Serial.println(testFilledCircles(10, ILI9341_MAGENTA)); - - Serial.print(F("Circles (outline) ")); - Serial.println(testCircles(10, ILI9341_WHITE)); - delay(500); - - Serial.print(F("Triangles (outline) ")); - Serial.println(testTriangles()); - delay(500); - - Serial.print(F("Triangles (filled) ")); - Serial.println(testFilledTriangles()); - delay(500); - - Serial.print(F("Rounded rects (outline) ")); - Serial.println(testRoundRects()); - delay(500); - - Serial.print(F("Rounded rects (filled) ")); - Serial.println(testFilledRoundRects()); - delay(500); - - Serial.println(F("Done!")); - -} - - -void loop(void) { - for(uint8_t rotation=0; rotation<4; rotation++) { - tft.setRotation(rotation); - testText(); - delay(1000); - } -} - -unsigned long testFillScreen() { - unsigned long start = micros(); - tft.fillScreen(ILI9341_BLACK); - tft.fillScreen(ILI9341_RED); - tft.fillScreen(ILI9341_GREEN); - tft.fillScreen(ILI9341_BLUE); - tft.fillScreen(ILI9341_BLACK); - return micros() - start; -} - -unsigned long testText() { - tft.fillScreen(ILI9341_BLACK); - unsigned long start = micros(); - tft.setCursor(0, 0); - tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); - tft.println("Hello World!"); - tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2); - tft.println(1234.56); - tft.setTextColor(ILI9341_RED); tft.setTextSize(3); - tft.println(0xDEADBEEF, HEX); - tft.println(); - tft.setTextColor(ILI9341_GREEN); - tft.setTextSize(5); - tft.println("Groop"); - tft.setTextSize(2); - tft.println("I implore thee,"); - tft.setTextSize(1); - tft.println("my foonting turlingdromes."); - tft.println("And hooptiously drangle me"); - tft.println("with crinkly bindlewurdles,"); - tft.println("Or I will rend thee"); - tft.println("in the gobberwarts"); - tft.println("with my blurglecruncheon,"); - tft.println("see if I don't!"); - return micros() - start; -} - -unsigned long testLines(uint16_t color) { - unsigned long start, t; - int x1, y1, x2, y2, - w = tft.width(), - h = tft.height(); - - tft.fillScreen(ILI9341_BLACK); - - x1 = y1 = 0; - y2 = h - 1; - start = micros(); - for(x2=0; x20; i-=6) { - i2 = i / 2; - start = micros(); - tft.fillRect(cx-i2, cy-i2, i, i, color1); - t += micros() - start; - // Outlines are not included in timing results - tft.drawRect(cx-i2, cy-i2, i, i, color2); - } - - return t; -} - -unsigned long testFilledCircles(uint8_t radius, uint16_t color) { - unsigned long start; - int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; - - tft.fillScreen(ILI9341_BLACK); - start = micros(); - for(x=radius; x10; i-=5) { - start = micros(); - tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(0, i, i)); - t += micros() - start; - tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(i, i, 0)); - } - - return t; -} - -unsigned long testRoundRects() { - unsigned long start; - int w, i, i2, - cx = tft.width() / 2 - 1, - cy = tft.height() / 2 - 1; - - tft.fillScreen(ILI9341_BLACK); - w = min(tft.width(), tft.height()); - start = micros(); - for(i=0; i20; i-=6) { - i2 = i / 2; - tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); - } - - return micros() - start; -} \ No newline at end of file diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/onoffbutton/onoffbutton.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/onoffbutton/onoffbutton.ino deleted file mode 100644 index b373835..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/onoffbutton/onoffbutton.ino +++ /dev/null @@ -1,125 +0,0 @@ -//This example implements a simple sliding On/Off button. The example -// demonstrates drawing and touch operations. -// -//Thanks to Adafruit forums member Asteroid for the original sketch! -// -#include -#include -#include -#include -#include - -// This is calibration data for the raw touch data to the screen coordinates -#define TS_MINX 150 -#define TS_MINY 130 -#define TS_MAXX 3800 -#define TS_MAXY 4000 - -#define STMPE_CS 8 -Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS); -#define TFT_CS 10 -#define TFT_DC 9 -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC); - -boolean RecordOn = false; - -#define FRAME_X 210 -#define FRAME_Y 180 -#define FRAME_W 100 -#define FRAME_H 50 - -#define REDBUTTON_X FRAME_X -#define REDBUTTON_Y FRAME_Y -#define REDBUTTON_W (FRAME_W/2) -#define REDBUTTON_H FRAME_H - -#define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W) -#define GREENBUTTON_Y FRAME_Y -#define GREENBUTTON_W (FRAME_W/2) -#define GREENBUTTON_H FRAME_H - -void drawFrame() -{ - tft.drawRect(FRAME_X, FRAME_Y, FRAME_W, FRAME_H, ILI9341_BLACK); -} - -void redBtn() -{ - tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_RED); - tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_BLUE); - drawFrame(); - tft.setCursor(GREENBUTTON_X + 6 , GREENBUTTON_Y + (GREENBUTTON_H/2)); - tft.setTextColor(ILI9341_WHITE); - tft.setTextSize(2); - tft.println("ON"); - RecordOn = false; -} - -void greenBtn() -{ - tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_GREEN); - tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_BLUE); - drawFrame(); - tft.setCursor(REDBUTTON_X + 6 , REDBUTTON_Y + (REDBUTTON_H/2)); - tft.setTextColor(ILI9341_WHITE); - tft.setTextSize(2); - tft.println("OFF"); - RecordOn = true; -} - -void setup(void) -{ - Serial.begin(9600); - tft.begin(); - if (!ts.begin()) { - Serial.println("Unable to start touchscreen."); - } - else { - Serial.println("Touchscreen started."); - } - - tft.fillScreen(ILI9341_BLUE); - // origin = left,top landscape (USB left upper) - tft.setRotation(1); - redBtn(); -} - -void loop() -{ - // See if there's any touch data for us - if (!ts.bufferEmpty()) - { - // Retrieve a point - TS_Point p = ts.getPoint(); - // Scale using the calibration #'s - // and rotate coordinate system - p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height()); - p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width()); - int y = tft.height() - p.x; - int x = p.y; - - if (RecordOn) - { - if((x > REDBUTTON_X) && (x < (REDBUTTON_X + REDBUTTON_W))) { - if ((y > REDBUTTON_Y) && (y <= (REDBUTTON_Y + REDBUTTON_H))) { - Serial.println("Red btn hit"); - redBtn(); - } - } - } - else //Record is off (RecordOn == false) - { - if((x > GREENBUTTON_X) && (x < (GREENBUTTON_X + GREENBUTTON_W))) { - if ((y > GREENBUTTON_Y) && (y <= (GREENBUTTON_Y + GREENBUTTON_H))) { - Serial.println("Green btn hit"); - greenBtn(); - } - } - } - - Serial.println(RecordOn); - } -} - - - diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/onoffbutton_breakout/onoffbutton_breakout.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/onoffbutton_breakout/onoffbutton_breakout.ino deleted file mode 100644 index 9e35441..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/onoffbutton_breakout/onoffbutton_breakout.ino +++ /dev/null @@ -1,133 +0,0 @@ -//This example implements a simple sliding On/Off button. The example -// demonstrates drawing and touch operations. -// -//Thanks to Adafruit forums member Asteroid for the original sketch! -// -#include -#include -#include -#include -#include - -//Touchscreen X+ X- Y+ Y- pins -#define YP A3 // must be an analog pin, use "An" notation! -#define XM A2 // must be an analog pin, use "An" notation! -#define YM 5 // can be a digital pin -#define XP 4 // can be a digital pin - -// This is calibration data for the raw touch data to the screen coordinates -#define TS_MINX 150 -#define TS_MINY 120 -#define TS_MAXX 920 -#define TS_MAXY 940 - -#define MINPRESSURE 10 -#define MAXPRESSURE 1000 - -// For better pressure precision, we need to know the resistance -// between X+ and X- Use any multimeter to read it -// For the one we're using, its 300 ohms across the X plate -TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); - - -#define TFT_CS 10 -#define TFT_DC 9 -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC); - -boolean RecordOn = false; - -#define FRAME_X 210 -#define FRAME_Y 180 -#define FRAME_W 100 -#define FRAME_H 50 - -#define REDBUTTON_X FRAME_X -#define REDBUTTON_Y FRAME_Y -#define REDBUTTON_W (FRAME_W/2) -#define REDBUTTON_H FRAME_H - -#define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W) -#define GREENBUTTON_Y FRAME_Y -#define GREENBUTTON_W (FRAME_W/2) -#define GREENBUTTON_H FRAME_H - -void drawFrame() -{ - tft.drawRect(FRAME_X, FRAME_Y, FRAME_W, FRAME_H, ILI9341_BLACK); -} - -void redBtn() -{ - tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_RED); - tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_BLUE); - drawFrame(); - tft.setCursor(GREENBUTTON_X + 6 , GREENBUTTON_Y + (GREENBUTTON_H/2)); - tft.setTextColor(ILI9341_WHITE); - tft.setTextSize(2); - tft.println("ON"); - RecordOn = false; -} - -void greenBtn() -{ - tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_GREEN); - tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_BLUE); - drawFrame(); - tft.setCursor(REDBUTTON_X + 6 , REDBUTTON_Y + (REDBUTTON_H/2)); - tft.setTextColor(ILI9341_WHITE); - tft.setTextSize(2); - tft.println("OFF"); - RecordOn = true; -} - -void setup(void) -{ - Serial.begin(9600); - tft.begin(); - - tft.fillScreen(ILI9341_BLUE); - // origin = left,top landscape (USB left upper) - tft.setRotation(1); - redBtn(); -} - -void loop() -{ - // Retrieve a point - TSPoint p = ts.getPoint(); - - // See if there's any touch data for us - if (p.z > MINPRESSURE && p.z < MAXPRESSURE) - { - // Scale using the calibration #'s - // and rotate coordinate system - p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height()); - p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width()); - int y = tft.height() - p.x; - int x = p.y; - - if (RecordOn) - { - if((x > REDBUTTON_X) && (x < (REDBUTTON_X + REDBUTTON_W))) { - if ((y > REDBUTTON_Y) && (y <= (REDBUTTON_Y + REDBUTTON_H))) { - Serial.println("Red btn hit"); - redBtn(); - } - } - } - else //Record is off (RecordOn == false) - { - if((x > GREENBUTTON_X) && (x < (GREENBUTTON_X + GREENBUTTON_W))) { - if ((y > GREENBUTTON_Y) && (y <= (GREENBUTTON_Y + GREENBUTTON_H))) { - Serial.println("Green btn hit"); - greenBtn(); - } - } - } - - Serial.println(RecordOn); - } -} - - - diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/spitftbitmap/spitftbitmap.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/spitftbitmap/spitftbitmap.ino deleted file mode 100644 index 84ff464..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/spitftbitmap/spitftbitmap.ino +++ /dev/null @@ -1,189 +0,0 @@ -/*************************************************** - This is our Bitmap drawing example for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#include // Core graphics library -#include "Adafruit_ILI9341_STM.h" // Hardware-specific library -#include -#include - -// TFT display and SD card will share the hardware SPI interface. -// Hardware SPI pins are specific to the Arduino board type and -// cannot be remapped to alternate pins. For Arduino Uno, -// Duemilanove, etc., pin 11 = MOSI, pin 12 = MISO, pin 13 = SCK. - -#define TFT_DC 9 -#define TFT_CS 10 -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC); - -#define SD_CS 4 - -void setup(void) { - Serial.begin(9600); - - tft.begin(); - tft.fillScreen(ILI9341_BLUE); - - Serial.print("Initializing SD card..."); - if (!SD.begin(SD_CS)) { - Serial.println("failed!"); - } - Serial.println("OK!"); - - bmpDraw("purple.bmp", 0, 0); -} - -void loop() { -} - -// This function opens a Windows Bitmap (BMP) file and -// displays it at the given coordinates. It's sped up -// by reading many pixels worth of data at a time -// (rather than pixel by pixel). Increasing the buffer -// size takes more of the Arduino's precious RAM but -// makes loading a little faster. 20 pixels seems a -// good balance. - -#define BUFFPIXEL 20 - -void bmpDraw(char *filename, uint8_t x, uint16_t y) { - - File bmpFile; - int bmpWidth, bmpHeight; // W+H in pixels - uint8_t bmpDepth; // Bit depth (currently must be 24) - uint32_t bmpImageoffset; // Start of image data in file - uint32_t rowSize; // Not always = bmpWidth; may have padding - uint8_t sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel) - uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer - boolean goodBmp = false; // Set to true on valid header parse - boolean flip = true; // BMP is stored bottom-to-top - int w, h, row, col; - uint8_t r, g, b; - uint32_t pos = 0, startTime = millis(); - - if((x >= tft.width()) || (y >= tft.height())) return; - - Serial.println(); - Serial.print(F("Loading image '")); - Serial.print(filename); - Serial.println('\''); - - // Open requested file on SD card - if ((bmpFile = SD.open(filename)) == NULL) { - Serial.print(F("File not found")); - return; - } - - // Parse BMP header - if(read16(bmpFile) == 0x4D42) { // BMP signature - Serial.print(F("File size: ")); Serial.println(read32(bmpFile)); - (void)read32(bmpFile); // Read & ignore creator bytes - bmpImageoffset = read32(bmpFile); // Start of image data - Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC); - // Read DIB header - Serial.print(F("Header size: ")); Serial.println(read32(bmpFile)); - bmpWidth = read32(bmpFile); - bmpHeight = read32(bmpFile); - if(read16(bmpFile) == 1) { // # planes -- must be '1' - bmpDepth = read16(bmpFile); // bits per pixel - Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth); - if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed - - goodBmp = true; // Supported BMP format -- proceed! - Serial.print(F("Image size: ")); - Serial.print(bmpWidth); - Serial.print('x'); - Serial.println(bmpHeight); - - // BMP rows are padded (if needed) to 4-byte boundary - rowSize = (bmpWidth * 3 + 3) & ~3; - - // If bmpHeight is negative, image is in top-down order. - // This is not canon but has been observed in the wild. - if(bmpHeight < 0) { - bmpHeight = -bmpHeight; - flip = false; - } - - // Crop area to be loaded - w = bmpWidth; - h = bmpHeight; - if((x+w-1) >= tft.width()) w = tft.width() - x; - if((y+h-1) >= tft.height()) h = tft.height() - y; - - // Set TFT address window to clipped image bounds - tft.setAddrWindow(x, y, x+w-1, y+h-1); - - for (row=0; row= sizeof(sdbuffer)) { // Indeed - bmpFile.read(sdbuffer, sizeof(sdbuffer)); - buffidx = 0; // Set index to beginning - } - - // Convert pixel from BMP to TFT format, push to display - b = sdbuffer[buffidx++]; - g = sdbuffer[buffidx++]; - r = sdbuffer[buffidx++]; - tft.pushColor(tft.color565(r,g,b)); - } // end pixel - } // end scanline - Serial.print(F("Loaded in ")); - Serial.print(millis() - startTime); - Serial.println(" ms"); - } // end goodBmp - } - } - - bmpFile.close(); - if(!goodBmp) Serial.println(F("BMP format not recognized.")); -} - -// These read 16- and 32-bit types from the SD card file. -// BMP data is stored little-endian, Arduino is little-endian too. -// May need to reverse subscript order if porting elsewhere. - -uint16_t read16(File &f) { - uint16_t result; - ((uint8_t *)&result)[0] = f.read(); // LSB - ((uint8_t *)&result)[1] = f.read(); // MSB - return result; -} - -uint32_t read32(File &f) { - uint32_t result; - ((uint8_t *)&result)[0] = f.read(); // LSB - ((uint8_t *)&result)[1] = f.read(); - ((uint8_t *)&result)[2] = f.read(); - ((uint8_t *)&result)[3] = f.read(); // MSB - return result; -} diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/stm32_graphicstest/stm32_graphicstest.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/stm32_graphicstest/stm32_graphicstest.ino deleted file mode 100644 index 26cb160..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/stm32_graphicstest/stm32_graphicstest.ino +++ /dev/null @@ -1,350 +0,0 @@ -/*************************************************** - This is our GFX example for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#include "SPI.h" - -#include // Core graphics library, with extra fonts. -#include // STM32 DMA Hardware-specific library - -// For the Adafruit shield, these are the default. -#define TFT_CS 8 -#define TFT_DC 10 -#define TFT_RST 9 - - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); -// If using the breakout, change pins as desired -//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC, TFT_RST); // Use hardware SPI - -void setup() { - Serial.begin(115200); - tft.begin(); -} - - -void loop(void) { - - Serial.println("ILI9341 Test!"); - // read diagnostics (optional but can help debug problems) - uint8_t x = tft.readcommand8(ILI9341_RDMODE); - Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDMADCTL); - Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDPIXFMT); - Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDIMGFMT); - Serial.print("Image Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDSELFDIAG); - Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); - - Serial.println(F("Benchmark Time (microseconds)")); - - Serial.print(F("Screen fill ")); - Serial.println(testFillScreen()); - - - Serial.print(F("Text ")); - Serial.println(testText()); - - Serial.print(F("Lines ")); - Serial.println(testLines(ILI9341_CYAN)); - - - Serial.print(F("Horiz/Vert Lines ")); - Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE)); - - - Serial.print(F("Rectangles (outline) ")); - Serial.println(testRects(ILI9341_GREEN)); - - - Serial.print(F("Rectangles (filled) ")); - Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); - - - Serial.print(F("Circles (filled) ")); - Serial.println(testFilledCircles(10, ILI9341_MAGENTA)); - - Serial.print(F("Circles (outline) ")); - Serial.println(testCircles(10, ILI9341_WHITE)); - - - Serial.print(F("Triangles (outline) ")); - Serial.println(testTriangles()); - - - Serial.print(F("Triangles (filled) ")); - Serial.println(testFilledTriangles()); - - - Serial.print(F("Rounded rects (outline) ")); - Serial.println(testRoundRects()); - - - Serial.print(F("Rounded rects (filled) ")); - Serial.println(testFilledRoundRects()); - - - Serial.println(F("Done!")); - - for(uint8_t rotation=0; rotation<4; rotation++) { - tft.setRotation(rotation); - testText(); - } -} - -unsigned long testFillScreen() { - unsigned long start = micros(); - tft.fillScreen(ILI9341_BLACK); - tft.fillScreen(ILI9341_RED); - tft.fillScreen(ILI9341_GREEN); - tft.fillScreen(ILI9341_BLUE); - tft.fillScreen(ILI9341_BLACK); - return micros() - start; -} - -unsigned long testText() { - tft.fillScreen(ILI9341_BLACK); - unsigned long start = micros(); - tft.setCursor(0, 0); - tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); - tft.println("Hello World!"); - tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2); - tft.println(1234.56); - tft.setTextColor(ILI9341_RED); tft.setTextSize(3); - tft.println(0xDEADBEEF, HEX); - tft.println(); - tft.setTextColor(ILI9341_GREEN); - tft.setTextSize(5); - tft.println("Groop"); - tft.setTextSize(2); - tft.println("I implore thee,"); - tft.setTextSize(1); - tft.println("my foonting turlingdromes."); - tft.println("And hooptiously drangle me"); - tft.println("with crinkly bindlewurdles,"); - tft.println("Or I will rend thee"); - tft.println("in the gobberwarts"); - tft.println("with my blurglecruncheon,"); - tft.println("see if I don't!"); - return micros() - start; -} - -unsigned long testLines(uint16_t color) { - unsigned long start, t; - int x1, y1, x2, y2, - w = tft.width(), - h = tft.height(); - - tft.fillScreen(ILI9341_BLACK); - - x1 = y1 = 0; - y2 = h - 1; - start = micros(); - for(x2=0; x20; i-=6) { - i2 = i / 2; - start = micros(); - tft.fillRect(cx-i2, cy-i2, i, i, color1); - t += micros() - start; - // Outlines are not included in timing results - tft.drawRect(cx-i2, cy-i2, i, i, color2); - } - - return t; -} - -unsigned long testFilledCircles(uint8_t radius, uint16_t color) { - unsigned long start; - int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; - - tft.fillScreen(ILI9341_BLACK); - start = micros(); - for(x=radius; x10; i-=5) { - start = micros(); - tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(0, i, i)); - t += micros() - start; - tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(i, i, 0)); - } - - return t; -} - -unsigned long testRoundRects() { - unsigned long start; - int w, i, i2, - cx = tft.width() / 2 - 1, - cy = tft.height() / 2 - 1; - - tft.fillScreen(ILI9341_BLACK); - w = min(tft.width(), tft.height()); - start = micros(); - for(i=0; i20; i-=6) { - i2 = i / 2; - tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); - } - - return micros() - start; -} \ No newline at end of file diff --git a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/touchpaint/touchpaint.ino b/GD32F1/libraries/Adafruit_ILI9341_STM/examples/touchpaint/touchpaint.ino deleted file mode 100644 index e10ecd9..0000000 --- a/GD32F1/libraries/Adafruit_ILI9341_STM/examples/touchpaint/touchpaint.ino +++ /dev/null @@ -1,146 +0,0 @@ -/*************************************************** - This is our touchscreen painting example for the Adafruit ILI9341 Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#include // Core graphics library -#include -#include // this is needed even tho we aren't using it -#include -#include - -// This is calibration data for the raw touch data to the screen coordinates -#define TS_MINX 150 -#define TS_MINY 130 -#define TS_MAXX 3800 -#define TS_MAXY 4000 - -// The STMPE610 uses hardware SPI on the shield, and #8 -#define STMPE_CS 8 -Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS); - -// The display also uses hardware SPI, plus #9 & #10 -#define TFT_CS 10 -#define TFT_DC 9 -Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC); - -// Size of the color selection boxes and the paintbrush size -#define BOXSIZE 40 -#define PENRADIUS 3 -int oldcolor, currentcolor; - -void setup(void) { - // while (!Serial); // used for leonardo debugging - - Serial.begin(9600); - Serial.println(F("Touch Paint!")); - - tft.begin(); - - if (!ts.begin()) { - Serial.println("Couldn't start touchscreen controller"); - while (1); - } - Serial.println("Touchscreen started"); - - tft.fillScreen(ILI9341_BLACK); - - // make the color selection boxes - tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED); - tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW); - tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN); - tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN); - tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE); - tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA); - - // select the current color 'red' - tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - currentcolor = ILI9341_RED; -} - - -void loop() -{ - // See if there's any touch data for us - if (ts.bufferEmpty()) { - return; - } - /* - // You can also wait for a touch - if (! ts.touched()) { - return; - } - */ - - // Retrieve a point - TS_Point p = ts.getPoint(); - - /* - Serial.print("X = "); Serial.print(p.x); - Serial.print("\tY = "); Serial.print(p.y); - Serial.print("\tPressure = "); Serial.println(p.z); - */ - - // Scale from ~0->4000 to tft.width using the calibration #'s - p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width()); - p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height()); - - /* - Serial.print("("); Serial.print(p.x); - Serial.print(", "); Serial.print(p.y); - Serial.println(")"); - */ - - if (p.y < BOXSIZE) { - oldcolor = currentcolor; - - if (p.x < BOXSIZE) { - currentcolor = ILI9341_RED; - tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*2) { - currentcolor = ILI9341_YELLOW; - tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*3) { - currentcolor = ILI9341_GREEN; - tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*4) { - currentcolor = ILI9341_CYAN; - tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*5) { - currentcolor = ILI9341_BLUE; - tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } else if (p.x < BOXSIZE*6) { - currentcolor = ILI9341_MAGENTA; - tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE); - } - - if (oldcolor != currentcolor) { - if (oldcolor == ILI9341_RED) - tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED); - if (oldcolor == ILI9341_YELLOW) - tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW); - if (oldcolor == ILI9341_GREEN) - tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN); - if (oldcolor == ILI9341_CYAN) - tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN); - if (oldcolor == ILI9341_BLUE) - tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE); - if (oldcolor == ILI9341_MAGENTA) - tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA); - } - } - if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) { - tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor); - } -} diff --git a/GD32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.cpp b/GD32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.cpp deleted file mode 100644 index c0c24a0..0000000 --- a/GD32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.cpp +++ /dev/null @@ -1,777 +0,0 @@ -/********************************************************************* -This is a library for our Monochrome OLEDs based on SSD1306 drivers - - Pick one up today in the adafruit shop! - ------> http://www.adafruit.com/category/63_98 - -These displays use SPI to communicate, 4 or 5 pins are required to -interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen below must be included in any redistribution -*********************************************************************/ - -#include -//#ifndef __SAM3X8E__ || __STM32F1__ - //#include -//#endif -#include - -//#include -#include -//HardWire HWIRE(1,I2C_FAST_MODE); // I2c1 -HardWire HWIRE(2,I2C_FAST_MODE); // I2c2 -#include "Adafruit_GFX.h" -#include "Adafruit_SSD1306_STM32.h" - -// the memory buffer for the LCD - -static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, -0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x80, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, -0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0xFF, -#if (SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH > 96*16) -0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, -0x80, 0xFF, 0xFF, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, -0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x8C, 0x8E, 0x84, 0x00, 0x00, 0x80, 0xF8, -0xF8, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, -0x00, 0xE0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xC7, 0x01, 0x01, -0x01, 0x01, 0x83, 0xFF, 0xFF, 0x00, 0x00, 0x7C, 0xFE, 0xC7, 0x01, 0x01, 0x01, 0x01, 0x83, 0xFF, -0xFF, 0xFF, 0x00, 0x38, 0xFE, 0xC7, 0x83, 0x01, 0x01, 0x01, 0x83, 0xC7, 0xFF, 0xFF, 0x00, 0x00, -0x01, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0xFF, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x7F, 0xFF, -0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF, -0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC7, 0xC7, 0x8F, -0x8F, 0x9F, 0xBF, 0xFF, 0xFF, 0xC3, 0xC0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFC, -0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x01, 0x03, 0x03, 0x03, -0x03, 0x03, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, -0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x00, 0x00, -0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, -0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x03, -0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -#if (SSD1306_LCDHEIGHT == 64) -0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F, -0x87, 0xC7, 0xF7, 0xFF, 0xFF, 0x1F, 0x1F, 0x3D, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0x7C, 0x7D, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x00, 0x30, 0x30, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xC0, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, -0x0F, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, -0x00, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x0E, 0xFC, 0xF8, 0x00, 0x00, 0xF0, 0xF8, 0x1C, 0x0E, -0x06, 0x06, 0x06, 0x0C, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFC, -0xFE, 0xFC, 0x00, 0x18, 0x3C, 0x7E, 0x66, 0xE6, 0xCE, 0x84, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0x06, -0x06, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x06, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0xC0, 0xF8, -0xFC, 0x4E, 0x46, 0x46, 0x46, 0x4E, 0x7C, 0x78, 0x40, 0x18, 0x3C, 0x76, 0xE6, 0xCE, 0xCC, 0x80, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x03, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, -0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x07, 0x0E, 0x0C, -0x18, 0x18, 0x0C, 0x06, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x0F, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, -0x07, 0x01, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, -0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x07, -0x07, 0x0C, 0x0C, 0x18, 0x1C, 0x0C, 0x06, 0x06, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif -#endif -}; - - - -// the most basic function, set a single pixel -void Adafruit_SSD1306::drawPixel(int16_t x, int16_t y, uint16_t color) { - if ((x < 0) || (x >= width()) || (y < 0) || (y >= height())) - return; - - // check rotation, move pixel around if necessary - switch (getRotation()) { - case 1: - swap(x, y); - x = WIDTH - x - 1; - break; - case 2: - x = WIDTH - x - 1; - y = HEIGHT - y - 1; - break; - case 3: - swap(x, y); - y = HEIGHT - y - 1; - break; - } - - // x is which column - switch (color) - { - case WHITE: buffer[x+ (y/8)*SSD1306_LCDWIDTH] |= (1 << (y&7)); break; - case BLACK: buffer[x+ (y/8)*SSD1306_LCDWIDTH] &= ~(1 << (y&7)); break; - case INVERSE: buffer[x+ (y/8)*SSD1306_LCDWIDTH] ^= (1 << (y&7)); break; - } - -} - -Adafruit_SSD1306::Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) { - cs = CS; - rst = RST; - dc = DC; - sclk = SCLK; - sid = SID; - hwSPI = false; -} - -// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset -Adafruit_SSD1306::Adafruit_SSD1306(int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) { - dc = DC; - rst = RST; - cs = CS; - hwSPI = true; -} - -// initializer for I2C - we only indicate the reset pin! -Adafruit_SSD1306::Adafruit_SSD1306(int8_t reset) : -Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) { - sclk = dc = cs = sid = -1; - rst = reset; -} - - -void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) { - _vccstate = vccstate; - _i2caddr = i2caddr; - - // set pin directions - if (sid != -1){ - pinMode(dc, OUTPUT); - pinMode(cs, OUTPUT); - csport = portOutputRegister(digitalPinToPort(cs)); - cspinmask = digitalPinToBitMask(cs); - dcport = portOutputRegister(digitalPinToPort(dc)); - dcpinmask = digitalPinToBitMask(dc); - if (!hwSPI){ - // set pins for software-SPI - pinMode(sid, OUTPUT); - pinMode(sclk, OUTPUT); - clkport = portOutputRegister(digitalPinToPort(sclk)); - clkpinmask = digitalPinToBitMask(sclk); - mosiport = portOutputRegister(digitalPinToPort(sid)); - mosipinmask = digitalPinToBitMask(sid); - } - if (hwSPI){ - SPI.begin (); -//#ifdef __SAM3X8E__ - SPI.setClockDivider (9); // 9.3 MHz -//#else - // SPI.setClockDivider (SPI_CLOCK_DIV2); // 8 MHz -//#endif - } - } - else - { - // I2C Init - HWIRE.begin(); - -#ifdef __SAM3X8E__ - // Force 400 KHz I2C, rawr! (Uses pins 20, 21 for SDA, SCL) - TWI1->TWI_CWGR = 0; - TWI1->TWI_CWGR = ((VARIANT_MCK / (2 * 400000)) - 4) * 0x101; -#endif - } - - if (reset) { - // Setup reset pin direction (used by both SPI and I2C) - pinMode(rst, OUTPUT); - digitalWrite(rst, HIGH); - // VDD (3.3V) goes high at start, lets just chill for a ms - delay(1); - // bring reset low - digitalWrite(rst, LOW); - // wait 10ms - delay(10); - // bring out of reset - digitalWrite(rst, HIGH); - // turn on VCC (9V?) - } - - #if defined SSD1306_128_32 - // Init sequence for 128x32 OLED module - ssd1306_command(SSD1306_DISPLAYOFF); // 0xAE - ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5 - ssd1306_command(0x80); // the suggested ratio 0x80 - ssd1306_command(SSD1306_SETMULTIPLEX); // 0xA8 - ssd1306_command(0x1F); - ssd1306_command(SSD1306_SETDISPLAYOFFSET); // 0xD3 - ssd1306_command(0x0); // no offset - ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0 - ssd1306_command(SSD1306_CHARGEPUMP); // 0x8D - if (vccstate == SSD1306_EXTERNALVCC) - { ssd1306_command(0x10); } - else - { ssd1306_command(0x14); } - ssd1306_command(SSD1306_MEMORYMODE); // 0x20 - ssd1306_command(0x00); // 0x0 act like ks0108 - ssd1306_command(SSD1306_SEGREMAP | 0x1); - ssd1306_command(SSD1306_COMSCANDEC); - ssd1306_command(SSD1306_SETCOMPINS); // 0xDA - ssd1306_command(0x02); - ssd1306_command(SSD1306_SETCONTRAST); // 0x81 - ssd1306_command(0x8F); - ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9 - if (vccstate == SSD1306_EXTERNALVCC) - { ssd1306_command(0x22); } - else - { ssd1306_command(0xF1); } - ssd1306_command(SSD1306_SETVCOMDETECT); // 0xDB - ssd1306_command(0x40); - ssd1306_command(SSD1306_DISPLAYALLON_RESUME); // 0xA4 - ssd1306_command(SSD1306_NORMALDISPLAY); // 0xA6 - #endif - - #if defined SSD1306_128_64 - // Init sequence for 128x64 OLED module - ssd1306_command(SSD1306_DISPLAYOFF); // 0xAE - ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5 - ssd1306_command(0x80); // the suggested ratio 0x80 - ssd1306_command(SSD1306_SETMULTIPLEX); // 0xA8 - ssd1306_command(0x3F); - ssd1306_command(SSD1306_SETDISPLAYOFFSET); // 0xD3 - ssd1306_command(0x0); // no offset - ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0 - ssd1306_command(SSD1306_CHARGEPUMP); // 0x8D - if (vccstate == SSD1306_EXTERNALVCC) - { ssd1306_command(0x10); } - else - { ssd1306_command(0x14); } - ssd1306_command(SSD1306_MEMORYMODE); // 0x20 - ssd1306_command(0x00); // 0x0 act like ks0108 - ssd1306_command(SSD1306_SEGREMAP | 0x1); - ssd1306_command(SSD1306_COMSCANDEC); - ssd1306_command(SSD1306_SETCOMPINS); // 0xDA - ssd1306_command(0x12); - ssd1306_command(SSD1306_SETCONTRAST); // 0x81 - if (vccstate == SSD1306_EXTERNALVCC) - { ssd1306_command(0x9F); } - else - { ssd1306_command(0xCF); } - ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9 - if (vccstate == SSD1306_EXTERNALVCC) - { ssd1306_command(0x22); } - else - { ssd1306_command(0xF1); } - ssd1306_command(SSD1306_SETVCOMDETECT); // 0xDB - ssd1306_command(0x40); - ssd1306_command(SSD1306_DISPLAYALLON_RESUME); // 0xA4 - ssd1306_command(SSD1306_NORMALDISPLAY); // 0xA6 - #endif - - #if defined SSD1306_96_16 - // Init sequence for 96x16 OLED module - ssd1306_command(SSD1306_DISPLAYOFF); // 0xAE - ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5 - ssd1306_command(0x80); // the suggested ratio 0x80 - ssd1306_command(SSD1306_SETMULTIPLEX); // 0xA8 - ssd1306_command(0x0F); - ssd1306_command(SSD1306_SETDISPLAYOFFSET); // 0xD3 - ssd1306_command(0x00); // no offset - ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0 - ssd1306_command(SSD1306_CHARGEPUMP); // 0x8D - if (vccstate == SSD1306_EXTERNALVCC) - { ssd1306_command(0x10); } - else - { ssd1306_command(0x14); } - ssd1306_command(SSD1306_MEMORYMODE); // 0x20 - ssd1306_command(0x00); // 0x0 act like ks0108 - ssd1306_command(SSD1306_SEGREMAP | 0x1); - ssd1306_command(SSD1306_COMSCANDEC); - ssd1306_command(SSD1306_SETCOMPINS); // 0xDA - ssd1306_command(0x2); //ada x12 - ssd1306_command(SSD1306_SETCONTRAST); // 0x81 - if (vccstate == SSD1306_EXTERNALVCC) - { ssd1306_command(0x10); } - else - { ssd1306_command(0xAF); } - ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9 - if (vccstate == SSD1306_EXTERNALVCC) - { ssd1306_command(0x22); } - else - { ssd1306_command(0xF1); } - ssd1306_command(SSD1306_SETVCOMDETECT); // 0xDB - ssd1306_command(0x40); - ssd1306_command(SSD1306_DISPLAYALLON_RESUME); // 0xA4 - ssd1306_command(SSD1306_NORMALDISPLAY); // 0xA6 - #endif - - ssd1306_command(SSD1306_DISPLAYON);//--turn on oled panel -} - - -void Adafruit_SSD1306::invertDisplay(uint8_t i) { - if (i) { - ssd1306_command(SSD1306_INVERTDISPLAY); - } else { - ssd1306_command(SSD1306_NORMALDISPLAY); - } -} - -void Adafruit_SSD1306::ssd1306_command(uint8_t c) { - if (sid != -1) - { - // SPI - //digitalWrite(cs, HIGH); - *csport |= cspinmask; - //digitalWrite(dc, LOW); - *dcport &= ~dcpinmask; - //digitalWrite(cs, LOW); - *csport &= ~cspinmask; - fastSPIwrite(c); - //digitalWrite(cs, HIGH); - *csport |= cspinmask; - } - else - { - // I2C - uint8_t control = 0x00; // Co = 0, D/C = 0 - HWIRE.beginTransmission(_i2caddr); - WIRE_WRITE(control); - WIRE_WRITE(c); - HWIRE.endTransmission(); - } -} - -// startscrollright -// Activate a right handed scroll for rows start through stop -// Hint, the display is 16 rows tall. To scroll the whole display, run: -// display.scrollright(0x00, 0x0F) -void Adafruit_SSD1306::startscrollright(uint8_t start, uint8_t stop){ - ssd1306_command(SSD1306_RIGHT_HORIZONTAL_SCROLL); - ssd1306_command(0X00); - ssd1306_command(start); - ssd1306_command(0X0F); - ssd1306_command(stop); - ssd1306_command(0X00); - ssd1306_command(0XFF); - ssd1306_command(SSD1306_ACTIVATE_SCROLL); -} - -// startscrollleft -// Activate a right handed scroll for rows start through stop -// Hint, the display is 16 rows tall. To scroll the whole display, run: -// display.scrollright(0x00, 0x0F) -void Adafruit_SSD1306::startscrollleft(uint8_t start, uint8_t stop){ - ssd1306_command(SSD1306_LEFT_HORIZONTAL_SCROLL); - ssd1306_command(0X00); - ssd1306_command(start); - ssd1306_command(7); - ssd1306_command(stop); - ssd1306_command(0X00); - ssd1306_command(0XFF); - ssd1306_command(SSD1306_ACTIVATE_SCROLL); -} - -// startscrolldiagright -// Activate a diagonal scroll for rows start through stop -// Hint, the display is 16 rows tall. To scroll the whole display, run: -// display.scrollright(0x00, 0x0F) -void Adafruit_SSD1306::startscrolldiagright(uint8_t start, uint8_t stop){ - ssd1306_command(SSD1306_SET_VERTICAL_SCROLL_AREA); - ssd1306_command(0X00); - ssd1306_command(SSD1306_LCDHEIGHT); - ssd1306_command(SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL); - ssd1306_command(0X00); - ssd1306_command(start); - ssd1306_command(0X00); - ssd1306_command(stop); - ssd1306_command(0X01); - ssd1306_command(SSD1306_ACTIVATE_SCROLL); -} - -// startscrolldiagleft -// Activate a diagonal scroll for rows start through stop -// Hint, the display is 16 rows tall. To scroll the whole display, run: -// display.scrollright(0x00, 0x0F) -void Adafruit_SSD1306::startscrolldiagleft(uint8_t start, uint8_t stop){ - ssd1306_command(SSD1306_SET_VERTICAL_SCROLL_AREA); - ssd1306_command(0X00); - ssd1306_command(SSD1306_LCDHEIGHT); - ssd1306_command(SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL); - ssd1306_command(0X00); - ssd1306_command(start); - ssd1306_command(0X00); - ssd1306_command(stop); - ssd1306_command(0X01); - ssd1306_command(SSD1306_ACTIVATE_SCROLL); -} - -void Adafruit_SSD1306::stopscroll(void){ - ssd1306_command(SSD1306_DEACTIVATE_SCROLL); -} - -// Dim the display -// dim = true: display is dimmed -// dim = false: display is normal -void Adafruit_SSD1306::dim(boolean dim) { - uint8_t contrast; - - if (dim) { - contrast = 0; // Dimmed display - } else { - if (_vccstate == SSD1306_EXTERNALVCC) { - contrast = 0x9F; - } else { - contrast = 0xCF; - } - } - // the range of contrast to too small to be really useful - // it is useful to dim the display - ssd1306_command(SSD1306_SETCONTRAST); - ssd1306_command(contrast); -} - -void Adafruit_SSD1306::ssd1306_data(uint8_t c) { - if (sid != -1) - { - // SPI - //digitalWrite(cs, HIGH); - *csport |= cspinmask; - //digitalWrite(dc, HIGH); - *dcport |= dcpinmask; - //digitalWrite(cs, LOW); - *csport &= ~cspinmask; - fastSPIwrite(c); - //digitalWrite(cs, HIGH); - *csport |= cspinmask; - } - else - { - // I2C - uint8_t control = 0x40; // Co = 0, D/C = 1 - HWIRE.beginTransmission(_i2caddr); - WIRE_WRITE(control); - WIRE_WRITE(c); - HWIRE.endTransmission(); - } -} - -void Adafruit_SSD1306::display(void) { - ssd1306_command(SSD1306_COLUMNADDR); - ssd1306_command(0); // Column start address (0 = reset) - ssd1306_command(SSD1306_LCDWIDTH-1); // Column end address (127 = reset) - - ssd1306_command(SSD1306_PAGEADDR); - ssd1306_command(0); // Page start address (0 = reset) - #if SSD1306_LCDHEIGHT == 64 - ssd1306_command(7); // Page end address - #endif - #if SSD1306_LCDHEIGHT == 32 - ssd1306_command(3); // Page end address - #endif - #if SSD1306_LCDHEIGHT == 16 - ssd1306_command(1); // Page end address - #endif - - if (sid != -1) - { - // SPI - *csport |= cspinmask; - *dcport |= dcpinmask; - *csport &= ~cspinmask; - - for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) { - fastSPIwrite(buffer[i]); - //ssd1306_data(buffer[i]); - } - *csport |= cspinmask; - } - else - { - // save I2C bitrate - /* -#ifndef __SAM3X8E__ - uint8_t twbrbackup = TWBR; - TWBR = 12; // upgrade to 400KHz! -#endif -*/ - //Serial.println(TWBR, DEC); - //Serial.println(TWSR & 0x3, DEC); - - // I2C - for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) { - // send a bunch of data in one xmission - HWIRE.beginTransmission(_i2caddr); - WIRE_WRITE(0x40); - for (uint8_t x=0; x<16; x++) { - WIRE_WRITE(buffer[i]); - i++; - } - i--; - HWIRE.endTransmission(); - } -/* -#ifndef __SAM3X8E__ - TWBR = twbrbackup; -#endif - */ - } -} - -// clear everything -void Adafruit_SSD1306::clearDisplay(void) { - memset(buffer, 0, (SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8)); -} - - -inline void Adafruit_SSD1306::fastSPIwrite(uint8_t d) { - - if(hwSPI) { - (void)SPI.transfer(d); - } else { - for(uint8_t bit = 0x80; bit; bit >>= 1) { - *clkport &= ~clkpinmask; - if(d & bit) *mosiport |= mosipinmask; - else *mosiport &= ~mosipinmask; - *clkport |= clkpinmask; - } - } - //*csport |= cspinmask; -} - -void Adafruit_SSD1306::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) { - boolean bSwap = false; - switch(rotation) { - case 0: - // 0 degree rotation, do nothing - break; - case 1: - // 90 degree rotation, swap x & y for rotation, then invert x - bSwap = true; - swap(x, y); - x = WIDTH - x - 1; - break; - case 2: - // 180 degree rotation, invert x and y - then shift y around for height. - x = WIDTH - x - 1; - y = HEIGHT - y - 1; - x -= (w-1); - break; - case 3: - // 270 degree rotation, swap x & y for rotation, then invert y and adjust y for w (not to become h) - bSwap = true; - swap(x, y); - y = HEIGHT - y - 1; - y -= (w-1); - break; - } - - if(bSwap) { - drawFastVLineInternal(x, y, w, color); - } else { - drawFastHLineInternal(x, y, w, color); - } -} - -void Adafruit_SSD1306::drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) { - // Do bounds/limit checks - if(y < 0 || y >= HEIGHT) { return; } - - // make sure we don't try to draw below 0 - if(x < 0) { - w += x; - x = 0; - } - - // make sure we don't go off the edge of the display - if( (x + w) > WIDTH) { - w = (WIDTH - x); - } - - // if our width is now negative, punt - if(w <= 0) { return; } - - // set up the pointer for movement through the buffer - register uint8_t *pBuf = buffer; - // adjust the buffer pointer for the current row - pBuf += ((y/8) * SSD1306_LCDWIDTH); - // and offset x columns in - pBuf += x; - - register uint8_t mask = 1 << (y&7); - - switch (color) - { - case WHITE: while(w--) { *pBuf++ |= mask; }; break; - case BLACK: mask = ~mask; while(w--) { *pBuf++ &= mask; }; break; - case INVERSE: while(w--) { *pBuf++ ^= mask; }; break; - } -} - -void Adafruit_SSD1306::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) { - bool bSwap = false; - switch(rotation) { - case 0: - break; - case 1: - // 90 degree rotation, swap x & y for rotation, then invert x and adjust x for h (now to become w) - bSwap = true; - swap(x, y); - x = WIDTH - x - 1; - x -= (h-1); - break; - case 2: - // 180 degree rotation, invert x and y - then shift y around for height. - x = WIDTH - x - 1; - y = HEIGHT - y - 1; - y -= (h-1); - break; - case 3: - // 270 degree rotation, swap x & y for rotation, then invert y - bSwap = true; - swap(x, y); - y = HEIGHT - y - 1; - break; - } - - if(bSwap) { - drawFastHLineInternal(x, y, h, color); - } else { - drawFastVLineInternal(x, y, h, color); - } -} - - -void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y, int16_t __h, uint16_t color) { - - // do nothing if we're off the left or right side of the screen - if(x < 0 || x >= WIDTH) { return; } - - // make sure we don't try to draw below 0 - if(__y < 0) { - // __y is negative, this will subtract enough from __h to account for __y being 0 - __h += __y; - __y = 0; - - } - - // make sure we don't go past the height of the display - if( (__y + __h) > HEIGHT) { - __h = (HEIGHT - __y); - } - - // if our height is now negative, punt - if(__h <= 0) { - return; - } - - // this display doesn't need ints for coordinates, use local byte registers for faster juggling - register uint8_t y = __y; - register uint8_t h = __h; - - - // set up the pointer for fast movement through the buffer - register uint8_t *pBuf = buffer; - // adjust the buffer pointer for the current row - pBuf += ((y/8) * SSD1306_LCDWIDTH); - // and offset x columns in - pBuf += x; - - // do the first partial byte, if necessary - this requires some masking - register uint8_t mod = (y&7); - if(mod) { - // mask off the high n bits we want to set - mod = 8-mod; - - // note - lookup table results in a nearly 10% performance improvement in fill* functions - // register uint8_t mask = ~(0xFF >> (mod)); - static uint8_t premask[8] = {0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE }; - register uint8_t mask = premask[mod]; - - // adjust the mask if we're not going to reach the end of this byte - if( h < mod) { - mask &= (0XFF >> (mod-h)); - } - - switch (color) - { - case WHITE: *pBuf |= mask; break; - case BLACK: *pBuf &= ~mask; break; - case INVERSE: *pBuf ^= mask; break; - } - - // fast exit if we're done here! - if(h= 8) { - if (color == INVERSE) { // separate copy of the code so we don't impact performance of the black/white write version with an extra comparison per loop - do { - *pBuf=~(*pBuf); - - // adjust the buffer forward 8 rows worth of data - pBuf += SSD1306_LCDWIDTH; - - // adjust h & y (there's got to be a faster way for me to do this, but this should still help a fair bit for now) - h -= 8; - } while(h >= 8); - } - else { - // store a local value to work with - register uint8_t val = (color == WHITE) ? 255 : 0; - - do { - // write our value in - *pBuf = val; - - // adjust the buffer forward 8 rows worth of data - pBuf += SSD1306_LCDWIDTH; - - // adjust h & y (there's got to be a faster way for me to do this, but this should still help a fair bit for now) - h -= 8; - } while(h >= 8); - } - } - - // now do the final partial byte, if necessary - if(h) { - mod = h & 7; - // this time we want to mask the low bits of the byte, vs the high bits we did above - // register uint8_t mask = (1 << mod) - 1; - // note - lookup table results in a nearly 10% performance improvement in fill* functions - static uint8_t postmask[8] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F }; - register uint8_t mask = postmask[mod]; - switch (color) - { - case WHITE: *pBuf |= mask; break; - case BLACK: *pBuf &= ~mask; break; - case INVERSE: *pBuf ^= mask; break; - } - } -} diff --git a/GD32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.h b/GD32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.h deleted file mode 100644 index 0686d76..0000000 --- a/GD32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.h +++ /dev/null @@ -1,172 +0,0 @@ -/********************************************************************* -This is a library for our Monochrome OLEDs based on SSD1306 drivers - - Pick one up today in the adafruit shop! - ------> http://www.adafruit.com/category/63_98 - -These displays use SPI to communicate, 4 or 5 pins are required to -interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen must be included in any redistribution -*********************************************************************/ - -#if ARDUINO >= 100 - #include "Arduino.h" - #define WIRE_WRITE HWIRE.write -#else - #include "WProgram.h" - #define WIRE_WRITE HWIRE.send -#endif -/* -#ifdef __SAM3X8E__ - typedef volatile RwReg PortReg; - typedef uint32_t PortMask; -#else - typedef volatile uint8_t PortReg; - typedef uint8_t PortMask; -#endif -*/ -//typedef volatile RwReg PortReg; -// typedef uint32_t PortMask; -#include -#include - -#define BLACK 0 -#define WHITE 1 -#define INVERSE 2 - -#define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D -// Address for 128x32 is 0x3C -// Address for 128x64 is 0x3D (default) or 0x3C (if SA0 is grounded) - -/*========================================================================= - SSD1306 Displays - ----------------------------------------------------------------------- - The driver is used in multiple displays (128x64, 128x32, etc.). - Select the appropriate display below to create an appropriately - sized framebuffer, etc. - - SSD1306_128_64 128x64 pixel display - - SSD1306_128_32 128x32 pixel display - - SSD1306_96_16 - - -----------------------------------------------------------------------*/ - #define SSD1306_128_64 -// #define SSD1306_128_32 -// #define SSD1306_96_16 -/*=========================================================================*/ - -#if defined SSD1306_128_64 && defined SSD1306_128_32 - #error "Only one SSD1306 display can be specified at once in SSD1306.h" -#endif -#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16 - #error "At least one SSD1306 display must be specified in SSD1306.h" -#endif - -#if defined SSD1306_128_64 - #define SSD1306_LCDWIDTH 128 - #define SSD1306_LCDHEIGHT 64 -#endif -#if defined SSD1306_128_32 - #define SSD1306_LCDWIDTH 128 - #define SSD1306_LCDHEIGHT 32 -#endif -#if defined SSD1306_96_16 - #define SSD1306_LCDWIDTH 96 - #define SSD1306_LCDHEIGHT 16 -#endif - -#define SSD1306_SETCONTRAST 0x81 -#define SSD1306_DISPLAYALLON_RESUME 0xA4 -#define SSD1306_DISPLAYALLON 0xA5 -#define SSD1306_NORMALDISPLAY 0xA6 -#define SSD1306_INVERTDISPLAY 0xA7 -#define SSD1306_DISPLAYOFF 0xAE -#define SSD1306_DISPLAYON 0xAF - -#define SSD1306_SETDISPLAYOFFSET 0xD3 -#define SSD1306_SETCOMPINS 0xDA - -#define SSD1306_SETVCOMDETECT 0xDB - -#define SSD1306_SETDISPLAYCLOCKDIV 0xD5 -#define SSD1306_SETPRECHARGE 0xD9 - -#define SSD1306_SETMULTIPLEX 0xA8 - -#define SSD1306_SETLOWCOLUMN 0x00 -#define SSD1306_SETHIGHCOLUMN 0x10 - -#define SSD1306_SETSTARTLINE 0x40 - -#define SSD1306_MEMORYMODE 0x20 -#define SSD1306_COLUMNADDR 0x21 -#define SSD1306_PAGEADDR 0x22 - -#define SSD1306_COMSCANINC 0xC0 -#define SSD1306_COMSCANDEC 0xC8 - -#define SSD1306_SEGREMAP 0xA0 - -#define SSD1306_CHARGEPUMP 0x8D - -#define SSD1306_EXTERNALVCC 0x1 -#define SSD1306_SWITCHCAPVCC 0x2 - -// Scrolling #defines -#define SSD1306_ACTIVATE_SCROLL 0x2F -#define SSD1306_DEACTIVATE_SCROLL 0x2E -#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 -#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 -#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 -#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 -#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A - -class Adafruit_SSD1306 : public Adafruit_GFX { - public: - Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS); - Adafruit_SSD1306(int8_t DC, int8_t RST, int8_t CS); - Adafruit_SSD1306(int8_t RST); - - void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = SSD1306_I2C_ADDRESS, bool reset=true); - void ssd1306_command(uint8_t c); - void ssd1306_data(uint8_t c); - - void clearDisplay(void); - void invertDisplay(uint8_t i); - void display(); - - void startscrollright(uint8_t start, uint8_t stop); - void startscrollleft(uint8_t start, uint8_t stop); - - void startscrolldiagright(uint8_t start, uint8_t stop); - void startscrolldiagleft(uint8_t start, uint8_t stop); - void stopscroll(void); - - void dim(boolean dim); - - void drawPixel(int16_t x, int16_t y, uint16_t color); - - virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); - virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - - private: - int8_t _i2caddr, _vccstate, sid, sclk, dc, rst, cs; - void fastSPIwrite(uint8_t c); - - boolean hwSPI; -volatile uint32 *mosiport, *clkport, *csport, *dcport; - uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask; - - inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline)); - inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline)); - -}; diff --git a/GD32F1/libraries/Adafruit_SSD1306/README.txt b/GD32F1/libraries/Adafruit_SSD1306/README.txt deleted file mode 100644 index 420cc15..0000000 --- a/GD32F1/libraries/Adafruit_SSD1306/README.txt +++ /dev/null @@ -1,24 +0,0 @@ -This is a library for our Monochrome OLEDs based on SSD1306 drivers - - Pick one up today in the adafruit shop! - ------> http://www.adafruit.com/category/63_98 - -These displays use SPI to communicate, 4 or 5 pins are required to -interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -Scrolling code contributed by Michael Gregg -BSD license, check license.txt for more information -All text above must be included in any redistribution - -To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h - -Place the Adafruit_SSD1306 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. - -You will also have to download the Adafruit GFX Graphics core which does all the circles, text, rectangles, etc. You can get it from -https://github.com/adafruit/Adafruit-GFX-Library -and download/install that library as well \ No newline at end of file diff --git a/GD32F1/libraries/Adafruit_SSD1306/STM32 README.txt b/GD32F1/libraries/Adafruit_SSD1306/STM32 README.txt deleted file mode 100644 index 54705cf..0000000 --- a/GD32F1/libraries/Adafruit_SSD1306/STM32 README.txt +++ /dev/null @@ -1,6 +0,0 @@ -STM32 adaption by Matthias Diro, 25.03.2015 -Things to know: -This adaption uses hardware I2C (hardwire.h), Port: I2c2. SDA=0, SCL=1 on maple mini -To change it to Port I2C1: -//HardWire HWIRE(1,I2C_FAST_MODE); // I2c1 -HardWire HWIRE(2,I2C_FAST_MODE); // I2c2 \ No newline at end of file diff --git a/GD32F1/libraries/Adafruit_SSD1306/examples/ssd1306_128x32_i2c/ssd1306_128x32_i2c.ino b/GD32F1/libraries/Adafruit_SSD1306/examples/ssd1306_128x32_i2c/ssd1306_128x32_i2c.ino deleted file mode 100644 index e82ebc1..0000000 --- a/GD32F1/libraries/Adafruit_SSD1306/examples/ssd1306_128x32_i2c/ssd1306_128x32_i2c.ino +++ /dev/null @@ -1,357 +0,0 @@ -/********************************************************************* -This is an example for our Monochrome OLEDs based on SSD1306 drivers - - Pick one up today in the adafruit shop! - ------> http://www.adafruit.com/category/63_98 - -This example is for a 128x32 size display using I2C to communicate -3 pins are required to interface (2 I2C and one reset) - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen must be included in any redistribution -*********************************************************************/ - -#include -#include -#include -#include - -#define OLED_RESET 4 -Adafruit_SSD1306 display(OLED_RESET); - -#define NUMFLAKES 10 -#define XPOS 0 -#define YPOS 1 -#define DELTAY 2 - - -#define LOGO16_GLCD_HEIGHT 16 -#define LOGO16_GLCD_WIDTH 16 -static const unsigned char PROGMEM logo16_glcd_bmp[] = -{ B00000000, B11000000, - B00000001, B11000000, - B00000001, B11000000, - B00000011, B11100000, - B11110011, B11100000, - B11111110, B11111000, - B01111110, B11111111, - B00110011, B10011111, - B00011111, B11111100, - B00001101, B01110000, - B00011011, B10100000, - B00111111, B11100000, - B00111111, B11110000, - B01111100, B11110000, - B01110000, B01110000, - B00000000, B00110000 }; - -#if (SSD1306_LCDHEIGHT != 32) -#error("Height incorrect, please fix Adafruit_SSD1306.h!"); -#endif - -void setup() { - Serial.begin(9600); - - // by default, we'll generate the high voltage from the 3.3v line internally! (neat!) - display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32) - // init done - - // Show image buffer on the display hardware. - // Since the buffer is intialized with an Adafruit splashscreen - // internally, this will display the splashscreen. - display.display(); - delay(2000); - - // Clear the buffer. - display.clearDisplay(); - - // draw a single pixel - display.drawPixel(10, 10, WHITE); - // Show the display buffer on the hardware. - // NOTE: You _must_ call display after making any drawing commands - // to make them visible on the display hardware! - display.display(); - delay(2000); - display.clearDisplay(); - - // draw many lines - testdrawline(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw rectangles - testdrawrect(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw multiple rectangles - testfillrect(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw mulitple circles - testdrawcircle(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw a white circle, 10 pixel radius - display.fillCircle(display.width()/2, display.height()/2, 10, WHITE); - display.display(); - delay(2000); - display.clearDisplay(); - - testdrawroundrect(); - delay(2000); - display.clearDisplay(); - - testfillroundrect(); - delay(2000); - display.clearDisplay(); - - testdrawtriangle(); - delay(2000); - display.clearDisplay(); - - testfilltriangle(); - delay(2000); - display.clearDisplay(); - - // draw the first ~12 characters in the font - testdrawchar(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw scrolling text - testscrolltext(); - delay(2000); - display.clearDisplay(); - - // text display tests - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println("Hello, world!"); - display.setTextColor(BLACK, WHITE); // 'inverted' text - display.println(3.141592); - display.setTextSize(2); - display.setTextColor(WHITE); - display.print("0x"); display.println(0xDEADBEEF, HEX); - display.display(); - delay(2000); - - // miniature bitmap display - display.clearDisplay(); - display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1); - display.display(); - - // invert the display - display.invertDisplay(true); - delay(1000); - display.invertDisplay(false); - delay(1000); - - // draw a bitmap icon and 'animate' movement - testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH); -} - - -void loop() { - -} - - -void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) { - uint8_t icons[NUMFLAKES][3]; - - // initialize - for (uint8_t f=0; f< NUMFLAKES; f++) { - icons[f][XPOS] = random(display.width()); - icons[f][YPOS] = 0; - icons[f][DELTAY] = random(5) + 1; - - Serial.print("x: "); - Serial.print(icons[f][XPOS], DEC); - Serial.print(" y: "); - Serial.print(icons[f][YPOS], DEC); - Serial.print(" dy: "); - Serial.println(icons[f][DELTAY], DEC); - } - - while (1) { - // draw each icon - for (uint8_t f=0; f< NUMFLAKES; f++) { - display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE); - } - display.display(); - delay(200); - - // then erase it + move it - for (uint8_t f=0; f< NUMFLAKES; f++) { - display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK); - // move it - icons[f][YPOS] += icons[f][DELTAY]; - // if its gone, reinit - if (icons[f][YPOS] > display.height()) { - icons[f][XPOS] = random(display.width()); - icons[f][YPOS] = 0; - icons[f][DELTAY] = random(5) + 1; - } - } - } -} - - -void testdrawchar(void) { - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - - for (uint8_t i=0; i < 168; i++) { - if (i == '\n') continue; - display.write(i); - if ((i > 0) && (i % 21 == 0)) - display.println(); - } - display.display(); -} - -void testdrawcircle(void) { - for (int16_t i=0; i0; i-=5) { - display.fillTriangle(display.width()/2, display.height()/2-i, - display.width()/2-i, display.height()/2+i, - display.width()/2+i, display.height()/2+i, WHITE); - if (color == WHITE) color = BLACK; - else color = WHITE; - display.display(); - } -} - -void testdrawroundrect(void) { - for (int16_t i=0; i=0; i-=4) { - display.drawLine(0, display.height()-1, display.width()-1, i, WHITE); - display.display(); - } - delay(250); - - display.clearDisplay(); - for (int16_t i=display.width()-1; i>=0; i-=4) { - display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE); - display.display(); - } - for (int16_t i=display.height()-1; i>=0; i-=4) { - display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE); - display.display(); - } - delay(250); - - display.clearDisplay(); - for (int16_t i=0; i http://www.adafruit.com/category/63_98 - -This example is for a 128x32 size display using SPI to communicate -4 or 5 pins are required to interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen must be included in any redistribution -*********************************************************************/ - -#include -#include -#include -#include - -// If using software SPI (the default case): -#define OLED_MOSI 9 -#define OLED_CLK 10 -#define OLED_DC 11 -#define OLED_CS 12 -#define OLED_RESET 13 -Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); - -/* Uncomment this block to use hardware SPI -#define OLED_DC 6 -#define OLED_CS 7 -#define OLED_RESET 8 -Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS); -*/ - -#define NUMFLAKES 10 -#define XPOS 0 -#define YPOS 1 -#define DELTAY 2 - -#define LOGO16_GLCD_HEIGHT 16 -#define LOGO16_GLCD_WIDTH 16 -static const unsigned char PROGMEM logo16_glcd_bmp[] = -{ B00000000, B11000000, - B00000001, B11000000, - B00000001, B11000000, - B00000011, B11100000, - B11110011, B11100000, - B11111110, B11111000, - B01111110, B11111111, - B00110011, B10011111, - B00011111, B11111100, - B00001101, B01110000, - B00011011, B10100000, - B00111111, B11100000, - B00111111, B11110000, - B01111100, B11110000, - B01110000, B01110000, - B00000000, B00110000 }; - -#if (SSD1306_LCDHEIGHT != 32) -#error("Height incorrect, please fix Adafruit_SSD1306.h!"); -#endif - -void setup() { - Serial.begin(9600); - - // by default, we'll generate the high voltage from the 3.3v line internally! (neat!) - display.begin(SSD1306_SWITCHCAPVCC); - // init done - - // Show image buffer on the display hardware. - // Since the buffer is intialized with an Adafruit splashscreen - // internally, this will display the splashscreen. - display.display(); - delay(2000); - - // Clear the buffer. - display.clearDisplay(); - - // draw a single pixel - display.drawPixel(10, 10, WHITE); - // Show the display buffer on the hardware. - // NOTE: You _must_ call display after making any drawing commands - // to make them visible on the display hardware! - display.display(); - delay(2000); - display.clearDisplay(); - - // draw many lines - testdrawline(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw rectangles - testdrawrect(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw multiple rectangles - testfillrect(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw mulitple circles - testdrawcircle(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw a white circle, 10 pixel radius - display.fillCircle(display.width()/2, display.height()/2, 10, WHITE); - display.display(); - delay(2000); - display.clearDisplay(); - - testdrawroundrect(); - delay(2000); - display.clearDisplay(); - - testfillroundrect(); - delay(2000); - display.clearDisplay(); - - testdrawtriangle(); - delay(2000); - display.clearDisplay(); - - testfilltriangle(); - delay(2000); - display.clearDisplay(); - - // draw the first ~12 characters in the font - testdrawchar(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw scrolling text - testscrolltext(); - delay(2000); - display.clearDisplay(); - - // text display tests - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println("Hello, world!"); - display.setTextColor(BLACK, WHITE); // 'inverted' text - display.println(3.141592); - display.setTextSize(2); - display.setTextColor(WHITE); - display.print("0x"); display.println(0xDEADBEEF, HEX); - display.display(); - delay(2000); - - // miniature bitmap display - display.clearDisplay(); - display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1); - display.display(); - - // invert the display - display.invertDisplay(true); - delay(1000); - display.invertDisplay(false); - delay(1000); - - // draw a bitmap icon and 'animate' movement - testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH); -} - - -void loop() { - -} - - -void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) { - uint8_t icons[NUMFLAKES][3]; - - // initialize - for (uint8_t f=0; f< NUMFLAKES; f++) { - icons[f][XPOS] = random(display.width()); - icons[f][YPOS] = 0; - icons[f][DELTAY] = random(5) + 1; - - Serial.print("x: "); - Serial.print(icons[f][XPOS], DEC); - Serial.print(" y: "); - Serial.print(icons[f][YPOS], DEC); - Serial.print(" dy: "); - Serial.println(icons[f][DELTAY], DEC); - } - - while (1) { - // draw each icon - for (uint8_t f=0; f< NUMFLAKES; f++) { - display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE); - } - display.display(); - delay(200); - - // then erase it + move it - for (uint8_t f=0; f< NUMFLAKES; f++) { - display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK); - // move it - icons[f][YPOS] += icons[f][DELTAY]; - // if its gone, reinit - if (icons[f][YPOS] > display.height()) { - icons[f][XPOS] = random(display.width()); - icons[f][YPOS] = 0; - icons[f][DELTAY] = random(5) + 1; - } - } - } -} - - -void testdrawchar(void) { - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - - for (uint8_t i=0; i < 168; i++) { - if (i == '\n') continue; - display.write(i); - if ((i > 0) && (i % 21 == 0)) - display.println(); - } - display.display(); -} - -void testdrawcircle(void) { - for (int16_t i=0; i0; i-=5) { - display.fillTriangle(display.width()/2, display.height()/2-i, - display.width()/2-i, display.height()/2+i, - display.width()/2+i, display.height()/2+i, WHITE); - if (color == WHITE) color = BLACK; - else color = WHITE; - display.display(); - } -} - -void testdrawroundrect(void) { - for (int16_t i=0; i=0; i-=4) { - display.drawLine(0, display.height()-1, display.width()-1, i, WHITE); - display.display(); - } - delay(250); - - display.clearDisplay(); - for (int16_t i=display.width()-1; i>=0; i-=4) { - display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE); - display.display(); - } - for (int16_t i=display.height()-1; i>=0; i-=4) { - display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE); - display.display(); - } - delay(250); - - display.clearDisplay(); - for (int16_t i=0; i http://www.adafruit.com/category/63_98 - -This example is for a 128x64 size display using I2C to communicate -3 pins are required to interface (2 I2C and one reset) - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen must be included in any redistribution -*********************************************************************/ - -#include -#include -#include -#include - -#define OLED_RESET 4 -Adafruit_SSD1306 display(OLED_RESET); - -#define NUMFLAKES 10 -#define XPOS 0 -#define YPOS 1 -#define DELTAY 2 - - -#define LOGO16_GLCD_HEIGHT 16 -#define LOGO16_GLCD_WIDTH 16 -static const unsigned char PROGMEM logo16_glcd_bmp[] = -{ B00000000, B11000000, - B00000001, B11000000, - B00000001, B11000000, - B00000011, B11100000, - B11110011, B11100000, - B11111110, B11111000, - B01111110, B11111111, - B00110011, B10011111, - B00011111, B11111100, - B00001101, B01110000, - B00011011, B10100000, - B00111111, B11100000, - B00111111, B11110000, - B01111100, B11110000, - B01110000, B01110000, - B00000000, B00110000 }; - -#if (SSD1306_LCDHEIGHT != 64) -#error("Height incorrect, please fix Adafruit_SSD1306.h!"); -#endif - -void setup() { - Serial.begin(9600); - - // by default, we'll generate the high voltage from the 3.3v line internally! (neat!) - display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) - // init done - - // Show image buffer on the display hardware. - // Since the buffer is intialized with an Adafruit splashscreen - // internally, this will display the splashscreen. - display.display(); - delay(2000); - - // Clear the buffer. - display.clearDisplay(); - - // draw a single pixel - display.drawPixel(10, 10, WHITE); - // Show the display buffer on the hardware. - // NOTE: You _must_ call display after making any drawing commands - // to make them visible on the display hardware! - display.display(); - delay(2000); - display.clearDisplay(); - - // draw many lines - testdrawline(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw rectangles - testdrawrect(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw multiple rectangles - testfillrect(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw mulitple circles - testdrawcircle(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw a white circle, 10 pixel radius - display.fillCircle(display.width()/2, display.height()/2, 10, WHITE); - display.display(); - delay(2000); - display.clearDisplay(); - - testdrawroundrect(); - delay(2000); - display.clearDisplay(); - - testfillroundrect(); - delay(2000); - display.clearDisplay(); - - testdrawtriangle(); - delay(2000); - display.clearDisplay(); - - testfilltriangle(); - delay(2000); - display.clearDisplay(); - - // draw the first ~12 characters in the font - testdrawchar(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw scrolling text - testscrolltext(); - delay(2000); - display.clearDisplay(); - - // text display tests - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println("Hello, world!"); - display.setTextColor(BLACK, WHITE); // 'inverted' text - display.println(3.141592); - display.setTextSize(2); - display.setTextColor(WHITE); - display.print("0x"); display.println(0xDEADBEEF, HEX); - display.display(); - delay(2000); - - // miniature bitmap display - display.clearDisplay(); - display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1); - display.display(); - - // invert the display - display.invertDisplay(true); - delay(1000); - display.invertDisplay(false); - delay(1000); - - // draw a bitmap icon and 'animate' movement - testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH); -} - - -void loop() { - -} - - -void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) { - uint8_t icons[NUMFLAKES][3]; - - // initialize - for (uint8_t f=0; f< NUMFLAKES; f++) { - icons[f][XPOS] = random(display.width()); - icons[f][YPOS] = 0; - icons[f][DELTAY] = random(5) + 1; - - Serial.print("x: "); - Serial.print(icons[f][XPOS], DEC); - Serial.print(" y: "); - Serial.print(icons[f][YPOS], DEC); - Serial.print(" dy: "); - Serial.println(icons[f][DELTAY], DEC); - } - - while (1) { - // draw each icon - for (uint8_t f=0; f< NUMFLAKES; f++) { - display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE); - } - display.display(); - delay(200); - - // then erase it + move it - for (uint8_t f=0; f< NUMFLAKES; f++) { - display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK); - // move it - icons[f][YPOS] += icons[f][DELTAY]; - // if its gone, reinit - if (icons[f][YPOS] > display.height()) { - icons[f][XPOS] = random(display.width()); - icons[f][YPOS] = 0; - icons[f][DELTAY] = random(5) + 1; - } - } - } -} - - -void testdrawchar(void) { - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - - for (uint8_t i=0; i < 168; i++) { - if (i == '\n') continue; - display.write(i); - if ((i > 0) && (i % 21 == 0)) - display.println(); - } - display.display(); -} - -void testdrawcircle(void) { - for (int16_t i=0; i0; i-=5) { - display.fillTriangle(display.width()/2, display.height()/2-i, - display.width()/2-i, display.height()/2+i, - display.width()/2+i, display.height()/2+i, WHITE); - if (color == WHITE) color = BLACK; - else color = WHITE; - display.display(); - } -} - -void testdrawroundrect(void) { - for (int16_t i=0; i=0; i-=4) { - display.drawLine(0, display.height()-1, display.width()-1, i, WHITE); - display.display(); - } - delay(250); - - display.clearDisplay(); - for (int16_t i=display.width()-1; i>=0; i-=4) { - display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE); - display.display(); - } - for (int16_t i=display.height()-1; i>=0; i-=4) { - display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE); - display.display(); - } - delay(250); - - display.clearDisplay(); - for (int16_t i=0; i http://www.adafruit.com/category/63_98 - -This example is for a 128x64 size display using SPI to communicate -4 or 5 pins are required to interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen must be included in any redistribution -*********************************************************************/ - -#include -#include -#include -#include - -// If using software SPI (the default case): -#define OLED_MOSI 9 -#define OLED_CLK 10 -#define OLED_DC 11 -#define OLED_CS 12 -#define OLED_RESET 13 -Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); - -/* Uncomment this block to use hardware SPI -#define OLED_DC 6 -#define OLED_CS 7 -#define OLED_RESET 8 -Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS); -*/ - -#define NUMFLAKES 10 -#define XPOS 0 -#define YPOS 1 -#define DELTAY 2 - -#define LOGO16_GLCD_HEIGHT 16 -#define LOGO16_GLCD_WIDTH 16 -static const unsigned char PROGMEM logo16_glcd_bmp[] = -{ B00000000, B11000000, - B00000001, B11000000, - B00000001, B11000000, - B00000011, B11100000, - B11110011, B11100000, - B11111110, B11111000, - B01111110, B11111111, - B00110011, B10011111, - B00011111, B11111100, - B00001101, B01110000, - B00011011, B10100000, - B00111111, B11100000, - B00111111, B11110000, - B01111100, B11110000, - B01110000, B01110000, - B00000000, B00110000 }; - -#if (SSD1306_LCDHEIGHT != 64) -#error("Height incorrect, please fix Adafruit_SSD1306.h!"); -#endif - -void setup() { - Serial.begin(9600); - - // by default, we'll generate the high voltage from the 3.3v line internally! (neat!) - display.begin(SSD1306_SWITCHCAPVCC); - // init done - - // Show image buffer on the display hardware. - // Since the buffer is intialized with an Adafruit splashscreen - // internally, this will display the splashscreen. - display.display(); - delay(2000); - - // Clear the buffer. - display.clearDisplay(); - - // draw a single pixel - display.drawPixel(10, 10, WHITE); - // Show the display buffer on the hardware. - // NOTE: You _must_ call display after making any drawing commands - // to make them visible on the display hardware! - display.display(); - delay(2000); - display.clearDisplay(); - - // draw many lines - testdrawline(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw rectangles - testdrawrect(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw multiple rectangles - testfillrect(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw mulitple circles - testdrawcircle(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw a white circle, 10 pixel radius - display.fillCircle(display.width()/2, display.height()/2, 10, WHITE); - display.display(); - delay(2000); - display.clearDisplay(); - - testdrawroundrect(); - delay(2000); - display.clearDisplay(); - - testfillroundrect(); - delay(2000); - display.clearDisplay(); - - testdrawtriangle(); - delay(2000); - display.clearDisplay(); - - testfilltriangle(); - delay(2000); - display.clearDisplay(); - - // draw the first ~12 characters in the font - testdrawchar(); - display.display(); - delay(2000); - display.clearDisplay(); - - // draw scrolling text - testscrolltext(); - delay(2000); - display.clearDisplay(); - - // text display tests - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println("Hello, world!"); - display.setTextColor(BLACK, WHITE); // 'inverted' text - display.println(3.141592); - display.setTextSize(2); - display.setTextColor(WHITE); - display.print("0x"); display.println(0xDEADBEEF, HEX); - display.display(); - delay(2000); - - // miniature bitmap display - display.clearDisplay(); - display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1); - display.display(); - - // invert the display - display.invertDisplay(true); - delay(1000); - display.invertDisplay(false); - delay(1000); - - // draw a bitmap icon and 'animate' movement - testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH); -} - - -void loop() { - -} - - -void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) { - uint8_t icons[NUMFLAKES][3]; - - // initialize - for (uint8_t f=0; f< NUMFLAKES; f++) { - icons[f][XPOS] = random(display.width()); - icons[f][YPOS] = 0; - icons[f][DELTAY] = random(5) + 1; - - Serial.print("x: "); - Serial.print(icons[f][XPOS], DEC); - Serial.print(" y: "); - Serial.print(icons[f][YPOS], DEC); - Serial.print(" dy: "); - Serial.println(icons[f][DELTAY], DEC); - } - - while (1) { - // draw each icon - for (uint8_t f=0; f< NUMFLAKES; f++) { - display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE); - } - display.display(); - delay(200); - - // then erase it + move it - for (uint8_t f=0; f< NUMFLAKES; f++) { - display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK); - // move it - icons[f][YPOS] += icons[f][DELTAY]; - // if its gone, reinit - if (icons[f][YPOS] > display.height()) { - icons[f][XPOS] = random(display.width()); - icons[f][YPOS] = 0; - icons[f][DELTAY] = random(5) + 1; - } - } - } -} - - -void testdrawchar(void) { - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - - for (uint8_t i=0; i < 168; i++) { - if (i == '\n') continue; - display.write(i); - if ((i > 0) && (i % 21 == 0)) - display.println(); - } - display.display(); -} - -void testdrawcircle(void) { - for (int16_t i=0; i0; i-=5) { - display.fillTriangle(display.width()/2, display.height()/2-i, - display.width()/2-i, display.height()/2+i, - display.width()/2+i, display.height()/2+i, WHITE); - if (color == WHITE) color = BLACK; - else color = WHITE; - display.display(); - } -} - -void testdrawroundrect(void) { - for (int16_t i=0; i=0; i-=4) { - display.drawLine(0, display.height()-1, display.width()-1, i, WHITE); - display.display(); - } - delay(250); - - display.clearDisplay(); - for (int16_t i=display.width()-1; i>=0; i-=4) { - display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE); - display.display(); - } - for (int16_t i=display.height()-1; i>=0; i-=4) { - display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE); - display.display(); - } - delay(250); - - display.clearDisplay(); - for (int16_t i=0; i= newEnd) - return EEPROM_OUT_SIZE; - - oldEnd = oldPage + 4; - oldIdx = oldPage + (uint32)(PageSize - 2); - - for (; oldIdx > oldEnd; oldIdx -= 4) - { - address = *(__io uint16*)oldIdx; - if (address == 0xFFFF || address == SkipAddress) - continue; // it's means that power off after write data - - found = 0; - for (idx = newPage + 6; idx < newIdx; idx += 4) - if ((*(__io uint16*)(idx)) == address) - { - found = 1; - break; - } - - if (found) - continue; - - if (newIdx < newEnd) - { - data = (*(__io uint16*)(oldIdx - 2)); - - FlashStatus = FLASH_ProgramHalfWord(newIdx, data); - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - - FlashStatus = FLASH_ProgramHalfWord(newIdx + 2, address); - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - - newIdx += 4; - } - else - return EEPROM_OUT_SIZE; - } - - // Erase the old Page: Set old Page status to EEPROM_EEPROM_ERASED status - data = EE_CheckErasePage(oldPage, EEPROM_ERASED); - if (data != EEPROM_OK) - return data; - - // Set new Page status - FlashStatus = FLASH_ProgramHalfWord(newPage, EEPROM_VALID_PAGE); - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - - return EEPROM_OK; -} - -/** - * @brief Verify if active page is full and Writes variable in EEPROM. - * @param Address: 16 bit virtual address of the variable - * @param Data: 16 bit data to be written as variable value - * @retval Success or error status: - * - FLASH_COMPLETE: on success - * - EEPROM_PAGE_FULL: if valid page is full (need page transfer) - * - EEPROM_NO_VALID_PAGE: if no valid page was found - * - EEPROM_OUT_SIZE: if EEPROM size exceeded - * - Flash error code: on write Flash error - */ -uint16 EEPROMClass::EE_VerifyPageFullWriteVariable(uint16 Address, uint16 Data) -{ - FLASH_Status FlashStatus; - uint32 idx, pageBase, pageEnd, newPage; - uint16 count; - - // Get valid Page for write operation - pageBase = EE_FindValidPage(); - if (pageBase == 0) - return EEPROM_NO_VALID_PAGE; - - // Get the valid Page end Address - pageEnd = pageBase + PageSize; // Set end of page - - for (idx = pageEnd - 2; idx > pageBase; idx -= 4) - { - if ((*(__io uint16*)idx) == Address) // Find last value for address - { - count = (*(__io uint16*)(idx - 2)); // Read last data - if (count == Data) - return EEPROM_OK; - if (count == 0xFFFF) - { - FlashStatus = FLASH_ProgramHalfWord(idx - 2, Data); // Set variable data - if (FlashStatus == FLASH_COMPLETE) - return EEPROM_OK; - } - break; - } - } - - // Check each active page address starting from begining - for (idx = pageBase + 4; idx < pageEnd; idx += 4) - if ((*(__io uint32*)idx) == 0xFFFFFFFF) // Verify if element - { // contents are 0xFFFFFFFF - FlashStatus = FLASH_ProgramHalfWord(idx, Data); // Set variable data - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - FlashStatus = FLASH_ProgramHalfWord(idx + 2, Address); // Set variable virtual address - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - return EEPROM_OK; - } - - // Empty slot not found, need page transfer - // Calculate unique variables in page - count = EE_GetVariablesCount(pageBase, Address) + 1; - if (count >= (PageSize / 4 - 1)) - return EEPROM_OUT_SIZE; - - if (pageBase == PageBase1) - newPage = PageBase0; // New page address where variable will be moved to - else - newPage = PageBase1; - - // Set the new Page status to RECEIVE_DATA status - FlashStatus = FLASH_ProgramHalfWord(newPage, EEPROM_RECEIVE_DATA); - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - - // Write the variable passed as parameter in the new active page - FlashStatus = FLASH_ProgramHalfWord(newPage + 4, Data); - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - - FlashStatus = FLASH_ProgramHalfWord(newPage + 6, Address); - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - - return EE_PageTransfer(newPage, pageBase, Address); -} - -EEPROMClass::EEPROMClass(void) -{ - PageBase0 = EEPROM_PAGE0_BASE; - PageBase1 = EEPROM_PAGE1_BASE; - PageSize = EEPROM_PAGE_SIZE; - Status = EEPROM_NOT_INIT; -} - -uint16 EEPROMClass::init(uint32 pageBase0, uint32 pageBase1, uint32 pageSize) -{ - PageBase0 = pageBase0; - PageBase1 = pageBase1; - PageSize = pageSize; - return init(); -} - -uint16 EEPROMClass::init(void) -{ - uint16 status0, status1; - FLASH_Status FlashStatus; - - FLASH_Unlock(); - Status = EEPROM_NO_VALID_PAGE; - - status0 = (*(__io uint16 *)PageBase0); - status1 = (*(__io uint16 *)PageBase1); - - switch (status0) - { -/* - Page0 Page1 - ----- ----- - EEPROM_ERASED EEPROM_VALID_PAGE Page1 valid, Page0 erased - EEPROM_RECEIVE_DATA Page1 need set to valid, Page0 erased - EEPROM_ERASED make EE_Format - any Error: EEPROM_NO_VALID_PAGE -*/ - case EEPROM_ERASED: - if (status1 == EEPROM_VALID_PAGE) // Page0 erased, Page1 valid - Status = EE_CheckErasePage(PageBase0, EEPROM_ERASED); - else if (status1 == EEPROM_RECEIVE_DATA) // Page0 erased, Page1 receive - { - FlashStatus = FLASH_ProgramHalfWord(PageBase1, EEPROM_VALID_PAGE); - if (FlashStatus != FLASH_COMPLETE) - Status = FlashStatus; - else - Status = EE_CheckErasePage(PageBase0, EEPROM_ERASED); - } - else if (status1 == EEPROM_ERASED) // Both in erased state so format EEPROM - Status = format(); - break; -/* - Page0 Page1 - ----- ----- - EEPROM_RECEIVE_DATA EEPROM_VALID_PAGE Transfer Page1 to Page0 - EEPROM_ERASED Page0 need set to valid, Page1 erased - any EEPROM_NO_VALID_PAGE -*/ - case EEPROM_RECEIVE_DATA: - if (status1 == EEPROM_VALID_PAGE) // Page0 receive, Page1 valid - Status = EE_PageTransfer(PageBase0, PageBase1, 0xFFFF); - else if (status1 == EEPROM_ERASED) // Page0 receive, Page1 erased - { - Status = EE_CheckErasePage(PageBase1, EEPROM_ERASED); - if (Status == EEPROM_OK) - { - FlashStatus = FLASH_ProgramHalfWord(PageBase0, EEPROM_VALID_PAGE); - if (FlashStatus != FLASH_COMPLETE) - Status = FlashStatus; - else - Status = EEPROM_OK; - } - } - break; -/* - Page0 Page1 - ----- ----- - EEPROM_VALID_PAGE EEPROM_VALID_PAGE Error: EEPROM_NO_VALID_PAGE - EEPROM_RECEIVE_DATA Transfer Page0 to Page1 - any Page0 valid, Page1 erased -*/ - case EEPROM_VALID_PAGE: - if (status1 == EEPROM_VALID_PAGE) // Both pages valid - Status = EEPROM_NO_VALID_PAGE; - else if (status1 == EEPROM_RECEIVE_DATA) - Status = EE_PageTransfer(PageBase1, PageBase0, 0xFFFF); - else - Status = EE_CheckErasePage(PageBase1, EEPROM_ERASED); - break; -/* - Page0 Page1 - ----- ----- - any EEPROM_VALID_PAGE Page1 valid, Page0 erased - EEPROM_RECEIVE_DATA Page1 valid, Page0 erased - any EEPROM_NO_VALID_PAGE -*/ - default: - if (status1 == EEPROM_VALID_PAGE) - Status = EE_CheckErasePage(PageBase0, EEPROM_ERASED); // Check/Erase Page0 - else if (status1 == EEPROM_RECEIVE_DATA) - { - FlashStatus = FLASH_ProgramHalfWord(PageBase1, EEPROM_VALID_PAGE); - if (FlashStatus != FLASH_COMPLETE) - Status = FlashStatus; - else - Status = EE_CheckErasePage(PageBase0, EEPROM_ERASED); - } - break; - } - return Status; -} - -/** - * @brief Erases PAGE0 and PAGE1 and writes EEPROM_VALID_PAGE / 0 header to PAGE0 - * @param PAGE0 and PAGE1 base addresses - * @retval Status of the last operation (Flash write or erase) done during EEPROM formating - */ -uint16 EEPROMClass::format(void) -{ - uint16 status; - FLASH_Status FlashStatus; - - FLASH_Unlock(); - - // Erase Page0 - status = EE_CheckErasePage(PageBase0, EEPROM_VALID_PAGE); - if (status != EEPROM_OK) - return status; - if ((*(__io uint16*)PageBase0) == EEPROM_ERASED) - { - // Set Page0 as valid page: Write VALID_PAGE at Page0 base address - FlashStatus = FLASH_ProgramHalfWord(PageBase0, EEPROM_VALID_PAGE); - if (FlashStatus != FLASH_COMPLETE) - return FlashStatus; - } - // Erase Page1 - return EE_CheckErasePage(PageBase1, EEPROM_ERASED); -} - -/** - * @brief Returns the erase counter for current page - * @param Data: Global variable contains the read variable value - * @retval Success or error status: - * - EEPROM_OK: if erases counter return. - * - EEPROM_NO_VALID_PAGE: if no valid page was found. - */ -uint16 EEPROMClass::erases(uint16 *Erases) -{ - uint32 pageBase; - if (Status != EEPROM_OK) - if (init() != EEPROM_OK) - return Status; - - // Get active Page for read operation - pageBase = EE_FindValidPage(); - if (pageBase == 0) - return EEPROM_NO_VALID_PAGE; - - *Erases = (*(__io uint16*)pageBase+2); - return EEPROM_OK; -} - -/** - * @brief Returns the last stored variable data, if found, - * which correspond to the passed virtual address - * @param Address: Variable virtual address - * @retval Data for variable or EEPROM_DEFAULT_DATA, if any errors - */ -uint16 EEPROMClass::read (uint16 Address) -{ - uint16 data; - read(Address, &data); - return data; -} - -/** - * @brief Returns the last stored variable data, if found, - * which correspond to the passed virtual address - * @param Address: Variable virtual address - * @param Data: Pointer to data variable - * @retval Success or error status: - * - EEPROM_OK: if variable was found - * - EEPROM_BAD_ADDRESS: if the variable was not found - * - EEPROM_NO_VALID_PAGE: if no valid page was found. - */ -uint16 EEPROMClass::read(uint16 Address, uint16 *Data) -{ - uint32 pageBase, pageEnd; - - // Set default data (empty EEPROM) - *Data = EEPROM_DEFAULT_DATA; - - if (Status == EEPROM_NOT_INIT) - if (init() != EEPROM_OK) - return Status; - - // Get active Page for read operation - pageBase = EE_FindValidPage(); - if (pageBase == 0) - return EEPROM_NO_VALID_PAGE; - - // Get the valid Page end Address - pageEnd = pageBase + ((uint32)(PageSize - 2)); - - // Check each active page address starting from end - for (pageBase += 6; pageEnd >= pageBase; pageEnd -= 4) - if ((*(__io uint16*)pageEnd) == Address) // Compare the read address with the virtual address - { - *Data = (*(__io uint16*)(pageEnd - 2)); // Get content of Address-2 which is variable value - return EEPROM_OK; - } - - // Return ReadStatus value: (0: variable exist, 1: variable doesn't exist) - return EEPROM_BAD_ADDRESS; -} - -/** - * @brief Writes/upadtes variable data in EEPROM. - * @param VirtAddress: Variable virtual address - * @param Data: 16 bit data to be written - * @retval Success or error status: - * - FLASH_COMPLETE: on success - * - EEPROM_BAD_ADDRESS: if address = 0xFFFF - * - EEPROM_PAGE_FULL: if valid page is full - * - EEPROM_NO_VALID_PAGE: if no valid page was found - * - EEPROM_OUT_SIZE: if no empty EEPROM variables - * - Flash error code: on write Flash error - */ -uint16 EEPROMClass::write(uint16 Address, uint16 Data) -{ - if (Status == EEPROM_NOT_INIT) - if (init() != EEPROM_OK) - return Status; - - if (Address == 0xFFFF) - return EEPROM_BAD_ADDRESS; - - // Write the variable virtual address and value in the EEPROM - uint16 status = EE_VerifyPageFullWriteVariable(Address, Data); - return status; -} - -/** - * @brief Return number of variable - * @retval Number of variables - */ -uint16 EEPROMClass::count(uint16 *Count) -{ - if (Status == EEPROM_NOT_INIT) - if (init() != EEPROM_OK) - return Status; - - // Get valid Page for write operation - uint32 pageBase = EE_FindValidPage(); - if (pageBase == 0) - return EEPROM_NO_VALID_PAGE; // No valid page, return max. numbers - - *Count = EE_GetVariablesCount(pageBase, 0xFFFF); - return EEPROM_OK; -} - -uint16 EEPROMClass::maxcount(void) -{ - return ((PageSize / 4)-1); -} - -EEPROMClass EEPROM; diff --git a/GD32F1/libraries/EEPROM/EEPROM.h b/GD32F1/libraries/EEPROM/EEPROM.h deleted file mode 100644 index 8a8320b..0000000 --- a/GD32F1/libraries/EEPROM/EEPROM.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef __EEPROM_H -#define __EEPROM_H - -#include -#include "flash_stm32.h" - -// HACK ALERT. This definition may not match your processor -// To Do. Work out correct value for EEPROM_PAGE_SIZE on the STM32F103CT6 etc -#define MCU_STM32F103RB - -#ifndef EEPROM_PAGE_SIZE - #if defined (MCU_STM32F103RB) - #define EEPROM_PAGE_SIZE (uint16)0x400 /* Page size = 1KByte */ - #elif defined (MCU_STM32F103ZE) || defined (MCU_STM32F103RE) || defined (MCU_STM32F103RD) - #define EEPROM_PAGE_SIZE (uint16)0x800 /* Page size = 2KByte */ - #else - #error "No MCU type specified. Add something like -DMCU_STM32F103RB to your compiler arguments (probably in a Makefile)." - #endif -#endif - -#ifndef EEPROM_START_ADDRESS - #if defined (MCU_STM32F103RB) - #define EEPROM_START_ADDRESS ((uint32)(0x8000000 + 128 * 1024 - 2 * EEPROM_PAGE_SIZE)) - #elif defined (MCU_STM32F103ZE) || defined (MCU_STM32F103RE) - #define EEPROM_START_ADDRESS ((uint32)(0x8000000 + 512 * 1024 - 2 * EEPROM_PAGE_SIZE)) - #elif defined (MCU_STM32F103RD) - #define EEPROM_START_ADDRESS ((uint32)(0x8000000 + 384 * 1024 - 2 * EEPROM_PAGE_SIZE)) - #else - #error "No MCU type specified. Add something like -DMCU_STM32F103RB to your compiler arguments (probably in a Makefile)." - #endif -#endif - -/* Pages 0 and 1 base and end addresses */ -#define EEPROM_PAGE0_BASE ((uint32)(EEPROM_START_ADDRESS + 0x000)) -#define EEPROM_PAGE1_BASE ((uint32)(EEPROM_START_ADDRESS + EEPROM_PAGE_SIZE)) - -/* Page status definitions */ -#define EEPROM_ERASED ((uint16)0xFFFF) /* PAGE is empty */ -#define EEPROM_RECEIVE_DATA ((uint16)0xEEEE) /* PAGE is marked to receive data */ -#define EEPROM_VALID_PAGE ((uint16)0x0000) /* PAGE containing valid data */ - -/* Page full define */ -enum : uint16 - { - EEPROM_OK = ((uint16)0x0000), - EEPROM_OUT_SIZE = ((uint16)0x0081), - EEPROM_BAD_ADDRESS = ((uint16)0x0082), - EEPROM_BAD_FLASH = ((uint16)0x0083), - EEPROM_NOT_INIT = ((uint16)0x0084), - EEPROM_NO_VALID_PAGE = ((uint16)0x00AB) - }; - -#define EEPROM_DEFAULT_DATA 0xFFFF - - -class EEPROMClass -{ -public: - EEPROMClass(void); - - uint16 init(void); - uint16 init(uint32, uint32, uint32); - - uint16 format(void); - - uint16 erases(uint16 *); - uint16 read (uint16 address); - uint16 read (uint16 address, uint16 *data); - uint16 write(uint16 address, uint16 data); - uint16 count(uint16 *); - uint16 maxcount(void); - - uint32 PageBase0; - uint32 PageBase1; - uint32 PageSize; - uint16 Status; -private: - FLASH_Status EE_ErasePage(uint32); - - uint16 EE_CheckPage(uint32, uint16); - uint16 EE_CheckErasePage(uint32, uint16); - uint16 EE_Format(void); - uint32 EE_FindValidPage(void); - uint16 EE_GetVariablesCount(uint32, uint16); - uint16 EE_PageTransfer(uint32, uint32, uint16); - uint16 EE_VerifyPageFullWriteVariable(uint16, uint16); -}; - -extern EEPROMClass EEPROM; - -#endif /* __EEPROM_H */ diff --git a/GD32F1/libraries/EEPROM/examples/EEPROM_example/EEPROM_example.ino b/GD32F1/libraries/EEPROM/examples/EEPROM_example/EEPROM_example.ino deleted file mode 100644 index e3c8982..0000000 --- a/GD32F1/libraries/EEPROM/examples/EEPROM_example/EEPROM_example.ino +++ /dev/null @@ -1,167 +0,0 @@ -#include - -int ledPin = 13; // LED connected to digital pin 13 -const char HELP_MSG[] = "Press :\r\n" \ - " 0 display configuration\r\n" \ - " 1 set configuration to 0x801F000 / 0x801F800 / 0x400 (RB MCU)\r\n" \ - " 2 set configuration to 0x801F000 / 0x801F800 / 0x800 (ZE/RE MCU)\r\n" \ - " 3 write/read variable\r\n" \ - " 4 increment address\r\n" \ - " 5 display pages top/bottom\r\n" \ - " 6 initialize EEPROM\r\n" \ - " 7 format EEPROM\r\n"; -uint16 DataWrite = 0; -uint16 AddressWrite = 0x10; - -void setup() -{ - // initialize the digital pin as an output: - pinMode(ledPin, OUTPUT); - Serial.begin(115200); - Serial.print(HELP_MSG); - -} - -void loop() -{ - uint16 Status; - uint16 Data; - - while (Serial.available()) - { - char cmd = (char)Serial.read(); - Serial.println(cmd); - if (cmd == '0') - { - DisplayConfig(); - } - else if (cmd == '1') - { - EEPROM.PageBase0 = 0x801F000; - EEPROM.PageBase1 = 0x801F800; - EEPROM.PageSize = 0x400; - DisplayConfig(); - } - else if (cmd == '2') - { - EEPROM.PageBase0 = 0x801F000; - EEPROM.PageBase1 = 0x801F800; - EEPROM.PageSize = 0x800; - DisplayConfig(); - } - else if (cmd == '3') - { - Status = EEPROM.write(AddressWrite, DataWrite); - Serial.print("EEPROM.write(0x"); - Serial.print(AddressWrite, HEX); - Serial.print(", 0x"); - Serial.print(DataWrite, HEX); - Serial.print(") : Status : "); - Serial.println(Status, HEX); - - Status = EEPROM.read(AddressWrite, &Data); - Serial.print("EEPROM.read(0x"); - Serial.print(AddressWrite, HEX); - Serial.print(", &..) = 0x"); - Serial.print(Data, HEX); - Serial.print(" : Status : "); - Serial.println(Status, HEX); - - ++DataWrite; - } - else if (cmd == '4') - { - ++AddressWrite; - } - else if (cmd == '5') - { - DisplayPages(0x20); - DisplayPagesEnd(0x20); - } - else if (cmd == '6') - { - Status = EEPROM.init(); - Serial.print("EEPROM.init() : "); - Serial.println(Status, HEX); - Serial.println(); - } - else if (cmd == '7') - { - Status = EEPROM.format(); - Serial.print("EEPROM.format() : "); - Serial.println(Status, HEX); - } - else - Serial.print(HELP_MSG); - } - digitalWrite(ledPin, HIGH); - delay(500); - digitalWrite(ledPin, LOW); - delay(500); -} - -void DisplayConfig(void) -{ - Serial.print ("EEPROM.PageBase0 : 0x"); - Serial.println(EEPROM.PageBase0, HEX); - Serial.print ("EEPROM.PageBase1 : 0x"); - Serial.println(EEPROM.PageBase1, HEX); - Serial.print ("EEPROM.PageSize : 0x"); - Serial.print (EEPROM.PageSize, HEX); - Serial.print (" ("); - Serial.print (EEPROM.PageSize, DEC); - Serial.println(")"); -} - -void DisplayHex(uint16 value) -{ - if (value <= 0xF) - Serial.print("000"); - else if (value <= 0xFF) - Serial.print("00"); - else if (value <= 0xFFF) - Serial.print("0"); - Serial.print(value, HEX); -} - -void DisplayPages(uint32 endIndex) -{ - Serial.println("Page 0 Top Page 1"); - - for (uint32 idx = 0; idx < endIndex; idx += 4) - { - Serial.print (EEPROM.PageBase0 + idx, HEX); - Serial.print (" : "); - DisplayHex(*(uint16*)(EEPROM.PageBase0 + idx)); - Serial.print (" "); - DisplayHex(*(uint16*)(EEPROM.PageBase0 + idx + 2)); - Serial.print (" "); - Serial.print (EEPROM.PageBase1 + idx, HEX); - Serial.print (" : "); - DisplayHex(*(uint16*)(EEPROM.PageBase1 + idx)); - Serial.print (" "); - DisplayHex(*(uint16*)(EEPROM.PageBase1 + idx + 2)); - Serial.println(); - } -} - -void DisplayPagesEnd(uint32 endIndex) -{ - Serial.println("Page 0 Bottom Page 1"); - - for (uint32 idx = EEPROM.PageSize - endIndex; idx < EEPROM.PageSize; idx += 4) - { - Serial.print (EEPROM.PageBase0 + idx, HEX); - Serial.print (" : "); - DisplayHex(*(uint16*)(EEPROM.PageBase0 + idx)); - Serial.print (" "); - DisplayHex(*(uint16*)(EEPROM.PageBase0 + idx + 2)); - Serial.print (" "); - Serial.print (EEPROM.PageBase1 + idx, HEX); - Serial.print (" : "); - DisplayHex(*(uint16*)(EEPROM.PageBase1 + idx)); - Serial.print (" "); - DisplayHex(*(uint16*)(EEPROM.PageBase1 + idx + 2)); - Serial.println(); - } -} \ No newline at end of file diff --git a/GD32F1/libraries/EEPROM/flash_stm32.c b/GD32F1/libraries/EEPROM/flash_stm32.c deleted file mode 100644 index 364e64e..0000000 --- a/GD32F1/libraries/EEPROM/flash_stm32.c +++ /dev/null @@ -1,160 +0,0 @@ -//#include "libmaple.h" -#include "libmaple/util.h" -#include "libmaple/flash.h" -#include "flash_stm32.h" - -#define FLASH_KEY1 ((uint32)0x45670123) -#define FLASH_KEY2 ((uint32)0xCDEF89AB) - -/* Delay definition */ -#define EraseTimeout ((uint32)0x00000FFF) -#define ProgramTimeout ((uint32)0x0000001F) - -/** - * @brief Inserts a time delay. - * @param None - * @retval None - */ -static void delay(void) -{ - __io uint32 i = 0; - for(i = 0xFF; i != 0; i--) { } -} - -/** - * @brief Returns the FLASH Status. - * @param None - * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, - * FLASH_ERROR_WRP or FLASH_COMPLETE - */ -FLASH_Status FLASH_GetStatus(void) -{ - if ((FLASH_BASE->SR & FLASH_SR_BSY) == FLASH_SR_BSY) - return FLASH_BUSY; - - if ((FLASH_BASE->SR & FLASH_SR_PGERR) != 0) - return FLASH_ERROR_PG; - - if ((FLASH_BASE->SR & FLASH_SR_WRPRTERR) != 0 ) - return FLASH_ERROR_WRP; - - if ((FLASH_BASE->SR & FLASH_OBR_OPTERR) != 0 ) - return FLASH_ERROR_OPT; - - return FLASH_COMPLETE; -} - -/** - * @brief Waits for a Flash operation to complete or a TIMEOUT to occur. - * @param Timeout: FLASH progamming Timeout - * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, - * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. - */ -FLASH_Status FLASH_WaitForLastOperation(uint32 Timeout) -{ - FLASH_Status status; - - /* Check for the Flash Status */ - status = FLASH_GetStatus(); - /* Wait for a Flash operation to complete or a TIMEOUT to occur */ - while ((status == FLASH_BUSY) && (Timeout != 0x00)) - { - delay(); - status = FLASH_GetStatus(); - Timeout--; - } - if (Timeout == 0) - status = FLASH_TIMEOUT; - /* Return the operation status */ - return status; -} - -/** - * @brief Erases a specified FLASH page. - * @param Page_Address: The page address to be erased. - * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, - * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. - */ -FLASH_Status FLASH_ErasePage(uint32 Page_Address) -{ - FLASH_Status status = FLASH_COMPLETE; - /* Check the parameters */ - ASSERT(IS_FLASH_ADDRESS(Page_Address)); - /* Wait for last operation to be completed */ - status = FLASH_WaitForLastOperation(EraseTimeout); - - if(status == FLASH_COMPLETE) - { - /* if the previous operation is completed, proceed to erase the page */ - FLASH_BASE->CR |= FLASH_CR_PER; - FLASH_BASE->AR = Page_Address; - FLASH_BASE->CR |= FLASH_CR_STRT; - - /* Wait for last operation to be completed */ - status = FLASH_WaitForLastOperation(EraseTimeout); - if(status != FLASH_TIMEOUT) - { - /* if the erase operation is completed, disable the PER Bit */ - FLASH_BASE->CR &= ~FLASH_CR_PER; - } - FLASH_BASE->SR = (FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPRTERR); - } - /* Return the Erase Status */ - return status; -} - -/** - * @brief Programs a half word at a specified address. - * @param Address: specifies the address to be programmed. - * @param Data: specifies the data to be programmed. - * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, - * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. - */ -FLASH_Status FLASH_ProgramHalfWord(uint32 Address, uint16 Data) -{ - FLASH_Status status = FLASH_BAD_ADDRESS; - - if (IS_FLASH_ADDRESS(Address)) - { - /* Wait for last operation to be completed */ - status = FLASH_WaitForLastOperation(ProgramTimeout); - if(status == FLASH_COMPLETE) - { - /* if the previous operation is completed, proceed to program the new data */ - FLASH_BASE->CR |= FLASH_CR_PG; - *(__io uint16*)Address = Data; - /* Wait for last operation to be completed */ - status = FLASH_WaitForLastOperation(ProgramTimeout); - if(status != FLASH_TIMEOUT) - { - /* if the program operation is completed, disable the PG Bit */ - FLASH_BASE->CR &= ~FLASH_CR_PG; - } - FLASH_BASE->SR = (FLASH_SR_EOP | FLASH_SR_PGERR | FLASH_SR_WRPRTERR); - } - } - return status; -} - -/** - * @brief Unlocks the FLASH Program Erase Controller. - * @param None - * @retval None - */ -void FLASH_Unlock(void) -{ - /* Authorize the FPEC Access */ - FLASH_BASE->KEYR = FLASH_KEY1; - FLASH_BASE->KEYR = FLASH_KEY2; -} - -/** - * @brief Locks the FLASH Program Erase Controller. - * @param None - * @retval None - */ -void FLASH_Lock(void) -{ - /* Set the Lock Bit to lock the FPEC and the FCR */ - FLASH_BASE->CR |= FLASH_CR_LOCK; -} diff --git a/GD32F1/libraries/EEPROM/flash_stm32.h b/GD32F1/libraries/EEPROM/flash_stm32.h deleted file mode 100644 index 4aa54b9..0000000 --- a/GD32F1/libraries/EEPROM/flash_stm32.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __FLASH_STM32_H -#define __FLASH_STM32_H - -#ifdef __cplusplus - extern "C" { -#endif - -typedef enum - { - FLASH_BUSY = 1, - FLASH_ERROR_PG, - FLASH_ERROR_WRP, - FLASH_ERROR_OPT, - FLASH_COMPLETE, - FLASH_TIMEOUT, - FLASH_BAD_ADDRESS - } FLASH_Status; - -#define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x0807FFFF)) - -FLASH_Status FLASH_WaitForLastOperation(uint32 Timeout); -FLASH_Status FLASH_ErasePage(uint32 Page_Address); -FLASH_Status FLASH_ProgramHalfWord(uint32 Address, uint16 Data); - -void FLASH_Unlock(void); -void FLASH_Lock(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __FLASH_STM32_H */ diff --git a/GD32F1/libraries/EEPROM/keywords.txt b/GD32F1/libraries/EEPROM/keywords.txt deleted file mode 100644 index ecf82c9..0000000 --- a/GD32F1/libraries/EEPROM/keywords.txt +++ /dev/null @@ -1,27 +0,0 @@ -####################################### -# Syntax Coloring Map For EEPROM -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -EEPROM KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -init KEYWORD2 -format KEYWORD2 -erases KEYWORD2 -read KEYWORD2 -write KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### -PageBase0 -PageBase1 -PageSize -Status diff --git a/GD32F1/libraries/FreeRTOS/MapleFreeRTOS.cpp b/GD32F1/libraries/FreeRTOS/MapleFreeRTOS.cpp deleted file mode 100644 index d235ceb..0000000 --- a/GD32F1/libraries/FreeRTOS/MapleFreeRTOS.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#include "MapleFreeRTOS.h" - -extern "C" { - -void vApplicationStackOverflowHook(xTaskHandle *pxTask, - signed char *pcTaskName) { - /* This function will get called if a task overflows its stack. - * If the parameters are corrupt then inspect pxCurrentTCB to find - * which was the offending task. */ - - (void) pxTask; - (void) pcTaskName; - - while (1) - ; -} - -} diff --git a/GD32F1/libraries/FreeRTOS/MapleFreeRTOS.h b/GD32F1/libraries/FreeRTOS/MapleFreeRTOS.h deleted file mode 100644 index 4cbbb96..0000000 --- a/GD32F1/libraries/FreeRTOS/MapleFreeRTOS.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#ifndef __MAPLE_FREERTOS_H__ -#define __MAPLE_FREERTOS_H__ - -#include - -extern "C" { -#define GCC_ARMCM3 -#include "utility/FreeRTOS.h" -#include "utility/task.h" -#include "utility/queue.h" -#include "utility/semphr.h" -} - -#endif diff --git a/GD32F1/libraries/FreeRTOS/keywords.txt b/GD32F1/libraries/FreeRTOS/keywords.txt deleted file mode 100644 index 4a20bae..0000000 --- a/GD32F1/libraries/FreeRTOS/keywords.txt +++ /dev/null @@ -1,27 +0,0 @@ -####################################### -# Syntax Coloring Map For CoOS -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -vTaskDelay KEYWORD2 -vTaskDelayUntil KEYWORD2 -xTaskCreate KEYWORD2 -vTaskSuspend KEYWORD2 -vTaskDelete KEYWORD2 -vTaskPrioritySet KEYWORD2 -uxTaskPriorityGet KEYWORD2 -vTaskStartScheduler KEYWORD2 -vApplicationIdleHook KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### -configUSE_IDLE_HOOK LITERAL1 -configMINIMAL_STACK_SIZE LITERAL1 -tskIDLE_PRIORITY LITERAL1 \ No newline at end of file diff --git a/GD32F1/libraries/FreeRTOS/rules.mk b/GD32F1/libraries/FreeRTOS/rules.mk deleted file mode 100644 index 2b415ba..0000000 --- a/GD32F1/libraries/FreeRTOS/rules.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) -BUILDDIRS += $(BUILD_PATH)/$(d)/utility - -# Local flags -CXXFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) -CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) - -# Local rules and targets -cSRCS_$(d) := utility/croutine.c \ - utility/heap_2.c \ - utility/list.c \ - utility/port.c \ - utility/queue.c \ - utility/timers.c \ - utility/tasks.c \ - -cppSRCS_$(d) := MapleFreeRTOS.cpp - -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ - $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CXXFLAGS := $(CXXFLAGS_$(d)) -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) \ No newline at end of file diff --git a/GD32F1/libraries/FreeRTOS/utility/FreeRTOS.h b/GD32F1/libraries/FreeRTOS/utility/FreeRTOS.h deleted file mode 100644 index a609bb3..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/FreeRTOS.h +++ /dev/null @@ -1,468 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#ifndef INC_FREERTOS_H -#define INC_FREERTOS_H - - -/* - * Include the generic headers required for the FreeRTOS port being used. - */ -#include - -/* Basic FreeRTOS definitions. */ -#include "projdefs.h" - -/* Application specific configuration options. */ -#include "FreeRTOSConfig.h" - -/* Definitions specific to the port being used. */ -#include "portable.h" - - -/* Defines the prototype to which the application task hook function must -conform. */ -typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); - - - - - -/* - * Check all the required application specific macros have been defined. - * These macros are application specific and (as downloaded) are defined - * within FreeRTOSConfig.h. - */ - -#ifndef configUSE_PREEMPTION - #error Missing definition: configUSE_PREEMPTION should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_IDLE_HOOK - #error Missing definition: configUSE_IDLE_HOOK should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_TICK_HOOK - #error Missing definition: configUSE_TICK_HOOK should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_CO_ROUTINES - #error Missing definition: configUSE_CO_ROUTINES should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskPrioritySet - #error Missing definition: INCLUDE_vTaskPrioritySet should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_uxTaskPriorityGet - #error Missing definition: INCLUDE_uxTaskPriorityGet should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskDelete - #error Missing definition: INCLUDE_vTaskDelete should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskCleanUpResources - #error Missing definition: INCLUDE_vTaskCleanUpResources should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskSuspend - #error Missing definition: INCLUDE_vTaskSuspend should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskDelayUntil - #error Missing definition: INCLUDE_vTaskDelayUntil should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskDelay - #error Missing definition: INCLUDE_vTaskDelay should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_16_BIT_TICKS - #error Missing definition: configUSE_16_BIT_TICKS should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_APPLICATION_TASK_TAG - #define configUSE_APPLICATION_TASK_TAG 0 -#endif - -#ifndef INCLUDE_uxTaskGetStackHighWaterMark - #define INCLUDE_uxTaskGetStackHighWaterMark 0 -#endif - -#ifndef configUSE_RECURSIVE_MUTEXES - #define configUSE_RECURSIVE_MUTEXES 0 -#endif - -#ifndef configUSE_MUTEXES - #define configUSE_MUTEXES 0 -#endif - -#ifndef configUSE_TIMERS - #define configUSE_TIMERS 0 -#endif - -#ifndef configUSE_COUNTING_SEMAPHORES - #define configUSE_COUNTING_SEMAPHORES 0 -#endif - -#ifndef configUSE_ALTERNATIVE_API - #define configUSE_ALTERNATIVE_API 0 -#endif - -#ifndef portCRITICAL_NESTING_IN_TCB - #define portCRITICAL_NESTING_IN_TCB 0 -#endif - -#ifndef configMAX_TASK_NAME_LEN - #define configMAX_TASK_NAME_LEN 16 -#endif - -#ifndef configIDLE_SHOULD_YIELD - #define configIDLE_SHOULD_YIELD 1 -#endif - -#if configMAX_TASK_NAME_LEN < 1 - #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h -#endif - -#ifndef INCLUDE_xTaskResumeFromISR - #define INCLUDE_xTaskResumeFromISR 1 -#endif - -#ifndef configASSERT - #define configASSERT( x ) -#endif - -/* The timers module relies on xTaskGetSchedulerState(). */ -#if configUSE_TIMERS == 1 - - #ifndef configTIMER_TASK_PRIORITY - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. - #endif /* configTIMER_TASK_PRIORITY */ - - #ifndef configTIMER_QUEUE_LENGTH - #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. - #endif /* configTIMER_QUEUE_LENGTH */ - - #ifndef configTIMER_TASK_STACK_DEPTH - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. - #endif /* configTIMER_TASK_STACK_DEPTH */ - -#endif /* configUSE_TIMERS */ - -#ifndef INCLUDE_xTaskGetSchedulerState - #define INCLUDE_xTaskGetSchedulerState 0 -#endif - -#ifndef INCLUDE_xTaskGetCurrentTaskHandle - #define INCLUDE_xTaskGetCurrentTaskHandle 0 -#endif - - -#ifndef portSET_INTERRUPT_MASK_FROM_ISR - #define portSET_INTERRUPT_MASK_FROM_ISR() 0 -#endif - -#ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR - #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue -#endif - - -#ifndef configQUEUE_REGISTRY_SIZE - #define configQUEUE_REGISTRY_SIZE 0U -#endif - -#if ( configQUEUE_REGISTRY_SIZE < 1U ) - #define vQueueAddToRegistry( xQueue, pcName ) - #define vQueueUnregisterQueue( xQueue ) -#endif - - -/* Remove any unused trace macros. */ -#ifndef traceSTART - /* Used to perform any necessary initialisation - for example, open a file - into which trace is to be written. */ - #define traceSTART() -#endif - -#ifndef traceEND - /* Use to close a trace, for example close a file into which trace has been - written. */ - #define traceEND() -#endif - -#ifndef traceTASK_SWITCHED_IN - /* Called after a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the selected task. */ - #define traceTASK_SWITCHED_IN() -#endif - -#ifndef traceTASK_SWITCHED_OUT - /* Called before a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the task being switched out. */ - #define traceTASK_SWITCHED_OUT() -#endif - -#ifndef traceBLOCKING_ON_QUEUE_RECEIVE - /* Task is about to block because it cannot read from a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the - task that attempted the read. */ - #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) -#endif - -#ifndef traceBLOCKING_ON_QUEUE_SEND - /* Task is about to block because it cannot write to a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the write was attempted. pxCurrentTCB points to the TCB of the - task that attempted the write. */ - #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) -#endif - -#ifndef configCHECK_FOR_STACK_OVERFLOW - #define configCHECK_FOR_STACK_OVERFLOW 0 -#endif - -/* The following event macros are embedded in the kernel API calls. */ - -#ifndef traceQUEUE_CREATE - #define traceQUEUE_CREATE( pxNewQueue ) -#endif - -#ifndef traceQUEUE_CREATE_FAILED - #define traceQUEUE_CREATE_FAILED() -#endif - -#ifndef traceCREATE_MUTEX - #define traceCREATE_MUTEX( pxNewQueue ) -#endif - -#ifndef traceCREATE_MUTEX_FAILED - #define traceCREATE_MUTEX_FAILED() -#endif - -#ifndef traceGIVE_MUTEX_RECURSIVE - #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) -#endif - -#ifndef traceGIVE_MUTEX_RECURSIVE_FAILED - #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) -#endif - -#ifndef traceTAKE_MUTEX_RECURSIVE - #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) -#endif - -#ifndef traceTAKE_MUTEX_RECURSIVE_FAILED - #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) -#endif - -#ifndef traceCREATE_COUNTING_SEMAPHORE - #define traceCREATE_COUNTING_SEMAPHORE() -#endif - -#ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED - #define traceCREATE_COUNTING_SEMAPHORE_FAILED() -#endif - -#ifndef traceQUEUE_SEND - #define traceQUEUE_SEND( pxQueue ) -#endif - -#ifndef traceQUEUE_SEND_FAILED - #define traceQUEUE_SEND_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_RECEIVE - #define traceQUEUE_RECEIVE( pxQueue ) -#endif - -#ifndef traceQUEUE_PEEK - #define traceQUEUE_PEEK( pxQueue ) -#endif - -#ifndef traceQUEUE_RECEIVE_FAILED - #define traceQUEUE_RECEIVE_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_SEND_FROM_ISR - #define traceQUEUE_SEND_FROM_ISR( pxQueue ) -#endif - -#ifndef traceQUEUE_SEND_FROM_ISR_FAILED - #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_RECEIVE_FROM_ISR - #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) -#endif - -#ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED - #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_DELETE - #define traceQUEUE_DELETE( pxQueue ) -#endif - -#ifndef traceTASK_CREATE - #define traceTASK_CREATE( pxNewTCB ) -#endif - -#ifndef traceTASK_CREATE_FAILED - #define traceTASK_CREATE_FAILED() -#endif - -#ifndef traceTASK_DELETE - #define traceTASK_DELETE( pxTaskToDelete ) -#endif - -#ifndef traceTASK_DELAY_UNTIL - #define traceTASK_DELAY_UNTIL() -#endif - -#ifndef traceTASK_DELAY - #define traceTASK_DELAY() -#endif - -#ifndef traceTASK_PRIORITY_SET - #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) -#endif - -#ifndef traceTASK_SUSPEND - #define traceTASK_SUSPEND( pxTaskToSuspend ) -#endif - -#ifndef traceTASK_RESUME - #define traceTASK_RESUME( pxTaskToResume ) -#endif - -#ifndef traceTASK_RESUME_FROM_ISR - #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) -#endif - -#ifndef traceTASK_INCREMENT_TICK - #define traceTASK_INCREMENT_TICK( xTickCount ) -#endif - -#ifndef traceTIMER_CREATE - #define traceTIMER_CREATE( pxNewTimer ) -#endif - -#ifndef traceTIMER_CREATE_FAILED - #define traceTIMER_CREATE_FAILED() -#endif - -#ifndef traceTIMER_COMMAND_SEND - #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) -#endif - -#ifndef traceTIMER_EXPIRED - #define traceTIMER_EXPIRED( pxTimer ) -#endif - -#ifndef traceTIMER_COMMAND_RECEIVED - #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) -#endif - -#ifndef configGENERATE_RUN_TIME_STATS - #define configGENERATE_RUN_TIME_STATS 0 -#endif - -#if ( configGENERATE_RUN_TIME_STATS == 1 ) - - #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. - #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ - - #ifndef portGET_RUN_TIME_COUNTER_VALUE - #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE - #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. - #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ - #endif /* portGET_RUN_TIME_COUNTER_VALUE */ - -#endif /* configGENERATE_RUN_TIME_STATS */ - -#ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() -#endif - -#ifndef configUSE_MALLOC_FAILED_HOOK - #define configUSE_MALLOC_FAILED_HOOK 0 -#endif - -#ifndef portPRIVILEGE_BIT - #define portPRIVILEGE_BIT ( ( unsigned portBASE_TYPE ) 0x00 ) -#endif - -#ifndef portYIELD_WITHIN_API - #define portYIELD_WITHIN_API portYIELD -#endif - -#ifndef pvPortMallocAligned - #define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMalloc( ( x ) ) ) : ( puxStackBuffer ) ) -#endif - -#ifndef vPortFreeAligned - #define vPortFreeAligned( pvBlockToFree ) vPortFree( pvBlockToFree ) -#endif - -#endif /* INC_FREERTOS_H */ - diff --git a/GD32F1/libraries/FreeRTOS/utility/FreeRTOSConfig.h b/GD32F1/libraries/FreeRTOS/utility/FreeRTOSConfig.h deleted file mode 100644 index 0956ee1..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/FreeRTOSConfig.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html. - *----------------------------------------------------------*/ - -#define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 -#define configCPU_CLOCK_HZ ( ( unsigned long ) F_CPU ) -#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) -#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 120 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 8 * 1024 ) ) -#define configMAX_TASK_NAME_LEN ( 16 ) -#define configUSE_TRACE_FACILITY 1 -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 1 - -/* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) - -#define configUSE_MUTEXES 1 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_ALTERNATIVE_API 0 -#define configCHECK_FOR_STACK_OVERFLOW 2 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 0 -#define configGENERATE_RUN_TIME_STATS 0 - -/* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ - -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 0 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 - -/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 -(lowest) to 0 (1?) (highest). */ -#define configKERNEL_INTERRUPT_PRIORITY 255 -#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ - - -/* This is the value being used as per the ST library which permits 16 -priority values, 0 to 15. This must correspond to the -configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest -NVIC value of 255. */ -#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 - -/*----------------------------------------------------------- - * UART configuration. - *-----------------------------------------------------------*/ -#define configCOM0_RX_BUFFER_LENGTH 128 -#define configCOM0_TX_BUFFER_LENGTH 128 -#define configCOM1_RX_BUFFER_LENGTH 128 -#define configCOM1_TX_BUFFER_LENGTH 128 - -#endif /* FREERTOS_CONFIG_H */ - diff --git a/GD32F1/libraries/FreeRTOS/utility/StackMacros.h b/GD32F1/libraries/FreeRTOS/utility/StackMacros.h deleted file mode 100644 index 547a58c..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/StackMacros.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#ifndef STACK_MACROS_H -#define STACK_MACROS_H - -/* - * Call the stack overflow hook function if the stack of the task being swapped - * out is currently overflowed, or looks like it might have overflowed in the - * past. - * - * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check - * the current stack state only - comparing the current top of stack value to - * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 - * will also cause the last few stack bytes to be checked to ensure the value - * to which the bytes were set when the task was created have not been - * overwritten. Note this second test does not guarantee that an overflowed - * stack will always be recognised. - */ - -/*-----------------------------------------------------------*/ - -#if( configCHECK_FOR_STACK_OVERFLOW == 0 ) - - /* FreeRTOSConfig.h is not set to check for stack overflows. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() - -#endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */ -/*-----------------------------------------------------------*/ - -#if( configCHECK_FOR_STACK_OVERFLOW == 1 ) - - /* FreeRTOSConfig.h is only set to use the first method of - overflow checking. */ - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() - -#endif -/*-----------------------------------------------------------*/ - -#if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) - - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ - { \ - vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */ -/*-----------------------------------------------------------*/ - -#if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) - - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ - { \ - vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ -/*-----------------------------------------------------------*/ - -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ -/*-----------------------------------------------------------*/ - -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - char *pcEndOfStack = ( char * ) pxCurrentTCB->pxEndOfStack; \ - static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ -/*-----------------------------------------------------------*/ - -#endif /* STACK_MACROS_H */ - diff --git a/GD32F1/libraries/FreeRTOS/utility/croutine.c b/GD32F1/libraries/FreeRTOS/utility/croutine.c deleted file mode 100644 index fe56730..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/croutine.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#include "FreeRTOS.h" -#include "task.h" -#include "croutine.h" - -/* - * Some kernel aware debuggers require data to be viewed to be global, rather - * than file scope. - */ -#ifdef portREMOVE_STATIC_QUALIFIER - #define static -#endif - - -/* Lists for ready and blocked co-routines. --------------------*/ -static xList pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ]; /*< Prioritised ready co-routines. */ -static xList xDelayedCoRoutineList1; /*< Delayed co-routines. */ -static xList xDelayedCoRoutineList2; /*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */ -static xList * pxDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used. */ -static xList * pxOverflowDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */ -static xList xPendingReadyCoRoutineList; /*< Holds co-routines that have been readied by an external event. They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */ - -/* Other file private variables. --------------------------------*/ -corCRCB * pxCurrentCoRoutine = NULL; -static unsigned portBASE_TYPE uxTopCoRoutineReadyPriority = 0; -static portTickType xCoRoutineTickCount = 0, xLastTickCount = 0, xPassedTicks = 0; - -/* The initial state of the co-routine when it is created. */ -#define corINITIAL_STATE ( 0 ) - -/* - * Place the co-routine represented by pxCRCB into the appropriate ready queue - * for the priority. It is inserted at the end of the list. - * - * This macro accesses the co-routine ready lists and therefore must not be - * used from within an ISR. - */ -#define prvAddCoRoutineToReadyQueue( pxCRCB ) \ -{ \ - if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority ) \ - { \ - uxTopCoRoutineReadyPriority = pxCRCB->uxPriority; \ - } \ - vListInsertEnd( ( xList * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) ); \ -} - -/* - * Utility to ready all the lists used by the scheduler. This is called - * automatically upon the creation of the first co-routine. - */ -static void prvInitialiseCoRoutineLists( void ); - -/* - * Co-routines that are readied by an interrupt cannot be placed directly into - * the ready lists (there is no mutual exclusion). Instead they are placed in - * in the pending ready list in order that they can later be moved to the ready - * list by the co-routine scheduler. - */ -static void prvCheckPendingReadyList( void ); - -/* - * Macro that looks at the list of co-routines that are currently delayed to - * see if any require waking. - * - * Co-routines are stored in the queue in the order of their wake time - - * meaning once one co-routine has been found whose timer has not expired - * we need not look any further down the list. - */ -static void prvCheckDelayedList( void ); - -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex ) -{ -signed portBASE_TYPE xReturn; -corCRCB *pxCoRoutine; - - /* Allocate the memory that will store the co-routine control block. */ - pxCoRoutine = ( corCRCB * ) pvPortMalloc( sizeof( corCRCB ) ); - if( pxCoRoutine ) - { - /* If pxCurrentCoRoutine is NULL then this is the first co-routine to - be created and the co-routine data structures need initialising. */ - if( pxCurrentCoRoutine == NULL ) - { - pxCurrentCoRoutine = pxCoRoutine; - prvInitialiseCoRoutineLists(); - } - - /* Check the priority is within limits. */ - if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES ) - { - uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1; - } - - /* Fill out the co-routine control block from the function parameters. */ - pxCoRoutine->uxState = corINITIAL_STATE; - pxCoRoutine->uxPriority = uxPriority; - pxCoRoutine->uxIndex = uxIndex; - pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode; - - /* Initialise all the other co-routine control block parameters. */ - vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) ); - vListInitialiseItem( &( pxCoRoutine->xEventListItem ) ); - - /* Set the co-routine control block as a link back from the xListItem. - This is so we can get back to the containing CRCB from a generic item - in a list. */ - listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine ); - listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine ); - - /* Event lists are always in priority order. */ - listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority ); - - /* Now the co-routine has been initialised it can be added to the ready - list at the correct priority. */ - prvAddCoRoutineToReadyQueue( pxCoRoutine ); - - xReturn = pdPASS; - } - else - { - xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList ) -{ -portTickType xTimeToWake; - - /* Calculate the time to wake - this may overflow but this is - not a problem. */ - xTimeToWake = xCoRoutineTickCount + xTicksToDelay; - - /* We must remove ourselves from the ready list before adding - ourselves to the blocked list as the same list item is used for - both lists. */ - vListRemove( ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) ); - - /* The list item will be inserted in wake time order. */ - listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake ); - - if( xTimeToWake < xCoRoutineTickCount ) - { - /* Wake time has overflowed. Place this item in the - overflow list. */ - vListInsert( ( xList * ) pxOverflowDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) ); - } - else - { - /* The wake time has not overflowed, so we can use the - current block list. */ - vListInsert( ( xList * ) pxDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) ); - } - - if( pxEventList ) - { - /* Also add the co-routine to an event list. If this is done then the - function must be called with interrupts disabled. */ - vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) ); - } -} -/*-----------------------------------------------------------*/ - -static void prvCheckPendingReadyList( void ) -{ - /* Are there any co-routines waiting to get moved to the ready list? These - are co-routines that have been readied by an ISR. The ISR cannot access - the ready lists itself. */ - while( listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) == pdFALSE ) - { - corCRCB *pxUnblockedCRCB; - - /* The pending ready list can be accessed by an ISR. */ - portDISABLE_INTERRUPTS(); - { - pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyCoRoutineList) ); - vListRemove( &( pxUnblockedCRCB->xEventListItem ) ); - } - portENABLE_INTERRUPTS(); - - vListRemove( &( pxUnblockedCRCB->xGenericListItem ) ); - prvAddCoRoutineToReadyQueue( pxUnblockedCRCB ); - } -} -/*-----------------------------------------------------------*/ - -static void prvCheckDelayedList( void ) -{ -corCRCB *pxCRCB; - - xPassedTicks = xTaskGetTickCount() - xLastTickCount; - while( xPassedTicks ) - { - xCoRoutineTickCount++; - xPassedTicks--; - - /* If the tick count has overflowed we need to swap the ready lists. */ - if( xCoRoutineTickCount == 0 ) - { - xList * pxTemp; - - /* Tick count has overflowed so we need to swap the delay lists. If there are - any items in pxDelayedCoRoutineList here then there is an error! */ - pxTemp = pxDelayedCoRoutineList; - pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList; - pxOverflowDelayedCoRoutineList = pxTemp; - } - - /* See if this tick has made a timeout expire. */ - while( listLIST_IS_EMPTY( pxDelayedCoRoutineList ) == pdFALSE ) - { - pxCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList ); - - if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) ) - { - /* Timeout not yet expired. */ - break; - } - - portDISABLE_INTERRUPTS(); - { - /* The event could have occurred just before this critical - section. If this is the case then the generic list item will - have been moved to the pending ready list and the following - line is still valid. Also the pvContainer parameter will have - been set to NULL so the following lines are also valid. */ - vListRemove( &( pxCRCB->xGenericListItem ) ); - - /* Is the co-routine waiting on an event also? */ - if( pxCRCB->xEventListItem.pvContainer ) - { - vListRemove( &( pxCRCB->xEventListItem ) ); - } - } - portENABLE_INTERRUPTS(); - - prvAddCoRoutineToReadyQueue( pxCRCB ); - } - } - - xLastTickCount = xCoRoutineTickCount; -} -/*-----------------------------------------------------------*/ - -void vCoRoutineSchedule( void ) -{ - /* See if any co-routines readied by events need moving to the ready lists. */ - prvCheckPendingReadyList(); - - /* See if any delayed co-routines have timed out. */ - prvCheckDelayedList(); - - /* Find the highest priority queue that contains ready co-routines. */ - while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) ) - { - if( uxTopCoRoutineReadyPriority == 0 ) - { - /* No more co-routines to check. */ - return; - } - --uxTopCoRoutineReadyPriority; - } - - /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines - of the same priority get an equal share of the processor time. */ - listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ); - - /* Call the co-routine. */ - ( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex ); - - return; -} -/*-----------------------------------------------------------*/ - -static void prvInitialiseCoRoutineLists( void ) -{ -unsigned portBASE_TYPE uxPriority; - - for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ ) - { - vListInitialise( ( xList * ) &( pxReadyCoRoutineLists[ uxPriority ] ) ); - } - - vListInitialise( ( xList * ) &xDelayedCoRoutineList1 ); - vListInitialise( ( xList * ) &xDelayedCoRoutineList2 ); - vListInitialise( ( xList * ) &xPendingReadyCoRoutineList ); - - /* Start with pxDelayedCoRoutineList using list1 and the - pxOverflowDelayedCoRoutineList using list2. */ - pxDelayedCoRoutineList = &xDelayedCoRoutineList1; - pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2; -} -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList ) -{ -corCRCB *pxUnblockedCRCB; -signed portBASE_TYPE xReturn; - - /* This function is called from within an interrupt. It can only access - event lists and the pending ready list. This function assumes that a - check has already been made to ensure pxEventList is not empty. */ - pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); - vListRemove( &( pxUnblockedCRCB->xEventListItem ) ); - vListInsertEnd( ( xList * ) &( xPendingReadyCoRoutineList ), &( pxUnblockedCRCB->xEventListItem ) ); - - if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} - diff --git a/GD32F1/libraries/FreeRTOS/utility/croutine.h b/GD32F1/libraries/FreeRTOS/utility/croutine.h deleted file mode 100644 index 6801c41..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/croutine.h +++ /dev/null @@ -1,752 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#ifndef CO_ROUTINE_H -#define CO_ROUTINE_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include croutine.h" -#endif - -#include "list.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Used to hide the implementation of the co-routine control block. The -control block structure however has to be included in the header due to -the macro implementation of the co-routine functionality. */ -typedef void * xCoRoutineHandle; - -/* Defines the prototype to which co-routine functions must conform. */ -typedef void (*crCOROUTINE_CODE)( xCoRoutineHandle, unsigned portBASE_TYPE ); - -typedef struct corCoRoutineControlBlock -{ - crCOROUTINE_CODE pxCoRoutineFunction; - xListItem xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ - xListItem xEventListItem; /*< List item used to place the CRCB in event lists. */ - unsigned portBASE_TYPE uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ - unsigned portBASE_TYPE uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ - unsigned short uxState; /*< Used internally by the co-routine implementation. */ -} corCRCB; /* Co-routine control block. Note must be identical in size down to uxPriority with tskTCB. */ - -/** - * croutine. h - *
- portBASE_TYPE xCoRoutineCreate(
-                                 crCOROUTINE_CODE pxCoRoutineCode,
-                                 unsigned portBASE_TYPE uxPriority,
-                                 unsigned portBASE_TYPE uxIndex
-                               );
- * - * Create a new co-routine and add it to the list of co-routines that are - * ready to run. - * - * @param pxCoRoutineCode Pointer to the co-routine function. Co-routine - * functions require special syntax - see the co-routine section of the WEB - * documentation for more information. - * - * @param uxPriority The priority with respect to other co-routines at which - * the co-routine will run. - * - * @param uxIndex Used to distinguish between different co-routines that - * execute the same function. See the example below and the co-routine section - * of the WEB documentation for further information. - * - * @return pdPASS if the co-routine was successfully created and added to a ready - * list, otherwise an error code defined with ProjDefs.h. - * - * Example usage: -
- // Co-routine to be created.
- void vFlashCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- static const char cLedToFlash[ 2 ] = { 5, 6 };
- static const portTickType uxFlashRates[ 2 ] = { 200, 400 };
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // This co-routine just delays for a fixed period, then toggles
-         // an LED.  Two co-routines are created using this function, so
-         // the uxIndex parameter is used to tell the co-routine which
-         // LED to flash and how long to delay.  This assumes xQueue has
-         // already been created.
-         vParTestToggleLED( cLedToFlash[ uxIndex ] );
-         crDELAY( xHandle, uxFlashRates[ uxIndex ] );
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
-
- // Function that creates two co-routines.
- void vOtherFunction( void )
- {
- unsigned char ucParameterToPass;
- xTaskHandle xHandle;
-		
-     // Create two co-routines at priority 0.  The first is given index 0
-     // so (from the code above) toggles LED 5 every 200 ticks.  The second
-     // is given index 1 so toggles LED 6 every 400 ticks.
-     for( uxIndex = 0; uxIndex < 2; uxIndex++ )
-     {
-         xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
-     }
- }
-   
- * \defgroup xCoRoutineCreate xCoRoutineCreate - * \ingroup Tasks - */ -signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex ); - - -/** - * croutine. h - *
- void vCoRoutineSchedule( void );
- * - * Run a co-routine. - * - * vCoRoutineSchedule() executes the highest priority co-routine that is able - * to run. The co-routine will execute until it either blocks, yields or is - * preempted by a task. Co-routines execute cooperatively so one - * co-routine cannot be preempted by another, but can be preempted by a task. - * - * If an application comprises of both tasks and co-routines then - * vCoRoutineSchedule should be called from the idle task (in an idle task - * hook). - * - * Example usage: -
- // This idle task hook will schedule a co-routine each time it is called.
- // The rest of the idle task will execute between co-routine calls.
- void vApplicationIdleHook( void )
- {
-	vCoRoutineSchedule();
- }
-
- // Alternatively, if you do not require any other part of the idle task to
- // execute, the idle task hook can call vCoRoutineScheduler() within an
- // infinite loop.
- void vApplicationIdleHook( void )
- {
-    for( ;; )
-    {
-        vCoRoutineSchedule();
-    }
- }
- 
- * \defgroup vCoRoutineSchedule vCoRoutineSchedule - * \ingroup Tasks - */ -void vCoRoutineSchedule( void ); - -/** - * croutine. h - *
- crSTART( xCoRoutineHandle xHandle );
- * - * This macro MUST always be called at the start of a co-routine function. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static long ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crSTART crSTART - * \ingroup Tasks - */ -#define crSTART( pxCRCB ) switch( ( ( corCRCB * )( pxCRCB ) )->uxState ) { case 0: - -/** - * croutine. h - *
- crEND();
- * - * This macro MUST always be called at the end of a co-routine function. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static long ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crSTART crSTART - * \ingroup Tasks - */ -#define crEND() } - -/* - * These macros are intended for internal use by the co-routine implementation - * only. The macros should not be used directly by application writers. - */ -#define crSET_STATE0( xHandle ) ( ( corCRCB * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): -#define crSET_STATE1( xHandle ) ( ( corCRCB * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): - -/** - * croutine. h - *
- crDELAY( xCoRoutineHandle xHandle, portTickType xTicksToDelay );
- * - * Delay a co-routine for a fixed period of time. - * - * crDELAY can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * @param xHandle The handle of the co-routine to delay. This is the xHandle - * parameter of the co-routine function. - * - * @param xTickToDelay The number of ticks that the co-routine should delay - * for. The actual amount of time this equates to is defined by - * configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant portTICK_RATE_MS - * can be used to convert ticks to milliseconds. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- // We are to delay for 200ms.
- static const xTickType xDelayTime = 200 / portTICK_RATE_MS;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-        // Delay for 200ms.
-        crDELAY( xHandle, xDelayTime );
-
-        // Do something here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crDELAY crDELAY - * \ingroup Tasks - */ -#define crDELAY( xHandle, xTicksToDelay ) \ - if( ( xTicksToDelay ) > 0 ) \ - { \ - vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ - } \ - crSET_STATE0( ( xHandle ) ); - -/** - *
- crQUEUE_SEND(
-                  xCoRoutineHandle xHandle,
-                  xQueueHandle pxQueue,
-                  void *pvItemToQueue,
-                  portTickType xTicksToWait,
-                  portBASE_TYPE *pxResult
-             )
- * - * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine - * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. - * - * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas - * xQueueSend() and xQueueReceive() can only be used from tasks. - * - * crQUEUE_SEND can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xHandle The handle of the calling co-routine. This is the xHandle - * parameter of the co-routine function. - * - * @param pxQueue The handle of the queue on which the data will be posted. - * The handle is obtained as the return value when the queue is created using - * the xQueueCreate() API function. - * - * @param pvItemToQueue A pointer to the data being posted onto the queue. - * The number of bytes of each queued item is specified when the queue is - * created. This number of bytes is copied from pvItemToQueue into the queue - * itself. - * - * @param xTickToDelay The number of ticks that the co-routine should block - * to wait for space to become available on the queue, should space not be - * available immediately. The actual amount of time this equates to is defined - * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant - * portTICK_RATE_MS can be used to convert ticks to milliseconds (see example - * below). - * - * @param pxResult The variable pointed to by pxResult will be set to pdPASS if - * data was successfully posted onto the queue, otherwise it will be set to an - * error defined within ProjDefs.h. - * - * Example usage: -
- // Co-routine function that blocks for a fixed period then posts a number onto
- // a queue.
- static void prvCoRoutineFlashTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static portBASE_TYPE xNumberToPost = 0;
- static portBASE_TYPE xResult;
-
-    // Co-routines must begin with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // This assumes the queue has already been created.
-        crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
-
-        if( xResult != pdPASS )
-        {
-            // The message was not posted!
-        }
-
-        // Increment the number to be posted onto the queue.
-        xNumberToPost++;
-
-        // Delay for 100 ticks.
-        crDELAY( xHandle, 100 );
-    }
-
-    // Co-routines must end with a call to crEND().
-    crEND();
- }
- * \defgroup crQUEUE_SEND crQUEUE_SEND - * \ingroup Tasks - */ -#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ - } \ - if( *pxResult == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *pxResult = pdPASS; \ - } \ -} - -/** - * croutine. h - *
-  crQUEUE_RECEIVE(
-                     xCoRoutineHandle xHandle,
-                     xQueueHandle pxQueue,
-                     void *pvBuffer,
-                     portTickType xTicksToWait,
-                     portBASE_TYPE *pxResult
-                 )
- * - * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine - * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. - * - * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas - * xQueueSend() and xQueueReceive() can only be used from tasks. - * - * crQUEUE_RECEIVE can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xHandle The handle of the calling co-routine. This is the xHandle - * parameter of the co-routine function. - * - * @param pxQueue The handle of the queue from which the data will be received. - * The handle is obtained as the return value when the queue is created using - * the xQueueCreate() API function. - * - * @param pvBuffer The buffer into which the received item is to be copied. - * The number of bytes of each queued item is specified when the queue is - * created. This number of bytes is copied into pvBuffer. - * - * @param xTickToDelay The number of ticks that the co-routine should block - * to wait for data to become available from the queue, should data not be - * available immediately. The actual amount of time this equates to is defined - * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant - * portTICK_RATE_MS can be used to convert ticks to milliseconds (see the - * crQUEUE_SEND example). - * - * @param pxResult The variable pointed to by pxResult will be set to pdPASS if - * data was successfully retrieved from the queue, otherwise it will be set to - * an error code as defined within ProjDefs.h. - * - * Example usage: -
- // A co-routine receives the number of an LED to flash from a queue.  It
- // blocks on the queue until the number is received.
- static void prvCoRoutineFlashWorkTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static portBASE_TYPE xResult;
- static unsigned portBASE_TYPE uxLEDToFlash;
-
-    // All co-routines must start with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // Wait for data to become available on the queue.
-        crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-        if( xResult == pdPASS )
-        {
-            // We received the LED to flash - flash it!
-            vParTestToggleLED( uxLEDToFlash );
-        }
-    }
-
-    crEND();
- }
- * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE - * \ingroup Tasks - */ -#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \ - } \ - if( *( pxResult ) == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *( pxResult ) = pdPASS; \ - } \ -} - -/** - * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            xQueueHandle pxQueue,
-                            void *pvItemToQueue,
-                            portBASE_TYPE xCoRoutinePreviouslyWoken
-                       )
- * - * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the - * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() - * functions used by tasks. - * - * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to - * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and - * xQueueReceiveFromISR() can only be used to pass data between a task and and - * ISR. - * - * crQUEUE_SEND_FROM_ISR can only be called from an ISR to send data to a queue - * that is being used from within a co-routine. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xCoRoutinePreviouslyWoken This is included so an ISR can post onto - * the same queue multiple times from a single interrupt. The first call - * should always pass in pdFALSE. Subsequent calls should pass in - * the value returned from the previous call. - * - * @return pdTRUE if a co-routine was woken by posting onto the queue. This is - * used by the ISR to determine if a context switch may be required following - * the ISR. - * - * Example usage: -
- // A co-routine that blocks on a queue waiting for characters to be received.
- static void vReceivingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
- {
- char cRxedChar;
- portBASE_TYPE xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Wait for data to become available on the queue.  This assumes the
-         // queue xCommsRxQueue has already been created!
-         crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-         // Was a character received?
-         if( xResult == pdPASS )
-         {
-             // Process the character here.
-         }
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to send characters received on a serial port to
- // a co-routine.
- void vUART_ISR( void )
- {
- char cRxedChar;
- portBASE_TYPE xCRWokenByPost = pdFALSE;
-
-     // We loop around reading characters until there are none left in the UART.
-     while( UART_RX_REG_NOT_EMPTY() )
-     {
-         // Obtain the character from the UART.
-         cRxedChar = UART_RX_REG;
-
-         // Post the character onto a queue.  xCRWokenByPost will be pdFALSE
-         // the first time around the loop.  If the post causes a co-routine
-         // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
-         // In this manner we can ensure that if more than one co-routine is
-         // blocked on the queue only one is woken by this ISR no matter how
-         // many characters are posted to the queue.
-         xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
-     }
- }
- * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR - * \ingroup Tasks - */ -#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) - - -/** - * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            xQueueHandle pxQueue,
-                            void *pvBuffer,
-                            portBASE_TYPE * pxCoRoutineWoken
-                       )
- * - * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the - * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() - * functions used by tasks. - * - * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to - * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and - * xQueueReceiveFromISR() can only be used to pass data between a task and and - * ISR. - * - * crQUEUE_RECEIVE_FROM_ISR can only be called from an ISR to receive data - * from a queue that is being used from within a co-routine (a co-routine - * posted to the queue). - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvBuffer A pointer to a buffer into which the received item will be - * placed. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from the queue into - * pvBuffer. - * - * @param pxCoRoutineWoken A co-routine may be blocked waiting for space to become - * available on the queue. If crQUEUE_RECEIVE_FROM_ISR causes such a - * co-routine to unblock *pxCoRoutineWoken will get set to pdTRUE, otherwise - * *pxCoRoutineWoken will remain unchanged. - * - * @return pdTRUE an item was successfully received from the queue, otherwise - * pdFALSE. - * - * Example usage: -
- // A co-routine that posts a character to a queue then blocks for a fixed
- // period.  The character is incremented each time.
- static void vSendingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
- {
- // cChar holds its value while this co-routine is blocked and must therefore
- // be declared static.
- static char cCharToTx = 'a';
- portBASE_TYPE xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Send the next character to the queue.
-         crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
-
-         if( xResult == pdPASS )
-         {
-             // The character was successfully posted to the queue.
-         }
-		 else
-		 {
-			// Could not post the character to the queue.
-		 }
-
-         // Enable the UART Tx interrupt to cause an interrupt in this
-		 // hypothetical UART.  The interrupt will obtain the character
-		 // from the queue and send it.
-		 ENABLE_RX_INTERRUPT();
-
-		 // Increment to the next character then block for a fixed period.
-		 // cCharToTx will maintain its value across the delay as it is
-		 // declared static.
-		 cCharToTx++;
-		 if( cCharToTx > 'x' )
-		 {
-			cCharToTx = 'a';
-		 }
-		 crDELAY( 100 );
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to receive characters to send on a UART.
- void vUART_ISR( void )
- {
- char cCharToTx;
- portBASE_TYPE xCRWokenByPost = pdFALSE;
-
-     while( UART_TX_REG_EMPTY() )
-     {
-         // Are there any characters in the queue waiting to be sent?
-		 // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
-		 // is woken by the post - ensuring that only a single co-routine is
-		 // woken no matter how many times we go around this loop.
-         if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
-		 {
-			 SEND_CHARACTER( cCharToTx );
-		 }
-     }
- }
- * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR - * \ingroup Tasks - */ -#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) - -/* - * This function is intended for internal use by the co-routine macros only. - * The macro nature of the co-routine implementation requires that the - * prototype appears here. The function should not be used by application - * writers. - * - * Removes the current co-routine from its ready list and places it in the - * appropriate delayed list. - */ -void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList ); - -/* - * This function is intended for internal use by the queue implementation only. - * The function should not be used by application writers. - * - * Removes the highest priority co-routine from the event list and places it in - * the pending ready list. - */ -signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList ); - -#ifdef __cplusplus -} -#endif - -#endif /* CO_ROUTINE_H */ diff --git a/GD32F1/libraries/FreeRTOS/utility/heap_2.c b/GD32F1/libraries/FreeRTOS/utility/heap_2.c deleted file mode 100644 index d135d8f..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/heap_2.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -/* - * A sample implementation of pvPortMalloc() and vPortFree() that permits - * allocated blocks to be freed, but does not combine adjacent free blocks - * into a single larger block. - * - * See heap_1.c and heap_3.c for alternative implementations, and the memory - * management pages of http://www.FreeRTOS.org for more information. - */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* Allocate the memory for the heap. The struct is used to force byte -alignment without using any non-portable code. */ -static union xRTOS_HEAP -{ - #if portBYTE_ALIGNMENT == 8 - volatile portDOUBLE dDummy; - #else - volatile unsigned long ulDummy; - #endif - unsigned char ucHeap[ configTOTAL_HEAP_SIZE ]; -} xHeap; - -/* Define the linked list structure. This is used to link free blocks in order -of their size. */ -typedef struct A_BLOCK_LINK -{ - struct A_BLOCK_LINK *pxNextFreeBlock; /*<< The next free block in the list. */ - size_t xBlockSize; /*<< The size of the free block. */ -} xBlockLink; - - -static const unsigned short heapSTRUCT_SIZE = ( sizeof( xBlockLink ) + portBYTE_ALIGNMENT - ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) ); -#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) ) - -/* Create a couple of list links to mark the start and end of the list. */ -static xBlockLink xStart, xEnd; - -/* Keeps track of the number of free bytes remaining, but says nothing about -fragmentation. */ -static size_t xFreeBytesRemaining = configTOTAL_HEAP_SIZE; - -/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */ - -/* - * Insert a block into the list of free blocks - which is ordered by size of - * the block. Small blocks at the start of the list and large blocks at the end - * of the list. - */ -#define prvInsertBlockIntoFreeList( pxBlockToInsert ) \ -{ \ -xBlockLink *pxIterator; \ -size_t xBlockSize; \ - \ - xBlockSize = pxBlockToInsert->xBlockSize; \ - \ - /* Iterate through the list until a block is found that has a larger size */ \ - /* than the block we are inserting. */ \ - for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \ - { \ - /* There is nothing to do here - just iterate to the correct position. */ \ - } \ - \ - /* Update the list to include the block being inserted in the correct */ \ - /* position. */ \ - pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; \ - pxIterator->pxNextFreeBlock = pxBlockToInsert; \ -} -/*-----------------------------------------------------------*/ - -#define prvHeapInit() \ -{ \ -xBlockLink *pxFirstFreeBlock; \ - \ - /* xStart is used to hold a pointer to the first item in the list of free */ \ - /* blocks. The void cast is used to prevent compiler warnings. */ \ - xStart.pxNextFreeBlock = ( void * ) xHeap.ucHeap; \ - xStart.xBlockSize = ( size_t ) 0; \ - \ - /* xEnd is used to mark the end of the list of free blocks. */ \ - xEnd.xBlockSize = configTOTAL_HEAP_SIZE; \ - xEnd.pxNextFreeBlock = NULL; \ - \ - /* To start with there is a single free block that is sized to take up the \ - entire heap space. */ \ - pxFirstFreeBlock = ( void * ) xHeap.ucHeap; \ - pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE; \ - pxFirstFreeBlock->pxNextFreeBlock = &xEnd; \ -} -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -xBlockLink *pxBlock, *pxPreviousBlock, *pxNewBlockLink; -static portBASE_TYPE xHeapHasBeenInitialised = pdFALSE; -void *pvReturn = NULL; - - vTaskSuspendAll(); - { - /* If this is the first call to malloc then the heap will require - initialisation to setup the list of free blocks. */ - if( xHeapHasBeenInitialised == pdFALSE ) - { - prvHeapInit(); - xHeapHasBeenInitialised = pdTRUE; - } - - /* The wanted size is increased so it can contain a xBlockLink - structure in addition to the requested amount of bytes. */ - if( xWantedSize > 0 ) - { - xWantedSize += heapSTRUCT_SIZE; - - /* Ensure that blocks are always aligned to the required number of bytes. */ - if( xWantedSize & portBYTE_ALIGNMENT_MASK ) - { - /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - } - } - - if( ( xWantedSize > 0 ) && ( xWantedSize < configTOTAL_HEAP_SIZE ) ) - { - /* Blocks are stored in byte order - traverse the list from the start - (smallest) block until one of adequate size is found. */ - pxPreviousBlock = &xStart; - pxBlock = xStart.pxNextFreeBlock; - while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock ) ) - { - pxPreviousBlock = pxBlock; - pxBlock = pxBlock->pxNextFreeBlock; - } - - /* If we found the end marker then a block of adequate size was not found. */ - if( pxBlock != &xEnd ) - { - /* Return the memory space - jumping over the xBlockLink structure - at its start. */ - pvReturn = ( void * ) ( ( ( unsigned char * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE ); - - /* This block is being returned for use so must be taken our of the - list of free blocks. */ - pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; - - /* If the block is larger than required it can be split into two. */ - if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) - { - /* This block is to be split into two. Create a new block - following the number of bytes requested. The void cast is - used to prevent byte alignment warnings from the compiler. */ - pxNewBlockLink = ( void * ) ( ( ( unsigned char * ) pxBlock ) + xWantedSize ); - - /* Calculate the sizes of two blocks split from the single - block. */ - pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; - pxBlock->xBlockSize = xWantedSize; - - /* Insert the new block into the list of free blocks. */ - prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); - } - - xFreeBytesRemaining -= pxBlock->xBlockSize; - } - } - } - xTaskResumeAll(); - - #if( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - } - #endif - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ -unsigned char *puc = ( unsigned char * ) pv; -xBlockLink *pxLink; - - if( pv ) - { - /* The memory being freed will have an xBlockLink structure immediately - before it. */ - puc -= heapSTRUCT_SIZE; - - /* This casting is to keep the compiler from issuing warnings. */ - pxLink = ( void * ) puc; - - vTaskSuspendAll(); - { - /* Add this block to the list of free blocks. */ - prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) ); - xFreeBytesRemaining += pxLink->xBlockSize; - } - xTaskResumeAll(); - } -} -/*-----------------------------------------------------------*/ - -size_t xPortGetFreeHeapSize( void ) -{ - return xFreeBytesRemaining; -} -/*-----------------------------------------------------------*/ - -void vPortInitialiseBlocks( void ) -{ - /* This just exists to keep the linker quiet. */ -} diff --git a/GD32F1/libraries/FreeRTOS/utility/list.c b/GD32F1/libraries/FreeRTOS/utility/list.c deleted file mode 100644 index 872b7dd..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/list.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - - -#include -#include "FreeRTOS.h" -#include "list.h" - -/*----------------------------------------------------------- - * PUBLIC LIST API documented in list.h - *----------------------------------------------------------*/ - -void vListInitialise( xList *pxList ) -{ - /* The list structure contains a list item which is used to mark the - end of the list. To initialise the list the list end is inserted - as the only list entry. */ - pxList->pxIndex = ( xListItem * ) &( pxList->xListEnd ); - - /* The list end value is the highest possible value in the list to - ensure it remains at the end of the list. */ - pxList->xListEnd.xItemValue = portMAX_DELAY; - - /* The list end next and previous pointers point to itself so we know - when the list is empty. */ - pxList->xListEnd.pxNext = ( xListItem * ) &( pxList->xListEnd ); - pxList->xListEnd.pxPrevious = ( xListItem * ) &( pxList->xListEnd ); - - pxList->uxNumberOfItems = ( unsigned portBASE_TYPE ) 0U; -} -/*-----------------------------------------------------------*/ - -void vListInitialiseItem( xListItem *pxItem ) -{ - /* Make sure the list item is not recorded as being on a list. */ - pxItem->pvContainer = NULL; -} -/*-----------------------------------------------------------*/ - -void vListInsertEnd( xList *pxList, xListItem *pxNewListItem ) -{ -volatile xListItem * pxIndex; - - /* Insert a new list item into pxList, but rather than sort the list, - makes the new list item the last item to be removed by a call to - pvListGetOwnerOfNextEntry. This means it has to be the item pointed to by - the pxIndex member. */ - pxIndex = pxList->pxIndex; - - pxNewListItem->pxNext = pxIndex->pxNext; - pxNewListItem->pxPrevious = pxList->pxIndex; - pxIndex->pxNext->pxPrevious = ( volatile xListItem * ) pxNewListItem; - pxIndex->pxNext = ( volatile xListItem * ) pxNewListItem; - pxList->pxIndex = ( volatile xListItem * ) pxNewListItem; - - /* Remember which list the item is in. */ - pxNewListItem->pvContainer = ( void * ) pxList; - - ( pxList->uxNumberOfItems )++; -} -/*-----------------------------------------------------------*/ - -void vListInsert( xList *pxList, xListItem *pxNewListItem ) -{ -volatile xListItem *pxIterator; -portTickType xValueOfInsertion; - - /* Insert the new list item into the list, sorted in ulListItem order. */ - xValueOfInsertion = pxNewListItem->xItemValue; - - /* If the list already contains a list item with the same item value then - the new list item should be placed after it. This ensures that TCB's which - are stored in ready lists (all of which have the same ulListItem value) - get an equal share of the CPU. However, if the xItemValue is the same as - the back marker the iteration loop below will not end. This means we need - to guard against this by checking the value first and modifying the - algorithm slightly if necessary. */ - if( xValueOfInsertion == portMAX_DELAY ) - { - pxIterator = pxList->xListEnd.pxPrevious; - } - else - { - /* *** NOTE *********************************************************** - If you find your application is crashing here then likely causes are: - 1) Stack overflow - - see http://www.freertos.org/Stacks-and-stack-overflow-checking.html - 2) Incorrect interrupt priority assignment, especially on Cortex-M3 - parts where numerically high priority values denote low actual - interrupt priories, which can seem counter intuitive. See - configMAX_SYSCALL_INTERRUPT_PRIORITY on http://www.freertos.org/a00110.html - 3) Calling an API function from within a critical section or when - the scheduler is suspended. - 4) Using a queue or semaphore before it has been initialised or - before the scheduler has been started (are interrupts firing - before vTaskStartScheduler() has been called?). - See http://www.freertos.org/FAQHelp.html for more tips. - **********************************************************************/ - - for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) - { - /* There is nothing to do here, we are just iterating to the - wanted insertion position. */ - } - } - - pxNewListItem->pxNext = pxIterator->pxNext; - pxNewListItem->pxNext->pxPrevious = ( volatile xListItem * ) pxNewListItem; - pxNewListItem->pxPrevious = pxIterator; - pxIterator->pxNext = ( volatile xListItem * ) pxNewListItem; - - /* Remember which list the item is in. This allows fast removal of the - item later. */ - pxNewListItem->pvContainer = ( void * ) pxList; - - ( pxList->uxNumberOfItems )++; -} -/*-----------------------------------------------------------*/ - -void vListRemove( xListItem *pxItemToRemove ) -{ -xList * pxList; - - pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious; - pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext; - - /* The list item knows which list it is in. Obtain the list from the list - item. */ - pxList = ( xList * ) pxItemToRemove->pvContainer; - - /* Make sure the index is left pointing to a valid item. */ - if( pxList->pxIndex == pxItemToRemove ) - { - pxList->pxIndex = pxItemToRemove->pxPrevious; - } - - pxItemToRemove->pvContainer = NULL; - ( pxList->uxNumberOfItems )--; -} -/*-----------------------------------------------------------*/ - diff --git a/GD32F1/libraries/FreeRTOS/utility/list.h b/GD32F1/libraries/FreeRTOS/utility/list.h deleted file mode 100644 index 01e69cb..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/list.h +++ /dev/null @@ -1,314 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -/* - * This is the list implementation used by the scheduler. While it is tailored - * heavily for the schedulers needs, it is also available for use by - * application code. - * - * xLists can only store pointers to xListItems. Each xListItem contains a - * numeric value (xItemValue). Most of the time the lists are sorted in - * descending item value order. - * - * Lists are created already containing one list item. The value of this - * item is the maximum possible that can be stored, it is therefore always at - * the end of the list and acts as a marker. The list member pxHead always - * points to this marker - even though it is at the tail of the list. This - * is because the tail contains a wrap back pointer to the true head of - * the list. - * - * In addition to it's value, each list item contains a pointer to the next - * item in the list (pxNext), a pointer to the list it is in (pxContainer) - * and a pointer to back to the object that contains it. These later two - * pointers are included for efficiency of list manipulation. There is - * effectively a two way link between the object containing the list item and - * the list item itself. - * - * - * \page ListIntroduction List Implementation - * \ingroup FreeRTOSIntro - */ - - -#ifndef LIST_H -#define LIST_H - -#ifdef __cplusplus -extern "C" { -#endif -/* - * Definition of the only type of object that a list can contain. - */ -struct xLIST_ITEM -{ - portTickType xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ - volatile struct xLIST_ITEM * pxNext; /*< Pointer to the next xListItem in the list. */ - volatile struct xLIST_ITEM * pxPrevious;/*< Pointer to the previous xListItem in the list. */ - void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ - void * pvContainer; /*< Pointer to the list in which this list item is placed (if any). */ -}; -typedef struct xLIST_ITEM xListItem; /* For some reason lint wants this as two separate definitions. */ - -struct xMINI_LIST_ITEM -{ - portTickType xItemValue; - volatile struct xLIST_ITEM *pxNext; - volatile struct xLIST_ITEM *pxPrevious; -}; -typedef struct xMINI_LIST_ITEM xMiniListItem; - -/* - * Definition of the type of queue used by the scheduler. - */ -typedef struct xLIST -{ - volatile unsigned portBASE_TYPE uxNumberOfItems; - volatile xListItem * pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to pvListGetOwnerOfNextEntry (). */ - volatile xMiniListItem xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ -} xList; - -/* - * Access macro to set the owner of a list item. The owner of a list item - * is the object (usually a TCB) that contains the list item. - * - * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER - * \ingroup LinkedList - */ -#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) - -/* - * Access macro to set the value of the list item. In most cases the value is - * used to sort the list in descending order. - * - * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE - * \ingroup LinkedList - */ -#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( pxListItem )->xItemValue = ( xValue ) - -/* - * Access macro the retrieve the value of the list item. The value can - * represent anything - for example a the priority of a task, or the time at - * which a task should be unblocked. - * - * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE - * \ingroup LinkedList - */ -#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) - -/* - * Access macro the retrieve the value of the list item at the head of a given - * list. - * - * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE - * \ingroup LinkedList - */ -#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->xItemValue ) - -/* - * Access macro to determine if a list contains any items. The macro will - * only have the value true if the list is empty. - * - * \page listLIST_IS_EMPTY listLIST_IS_EMPTY - * \ingroup LinkedList - */ -#define listLIST_IS_EMPTY( pxList ) ( ( pxList )->uxNumberOfItems == ( unsigned portBASE_TYPE ) 0 ) - -/* - * Access macro to return the number of items in the list. - */ -#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) - -/* - * Access function to obtain the owner of the next entry in a list. - * - * The list member pxIndex is used to walk through a list. Calling - * listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list - * and returns that entries pxOwner parameter. Using multiple calls to this - * function it is therefore possible to move through every item contained in - * a list. - * - * The pxOwner parameter of a list item is a pointer to the object that owns - * the list item. In the scheduler this is normally a task control block. - * The pxOwner parameter effectively creates a two way link between the list - * item and its owner. - * - * @param pxList The list from which the next item owner is to be returned. - * - * \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY - * \ingroup LinkedList - */ -#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ -{ \ -xList * const pxConstList = ( pxList ); \ - /* Increment the index to the next item and return the item, ensuring */ \ - /* we don't return the marker used at the end of the list. */ \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - if( ( pxConstList )->pxIndex == ( xListItem * ) &( ( pxConstList )->xListEnd ) ) \ - { \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - } \ - ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ -} - - -/* - * Access function to obtain the owner of the first entry in a list. Lists - * are normally sorted in ascending item value order. - * - * This function returns the pxOwner member of the first item in the list. - * The pxOwner parameter of a list item is a pointer to the object that owns - * the list item. In the scheduler this is normally a task control block. - * The pxOwner parameter effectively creates a two way link between the list - * item and its owner. - * - * @param pxList The list from which the owner of the head item is to be - * returned. - * - * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY - * \ingroup LinkedList - */ -#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner ) - -/* - * Check to see if a list item is within a list. The list item maintains a - * "container" pointer that points to the list it is in. All this macro does - * is check to see if the container and the list match. - * - * @param pxList The list we want to know if the list item is within. - * @param pxListItem The list item we want to know if is in the list. - * @return pdTRUE is the list item is in the list, otherwise pdFALSE. - * pointer against - */ -#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( pxListItem )->pvContainer == ( void * ) ( pxList ) ) - -/* - * Must be called before a list is used! This initialises all the members - * of the list structure and inserts the xListEnd item into the list as a - * marker to the back of the list. - * - * @param pxList Pointer to the list being initialised. - * - * \page vListInitialise vListInitialise - * \ingroup LinkedList - */ -void vListInitialise( xList *pxList ); - -/* - * Must be called before a list item is used. This sets the list container to - * null so the item does not think that it is already contained in a list. - * - * @param pxItem Pointer to the list item being initialised. - * - * \page vListInitialiseItem vListInitialiseItem - * \ingroup LinkedList - */ -void vListInitialiseItem( xListItem *pxItem ); - -/* - * Insert a list item into a list. The item will be inserted into the list in - * a position determined by its item value (descending item value order). - * - * @param pxList The list into which the item is to be inserted. - * - * @param pxNewListItem The item to that is to be placed in the list. - * - * \page vListInsert vListInsert - * \ingroup LinkedList - */ -void vListInsert( xList *pxList, xListItem *pxNewListItem ); - -/* - * Insert a list item into a list. The item will be inserted in a position - * such that it will be the last item within the list returned by multiple - * calls to listGET_OWNER_OF_NEXT_ENTRY. - * - * The list member pvIndex is used to walk through a list. Calling - * listGET_OWNER_OF_NEXT_ENTRY increments pvIndex to the next item in the list. - * Placing an item in a list using vListInsertEnd effectively places the item - * in the list position pointed to by pvIndex. This means that every other - * item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before - * the pvIndex parameter again points to the item being inserted. - * - * @param pxList The list into which the item is to be inserted. - * - * @param pxNewListItem The list item to be inserted into the list. - * - * \page vListInsertEnd vListInsertEnd - * \ingroup LinkedList - */ -void vListInsertEnd( xList *pxList, xListItem *pxNewListItem ); - -/* - * Remove an item from a list. The list item has a pointer to the list that - * it is in, so only the list item need be passed into the function. - * - * @param vListRemove The item to be removed. The item will remove itself from - * the list pointed to by it's pxContainer parameter. - * - * \page vListRemove vListRemove - * \ingroup LinkedList - */ -void vListRemove( xListItem *pxItemToRemove ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/GD32F1/libraries/FreeRTOS/utility/mpu_wrappers.h b/GD32F1/libraries/FreeRTOS/utility/mpu_wrappers.h deleted file mode 100644 index a0c2723..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/mpu_wrappers.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#ifndef MPU_WRAPPERS_H -#define MPU_WRAPPERS_H - -/* This file redefines API functions to be called through a wrapper macro, but -only for ports that are using the MPU. */ -#ifdef portUSING_MPU_WRAPPERS - - /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is - included from queue.c or task.c to prevent it from having an effect within - those files. */ - #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - - #define xTaskGenericCreate MPU_xTaskGenericCreate - #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions - #define vTaskDelete MPU_vTaskDelete - #define vTaskDelayUntil MPU_vTaskDelayUntil - #define vTaskDelay MPU_vTaskDelay - #define uxTaskPriorityGet MPU_uxTaskPriorityGet - #define vTaskPrioritySet MPU_vTaskPrioritySet - #define vTaskSuspend MPU_vTaskSuspend - #define xTaskIsTaskSuspended MPU_xTaskIsTaskSuspended - #define vTaskResume MPU_vTaskResume - #define vTaskSuspendAll MPU_vTaskSuspendAll - #define xTaskResumeAll MPU_xTaskResumeAll - #define xTaskGetTickCount MPU_xTaskGetTickCount - #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks - #define vTaskList MPU_vTaskList - #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats - #define vTaskStartTrace MPU_vTaskStartTrace - #define ulTaskEndTrace MPU_ulTaskEndTrace - #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag - #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag - #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook - #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark - #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle - #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState - - #define xQueueCreate MPU_xQueueCreate - #define xQueueCreateMutex MPU_xQueueCreateMutex - #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive - #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive - #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore - #define xQueueGenericSend MPU_xQueueGenericSend - #define xQueueAltGenericSend MPU_xQueueAltGenericSend - #define xQueueAltGenericReceive MPU_xQueueAltGenericReceive - #define xQueueGenericReceive MPU_xQueueGenericReceive - #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting - #define vQueueDelete MPU_vQueueDelete - - #define pvPortMalloc MPU_pvPortMalloc - #define vPortFree MPU_vPortFree - #define xPortGetFreeHeapSize MPU_xPortGetFreeHeapSize - #define vPortInitialiseBlocks MPU_vPortInitialiseBlocks - - #if configQUEUE_REGISTRY_SIZE > 0 - #define vQueueAddToRegistry MPU_vQueueAddToRegistry - #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue - #endif - - /* Remove the privileged function macro. */ - #define PRIVILEGED_FUNCTION - - #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - - /* Ensure API functions go in the privileged execution section. */ - #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - //#define PRIVILEGED_DATA - - #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - -#else /* portUSING_MPU_WRAPPERS */ - - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA - #define portUSING_MPU_WRAPPERS 0 - -#endif /* portUSING_MPU_WRAPPERS */ - - -#endif /* MPU_WRAPPERS_H */ - diff --git a/GD32F1/libraries/FreeRTOS/utility/port.c b/GD32F1/libraries/FreeRTOS/utility/port.c deleted file mode 100644 index dc01720..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/port.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -/*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the ARM CM3 port. - *----------------------------------------------------------*/ - -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" - -/* For backward compatibility, ensure configKERNEL_INTERRUPT_PRIORITY is -defined. The value should also ensure backward compatibility. -FreeRTOS.org versions prior to V4.4.0 did not include this definition. */ -#ifndef configKERNEL_INTERRUPT_PRIORITY - #define configKERNEL_INTERRUPT_PRIORITY 255 -#endif - -/* Constants required to manipulate the NVIC. */ -#define portNVIC_SYSTICK_CTRL ( ( volatile unsigned long *) 0xe000e010 ) -#define portNVIC_SYSTICK_LOAD ( ( volatile unsigned long *) 0xe000e014 ) -#define portNVIC_INT_CTRL ( ( volatile unsigned long *) 0xe000ed04 ) -#define portNVIC_SYSPRI2 ( ( volatile unsigned long *) 0xe000ed20 ) -#define portNVIC_SYSTICK_CLK 0x00000004 -#define portNVIC_SYSTICK_INT 0x00000002 -#define portNVIC_SYSTICK_ENABLE 0x00000001 -#define portNVIC_PENDSVSET 0x10000000 -#define portNVIC_PENDSV_PRI ( ( ( unsigned long ) configKERNEL_INTERRUPT_PRIORITY ) << 16 ) -#define portNVIC_SYSTICK_PRI ( ( ( unsigned long ) configKERNEL_INTERRUPT_PRIORITY ) << 24 ) - -/* Constants required to set up the initial stack. */ -#define portINITIAL_XPSR ( 0x01000000 ) - -/* The priority used by the kernel is assigned to a variable to make access -from inline assembler easier. */ -const unsigned long ulKernelPriority = configKERNEL_INTERRUPT_PRIORITY; - -/* Each task maintains its own interrupt status in the critical nesting -variable. */ -static unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa; - -/* - * Setup the timer to generate the tick interrupts. - */ -static void prvSetupTimerInterrupt( void ); - -/* - * Exception handlers. - */ -void xPortPendSVHandler( void ) __attribute__ (( naked )); -void xPortSysTickHandler( void ); -void vPortSVCHandler( void ) __attribute__ (( naked )); - -/* - * Start first task is a separate function so it can be tested in isolation. - */ -void vPortStartFirstTask( void ) __attribute__ (( naked )); - -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ) -{ - /* Simulate the stack frame as it would be created by a context switch - interrupt. */ - pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ - *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ - pxTopOfStack--; - *pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */ - pxTopOfStack--; - *pxTopOfStack = 0; /* LR */ - pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ - *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */ - pxTopOfStack -= 8; /* R11, R10, R9, R8, R7, R6, R5 and R4. */ - - return pxTopOfStack; -} -/*-----------------------------------------------------------*/ - -// !!! Maple -// void vPortSVCHandler( void ) -void __exc_svc( void ) -// !!! Maple -{ - __asm volatile ( - " ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */ - " ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */ - " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */ - " ldmia r0!, {r4-r11} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */ - " msr psp, r0 \n" /* Restore the task stack pointer. */ - " mov r0, #0 \n" - " msr basepri, r0 \n" - " orr r14, #0xd \n" - " bx r14 \n" - " \n" - " .align 2 \n" - "pxCurrentTCBConst2: .word pxCurrentTCB \n" - ); -} -/*-----------------------------------------------------------*/ - -void vPortStartFirstTask( void ) -{ - __asm volatile( - " ldr r0, =0xE000ED08 \n" /* Use the NVIC offset register to locate the stack. */ - " ldr r0, [r0] \n" - " ldr r0, [r0] \n" - " msr msp, r0 \n" /* Set the msp back to the start of the stack. */ - " cpsie i \n" /* Globally enable interrupts. */ - " svc 0 \n" /* System call to start first task. */ - " nop \n" - ); -} -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -portBASE_TYPE xPortStartScheduler( void ) -{ - /* Make PendSV, CallSV and SysTick the same priroity as the kernel. */ - *(portNVIC_SYSPRI2) |= portNVIC_PENDSV_PRI; - *(portNVIC_SYSPRI2) |= portNVIC_SYSTICK_PRI; - -// !!! Maple - systick_attach_callback(&xPortSysTickHandler); -// /* Start the timer that generates the tick ISR. Interrupts are disabled -// here already. */ -// prvSetupTimerInterrupt(); -// !!! Maple - - /* Initialise the critical nesting count ready for the first task. */ - uxCriticalNesting = 0; - - /* Start the first task. */ - vPortStartFirstTask(); - - /* Should not get here! */ - return 0; -} -/*-----------------------------------------------------------*/ - -void vPortEndScheduler( void ) -{ - /* It is unlikely that the CM3 port will require this function as there - is nothing to return to. */ -} -/*-----------------------------------------------------------*/ - -void vPortYieldFromISR( void ) -{ - /* Set a PendSV to request a context switch. */ - *(portNVIC_INT_CTRL) = portNVIC_PENDSVSET; -} -/*-----------------------------------------------------------*/ - -void vPortEnterCritical( void ) -{ - portDISABLE_INTERRUPTS(); - uxCriticalNesting++; -} -/*-----------------------------------------------------------*/ - -void vPortExitCritical( void ) -{ - uxCriticalNesting--; - if( uxCriticalNesting == 0 ) - { - portENABLE_INTERRUPTS(); - } -} -/*-----------------------------------------------------------*/ - -// !!! Maple -// void xPortPendSVHandler( void ) -void __exc_pendsv( void ) -// !!! Maple -{ - /* This is a naked function. */ - - __asm volatile - ( - " mrs r0, psp \n" - " \n" - " ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */ - " ldr r2, [r3] \n" - " \n" - " stmdb r0!, {r4-r11} \n" /* Save the remaining registers. */ - " str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */ - " \n" - " stmdb sp!, {r3, r14} \n" - " mov r0, %0 \n" - " msr basepri, r0 \n" - " bl vTaskSwitchContext \n" - " mov r0, #0 \n" - " msr basepri, r0 \n" - " ldmia sp!, {r3, r14} \n" - " \n" /* Restore the context, including the critical nesting count. */ - " ldr r1, [r3] \n" - " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */ - " ldmia r0!, {r4-r11} \n" /* Pop the registers. */ - " msr psp, r0 \n" - " bx r14 \n" - " \n" - " .align 2 \n" - "pxCurrentTCBConst: .word pxCurrentTCB \n" - ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) - ); -} -/*-----------------------------------------------------------*/ - -void xPortSysTickHandler( void ) -{ -unsigned long ulDummy; - - /* If using preemption, also force a context switch. */ - #if configUSE_PREEMPTION == 1 - *(portNVIC_INT_CTRL) = portNVIC_PENDSVSET; - #endif - - ulDummy = portSET_INTERRUPT_MASK_FROM_ISR(); - { - vTaskIncrementTick(); - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( ulDummy ); -} -/*-----------------------------------------------------------*/ - -/* - * Setup the systick timer to generate the tick interrupts at the required - * frequency. - */ -void prvSetupTimerInterrupt( void ) -{ - /* Configure SysTick to interrupt at the requested rate. */ - *(portNVIC_SYSTICK_LOAD) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; - *(portNVIC_SYSTICK_CTRL) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE; -} -/*-----------------------------------------------------------*/ - diff --git a/GD32F1/libraries/FreeRTOS/utility/portable.h b/GD32F1/libraries/FreeRTOS/utility/portable.h deleted file mode 100644 index b48a675..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/portable.h +++ /dev/null @@ -1,396 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -/*----------------------------------------------------------- - * Portable layer API. Each function must be defined for each port. - *----------------------------------------------------------*/ - -#ifndef PORTABLE_H -#define PORTABLE_H - -/* Include the macro file relevant to the port being used. */ - -#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT - #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); -#endif - -#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT - #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); -#endif - -#ifdef GCC_MEGA_AVR - #include "../portable/GCC/ATMega323/portmacro.h" -#endif - -#ifdef IAR_MEGA_AVR - #include "../portable/IAR/ATMega323/portmacro.h" -#endif - -#ifdef MPLAB_PIC24_PORT - #include "..\..\Source\portable\MPLAB\PIC24_dsPIC\portmacro.h" -#endif - -#ifdef MPLAB_DSPIC_PORT - #include "..\..\Source\portable\MPLAB\PIC24_dsPIC\portmacro.h" -#endif - -#ifdef MPLAB_PIC18F_PORT - #include "..\..\Source\portable\MPLAB\PIC18F\portmacro.h" -#endif - -#ifdef MPLAB_PIC32MX_PORT - #include "..\..\Source\portable\MPLAB\PIC32MX\portmacro.h" -#endif - -#ifdef _FEDPICC - #include "libFreeRTOS/Include/portmacro.h" -#endif - -#ifdef SDCC_CYGNAL - #include "../../Source/portable/SDCC/Cygnal/portmacro.h" -#endif - -#ifdef GCC_ARM7 - #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" -#endif - -#ifdef GCC_ARM7_ECLIPSE - #include "portmacro.h" -#endif - -#ifdef ROWLEY_LPC23xx - #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" -#endif - -#ifdef IAR_MSP430 - #include "..\..\Source\portable\IAR\MSP430\portmacro.h" -#endif - -#ifdef GCC_MSP430 - #include "../../Source/portable/GCC/MSP430F449/portmacro.h" -#endif - -#ifdef ROWLEY_MSP430 - #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" -#endif - -#ifdef ARM7_LPC21xx_KEIL_RVDS - #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" -#endif - -#ifdef SAM7_GCC - #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" -#endif - -#ifdef SAM7_IAR - #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" -#endif - -#ifdef SAM9XE_IAR - #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" -#endif - -#ifdef LPC2000_IAR - #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" -#endif - -#ifdef STR71X_IAR - #include "..\..\Source\portable\IAR\STR71x\portmacro.h" -#endif - -#ifdef STR75X_IAR - #include "..\..\Source\portable\IAR\STR75x\portmacro.h" -#endif - -#ifdef STR75X_GCC - #include "..\..\Source\portable\GCC\STR75x\portmacro.h" -#endif - -#ifdef STR91X_IAR - #include "..\..\Source\portable\IAR\STR91x\portmacro.h" -#endif - -#ifdef GCC_H8S - #include "../../Source/portable/GCC/H8S2329/portmacro.h" -#endif - -#ifdef GCC_AT91FR40008 - #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" -#endif - -#ifdef RVDS_ARMCM3_LM3S102 - #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" -#endif - -#ifdef GCC_ARMCM3_LM3S102 - #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" -#endif - -#ifdef GCC_ARMCM3 - #include "portmacro.h" -#endif - -#ifdef IAR_ARM_CM3 - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" -#endif - -#ifdef IAR_ARMCM3_LM - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" -#endif - -#ifdef HCS12_CODE_WARRIOR - #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" -#endif - -#ifdef MICROBLAZE_GCC - #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" -#endif - -#ifdef TERN_EE - #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" -#endif - -#ifdef GCC_HCS12 - #include "../../Source/portable/GCC/HCS12/portmacro.h" -#endif - -#ifdef GCC_MCF5235 - #include "../../Source/portable/GCC/MCF5235/portmacro.h" -#endif - -#ifdef COLDFIRE_V2_GCC - #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" -#endif - -#ifdef COLDFIRE_V2_CODEWARRIOR - #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" -#endif - -#ifdef GCC_PPC405 - #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" -#endif - -#ifdef GCC_PPC440 - #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" -#endif - -#ifdef _16FX_SOFTUNE - #include "..\..\Source\portable\Softune\MB96340\portmacro.h" -#endif - -#ifdef BCC_INDUSTRIAL_PC_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); -#endif - -#ifdef BCC_FLASH_LITE_186_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); -#endif - -#ifdef __GNUC__ - #ifdef __AVR32_AVR32A__ - #include "portmacro.h" - #endif -#endif - -#ifdef __ICCAVR32__ - #ifdef __CORE__ - #if __CORE__ == __AVR32A__ - #include "portmacro.h" - #endif - #endif -#endif - -#ifdef __91467D - #include "portmacro.h" -#endif - -#ifdef __96340 - #include "portmacro.h" -#endif - - -#ifdef __IAR_V850ES_Fx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_V850ES_Jx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_V850ES_Jx3_L__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_V850ES_Jx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_V850ES_Hx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_78K0R_Kx3__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" -#endif - -#ifdef __IAR_78K0R_Kx3L__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" -#endif - -/* Catch all to ensure portmacro.h is included in the build. Newer demos -have the path as part of the project options, rather than as relative from -the project location. If portENTER_CRITICAL() has not been defined then -portmacro.h has not yet been included - as every portmacro.h provides a -portENTER_CRITICAL() definition. Check the demo application for your demo -to find the path to the correct portmacro.h file. */ -#ifndef portENTER_CRITICAL - #include "portmacro.h" -#endif - -#if portBYTE_ALIGNMENT == 8 - #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) -#endif - -#if portBYTE_ALIGNMENT == 4 - #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) -#endif - -#if portBYTE_ALIGNMENT == 2 - #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) -#endif - -#if portBYTE_ALIGNMENT == 1 - #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) -#endif - -#ifndef portBYTE_ALIGNMENT_MASK - #error "Invalid portBYTE_ALIGNMENT definition" -#endif - -#ifndef portNUM_CONFIGURABLE_REGIONS - #define portNUM_CONFIGURABLE_REGIONS 1 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include "mpu_wrappers.h" - -/* - * Setup the stack of a new task so it is ready to be placed under the - * scheduler control. The registers have to be placed on the stack in - * the order that the port expects to find them. - * - */ -#if( portUSING_MPU_WRAPPERS == 1 ) - portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters, portBASE_TYPE xRunPrivileged ) PRIVILEGED_FUNCTION; -#else - portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ); -#endif - -/* - * Map to the memory management routines required for the port. - */ -void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; -void vPortFree( void *pv ) PRIVILEGED_FUNCTION; -void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; -size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; - -/* - * Setup the hardware ready for the scheduler to take control. This generally - * sets up a tick interrupt and sets timers for the correct tick frequency. - */ -portBASE_TYPE xPortStartScheduler( void ) PRIVILEGED_FUNCTION; - -/* - * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so - * the hardware is left in its original condition after the scheduler stops - * executing. - */ -void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; - -/* - * The structures and methods of manipulating the MPU are contained within the - * port layer. - * - * Fills the xMPUSettings structure with the memory region information - * contained in xRegions. - */ -#if( portUSING_MPU_WRAPPERS == 1 ) - struct xMEMORY_REGION; - void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, portSTACK_TYPE *pxBottomOfStack, unsigned short usStackDepth ) PRIVILEGED_FUNCTION; -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* PORTABLE_H */ - diff --git a/GD32F1/libraries/FreeRTOS/utility/portmacro.h b/GD32F1/libraries/FreeRTOS/utility/portmacro.h deleted file mode 100644 index 7f2d1af..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/portmacro.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*----------------------------------------------------------- - * Port specific definitions. - * - * The settings in this file configure FreeRTOS correctly for the - * given hardware and compiler. - * - * These settings should not be altered. - *----------------------------------------------------------- - */ - -/* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE unsigned portLONG -#define portBASE_TYPE long - -#if( configUSE_16_BIT_TICKS == 1 ) - typedef unsigned portSHORT portTickType; - #define portMAX_DELAY ( portTickType ) 0xffff -#else - typedef unsigned portLONG portTickType; - #define portMAX_DELAY ( portTickType ) 0xffffffff -#endif -/*-----------------------------------------------------------*/ - -/* Architecture specifics. */ -#define portSTACK_GROWTH ( -1 ) -#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 8 -/*-----------------------------------------------------------*/ - - -/* Scheduler utilities. */ -extern void vPortYieldFromISR( void ); - -#define portYIELD() vPortYieldFromISR() - -#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYieldFromISR() -/*-----------------------------------------------------------*/ - - -/* Critical section management. */ - -/* - * Set basepri to portMAX_SYSCALL_INTERRUPT_PRIORITY without effecting other - * registers. r0 is clobbered. - */ -#define portSET_INTERRUPT_MASK() \ - __asm volatile \ - ( \ - " mov r0, %0 \n" \ - " msr basepri, r0 \n" \ - ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY):"r0" \ - ) - -/* - * Set basepri back to 0 without effective other registers. - * r0 is clobbered. - */ -#define portCLEAR_INTERRUPT_MASK() \ - __asm volatile \ - ( \ - " mov r0, #0 \n" \ - " msr basepri, r0 \n" \ - :::"r0" \ - ) - -#define portSET_INTERRUPT_MASK_FROM_ISR() 0;portSET_INTERRUPT_MASK() -#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) portCLEAR_INTERRUPT_MASK();(void)x - - -extern void vPortEnterCritical( void ); -extern void vPortExitCritical( void ); - -#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK() -#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK() -#define portENTER_CRITICAL() vPortEnterCritical() -#define portEXIT_CRITICAL() vPortExitCritical() -/*-----------------------------------------------------------*/ - -/* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) -#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) - -#define portNOP() - -#ifdef __cplusplus -} -#endif - -#endif /* PORTMACRO_H */ - diff --git a/GD32F1/libraries/FreeRTOS/utility/projdefs.h b/GD32F1/libraries/FreeRTOS/utility/projdefs.h deleted file mode 100644 index 18366fa..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/projdefs.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#ifndef PROJDEFS_H -#define PROJDEFS_H - -/* Defines the prototype to which task functions must conform. */ -typedef void (*pdTASK_CODE)( void * ); - -#define pdTRUE ( 1 ) -#define pdFALSE ( 0 ) - -#define pdPASS ( 1 ) -#define pdFAIL ( 0 ) -#define errQUEUE_EMPTY ( 0 ) -#define errQUEUE_FULL ( 0 ) - -/* Error definitions. */ -#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) -#define errNO_TASK_TO_RUN ( -2 ) -#define errQUEUE_BLOCKED ( -4 ) -#define errQUEUE_YIELD ( -5 ) - -#endif /* PROJDEFS_H */ - - - diff --git a/GD32F1/libraries/FreeRTOS/utility/queue.c b/GD32F1/libraries/FreeRTOS/utility/queue.c deleted file mode 100644 index c7ed600..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/queue.c +++ /dev/null @@ -1,1539 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#include -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" -#include "croutine.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/*----------------------------------------------------------- - * PUBLIC LIST API documented in list.h - *----------------------------------------------------------*/ - -/* Constants used with the cRxLock and cTxLock structure members. */ -#define queueUNLOCKED ( ( signed portBASE_TYPE ) -1 ) -#define queueLOCKED_UNMODIFIED ( ( signed portBASE_TYPE ) 0 ) - -#define queueERRONEOUS_UNBLOCK ( -1 ) - -/* For internal use only. */ -#define queueSEND_TO_BACK ( 0 ) -#define queueSEND_TO_FRONT ( 1 ) - -/* Effectively make a union out of the xQUEUE structure. */ -#define pxMutexHolder pcTail -#define uxQueueType pcHead -#define uxRecursiveCallCount pcReadFrom -#define queueQUEUE_IS_MUTEX NULL - -/* Semaphores do not actually store or copy data, so have an items size of -zero. */ -#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( 0 ) -#define queueDONT_BLOCK ( ( portTickType ) 0 ) -#define queueMUTEX_GIVE_BLOCK_TIME ( ( portTickType ) 0 ) - -/* - * Definition of the queue used by the scheduler. - * Items are queued by copy, not reference. - */ -typedef struct QueueDefinition -{ - signed char *pcHead; /*< Points to the beginning of the queue storage area. */ - signed char *pcTail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */ - - signed char *pcWriteTo; /*< Points to the free next place in the storage area. */ - signed char *pcReadFrom; /*< Points to the last place that a queued item was read from. */ - - xList xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */ - xList xTasksWaitingToReceive; /*< List of tasks that are blocked waiting to read from this queue. Stored in priority order. */ - - volatile unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of items currently in the queue. */ - unsigned portBASE_TYPE uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */ - unsigned portBASE_TYPE uxItemSize; /*< The size of each items that the queue will hold. */ - - signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ - signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ - -} xQUEUE; -/*-----------------------------------------------------------*/ - -/* - * Inside this file xQueueHandle is a pointer to a xQUEUE structure. - * To keep the definition private the API header file defines it as a - * pointer to void. - */ -typedef xQUEUE * xQueueHandle; - -/* - * Prototypes for public functions are included here so we don't have to - * include the API header file (as it defines xQueueHandle differently). These - * functions are documented in the API header file. - */ -xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ) PRIVILEGED_FUNCTION; -signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION; -unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; -void vQueueDelete( xQueueHandle xQueue ) PRIVILEGED_FUNCTION; -signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION; -signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION; -signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION; -xQueueHandle xQueueCreateMutex( void ) PRIVILEGED_FUNCTION; -xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION; -portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ) PRIVILEGED_FUNCTION; -portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex ) PRIVILEGED_FUNCTION; -signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION; -signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION; -signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; -signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; -unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; -void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION; - -/* - * Co-routine queue functions differ from task queue functions. Co-routines are - * an optional component. - */ -#if configUSE_CO_ROUTINES == 1 - signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ) PRIVILEGED_FUNCTION; - signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION; - signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION; - signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ) PRIVILEGED_FUNCTION; -#endif - -/* - * The queue registry is just a means for kernel aware debuggers to locate - * queue structures. It has no other purpose so is an optional component. - */ -#if configQUEUE_REGISTRY_SIZE > 0 - - /* The type stored within the queue registry array. This allows a name - to be assigned to each queue making kernel aware debugging a little - more user friendly. */ - typedef struct QUEUE_REGISTRY_ITEM - { - signed char *pcQueueName; - xQueueHandle xHandle; - } xQueueRegistryItem; - - /* The queue registry is simply an array of xQueueRegistryItem structures. - The pcQueueName member of a structure being NULL is indicative of the - array position being vacant. */ - xQueueRegistryItem xQueueRegistry[ configQUEUE_REGISTRY_SIZE ]; - - /* Removes a queue from the registry by simply setting the pcQueueName - member to NULL. */ - static void vQueueUnregisterQueue( xQueueHandle xQueue ) PRIVILEGED_FUNCTION; - void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcQueueName ) PRIVILEGED_FUNCTION; -#endif - -/* - * Unlocks a queue locked by a call to prvLockQueue. Locking a queue does not - * prevent an ISR from adding or removing items to the queue, but does prevent - * an ISR from removing tasks from the queue event lists. If an ISR finds a - * queue is locked it will instead increment the appropriate queue lock count - * to indicate that a task may require unblocking. When the queue in unlocked - * these lock counts are inspected, and the appropriate action taken. - */ -static void prvUnlockQueue( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; - -/* - * Uses a critical section to determine if there is any data in a queue. - * - * @return pdTRUE if the queue contains no items, otherwise pdFALSE. - */ -static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; - -/* - * Uses a critical section to determine if there is any space in a queue. - * - * @return pdTRUE if there is no space, otherwise pdFALSE; - */ -static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; - -/* - * Copies an item into the queue, either at the front of the queue or the - * back of the queue. - */ -static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ) PRIVILEGED_FUNCTION; - -/* - * Copies an item out of a queue. - */ -static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) PRIVILEGED_FUNCTION; -/*-----------------------------------------------------------*/ - -/* - * Macro to mark a queue as locked. Locking a queue prevents an ISR from - * accessing the queue event lists. - */ -#define prvLockQueue( pxQueue ) \ - taskENTER_CRITICAL(); \ - { \ - if( ( pxQueue )->xRxLock == queueUNLOCKED ) \ - { \ - ( pxQueue )->xRxLock = queueLOCKED_UNMODIFIED; \ - } \ - if( ( pxQueue )->xTxLock == queueUNLOCKED ) \ - { \ - ( pxQueue )->xTxLock = queueLOCKED_UNMODIFIED; \ - } \ - } \ - taskEXIT_CRITICAL() -/*-----------------------------------------------------------*/ - - -/*----------------------------------------------------------- - * PUBLIC QUEUE MANAGEMENT API documented in queue.h - *----------------------------------------------------------*/ - -xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ) -{ -xQUEUE *pxNewQueue; -size_t xQueueSizeInBytes; -xQueueHandle xReturn = NULL; - - /* Allocate the new queue structure. */ - if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 ) - { - pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) ); - if( pxNewQueue != NULL ) - { - /* Create the list of pointers to queue items. The queue is one byte - longer than asked for to make wrap checking easier/faster. */ - xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; - - pxNewQueue->pcHead = ( signed char * ) pvPortMalloc( xQueueSizeInBytes ); - if( pxNewQueue->pcHead != NULL ) - { - /* Initialise the queue members as described above where the - queue type is defined. */ - pxNewQueue->pcTail = pxNewQueue->pcHead + ( uxQueueLength * uxItemSize ); - pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U; - pxNewQueue->pcWriteTo = pxNewQueue->pcHead; - pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - ( unsigned portBASE_TYPE ) 1U ) * uxItemSize ); - pxNewQueue->uxLength = uxQueueLength; - pxNewQueue->uxItemSize = uxItemSize; - pxNewQueue->xRxLock = queueUNLOCKED; - pxNewQueue->xTxLock = queueUNLOCKED; - - /* Likewise ensure the event queues start with the correct state. */ - vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) ); - vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) ); - - traceQUEUE_CREATE( pxNewQueue ); - xReturn = pxNewQueue; - } - else - { - traceQUEUE_CREATE_FAILED(); - vPortFree( pxNewQueue ); - } - } - } - - configASSERT( xReturn ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_MUTEXES == 1 ) - - xQueueHandle xQueueCreateMutex( void ) - { - xQUEUE *pxNewQueue; - - /* Allocate the new queue structure. */ - pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) ); - if( pxNewQueue != NULL ) - { - /* Information required for priority inheritance. */ - pxNewQueue->pxMutexHolder = NULL; - pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX; - - /* Queues used as a mutex no data is actually copied into or out - of the queue. */ - pxNewQueue->pcWriteTo = NULL; - pxNewQueue->pcReadFrom = NULL; - - /* Each mutex has a length of 1 (like a binary semaphore) and - an item size of 0 as nothing is actually copied into or out - of the mutex. */ - pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U; - pxNewQueue->uxLength = ( unsigned portBASE_TYPE ) 1U; - pxNewQueue->uxItemSize = ( unsigned portBASE_TYPE ) 0U; - pxNewQueue->xRxLock = queueUNLOCKED; - pxNewQueue->xTxLock = queueUNLOCKED; - - /* Ensure the event queues start with the correct state. */ - vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) ); - vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) ); - - /* Start with the semaphore in the expected state. */ - xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK ); - - traceCREATE_MUTEX( pxNewQueue ); - } - else - { - traceCREATE_MUTEX_FAILED(); - } - - configASSERT( pxNewQueue ); - return pxNewQueue; - } - -#endif /* configUSE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if configUSE_RECURSIVE_MUTEXES == 1 - - portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex ) - { - portBASE_TYPE xReturn; - - configASSERT( pxMutex ); - - /* If this is the task that holds the mutex then pxMutexHolder will not - change outside of this task. If this task does not hold the mutex then - pxMutexHolder can never coincidentally equal the tasks handle, and as - this is the only condition we are interested in it does not matter if - pxMutexHolder is accessed simultaneously by another task. Therefore no - mutual exclusion is required to test the pxMutexHolder variable. */ - if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() ) - { - traceGIVE_MUTEX_RECURSIVE( pxMutex ); - - /* uxRecursiveCallCount cannot be zero if pxMutexHolder is equal to - the task handle, therefore no underflow check is required. Also, - uxRecursiveCallCount is only modified by the mutex holder, and as - there can only be one, no mutual exclusion is required to modify the - uxRecursiveCallCount member. */ - ( pxMutex->uxRecursiveCallCount )--; - - /* Have we unwound the call count? */ - if( pxMutex->uxRecursiveCallCount == 0 ) - { - /* Return the mutex. This will automatically unblock any other - task that might be waiting to access the mutex. */ - xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK ); - } - - xReturn = pdPASS; - } - else - { - /* We cannot give the mutex because we are not the holder. */ - xReturn = pdFAIL; - - traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ); - } - - return xReturn; - } - -#endif /* configUSE_RECURSIVE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if configUSE_RECURSIVE_MUTEXES == 1 - - portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime ) - { - portBASE_TYPE xReturn; - - configASSERT( pxMutex ); - - /* Comments regarding mutual exclusion as per those within - xQueueGiveMutexRecursive(). */ - - traceTAKE_MUTEX_RECURSIVE( pxMutex ); - - if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() ) - { - ( pxMutex->uxRecursiveCallCount )++; - xReturn = pdPASS; - } - else - { - xReturn = xQueueGenericReceive( pxMutex, NULL, xBlockTime, pdFALSE ); - - /* pdPASS will only be returned if we successfully obtained the mutex, - we may have blocked to reach here. */ - if( xReturn == pdPASS ) - { - ( pxMutex->uxRecursiveCallCount )++; - } - else - { - traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ); - } - } - - return xReturn; - } - -#endif /* configUSE_RECURSIVE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if configUSE_COUNTING_SEMAPHORES == 1 - - xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) - { - xQueueHandle pxHandle; - - pxHandle = xQueueCreate( ( unsigned portBASE_TYPE ) uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH ); - - if( pxHandle != NULL ) - { - pxHandle->uxMessagesWaiting = uxInitialCount; - - traceCREATE_COUNTING_SEMAPHORE(); - } - else - { - traceCREATE_COUNTING_SEMAPHORE_FAILED(); - } - - configASSERT( pxHandle ); - return pxHandle; - } - -#endif /* configUSE_COUNTING_SEMAPHORES */ -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) -{ -signed portBASE_TYPE xEntryTimeSet = pdFALSE; -xTimeOutType xTimeOut; - - configASSERT( pxQueue ); - configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) ); - - /* This function relaxes the coding standard somewhat to allow return - statements within the function itself. This is done in the interest - of execution time efficiency. */ - for( ;; ) - { - taskENTER_CRITICAL(); - { - /* Is there room on the queue now? To be running we must be - the highest priority task wanting to access the queue. */ - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - traceQUEUE_SEND( pxQueue ); - prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); - - /* If there was a task waiting for data to arrive on the - queue then unblock it now. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE ) - { - /* The unblocked task has a priority higher than - our own so yield immediately. Yes it is ok to do - this from within the critical section - the kernel - takes care of that. */ - portYIELD_WITHIN_API(); - } - } - - taskEXIT_CRITICAL(); - - /* Return to the original privilege level before exiting the - function. */ - return pdPASS; - } - else - { - if( xTicksToWait == ( portTickType ) 0 ) - { - /* The queue was full and no block time is specified (or - the block time has expired) so leave now. */ - taskEXIT_CRITICAL(); - - /* Return to the original privilege level before exiting - the function. */ - traceQUEUE_SEND_FAILED( pxQueue ); - return errQUEUE_FULL; - } - else if( xEntryTimeSet == pdFALSE ) - { - /* The queue was full and a block time was specified so - configure the timeout structure. */ - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - } - } - taskEXIT_CRITICAL(); - - /* Interrupts and other tasks can send to and receive from the queue - now the critical section has been exited. */ - - vTaskSuspendAll(); - prvLockQueue( pxQueue ); - - /* Update the timeout state to see if it has expired yet. */ - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if( prvIsQueueFull( pxQueue ) ) - { - traceBLOCKING_ON_QUEUE_SEND( pxQueue ); - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); - - /* Unlocking the queue means queue events can effect the - event list. It is possible that interrupts occurring now - remove this task from the event list again - but as the - scheduler is suspended the task will go onto the pending - ready last instead of the actual ready list. */ - prvUnlockQueue( pxQueue ); - - /* Resuming the scheduler will move tasks from the pending - ready list into the ready list - so it is feasible that this - task is already in a ready list before it yields - in which - case the yield will not cause a context switch unless there - is also a higher priority task in the pending ready list. */ - if( !xTaskResumeAll() ) - { - portYIELD_WITHIN_API(); - } - } - else - { - /* Try again. */ - prvUnlockQueue( pxQueue ); - ( void ) xTaskResumeAll(); - } - } - else - { - /* The timeout has expired. */ - prvUnlockQueue( pxQueue ); - ( void ) xTaskResumeAll(); - - /* Return to the original privilege level before exiting the - function. */ - traceQUEUE_SEND_FAILED( pxQueue ); - return errQUEUE_FULL; - } - } -} -/*-----------------------------------------------------------*/ - -#if configUSE_ALTERNATIVE_API == 1 - - signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) - { - signed portBASE_TYPE xEntryTimeSet = pdFALSE; - xTimeOutType xTimeOut; - - configASSERT( pxQueue ); - configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) ); - - for( ;; ) - { - taskENTER_CRITICAL(); - { - /* Is there room on the queue now? To be running we must be - the highest priority task wanting to access the queue. */ - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - traceQUEUE_SEND( pxQueue ); - prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); - - /* If there was a task waiting for data to arrive on the - queue then unblock it now. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE ) - { - /* The unblocked task has a priority higher than - our own so yield immediately. */ - portYIELD_WITHIN_API(); - } - } - - taskEXIT_CRITICAL(); - return pdPASS; - } - else - { - if( xTicksToWait == ( portTickType ) 0 ) - { - taskEXIT_CRITICAL(); - return errQUEUE_FULL; - } - else if( xEntryTimeSet == pdFALSE ) - { - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - } - } - taskEXIT_CRITICAL(); - - taskENTER_CRITICAL(); - { - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if( prvIsQueueFull( pxQueue ) ) - { - traceBLOCKING_ON_QUEUE_SEND( pxQueue ); - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); - portYIELD_WITHIN_API(); - } - } - else - { - taskEXIT_CRITICAL(); - traceQUEUE_SEND_FAILED( pxQueue ); - return errQUEUE_FULL; - } - } - taskEXIT_CRITICAL(); - } - } - -#endif /* configUSE_ALTERNATIVE_API */ -/*-----------------------------------------------------------*/ - -#if configUSE_ALTERNATIVE_API == 1 - - signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) - { - signed portBASE_TYPE xEntryTimeSet = pdFALSE; - xTimeOutType xTimeOut; - signed char *pcOriginalReadPosition; - - configASSERT( pxQueue ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) ); - - for( ;; ) - { - taskENTER_CRITICAL(); - { - if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) - { - /* Remember our read position in case we are just peeking. */ - pcOriginalReadPosition = pxQueue->pcReadFrom; - - prvCopyDataFromQueue( pxQueue, pvBuffer ); - - if( xJustPeeking == pdFALSE ) - { - traceQUEUE_RECEIVE( pxQueue ); - - /* We are actually removing data. */ - --( pxQueue->uxMessagesWaiting ); - - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - /* Record the information required to implement - priority inheritance should it become necessary. */ - pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle(); - } - } - #endif - - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) - { - portYIELD_WITHIN_API(); - } - } - } - else - { - traceQUEUE_PEEK( pxQueue ); - - /* We are not removing the data, so reset our read - pointer. */ - pxQueue->pcReadFrom = pcOriginalReadPosition; - - /* The data is being left in the queue, so see if there are - any other tasks waiting for the data. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority than this task. */ - portYIELD_WITHIN_API(); - } - } - - } - - taskEXIT_CRITICAL(); - return pdPASS; - } - else - { - if( xTicksToWait == ( portTickType ) 0 ) - { - taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - else if( xEntryTimeSet == pdFALSE ) - { - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - } - } - taskEXIT_CRITICAL(); - - taskENTER_CRITICAL(); - { - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if( prvIsQueueEmpty( pxQueue ) ) - { - traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); - - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - portENTER_CRITICAL(); - vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); - portEXIT_CRITICAL(); - } - } - #endif - - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); - portYIELD_WITHIN_API(); - } - } - else - { - taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - } - taskEXIT_CRITICAL(); - } - } - - -#endif /* configUSE_ALTERNATIVE_API */ -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) -{ -signed portBASE_TYPE xReturn; -unsigned portBASE_TYPE uxSavedInterruptStatus; - - configASSERT( pxQueue ); - configASSERT( pxHigherPriorityTaskWoken ); - configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) ); - - /* Similar to xQueueGenericSend, except we don't block if there is no room - in the queue. Also we don't directly wake a task that was blocked on a - queue read, instead we return a flag to say whether a context switch is - required or not (i.e. has a task with a higher priority than us been woken - by this post). */ - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - traceQUEUE_SEND_FROM_ISR( pxQueue ); - - prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); - - /* If the queue is locked we do not alter the event list. This will - be done when the queue is unlocked later. */ - if( pxQueue->xTxLock == queueUNLOCKED ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so record that a - context switch is required. */ - *pxHigherPriorityTaskWoken = pdTRUE; - } - } - } - else - { - /* Increment the lock count so the task that unlocks the queue - knows that data was posted while it was locked. */ - ++( pxQueue->xTxLock ); - } - - xReturn = pdPASS; - } - else - { - traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); - xReturn = errQUEUE_FULL; - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) -{ -signed portBASE_TYPE xEntryTimeSet = pdFALSE; -xTimeOutType xTimeOut; -signed char *pcOriginalReadPosition; - - configASSERT( pxQueue ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) ); - - /* This function relaxes the coding standard somewhat to allow return - statements within the function itself. This is done in the interest - of execution time efficiency. */ - - for( ;; ) - { - taskENTER_CRITICAL(); - { - /* Is there data in the queue now? To be running we must be - the highest priority task wanting to access the queue. */ - if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) - { - /* Remember our read position in case we are just peeking. */ - pcOriginalReadPosition = pxQueue->pcReadFrom; - - prvCopyDataFromQueue( pxQueue, pvBuffer ); - - if( xJustPeeking == pdFALSE ) - { - traceQUEUE_RECEIVE( pxQueue ); - - /* We are actually removing data. */ - --( pxQueue->uxMessagesWaiting ); - - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - /* Record the information required to implement - priority inheritance should it become necessary. */ - pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle(); - } - } - #endif - - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) - { - portYIELD_WITHIN_API(); - } - } - } - else - { - traceQUEUE_PEEK( pxQueue ); - - /* We are not removing the data, so reset our read - pointer. */ - pxQueue->pcReadFrom = pcOriginalReadPosition; - - /* The data is being left in the queue, so see if there are - any other tasks waiting for the data. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority than this task. */ - portYIELD_WITHIN_API(); - } - } - - } - - taskEXIT_CRITICAL(); - return pdPASS; - } - else - { - if( xTicksToWait == ( portTickType ) 0 ) - { - /* The queue was empty and no block time is specified (or - the block time has expired) so leave now. */ - taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - else if( xEntryTimeSet == pdFALSE ) - { - /* The queue was empty and a block time was specified so - configure the timeout structure. */ - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - } - } - taskEXIT_CRITICAL(); - - /* Interrupts and other tasks can send to and receive from the queue - now the critical section has been exited. */ - - vTaskSuspendAll(); - prvLockQueue( pxQueue ); - - /* Update the timeout state to see if it has expired yet. */ - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if( prvIsQueueEmpty( pxQueue ) ) - { - traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); - - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - portENTER_CRITICAL(); - { - vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); - } - portEXIT_CRITICAL(); - } - } - #endif - - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); - prvUnlockQueue( pxQueue ); - if( !xTaskResumeAll() ) - { - portYIELD_WITHIN_API(); - } - } - else - { - /* Try again. */ - prvUnlockQueue( pxQueue ); - ( void ) xTaskResumeAll(); - } - } - else - { - prvUnlockQueue( pxQueue ); - ( void ) xTaskResumeAll(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - } -} -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ) -{ -signed portBASE_TYPE xReturn; -unsigned portBASE_TYPE uxSavedInterruptStatus; - - configASSERT( pxQueue ); - configASSERT( pxTaskWoken ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) ); - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - /* We cannot block from an ISR, so check there is data available. */ - if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) - { - traceQUEUE_RECEIVE_FROM_ISR( pxQueue ); - - prvCopyDataFromQueue( pxQueue, pvBuffer ); - --( pxQueue->uxMessagesWaiting ); - - /* If the queue is locked we will not modify the event list. Instead - we update the lock count so the task that unlocks the queue will know - that an ISR has removed data while the queue was locked. */ - if( pxQueue->xRxLock == queueUNLOCKED ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) - { - /* The task waiting has a higher priority than us so - force a context switch. */ - *pxTaskWoken = pdTRUE; - } - } - } - else - { - /* Increment the lock count so the task that unlocks the queue - knows that data was removed while it was locked. */ - ++( pxQueue->xRxLock ); - } - - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ); - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) -{ -unsigned portBASE_TYPE uxReturn; - - configASSERT( pxQueue ); - - taskENTER_CRITICAL(); - uxReturn = pxQueue->uxMessagesWaiting; - taskEXIT_CRITICAL(); - - return uxReturn; -} -/*-----------------------------------------------------------*/ - -unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) -{ -unsigned portBASE_TYPE uxReturn; - - configASSERT( pxQueue ); - - uxReturn = pxQueue->uxMessagesWaiting; - - return uxReturn; -} -/*-----------------------------------------------------------*/ - -void vQueueDelete( xQueueHandle pxQueue ) -{ - configASSERT( pxQueue ); - - traceQUEUE_DELETE( pxQueue ); - vQueueUnregisterQueue( pxQueue ); - vPortFree( pxQueue->pcHead ); - vPortFree( pxQueue ); -} -/*-----------------------------------------------------------*/ - -static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ) -{ - if( pxQueue->uxItemSize == ( unsigned portBASE_TYPE ) 0 ) - { - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - /* The mutex is no longer being held. */ - vTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder ); - pxQueue->pxMutexHolder = NULL; - } - } - #endif - } - else if( xPosition == queueSEND_TO_BACK ) - { - memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize ); - pxQueue->pcWriteTo += pxQueue->uxItemSize; - if( pxQueue->pcWriteTo >= pxQueue->pcTail ) - { - pxQueue->pcWriteTo = pxQueue->pcHead; - } - } - else - { - memcpy( ( void * ) pxQueue->pcReadFrom, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize ); - pxQueue->pcReadFrom -= pxQueue->uxItemSize; - if( pxQueue->pcReadFrom < pxQueue->pcHead ) - { - pxQueue->pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize ); - } - } - - ++( pxQueue->uxMessagesWaiting ); -} -/*-----------------------------------------------------------*/ - -static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) -{ - if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX ) - { - pxQueue->pcReadFrom += pxQueue->uxItemSize; - if( pxQueue->pcReadFrom >= pxQueue->pcTail ) - { - pxQueue->pcReadFrom = pxQueue->pcHead; - } - memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); - } -} -/*-----------------------------------------------------------*/ - -static void prvUnlockQueue( xQueueHandle pxQueue ) -{ - /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */ - - /* The lock counts contains the number of extra data items placed or - removed from the queue while the queue was locked. When a queue is - locked items can be added or removed, but the event lists cannot be - updated. */ - taskENTER_CRITICAL(); - { - /* See if data was added to the queue while it was locked. */ - while( pxQueue->xTxLock > queueLOCKED_UNMODIFIED ) - { - /* Data was posted while the queue was locked. Are any tasks - blocked waiting for data to become available? */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so record that a - context switch is required. */ - vTaskMissedYield(); - } - - --( pxQueue->xTxLock ); - } - else - { - break; - } - } - - pxQueue->xTxLock = queueUNLOCKED; - } - taskEXIT_CRITICAL(); - - /* Do the same for the Rx lock. */ - taskENTER_CRITICAL(); - { - while( pxQueue->xRxLock > queueLOCKED_UNMODIFIED ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) - { - vTaskMissedYield(); - } - - --( pxQueue->xRxLock ); - } - else - { - break; - } - } - - pxQueue->xRxLock = queueUNLOCKED; - } - taskEXIT_CRITICAL(); -} -/*-----------------------------------------------------------*/ - -static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ) -{ -signed portBASE_TYPE xReturn; - - taskENTER_CRITICAL(); - xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 ); - taskEXIT_CRITICAL(); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ) -{ -signed portBASE_TYPE xReturn; - - configASSERT( pxQueue ); - xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ) -{ -signed portBASE_TYPE xReturn; - - taskENTER_CRITICAL(); - xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength ); - taskEXIT_CRITICAL(); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) -{ -signed portBASE_TYPE xReturn; - - configASSERT( pxQueue ); - xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#if configUSE_CO_ROUTINES == 1 -signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ) -{ -signed portBASE_TYPE xReturn; - - /* If the queue is already full we may have to block. A critical section - is required to prevent an interrupt removing something from the queue - between the check to see if the queue is full and blocking on the queue. */ - portDISABLE_INTERRUPTS(); - { - if( prvIsQueueFull( pxQueue ) ) - { - /* The queue is full - do we want to block or just leave without - posting? */ - if( xTicksToWait > ( portTickType ) 0 ) - { - /* As this is called from a coroutine we cannot block directly, but - return indicating that we need to block. */ - vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) ); - portENABLE_INTERRUPTS(); - return errQUEUE_BLOCKED; - } - else - { - portENABLE_INTERRUPTS(); - return errQUEUE_FULL; - } - } - } - portENABLE_INTERRUPTS(); - - portNOP(); - - portDISABLE_INTERRUPTS(); - { - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - /* There is room in the queue, copy the data into the queue. */ - prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); - xReturn = pdPASS; - - /* Were any co-routines waiting for data to become available? */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - /* In this instance the co-routine could be placed directly - into the ready list as we are within a critical section. - Instead the same pending ready list mechanism is used as if - the event were caused from within an interrupt. */ - if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The co-routine waiting has a higher priority so record - that a yield might be appropriate. */ - xReturn = errQUEUE_YIELD; - } - } - } - else - { - xReturn = errQUEUE_FULL; - } - } - portENABLE_INTERRUPTS(); - - return xReturn; -} -#endif -/*-----------------------------------------------------------*/ - -#if configUSE_CO_ROUTINES == 1 -signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ) -{ -signed portBASE_TYPE xReturn; - - /* If the queue is already empty we may have to block. A critical section - is required to prevent an interrupt adding something to the queue - between the check to see if the queue is empty and blocking on the queue. */ - portDISABLE_INTERRUPTS(); - { - if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 ) - { - /* There are no messages in the queue, do we want to block or just - leave with nothing? */ - if( xTicksToWait > ( portTickType ) 0 ) - { - /* As this is a co-routine we cannot block directly, but return - indicating that we need to block. */ - vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) ); - portENABLE_INTERRUPTS(); - return errQUEUE_BLOCKED; - } - else - { - portENABLE_INTERRUPTS(); - return errQUEUE_FULL; - } - } - } - portENABLE_INTERRUPTS(); - - portNOP(); - - portDISABLE_INTERRUPTS(); - { - if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) - { - /* Data is available from the queue. */ - pxQueue->pcReadFrom += pxQueue->uxItemSize; - if( pxQueue->pcReadFrom >= pxQueue->pcTail ) - { - pxQueue->pcReadFrom = pxQueue->pcHead; - } - --( pxQueue->uxMessagesWaiting ); - memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); - - xReturn = pdPASS; - - /* Were any co-routines waiting for space to become available? */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - /* In this instance the co-routine could be placed directly - into the ready list as we are within a critical section. - Instead the same pending ready list mechanism is used as if - the event were caused from within an interrupt. */ - if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) - { - xReturn = errQUEUE_YIELD; - } - } - } - else - { - xReturn = pdFAIL; - } - } - portENABLE_INTERRUPTS(); - - return xReturn; -} -#endif -/*-----------------------------------------------------------*/ - - - -#if configUSE_CO_ROUTINES == 1 -signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ) -{ - /* Cannot block within an ISR so if there is no space on the queue then - exit without doing anything. */ - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); - - /* We only want to wake one co-routine per ISR, so check that a - co-routine has not already been woken. */ - if( !xCoRoutinePreviouslyWoken ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - return pdTRUE; - } - } - } - } - - return xCoRoutinePreviouslyWoken; -} -#endif -/*-----------------------------------------------------------*/ - -#if configUSE_CO_ROUTINES == 1 -signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxCoRoutineWoken ) -{ -signed portBASE_TYPE xReturn; - - /* We cannot block from an ISR, so check there is data available. If - not then just leave without doing anything. */ - if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) - { - /* Copy the data from the queue. */ - pxQueue->pcReadFrom += pxQueue->uxItemSize; - if( pxQueue->pcReadFrom >= pxQueue->pcTail ) - { - pxQueue->pcReadFrom = pxQueue->pcHead; - } - --( pxQueue->uxMessagesWaiting ); - memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); - - if( !( *pxCoRoutineWoken ) ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) - { - *pxCoRoutineWoken = pdTRUE; - } - } - } - - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - } - - return xReturn; -} -#endif -/*-----------------------------------------------------------*/ - -#if configQUEUE_REGISTRY_SIZE > 0 - - void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcQueueName ) - { - unsigned portBASE_TYPE ux; - - /* See if there is an empty space in the registry. A NULL name denotes - a free slot. */ - for( ux = ( unsigned portBASE_TYPE ) 0U; ux < configQUEUE_REGISTRY_SIZE; ux++ ) - { - if( xQueueRegistry[ ux ].pcQueueName == NULL ) - { - /* Store the information on this queue. */ - xQueueRegistry[ ux ].pcQueueName = pcQueueName; - xQueueRegistry[ ux ].xHandle = xQueue; - break; - } - } - } - -#endif -/*-----------------------------------------------------------*/ - -#if configQUEUE_REGISTRY_SIZE > 0 - - static void vQueueUnregisterQueue( xQueueHandle xQueue ) - { - unsigned portBASE_TYPE ux; - - /* See if the handle of the queue being unregistered in actually in the - registry. */ - for( ux = ( unsigned portBASE_TYPE ) 0U; ux < configQUEUE_REGISTRY_SIZE; ux++ ) - { - if( xQueueRegistry[ ux ].xHandle == xQueue ) - { - /* Set the name to NULL to show that this slot if free again. */ - xQueueRegistry[ ux ].pcQueueName = NULL; - break; - } - } - - } - -#endif -/*-----------------------------------------------------------*/ - -#if configUSE_TIMERS == 1 - - void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) - { - /* This function should not be called by application code hence the - 'Restricted' in its name. It is not part of the public API. It is - designed for use by kernel code, and has special calling requirements. - It can result in vListInsert() being called on a list that can only - possibly ever have one item in it, so the list will be fast, but even - so it should be called with the scheduler locked and not from a critical - section. */ - - /* Only do anything if there are no messages in the queue. This function - will not actually cause the task to block, just place it on a blocked - list. It will not block until the scheduler is unlocked - at which - time a yield will be performed. If an item is added to the queue while - the queue is locked, and the calling task blocks on the queue, then the - calling task will be immediately unblocked when the queue is unlocked. */ - prvLockQueue( pxQueue ); - if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0U ) - { - /* There is nothing in the queue, block for the specified period. */ - vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); - } - prvUnlockQueue( pxQueue ); - } - -#endif - diff --git a/GD32F1/libraries/FreeRTOS/utility/queue.h b/GD32F1/libraries/FreeRTOS/utility/queue.h deleted file mode 100644 index 9a6c86a..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/queue.h +++ /dev/null @@ -1,1270 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - - -#ifndef QUEUE_H -#define QUEUE_H - -#ifndef INC_FREERTOS_H - #error "#include FreeRTOS.h" must appear in source files before "#include queue.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -#include "mpu_wrappers.h" - -/** - * Type by which queues are referenced. For example, a call to xQueueCreate - * returns (via a pointer parameter) an xQueueHandle variable that can then - * be used as a parameter to xQueueSend(), xQueueReceive(), etc. - */ -typedef void * xQueueHandle; - - -/* For internal use only. */ -#define queueSEND_TO_BACK ( 0 ) -#define queueSEND_TO_FRONT ( 1 ) - - -/** - * queue. h - *
- xQueueHandle xQueueCreate(
-							  unsigned portBASE_TYPE uxQueueLength,
-							  unsigned portBASE_TYPE uxItemSize
-						  );
- * 
- * - * Creates a new queue instance. This allocates the storage required by the - * new queue and returns a handle for the queue. - * - * @param uxQueueLength The maximum number of items that the queue can contain. - * - * @param uxItemSize The number of bytes each item in the queue will require. - * Items are queued by copy, not by reference, so this is the number of bytes - * that will be copied for each posted item. Each item on the queue must be - * the same size. - * - * @return If the queue is successfully create then a handle to the newly - * created queue is returned. If the queue cannot be created then 0 is - * returned. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- };
-
- void vATask( void *pvParameters )
- {
- xQueueHandle xQueue1, xQueue2;
-
-	// Create a queue capable of containing 10 unsigned long values.
-	xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
-	if( xQueue1 == 0 )
-	{
-		// Queue was not created and must not be used.
-	}
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue2 == 0 )
-	{
-		// Queue was not created and must not be used.
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueCreate xQueueCreate - * \ingroup QueueManagement - */ -xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ); - -/** - * queue. h - *
- portBASE_TYPE xQueueSendToToFront(
-								   xQueueHandle	xQueue,
-								   const void	*	pvItemToQueue,
-								   portTickType	xTicksToWait
-							   );
- * 
- * - * This is a macro that calls xQueueGenericSend(). - * - * Post an item to the front of a queue. The item is queued by copy, not by - * reference. This function must not be called from an interrupt service - * routine. See xQueueSendFromISR () for an alternative which may be used - * in an ISR. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for space to become available on the queue, should it already - * be full. The call will return immediately if this is set to 0 and the - * queue is full. The time is defined in tick periods so the constant - * portTICK_RATE_MS should be used to convert to real time if this is required. - * - * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- unsigned long ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- xQueueHandle xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 unsigned long values.
-	xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an unsigned long.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend - * \ingroup QueueManagement - */ -#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) - -/** - * queue. h - *
- portBASE_TYPE xQueueSendToBack(
-								   xQueueHandle	xQueue,
-								   const	void	*	pvItemToQueue,
-								   portTickType	xTicksToWait
-							   );
- * 
- * - * This is a macro that calls xQueueGenericSend(). - * - * Post an item to the back of a queue. The item is queued by copy, not by - * reference. This function must not be called from an interrupt service - * routine. See xQueueSendFromISR () for an alternative which may be used - * in an ISR. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for space to become available on the queue, should it already - * be full. The call will return immediately if this is set to 0 and the queue - * is full. The time is defined in tick periods so the constant - * portTICK_RATE_MS should be used to convert to real time if this is required. - * - * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- unsigned long ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- xQueueHandle xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 unsigned long values.
-	xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an unsigned long.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend - * \ingroup QueueManagement - */ -#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) - -/** - * queue. h - *
- portBASE_TYPE xQueueSend(
-							  xQueueHandle xQueue,
-							  const void * pvItemToQueue,
-							  portTickType xTicksToWait
-						 );
- * 
- * - * This is a macro that calls xQueueGenericSend(). It is included for - * backward compatibility with versions of FreeRTOS.org that did not - * include the xQueueSendToFront() and xQueueSendToBack() macros. It is - * equivalent to xQueueSendToBack(). - * - * Post an item on a queue. The item is queued by copy, not by reference. - * This function must not be called from an interrupt service routine. - * See xQueueSendFromISR () for an alternative which may be used in an ISR. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for space to become available on the queue, should it already - * be full. The call will return immediately if this is set to 0 and the - * queue is full. The time is defined in tick periods so the constant - * portTICK_RATE_MS should be used to convert to real time if this is required. - * - * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- unsigned long ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- xQueueHandle xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 unsigned long values.
-	xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an unsigned long.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend - * \ingroup QueueManagement - */ -#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) - - -/** - * queue. h - *
- portBASE_TYPE xQueueGenericSend(
-									xQueueHandle xQueue,
-									const void * pvItemToQueue,
-									portTickType xTicksToWait
-									portBASE_TYPE xCopyPosition
-								);
- * 
- * - * It is preferred that the macros xQueueSend(), xQueueSendToFront() and - * xQueueSendToBack() are used in place of calling this function directly. - * - * Post an item on a queue. The item is queued by copy, not by reference. - * This function must not be called from an interrupt service routine. - * See xQueueSendFromISR () for an alternative which may be used in an ISR. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for space to become available on the queue, should it already - * be full. The call will return immediately if this is set to 0 and the - * queue is full. The time is defined in tick periods so the constant - * portTICK_RATE_MS should be used to convert to real time if this is required. - * - * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the - * item at the back of the queue, or queueSEND_TO_FRONT to place the item - * at the front of the queue (for high priority messages). - * - * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- unsigned long ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- xQueueHandle xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 unsigned long values.
-	xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an unsigned long.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10, queueSEND_TO_BACK ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0, queueSEND_TO_BACK );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend - * \ingroup QueueManagement - */ -signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); - -/** - * queue. h - *
- portBASE_TYPE xQueuePeek(
-							 xQueueHandle xQueue,
-							 void *pvBuffer,
-							 portTickType xTicksToWait
-						 );
- * - * This is a macro that calls the xQueueGenericReceive() function. - * - * Receive an item from a queue without removing the item from the queue. - * The item is received by copy so a buffer of adequate size must be - * provided. The number of bytes copied into the buffer was defined when - * the queue was created. - * - * Successfully received items remain on the queue so will be returned again - * by the next call, or a call to xQueueReceive(). - * - * This macro must not be used in an interrupt service routine. - * - * @param pxQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for an item to receive should the queue be empty at the time - * of the call. The time is defined in tick periods so the constant - * portTICK_RATE_MS should be used to convert to real time if this is required. - * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue - * is empty. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- xQueueHandle xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to peek the data from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Peek a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueuePeek( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask, but the item still remains on the queue.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive - * \ingroup QueueManagement - */ -#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) - -/** - * queue. h - *
- portBASE_TYPE xQueueReceive(
-								 xQueueHandle xQueue,
-								 void *pvBuffer,
-								 portTickType xTicksToWait
-							);
- * - * This is a macro that calls the xQueueGenericReceive() function. - * - * Receive an item from a queue. The item is received by copy so a buffer of - * adequate size must be provided. The number of bytes copied into the buffer - * was defined when the queue was created. - * - * Successfully received items are removed from the queue. - * - * This function must not be used in an interrupt service routine. See - * xQueueReceiveFromISR for an alternative that can. - * - * @param pxQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for an item to receive should the queue be empty at the time - * of the call. xQueueReceive() will return immediately if xTicksToWait - * is zero and the queue is empty. The time is defined in tick periods so the - * constant portTICK_RATE_MS should be used to convert to real time if this is - * required. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- xQueueHandle xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to receive from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Receive a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive - * \ingroup QueueManagement - */ -#define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) - - -/** - * queue. h - *
- portBASE_TYPE xQueueGenericReceive(
-									   xQueueHandle	xQueue,
-									   void	*pvBuffer,
-									   portTickType	xTicksToWait
-									   portBASE_TYPE	xJustPeek
-									);
- * - * It is preferred that the macro xQueueReceive() be used rather than calling - * this function directly. - * - * Receive an item from a queue. The item is received by copy so a buffer of - * adequate size must be provided. The number of bytes copied into the buffer - * was defined when the queue was created. - * - * This function must not be used in an interrupt service routine. See - * xQueueReceiveFromISR for an alternative that can. - * - * @param pxQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for an item to receive should the queue be empty at the time - * of the call. The time is defined in tick periods so the constant - * portTICK_RATE_MS should be used to convert to real time if this is required. - * xQueueGenericReceive() will return immediately if the queue is empty and - * xTicksToWait is 0. - * - * @param xJustPeek When set to true, the item received from the queue is not - * actually removed from the queue - meaning a subsequent call to - * xQueueReceive() will return the same item. When set to false, the item - * being received from the queue is also removed from the queue. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- xQueueHandle xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to receive from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Receive a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive - * \ingroup QueueManagement - */ -signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek ); - -/** - * queue. h - *
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );
- * - * Return the number of messages stored in a queue. - * - * @param xQueue A handle to the queue being queried. - * - * @return The number of messages available in the queue. - * - * \page uxQueueMessagesWaiting uxQueueMessagesWaiting - * \ingroup QueueManagement - */ -unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue ); - -/** - * queue. h - *
void vQueueDelete( xQueueHandle xQueue );
- * - * Delete a queue - freeing all the memory allocated for storing of items - * placed on the queue. - * - * @param xQueue A handle to the queue to be deleted. - * - * \page vQueueDelete vQueueDelete - * \ingroup QueueManagement - */ -void vQueueDelete( xQueueHandle pxQueue ); - -/** - * queue. h - *
- portBASE_TYPE xQueueSendToFrontFromISR(
-										 xQueueHandle pxQueue,
-										 const void *pvItemToQueue,
-										 portBASE_TYPE *pxHigherPriorityTaskWoken
-									  );
- 
- * - * This is a macro that calls xQueueGenericSendFromISR(). - * - * Post an item to the front of a queue. It is safe to use this macro from - * within an interrupt service routine. - * - * Items are queued by copy not reference so it is preferable to only - * queue small items, especially when called from an ISR. In most cases - * it would be preferable to store a pointer to the item being queued. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the data was successfully sent to the queue, otherwise - * errQUEUE_FULL. - * - * Example usage for buffered IO (where the ISR can obtain more than one value - * per call): -
- void vBufferISR( void )
- {
- char cIn;
- portBASE_TYPE xHigherPrioritTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		taskYIELD ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR - * \ingroup QueueManagement - */ -#define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) - - -/** - * queue. h - *
- portBASE_TYPE xQueueSendToBackFromISR(
-										 xQueueHandle pxQueue,
-										 const void *pvItemToQueue,
-										 portBASE_TYPE *pxHigherPriorityTaskWoken
-									  );
- 
- * - * This is a macro that calls xQueueGenericSendFromISR(). - * - * Post an item to the back of a queue. It is safe to use this macro from - * within an interrupt service routine. - * - * Items are queued by copy not reference so it is preferable to only - * queue small items, especially when called from an ISR. In most cases - * it would be preferable to store a pointer to the item being queued. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the data was successfully sent to the queue, otherwise - * errQUEUE_FULL. - * - * Example usage for buffered IO (where the ISR can obtain more than one value - * per call): -
- void vBufferISR( void )
- {
- char cIn;
- portBASE_TYPE xHigherPriorityTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		taskYIELD ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR - * \ingroup QueueManagement - */ -#define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) - -/** - * queue. h - *
- portBASE_TYPE xQueueSendFromISR(
-									 xQueueHandle pxQueue,
-									 const void *pvItemToQueue,
-									 portBASE_TYPE *pxHigherPriorityTaskWoken
-								);
- 
- * - * This is a macro that calls xQueueGenericSendFromISR(). It is included - * for backward compatibility with versions of FreeRTOS.org that did not - * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR() - * macros. - * - * Post an item to the back of a queue. It is safe to use this function from - * within an interrupt service routine. - * - * Items are queued by copy not reference so it is preferable to only - * queue small items, especially when called from an ISR. In most cases - * it would be preferable to store a pointer to the item being queued. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueSendFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the data was successfully sent to the queue, otherwise - * errQUEUE_FULL. - * - * Example usage for buffered IO (where the ISR can obtain more than one value - * per call): -
- void vBufferISR( void )
- {
- char cIn;
- portBASE_TYPE xHigherPriorityTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		// Actual macro used here is port specific.
-		taskYIELD_FROM_ISR ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR - * \ingroup QueueManagement - */ -#define xQueueSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) - -/** - * queue. h - *
- portBASE_TYPE xQueueGenericSendFromISR(
-										   xQueueHandle	pxQueue,
-										   const	void	*pvItemToQueue,
-										   portBASE_TYPE	*pxHigherPriorityTaskWoken,
-										   portBASE_TYPE	xCopyPosition
-									   );
- 
- * - * It is preferred that the macros xQueueSendFromISR(), - * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place - * of calling this function directly. - * - * Post an item on a queue. It is safe to use this function from within an - * interrupt service routine. - * - * Items are queued by copy not reference so it is preferable to only - * queue small items, especially when called from an ISR. In most cases - * it would be preferable to store a pointer to the item being queued. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the - * item at the back of the queue, or queueSEND_TO_FRONT to place the item - * at the front of the queue (for high priority messages). - * - * @return pdTRUE if the data was successfully sent to the queue, otherwise - * errQUEUE_FULL. - * - * Example usage for buffered IO (where the ISR can obtain more than one value - * per call): -
- void vBufferISR( void )
- {
- char cIn;
- portBASE_TYPE xHigherPriorityTaskWokenByPost;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWokenByPost = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post each byte.
-		xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.  Note that the
-	// name of the yield function required is port specific.
-	if( xHigherPriorityTaskWokenByPost )
-	{
-		taskYIELD_YIELD_FROM_ISR();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR - * \ingroup QueueManagement - */ -signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ); - -/** - * queue. h - *
- portBASE_TYPE xQueueReceiveFromISR(
-									   xQueueHandle	pxQueue,
-									   void	*pvBuffer,
-									   portBASE_TYPE	*pxTaskWoken
-								   );
- * 
- * - * Receive an item from a queue. It is safe to use this function from within an - * interrupt service routine. - * - * @param pxQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param pxTaskWoken A task may be blocked waiting for space to become - * available on the queue. If xQueueReceiveFromISR causes such a task to - * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will - * remain unchanged. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
-
- xQueueHandle xQueue;
-
- // Function to create a queue and post some values.
- void vAFunction( void *pvParameters )
- {
- char cValueToPost;
- const portTickType xBlockTime = ( portTickType )0xff;
-
-	// Create a queue capable of containing 10 characters.
-	xQueue = xQueueCreate( 10, sizeof( char ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Post some characters that will be used within an ISR.  If the queue
-	// is full then this task will block for xBlockTime ticks.
-	cValueToPost = 'a';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
-	cValueToPost = 'b';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
-
-	// ... keep posting characters ... this task may block when the queue
-	// becomes full.
-
-	cValueToPost = 'c';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
- }
-
- // ISR that outputs all the characters received on the queue.
- void vISR_Routine( void )
- {
- portBASE_TYPE xTaskWokenByReceive = pdFALSE;
- char cRxedChar;
-
-	while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
-	{
-		// A character was received.  Output the character now.
-		vOutputCharacter( cRxedChar );
-
-		// If removing the character from the queue woke the task that was
-		// posting onto the queue cTaskWokenByReceive will have been set to
-		// pdTRUE.  No matter how many times this loop iterates only one
-		// task will be woken.
-	}
-
-	if( cTaskWokenByPost != ( char ) pdFALSE;
-	{
-		taskYIELD ();
-	}
- }
- 
- * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR - * \ingroup QueueManagement - */ -signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ); - -/* - * Utilities to query queue that are safe to use from an ISR. These utilities - * should be used only from witin an ISR, or within a critical section. - */ -signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ); -signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ); -unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ); - - -/* - * xQueueAltGenericSend() is an alternative version of xQueueGenericSend(). - * Likewise xQueueAltGenericReceive() is an alternative version of - * xQueueGenericReceive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); -signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ); -#define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) -#define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) -#define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) -#define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) - -/* - * The functions defined above are for passing data to and from tasks. The - * functions below are the equivalents for passing data to and from - * co-routines. - * - * These functions are called from the co-routine macro implementation and - * should not be called directly from application code. Instead use the macro - * wrappers defined within croutine.h. - */ -signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ); -signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ); -signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ); -signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ); - -/* - * For internal use only. Use xSemaphoreCreateMutex() or - * xSemaphoreCreateCounting() instead of calling these functions directly. - */ -xQueueHandle xQueueCreateMutex( void ); -xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ); - -/* - * For internal use only. Use xSemaphoreTakeMutexRecursive() or - * xSemaphoreGiveMutexRecursive() instead of calling these functions directly. - */ -portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime ); -portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex ); - -/* - * The registry is provided as a means for kernel aware debuggers to - * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add - * a queue, semaphore or mutex handle to the registry if you want the handle - * to be available to a kernel aware debugger. If you are not using a kernel - * aware debugger then this function can be ignored. - * - * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the - * registry can hold. configQUEUE_REGISTRY_SIZE must be greater than 0 - * within FreeRTOSConfig.h for the registry to be available. Its value - * does not effect the number of queues, semaphores and mutexes that can be - * created - just the number that the registry can hold. - * - * @param xQueue The handle of the queue being added to the registry. This - * is the handle returned by a call to xQueueCreate(). Semaphore and mutex - * handles can also be passed in here. - * - * @param pcName The name to be associated with the handle. This is the - * name that the kernel aware debugger will display. - */ -#if configQUEUE_REGISTRY_SIZE > 0U - void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName ); -#endif - -/* Not a public API function, hence the 'Restricted' in the name. */ -void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ); - - -#ifdef __cplusplus -} -#endif - -#endif /* QUEUE_H */ - diff --git a/GD32F1/libraries/FreeRTOS/utility/semphr.h b/GD32F1/libraries/FreeRTOS/utility/semphr.h deleted file mode 100644 index 7a9e83f..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/semphr.h +++ /dev/null @@ -1,717 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -#ifndef SEMAPHORE_H -#define SEMAPHORE_H - -#ifndef INC_FREERTOS_H - #error "#include FreeRTOS.h" must appear in source files before "#include semphr.h" -#endif - -#include "queue.h" - -typedef xQueueHandle xSemaphoreHandle; - -#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( unsigned char ) 1U ) -#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned char ) 0U ) -#define semGIVE_BLOCK_TIME ( ( portTickType ) 0U ) - - -/** - * semphr. h - *
vSemaphoreCreateBinary( xSemaphoreHandle xSemaphore )
- * - * Macro that implements a semaphore by using the existing queue mechanism. - * The queue length is 1 as this is a binary semaphore. The data size is 0 - * as we don't want to actually store any data - we just want to know if the - * queue is empty or full. - * - * This type of semaphore can be used for pure synchronisation between tasks or - * between an interrupt and a task. The semaphore need not be given back once - * obtained, so one task/interrupt can continuously 'give' the semaphore while - * another continuously 'takes' the semaphore. For this reason this type of - * semaphore does not use a priority inheritance mechanism. For an alternative - * that does use priority inheritance see xSemaphoreCreateMutex(). - * - * @param xSemaphore Handle to the created semaphore. Should be of type xSemaphoreHandle. - * - * Example usage: -
- xSemaphoreHandle xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
-    // This is a macro so pass the variable in directly.
-    vSemaphoreCreateBinary( xSemaphore );
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.  
-    }
- }
- 
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary - * \ingroup Semaphores - */ -#define vSemaphoreCreateBinary( xSemaphore ) { \ - ( xSemaphore ) = xQueueCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH ); \ - if( ( xSemaphore ) != NULL ) \ - { \ - xSemaphoreGive( ( xSemaphore ) ); \ - } \ - } - -/** - * semphr. h - *
xSemaphoreTake( 
- *                   xSemaphoreHandle xSemaphore, 
- *                   portTickType xBlockTime 
- *               )
- * - * Macro to obtain a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or - * xSemaphoreCreateCounting(). - * - * @param xSemaphore A handle to the semaphore being taken - obtained when - * the semaphore was created. - * - * @param xBlockTime The time in ticks to wait for the semaphore to become - * available. The macro portTICK_RATE_MS can be used to convert this to a - * real time. A block time of zero can be used to poll the semaphore. A block - * time of portMAX_DELAY can be used to block indefinitely (provided - * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h). - * - * @return pdTRUE if the semaphore was obtained. pdFALSE - * if xBlockTime expired without the semaphore becoming available. - * - * Example usage: -
- xSemaphoreHandle xSemaphore = NULL;
-
- // A task that creates a semaphore.
- void vATask( void * pvParameters )
- {
-    // Create the semaphore to guard a shared resource.
-    vSemaphoreCreateBinary( xSemaphore );
- }
-
- // A task that uses the semaphore.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xSemaphore != NULL )
-    {
-        // See if we can obtain the semaphore.  If the semaphore is not available
-        // wait 10 ticks to see if it becomes free.	
-        if( xSemaphoreTake( xSemaphore, ( portTickType ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the semaphore and can now access the
-            // shared resource.
-
-            // ...
-
-            // We have finished accessing the shared resource.  Release the 
-            // semaphore.
-            xSemaphoreGive( xSemaphore );
-        }
-        else
-        {
-            // We could not obtain the semaphore and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreTake xSemaphoreTake - * \ingroup Semaphores - */ -#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) - -/** - * semphr. h - * xSemaphoreTakeRecursive( - * xSemaphoreHandle xMutex, - * portTickType xBlockTime - * ) - * - * Macro to recursively obtain, or 'take', a mutex type semaphore. - * The mutex must have previously been created using a call to - * xSemaphoreCreateRecursiveMutex(); - * - * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this - * macro to be available. - * - * This macro must not be used on mutexes created using xSemaphoreCreateMutex(). - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * @param xMutex A handle to the mutex being obtained. This is the - * handle returned by xSemaphoreCreateRecursiveMutex(); - * - * @param xBlockTime The time in ticks to wait for the semaphore to become - * available. The macro portTICK_RATE_MS can be used to convert this to a - * real time. A block time of zero can be used to poll the semaphore. If - * the task already owns the semaphore then xSemaphoreTakeRecursive() will - * return immediately no matter what the value of xBlockTime. - * - * @return pdTRUE if the semaphore was obtained. pdFALSE if xBlockTime - * expired without the semaphore becoming available. - * - * Example usage: -
- xSemaphoreHandle xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
-    // Create the mutex to guard a shared resource.
-    xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xMutex != NULL )
-    {
-        // See if we can obtain the mutex.  If the mutex is not available
-        // wait 10 ticks to see if it becomes free.	
-        if( xSemaphoreTakeRecursive( xSemaphore, ( portTickType ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the mutex and can now access the
-            // shared resource.
-
-            // ...
-            // For some reason due to the nature of the code further calls to 
-			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
-			// code these would not be just sequential calls as this would make
-			// no sense.  Instead the calls are likely to be buried inside
-			// a more complex call structure.
-            xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 );
-            xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 );
-
-            // The mutex has now been 'taken' three times, so will not be 
-			// available to another task until it has also been given back
-			// three times.  Again it is unlikely that real code would have
-			// these calls sequentially, but instead buried in a more complex
-			// call structure.  This is just for illustrative purposes.
-            xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-
-			// Now the mutex can be taken by other tasks.
-        }
-        else
-        {
-            // We could not obtain the mutex and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive - * \ingroup Semaphores - */ -#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) - - -/* - * xSemaphoreAltTake() is an alternative version of xSemaphoreTake(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) - -/** - * semphr. h - *
xSemaphoreGive( xSemaphoreHandle xSemaphore )
- * - * Macro to release a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or - * xSemaphoreCreateCounting(). and obtained using sSemaphoreTake(). - * - * This macro must not be used from an ISR. See xSemaphoreGiveFromISR () for - * an alternative which can be used from an ISR. - * - * This macro must also not be used on semaphores created using - * xSemaphoreCreateRecursiveMutex(). - * - * @param xSemaphore A handle to the semaphore being released. This is the - * handle returned when the semaphore was created. - * - * @return pdTRUE if the semaphore was released. pdFALSE if an error occurred. - * Semaphores are implemented using queues. An error can occur if there is - * no space on the queue to post a message - indicating that the - * semaphore was not first obtained correctly. - * - * Example usage: -
- xSemaphoreHandle xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Create the semaphore to guard a shared resource.
-    vSemaphoreCreateBinary( xSemaphore );
-
-    if( xSemaphore != NULL )
-    {
-        if( xSemaphoreGive( xSemaphore ) != pdTRUE )
-        {
-            // We would expect this call to fail because we cannot give
-            // a semaphore without first "taking" it!
-        }
-
-        // Obtain the semaphore - don't block if the semaphore is not
-        // immediately available.
-        if( xSemaphoreTake( xSemaphore, ( portTickType ) 0 ) )
-        {
-            // We now have the semaphore and can access the shared resource.
-
-            // ...
-
-            // We have finished accessing the shared resource so can free the
-            // semaphore.
-            if( xSemaphoreGive( xSemaphore ) != pdTRUE )
-            {
-                // We would not expect this call to fail because we must have
-                // obtained the semaphore to get here.
-            }
-        }
-    }
- }
- 
- * \defgroup xSemaphoreGive xSemaphoreGive - * \ingroup Semaphores - */ -#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** - * semphr. h - *
xSemaphoreGiveRecursive( xSemaphoreHandle xMutex )
- * - * Macro to recursively release, or 'give', a mutex type semaphore. - * The mutex must have previously been created using a call to - * xSemaphoreCreateRecursiveMutex(); - * - * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this - * macro to be available. - * - * This macro must not be used on mutexes created using xSemaphoreCreateMutex(). - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * @param xMutex A handle to the mutex being released, or 'given'. This is the - * handle returned by xSemaphoreCreateMutex(); - * - * @return pdTRUE if the semaphore was given. - * - * Example usage: -
- xSemaphoreHandle xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
-    // Create the mutex to guard a shared resource.
-    xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xMutex != NULL )
-    {
-        // See if we can obtain the mutex.  If the mutex is not available
-        // wait 10 ticks to see if it becomes free.	
-        if( xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the mutex and can now access the
-            // shared resource.
-
-            // ...
-            // For some reason due to the nature of the code further calls to 
-			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
-			// code these would not be just sequential calls as this would make
-			// no sense.  Instead the calls are likely to be buried inside
-			// a more complex call structure.
-            xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 );
-            xSemaphoreTakeRecursive( xMutex, ( portTickType ) 10 );
-
-            // The mutex has now been 'taken' three times, so will not be 
-			// available to another task until it has also been given back
-			// three times.  Again it is unlikely that real code would have
-			// these calls sequentially, it would be more likely that the calls
-			// to xSemaphoreGiveRecursive() would be called as a call stack
-			// unwound.  This is just for demonstrative purposes.
-            xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-
-			// Now the mutex can be taken by other tasks.
-        }
-        else
-        {
-            // We could not obtain the mutex and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive - * \ingroup Semaphores - */ -#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) - -/* - * xSemaphoreAltGive() is an alternative version of xSemaphoreGive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** - * semphr. h - *
- xSemaphoreGiveFromISR( 
-                          xSemaphoreHandle xSemaphore, 
-                          signed portBASE_TYPE *pxHigherPriorityTaskWoken
-                      )
- * - * Macro to release a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary() or xSemaphoreCreateCounting(). - * - * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) - * must not be used with this macro. - * - * This macro can be used from an ISR. - * - * @param xSemaphore A handle to the semaphore being released. This is the - * handle returned when the semaphore was created. - * - * @param pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if giving the semaphore caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xSemaphoreGiveFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the semaphore was successfully given, otherwise errQUEUE_FULL. - * - * Example usage: -
- \#define LONG_TIME 0xffff
- \#define TICKS_TO_WAIT	10
- xSemaphoreHandle xSemaphore = NULL;
-
- // Repetitive task.
- void vATask( void * pvParameters )
- {
-    for( ;; )
-    {
-        // We want this task to run every 10 ticks of a timer.  The semaphore 
-        // was created before this task was started.
-
-        // Block waiting for the semaphore to become available.
-        if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
-        {
-            // It is time to execute.
-
-            // ...
-
-            // We have finished our task.  Return to the top of the loop where
-            // we will block on the semaphore until it is time to execute 
-            // again.  Note when using the semaphore for synchronisation with an
-			// ISR in this manner there is no need to 'give' the semaphore back.
-        }
-    }
- }
-
- // Timer ISR
- void vTimerISR( void * pvParameters )
- {
- static unsigned char ucLocalTickCount = 0;
- static signed portBASE_TYPE xHigherPriorityTaskWoken;
-
-    // A timer tick has occurred.
-
-    // ... Do other time functions.
-
-    // Is it time for vATask () to run?
-	xHigherPriorityTaskWoken = pdFALSE;
-    ucLocalTickCount++;
-    if( ucLocalTickCount >= TICKS_TO_WAIT )
-    {
-        // Unblock the task by releasing the semaphore.
-        xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
-
-        // Reset the count so we release the semaphore again in 10 ticks time.
-        ucLocalTickCount = 0;
-    }
-
-    if( xHigherPriorityTaskWoken != pdFALSE )
-    {
-        // We can force a context switch here.  Context switching from an
-        // ISR uses port specific syntax.  Check the demo task for your port
-        // to find the syntax required.
-    }
- }
- 
- * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR - * \ingroup Semaphores - */ -#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) - -/** - * semphr. h - *
xSemaphoreHandle xSemaphoreCreateMutex( void )
- * - * Macro that implements a mutex semaphore by using the existing queue - * mechanism. - * - * Mutexes created using this macro can be accessed using the xSemaphoreTake() - * and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and - * xSemaphoreGiveRecursive() macros should not be used. - * - * This type of semaphore uses a priority inheritance mechanism so a task - * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the - * semaphore it is no longer required. - * - * Mutex type semaphores cannot be used from within interrupt service routines. - * - * See vSemaphoreCreateBinary() for an alternative implementation that can be - * used for pure synchronisation (where one task or interrupt always 'gives' the - * semaphore and another always 'takes' the semaphore) and from within interrupt - * service routines. - * - * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * xSemaphoreHandle. - * - * Example usage: -
- xSemaphoreHandle xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateMutex();
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.  
-    }
- }
- 
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex - * \ingroup Semaphores - */ -#define xSemaphoreCreateMutex() xQueueCreateMutex() - - -/** - * semphr. h - *
xSemaphoreHandle xSemaphoreCreateRecursiveMutex( void )
- * - * Macro that implements a recursive mutex by using the existing queue - * mechanism. - * - * Mutexes created using this macro can be accessed using the - * xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() macros. The - * xSemaphoreTake() and xSemaphoreGive() macros should not be used. - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * This type of semaphore uses a priority inheritance mechanism so a task - * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the - * semaphore it is no longer required. - * - * Mutex type semaphores cannot be used from within interrupt service routines. - * - * See vSemaphoreCreateBinary() for an alternative implementation that can be - * used for pure synchronisation (where one task or interrupt always 'gives' the - * semaphore and another always 'takes' the semaphore) and from within interrupt - * service routines. - * - * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * xSemaphoreHandle. - * - * Example usage: -
- xSemaphoreHandle xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateRecursiveMutex();
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.  
-    }
- }
- 
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex - * \ingroup Semaphores - */ -#define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex() - -/** - * semphr. h - *
xSemaphoreHandle xSemaphoreCreateCounting( unsigned portBASE_TYPE uxMaxCount, unsigned portBASE_TYPE uxInitialCount )
- * - * Macro that creates a counting semaphore by using the existing - * queue mechanism. - * - * Counting semaphores are typically used for two things: - * - * 1) Counting events. - * - * In this usage scenario an event handler will 'give' a semaphore each time - * an event occurs (incrementing the semaphore count value), and a handler - * task will 'take' a semaphore each time it processes an event - * (decrementing the semaphore count value). The count value is therefore - * the difference between the number of events that have occurred and the - * number that have been processed. In this case it is desirable for the - * initial count value to be zero. - * - * 2) Resource management. - * - * In this usage scenario the count value indicates the number of resources - * available. To obtain control of a resource a task must first obtain a - * semaphore - decrementing the semaphore count value. When the count value - * reaches zero there are no free resources. When a task finishes with the - * resource it 'gives' the semaphore back - incrementing the semaphore count - * value. In this case it is desirable for the initial count value to be - * equal to the maximum count value, indicating that all resources are free. - * - * @param uxMaxCount The maximum count value that can be reached. When the - * semaphore reaches this value it can no longer be 'given'. - * - * @param uxInitialCount The count value assigned to the semaphore when it is - * created. - * - * @return Handle to the created semaphore. Null if the semaphore could not be - * created. - * - * Example usage: -
- xSemaphoreHandle xSemaphore;
-
- void vATask( void * pvParameters )
- {
- xSemaphoreHandle xSemaphore = NULL;
-
-    // Semaphore cannot be used before a call to xSemaphoreCreateCounting().
-    // The max value to which the semaphore can count should be 10, and the
-    // initial value assigned to the count should be 0.
-    xSemaphore = xSemaphoreCreateCounting( 10, 0 );
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.  
-    }
- }
- 
- * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting - * \ingroup Semaphores - */ -#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) - - -#endif /* SEMAPHORE_H */ - - diff --git a/GD32F1/libraries/FreeRTOS/utility/task.h b/GD32F1/libraries/FreeRTOS/utility/task.h deleted file mode 100644 index 96ba68e..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/task.h +++ /dev/null @@ -1,1307 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - - -#ifndef TASK_H -#define TASK_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include task.h" -#endif - -#include "portable.h" -#include "list.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*----------------------------------------------------------- - * MACROS AND DEFINITIONS - *----------------------------------------------------------*/ - -#define tskKERNEL_VERSION_NUMBER "V7.0.1" - -/** - * task. h - * - * Type by which tasks are referenced. For example, a call to xTaskCreate - * returns (via a pointer parameter) an xTaskHandle variable that can then - * be used as a parameter to vTaskDelete to delete the task. - * - * \page xTaskHandle xTaskHandle - * \ingroup Tasks - */ -typedef void * xTaskHandle; - -/* - * Used internally only. - */ -typedef struct xTIME_OUT -{ - portBASE_TYPE xOverflowCount; - portTickType xTimeOnEntering; -} xTimeOutType; - -/* - * Defines the memory ranges allocated to the task when an MPU is used. - */ -typedef struct xMEMORY_REGION -{ - void *pvBaseAddress; - unsigned long ulLengthInBytes; - unsigned long ulParameters; -} xMemoryRegion; - -/* - * Parameters required to create an MPU protected task. - */ -typedef struct xTASK_PARAMTERS -{ - pdTASK_CODE pvTaskCode; - const signed char * const pcName; - unsigned short usStackDepth; - void *pvParameters; - unsigned portBASE_TYPE uxPriority; - portSTACK_TYPE *puxStackBuffer; - xMemoryRegion xRegions[ portNUM_CONFIGURABLE_REGIONS ]; -} xTaskParameters; - -/* - * Defines the priority used by the idle task. This must not be modified. - * - * \ingroup TaskUtils - */ -#define tskIDLE_PRIORITY ( ( unsigned portBASE_TYPE ) 0U ) - -/** - * task. h - * - * Macro for forcing a context switch. - * - * \page taskYIELD taskYIELD - * \ingroup SchedulerControl - */ -#define taskYIELD() portYIELD() - -/** - * task. h - * - * Macro to mark the start of a critical code region. Preemptive context - * switches cannot occur when in a critical region. - * - * NOTE: This may alter the stack (depending on the portable implementation) - * so must be used with care! - * - * \page taskENTER_CRITICAL taskENTER_CRITICAL - * \ingroup SchedulerControl - */ -#define taskENTER_CRITICAL() portENTER_CRITICAL() - -/** - * task. h - * - * Macro to mark the end of a critical code region. Preemptive context - * switches cannot occur when in a critical region. - * - * NOTE: This may alter the stack (depending on the portable implementation) - * so must be used with care! - * - * \page taskEXIT_CRITICAL taskEXIT_CRITICAL - * \ingroup SchedulerControl - */ -#define taskEXIT_CRITICAL() portEXIT_CRITICAL() - -/** - * task. h - * - * Macro to disable all maskable interrupts. - * - * \page taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS - * \ingroup SchedulerControl - */ -#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() - -/** - * task. h - * - * Macro to enable microcontroller interrupts. - * - * \page taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS - * \ingroup SchedulerControl - */ -#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() - -/* Definitions returned by xTaskGetSchedulerState(). */ -#define taskSCHEDULER_NOT_STARTED 0 -#define taskSCHEDULER_RUNNING 1 -#define taskSCHEDULER_SUSPENDED 2 - -/*----------------------------------------------------------- - * TASK CREATION API - *----------------------------------------------------------*/ - -/** - * task. h - *
- portBASE_TYPE xTaskCreate(
-							  pdTASK_CODE pvTaskCode,
-							  const char * const pcName,
-							  unsigned short usStackDepth,
-							  void *pvParameters,
-							  unsigned portBASE_TYPE uxPriority,
-							  xTaskHandle *pvCreatedTask
-						  );
- * - * Create a new task and add it to the list of tasks that are ready to run. - * - * xTaskCreate() can only be used to create a task that has unrestricted - * access to the entire microcontroller memory map. Systems that include MPU - * support can alternatively create an MPU constrained task using - * xTaskCreateRestricted(). - * - * @param pvTaskCode Pointer to the task entry function. Tasks - * must be implemented to never return (i.e. continuous loop). - * - * @param pcName A descriptive name for the task. This is mainly used to - * facilitate debugging. Max length defined by tskMAX_TASK_NAME_LEN - default - * is 16. - * - * @param usStackDepth The size of the task stack specified as the number of - * variables the stack can hold - not the number of bytes. For example, if - * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes - * will be allocated for stack storage. - * - * @param pvParameters Pointer that will be used as the parameter for the task - * being created. - * - * @param uxPriority The priority at which the task should run. Systems that - * include MPU support can optionally create tasks in a privileged (system) - * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For - * example, to create a privileged task at priority 2 the uxPriority parameter - * should be set to ( 2 | portPRIVILEGE_BIT ). - * - * @param pvCreatedTask Used to pass back a handle by which the created task - * can be referenced. - * - * @return pdPASS if the task was successfully created and added to a ready - * list, otherwise an error code defined in the file errors. h - * - * Example usage: -
- // Task to be created.
- void vTaskCode( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-	 }
- }
-
- // Function that creates a task.
- void vOtherFunction( void )
- {
- static unsigned char ucParameterToPass;
- xTaskHandle xHandle;
-
-	 // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass
-	 // must exist for the lifetime of the task, so in this case is declared static.  If it was just an
-	 // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
-	 // the new task attempts to access it.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
-
-	 // Use the handle to delete the task.
-	 vTaskDelete( xHandle );
- }
-   
- * \defgroup xTaskCreate xTaskCreate - * \ingroup Tasks - */ -#define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) ) - -/** - * task. h - *
- portBASE_TYPE xTaskCreateRestricted( xTaskParameters *pxTaskDefinition, xTaskHandle *pxCreatedTask );
- * - * xTaskCreateRestricted() should only be used in systems that include an MPU - * implementation. - * - * Create a new task and add it to the list of tasks that are ready to run. - * The function parameters define the memory regions and associated access - * permissions allocated to the task. - * - * @param pxTaskDefinition Pointer to a structure that contains a member - * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API - * documentation) plus an optional stack buffer and the memory region - * definitions. - * - * @param pxCreatedTask Used to pass back a handle by which the created task - * can be referenced. - * - * @return pdPASS if the task was successfully created and added to a ready - * list, otherwise an error code defined in the file errors. h - * - * Example usage: -
-// Create an xTaskParameters structure that defines the task to be created.
-static const xTaskParameters xCheckTaskParameters =
-{
-	vATask,		// pvTaskCode - the function that implements the task.
-	"ATask",	// pcName - just a text name for the task to assist debugging.
-	100,		// usStackDepth	- the stack size DEFINED IN WORDS.
-	NULL,		// pvParameters - passed into the task function as the function parameters.
-	( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
-	cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
-
-	// xRegions - Allocate up to three separate memory regions for access by
-	// the task, with appropriate access permissions.  Different processors have
-	// different memory alignment requirements - refer to the FreeRTOS documentation
-	// for full information.
-	{											
-		// Base address					Length	Parameters
-        { cReadWriteArray,				32,		portMPU_REGION_READ_WRITE },
-        { cReadOnlyArray,				32,		portMPU_REGION_READ_ONLY },
-        { cPrivilegedOnlyAccessArray,	128,	portMPU_REGION_PRIVILEGED_READ_WRITE }
-	}
-};
-
-int main( void )
-{
-xTaskHandle xHandle;
-
-	// Create a task from the const structure defined above.  The task handle
-	// is requested (the second parameter is not NULL) but in this case just for
-	// demonstration purposes as its not actually used.
-	xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
-
-	// Start the scheduler.
-	vTaskStartScheduler();
-
-	// Will only get here if there was insufficient memory to create the idle
-	// task.
-	for( ;; );
-}
-   
- * \defgroup xTaskCreateRestricted xTaskCreateRestricted - * \ingroup Tasks - */ -#define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) ) - -/** - * task. h - *
- void vTaskAllocateMPURegions( xTaskHandle xTask, const xMemoryRegion * const pxRegions );
- * - * Memory regions are assigned to a restricted task when the task is created by - * a call to xTaskCreateRestricted(). These regions can be redefined using - * vTaskAllocateMPURegions(). - * - * @param xTask The handle of the task being updated. - * - * @param xRegions A pointer to an xMemoryRegion structure that contains the - * new memory region definitions. - * - * Example usage: -
-// Define an array of xMemoryRegion structures that configures an MPU region
-// allowing read/write access for 1024 bytes starting at the beginning of the
-// ucOneKByte array.  The other two of the maximum 3 definable regions are
-// unused so set to zero.
-static const xMemoryRegion xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
-{											
-	// Base address		Length		Parameters
-	{ ucOneKByte,		1024,		portMPU_REGION_READ_WRITE },
-	{ 0,				0,			0 },
-	{ 0,				0,			0 }
-};
-
-void vATask( void *pvParameters )
-{
-	// This task was created such that it has access to certain regions of
-	// memory as defined by the MPU configuration.  At some point it is
-	// desired that these MPU regions are replaced with that defined in the
-	// xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()
-	// for this purpose.  NULL is used as the task handle to indicate that this
-	// function should modify the MPU regions of the calling task.
-	vTaskAllocateMPURegions( NULL, xAltRegions );
-	
-	// Now the task can continue its function, but from this point on can only
-	// access its stack and the ucOneKByte array (unless any other statically
-	// defined or shared regions have been declared elsewhere).
-}
-   
- * \defgroup xTaskCreateRestricted xTaskCreateRestricted - * \ingroup Tasks - */ -void vTaskAllocateMPURegions( xTaskHandle xTask, const xMemoryRegion * const pxRegions ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskDelete( xTaskHandle pxTask );
- * - * INCLUDE_vTaskDelete must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Remove a task from the RTOS real time kernels management. The task being - * deleted will be removed from all ready, blocked, suspended and event lists. - * - * NOTE: The idle task is responsible for freeing the kernel allocated - * memory from tasks that have been deleted. It is therefore important that - * the idle task is not starved of microcontroller processing time if your - * application makes any calls to vTaskDelete (). Memory allocated by the - * task code is not automatically freed, and should be freed before the task - * is deleted. - * - * See the demo application file death.c for sample code that utilises - * vTaskDelete (). - * - * @param pxTask The handle of the task to be deleted. Passing NULL will - * cause the calling task to be deleted. - * - * Example usage: -
- void vOtherFunction( void )
- {
- xTaskHandle xHandle;
-
-	 // Create the task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // Use the handle to delete the task.
-	 vTaskDelete( xHandle );
- }
-   
- * \defgroup vTaskDelete vTaskDelete - * \ingroup Tasks - */ -void vTaskDelete( xTaskHandle pxTaskToDelete ) PRIVILEGED_FUNCTION; - -/*----------------------------------------------------------- - * TASK CONTROL API - *----------------------------------------------------------*/ - -/** - * task. h - *
void vTaskDelay( portTickType xTicksToDelay );
- * - * Delay a task for a given number of ticks. The actual time that the - * task remains blocked depends on the tick rate. The constant - * portTICK_RATE_MS can be used to calculate real time from the tick - * rate - with the resolution of one tick period. - * - * INCLUDE_vTaskDelay must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * - * vTaskDelay() specifies a time at which the task wishes to unblock relative to - * the time at which vTaskDelay() is called. For example, specifying a block - * period of 100 ticks will cause the task to unblock 100 ticks after - * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method - * of controlling the frequency of a cyclical task as the path taken through the - * code, as well as other task and interrupt activity, will effect the frequency - * at which vTaskDelay() gets called and therefore the time at which the task - * next executes. See vTaskDelayUntil() for an alternative API function designed - * to facilitate fixed frequency execution. It does this by specifying an - * absolute time (rather than a relative time) at which the calling task should - * unblock. - * - * @param xTicksToDelay The amount of time, in tick periods, that - * the calling task should block. - * - * Example usage: - - void vTaskFunction( void * pvParameters ) - { - void vTaskFunction( void * pvParameters ) - { - // Block for 500ms. - const portTickType xDelay = 500 / portTICK_RATE_MS; - - for( ;; ) - { - // Simply toggle the LED every 500ms, blocking between each toggle. - vToggleLED(); - vTaskDelay( xDelay ); - } - } - - * \defgroup vTaskDelay vTaskDelay - * \ingroup TaskCtrl - */ -void vTaskDelay( portTickType xTicksToDelay ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrement );
- * - * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Delay a task until a specified time. This function can be used by cyclical - * tasks to ensure a constant execution frequency. - * - * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will - * cause a task to block for the specified number of ticks from the time vTaskDelay () is - * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed - * execution frequency as the time between a task starting to execute and that task - * calling vTaskDelay () may not be fixed [the task may take a different path though the - * code between calls, or may get interrupted or preempted a different number of times - * each time it executes]. - * - * Whereas vTaskDelay () specifies a wake time relative to the time at which the function - * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to - * unblock. - * - * The constant portTICK_RATE_MS can be used to calculate real time from the tick - * rate - with the resolution of one tick period. - * - * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the - * task was last unblocked. The variable must be initialised with the current time - * prior to its first use (see the example below). Following this the variable is - * automatically updated within vTaskDelayUntil (). - * - * @param xTimeIncrement The cycle time period. The task will be unblocked at - * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the - * same xTimeIncrement parameter value will cause the task to execute with - * a fixed interface period. - * - * Example usage: -
- // Perform an action every 10 ticks.
- void vTaskFunction( void * pvParameters )
- {
- portTickType xLastWakeTime;
- const portTickType xFrequency = 10;
-
-	 // Initialise the xLastWakeTime variable with the current time.
-	 xLastWakeTime = xTaskGetTickCount ();
-	 for( ;; )
-	 {
-		 // Wait for the next cycle.
-		 vTaskDelayUntil( &xLastWakeTime, xFrequency );
-
-		 // Perform action here.
-	 }
- }
-   
- * \defgroup vTaskDelayUntil vTaskDelayUntil - * \ingroup TaskCtrl - */ -void vTaskDelayUntil( portTickType * const pxPreviousWakeTime, portTickType xTimeIncrement ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );
- * - * INCLUDE_xTaskPriorityGet must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Obtain the priority of any task. - * - * @param pxTask Handle of the task to be queried. Passing a NULL - * handle results in the priority of the calling task being returned. - * - * @return The priority of pxTask. - * - * Example usage: -
- void vAFunction( void )
- {
- xTaskHandle xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to obtain the priority of the created task.
-	 // It was created with tskIDLE_PRIORITY, but may have changed
-	 // it itself.
-	 if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
-	 {
-		 // The task has changed it's priority.
-	 }
-
-	 // ...
-
-	 // Is our priority higher than the created task?
-	 if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
-	 {
-		 // Our priority (obtained using NULL handle) is higher.
-	 }
- }
-   
- * \defgroup uxTaskPriorityGet uxTaskPriorityGet - * \ingroup TaskCtrl - */ -unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );
- * - * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Set the priority of any task. - * - * A context switch will occur before the function returns if the priority - * being set is higher than the currently executing task. - * - * @param pxTask Handle to the task for which the priority is being set. - * Passing a NULL handle results in the priority of the calling task being set. - * - * @param uxNewPriority The priority to which the task will be set. - * - * Example usage: -
- void vAFunction( void )
- {
- xTaskHandle xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to raise the priority of the created task.
-	 vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
-
-	 // ...
-
-	 // Use a NULL handle to raise our priority to the same value.
-	 vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
- }
-   
- * \defgroup vTaskPrioritySet vTaskPrioritySet - * \ingroup TaskCtrl - */ -void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskSuspend( xTaskHandle pxTaskToSuspend );
- * - * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Suspend any task. When suspended a task will never get any microcontroller - * processing time, no matter what its priority. - * - * Calls to vTaskSuspend are not accumulative - - * i.e. calling vTaskSuspend () twice on the same task still only requires one - * call to vTaskResume () to ready the suspended task. - * - * @param pxTaskToSuspend Handle to the task being suspended. Passing a NULL - * handle will cause the calling task to be suspended. - * - * Example usage: -
- void vAFunction( void )
- {
- xTaskHandle xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to suspend the created task.
-	 vTaskSuspend( xHandle );
-
-	 // ...
-
-	 // The created task will not run during this period, unless
-	 // another task calls vTaskResume( xHandle ).
-
-	 //...
-
-
-	 // Suspend ourselves.
-	 vTaskSuspend( NULL );
-
-	 // We cannot get here unless another task calls vTaskResume
-	 // with our handle as the parameter.
- }
-   
- * \defgroup vTaskSuspend vTaskSuspend - * \ingroup TaskCtrl - */ -void vTaskSuspend( xTaskHandle pxTaskToSuspend ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskResume( xTaskHandle pxTaskToResume );
- * - * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Resumes a suspended task. - * - * A task that has been suspended by one of more calls to vTaskSuspend () - * will be made available for running again by a single call to - * vTaskResume (). - * - * @param pxTaskToResume Handle to the task being readied. - * - * Example usage: -
- void vAFunction( void )
- {
- xTaskHandle xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to suspend the created task.
-	 vTaskSuspend( xHandle );
-
-	 // ...
-
-	 // The created task will not run during this period, unless
-	 // another task calls vTaskResume( xHandle ).
-
-	 //...
-
-
-	 // Resume the suspended task ourselves.
-	 vTaskResume( xHandle );
-
-	 // The created task will once again get microcontroller processing
-	 // time in accordance with it priority within the system.
- }
-   
- * \defgroup vTaskResume vTaskResume - * \ingroup TaskCtrl - */ -void vTaskResume( xTaskHandle pxTaskToResume ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void xTaskResumeFromISR( xTaskHandle pxTaskToResume );
- * - * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be - * available. See the configuration section for more information. - * - * An implementation of vTaskResume() that can be called from within an ISR. - * - * A task that has been suspended by one of more calls to vTaskSuspend () - * will be made available for running again by a single call to - * xTaskResumeFromISR (). - * - * @param pxTaskToResume Handle to the task being readied. - * - * \defgroup vTaskResumeFromISR vTaskResumeFromISR - * \ingroup TaskCtrl - */ -portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume ) PRIVILEGED_FUNCTION; - -/*----------------------------------------------------------- - * SCHEDULER CONTROL - *----------------------------------------------------------*/ - -/** - * task. h - *
void vTaskStartScheduler( void );
- * - * Starts the real time kernel tick processing. After calling the kernel - * has control over which tasks are executed and when. This function - * does not return until an executing task calls vTaskEndScheduler (). - * - * At least one task should be created via a call to xTaskCreate () - * before calling vTaskStartScheduler (). The idle task is created - * automatically when the first application task is created. - * - * See the demo application file main.c for an example of creating - * tasks and starting the kernel. - * - * Example usage: -
- void vAFunction( void )
- {
-	 // Create at least one task before starting the kernel.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
-
-	 // Start the real time kernel with preemption.
-	 vTaskStartScheduler ();
-
-	 // Will not get here unless a task calls vTaskEndScheduler ()
- }
-   
- * - * \defgroup vTaskStartScheduler vTaskStartScheduler - * \ingroup SchedulerControl - */ -void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskEndScheduler( void );
- * - * Stops the real time kernel tick. All created tasks will be automatically - * deleted and multitasking (either preemptive or cooperative) will - * stop. Execution then resumes from the point where vTaskStartScheduler () - * was called, as if vTaskStartScheduler () had just returned. - * - * See the demo application file main. c in the demo/PC directory for an - * example that uses vTaskEndScheduler (). - * - * vTaskEndScheduler () requires an exit function to be defined within the - * portable layer (see vPortEndScheduler () in port. c for the PC port). This - * performs hardware specific operations such as stopping the kernel tick. - * - * vTaskEndScheduler () will cause all of the resources allocated by the - * kernel to be freed - but will not free resources allocated by application - * tasks. - * - * Example usage: -
- void vTaskCode( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // At some point we want to end the real time kernel processing
-		 // so call ...
-		 vTaskEndScheduler ();
-	 }
- }
-
- void vAFunction( void )
- {
-	 // Create at least one task before starting the kernel.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
-
-	 // Start the real time kernel with preemption.
-	 vTaskStartScheduler ();
-
-	 // Will only get here when the vTaskCode () task has called
-	 // vTaskEndScheduler ().  When we get here we are back to single task
-	 // execution.
- }
-   
- * - * \defgroup vTaskEndScheduler vTaskEndScheduler - * \ingroup SchedulerControl - */ -void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskSuspendAll( void );
- * - * Suspends all real time kernel activity while keeping interrupts (including the - * kernel tick) enabled. - * - * After calling vTaskSuspendAll () the calling task will continue to execute - * without risk of being swapped out until a call to xTaskResumeAll () has been - * made. - * - * API functions that have the potential to cause a context switch (for example, - * vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler - * is suspended. - * - * Example usage: -
- void vTask1( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // ...
-
-		 // At some point the task wants to perform a long operation during
-		 // which it does not want to get swapped out.  It cannot use
-		 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
-		 // operation may cause interrupts to be missed - including the
-		 // ticks.
-
-		 // Prevent the real time kernel swapping out the task.
-		 vTaskSuspendAll ();
-
-		 // Perform the operation here.  There is no need to use critical
-		 // sections as we have all the microcontroller processing time.
-		 // During this time interrupts will still operate and the kernel
-		 // tick count will be maintained.
-
-		 // ...
-
-		 // The operation is complete.  Restart the kernel.
-		 xTaskResumeAll ();
-	 }
- }
-   
- * \defgroup vTaskSuspendAll vTaskSuspendAll - * \ingroup SchedulerControl - */ -void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
char xTaskResumeAll( void );
- * - * Resumes real time kernel activity following a call to vTaskSuspendAll (). - * After a call to vTaskSuspendAll () the kernel will take control of which - * task is executing at any time. - * - * @return If resuming the scheduler caused a context switch then pdTRUE is - * returned, otherwise pdFALSE is returned. - * - * Example usage: -
- void vTask1( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // ...
-
-		 // At some point the task wants to perform a long operation during
-		 // which it does not want to get swapped out.  It cannot use
-		 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
-		 // operation may cause interrupts to be missed - including the
-		 // ticks.
-
-		 // Prevent the real time kernel swapping out the task.
-		 vTaskSuspendAll ();
-
-		 // Perform the operation here.  There is no need to use critical
-		 // sections as we have all the microcontroller processing time.
-		 // During this time interrupts will still operate and the real
-		 // time kernel tick count will be maintained.
-
-		 // ...
-
-		 // The operation is complete.  Restart the kernel.  We want to force
-		 // a context switch - but there is no point if resuming the scheduler
-		 // caused a context switch already.
-		 if( !xTaskResumeAll () )
-		 {
-			  taskYIELD ();
-		 }
-	 }
- }
-   
- * \defgroup xTaskResumeAll xTaskResumeAll - * \ingroup SchedulerControl - */ -signed portBASE_TYPE xTaskResumeAll( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
signed portBASE_TYPE xTaskIsTaskSuspended( xTaskHandle xTask );
- * - * Utility task that simply returns pdTRUE if the task referenced by xTask is - * currently in the Suspended state, or pdFALSE if the task referenced by xTask - * is in any other state. - * - */ -signed portBASE_TYPE xTaskIsTaskSuspended( xTaskHandle xTask ) PRIVILEGED_FUNCTION; - -/*----------------------------------------------------------- - * TASK UTILITIES - *----------------------------------------------------------*/ - -/** - * task. h - *
portTickType xTaskGetTickCount( void );
- * - * @return The count of ticks since vTaskStartScheduler was called. - * - * \page xTaskGetTickCount xTaskGetTickCount - * \ingroup TaskUtils - */ -portTickType xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
portTickType xTaskGetTickCountFromISR( void );
- * - * @return The count of ticks since vTaskStartScheduler was called. - * - * This is a version of xTaskGetTickCount() that is safe to be called from an - * ISR - provided that portTickType is the natural word size of the - * microcontroller being used or interrupt nesting is either not supported or - * not being used. - * - * \page xTaskGetTickCount xTaskGetTickCount - * \ingroup TaskUtils - */ -portTickType xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
unsigned short uxTaskGetNumberOfTasks( void );
- * - * @return The number of tasks that the real time kernel is currently managing. - * This includes all ready, blocked and suspended tasks. A task that - * has been deleted but not yet freed by the idle task will also be - * included in the count. - * - * \page uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks - * \ingroup TaskUtils - */ -unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskList( char *pcWriteBuffer );
- * - * configUSE_TRACE_FACILITY must be defined as 1 for this function to be - * available. See the configuration section for more information. - * - * NOTE: This function will disable interrupts for its duration. It is - * not intended for normal application runtime use but as a debug aid. - * - * Lists all the current tasks, along with their current state and stack - * usage high water mark. - * - * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or - * suspended ('S'). - * - * @param pcWriteBuffer A buffer into which the above mentioned details - * will be written, in ascii form. This buffer is assumed to be large - * enough to contain the generated report. Approximately 40 bytes per - * task should be sufficient. - * - * \page vTaskList vTaskList - * \ingroup TaskUtils - */ -void vTaskList( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskGetRunTimeStats( char *pcWriteBuffer );
- * - * configGENERATE_RUN_TIME_STATS must be defined as 1 for this function - * to be available. The application must also then provide definitions - * for portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and - * portGET_RUN_TIME_COUNTER_VALUE to configure a peripheral timer/counter - * and return the timers current count value respectively. The counter - * should be at least 10 times the frequency of the tick count. - * - * NOTE: This function will disable interrupts for its duration. It is - * not intended for normal application runtime use but as a debug aid. - * - * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total - * accumulated execution time being stored for each task. The resolution - * of the accumulated time value depends on the frequency of the timer - * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. - * Calling vTaskGetRunTimeStats() writes the total execution time of each - * task into a buffer, both as an absolute count value and as a percentage - * of the total system execution time. - * - * @param pcWriteBuffer A buffer into which the execution times will be - * written, in ascii form. This buffer is assumed to be large enough to - * contain the generated report. Approximately 40 bytes per task should - * be sufficient. - * - * \page vTaskGetRunTimeStats vTaskGetRunTimeStats - * \ingroup TaskUtils - */ -void vTaskGetRunTimeStats( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskStartTrace( char * pcBuffer, unsigned portBASE_TYPE uxBufferSize );
- * - * Starts a real time kernel activity trace. The trace logs the identity of - * which task is running when. - * - * The trace file is stored in binary format. A separate DOS utility called - * convtrce.exe is used to convert this into a tab delimited text file which - * can be viewed and plotted in a spread sheet. - * - * @param pcBuffer The buffer into which the trace will be written. - * - * @param ulBufferSize The size of pcBuffer in bytes. The trace will continue - * until either the buffer in full, or ulTaskEndTrace () is called. - * - * \page vTaskStartTrace vTaskStartTrace - * \ingroup TaskUtils - */ -void vTaskStartTrace( signed char * pcBuffer, unsigned long ulBufferSize ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
unsigned long ulTaskEndTrace( void );
- * - * Stops a kernel activity trace. See vTaskStartTrace (). - * - * @return The number of bytes that have been written into the trace buffer. - * - * \page usTaskEndTrace usTaskEndTrace - * \ingroup TaskUtils - */ -unsigned long ulTaskEndTrace( void ) PRIVILEGED_FUNCTION; - -/** - * task.h - *
unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask );
- * - * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for - * this function to be available. - * - * Returns the high water mark of the stack associated with xTask. That is, - * the minimum free stack space there has been (in words, so on a 32 bit machine - * a value of 1 means 4 bytes) since the task started. The smaller the returned - * number the closer the task has come to overflowing its stack. - * - * @param xTask Handle of the task associated with the stack to be checked. - * Set xTask to NULL to check the stack of the calling task. - * - * @return The smallest amount of free stack space there has been (in bytes) - * since the task referenced by xTask was created. - */ -unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask ) PRIVILEGED_FUNCTION; - -/* When using trace macros it is sometimes necessary to include tasks.h before -FreeRTOS.h. When this is done pdTASK_HOOK_CODE will not yet have been defined, -so the following two prototypes will cause a compilation error. This can be -fixed by simply guarding against the inclusion of these two prototypes unless -they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration -constant. */ -#ifdef configUSE_APPLICATION_TASK_TAG - #if configUSE_APPLICATION_TASK_TAG == 1 - /** - * task.h - *
void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction );
- * - * Sets pxHookFunction to be the task hook function used by the task xTask. - * Passing xTask as NULL has the effect of setting the calling tasks hook - * function. - */ - void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction ) PRIVILEGED_FUNCTION; - - /** - * task.h - *
void xTaskGetApplicationTaskTag( xTaskHandle xTask );
- * - * Returns the pxHookFunction value assigned to the task xTask. - */ - pdTASK_HOOK_CODE xTaskGetApplicationTaskTag( xTaskHandle xTask ) PRIVILEGED_FUNCTION; - #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ -#endif /* ifdef configUSE_APPLICATION_TASK_TAG */ - -/** - * task.h - *
portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction );
- * - * Calls the hook function associated with xTask. Passing xTask as NULL has - * the effect of calling the Running tasks (the calling task) hook function. - * - * pvParameter is passed to the hook function for the task to interpret as it - * wants. - */ -portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter ) PRIVILEGED_FUNCTION; - - -/*----------------------------------------------------------- - * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES - *----------------------------------------------------------*/ - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY - * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS - * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * Called from the real time kernel tick (either preemptive or cooperative), - * this increments the tick count and checks if any tasks that are blocked - * for a finite period required removing from a blocked list and placing on - * a ready list. - */ -void vTaskIncrementTick( void ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN - * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. - * - * Removes the calling task from the ready list and places it both - * on the list of tasks waiting for a particular event, and the - * list of delayed tasks. The task will be removed from both lists - * and replaced on the ready list should either the event occur (and - * there be no higher priority tasks waiting on the same event) or - * the delay period expires. - * - * @param pxEventList The list containing tasks that are blocked waiting - * for the event to occur. - * - * @param xTicksToWait The maximum amount of time that the task should wait - * for the event to occur. This is specified in kernel ticks,the constant - * portTICK_RATE_MS can be used to convert kernel ticks into a real time - * period. - */ -void vTaskPlaceOnEventList( const xList * const pxEventList, portTickType xTicksToWait ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN - * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. - * - * This function performs nearly the same function as vTaskPlaceOnEventList(). - * The difference being that this function does not permit tasks to block - * indefinitely, whereas vTaskPlaceOnEventList() does. - * - * @return pdTRUE if the task being removed has a higher priority than the task - * making the call, otherwise pdFALSE. - */ -void vTaskPlaceOnEventListRestricted( const xList * const pxEventList, portTickType xTicksToWait ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN - * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. - * - * Removes a task from both the specified event list and the list of blocked - * tasks, and places it on a ready queue. - * - * xTaskRemoveFromEventList () will be called if either an event occurs to - * unblock a task, or the block timeout period expires. - * - * @return pdTRUE if the task being removed has a higher priority than the task - * making the call, otherwise pdFALSE. - */ -signed portBASE_TYPE xTaskRemoveFromEventList( const xList * const pxEventList ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN - * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * INCLUDE_vTaskCleanUpResources and INCLUDE_vTaskSuspend must be defined as 1 - * for this function to be available. - * See the configuration section for more information. - * - * Empties the ready and delayed queues of task control blocks, freeing the - * memory allocated for the task control block and task stacks as it goes. - */ -void vTaskCleanUpResources( void ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY - * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS - * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * Sets the pointer to the current TCB to the TCB of the highest priority task - * that is ready to run. - */ -void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; - -/* - * Return the handle of the calling task. - */ -xTaskHandle xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION; - -/* - * Capture the current time status for future reference. - */ -void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut ) PRIVILEGED_FUNCTION; - -/* - * Compare the time status now with that previously captured to see if the - * timeout has expired. - */ -portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait ) PRIVILEGED_FUNCTION; - -/* - * Shortcut used by the queue implementation to prevent unnecessary call to - * taskYIELD(); - */ -void vTaskMissedYield( void ) PRIVILEGED_FUNCTION; - -/* - * Returns the scheduler state as taskSCHEDULER_RUNNING, - * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED. - */ -portBASE_TYPE xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION; - -/* - * Raises the priority of the mutex holder to that of the calling task should - * the mutex holder have a priority less than the calling task. - */ -void vTaskPriorityInherit( xTaskHandle * const pxMutexHolder ) PRIVILEGED_FUNCTION; - -/* - * Set the priority of a task back to its proper priority in the case that it - * inherited a higher priority while it was holding a semaphore. - */ -void vTaskPriorityDisinherit( xTaskHandle * const pxMutexHolder ) PRIVILEGED_FUNCTION; - -/* - * Generic version of the task creation function which is in turn called by the - * xTaskCreate() and xTaskCreateRestricted() macros. - */ -signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) PRIVILEGED_FUNCTION; - -#ifdef __cplusplus -} -#endif -#endif /* TASK_H */ - - - diff --git a/GD32F1/libraries/FreeRTOS/utility/tasks.c b/GD32F1/libraries/FreeRTOS/utility/tasks.c deleted file mode 100644 index d48dd4d..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/tasks.c +++ /dev/null @@ -1,2522 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - - -#include -#include -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "StackMacros.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* - * Macro to define the amount of stack available to the idle task. - */ -#define tskIDLE_STACK_SIZE configMINIMAL_STACK_SIZE - -/* - * Task control block. A task control block (TCB) is allocated to each task, - * and stores the context of the task. - */ -typedef struct tskTaskControlBlock -{ - volatile portSTACK_TYPE *pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE STRUCT. */ - - #if ( portUSING_MPU_WRAPPERS == 1 ) - xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE STRUCT. */ - #endif - - xListItem xGenericListItem; /*< List item used to place the TCB in ready and blocked queues. */ - xListItem xEventListItem; /*< List item used to place the TCB in event lists. */ - unsigned portBASE_TYPE uxPriority; /*< The priority of the task where 0 is the lowest priority. */ - portSTACK_TYPE *pxStack; /*< Points to the start of the stack. */ - signed char pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created. Facilitates debugging only. */ - - #if ( portSTACK_GROWTH > 0 ) - portSTACK_TYPE *pxEndOfStack; /*< Used for stack overflow checking on architectures where the stack grows up from low memory. */ - #endif - - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - unsigned portBASE_TYPE uxCriticalNesting; - #endif - - #if ( configUSE_TRACE_FACILITY == 1 ) - unsigned portBASE_TYPE uxTCBNumber; /*< This is used for tracing the scheduler and making debugging easier only. */ - #endif - - #if ( configUSE_MUTEXES == 1 ) - unsigned portBASE_TYPE uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */ - #endif - - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - pdTASK_HOOK_CODE pxTaskTag; - #endif - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - unsigned long ulRunTimeCounter; /*< Used for calculating how much CPU time each task is utilising. */ - #endif - -} tskTCB; - - -/* - * Some kernel aware debuggers require data to be viewed to be global, rather - * than file scope. - */ -#ifdef portREMOVE_STATIC_QUALIFIER - #define static -#endif - -/*lint -e956 */ -PRIVILEGED_DATA tskTCB * volatile pxCurrentTCB = NULL; - -/* Lists for ready and blocked tasks. --------------------*/ - -PRIVILEGED_DATA static xList pxReadyTasksLists[ configMAX_PRIORITIES ]; /*< Prioritised ready tasks. */ -PRIVILEGED_DATA static xList xDelayedTaskList1; /*< Delayed tasks. */ -PRIVILEGED_DATA static xList xDelayedTaskList2; /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */ -PRIVILEGED_DATA static xList * volatile pxDelayedTaskList ; /*< Points to the delayed task list currently being used. */ -PRIVILEGED_DATA static xList * volatile pxOverflowDelayedTaskList; /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */ -PRIVILEGED_DATA static xList xPendingReadyList; /*< Tasks that have been readied while the scheduler was suspended. They will be moved to the ready queue when the scheduler is resumed. */ - -#if ( INCLUDE_vTaskDelete == 1 ) - - PRIVILEGED_DATA static volatile xList xTasksWaitingTermination; /*< Tasks that have been deleted - but the their memory not yet freed. */ - PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxTasksDeleted = ( unsigned portBASE_TYPE ) 0; - -#endif - -#if ( INCLUDE_vTaskSuspend == 1 ) - - PRIVILEGED_DATA static xList xSuspendedTaskList; /*< Tasks that are currently suspended. */ - -#endif - -/* File private variables. --------------------------------*/ -PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks = ( unsigned portBASE_TYPE ) 0; -PRIVILEGED_DATA static volatile portTickType xTickCount = ( portTickType ) 0; -PRIVILEGED_DATA static unsigned portBASE_TYPE uxTopUsedPriority = tskIDLE_PRIORITY; -PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxTopReadyPriority = tskIDLE_PRIORITY; -PRIVILEGED_DATA static volatile signed portBASE_TYPE xSchedulerRunning = pdFALSE; -PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxSchedulerSuspended = ( unsigned portBASE_TYPE ) pdFALSE; -PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxMissedTicks = ( unsigned portBASE_TYPE ) 0; -PRIVILEGED_DATA static volatile portBASE_TYPE xMissedYield = ( portBASE_TYPE ) pdFALSE; -PRIVILEGED_DATA static volatile portBASE_TYPE xNumOfOverflows = ( portBASE_TYPE ) 0; -PRIVILEGED_DATA static unsigned portBASE_TYPE uxTaskNumber = ( unsigned portBASE_TYPE ) 0; -PRIVILEGED_DATA static portTickType xNextTaskUnblockTime = ( portTickType ) portMAX_DELAY; - -#if ( configGENERATE_RUN_TIME_STATS == 1 ) - - PRIVILEGED_DATA static char pcStatsString[ 50 ] ; - PRIVILEGED_DATA static unsigned long ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */ - static void prvGenerateRunTimeStatsForTasksInList( const signed char *pcWriteBuffer, xList *pxList, unsigned long ulTotalRunTime ) PRIVILEGED_FUNCTION; - -#endif - -/* Debugging and trace facilities private variables and macros. ------------*/ - -/* - * The value used to fill the stack of a task when the task is created. This - * is used purely for checking the high water mark for tasks. - */ -#define tskSTACK_FILL_BYTE ( 0xa5U ) - -/* - * Macros used by vListTask to indicate which state a task is in. - */ -#define tskBLOCKED_CHAR ( ( signed char ) 'B' ) -#define tskREADY_CHAR ( ( signed char ) 'R' ) -#define tskDELETED_CHAR ( ( signed char ) 'D' ) -#define tskSUSPENDED_CHAR ( ( signed char ) 'S' ) - -/* - * Macros and private variables used by the trace facility. - */ -#if ( configUSE_TRACE_FACILITY == 1 ) - - #define tskSIZE_OF_EACH_TRACE_LINE ( ( unsigned long ) ( sizeof( unsigned long ) + sizeof( unsigned long ) ) ) - PRIVILEGED_DATA static volatile signed char * volatile pcTraceBuffer; - PRIVILEGED_DATA static signed char *pcTraceBufferStart; - PRIVILEGED_DATA static signed char *pcTraceBufferEnd; - PRIVILEGED_DATA static signed portBASE_TYPE xTracing = pdFALSE; - static unsigned portBASE_TYPE uxPreviousTask = 255U; - PRIVILEGED_DATA static char pcStatusString[ 50 ]; - -#endif - -/*-----------------------------------------------------------*/ - -/* - * Macro that writes a trace of scheduler activity to a buffer. This trace - * shows which task is running when and is very useful as a debugging tool. - * As this macro is called each context switch it is a good idea to undefine - * it if not using the facility. - */ -#if ( configUSE_TRACE_FACILITY == 1 ) - - #define vWriteTraceToBuffer() \ - { \ - if( xTracing ) \ - { \ - if( uxPreviousTask != pxCurrentTCB->uxTCBNumber ) \ - { \ - if( ( pcTraceBuffer + tskSIZE_OF_EACH_TRACE_LINE ) < pcTraceBufferEnd ) \ - { \ - uxPreviousTask = pxCurrentTCB->uxTCBNumber; \ - *( unsigned long * ) pcTraceBuffer = ( unsigned long ) xTickCount; \ - pcTraceBuffer += sizeof( unsigned long ); \ - *( unsigned long * ) pcTraceBuffer = ( unsigned long ) uxPreviousTask; \ - pcTraceBuffer += sizeof( unsigned long ); \ - } \ - else \ - { \ - xTracing = pdFALSE; \ - } \ - } \ - } \ - } - -#else - - #define vWriteTraceToBuffer() - -#endif -/*-----------------------------------------------------------*/ - -/* - * Place the task represented by pxTCB into the appropriate ready queue for - * the task. It is inserted at the end of the list. One quirk of this is - * that if the task being inserted is at the same priority as the currently - * executing task, then it will only be rescheduled after the currently - * executing task has been rescheduled. - */ -#define prvAddTaskToReadyQueue( pxTCB ) \ - if( ( pxTCB )->uxPriority > uxTopReadyPriority ) \ - { \ - uxTopReadyPriority = ( pxTCB )->uxPriority; \ - } \ - vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) ) -/*-----------------------------------------------------------*/ - -/* - * Macro that looks at the list of tasks that are currently delayed to see if - * any require waking. - * - * Tasks are stored in the queue in the order of their wake time - meaning - * once one tasks has been found whose timer has not expired we need not look - * any further down the list. - */ -#define prvCheckDelayedTasks() \ -{ \ -portTickType xItemValue; \ - \ - /* Is the tick count greater than or equal to the wake time of the first \ - task referenced from the delayed tasks list? */ \ - if( xTickCount >= xNextTaskUnblockTime ) \ - { \ - for( ;; ) \ - { \ - if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) \ - { \ - /* The delayed list is empty. Set xNextTaskUnblockTime to the \ - maximum possible value so it is extremely unlikely that the \ - if( xTickCount >= xNextTaskUnblockTime ) test will pass next \ - time through. */ \ - xNextTaskUnblockTime = portMAX_DELAY; \ - break; \ - } \ - else \ - { \ - /* The delayed list is not empty, get the value of the item at \ - the head of the delayed list. This is the time at which the \ - task at the head of the delayed list should be removed from \ - the Blocked state. */ \ - pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); \ - xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) ); \ - \ - if( xTickCount < xItemValue ) \ - { \ - /* It is not time to unblock this item yet, but the item \ - value is the time at which the task at the head of the \ - blocked list should be removed from the Blocked state - \ - so record the item value in xNextTaskUnblockTime. */ \ - xNextTaskUnblockTime = xItemValue; \ - break; \ - } \ - \ - /* It is time to remove the item from the Blocked state. */ \ - vListRemove( &( pxTCB->xGenericListItem ) ); \ - \ - /* Is the task waiting on an event also? */ \ - if( pxTCB->xEventListItem.pvContainer ) \ - { \ - vListRemove( &( pxTCB->xEventListItem ) ); \ - } \ - prvAddTaskToReadyQueue( pxTCB ); \ - } \ - } \ - } \ -} -/*-----------------------------------------------------------*/ - -/* - * Several functions take an xTaskHandle parameter that can optionally be NULL, - * where NULL is used to indicate that the handle of the currently executing - * task should be used in place of the parameter. This macro simply checks to - * see if the parameter is NULL and returns a pointer to the appropriate TCB. - */ -#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) ( pxHandle ) ) - -/* Callback function prototypes. --------------------------*/ -extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); -extern void vApplicationTickHook( void ); - -/* File private functions. --------------------------------*/ - -/* - * Utility to ready a TCB for a given task. Mainly just copies the parameters - * into the TCB structure. - */ -static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion * const xRegions, unsigned short usStackDepth ) PRIVILEGED_FUNCTION; - -/* - * Utility to ready all the lists used by the scheduler. This is called - * automatically upon the creation of the first task. - */ -static void prvInitialiseTaskLists( void ) PRIVILEGED_FUNCTION; - -/* - * The idle task, which as all tasks is implemented as a never ending loop. - * The idle task is automatically created and added to the ready lists upon - * creation of the first user task. - * - * The portTASK_FUNCTION_PROTO() macro is used to allow port/compiler specific - * language extensions. The equivalent prototype for this function is: - * - * void prvIdleTask( void *pvParameters ); - * - */ -static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ); - -/* - * Utility to free all memory allocated by the scheduler to hold a TCB, - * including the stack pointed to by the TCB. - * - * This does not free memory allocated by the task itself (i.e. memory - * allocated by calls to pvPortMalloc from within the tasks application code). - */ -#if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) ) - - static void prvDeleteTCB( tskTCB *pxTCB ) PRIVILEGED_FUNCTION; - -#endif - -/* - * Used only by the idle task. This checks to see if anything has been placed - * in the list of tasks waiting to be deleted. If so the task is cleaned up - * and its TCB deleted. - */ -static void prvCheckTasksWaitingTermination( void ) PRIVILEGED_FUNCTION; - -/* - * The currently executing task is entering the Blocked state. Add the task to - * either the current or the overflow delayed task list. - */ -static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake ) PRIVILEGED_FUNCTION; - -/* - * Allocates memory from the heap for a TCB and associated stack. Checks the - * allocation was successful. - */ -static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TYPE *puxStackBuffer ) PRIVILEGED_FUNCTION; - -/* - * Called from vTaskList. vListTasks details all the tasks currently under - * control of the scheduler. The tasks may be in one of a number of lists. - * prvListTaskWithinSingleList accepts a list and details the tasks from - * within just that list. - * - * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM - * NORMAL APPLICATION CODE. - */ -#if ( configUSE_TRACE_FACILITY == 1 ) - - static void prvListTaskWithinSingleList( const signed char *pcWriteBuffer, xList *pxList, signed char cStatus ) PRIVILEGED_FUNCTION; - -#endif - -/* - * When a task is created, the stack of the task is filled with a known value. - * This function determines the 'high water mark' of the task stack by - * determining how much of the stack remains at the original preset value. - */ -#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) - - static unsigned short usTaskCheckFreeStackSpace( const unsigned char * pucStackByte ) PRIVILEGED_FUNCTION; - -#endif - - -/*lint +e956 */ - - - -/*----------------------------------------------------------- - * TASK CREATION API documented in task.h - *----------------------------------------------------------*/ - -signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) -{ -signed portBASE_TYPE xReturn; -tskTCB * pxNewTCB; - - configASSERT( pxTaskCode ); - configASSERT( ( uxPriority < configMAX_PRIORITIES ) ); - - /* Allocate the memory required by the TCB and stack for the new task, - checking that the allocation was successful. */ - pxNewTCB = prvAllocateTCBAndStack( usStackDepth, puxStackBuffer ); - - if( pxNewTCB != NULL ) - { - portSTACK_TYPE *pxTopOfStack; - - #if( portUSING_MPU_WRAPPERS == 1 ) - /* Should the task be created in privileged mode? */ - portBASE_TYPE xRunPrivileged; - if( ( uxPriority & portPRIVILEGE_BIT ) != 0x00 ) - { - xRunPrivileged = pdTRUE; - } - else - { - xRunPrivileged = pdFALSE; - } - uxPriority &= ~portPRIVILEGE_BIT; - #endif /* portUSING_MPU_WRAPPERS == 1 */ - - /* Calculate the top of stack address. This depends on whether the - stack grows from high memory to low (as per the 80x86) or visa versa. - portSTACK_GROWTH is used to make the result positive or negative as - required by the port. */ - #if( portSTACK_GROWTH < 0 ) - { - pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( unsigned short ) 1 ); - pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( unsigned long ) pxTopOfStack ) & ( ( unsigned long ) ~portBYTE_ALIGNMENT_MASK ) ); - - /* Check the alignment of the calculated top of stack is correct. */ - configASSERT( ( ( ( unsigned long ) pxTopOfStack & ( unsigned long ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); - } - #else - { - pxTopOfStack = pxNewTCB->pxStack; - - /* Check the alignment of the stack buffer is correct. */ - configASSERT( ( ( ( unsigned long ) pxNewTCB->pxStack & ( unsigned long ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); - - /* If we want to use stack checking on architectures that use - a positive stack growth direction then we also need to store the - other extreme of the stack space. */ - pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ); - } - #endif - - /* Setup the newly allocated TCB with the initial state of the task. */ - prvInitialiseTCBVariables( pxNewTCB, pcName, uxPriority, xRegions, usStackDepth ); - - /* Initialize the TCB stack to look as if the task was already running, - but had been interrupted by the scheduler. The return address is set - to the start of the task function. Once the stack has been initialised - the top of stack variable is updated. */ - #if( portUSING_MPU_WRAPPERS == 1 ) - { - pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged ); - } - #else - { - pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); - } - #endif - - /* Check the alignment of the initialised stack. */ - configASSERT( ( ( ( unsigned long ) pxNewTCB->pxTopOfStack & ( unsigned long ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); - - if( ( void * ) pxCreatedTask != NULL ) - { - /* Pass the TCB out - in an anonymous way. The calling function/ - task can use this as a handle to delete the task later if - required.*/ - *pxCreatedTask = ( xTaskHandle ) pxNewTCB; - } - - /* We are going to manipulate the task queues to add this task to a - ready list, so must make sure no interrupts occur. */ - taskENTER_CRITICAL(); - { - uxCurrentNumberOfTasks++; - if( pxCurrentTCB == NULL ) - { - /* There are no other tasks, or all the other tasks are in - the suspended state - make this the current task. */ - pxCurrentTCB = pxNewTCB; - - if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1 ) - { - /* This is the first task to be created so do the preliminary - initialisation required. We will not recover if this call - fails, but we will report the failure. */ - prvInitialiseTaskLists(); - } - } - else - { - /* If the scheduler is not already running, make this task the - current task if it is the highest priority task to be created - so far. */ - if( xSchedulerRunning == pdFALSE ) - { - if( pxCurrentTCB->uxPriority <= uxPriority ) - { - pxCurrentTCB = pxNewTCB; - } - } - } - - /* Remember the top priority to make context switching faster. Use - the priority in pxNewTCB as this has been capped to a valid value. */ - if( pxNewTCB->uxPriority > uxTopUsedPriority ) - { - uxTopUsedPriority = pxNewTCB->uxPriority; - } - - #if ( configUSE_TRACE_FACILITY == 1 ) - { - /* Add a counter into the TCB for tracing only. */ - pxNewTCB->uxTCBNumber = uxTaskNumber; - } - #endif - uxTaskNumber++; - - prvAddTaskToReadyQueue( pxNewTCB ); - - xReturn = pdPASS; - traceTASK_CREATE( pxNewTCB ); - } - taskEXIT_CRITICAL(); - } - else - { - xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; - traceTASK_CREATE_FAILED(); - } - - if( xReturn == pdPASS ) - { - if( xSchedulerRunning != pdFALSE ) - { - /* If the created task is of a higher priority than the current task - then it should run now. */ - if( pxCurrentTCB->uxPriority < uxPriority ) - { - portYIELD_WITHIN_API(); - } - } - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskDelete == 1 ) - - void vTaskDelete( xTaskHandle pxTaskToDelete ) - { - tskTCB *pxTCB; - - taskENTER_CRITICAL(); - { - /* Ensure a yield is performed if the current task is being - deleted. */ - if( pxTaskToDelete == pxCurrentTCB ) - { - pxTaskToDelete = NULL; - } - - /* If null is passed in here then we are deleting ourselves. */ - pxTCB = prvGetTCBFromHandle( pxTaskToDelete ); - - /* Remove task from the ready list and place in the termination list. - This will stop the task from be scheduled. The idle task will check - the termination list and free up any memory allocated by the - scheduler for the TCB and stack. */ - vListRemove( &( pxTCB->xGenericListItem ) ); - - /* Is the task waiting on an event also? */ - if( pxTCB->xEventListItem.pvContainer ) - { - vListRemove( &( pxTCB->xEventListItem ) ); - } - - vListInsertEnd( ( xList * ) &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) ); - - /* Increment the ucTasksDeleted variable so the idle task knows - there is a task that has been deleted and that it should therefore - check the xTasksWaitingTermination list. */ - ++uxTasksDeleted; - - /* Increment the uxTaskNumberVariable also so kernel aware debuggers - can detect that the task lists need re-generating. */ - uxTaskNumber++; - - traceTASK_DELETE( pxTCB ); - } - taskEXIT_CRITICAL(); - - /* Force a reschedule if we have just deleted the current task. */ - if( xSchedulerRunning != pdFALSE ) - { - if( ( void * ) pxTaskToDelete == NULL ) - { - portYIELD_WITHIN_API(); - } - } - } - -#endif - - - - - - -/*----------------------------------------------------------- - * TASK CONTROL API documented in task.h - *----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskDelayUntil == 1 ) - - void vTaskDelayUntil( portTickType * const pxPreviousWakeTime, portTickType xTimeIncrement ) - { - portTickType xTimeToWake; - portBASE_TYPE xAlreadyYielded, xShouldDelay = pdFALSE; - - configASSERT( pxPreviousWakeTime ); - configASSERT( ( xTimeIncrement > 0 ) ); - - vTaskSuspendAll(); - { - /* Generate the tick time at which the task wants to wake. */ - xTimeToWake = *pxPreviousWakeTime + xTimeIncrement; - - if( xTickCount < *pxPreviousWakeTime ) - { - /* The tick count has overflowed since this function was - lasted called. In this case the only time we should ever - actually delay is if the wake time has also overflowed, - and the wake time is greater than the tick time. When this - is the case it is as if neither time had overflowed. */ - if( ( xTimeToWake < *pxPreviousWakeTime ) && ( xTimeToWake > xTickCount ) ) - { - xShouldDelay = pdTRUE; - } - } - else - { - /* The tick time has not overflowed. In this case we will - delay if either the wake time has overflowed, and/or the - tick time is less than the wake time. */ - if( ( xTimeToWake < *pxPreviousWakeTime ) || ( xTimeToWake > xTickCount ) ) - { - xShouldDelay = pdTRUE; - } - } - - /* Update the wake time ready for the next call. */ - *pxPreviousWakeTime = xTimeToWake; - - if( xShouldDelay != pdFALSE ) - { - traceTASK_DELAY_UNTIL(); - - /* We must remove ourselves from the ready list before adding - ourselves to the blocked list as the same list item is used for - both lists. */ - vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - xAlreadyYielded = xTaskResumeAll(); - - /* Force a reschedule if xTaskResumeAll has not already done so, we may - have put ourselves to sleep. */ - if( !xAlreadyYielded ) - { - portYIELD_WITHIN_API(); - } - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskDelay == 1 ) - - void vTaskDelay( portTickType xTicksToDelay ) - { - portTickType xTimeToWake; - signed portBASE_TYPE xAlreadyYielded = pdFALSE; - - /* A delay time of zero just forces a reschedule. */ - if( xTicksToDelay > ( portTickType ) 0 ) - { - vTaskSuspendAll(); - { - traceTASK_DELAY(); - - /* A task that is removed from the event list while the - scheduler is suspended will not get placed in the ready - list or removed from the blocked list until the scheduler - is resumed. - - This task cannot be in an event list as it is the currently - executing task. */ - - /* Calculate the time to wake - this may overflow but this is - not a problem. */ - xTimeToWake = xTickCount + xTicksToDelay; - - /* We must remove ourselves from the ready list before adding - ourselves to the blocked list as the same list item is used for - both lists. */ - vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - xAlreadyYielded = xTaskResumeAll(); - } - - /* Force a reschedule if xTaskResumeAll has not already done so, we may - have put ourselves to sleep. */ - if( !xAlreadyYielded ) - { - portYIELD_WITHIN_API(); - } - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_uxTaskPriorityGet == 1 ) - - unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask ) - { - tskTCB *pxTCB; - unsigned portBASE_TYPE uxReturn; - - taskENTER_CRITICAL(); - { - /* If null is passed in here then we are changing the - priority of the calling function. */ - pxTCB = prvGetTCBFromHandle( pxTask ); - uxReturn = pxTCB->uxPriority; - } - taskEXIT_CRITICAL(); - - return uxReturn; - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskPrioritySet == 1 ) - - void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority ) - { - tskTCB *pxTCB; - unsigned portBASE_TYPE uxCurrentPriority; - portBASE_TYPE xYieldRequired = pdFALSE; - - configASSERT( ( uxNewPriority < configMAX_PRIORITIES ) ); - - /* Ensure the new priority is valid. */ - if( uxNewPriority >= configMAX_PRIORITIES ) - { - uxNewPriority = configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U; - } - - taskENTER_CRITICAL(); - { - if( pxTask == pxCurrentTCB ) - { - pxTask = NULL; - } - - /* If null is passed in here then we are changing the - priority of the calling function. */ - pxTCB = prvGetTCBFromHandle( pxTask ); - - traceTASK_PRIORITY_SET( pxTask, uxNewPriority ); - - #if ( configUSE_MUTEXES == 1 ) - { - uxCurrentPriority = pxTCB->uxBasePriority; - } - #else - { - uxCurrentPriority = pxTCB->uxPriority; - } - #endif - - if( uxCurrentPriority != uxNewPriority ) - { - /* The priority change may have readied a task of higher - priority than the calling task. */ - if( uxNewPriority > uxCurrentPriority ) - { - if( pxTask != NULL ) - { - /* The priority of another task is being raised. If we - were raising the priority of the currently running task - there would be no need to switch as it must have already - been the highest priority task. */ - xYieldRequired = pdTRUE; - } - } - else if( pxTask == NULL ) - { - /* Setting our own priority down means there may now be another - task of higher priority that is ready to execute. */ - xYieldRequired = pdTRUE; - } - - - - #if ( configUSE_MUTEXES == 1 ) - { - /* Only change the priority being used if the task is not - currently using an inherited priority. */ - if( pxTCB->uxBasePriority == pxTCB->uxPriority ) - { - pxTCB->uxPriority = uxNewPriority; - } - - /* The base priority gets set whatever. */ - pxTCB->uxBasePriority = uxNewPriority; - } - #else - { - pxTCB->uxPriority = uxNewPriority; - } - #endif - - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( configMAX_PRIORITIES - ( portTickType ) uxNewPriority ) ); - - /* If the task is in the blocked or suspended list we need do - nothing more than change it's priority variable. However, if - the task is in a ready list it needs to be removed and placed - in the queue appropriate to its new priority. */ - if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxCurrentPriority ] ), &( pxTCB->xGenericListItem ) ) ) - { - /* The task is currently in its ready list - remove before adding - it to it's new ready list. As we are in a critical section we - can do this even if the scheduler is suspended. */ - vListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyQueue( pxTCB ); - } - - if( xYieldRequired == pdTRUE ) - { - portYIELD_WITHIN_API(); - } - } - } - taskEXIT_CRITICAL(); - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskSuspend == 1 ) - - void vTaskSuspend( xTaskHandle pxTaskToSuspend ) - { - tskTCB *pxTCB; - - taskENTER_CRITICAL(); - { - /* Ensure a yield is performed if the current task is being - suspended. */ - if( pxTaskToSuspend == pxCurrentTCB ) - { - pxTaskToSuspend = NULL; - } - - /* If null is passed in here then we are suspending ourselves. */ - pxTCB = prvGetTCBFromHandle( pxTaskToSuspend ); - - traceTASK_SUSPEND( pxTCB ); - - /* Remove task from the ready/delayed list and place in the suspended list. */ - vListRemove( &( pxTCB->xGenericListItem ) ); - - /* Is the task waiting on an event also? */ - if( pxTCB->xEventListItem.pvContainer ) - { - vListRemove( &( pxTCB->xEventListItem ) ); - } - - vListInsertEnd( ( xList * ) &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ); - } - taskEXIT_CRITICAL(); - - if( ( void * ) pxTaskToSuspend == NULL ) - { - if( xSchedulerRunning != pdFALSE ) - { - /* We have just suspended the current task. */ - portYIELD_WITHIN_API(); - } - else - { - /* The scheduler is not running, but the task that was pointed - to by pxCurrentTCB has just been suspended and pxCurrentTCB - must be adjusted to point to a different task. */ - if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks ) - { - /* No other tasks are ready, so set pxCurrentTCB back to - NULL so when the next task is created pxCurrentTCB will - be set to point to it no matter what its relative priority - is. */ - pxCurrentTCB = NULL; - } - else - { - vTaskSwitchContext(); - } - } - } - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskSuspend == 1 ) - - signed portBASE_TYPE xTaskIsTaskSuspended( xTaskHandle xTask ) - { - portBASE_TYPE xReturn = pdFALSE; - const tskTCB * const pxTCB = ( tskTCB * ) xTask; - - /* It does not make sense to check if the calling task is suspended. */ - configASSERT( xTask ); - - /* Is the task we are attempting to resume actually in the - suspended list? */ - if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE ) - { - /* Has the task already been resumed from within an ISR? */ - if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) != pdTRUE ) - { - /* Is it in the suspended list because it is in the - Suspended state? It is possible to be in the suspended - list because it is blocked on a task with no timeout - specified. */ - if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) == pdTRUE ) - { - xReturn = pdTRUE; - } - } - } - - return xReturn; - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskSuspend == 1 ) - - void vTaskResume( xTaskHandle pxTaskToResume ) - { - tskTCB *pxTCB; - - /* It does not make sense to resume the calling task. */ - configASSERT( pxTaskToResume ); - - /* Remove the task from whichever list it is currently in, and place - it in the ready list. */ - pxTCB = ( tskTCB * ) pxTaskToResume; - - /* The parameter cannot be NULL as it is impossible to resume the - currently executing task. */ - if( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) ) - { - taskENTER_CRITICAL(); - { - if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE ) - { - traceTASK_RESUME( pxTCB ); - - /* As we are in a critical section we can access the ready - lists even if the scheduler is suspended. */ - vListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyQueue( pxTCB ); - - /* We may have just resumed a higher priority task. */ - if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) - { - /* This yield may not cause the task just resumed to run, but - will leave the lists in the correct state for the next yield. */ - portYIELD_WITHIN_API(); - } - } - } - taskEXIT_CRITICAL(); - } - } - -#endif - -/*-----------------------------------------------------------*/ - -#if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) - - portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume ) - { - portBASE_TYPE xYieldRequired = pdFALSE; - tskTCB *pxTCB; - - configASSERT( pxTaskToResume ); - - pxTCB = ( tskTCB * ) pxTaskToResume; - - if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE ) - { - traceTASK_RESUME_FROM_ISR( pxTCB ); - - if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) - { - xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ); - vListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyQueue( pxTCB ); - } - else - { - /* We cannot access the delayed or ready lists, so will hold this - task pending until the scheduler is resumed, at which point a - yield will be performed if necessary. */ - vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); - } - } - - return xYieldRequired; - } - -#endif - - - - -/*----------------------------------------------------------- - * PUBLIC SCHEDULER CONTROL documented in task.h - *----------------------------------------------------------*/ - - -void vTaskStartScheduler( void ) -{ -portBASE_TYPE xReturn; - - /* Add the idle task at the lowest priority. */ - xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), ( xTaskHandle * ) NULL ); - - #if ( configUSE_TIMERS == 1 ) - { - if( xReturn == pdPASS ) - { - xReturn = xTimerCreateTimerTask(); - } - } - #endif - - if( xReturn == pdPASS ) - { - /* Interrupts are turned off here, to ensure a tick does not occur - before or during the call to xPortStartScheduler(). The stacks of - the created tasks contain a status word with interrupts switched on - so interrupts will automatically get re-enabled when the first task - starts to run. - - STEPPING THROUGH HERE USING A DEBUGGER CAN CAUSE BIG PROBLEMS IF THE - DEBUGGER ALLOWS INTERRUPTS TO BE PROCESSED. */ - portDISABLE_INTERRUPTS(); - - xSchedulerRunning = pdTRUE; - xTickCount = ( portTickType ) 0; - - /* If configGENERATE_RUN_TIME_STATS is defined then the following - macro must be defined to configure the timer/counter used to generate - the run time counter time base. */ - portCONFIGURE_TIMER_FOR_RUN_TIME_STATS(); - - /* Setting up the timer tick is hardware specific and thus in the - portable interface. */ - if( xPortStartScheduler() ) - { - /* Should not reach here as if the scheduler is running the - function will not return. */ - } - else - { - /* Should only reach here if a task calls xTaskEndScheduler(). */ - } - } - - /* This line will only be reached if the kernel could not be started. */ - configASSERT( xReturn ); -} -/*-----------------------------------------------------------*/ - -void vTaskEndScheduler( void ) -{ - /* Stop the scheduler interrupts and call the portable scheduler end - routine so the original ISRs can be restored if necessary. The port - layer must ensure interrupts enable bit is left in the correct state. */ - portDISABLE_INTERRUPTS(); - xSchedulerRunning = pdFALSE; - vPortEndScheduler(); -} -/*----------------------------------------------------------*/ - -void vTaskSuspendAll( void ) -{ - /* A critical section is not required as the variable is of type - portBASE_TYPE. */ - ++uxSchedulerSuspended; -} -/*----------------------------------------------------------*/ - -signed portBASE_TYPE xTaskResumeAll( void ) -{ -register tskTCB *pxTCB; -signed portBASE_TYPE xAlreadyYielded = pdFALSE; - - /* If uxSchedulerSuspended is zero then this function does not match a - previous call to vTaskSuspendAll(). */ - configASSERT( uxSchedulerSuspended ); - - /* It is possible that an ISR caused a task to be removed from an event - list while the scheduler was suspended. If this was the case then the - removed task will have been added to the xPendingReadyList. Once the - scheduler has been resumed it is safe to move all the pending ready - tasks from this list into their appropriate ready list. */ - taskENTER_CRITICAL(); - { - --uxSchedulerSuspended; - - if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) - { - if( uxCurrentNumberOfTasks > ( unsigned portBASE_TYPE ) 0 ) - { - portBASE_TYPE xYieldRequired = pdFALSE; - - /* Move any readied tasks from the pending list into the - appropriate ready list. */ - while( listLIST_IS_EMPTY( ( xList * ) &xPendingReadyList ) == pdFALSE ) - { - pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xPendingReadyList ) ); - vListRemove( &( pxTCB->xEventListItem ) ); - vListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyQueue( pxTCB ); - - /* If we have moved a task that has a priority higher than - the current task then we should yield. */ - if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) - { - xYieldRequired = pdTRUE; - } - } - - /* If any ticks occurred while the scheduler was suspended then - they should be processed now. This ensures the tick count does not - slip, and that any delayed tasks are resumed at the correct time. */ - if( uxMissedTicks > ( unsigned portBASE_TYPE ) 0 ) - { - while( uxMissedTicks > ( unsigned portBASE_TYPE ) 0 ) - { - vTaskIncrementTick(); - --uxMissedTicks; - } - - /* As we have processed some ticks it is appropriate to yield - to ensure the highest priority task that is ready to run is - the task actually running. */ - #if configUSE_PREEMPTION == 1 - { - xYieldRequired = pdTRUE; - } - #endif - } - - if( ( xYieldRequired == pdTRUE ) || ( xMissedYield == pdTRUE ) ) - { - xAlreadyYielded = pdTRUE; - xMissedYield = pdFALSE; - portYIELD_WITHIN_API(); - } - } - } - } - taskEXIT_CRITICAL(); - - return xAlreadyYielded; -} - - - - - - -/*----------------------------------------------------------- - * PUBLIC TASK UTILITIES documented in task.h - *----------------------------------------------------------*/ - - - -portTickType xTaskGetTickCount( void ) -{ -portTickType xTicks; - - /* Critical section required if running on a 16 bit processor. */ - taskENTER_CRITICAL(); - { - xTicks = xTickCount; - } - taskEXIT_CRITICAL(); - - return xTicks; -} -/*-----------------------------------------------------------*/ - -portTickType xTaskGetTickCountFromISR( void ) -{ -portTickType xReturn; -unsigned portBASE_TYPE uxSavedInterruptStatus; - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - xReturn = xTickCount; - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) -{ - /* A critical section is not required because the variables are of type - portBASE_TYPE. */ - return uxCurrentNumberOfTasks; -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - void vTaskList( signed char *pcWriteBuffer ) - { - unsigned portBASE_TYPE uxQueue; - - /* This is a VERY costly function that should be used for debug only. - It leaves interrupts disabled for a LONG time. */ - - vTaskSuspendAll(); - { - /* Run through all the lists that could potentially contain a TCB and - report the task name, state and stack high water mark. */ - - *pcWriteBuffer = ( signed char ) 0x00; - strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" ); - - uxQueue = uxTopUsedPriority + ( unsigned portBASE_TYPE ) 1U; - - do - { - uxQueue--; - - if( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) == pdFALSE ) - { - prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &( pxReadyTasksLists[ uxQueue ] ), tskREADY_CHAR ); - } - }while( uxQueue > ( unsigned short ) tskIDLE_PRIORITY ); - - if( listLIST_IS_EMPTY( pxDelayedTaskList ) == pdFALSE ) - { - prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) pxDelayedTaskList, tskBLOCKED_CHAR ); - } - - if( listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) == pdFALSE ) - { - prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) pxOverflowDelayedTaskList, tskBLOCKED_CHAR ); - } - - #if( INCLUDE_vTaskDelete == 1 ) - { - if( listLIST_IS_EMPTY( &xTasksWaitingTermination ) == pdFALSE ) - { - prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &xTasksWaitingTermination, tskDELETED_CHAR ); - } - } - #endif - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) - { - prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &xSuspendedTaskList, tskSUSPENDED_CHAR ); - } - } - #endif - } - xTaskResumeAll(); - } - -#endif -/*----------------------------------------------------------*/ - -#if ( configGENERATE_RUN_TIME_STATS == 1 ) - - void vTaskGetRunTimeStats( signed char *pcWriteBuffer ) - { - unsigned portBASE_TYPE uxQueue; - unsigned long ulTotalRunTime; - - /* This is a VERY costly function that should be used for debug only. - It leaves interrupts disabled for a LONG time. */ - - vTaskSuspendAll(); - { - #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE - portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime ); - #else - ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); - #endif - - /* Divide ulTotalRunTime by 100 to make the percentage caluclations - simpler in the prvGenerateRunTimeStatsForTasksInList() function. */ - ulTotalRunTime /= 100UL; - - /* Run through all the lists that could potentially contain a TCB, - generating a table of run timer percentages in the provided - buffer. */ - - *pcWriteBuffer = ( signed char ) 0x00; - strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" ); - - uxQueue = uxTopUsedPriority + ( unsigned portBASE_TYPE ) 1U; - - do - { - uxQueue--; - - if( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) == pdFALSE ) - { - prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &( pxReadyTasksLists[ uxQueue ] ), ulTotalRunTime ); - } - }while( uxQueue > ( unsigned short ) tskIDLE_PRIORITY ); - - if( listLIST_IS_EMPTY( pxDelayedTaskList ) == pdFALSE ) - { - prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) pxDelayedTaskList, ulTotalRunTime ); - } - - if( listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) == pdFALSE ) - { - prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) pxOverflowDelayedTaskList, ulTotalRunTime ); - } - - #if ( INCLUDE_vTaskDelete == 1 ) - { - if( listLIST_IS_EMPTY( &xTasksWaitingTermination ) == pdFALSE ) - { - prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &xTasksWaitingTermination, ulTotalRunTime ); - } - } - #endif - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) - { - prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &xSuspendedTaskList, ulTotalRunTime ); - } - } - #endif - } - xTaskResumeAll(); - } - -#endif -/*----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - void vTaskStartTrace( signed char * pcBuffer, unsigned long ulBufferSize ) - { - configASSERT( pcBuffer ); - configASSERT( ulBufferSize ); - - taskENTER_CRITICAL(); - { - pcTraceBuffer = ( signed char * )pcBuffer; - pcTraceBufferStart = pcBuffer; - pcTraceBufferEnd = pcBuffer + ( ulBufferSize - tskSIZE_OF_EACH_TRACE_LINE ); - xTracing = pdTRUE; - } - taskEXIT_CRITICAL(); - } - -#endif -/*----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - unsigned long ulTaskEndTrace( void ) - { - unsigned long ulBufferLength; - - taskENTER_CRITICAL(); - xTracing = pdFALSE; - taskEXIT_CRITICAL(); - - ulBufferLength = ( unsigned long ) ( pcTraceBuffer - pcTraceBufferStart ); - - return ulBufferLength; - } - -#endif - - - -/*----------------------------------------------------------- - * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES - * documented in task.h - *----------------------------------------------------------*/ - - -void vTaskIncrementTick( void ) -{ -tskTCB * pxTCB; - - /* Called by the portable layer each time a tick interrupt occurs. - Increments the tick then checks to see if the new tick value will cause any - tasks to be unblocked. */ - if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) - { - ++xTickCount; - if( xTickCount == ( portTickType ) 0 ) - { - xList *pxTemp; - - /* Tick count has overflowed so we need to swap the delay lists. - If there are any items in pxDelayedTaskList here then there is - an error! */ - configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) ); - - pxTemp = pxDelayedTaskList; - pxDelayedTaskList = pxOverflowDelayedTaskList; - pxOverflowDelayedTaskList = pxTemp; - xNumOfOverflows++; - - if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) - { - /* The new current delayed list is empty. Set - xNextTaskUnblockTime to the maximum possible value so it is - extremely unlikely that the - if( xTickCount >= xNextTaskUnblockTime ) test will pass until - there is an item in the delayed list. */ - xNextTaskUnblockTime = portMAX_DELAY; - } - else - { - /* The new current delayed list is not empty, get the value of - the item at the head of the delayed list. This is the time at - which the task at the head of the delayed list should be removed - from the Blocked state. */ - pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); - xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) ); - } - } - - /* See if this tick has made a timeout expire. */ - prvCheckDelayedTasks(); - } - else - { - ++uxMissedTicks; - - /* The tick hook gets called at regular intervals, even if the - scheduler is locked. */ - #if ( configUSE_TICK_HOOK == 1 ) - { - vApplicationTickHook(); - } - #endif - } - - #if ( configUSE_TICK_HOOK == 1 ) - { - /* Guard against the tick hook being called when the missed tick - count is being unwound (when the scheduler is being unlocked. */ - if( uxMissedTicks == ( unsigned portBASE_TYPE ) 0U ) - { - vApplicationTickHook(); - } - } - #endif - - traceTASK_INCREMENT_TICK( xTickCount ); -} -/*-----------------------------------------------------------*/ - -#if ( ( INCLUDE_vTaskCleanUpResources == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) - - void vTaskCleanUpResources( void ) - { - unsigned short usQueue; - volatile tskTCB *pxTCB; - - usQueue = ( unsigned short ) uxTopUsedPriority + ( unsigned short ) 1; - - /* Remove any TCB's from the ready queues. */ - do - { - usQueue--; - - while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ usQueue ] ) ) == pdFALSE ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &( pxReadyTasksLists[ usQueue ] ) ); - vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); - - prvDeleteTCB( ( tskTCB * ) pxTCB ); - } - }while( usQueue > ( unsigned short ) tskIDLE_PRIORITY ); - - /* Remove any TCB's from the delayed queue. */ - while( listLIST_IS_EMPTY( &xDelayedTaskList1 ) == pdFALSE ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xDelayedTaskList1 ); - vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); - - prvDeleteTCB( ( tskTCB * ) pxTCB ); - } - - /* Remove any TCB's from the overflow delayed queue. */ - while( listLIST_IS_EMPTY( &xDelayedTaskList2 ) == pdFALSE ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xDelayedTaskList2 ); - vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); - - prvDeleteTCB( ( tskTCB * ) pxTCB ); - } - - while( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xSuspendedTaskList ); - vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); - - prvDeleteTCB( ( tskTCB * ) pxTCB ); - } - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( configUSE_APPLICATION_TASK_TAG == 1 ) - - void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction ) - { - tskTCB *xTCB; - - /* If xTask is NULL then we are setting our own task hook. */ - if( xTask == NULL ) - { - xTCB = ( tskTCB * ) pxCurrentTCB; - } - else - { - xTCB = ( tskTCB * ) xTask; - } - - /* Save the hook function in the TCB. A critical section is required as - the value can be accessed from an interrupt. */ - taskENTER_CRITICAL(); - xTCB->pxTaskTag = pxHookFunction; - taskEXIT_CRITICAL(); - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( configUSE_APPLICATION_TASK_TAG == 1 ) - - pdTASK_HOOK_CODE xTaskGetApplicationTaskTag( xTaskHandle xTask ) - { - tskTCB *xTCB; - pdTASK_HOOK_CODE xReturn; - - /* If xTask is NULL then we are setting our own task hook. */ - if( xTask == NULL ) - { - xTCB = ( tskTCB * ) pxCurrentTCB; - } - else - { - xTCB = ( tskTCB * ) xTask; - } - - /* Save the hook function in the TCB. A critical section is required as - the value can be accessed from an interrupt. */ - taskENTER_CRITICAL(); - xReturn = xTCB->pxTaskTag; - taskEXIT_CRITICAL(); - - return xReturn; - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( configUSE_APPLICATION_TASK_TAG == 1 ) - - portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter ) - { - tskTCB *xTCB; - portBASE_TYPE xReturn; - - /* If xTask is NULL then we are calling our own task hook. */ - if( xTask == NULL ) - { - xTCB = ( tskTCB * ) pxCurrentTCB; - } - else - { - xTCB = ( tskTCB * ) xTask; - } - - if( xTCB->pxTaskTag != NULL ) - { - xReturn = xTCB->pxTaskTag( pvParameter ); - } - else - { - xReturn = pdFAIL; - } - - return xReturn; - } - -#endif -/*-----------------------------------------------------------*/ - -void vTaskSwitchContext( void ) -{ - if( uxSchedulerSuspended != ( unsigned portBASE_TYPE ) pdFALSE ) - { - /* The scheduler is currently suspended - do not allow a context - switch. */ - xMissedYield = pdTRUE; - } - else - { - traceTASK_SWITCHED_OUT(); - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - { - unsigned long ulTempCounter; - - #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE - portALT_GET_RUN_TIME_COUNTER_VALUE( ulTempCounter ); - #else - ulTempCounter = portGET_RUN_TIME_COUNTER_VALUE(); - #endif - - /* Add the amount of time the task has been running to the accumulated - time so far. The time the task started running was stored in - ulTaskSwitchedInTime. Note that there is no overflow protection here - so count values are only valid until the timer overflows. Generally - this will be about 1 hour assuming a 1uS timer increment. */ - pxCurrentTCB->ulRunTimeCounter += ( ulTempCounter - ulTaskSwitchedInTime ); - ulTaskSwitchedInTime = ulTempCounter; - } - #endif - - taskFIRST_CHECK_FOR_STACK_OVERFLOW(); - taskSECOND_CHECK_FOR_STACK_OVERFLOW(); - - /* Find the highest priority queue that contains ready tasks. */ - while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) ) - { - configASSERT( uxTopReadyPriority ); - --uxTopReadyPriority; - } - - /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the - same priority get an equal share of the processor time. */ - listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) ); - - traceTASK_SWITCHED_IN(); - vWriteTraceToBuffer(); - } -} -/*-----------------------------------------------------------*/ - -void vTaskPlaceOnEventList( const xList * const pxEventList, portTickType xTicksToWait ) -{ -portTickType xTimeToWake; - - configASSERT( pxEventList ); - - /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE - SCHEDULER SUSPENDED. */ - - /* Place the event list item of the TCB in the appropriate event list. - This is placed in the list in priority order so the highest priority task - is the first to be woken by the event. */ - vListInsert( ( xList * ) pxEventList, ( xListItem * ) &( pxCurrentTCB->xEventListItem ) ); - - /* We must remove ourselves from the ready list before adding ourselves - to the blocked list as the same list item is used for both lists. We have - exclusive access to the ready lists as the scheduler is locked. */ - vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); - - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if( xTicksToWait == portMAX_DELAY ) - { - /* Add ourselves to the suspended task list instead of a delayed task - list to ensure we are not woken by a timing event. We will block - indefinitely. */ - vListInsertEnd( ( xList * ) &xSuspendedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else - { - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif -} -/*-----------------------------------------------------------*/ - -#if configUSE_TIMERS == 1 - - void vTaskPlaceOnEventListRestricted( const xList * const pxEventList, portTickType xTicksToWait ) - { - portTickType xTimeToWake; - - configASSERT( pxEventList ); - - /* This function should not be called by application code hence the - 'Restricted' in its name. It is not part of the public API. It is - designed for use by kernel code, and has special calling requirements - - it should be called from a critical section. */ - - - /* Place the event list item of the TCB in the appropriate event list. - In this case it is assume that this is the only task that is going to - be waiting on this event list, so the faster vListInsertEnd() function - can be used in place of vListInsert. */ - vListInsertEnd( ( xList * ) pxEventList, ( xListItem * ) &( pxCurrentTCB->xEventListItem ) ); - - /* We must remove this task from the ready list before adding it to the - blocked list as the same list item is used for both lists. This - function is called form a critical section. */ - vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); - - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - -#endif /* configUSE_TIMERS */ -/*-----------------------------------------------------------*/ - -signed portBASE_TYPE xTaskRemoveFromEventList( const xList * const pxEventList ) -{ -tskTCB *pxUnblockedTCB; -portBASE_TYPE xReturn; - - /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE - SCHEDULER SUSPENDED. It can also be called from within an ISR. */ - - /* The event list is sorted in priority order, so we can remove the - first in the list, remove the TCB from the delayed list, and add - it to the ready list. - - If an event is for a queue that is locked then this function will never - get called - the lock count on the queue will get modified instead. This - means we can always expect exclusive access to the event list here. - - This function assumes that a check has already been made to ensure that - pxEventList is not empty. */ - pxUnblockedTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); - configASSERT( pxUnblockedTCB ); - vListRemove( &( pxUnblockedTCB->xEventListItem ) ); - - if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) - { - vListRemove( &( pxUnblockedTCB->xGenericListItem ) ); - prvAddTaskToReadyQueue( pxUnblockedTCB ); - } - else - { - /* We cannot access the delayed or ready lists, so will hold this - task pending until the scheduler is resumed. */ - vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) ); - } - - if( pxUnblockedTCB->uxPriority >= pxCurrentTCB->uxPriority ) - { - /* Return true if the task removed from the event list has - a higher priority than the calling task. This allows - the calling task to know if it should force a context - switch now. */ - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut ) -{ - configASSERT( pxTimeOut ); - pxTimeOut->xOverflowCount = xNumOfOverflows; - pxTimeOut->xTimeOnEntering = xTickCount; -} -/*-----------------------------------------------------------*/ - -portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait ) -{ -portBASE_TYPE xReturn; - - configASSERT( pxTimeOut ); - configASSERT( pxTicksToWait ); - - taskENTER_CRITICAL(); - { - #if ( INCLUDE_vTaskSuspend == 1 ) - /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is - the maximum block time then the task should block indefinitely, and - therefore never time out. */ - if( *pxTicksToWait == portMAX_DELAY ) - { - xReturn = pdFALSE; - } - else /* We are not blocking indefinitely, perform the checks below. */ - #endif - - if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( ( portTickType ) xTickCount >= ( portTickType ) pxTimeOut->xTimeOnEntering ) ) - { - /* The tick count is greater than the time at which vTaskSetTimeout() - was called, but has also overflowed since vTaskSetTimeOut() was called. - It must have wrapped all the way around and gone past us again. This - passed since vTaskSetTimeout() was called. */ - xReturn = pdTRUE; - } - else if( ( ( portTickType ) ( ( portTickType ) xTickCount - ( portTickType ) pxTimeOut->xTimeOnEntering ) ) < ( portTickType ) *pxTicksToWait ) - { - /* Not a genuine timeout. Adjust parameters for time remaining. */ - *pxTicksToWait -= ( ( portTickType ) xTickCount - ( portTickType ) pxTimeOut->xTimeOnEntering ); - vTaskSetTimeOutState( pxTimeOut ); - xReturn = pdFALSE; - } - else - { - xReturn = pdTRUE; - } - } - taskEXIT_CRITICAL(); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vTaskMissedYield( void ) -{ - xMissedYield = pdTRUE; -} - -/* - * ----------------------------------------------------------- - * The Idle task. - * ---------------------------------------------------------- - * - * The portTASK_FUNCTION() macro is used to allow port/compiler specific - * language extensions. The equivalent prototype for this function is: - * - * void prvIdleTask( void *pvParameters ); - * - */ -static portTASK_FUNCTION( prvIdleTask, pvParameters ) -{ - /* Stop warnings. */ - ( void ) pvParameters; - - for( ;; ) - { - /* See if any tasks have been deleted. */ - prvCheckTasksWaitingTermination(); - - #if ( configUSE_PREEMPTION == 0 ) - { - /* If we are not using preemption we keep forcing a task switch to - see if any other task has become available. If we are using - preemption we don't need to do this as any task becoming available - will automatically get the processor anyway. */ - taskYIELD(); - } - #endif - - #if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) - { - /* When using preemption tasks of equal priority will be - timesliced. If a task that is sharing the idle priority is ready - to run then the idle task should yield before the end of the - timeslice. - - A critical region is not required here as we are just reading from - the list, and an occasional incorrect value will not matter. If - the ready list at the idle priority contains more than one task - then a task other than the idle task is ready to execute. */ - if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( unsigned portBASE_TYPE ) 1 ) - { - taskYIELD(); - } - } - #endif - - #if ( configUSE_IDLE_HOOK == 1 ) - { - extern void vApplicationIdleHook( void ); - - /* Call the user defined function from within the idle task. This - allows the application designer to add background functionality - without the overhead of a separate task. - NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, - CALL A FUNCTION THAT MIGHT BLOCK. */ - vApplicationIdleHook(); - } - #endif - } -} /*lint !e715 pvParameters is not accessed but all task functions require the same prototype. */ - - - - - - - -/*----------------------------------------------------------- - * File private functions documented at the top of the file. - *----------------------------------------------------------*/ - - - -static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion * const xRegions, unsigned short usStackDepth ) -{ - /* Store the function name in the TCB. */ - #if configMAX_TASK_NAME_LEN > 1 - { - /* Don't bring strncpy into the build unnecessarily. */ - strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned short ) configMAX_TASK_NAME_LEN ); - } - #endif - pxTCB->pcTaskName[ ( unsigned short ) configMAX_TASK_NAME_LEN - ( unsigned short ) 1 ] = ( signed char ) '\0'; - - /* This is used as an array index so must ensure it's not too large. First - remove the privilege bit if one is present. */ - if( uxPriority >= configMAX_PRIORITIES ) - { - uxPriority = configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U; - } - - pxTCB->uxPriority = uxPriority; - #if ( configUSE_MUTEXES == 1 ) - { - pxTCB->uxBasePriority = uxPriority; - } - #endif - - vListInitialiseItem( &( pxTCB->xGenericListItem ) ); - vListInitialiseItem( &( pxTCB->xEventListItem ) ); - - /* Set the pxTCB as a link back from the xListItem. This is so we can get - back to the containing TCB from a generic item in a list. */ - listSET_LIST_ITEM_OWNER( &( pxTCB->xGenericListItem ), pxTCB ); - - /* Event lists are always in priority order. */ - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority ); - listSET_LIST_ITEM_OWNER( &( pxTCB->xEventListItem ), pxTCB ); - - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - { - pxTCB->uxCriticalNesting = ( unsigned portBASE_TYPE ) 0; - } - #endif - - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - { - pxTCB->pxTaskTag = NULL; - } - #endif - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - { - pxTCB->ulRunTimeCounter = 0UL; - } - #endif - - #if ( portUSING_MPU_WRAPPERS == 1 ) - { - vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, pxTCB->pxStack, usStackDepth ); - } - #else - { - ( void ) xRegions; - ( void ) usStackDepth; - } - #endif -} -/*-----------------------------------------------------------*/ - -#if ( portUSING_MPU_WRAPPERS == 1 ) - - void vTaskAllocateMPURegions( xTaskHandle xTaskToModify, const xMemoryRegion * const xRegions ) - { - tskTCB *pxTCB; - - if( xTaskToModify == pxCurrentTCB ) - { - xTaskToModify = NULL; - } - - /* If null is passed in here then we are deleting ourselves. */ - pxTCB = prvGetTCBFromHandle( xTaskToModify ); - - vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 ); - } - /*-----------------------------------------------------------*/ -#endif - -static void prvInitialiseTaskLists( void ) -{ -unsigned portBASE_TYPE uxPriority; - - for( uxPriority = ( unsigned portBASE_TYPE ) 0U; uxPriority < configMAX_PRIORITIES; uxPriority++ ) - { - vListInitialise( ( xList * ) &( pxReadyTasksLists[ uxPriority ] ) ); - } - - vListInitialise( ( xList * ) &xDelayedTaskList1 ); - vListInitialise( ( xList * ) &xDelayedTaskList2 ); - vListInitialise( ( xList * ) &xPendingReadyList ); - - #if ( INCLUDE_vTaskDelete == 1 ) - { - vListInitialise( ( xList * ) &xTasksWaitingTermination ); - } - #endif - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - vListInitialise( ( xList * ) &xSuspendedTaskList ); - } - #endif - - /* Start with pxDelayedTaskList using list1 and the pxOverflowDelayedTaskList - using list2. */ - pxDelayedTaskList = &xDelayedTaskList1; - pxOverflowDelayedTaskList = &xDelayedTaskList2; -} -/*-----------------------------------------------------------*/ - -static void prvCheckTasksWaitingTermination( void ) -{ - #if ( INCLUDE_vTaskDelete == 1 ) - { - portBASE_TYPE xListIsEmpty; - - /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called - too often in the idle task. */ - if( uxTasksDeleted > ( unsigned portBASE_TYPE ) 0 ) - { - vTaskSuspendAll(); - xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination ); - xTaskResumeAll(); - - if( xListIsEmpty == pdFALSE ) - { - tskTCB *pxTCB; - - taskENTER_CRITICAL(); - { - pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xTasksWaitingTermination ) ); - vListRemove( &( pxTCB->xGenericListItem ) ); - --uxCurrentNumberOfTasks; - --uxTasksDeleted; - } - taskEXIT_CRITICAL(); - - prvDeleteTCB( pxTCB ); - } - } - } - #endif -} -/*-----------------------------------------------------------*/ - -static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake ) -{ - /* The list item will be inserted in wake time order. */ - listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake ); - - if( xTimeToWake < xTickCount ) - { - /* Wake time has overflowed. Place this item in the overflow list. */ - vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* The wake time has not overflowed, so we can use the current block list. */ - vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ); - - /* If the task entering the blocked state was placed at the head of the - list of blocked tasks then xNextTaskUnblockTime needs to be updated - too. */ - if( xTimeToWake < xNextTaskUnblockTime ) - { - xNextTaskUnblockTime = xTimeToWake; - } - } -} -/*-----------------------------------------------------------*/ - -static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TYPE *puxStackBuffer ) -{ -tskTCB *pxNewTCB; - - /* Allocate space for the TCB. Where the memory comes from depends on - the implementation of the port malloc function. */ - pxNewTCB = ( tskTCB * ) pvPortMalloc( sizeof( tskTCB ) ); - - if( pxNewTCB != NULL ) - { - /* Allocate space for the stack used by the task being created. - The base of the stack memory stored in the TCB so the task can - be deleted later if required. */ - pxNewTCB->pxStack = ( portSTACK_TYPE * ) pvPortMallocAligned( ( ( ( size_t )usStackDepth ) * sizeof( portSTACK_TYPE ) ), puxStackBuffer ); - - if( pxNewTCB->pxStack == NULL ) - { - /* Could not allocate the stack. Delete the allocated TCB. */ - vPortFree( pxNewTCB ); - pxNewTCB = NULL; - } - else - { - /* Just to help debugging. */ - memset( pxNewTCB->pxStack, tskSTACK_FILL_BYTE, usStackDepth * sizeof( portSTACK_TYPE ) ); - } - } - - return pxNewTCB; -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - static void prvListTaskWithinSingleList( const signed char *pcWriteBuffer, xList *pxList, signed char cStatus ) - { - volatile tskTCB *pxNextTCB, *pxFirstTCB; - unsigned short usStackRemaining; - - /* Write the details of all the TCB's in pxList into the buffer. */ - listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); - do - { - listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); - #if ( portSTACK_GROWTH > 0 ) - { - usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxEndOfStack ); - } - #else - { - usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxStack ); - } - #endif - - sprintf( pcStatusString, ( char * ) "%s\t\t%c\t%u\t%u\t%u\r\n", pxNextTCB->pcTaskName, cStatus, ( unsigned int ) pxNextTCB->uxPriority, usStackRemaining, ( unsigned int ) pxNextTCB->uxTCBNumber ); - strcat( ( char * ) pcWriteBuffer, ( char * ) pcStatusString ); - - } while( pxNextTCB != pxFirstTCB ); - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( configGENERATE_RUN_TIME_STATS == 1 ) - - static void prvGenerateRunTimeStatsForTasksInList( const signed char *pcWriteBuffer, xList *pxList, unsigned long ulTotalRunTime ) - { - volatile tskTCB *pxNextTCB, *pxFirstTCB; - unsigned long ulStatsAsPercentage; - - /* Write the run time stats of all the TCB's in pxList into the buffer. */ - listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); - do - { - /* Get next TCB in from the list. */ - listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); - - /* Divide by zero check. */ - if( ulTotalRunTime > 0UL ) - { - /* Has the task run at all? */ - if( pxNextTCB->ulRunTimeCounter == 0 ) - { - /* The task has used no CPU time at all. */ - sprintf( pcStatsString, ( char * ) "%s\t\t0\t\t0%%\r\n", pxNextTCB->pcTaskName ); - } - else - { - /* What percentage of the total run time has the task used? - This will always be rounded down to the nearest integer. - ulTotalRunTime has already been divided by 100. */ - ulStatsAsPercentage = pxNextTCB->ulRunTimeCounter / ulTotalRunTime; - - if( ulStatsAsPercentage > 0UL ) - { - #ifdef portLU_PRINTF_SPECIFIER_REQUIRED - { - sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter, ulStatsAsPercentage ); - } - #else - { - /* sizeof( int ) == sizeof( long ) so a smaller - printf() library can be used. */ - sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); - } - #endif - } - else - { - /* If the percentage is zero here then the task has - consumed less than 1% of the total run time. */ - #ifdef portLU_PRINTF_SPECIFIER_REQUIRED - { - sprintf( pcStatsString, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxNextTCB->pcTaskName, pxNextTCB->ulRunTimeCounter ); - } - #else - { - /* sizeof( int ) == sizeof( long ) so a smaller - printf() library can be used. */ - sprintf( pcStatsString, ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxNextTCB->pcTaskName, ( unsigned int ) pxNextTCB->ulRunTimeCounter ); - } - #endif - } - } - - strcat( ( char * ) pcWriteBuffer, ( char * ) pcStatsString ); - } - - } while( pxNextTCB != pxFirstTCB ); - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) - - static unsigned short usTaskCheckFreeStackSpace( const unsigned char * pucStackByte ) - { - register unsigned short usCount = 0; - - while( *pucStackByte == tskSTACK_FILL_BYTE ) - { - pucStackByte -= portSTACK_GROWTH; - usCount++; - } - - usCount /= sizeof( portSTACK_TYPE ); - - return usCount; - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) - - unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask ) - { - tskTCB *pxTCB; - unsigned char *pcEndOfStack; - unsigned portBASE_TYPE uxReturn; - - pxTCB = prvGetTCBFromHandle( xTask ); - - #if portSTACK_GROWTH < 0 - { - pcEndOfStack = ( unsigned char * ) pxTCB->pxStack; - } - #else - { - pcEndOfStack = ( unsigned char * ) pxTCB->pxEndOfStack; - } - #endif - - uxReturn = ( unsigned portBASE_TYPE ) usTaskCheckFreeStackSpace( pcEndOfStack ); - - return uxReturn; - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) ) - - static void prvDeleteTCB( tskTCB *pxTCB ) - { - /* Free up the memory allocated by the scheduler for the task. It is up to - the task to free any memory allocated at the application level. */ - vPortFreeAligned( pxTCB->pxStack ); - vPortFree( pxTCB ); - } - -#endif - - -/*-----------------------------------------------------------*/ - -#if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) - - xTaskHandle xTaskGetCurrentTaskHandle( void ) - { - xTaskHandle xReturn; - - /* A critical section is not required as this is not called from - an interrupt and the current TCB will always be the same for any - individual execution thread. */ - xReturn = pxCurrentTCB; - - return xReturn; - } - -#endif - -/*-----------------------------------------------------------*/ - -#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) - - portBASE_TYPE xTaskGetSchedulerState( void ) - { - portBASE_TYPE xReturn; - - if( xSchedulerRunning == pdFALSE ) - { - xReturn = taskSCHEDULER_NOT_STARTED; - } - else - { - if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE ) - { - xReturn = taskSCHEDULER_RUNNING; - } - else - { - xReturn = taskSCHEDULER_SUSPENDED; - } - } - - return xReturn; - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( configUSE_MUTEXES == 1 ) - - void vTaskPriorityInherit( xTaskHandle * const pxMutexHolder ) - { - tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder; - - configASSERT( pxMutexHolder ); - - if( pxTCB->uxPriority < pxCurrentTCB->uxPriority ) - { - /* Adjust the mutex holder state to account for its new priority. */ - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB->uxPriority ); - - /* If the task being modified is in the ready state it will need to - be moved in to a new list. */ - if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) ) - { - vListRemove( &( pxTCB->xGenericListItem ) ); - - /* Inherit the priority before being moved into the new list. */ - pxTCB->uxPriority = pxCurrentTCB->uxPriority; - prvAddTaskToReadyQueue( pxTCB ); - } - else - { - /* Just inherit the priority. */ - pxTCB->uxPriority = pxCurrentTCB->uxPriority; - } - } - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( configUSE_MUTEXES == 1 ) - - void vTaskPriorityDisinherit( xTaskHandle * const pxMutexHolder ) - { - tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder; - - if( pxMutexHolder != NULL ) - { - if( pxTCB->uxPriority != pxTCB->uxBasePriority ) - { - /* We must be the running task to be able to give the mutex back. - Remove ourselves from the ready list we currently appear in. */ - vListRemove( &( pxTCB->xGenericListItem ) ); - - /* Disinherit the priority before adding ourselves into the new - ready list. */ - pxTCB->uxPriority = pxTCB->uxBasePriority; - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxTCB->uxPriority ); - prvAddTaskToReadyQueue( pxTCB ); - } - } - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( portCRITICAL_NESTING_IN_TCB == 1 ) - - void vTaskEnterCritical( void ) - { - portDISABLE_INTERRUPTS(); - - if( xSchedulerRunning != pdFALSE ) - { - ( pxCurrentTCB->uxCriticalNesting )++; - } - } - -#endif -/*-----------------------------------------------------------*/ - -#if ( portCRITICAL_NESTING_IN_TCB == 1 ) - -void vTaskExitCritical( void ) -{ - if( xSchedulerRunning != pdFALSE ) - { - if( pxCurrentTCB->uxCriticalNesting > 0 ) - { - ( pxCurrentTCB->uxCriticalNesting )--; - - if( pxCurrentTCB->uxCriticalNesting == 0 ) - { - portENABLE_INTERRUPTS(); - } - } - } -} - -#endif -/*-----------------------------------------------------------*/ - - - - diff --git a/GD32F1/libraries/FreeRTOS/utility/timers.c b/GD32F1/libraries/FreeRTOS/utility/timers.c deleted file mode 100644 index 1dd7555..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/timers.c +++ /dev/null @@ -1,649 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "timers.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* This entire source file will be skipped if the application is not configured -to include software timer functionality. This #if is closed at the very bottom -of this file. If you want to include software timer functionality then ensure -configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */ -#if ( configUSE_TIMERS == 1 ) - -/* Misc definitions. */ -#define tmrNO_DELAY ( portTickType ) 0U - -/* The definition of the timers themselves. */ -typedef struct tmrTimerControl -{ - const signed char *pcTimerName; /*<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */ - xListItem xTimerListItem; /*<< Standard linked list item as used by all kernel features for event management. */ - portTickType xTimerPeriodInTicks;/*<< How quickly and often the timer expires. */ - unsigned portBASE_TYPE uxAutoReload; /*<< Set to pdTRUE if the timer should be automatically restarted once expired. Set to pdFALSE if the timer is, in effect, a one shot timer. */ - void *pvTimerID; /*<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. */ - tmrTIMER_CALLBACK pxCallbackFunction; /*<< The function that will be called when the timer expires. */ -} xTIMER; - -/* The definition of messages that can be sent and received on the timer -queue. */ -typedef struct tmrTimerQueueMessage -{ - portBASE_TYPE xMessageID; /*<< The command being sent to the timer service task. */ - portTickType xMessageValue; /*<< An optional value used by a subset of commands, for example, when changing the period of a timer. */ - xTIMER * pxTimer; /*<< The timer to which the command will be applied. */ -} xTIMER_MESSAGE; - - -/* The list in which active timers are stored. Timers are referenced in expire -time order, with the nearest expiry time at the front of the list. Only the -timer service task is allowed to access xActiveTimerList. */ -PRIVILEGED_DATA static xList xActiveTimerList1; -PRIVILEGED_DATA static xList xActiveTimerList2; -PRIVILEGED_DATA static xList *pxCurrentTimerList; -PRIVILEGED_DATA static xList *pxOverflowTimerList; - -/* A queue that is used to send commands to the timer service task. */ -PRIVILEGED_DATA static xQueueHandle xTimerQueue = NULL; - -/*-----------------------------------------------------------*/ - -/* - * Initialise the infrastructure used by the timer service task if it has not - * been initialised already. - */ -static void prvCheckForValidListAndQueue( void ) PRIVILEGED_FUNCTION; - -/* - * The timer service task (daemon). Timer functionality is controlled by this - * task. Other tasks communicate with the timer service task using the - * xTimerQueue queue. - */ -static void prvTimerTask( void *pvParameters ) PRIVILEGED_FUNCTION; - -/* - * Called by the timer service task to interpret and process a command it - * received on the timer queue. - */ -static void prvProcessReceivedCommands( void ) PRIVILEGED_FUNCTION; - -/* - * Insert the timer into either xActiveTimerList1, or xActiveTimerList2, - * depending on if the expire time causes a timer counter overflow. - */ -static portBASE_TYPE prvInsertTimerInActiveList( xTIMER *pxTimer, portTickType xNextExpiryTime, portTickType xTimeNow, portTickType xCommandTime ) PRIVILEGED_FUNCTION; - -/* - * An active timer has reached its expire time. Reload the timer if it is an - * auto reload timer, then call its callback. - */ -static void prvProcessExpiredTimer( portTickType xNextExpireTime, portTickType xTimeNow ) PRIVILEGED_FUNCTION; - -/* - * The tick count has overflowed. Switch the timer lists after ensuring the - * current timer list does not still reference some timers. - */ -static void prvSwitchTimerLists( portTickType xLastTime ) PRIVILEGED_FUNCTION; - -/* - * Obtain the current tick count, setting *pxTimerListsWereSwitched to pdTRUE - * if a tick count overflow occurred since prvSampleTimeNow() was last called. - */ -static portTickType prvSampleTimeNow( portBASE_TYPE *pxTimerListsWereSwitched ) PRIVILEGED_FUNCTION; - -/* - * If the timer list contains any active timers then return the expire time of - * the timer that will expire first and set *pxListWasEmpty to false. If the - * timer list does not contain any timers then return 0 and set *pxListWasEmpty - * to pdTRUE. - */ -static portTickType prvGetNextExpireTime( portBASE_TYPE *pxListWasEmpty ) PRIVILEGED_FUNCTION; - -/* - * If a timer has expired, process it. Otherwise, block the timer service task - * until either a timer does expire or a command is received. - */ -static void prvProcessTimerOrBlockTask( portTickType xNextExpireTime, portBASE_TYPE xListWasEmpty ) PRIVILEGED_FUNCTION; - -/*-----------------------------------------------------------*/ - -portBASE_TYPE xTimerCreateTimerTask( void ) -{ -portBASE_TYPE xReturn = pdFAIL; - - /* This function is called when the scheduler is started if - configUSE_TIMERS is set to 1. Check that the infrastructure used by the - timer service task has been created/initialised. If timers have already - been created then the initialisation will already have been performed. */ - prvCheckForValidListAndQueue(); - - if( xTimerQueue != NULL ) - { - xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, NULL); - } - - configASSERT( xReturn ); - return xReturn; -} -/*-----------------------------------------------------------*/ - -xTimerHandle xTimerCreate( const signed char *pcTimerName, portTickType xTimerPeriodInTicks, unsigned portBASE_TYPE uxAutoReload, void *pvTimerID, tmrTIMER_CALLBACK pxCallbackFunction ) -{ -xTIMER *pxNewTimer; - - /* Allocate the timer structure. */ - if( xTimerPeriodInTicks == ( portTickType ) 0U ) - { - pxNewTimer = NULL; - configASSERT( ( xTimerPeriodInTicks > 0 ) ); - } - else - { - pxNewTimer = ( xTIMER * ) pvPortMalloc( sizeof( xTIMER ) ); - if( pxNewTimer != NULL ) - { - /* Ensure the infrastructure used by the timer service task has been - created/initialised. */ - prvCheckForValidListAndQueue(); - - /* Initialise the timer structure members using the function parameters. */ - pxNewTimer->pcTimerName = pcTimerName; - pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks; - pxNewTimer->uxAutoReload = uxAutoReload; - pxNewTimer->pvTimerID = pvTimerID; - pxNewTimer->pxCallbackFunction = pxCallbackFunction; - vListInitialiseItem( &( pxNewTimer->xTimerListItem ) ); - - traceTIMER_CREATE( pxNewTimer ); - } - else - { - traceTIMER_CREATE_FAILED(); - } - } - - return ( xTimerHandle ) pxNewTimer; -} -/*-----------------------------------------------------------*/ - -portBASE_TYPE xTimerGenericCommand( xTimerHandle xTimer, portBASE_TYPE xCommandID, portTickType xOptionalValue, portBASE_TYPE *pxHigherPriorityTaskWoken, portTickType xBlockTime ) -{ -portBASE_TYPE xReturn = pdFAIL; -xTIMER_MESSAGE xMessage; - - /* Send a message to the timer service task to perform a particular action - on a particular timer definition. */ - if( xTimerQueue != NULL ) - { - /* Send a command to the timer service task to start the xTimer timer. */ - xMessage.xMessageID = xCommandID; - xMessage.xMessageValue = xOptionalValue; - xMessage.pxTimer = ( xTIMER * ) xTimer; - - if( pxHigherPriorityTaskWoken == NULL ) - { - if( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING ) - { - xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xBlockTime ); - } - else - { - xReturn = xQueueSendToBack( xTimerQueue, &xMessage, tmrNO_DELAY ); - } - } - else - { - xReturn = xQueueSendToBackFromISR( xTimerQueue, &xMessage, pxHigherPriorityTaskWoken ); - } - - traceTIMER_COMMAND_SEND( xTimer, xCommandID, xOptionalValue, xReturn ); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static void prvProcessExpiredTimer( portTickType xNextExpireTime, portTickType xTimeNow ) -{ -xTIMER *pxTimer; -portBASE_TYPE xResult; - - /* Remove the timer from the list of active timers. A check has already - been performed to ensure the list is not empty. */ - pxTimer = ( xTIMER * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); - vListRemove( &( pxTimer->xTimerListItem ) ); - traceTIMER_EXPIRED( pxTimer ); - - /* If the timer is an auto reload timer then calculate the next - expiry time and re-insert the timer in the list of active timers. */ - if( pxTimer->uxAutoReload == ( unsigned portBASE_TYPE ) pdTRUE ) - { - /* This is the only time a timer is inserted into a list using - a time relative to anything other than the current time. It - will therefore be inserted into the correct list relative to - the time this task thinks it is now, even if a command to - switch lists due to a tick count overflow is already waiting in - the timer queue. */ - if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) == pdTRUE ) - { - /* The timer expired before it was added to the active timer - list. Reload it now. */ - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; - } - } - - /* Call the timer callback. */ - pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer ); -} -/*-----------------------------------------------------------*/ - -static void prvTimerTask( void *pvParameters ) -{ -portTickType xNextExpireTime; -portBASE_TYPE xListWasEmpty; - - /* Just to avoid compiler warnings. */ - ( void ) pvParameters; - - for( ;; ) - { - /* Query the timers list to see if it contains any timers, and if so, - obtain the time at which the next timer will expire. */ - xNextExpireTime = prvGetNextExpireTime( &xListWasEmpty ); - - /* If a timer has expired, process it. Otherwise, block this task - until either a timer does expire, or a command is received. */ - prvProcessTimerOrBlockTask( xNextExpireTime, xListWasEmpty ); - - /* Empty the command queue. */ - prvProcessReceivedCommands(); - } -} -/*-----------------------------------------------------------*/ - -static void prvProcessTimerOrBlockTask( portTickType xNextExpireTime, portBASE_TYPE xListWasEmpty ) -{ -portTickType xTimeNow; -portBASE_TYPE xTimerListsWereSwitched; - - vTaskSuspendAll(); - { - /* Obtain the time now to make an assessment as to whether the timer - has expired or not. If obtaining the time causes the lists to switch - then don't process this timer as any timers that remained in the list - when the lists were switched will have been processed within the - prvSampelTimeNow() function. */ - xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched ); - if( xTimerListsWereSwitched == pdFALSE ) - { - /* The tick count has not overflowed, has the timer expired? */ - if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) ) - { - xTaskResumeAll(); - prvProcessExpiredTimer( xNextExpireTime, xTimeNow ); - } - else - { - /* The tick count has not overflowed, and the next expire - time has not been reached yet. This task should therefore - block to wait for the next expire time or a command to be - received - whichever comes first. The following line cannot - be reached unless xNextExpireTime > xTimeNow, except in the - case when the current timer list is empty. */ - vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ) ); - - if( xTaskResumeAll() == pdFALSE ) - { - /* Yield to wait for either a command to arrive, or the block time - to expire. If a command arrived between the critical section being - exited and this yield then the yield will not cause the task - to block. */ - portYIELD_WITHIN_API(); - } - } - } - else - { - xTaskResumeAll(); - } - } -} -/*-----------------------------------------------------------*/ - -static portTickType prvGetNextExpireTime( portBASE_TYPE *pxListWasEmpty ) -{ -portTickType xNextExpireTime; - - /* Timers are listed in expiry time order, with the head of the list - referencing the task that will expire first. Obtain the time at which - the timer with the nearest expiry time will expire. If there are no - active timers then just set the next expire time to 0. That will cause - this task to unblock when the tick count overflows, at which point the - timer lists will be switched and the next expiry time can be - re-assessed. */ - *pxListWasEmpty = listLIST_IS_EMPTY( pxCurrentTimerList ); - if( *pxListWasEmpty == pdFALSE ) - { - xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList ); - } - else - { - /* Ensure the task unblocks when the tick count rolls over. */ - xNextExpireTime = ( portTickType ) 0U; - } - - return xNextExpireTime; -} -/*-----------------------------------------------------------*/ - -static portTickType prvSampleTimeNow( portBASE_TYPE *pxTimerListsWereSwitched ) -{ -portTickType xTimeNow; -static portTickType xLastTime = ( portTickType ) 0U; - - xTimeNow = xTaskGetTickCount(); - - if( xTimeNow < xLastTime ) - { - prvSwitchTimerLists( xLastTime ); - *pxTimerListsWereSwitched = pdTRUE; - } - else - { - *pxTimerListsWereSwitched = pdFALSE; - } - - xLastTime = xTimeNow; - - return xTimeNow; -} -/*-----------------------------------------------------------*/ - -static portBASE_TYPE prvInsertTimerInActiveList( xTIMER *pxTimer, portTickType xNextExpiryTime, portTickType xTimeNow, portTickType xCommandTime ) -{ -portBASE_TYPE xProcessTimerNow = pdFALSE; - - listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xNextExpiryTime ); - listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer ); - - if( xNextExpiryTime <= xTimeNow ) - { - /* Has the expiry time elapsed between the command to start/reset a - timer was issued, and the time the command was processed? */ - if( ( ( portTickType ) ( xTimeNow - xCommandTime ) ) >= pxTimer->xTimerPeriodInTicks ) - { - /* The time between a command being issued and the command being - processed actually exceeds the timers period. */ - xProcessTimerNow = pdTRUE; - } - else - { - vListInsert( pxOverflowTimerList, &( pxTimer->xTimerListItem ) ); - } - } - else - { - if( ( xTimeNow < xCommandTime ) && ( xNextExpiryTime >= xCommandTime ) ) - { - /* If, since the command was issued, the tick count has overflowed - but the expiry time has not, then the timer must have already passed - its expiry time and should be processed immediately. */ - xProcessTimerNow = pdTRUE; - } - else - { - vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) ); - } - } - - return xProcessTimerNow; -} -/*-----------------------------------------------------------*/ - -static void prvProcessReceivedCommands( void ) -{ -xTIMER_MESSAGE xMessage; -xTIMER *pxTimer; -portBASE_TYPE xTimerListsWereSwitched, xResult; -portTickType xTimeNow; - - /* In this case the xTimerListsWereSwitched parameter is not used, but it - must be present in the function call. */ - xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched ); - - while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) - { - pxTimer = xMessage.pxTimer; - - /* Is the timer already in a list of active timers? When the command - is trmCOMMAND_PROCESS_TIMER_OVERFLOW, the timer will be NULL as the - command is to the task rather than to an individual timer. */ - if( pxTimer != NULL ) - { - if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE ) - { - /* The timer is in a list, remove it. */ - vListRemove( &( pxTimer->xTimerListItem ) ); - } - } - - traceTIMER_COMMAND_RECEIVED( pxTimer, xMessage.xMessageID, xMessage.xMessageValue ); - - switch( xMessage.xMessageID ) - { - case tmrCOMMAND_START : - /* Start or restart a timer. */ - if( prvInsertTimerInActiveList( pxTimer, xMessage.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow, xMessage.xMessageValue ) == pdTRUE ) - { - /* The timer expired before it was added to the active timer - list. Process it now. */ - pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer ); - - if( pxTimer->uxAutoReload == ( unsigned portBASE_TYPE ) pdTRUE ) - { - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xMessage.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; - } - } - break; - - case tmrCOMMAND_STOP : - /* The timer has already been removed from the active list. - There is nothing to do here. */ - break; - - case tmrCOMMAND_CHANGE_PERIOD : - pxTimer->xTimerPeriodInTicks = xMessage.xMessageValue; - configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) ); - prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow ); - break; - - case tmrCOMMAND_DELETE : - /* The timer has already been removed from the active list, - just free up the memory. */ - vPortFree( pxTimer ); - break; - - default : - /* Don't expect to get here. */ - break; - } - } -} -/*-----------------------------------------------------------*/ - -static void prvSwitchTimerLists( portTickType xLastTime ) -{ -portTickType xNextExpireTime, xReloadTime; -xList *pxTemp; -xTIMER *pxTimer; -portBASE_TYPE xResult; - - /* Remove compiler warnings if configASSERT() is not defined. */ - ( void ) xLastTime; - - /* The tick count has overflowed. The timer lists must be switched. - If there are any timers still referenced from the current timer list - then they must have expired and should be processed before the lists - are switched. */ - while( listLIST_IS_EMPTY( pxCurrentTimerList ) == pdFALSE ) - { - xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList ); - - /* Remove the timer from the list. */ - pxTimer = ( xTIMER * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); - vListRemove( &( pxTimer->xTimerListItem ) ); - - /* Execute its callback, then send a command to restart the timer if - it is an auto-reload timer. It cannot be restarted here as the lists - have not yet been switched. */ - pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer ); - - if( pxTimer->uxAutoReload == ( unsigned portBASE_TYPE ) pdTRUE ) - { - /* Calculate the reload value, and if the reload value results in - the timer going into the same timer list then it has already expired - and the timer should be re-inserted into the current list so it is - processed again within this loop. Otherwise a command should be sent - to restart the timer to ensure it is only inserted into a list after - the lists have been swapped. */ - xReloadTime = ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ); - if( xReloadTime > xNextExpireTime ) - { - listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xReloadTime ); - listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer ); - vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) ); - } - else - { - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; - } - } - } - - pxTemp = pxCurrentTimerList; - pxCurrentTimerList = pxOverflowTimerList; - pxOverflowTimerList = pxTemp; -} -/*-----------------------------------------------------------*/ - -static void prvCheckForValidListAndQueue( void ) -{ - /* Check that the list from which active timers are referenced, and the - queue used to communicate with the timer service, have been - initialised. */ - taskENTER_CRITICAL(); - { - if( xTimerQueue == NULL ) - { - vListInitialise( &xActiveTimerList1 ); - vListInitialise( &xActiveTimerList2 ); - pxCurrentTimerList = &xActiveTimerList1; - pxOverflowTimerList = &xActiveTimerList2; - xTimerQueue = xQueueCreate( ( unsigned portBASE_TYPE ) configTIMER_QUEUE_LENGTH, sizeof( xTIMER_MESSAGE ) ); - } - } - taskEXIT_CRITICAL(); -} -/*-----------------------------------------------------------*/ - -portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) -{ -portBASE_TYPE xTimerIsInActiveList; -xTIMER *pxTimer = ( xTIMER * ) xTimer; - - /* Is the timer in the list of active timers? */ - taskENTER_CRITICAL(); - { - /* Checking to see if it is in the NULL list in effect checks to see if - it is referenced from either the current or the overflow timer lists in - one go, but the logic has to be reversed, hence the '!'. */ - xTimerIsInActiveList = !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) ); - } - taskEXIT_CRITICAL(); - - return xTimerIsInActiveList; -} -/*-----------------------------------------------------------*/ - -void *pvTimerGetTimerID( xTimerHandle xTimer ) -{ -xTIMER *pxTimer = ( xTIMER * ) xTimer; - - return pxTimer->pvTimerID; -} -/*-----------------------------------------------------------*/ - -/* This entire source file will be skipped if the application is not configured -to include software timer functionality. If you want to include software timer -functionality then ensure configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */ -#endif /* configUSE_TIMERS == 1 */ diff --git a/GD32F1/libraries/FreeRTOS/utility/timers.h b/GD32F1/libraries/FreeRTOS/utility/timers.h deleted file mode 100644 index f1bcb0d..0000000 --- a/GD32F1/libraries/FreeRTOS/utility/timers.h +++ /dev/null @@ -1,936 +0,0 @@ -/* - FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. - - - FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: - Atollic AB - Atollic provides professional embedded systems development - tools for C/C++ development, code analysis and test automation. - See http://www.atollic.com - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - - -#ifndef TIMERS_H -#define TIMERS_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include timers.h" -#endif - -#include "portable.h" -#include "list.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* IDs for commands that can be sent/received on the timer queue. These are to -be used solely through the macros that make up the public software timer API, -as defined below. */ -#define tmrCOMMAND_START 0 -#define tmrCOMMAND_STOP 1 -#define tmrCOMMAND_CHANGE_PERIOD 2 -#define tmrCOMMAND_DELETE 3 - -/*----------------------------------------------------------- - * MACROS AND DEFINITIONS - *----------------------------------------------------------*/ - - /** - * Type by which software timers are referenced. For example, a call to - * xTimerCreate() returns an xTimerHandle variable that can then be used to - * reference the subject timer in calls to other software timer API functions - * (for example, xTimerStart(), xTimerReset(), etc.). - */ -typedef void * xTimerHandle; - -/* Define the prototype to which timer callback functions must conform. */ -typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer ); - -/** - * xTimerHandle xTimerCreate( const signed char *pcTimerName, - * portTickType xTimerPeriod, - * unsigned portBASE_TYPE uxAutoReload, - * void * pvTimerID, - * tmrTIMER_CALLBACK pxCallbackFunction ); - * - * Creates a new software timer instance. This allocates the storage required - * by the new timer, initialises the new timers internal state, and returns a - * handle by which the new timer can be referenced. - * - * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), - * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and - * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the - * active state. - * - * @param pcTimerName A text name that is assigned to the timer. This is done - * purely to assist debugging. The kernel itself only ever references a timer by - * its handle, and never by its name. - * - * @param xTimerPeriod The timer period. The time is defined in tick periods so - * the constant portTICK_RATE_MS can be used to convert a time that has been - * specified in milliseconds. For example, if the timer must expire after 100 - * ticks, then xTimerPeriod should be set to 100. Alternatively, if the timer - * must expire after 500ms, then xPeriod can be set to ( 500 / portTICK_RATE_MS ) - * provided configTICK_RATE_HZ is less than or equal to 1000. - * - * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will - * expire repeatedly with a frequency set by the xTimerPeriod parameter. If - * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and - * enter the dormant state after it expires. - * - * @param pvTimerID An identifier that is assigned to the timer being created. - * Typically this would be used in the timer callback function to identify which - * timer expired when the same callback function is assigned to more than one - * timer. - * - * @param pxCallbackFunction The function to call when the timer expires. - * Callback functions must have the prototype defined by tmrTIMER_CALLBACK, - * which is "void vCallbackFunction( xTIMER *xTimer );". - * - * @return If the timer is successfully create then a handle to the newly - * created timer is returned. If the timer cannot be created (because either - * there is insufficient FreeRTOS heap remaining to allocate the timer - * structures, or the timer period was set to 0) then 0 is returned. - * - * Example usage: - * - * - * #define NUM_TIMERS 5 - * - * // An array to hold handles to the created timers. - * xTimerHandle xTimers[ NUM_TIMERS ]; - * - * // An array to hold a count of the number of times each timer expires. - * long lExpireCounters[ NUM_TIMERS ] = { 0 }; - * - * // Define a callback function that will be used by multiple timer instances. - * // The callback function does nothing but count the number of times the - * // associated timer expires, and stop the timer once the timer has expired - * // 10 times. - * void vTimerCallback( xTIMER *pxTimer ) - * { - * long lArrayIndex; - * const long xMaxExpiryCountBeforeStopping = 10; - * - * // Optionally do something if the pxTimer parameter is NULL. - * configASSERT( pxTimer ); - * - * // Which timer expired? - * lArrayIndex = ( long ) pvTimerGetTimerID( pxTimer ); - * - * // Increment the number of times that pxTimer has expired. - * lExpireCounters[ lArrayIndex ] += 1; - * - * // If the timer has expired 10 times then stop it from running. - * if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping ) - * { - * // Do not use a block time if calling a timer API function from a - * // timer callback function, as doing so could cause a deadlock! - * xTimerStop( pxTimer, 0 ); - * } - * } - * - * void main( void ) - * { - * long x; - * - * // Create then start some timers. Starting the timers before the scheduler - * // has been started means the timers will start running immediately that - * // the scheduler starts. - * for( x = 0; x < NUM_TIMERS; x++ ) - * { - * xTimers[ x ] = xTimerCreate( "Timer", // Just a text name, not used by the kernel. - * ( 100 * x ), // The timer period in ticks. - * pdTRUE, // The timers will auto-reload themselves when they expire. - * ( void * ) x, // Assign each timer a unique id equal to its array index. - * vTimerCallback // Each timer calls the same callback when it expires. - * ); - * - * if( xTimers[ x ] == NULL ) - * { - * // The timer was not created. - * } - * else - * { - * // Start the timer. No block time is specified, and even if one was - * // it would be ignored because the scheduler has not yet been - * // started. - * if( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) - * { - * // The timer could not be set into the Active state. - * } - * } - * } - * - * // ... - * // Create tasks here. - * // ... - * - * // Starting the scheduler will start the timers running as they have already - * // been set into the active state. - * xTaskStartScheduler(); - * - * // Should not reach here. - * for( ;; ); - * } - */ -xTimerHandle xTimerCreate( const signed char *pcTimerName, portTickType xTimerPeriodInTicks, unsigned portBASE_TYPE uxAutoReload, void * pvTimerID, tmrTIMER_CALLBACK pxCallbackFunction ) PRIVILEGED_FUNCTION; - -/** - * void *pvTimerGetTimerID( xTimerHandle xTimer ); - * - * Returns the ID assigned to the timer. - * - * IDs are assigned to timers using the pvTimerID parameter of the call to - * xTimerCreated() that was used to create the timer. - * - * If the same callback function is assigned to multiple timers then the timer - * ID can be used within the callback function to identify which timer actually - * expired. - * - * @param xTimer The timer being queried. - * - * @return The ID assigned to the timer being queried. - * - * Example usage: - * - * See the xTimerCreate() API function example usage scenario. - */ -void *pvTimerGetTimerID( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; - -/** - * portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ); - * - * Queries a timer to see if it is active or dormant. - * - * A timer will be dormant if: - * 1) It has been created but not started, or - * 2) It is an expired on-shot timer that has not been restarted. - * - * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), - * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and - * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the - * active state. - * - * @param xTimer The timer being queried. - * - * @return pdFALSE will be returned if the timer is dormant. A value other than - * pdFALSE will be returned if the timer is active. - * - * Example usage: - * - * // This function assumes xTimer has already been created. - * void vAFunction( xTimerHandle xTimer ) - * { - * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" - * { - * // xTimer is active, do something. - * } - * else - * { - * // xTimer is not active, do something else. - * } - * } - */ -portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; - -/** - * portBASE_TYPE xTimerStart( xTimerHandle xTimer, portTickType xBlockTime ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerStart() starts a timer that was previously created using the - * xTimerCreate() API function. If the timer had already been started and was - * already in the active state, then xTimerStart() has equivalent functionality - * to the xTimerReset() API function. - * - * Starting a timer ensures the timer is in the active state. If the timer - * is not stopped, deleted, or reset in the mean time, the callback function - * associated with the timer will get called 'n' ticks after xTimerStart() was - * called, where 'n' is the timers defined period. - * - * It is valid to call xTimerStart() before the scheduler has been started, but - * when this is done the timer will not actually start until the scheduler is - * started, and the timers expiry time will be relative to when the scheduler is - * started, not relative to when xTimerStart() was called. - * - * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStart() - * to be available. - * - * @param xTimer The handle of the timer being started/restarted. - * - * @param xBlockTime Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the start command to be successfully - * sent to the timer command queue, should the queue already be full when - * xTimerStart() was called. xBlockTime is ignored if xTimerStart() is called - * before the scheduler is started. - * - * @return pdFAIL will be returned if the start command could not be sent to - * the timer command queue even after xBlockTime ticks had passed. pdPASS will - * be returned if the command was successfully sent to the timer command queue. - * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system, although the - * timers expiry time is relative to when xTimerStart() is actually called. The - * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * - * See the xTimerCreate() API function example usage scenario. - * - */ -#define xTimerStart( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xBlockTime ) ) - -/** - * portBASE_TYPE xTimerStop( xTimerHandle xTimer, portTickType xBlockTime ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerStop() stops a timer that was previously started using either of the - * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), - * xTimerChangePeriod() or xTimerChangePeriodFromISR() API functions. - * - * Stopping a timer ensures the timer is not in the active state. - * - * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStop() - * to be available. - * - * @param xTimer The handle of the timer being stopped. - * - * @param xBlockTime Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the stop command to be successfully - * sent to the timer command queue, should the queue already be full when - * xTimerStop() was called. xBlockTime is ignored if xTimerStop() is called - * before the scheduler is started. - * - * @return pdFAIL will be returned if the stop command could not be sent to - * the timer command queue even after xBlockTime ticks had passed. pdPASS will - * be returned if the command was successfully sent to the timer command queue. - * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system. The timer - * service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * - * See the xTimerCreate() API function example usage scenario. - * - */ -#define xTimerStop( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xBlockTime ) ) - -/** - * portBASE_TYPE xTimerChangePeriod( xTimerHandle xTimer, - * portTickType xNewPeriod, - * portTickType xBlockTime ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerChangePeriod() changes the period of a timer that was previously - * created using the xTimerCreate() API function. - * - * xTimerChangePeriod() can be called to change the period of an active or - * dormant state timer. - * - * The configUSE_TIMERS configuration constant must be set to 1 for - * xTimerChangePeriod() to be available. - * - * @param xTimer The handle of the timer that is having its period changed. - * - * @param xNewPeriod The new period for xTimer. Timer periods are specified in - * tick periods, so the constant portTICK_RATE_MS can be used to convert a time - * that has been specified in milliseconds. For example, if the timer must - * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, - * if the timer must expire after 500ms, then xNewPeriod can be set to - * ( 500 / portTICK_RATE_MS ) provided configTICK_RATE_HZ is less than - * or equal to 1000. - * - * @param xBlockTime Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the change period command to be - * successfully sent to the timer command queue, should the queue already be - * full when xTimerChangePeriod() was called. xBlockTime is ignored if - * xTimerChangePeriod() is called before the scheduler is started. - * - * @return pdFAIL will be returned if the change period command could not be - * sent to the timer command queue even after xBlockTime ticks had passed. - * pdPASS will be returned if the command was successfully sent to the timer - * command queue. When the command is actually processed will depend on the - * priority of the timer service/daemon task relative to other tasks in the - * system. The timer service/daemon task priority is set by the - * configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * - * // This function assumes xTimer has already been created. If the timer - * // referenced by xTimer is already active when it is called, then the timer - * // is deleted. If the timer referenced by xTimer is not active when it is - * // called, then the period of the timer is set to 500ms and the timer is - * // started. - * void vAFunction( xTimerHandle xTimer ) - * { - * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" - * { - * // xTimer is already active - delete it. - * xTimerDelete( xTimer ); - * } - * else - * { - * // xTimer is not active, change its period to 500ms. This will also - * // cause the timer to start. Block for a maximum of 100 ticks if the - * // change period command cannot immediately be sent to the timer - * // command queue. - * if( xTimerChangePeriod( xTimer, 500 / portTICK_RATE_MS, 100 ) == pdPASS ) - * { - * // The command was successfully sent. - * } - * else - * { - * // The command could not be sent, even after waiting for 100 ticks - * // to pass. Take appropriate action here. - * } - * } - * } - */ - #define xTimerChangePeriod( xTimer, xNewPeriod, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xBlockTime ) ) - -/** - * portBASE_TYPE xTimerDelete( xTimerHandle xTimer, portTickType xBlockTime ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerDelete() deletes a timer that was previously created using the - * xTimerCreate() API function. - * - * The configUSE_TIMERS configuration constant must be set to 1 for - * xTimerDelete() to be available. - * - * @param xTimer The handle of the timer being deleted. - * - * @param xBlockTime Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the delete command to be - * successfully sent to the timer command queue, should the queue already be - * full when xTimerDelete() was called. xBlockTime is ignored if xTimerDelete() - * is called before the scheduler is started. - * - * @return pdFAIL will be returned if the delete command could not be sent to - * the timer command queue even after xBlockTime ticks had passed. pdPASS will - * be returned if the command was successfully sent to the timer command queue. - * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system. The timer - * service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * - * See the xTimerChangePeriod() API function example usage scenario. - */ -#define xTimerDelete( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xBlockTime ) ) - -/** - * portBASE_TYPE xTimerReset( xTimerHandle xTimer, portTickType xBlockTime ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerReset() re-starts a timer that was previously created using the - * xTimerCreate() API function. If the timer had already been started and was - * already in the active state, then xTimerReset() will cause the timer to - * re-evaluate its expiry time so that it is relative to when xTimerReset() was - * called. If the timer was in the dormant state then xTimerReset() has - * equivalent functionality to the xTimerStart() API function. - * - * Resetting a timer ensures the timer is in the active state. If the timer - * is not stopped, deleted, or reset in the mean time, the callback function - * associated with the timer will get called 'n' ticks after xTimerReset() was - * called, where 'n' is the timers defined period. - * - * It is valid to call xTimerReset() before the scheduler has been started, but - * when this is done the timer will not actually start until the scheduler is - * started, and the timers expiry time will be relative to when the scheduler is - * started, not relative to when xTimerReset() was called. - * - * The configUSE_TIMERS configuration constant must be set to 1 for xTimerReset() - * to be available. - * - * @param xTimer The handle of the timer being reset/started/restarted. - * - * @param xBlockTime Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the reset command to be successfully - * sent to the timer command queue, should the queue already be full when - * xTimerReset() was called. xBlockTime is ignored if xTimerReset() is called - * before the scheduler is started. - * - * @return pdFAIL will be returned if the reset command could not be sent to - * the timer command queue even after xBlockTime ticks had passed. pdPASS will - * be returned if the command was successfully sent to the timer command queue. - * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system, although the - * timers expiry time is relative to when xTimerStart() is actually called. The - * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * - * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In - * // this case, the timer is a one-shot timer. - * - * xTimerHandle xBacklightTimer = NULL; - * - * // The callback function assigned to the one-shot timer. In this case the - * // parameter is not used. - * void vBacklightTimerCallback( xTIMER *pxTimer ) - * { - * // The timer expired, therefore 5 seconds must have passed since a key - * // was pressed. Switch off the LCD back-light. - * vSetBacklightState( BACKLIGHT_OFF ); - * } - * - * // The key press event handler. - * void vKeyPressEventHandler( char cKey ) - * { - * // Ensure the LCD back-light is on, then reset the timer that is - * // responsible for turning the back-light off after 5 seconds of - * // key inactivity. Wait 10 ticks for the command to be successfully sent - * // if it cannot be sent immediately. - * vSetBacklightState( BACKLIGHT_ON ); - * if( xTimerReset( xBacklightTimer, 100 ) != pdPASS ) - * { - * // The reset command was not executed successfully. Take appropriate - * // action here. - * } - * - * // Perform the rest of the key processing here. - * } - * - * void main( void ) - * { - * long x; - * - * // Create then start the one-shot timer that is responsible for turning - * // the back-light off if no keys are pressed within a 5 second period. - * xBacklightTimer = xTimerCreate( "BacklightTimer", // Just a text name, not used by the kernel. - * ( 5000 / portTICK_RATE_MS), // The timer period in ticks. - * pdFALSE, // The timer is a one-shot timer. - * 0, // The id is not used by the callback so can take any value. - * vBacklightTimerCallback // The callback function that switches the LCD back-light off. - * ); - * - * if( xBacklightTimer == NULL ) - * { - * // The timer was not created. - * } - * else - * { - * // Start the timer. No block time is specified, and even if one was - * // it would be ignored because the scheduler has not yet been - * // started. - * if( xTimerStart( xBacklightTimer, 0 ) != pdPASS ) - * { - * // The timer could not be set into the Active state. - * } - * } - * - * // ... - * // Create tasks here. - * // ... - * - * // Starting the scheduler will start the timer running as it has already - * // been set into the active state. - * xTaskStartScheduler(); - * - * // Should not reach here. - * for( ;; ); - * } - */ -#define xTimerReset( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xBlockTime ) ) - -/** - * portBASE_TYPE xTimerStartFromISR( xTimerHandle xTimer, - * portBASE_TYPE *pxHigherPriorityTaskWoken ); - * - * A version of xTimerStart() that can be called from an interrupt service - * routine. - * - * @param xTimer The handle of the timer being started/restarted. - * - * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most - * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerStartFromISR() writes a message to the timer - * command queue, so has the potential to transition the timer service/daemon - * task out of the Blocked state. If calling xTimerStartFromISR() causes the - * timer service/daemon task to leave the Blocked state, and the timer service/ - * daemon task has a priority equal to or greater than the currently executing - * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will - * get set to pdTRUE internally within the xTimerStartFromISR() function. If - * xTimerStartFromISR() sets this value to pdTRUE then a context switch should - * be performed before the interrupt exits. - * - * @return pdFAIL will be returned if the start command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system, although the timers expiry time is - * relative to when xTimerStartFromISR() is actually called. The timer service/daemon - * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * - * // This scenario assumes xBacklightTimer has already been created. When a - * // key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In - * // this case, the timer is a one-shot timer, and unlike the example given for - * // the xTimerReset() function, the key press event handler is an interrupt - * // service routine. - * - * // The callback function assigned to the one-shot timer. In this case the - * // parameter is not used. - * void vBacklightTimerCallback( xTIMER *pxTimer ) - * { - * // The timer expired, therefore 5 seconds must have passed since a key - * // was pressed. Switch off the LCD back-light. - * vSetBacklightState( BACKLIGHT_OFF ); - * } - * - * // The key press interrupt service routine. - * void vKeyPressEventInterruptHandler( void ) - * { - * portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; - * - * // Ensure the LCD back-light is on, then restart the timer that is - * // responsible for turning the back-light off after 5 seconds of - * // key inactivity. This is an interrupt service routine so can only - * // call FreeRTOS API functions that end in "FromISR". - * vSetBacklightState( BACKLIGHT_ON ); - * - * // xTimerStartFromISR() or xTimerResetFromISR() could be called here - * // as both cause the timer to re-calculate its expiry time. - * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was - * // declared (in this function). - * if( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) - * { - * // The start command was not executed successfully. Take appropriate - * // action here. - * } - * - * // Perform the rest of the key processing here. - * - * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch - * // should be performed. The syntax required to perform a context switch - * // from inside an ISR varies from port to port, and from compiler to - * // compiler. Inspect the demos for the port you are using to find the - * // actual syntax required. - * if( xHigherPriorityTaskWoken != pdFALSE ) - * { - * // Call the interrupt safe yield function here (actual function - * // depends on the FreeRTOS port being used. - * } - * } - */ -#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) - -/** - * portBASE_TYPE xTimerStopFromISR( xTimerHandle xTimer, - * portBASE_TYPE *pxHigherPriorityTaskWoken ); - * - * A version of xTimerStop() that can be called from an interrupt service - * routine. - * - * @param xTimer The handle of the timer being stopped. - * - * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most - * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerStopFromISR() writes a message to the timer - * command queue, so has the potential to transition the timer service/daemon - * task out of the Blocked state. If calling xTimerStopFromISR() causes the - * timer service/daemon task to leave the Blocked state, and the timer service/ - * daemon task has a priority equal to or greater than the currently executing - * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will - * get set to pdTRUE internally within the xTimerStopFromISR() function. If - * xTimerStopFromISR() sets this value to pdTRUE then a context switch should - * be performed before the interrupt exits. - * - * @return pdFAIL will be returned if the stop command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system. The timer service/daemon task - * priority is set by the configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * - * // This scenario assumes xTimer has already been created and started. When - * // an interrupt occurs, the timer should be simply stopped. - * - * // The interrupt service routine that stops the timer. - * void vAnExampleInterruptServiceRoutine( void ) - * { - * portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; - * - * // The interrupt has occurred - simply stop the timer. - * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined - * // (within this function). As this is an interrupt service routine, only - * // FreeRTOS API functions that end in "FromISR" can be used. - * if( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) - * { - * // The stop command was not executed successfully. Take appropriate - * // action here. - * } - * - * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch - * // should be performed. The syntax required to perform a context switch - * // from inside an ISR varies from port to port, and from compiler to - * // compiler. Inspect the demos for the port you are using to find the - * // actual syntax required. - * if( xHigherPriorityTaskWoken != pdFALSE ) - * { - * // Call the interrupt safe yield function here (actual function - * // depends on the FreeRTOS port being used. - * } - * } - */ -#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0, ( pxHigherPriorityTaskWoken ), 0U ) - -/** - * portBASE_TYPE xTimerChangePeriodFromISR( xTimerHandle xTimer, - * portTickType xNewPeriod, - * portBASE_TYPE *pxHigherPriorityTaskWoken ); - * - * A version of xTimerChangePeriod() that can be called from an interrupt - * service routine. - * - * @param xTimer The handle of the timer that is having its period changed. - * - * @param xNewPeriod The new period for xTimer. Timer periods are specified in - * tick periods, so the constant portTICK_RATE_MS can be used to convert a time - * that has been specified in milliseconds. For example, if the timer must - * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, - * if the timer must expire after 500ms, then xNewPeriod can be set to - * ( 500 / portTICK_RATE_MS ) provided configTICK_RATE_HZ is less than - * or equal to 1000. - * - * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most - * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerChangePeriodFromISR() writes a message to the - * timer command queue, so has the potential to transition the timer service/ - * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR() - * causes the timer service/daemon task to leave the Blocked state, and the - * timer service/daemon task has a priority equal to or greater than the - * currently executing task (the task that was interrupted), then - * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the - * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets - * this value to pdTRUE then a context switch should be performed before the - * interrupt exits. - * - * @return pdFAIL will be returned if the command to change the timers period - * could not be sent to the timer command queue. pdPASS will be returned if the - * command was successfully sent to the timer command queue. When the command - * is actually processed will depend on the priority of the timer service/daemon - * task relative to other tasks in the system. The timer service/daemon task - * priority is set by the configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * - * // This scenario assumes xTimer has already been created and started. When - * // an interrupt occurs, the period of xTimer should be changed to 500ms. - * - * // The interrupt service routine that changes the period of xTimer. - * void vAnExampleInterruptServiceRoutine( void ) - * { - * portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; - * - * // The interrupt has occurred - change the period of xTimer to 500ms. - * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined - * // (within this function). As this is an interrupt service routine, only - * // FreeRTOS API functions that end in "FromISR" can be used. - * if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) - * { - * // The command to change the timers period was not executed - * // successfully. Take appropriate action here. - * } - * - * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch - * // should be performed. The syntax required to perform a context switch - * // from inside an ISR varies from port to port, and from compiler to - * // compiler. Inspect the demos for the port you are using to find the - * // actual syntax required. - * if( xHigherPriorityTaskWoken != pdFALSE ) - * { - * // Call the interrupt safe yield function here (actual function - * // depends on the FreeRTOS port being used. - * } - * } - */ -#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U ) - -/** - * portBASE_TYPE xTimerResetFromISR( xTimerHandle xTimer, - * portBASE_TYPE *pxHigherPriorityTaskWoken ); - * - * A version of xTimerReset() that can be called from an interrupt service - * routine. - * - * @param xTimer The handle of the timer that is to be started, reset, or - * restarted. - * - * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most - * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerResetFromISR() writes a message to the timer - * command queue, so has the potential to transition the timer service/daemon - * task out of the Blocked state. If calling xTimerResetFromISR() causes the - * timer service/daemon task to leave the Blocked state, and the timer service/ - * daemon task has a priority equal to or greater than the currently executing - * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will - * get set to pdTRUE internally within the xTimerResetFromISR() function. If - * xTimerResetFromISR() sets this value to pdTRUE then a context switch should - * be performed before the interrupt exits. - * - * @return pdFAIL will be returned if the reset command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system, although the timers expiry time is - * relative to when xTimerResetFromISR() is actually called. The timer service/daemon - * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * - * // This scenario assumes xBacklightTimer has already been created. When a - * // key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In - * // this case, the timer is a one-shot timer, and unlike the example given for - * // the xTimerReset() function, the key press event handler is an interrupt - * // service routine. - * - * // The callback function assigned to the one-shot timer. In this case the - * // parameter is not used. - * void vBacklightTimerCallback( xTIMER *pxTimer ) - * { - * // The timer expired, therefore 5 seconds must have passed since a key - * // was pressed. Switch off the LCD back-light. - * vSetBacklightState( BACKLIGHT_OFF ); - * } - * - * // The key press interrupt service routine. - * void vKeyPressEventInterruptHandler( void ) - * { - * portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; - * - * // Ensure the LCD back-light is on, then reset the timer that is - * // responsible for turning the back-light off after 5 seconds of - * // key inactivity. This is an interrupt service routine so can only - * // call FreeRTOS API functions that end in "FromISR". - * vSetBacklightState( BACKLIGHT_ON ); - * - * // xTimerStartFromISR() or xTimerResetFromISR() could be called here - * // as both cause the timer to re-calculate its expiry time. - * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was - * // declared (in this function). - * if( xTimerResetFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) - * { - * // The reset command was not executed successfully. Take appropriate - * // action here. - * } - * - * // Perform the rest of the key processing here. - * - * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch - * // should be performed. The syntax required to perform a context switch - * // from inside an ISR varies from port to port, and from compiler to - * // compiler. Inspect the demos for the port you are using to find the - * // actual syntax required. - * if( xHigherPriorityTaskWoken != pdFALSE ) - * { - * // Call the interrupt safe yield function here (actual function - * // depends on the FreeRTOS port being used. - * } - * } - */ -#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) - -/* - * Functions beyond this part are not part of the public API and are intended - * for use by the kernel only. - */ -portBASE_TYPE xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION; -portBASE_TYPE xTimerGenericCommand( xTimerHandle xTimer, portBASE_TYPE xCommandID, portTickType xOptionalValue, portBASE_TYPE *pxHigherPriorityTaskWoken, portTickType xBlockTime ) PRIVILEGED_FUNCTION; - -#ifdef __cplusplus -} -#endif -#endif /* TIMERS_H */ - - - diff --git a/GD32F1/libraries/FreeRTOS821/MapleFreeRTOS821.cpp b/GD32F1/libraries/FreeRTOS821/MapleFreeRTOS821.cpp deleted file mode 100644 index a25ce7f..0000000 --- a/GD32F1/libraries/FreeRTOS821/MapleFreeRTOS821.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#include "MapleFreeRTOS821.h" - -extern "C" { - -void vApplicationStackOverflowHook(xTaskHandle *pxTask, - signed char *pcTaskName) { - /* This function will get called if a task overflows its stack. - * If the parameters are corrupt then inspect pxCurrentTCB to find - * which was the offending task. */ - - (void) pxTask; - (void) pcTaskName; - - while (1) - ; -} - -} diff --git a/GD32F1/libraries/FreeRTOS821/MapleFreeRTOS821.h b/GD32F1/libraries/FreeRTOS821/MapleFreeRTOS821.h deleted file mode 100644 index 4cbbb96..0000000 --- a/GD32F1/libraries/FreeRTOS821/MapleFreeRTOS821.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#ifndef __MAPLE_FREERTOS_H__ -#define __MAPLE_FREERTOS_H__ - -#include - -extern "C" { -#define GCC_ARMCM3 -#include "utility/FreeRTOS.h" -#include "utility/task.h" -#include "utility/queue.h" -#include "utility/semphr.h" -} - -#endif diff --git a/GD32F1/libraries/FreeRTOS821/examples/rtos_blink/rtos_blink.ino b/GD32F1/libraries/FreeRTOS821/examples/rtos_blink/rtos_blink.ino deleted file mode 100644 index a972b6c..0000000 --- a/GD32F1/libraries/FreeRTOS821/examples/rtos_blink/rtos_blink.ino +++ /dev/null @@ -1,31 +0,0 @@ -//#include -//#include "libraries/FreeRTOS/MapleFreeRTOS.h" -#include - -static void vLEDFlashTask(void *pvParameters) { - for (;;) { - vTaskDelay(1000); - digitalWrite(BOARD_LED_PIN, HIGH); - vTaskDelay(50); - digitalWrite(BOARD_LED_PIN, LOW); - } -} - -void setup() { - // initialize the digital pin as an output: - pinMode(BOARD_LED_PIN, OUTPUT); - - xTaskCreate(vLEDFlashTask, - "Task1", - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY + 2, - NULL); - vTaskStartScheduler(); -} - -void loop() { - // Insert background code here -} - - diff --git a/GD32F1/libraries/FreeRTOS821/examples/rtos_display_blink/rtos_display_blink.ino b/GD32F1/libraries/FreeRTOS821/examples/rtos_display_blink/rtos_display_blink.ino deleted file mode 100644 index bd6c3e4..0000000 --- a/GD32F1/libraries/FreeRTOS821/examples/rtos_display_blink/rtos_display_blink.ino +++ /dev/null @@ -1,212 +0,0 @@ -#define USE_SEMAPHORE_DMA1 -#include -#include -#include -#include - -#define __CS 8 -#define __RST 9 -#define __DC 10 - -TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST); - -xSemaphoreHandle xDisplayFree; - - -const float sin_d[] = { - 0, 0.17, 0.34, 0.5, 0.64, 0.77, 0.87, 0.94, 0.98, 1, 0.98, 0.94, - 0.87, 0.77, 0.64, 0.5, 0.34, 0.17, 0, -0.17, -0.34, -0.5, -0.64, - -0.77, -0.87, -0.94, -0.98, -1, -0.98, -0.94, -0.87, -0.77, - -0.64, -0.5, -0.34, -0.17 -}; -const float cos_d[] = { - 1, 0.98, 0.94, 0.87, 0.77, 0.64, 0.5, 0.34, 0.17, 0, -0.17, -0.34, - -0.5, -0.64, -0.77, -0.87, -0.94, -0.98, -1, -0.98, -0.94, -0.87, - -0.77, -0.64, -0.5, -0.34, -0.17, 0, 0.17, 0.34, 0.5, 0.64, 0.77, - 0.87, 0.94, 0.98 -}; -const float d = 5; -float cube1_px[] = { - -d, d, d, -d, -d, d, d, -d -}; -float cube1_py[] = { - -d, -d, d, d, -d, -d, d, d -}; -float cube1_pz[] = { - -d, -d, -d, -d, d, d, d, d -}; - -float cube1_p2x[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; -float cube1_p2y[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int cube1_r[] = { - 0, 0, 0 -}; -const float d2 = 10; -float cube2_px[] = { - -d2, d2, d2, -d2, -d2, d2, d2, -d2 -}; -float cube2_py[] = { - -d2, -d2, d2, d2, -d2, -d2, d2, d2 -}; -float cube2_pz[] = { - -d2, -d2, -d2, -d2, d2, d2, d2, d2 -}; - -float cube2_p2x[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; -float cube2_p2y[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int cube2_r[] = { - 0, 0, 0 -}; - -uint16 cube1_x, cube1_y, cube2_x, cube2_y, cube1_color, cube2_color; - -static void vLEDFlashTask(void *pvParameters) { - for (;;) { - vTaskDelay(1000); - digitalWrite(BOARD_LED_PIN, HIGH); - vTaskDelay(50); - digitalWrite(BOARD_LED_PIN, LOW); - } -} - -static void vCube1LoopTask(void *pvParameters) { - while (1) { - if ( xSemaphoreTake( xDisplayFree, ( portTickType ) 10 ) == pdTRUE ) - { - cube(cube1_px, cube1_py, cube1_pz, cube1_p2x, cube1_p2y, cube1_r, &cube1_x, &cube1_y, &cube1_color); - xSemaphoreGive( xDisplayFree ); - vTaskDelay(15); - } - } -} - -static void vCube2LoopTask(void *pvParameters) { - while (1) { - if ( xSemaphoreTake( xDisplayFree, ( portTickType ) 10 ) == pdTRUE ) - { - cube(cube2_px, cube2_py, cube2_pz, cube2_p2x, cube2_p2y, cube2_r, &cube2_x, &cube2_y, &cube2_color); - xSemaphoreGive( xDisplayFree ); - vTaskDelay(40); - } - } -} - - -void cube(float *px, float *py, float *pz, float *p2x, float *p2y, int *r, uint16 *x, uint16 *y, uint16 *color) { - - for (int i = 0; i < 3; i++) { - tft.drawLine(p2x[i], p2y[i], p2x[i + 1], p2y[i + 1], WHITE); - tft.drawLine(p2x[i + 4], p2y[i + 4], p2x[i + 5], p2y[i + 5], WHITE); - tft.drawLine(p2x[i], p2y[i], p2x[i + 4], p2y[i + 4], WHITE); - } - tft.drawLine(p2x[3], p2y[3], p2x[0], p2y[0], WHITE); - tft.drawLine(p2x[7], p2y[7], p2x[4], p2y[4], WHITE); - tft.drawLine(p2x[3], p2y[3], p2x[7], p2y[7], WHITE); - - r[0] = r[0] + 1; - r[1] = r[1] + 1; - if (r[0] == 36) r[0] = 0; - if (r[1] == 36) r[1] = 0; - if (r[2] == 36) r[2] = 0; - for (int i = 0; i < 8; i++) - { - float px2 = px[i]; - float py2 = cos_d[r[0]] * py[i] - sin_d[r[0]] * pz[i]; - float pz2 = sin_d[r[0]] * py[i] + cos_d[r[0]] * pz[i]; - - float px3 = cos_d[r[1]] * px2 + sin_d[r[1]] * pz2; - float py3 = py2; - float pz3 = -sin_d[r[1]] * px2 + cos_d[r[1]] * pz2; - - float ax = cos_d[r[2]] * px3 - sin_d[r[2]] * py3; - float ay = sin_d[r[2]] * px3 + cos_d[r[2]] * py3; - float az = pz3 - 190; - - p2x[i] = *x + ax * 500 / az; - p2y[i] = *y + ay * 500 / az; - } - - for (int i = 0; i < 3; i++) { - tft.drawLine(p2x[i], p2y[i], p2x[i + 1], p2y[i + 1], *color); - tft.drawLine(p2x[i + 4], p2y[i + 4], p2x[i + 5], p2y[i + 5], *color); - tft.drawLine(p2x[i], p2y[i], p2x[i + 4], p2y[i + 4], *color); - } - tft.drawLine(p2x[3], p2y[3], p2x[0], p2y[0], *color); - tft.drawLine(p2x[7], p2y[7], p2x[4], p2y[4], *color); - tft.drawLine(p2x[3], p2y[3], p2x[7], p2y[7], *color); -} - -static void vSqrtTask(void *pvParameters) { - while (1){ - Serial.println ("Starting Sqrt calculations..."); - uint16 x = 0; - uint16 ixx[1001]; - // Library Sqrt - uint32_t t0 = millis(); - for (uint32_t n = 247583650 ; n > 247400000 ; n--) { - x = sqrt (n); - } - uint32_t t1 = millis() - t0; - Serial.print ("Sqrt calculations took (ms): "); - Serial.println (t1); - delay (5000); - } -} - -void setup() { - // initialize the digital pin as an output: - Serial.begin(9600); - delay (5000); - Serial.println ("Running..."); - pinMode(BOARD_LED_PIN, OUTPUT); - tft.begin(); - tft.fillScreen(WHITE); - cube1_x = ((tft.width()) / 4); - cube1_y = ((tft.height()) / 4); - cube2_x = ((tft.width()) / 2); - cube2_y = ((tft.height()) / 2); - cube1_color = BLACK; - cube2_color = RED; - vSemaphoreCreateBinary(xDisplayFree); - xTaskCreate(vLEDFlashTask, - "Task1", - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY + 2, - NULL); - xTaskCreate(vCube1LoopTask, - "Cube1", - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY + 2, - NULL); - xTaskCreate(vCube2LoopTask, - "Cube2", - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY+1, - NULL); - xTaskCreate(vSqrtTask, - "Sqrt", - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY, - NULL); - vTaskStartScheduler(); -} - -void loop() { - // Do not write any code here, it would not execute. -} - - diff --git a/GD32F1/libraries/FreeRTOS821/keywords.txt b/GD32F1/libraries/FreeRTOS821/keywords.txt deleted file mode 100644 index 4a20bae..0000000 --- a/GD32F1/libraries/FreeRTOS821/keywords.txt +++ /dev/null @@ -1,27 +0,0 @@ -####################################### -# Syntax Coloring Map For CoOS -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -vTaskDelay KEYWORD2 -vTaskDelayUntil KEYWORD2 -xTaskCreate KEYWORD2 -vTaskSuspend KEYWORD2 -vTaskDelete KEYWORD2 -vTaskPrioritySet KEYWORD2 -uxTaskPriorityGet KEYWORD2 -vTaskStartScheduler KEYWORD2 -vApplicationIdleHook KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### -configUSE_IDLE_HOOK LITERAL1 -configMINIMAL_STACK_SIZE LITERAL1 -tskIDLE_PRIORITY LITERAL1 \ No newline at end of file diff --git a/GD32F1/libraries/FreeRTOS821/rules.mk b/GD32F1/libraries/FreeRTOS821/rules.mk deleted file mode 100644 index 2b415ba..0000000 --- a/GD32F1/libraries/FreeRTOS821/rules.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) -BUILDDIRS += $(BUILD_PATH)/$(d)/utility - -# Local flags -CXXFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) -CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) - -# Local rules and targets -cSRCS_$(d) := utility/croutine.c \ - utility/heap_2.c \ - utility/list.c \ - utility/port.c \ - utility/queue.c \ - utility/timers.c \ - utility/tasks.c \ - -cppSRCS_$(d) := MapleFreeRTOS.cpp - -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ - $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CXXFLAGS := $(CXXFLAGS_$(d)) -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) \ No newline at end of file diff --git a/GD32F1/libraries/FreeRTOS821/utility/FreeRTOS.h b/GD32F1/libraries/FreeRTOS821/utility/FreeRTOS.h deleted file mode 100644 index 32c9138..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/FreeRTOS.h +++ /dev/null @@ -1,799 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef INC_FREERTOS_H -#define INC_FREERTOS_H - -/* - * Include the generic headers required for the FreeRTOS port being used. - */ -#include - -/* - * If stdint.h cannot be located then: - * + If using GCC ensure the -nostdint options is *not* being used. - * + Ensure the project's include path includes the directory in which your - * compiler stores stdint.h. - * + Set any compiler options necessary for it to support C99, as technically - * stdint.h is only mandatory with C99 (FreeRTOS does not require C99 in any - * other way). - * + The FreeRTOS download includes a simple stdint.h definition that can be - * used in cases where none is provided by the compiler. The files only - * contains the typedefs required to build FreeRTOS. Read the instructions - * in FreeRTOS/source/stdint.readme for more information. - */ -#include /* READ COMMENT ABOVE. */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Application specific configuration options. */ -#include "FreeRTOSConfig.h" - -/* Basic FreeRTOS definitions. */ -#include "projdefs.h" - -/* Definitions specific to the port being used. */ -#include "portable.h" - -/* - * Check all the required application specific macros have been defined. - * These macros are application specific and (as downloaded) are defined - * within FreeRTOSConfig.h. - */ - -#ifndef configMINIMAL_STACK_SIZE - #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. -#endif - -#ifndef configMAX_PRIORITIES - #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_PREEMPTION - #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_IDLE_HOOK - #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_TICK_HOOK - #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskPrioritySet - #error Missing definition: INCLUDE_vTaskPrioritySet must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_uxTaskPriorityGet - #error Missing definition: INCLUDE_uxTaskPriorityGet must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskDelete - #error Missing definition: INCLUDE_vTaskDelete must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskSuspend - #error Missing definition: INCLUDE_vTaskSuspend must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskDelayUntil - #error Missing definition: INCLUDE_vTaskDelayUntil must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef INCLUDE_vTaskDelay - #error Missing definition: INCLUDE_vTaskDelay must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configUSE_16_BIT_TICKS - #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. -#endif - -#ifndef configMAX_PRIORITIES - #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. -#endif - -#ifndef configUSE_CO_ROUTINES - #define configUSE_CO_ROUTINES 0 -#endif - -#if configUSE_CO_ROUTINES != 0 - #ifndef configMAX_CO_ROUTINE_PRIORITIES - #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. - #endif -#endif - -#ifndef INCLUDE_xTaskGetIdleTaskHandle - #define INCLUDE_xTaskGetIdleTaskHandle 0 -#endif - -#ifndef INCLUDE_xTimerGetTimerDaemonTaskHandle - #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0 -#endif - -#ifndef INCLUDE_xQueueGetMutexHolder - #define INCLUDE_xQueueGetMutexHolder 0 -#endif - -#ifndef INCLUDE_xSemaphoreGetMutexHolder - #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder -#endif - -#ifndef INCLUDE_pcTaskGetTaskName - #define INCLUDE_pcTaskGetTaskName 0 -#endif - -#ifndef configUSE_APPLICATION_TASK_TAG - #define configUSE_APPLICATION_TASK_TAG 0 -#endif - -#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS - #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 -#endif - -#ifndef INCLUDE_uxTaskGetStackHighWaterMark - #define INCLUDE_uxTaskGetStackHighWaterMark 0 -#endif - -#ifndef INCLUDE_eTaskGetState - #define INCLUDE_eTaskGetState 0 -#endif - -#ifndef configUSE_RECURSIVE_MUTEXES - #define configUSE_RECURSIVE_MUTEXES 0 -#endif - -#ifndef configUSE_MUTEXES - #define configUSE_MUTEXES 0 -#endif - -#ifndef configUSE_TIMERS - #define configUSE_TIMERS 0 -#endif - -#ifndef configUSE_COUNTING_SEMAPHORES - #define configUSE_COUNTING_SEMAPHORES 0 -#endif - -#ifndef configUSE_ALTERNATIVE_API - #define configUSE_ALTERNATIVE_API 0 -#endif - -#ifndef portCRITICAL_NESTING_IN_TCB - #define portCRITICAL_NESTING_IN_TCB 0 -#endif - -#ifndef configMAX_TASK_NAME_LEN - #define configMAX_TASK_NAME_LEN 16 -#endif - -#ifndef configIDLE_SHOULD_YIELD - #define configIDLE_SHOULD_YIELD 1 -#endif - -#if configMAX_TASK_NAME_LEN < 1 - #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h -#endif - -#ifndef INCLUDE_xTaskResumeFromISR - #define INCLUDE_xTaskResumeFromISR 1 -#endif - -#ifndef INCLUDE_xEventGroupSetBitFromISR - #define INCLUDE_xEventGroupSetBitFromISR 0 -#endif - -#ifndef INCLUDE_xTimerPendFunctionCall - #define INCLUDE_xTimerPendFunctionCall 0 -#endif - -#ifndef configASSERT - #define configASSERT( x ) - #define configASSERT_DEFINED 0 -#else - #define configASSERT_DEFINED 1 -#endif - -/* The timers module relies on xTaskGetSchedulerState(). */ -#if configUSE_TIMERS == 1 - - #ifndef configTIMER_TASK_PRIORITY - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. - #endif /* configTIMER_TASK_PRIORITY */ - - #ifndef configTIMER_QUEUE_LENGTH - #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. - #endif /* configTIMER_QUEUE_LENGTH */ - - #ifndef configTIMER_TASK_STACK_DEPTH - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. - #endif /* configTIMER_TASK_STACK_DEPTH */ - -#endif /* configUSE_TIMERS */ - -#ifndef INCLUDE_xTaskGetSchedulerState - #define INCLUDE_xTaskGetSchedulerState 0 -#endif - -#ifndef INCLUDE_xTaskGetCurrentTaskHandle - #define INCLUDE_xTaskGetCurrentTaskHandle 0 -#endif - - -#ifndef portSET_INTERRUPT_MASK_FROM_ISR - #define portSET_INTERRUPT_MASK_FROM_ISR() 0 -#endif - -#ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR - #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue -#endif - -#ifndef portCLEAN_UP_TCB - #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB -#endif - -#ifndef portPRE_TASK_DELETE_HOOK - #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) -#endif - -#ifndef portSETUP_TCB - #define portSETUP_TCB( pxTCB ) ( void ) pxTCB -#endif - -#ifndef configQUEUE_REGISTRY_SIZE - #define configQUEUE_REGISTRY_SIZE 0U -#endif - -#if ( configQUEUE_REGISTRY_SIZE < 1 ) - #define vQueueAddToRegistry( xQueue, pcName ) - #define vQueueUnregisterQueue( xQueue ) -#endif - -#ifndef portPOINTER_SIZE_TYPE - #define portPOINTER_SIZE_TYPE uint32_t -#endif - -/* Remove any unused trace macros. */ -#ifndef traceSTART - /* Used to perform any necessary initialisation - for example, open a file - into which trace is to be written. */ - #define traceSTART() -#endif - -#ifndef traceEND - /* Use to close a trace, for example close a file into which trace has been - written. */ - #define traceEND() -#endif - -#ifndef traceTASK_SWITCHED_IN - /* Called after a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the selected task. */ - #define traceTASK_SWITCHED_IN() -#endif - -#ifndef traceINCREASE_TICK_COUNT - /* Called before stepping the tick count after waking from tickless idle - sleep. */ - #define traceINCREASE_TICK_COUNT( x ) -#endif - -#ifndef traceLOW_POWER_IDLE_BEGIN - /* Called immediately before entering tickless idle. */ - #define traceLOW_POWER_IDLE_BEGIN() -#endif - -#ifndef traceLOW_POWER_IDLE_END - /* Called when returning to the Idle task after a tickless idle. */ - #define traceLOW_POWER_IDLE_END() -#endif - -#ifndef traceTASK_SWITCHED_OUT - /* Called before a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the task being switched out. */ - #define traceTASK_SWITCHED_OUT() -#endif - -#ifndef traceTASK_PRIORITY_INHERIT - /* Called when a task attempts to take a mutex that is already held by a - lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task - that holds the mutex. uxInheritedPriority is the priority the mutex holder - will inherit (the priority of the task that is attempting to obtain the - muted. */ - #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) -#endif - -#ifndef traceTASK_PRIORITY_DISINHERIT - /* Called when a task releases a mutex, the holding of which had resulted in - the task inheriting the priority of a higher priority task. - pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the - mutex. uxOriginalPriority is the task's configured (base) priority. */ - #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) -#endif - -#ifndef traceBLOCKING_ON_QUEUE_RECEIVE - /* Task is about to block because it cannot read from a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the - task that attempted the read. */ - #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) -#endif - -#ifndef traceBLOCKING_ON_QUEUE_SEND - /* Task is about to block because it cannot write to a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the write was attempted. pxCurrentTCB points to the TCB of the - task that attempted the write. */ - #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) -#endif - -#ifndef configCHECK_FOR_STACK_OVERFLOW - #define configCHECK_FOR_STACK_OVERFLOW 0 -#endif - -/* The following event macros are embedded in the kernel API calls. */ - -#ifndef traceMOVED_TASK_TO_READY_STATE - #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) -#endif - -#ifndef traceQUEUE_CREATE - #define traceQUEUE_CREATE( pxNewQueue ) -#endif - -#ifndef traceQUEUE_CREATE_FAILED - #define traceQUEUE_CREATE_FAILED( ucQueueType ) -#endif - -#ifndef traceCREATE_MUTEX - #define traceCREATE_MUTEX( pxNewQueue ) -#endif - -#ifndef traceCREATE_MUTEX_FAILED - #define traceCREATE_MUTEX_FAILED() -#endif - -#ifndef traceGIVE_MUTEX_RECURSIVE - #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) -#endif - -#ifndef traceGIVE_MUTEX_RECURSIVE_FAILED - #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) -#endif - -#ifndef traceTAKE_MUTEX_RECURSIVE - #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) -#endif - -#ifndef traceTAKE_MUTEX_RECURSIVE_FAILED - #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) -#endif - -#ifndef traceCREATE_COUNTING_SEMAPHORE - #define traceCREATE_COUNTING_SEMAPHORE() -#endif - -#ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED - #define traceCREATE_COUNTING_SEMAPHORE_FAILED() -#endif - -#ifndef traceQUEUE_SEND - #define traceQUEUE_SEND( pxQueue ) -#endif - -#ifndef traceQUEUE_SEND_FAILED - #define traceQUEUE_SEND_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_RECEIVE - #define traceQUEUE_RECEIVE( pxQueue ) -#endif - -#ifndef traceQUEUE_PEEK - #define traceQUEUE_PEEK( pxQueue ) -#endif - -#ifndef traceQUEUE_PEEK_FROM_ISR - #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) -#endif - -#ifndef traceQUEUE_RECEIVE_FAILED - #define traceQUEUE_RECEIVE_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_SEND_FROM_ISR - #define traceQUEUE_SEND_FROM_ISR( pxQueue ) -#endif - -#ifndef traceQUEUE_SEND_FROM_ISR_FAILED - #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_RECEIVE_FROM_ISR - #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) -#endif - -#ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED - #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_PEEK_FROM_ISR_FAILED - #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) -#endif - -#ifndef traceQUEUE_DELETE - #define traceQUEUE_DELETE( pxQueue ) -#endif - -#ifndef traceTASK_CREATE - #define traceTASK_CREATE( pxNewTCB ) -#endif - -#ifndef traceTASK_CREATE_FAILED - #define traceTASK_CREATE_FAILED() -#endif - -#ifndef traceTASK_DELETE - #define traceTASK_DELETE( pxTaskToDelete ) -#endif - -#ifndef traceTASK_DELAY_UNTIL - #define traceTASK_DELAY_UNTIL() -#endif - -#ifndef traceTASK_DELAY - #define traceTASK_DELAY() -#endif - -#ifndef traceTASK_PRIORITY_SET - #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) -#endif - -#ifndef traceTASK_SUSPEND - #define traceTASK_SUSPEND( pxTaskToSuspend ) -#endif - -#ifndef traceTASK_RESUME - #define traceTASK_RESUME( pxTaskToResume ) -#endif - -#ifndef traceTASK_RESUME_FROM_ISR - #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) -#endif - -#ifndef traceTASK_INCREMENT_TICK - #define traceTASK_INCREMENT_TICK( xTickCount ) -#endif - -#ifndef traceTIMER_CREATE - #define traceTIMER_CREATE( pxNewTimer ) -#endif - -#ifndef traceTIMER_CREATE_FAILED - #define traceTIMER_CREATE_FAILED() -#endif - -#ifndef traceTIMER_COMMAND_SEND - #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) -#endif - -#ifndef traceTIMER_EXPIRED - #define traceTIMER_EXPIRED( pxTimer ) -#endif - -#ifndef traceTIMER_COMMAND_RECEIVED - #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) -#endif - -#ifndef traceMALLOC - #define traceMALLOC( pvAddress, uiSize ) -#endif - -#ifndef traceFREE - #define traceFREE( pvAddress, uiSize ) -#endif - -#ifndef traceEVENT_GROUP_CREATE - #define traceEVENT_GROUP_CREATE( xEventGroup ) -#endif - -#ifndef traceEVENT_GROUP_CREATE_FAILED - #define traceEVENT_GROUP_CREATE_FAILED() -#endif - -#ifndef traceEVENT_GROUP_SYNC_BLOCK - #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ) -#endif - -#ifndef traceEVENT_GROUP_SYNC_END - #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred -#endif - -#ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK - #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ) -#endif - -#ifndef traceEVENT_GROUP_WAIT_BITS_END - #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred -#endif - -#ifndef traceEVENT_GROUP_CLEAR_BITS - #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ) -#endif - -#ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR - #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ) -#endif - -#ifndef traceEVENT_GROUP_SET_BITS - #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ) -#endif - -#ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR - #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ) -#endif - -#ifndef traceEVENT_GROUP_DELETE - #define traceEVENT_GROUP_DELETE( xEventGroup ) -#endif - -#ifndef tracePEND_FUNC_CALL - #define tracePEND_FUNC_CALL(xFunctionToPend, pvParameter1, ulParameter2, ret) -#endif - -#ifndef tracePEND_FUNC_CALL_FROM_ISR - #define tracePEND_FUNC_CALL_FROM_ISR(xFunctionToPend, pvParameter1, ulParameter2, ret) -#endif - -#ifndef traceQUEUE_REGISTRY_ADD - #define traceQUEUE_REGISTRY_ADD(xQueue, pcQueueName) -#endif - -#ifndef configGENERATE_RUN_TIME_STATS - #define configGENERATE_RUN_TIME_STATS 0 -#endif - -#if ( configGENERATE_RUN_TIME_STATS == 1 ) - - #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. - #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ - - #ifndef portGET_RUN_TIME_COUNTER_VALUE - #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE - #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. - #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ - #endif /* portGET_RUN_TIME_COUNTER_VALUE */ - -#endif /* configGENERATE_RUN_TIME_STATS */ - -#ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() -#endif - -#ifndef configUSE_MALLOC_FAILED_HOOK - #define configUSE_MALLOC_FAILED_HOOK 0 -#endif - -#ifndef portPRIVILEGE_BIT - #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) -#endif - -#ifndef portYIELD_WITHIN_API - #define portYIELD_WITHIN_API portYIELD -#endif - -#ifndef pvPortMallocAligned - #define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMalloc( ( x ) ) ) : ( puxStackBuffer ) ) -#endif - -#ifndef vPortFreeAligned - #define vPortFreeAligned( pvBlockToFree ) vPortFree( pvBlockToFree ) -#endif - -#ifndef portSUPPRESS_TICKS_AND_SLEEP - #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) -#endif - -#ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP - #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 -#endif - -#if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2 - #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 -#endif - -#ifndef configUSE_TICKLESS_IDLE - #define configUSE_TICKLESS_IDLE 0 -#endif - -#ifndef configPRE_SLEEP_PROCESSING - #define configPRE_SLEEP_PROCESSING( x ) -#endif - -#ifndef configPOST_SLEEP_PROCESSING - #define configPOST_SLEEP_PROCESSING( x ) -#endif - -#ifndef configUSE_QUEUE_SETS - #define configUSE_QUEUE_SETS 0 -#endif - -#ifndef portTASK_USES_FLOATING_POINT - #define portTASK_USES_FLOATING_POINT() -#endif - -#ifndef configUSE_TIME_SLICING - #define configUSE_TIME_SLICING 1 -#endif - -#ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS - #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 -#endif - -#ifndef configUSE_NEWLIB_REENTRANT - #define configUSE_NEWLIB_REENTRANT 0 -#endif - -#ifndef configUSE_STATS_FORMATTING_FUNCTIONS - #define configUSE_STATS_FORMATTING_FUNCTIONS 0 -#endif - -#ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID - #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() -#endif - -#ifndef configUSE_TRACE_FACILITY - #define configUSE_TRACE_FACILITY 0 -#endif - -#ifndef mtCOVERAGE_TEST_MARKER - #define mtCOVERAGE_TEST_MARKER() -#endif - -#ifndef mtCOVERAGE_TEST_DELAY - #define mtCOVERAGE_TEST_DELAY() -#endif - -#ifndef portASSERT_IF_IN_ISR - #define portASSERT_IF_IN_ISR() -#endif - -#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION - #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 -#endif - -#ifndef configAPPLICATION_ALLOCATED_HEAP - #define configAPPLICATION_ALLOCATED_HEAP 0 -#endif - -#ifndef configUSE_TASK_NOTIFICATIONS - #define configUSE_TASK_NOTIFICATIONS 1 -#endif - -#ifndef portTICK_TYPE_IS_ATOMIC - #define portTICK_TYPE_IS_ATOMIC 0 -#endif - -#if( portTICK_TYPE_IS_ATOMIC == 0 ) - /* Either variables of tick type cannot be read atomically, or - portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when - the tick count is returned to the standard critical section macros. */ - #define portTICK_TYPE_ENTER_CRITICAL() portENTER_CRITICAL() - #define portTICK_TYPE_EXIT_CRITICAL() portEXIT_CRITICAL() - #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() - #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) -#else - /* The tick type can be read atomically, so critical sections used when the - tick count is returned can be defined away. */ - #define portTICK_TYPE_ENTER_CRITICAL() - #define portTICK_TYPE_EXIT_CRITICAL() - #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 - #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x -#endif - -/* Definitions to allow backward compatibility with FreeRTOS versions prior to -V8 if desired. */ -#ifndef configENABLE_BACKWARD_COMPATIBILITY - #define configENABLE_BACKWARD_COMPATIBILITY 1 -#endif - -#if configENABLE_BACKWARD_COMPATIBILITY == 1 - #define eTaskStateGet eTaskGetState - #define portTickType TickType_t - #define xTaskHandle TaskHandle_t - #define xQueueHandle QueueHandle_t - #define xSemaphoreHandle SemaphoreHandle_t - #define xQueueSetHandle QueueSetHandle_t - #define xQueueSetMemberHandle QueueSetMemberHandle_t - #define xTimeOutType TimeOut_t - #define xMemoryRegion MemoryRegion_t - #define xTaskParameters TaskParameters_t - #define xTaskStatusType TaskStatus_t - #define xTimerHandle TimerHandle_t - #define xCoRoutineHandle CoRoutineHandle_t - #define pdTASK_HOOK_CODE TaskHookFunction_t - #define portTICK_RATE_MS portTICK_PERIOD_MS - - /* Backward compatibility within the scheduler code only - these definitions - are not really required but are included for completeness. */ - #define tmrTIMER_CALLBACK TimerCallbackFunction_t - #define pdTASK_CODE TaskFunction_t - #define xListItem ListItem_t - #define xList List_t -#endif /* configENABLE_BACKWARD_COMPATIBILITY */ - -#ifdef __cplusplus -} -#endif - -#endif /* INC_FREERTOS_H */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/FreeRTOSConfig.h b/GD32F1/libraries/FreeRTOS821/utility/FreeRTOSConfig.h deleted file mode 100644 index 2f8b84a..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/FreeRTOSConfig.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html. - *----------------------------------------------------------*/ - -#define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 -#define configCPU_CLOCK_HZ ( ( unsigned long ) F_CPU ) -#define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) -#define configMAX_PRIORITIES ( 5 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 120 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 8 * 1024 ) ) -#define configMAX_TASK_NAME_LEN ( 16 ) -#define configUSE_TRACE_FACILITY 1 -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 1 - -/* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) - -#define configUSE_MUTEXES 1 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_ALTERNATIVE_API 0 -#define configCHECK_FOR_STACK_OVERFLOW 2 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 0 -#define configGENERATE_RUN_TIME_STATS 0 - -/* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ - -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 0 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 - -/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 -(lowest) to 0 (1?) (highest). */ -#define configKERNEL_INTERRUPT_PRIORITY 255 -/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! -See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ -#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ - - -/* This is the value being used as per the ST library which permits 16 -priority values, 0 to 15. This must correspond to the -configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest -NVIC value of 255. */ -#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 - -/*----------------------------------------------------------- - * UART configuration. - *-----------------------------------------------------------*/ -#define configCOM0_RX_BUFFER_LENGTH 128 -#define configCOM0_TX_BUFFER_LENGTH 128 -#define configCOM1_RX_BUFFER_LENGTH 128 -#define configCOM1_TX_BUFFER_LENGTH 128 - -#endif /* FREERTOS_CONFIG_H */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_1.c b/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_1.c deleted file mode 100644 index 178ff7c..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_1.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -/* - * The simplest possible implementation of pvPortMalloc(). Note that this - * implementation does NOT allow allocated memory to be freed again. - * - * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the - * memory management pages of http://www.FreeRTOS.org for more information. - */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* A few bytes might be lost to byte aligning the heap start address. */ -#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) - -/* Allocate the memory for the heap. */ -static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; -static size_t xNextFreeByte = ( size_t ) 0; - -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -void *pvReturn = NULL; -static uint8_t *pucAlignedHeap = NULL; - - /* Ensure that blocks are always aligned to the required number of bytes. */ - #if portBYTE_ALIGNMENT != 1 - if( xWantedSize & portBYTE_ALIGNMENT_MASK ) - { - /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - } - #endif - - vTaskSuspendAll(); - { - if( pucAlignedHeap == NULL ) - { - /* Ensure the heap starts on a correctly aligned boundary. */ - pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); - } - - /* Check there is enough room left for the allocation. */ - if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && - ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */ - { - /* Return the next free byte then increment the index past this - block. */ - pvReturn = pucAlignedHeap + xNextFreeByte; - xNextFreeByte += xWantedSize; - } - - traceMALLOC( pvReturn, xWantedSize ); - } - ( void ) xTaskResumeAll(); - - #if( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - } - #endif - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ - /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and - heap_4.c for alternative implementations, and the memory management pages of - http://www.FreeRTOS.org for more information. */ - ( void ) pv; - - /* Force an assert as it is invalid to call this function. */ - configASSERT( pv == NULL ); -} -/*-----------------------------------------------------------*/ - -void vPortInitialiseBlocks( void ) -{ - /* Only required when static memory is not cleared. */ - xNextFreeByte = ( size_t ) 0; -} -/*-----------------------------------------------------------*/ - -size_t xPortGetFreeHeapSize( void ) -{ - return ( configADJUSTED_HEAP_SIZE - xNextFreeByte ); -} - - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_2.c b/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_2.c deleted file mode 100644 index a1a7674..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_2.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/* - * A sample implementation of pvPortMalloc() and vPortFree() that permits - * allocated blocks to be freed, but does not combine adjacent free blocks - * into a single larger block (and so will fragment memory). See heap_4.c for - * an equivalent that does combine adjacent blocks into single larger blocks. - * - * See heap_1.c, heap_3.c and heap_4.c for alternative implementations, and the - * memory management pages of http://www.FreeRTOS.org for more information. - */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* A few bytes might be lost to byte aligning the heap start address. */ -#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) - -/* - * Initialises the heap structures before their first use. - */ -static void prvHeapInit( void ); - -/* Allocate the memory for the heap. */ -static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; - -/* Define the linked list structure. This is used to link free blocks in order -of their size. */ -typedef struct A_BLOCK_LINK -{ - struct A_BLOCK_LINK *pxNextFreeBlock; /*<< The next free block in the list. */ - size_t xBlockSize; /*<< The size of the free block. */ -} BlockLink_t; - - -static const uint16_t heapSTRUCT_SIZE = ( ( sizeof ( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK ); -#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) ) - -/* Create a couple of list links to mark the start and end of the list. */ -static BlockLink_t xStart, xEnd; - -/* Keeps track of the number of free bytes remaining, but says nothing about -fragmentation. */ -static size_t xFreeBytesRemaining = configADJUSTED_HEAP_SIZE; - -/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */ - -/* - * Insert a block into the list of free blocks - which is ordered by size of - * the block. Small blocks at the start of the list and large blocks at the end - * of the list. - */ -#define prvInsertBlockIntoFreeList( pxBlockToInsert ) \ -{ \ -BlockLink_t *pxIterator; \ -size_t xBlockSize; \ - \ - xBlockSize = pxBlockToInsert->xBlockSize; \ - \ - /* Iterate through the list until a block is found that has a larger size */ \ - /* than the block we are inserting. */ \ - for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \ - { \ - /* There is nothing to do here - just iterate to the correct position. */ \ - } \ - \ - /* Update the list to include the block being inserted in the correct */ \ - /* position. */ \ - pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; \ - pxIterator->pxNextFreeBlock = pxBlockToInsert; \ -} -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; -static BaseType_t xHeapHasBeenInitialised = pdFALSE; -void *pvReturn = NULL; - - vTaskSuspendAll(); - { - /* If this is the first call to malloc then the heap will require - initialisation to setup the list of free blocks. */ - if( xHeapHasBeenInitialised == pdFALSE ) - { - prvHeapInit(); - xHeapHasBeenInitialised = pdTRUE; - } - - /* The wanted size is increased so it can contain a BlockLink_t - structure in addition to the requested amount of bytes. */ - if( xWantedSize > 0 ) - { - xWantedSize += heapSTRUCT_SIZE; - - /* Ensure that blocks are always aligned to the required number of bytes. */ - if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 ) - { - /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - } - } - - if( ( xWantedSize > 0 ) && ( xWantedSize < configADJUSTED_HEAP_SIZE ) ) - { - /* Blocks are stored in byte order - traverse the list from the start - (smallest) block until one of adequate size is found. */ - pxPreviousBlock = &xStart; - pxBlock = xStart.pxNextFreeBlock; - while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) - { - pxPreviousBlock = pxBlock; - pxBlock = pxBlock->pxNextFreeBlock; - } - - /* If we found the end marker then a block of adequate size was not found. */ - if( pxBlock != &xEnd ) - { - /* Return the memory space - jumping over the BlockLink_t structure - at its start. */ - pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE ); - - /* This block is being returned for use so must be taken out of the - list of free blocks. */ - pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; - - /* If the block is larger than required it can be split into two. */ - if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) - { - /* This block is to be split into two. Create a new block - following the number of bytes requested. The void cast is - used to prevent byte alignment warnings from the compiler. */ - pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); - - /* Calculate the sizes of two blocks split from the single - block. */ - pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; - pxBlock->xBlockSize = xWantedSize; - - /* Insert the new block into the list of free blocks. */ - prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); - } - - xFreeBytesRemaining -= pxBlock->xBlockSize; - } - } - - traceMALLOC( pvReturn, xWantedSize ); - } - ( void ) xTaskResumeAll(); - - #if( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - } - #endif - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ -uint8_t *puc = ( uint8_t * ) pv; -BlockLink_t *pxLink; - - if( pv != NULL ) - { - /* The memory being freed will have an BlockLink_t structure immediately - before it. */ - puc -= heapSTRUCT_SIZE; - - /* This unexpected casting is to keep some compilers from issuing - byte alignment warnings. */ - pxLink = ( void * ) puc; - - vTaskSuspendAll(); - { - /* Add this block to the list of free blocks. */ - prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); - xFreeBytesRemaining += pxLink->xBlockSize; - traceFREE( pv, pxLink->xBlockSize ); - } - ( void ) xTaskResumeAll(); - } -} -/*-----------------------------------------------------------*/ - -size_t xPortGetFreeHeapSize( void ) -{ - return xFreeBytesRemaining; -} -/*-----------------------------------------------------------*/ - -void vPortInitialiseBlocks( void ) -{ - /* This just exists to keep the linker quiet. */ -} -/*-----------------------------------------------------------*/ - -static void prvHeapInit( void ) -{ -BlockLink_t *pxFirstFreeBlock; -uint8_t *pucAlignedHeap; - - /* Ensure the heap starts on a correctly aligned boundary. */ - pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); - - /* xStart is used to hold a pointer to the first item in the list of free - blocks. The void cast is used to prevent compiler warnings. */ - xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; - xStart.xBlockSize = ( size_t ) 0; - - /* xEnd is used to mark the end of the list of free blocks. */ - xEnd.xBlockSize = configADJUSTED_HEAP_SIZE; - xEnd.pxNextFreeBlock = NULL; - - /* To start with there is a single free block that is sized to take up the - entire heap space. */ - pxFirstFreeBlock = ( void * ) pucAlignedHeap; - pxFirstFreeBlock->xBlockSize = configADJUSTED_HEAP_SIZE; - pxFirstFreeBlock->pxNextFreeBlock = &xEnd; -} -/*-----------------------------------------------------------*/ diff --git a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_3.c b/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_3.c deleted file mode 100644 index f3c49c0..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_3.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -/* - * Implementation of pvPortMalloc() and vPortFree() that relies on the - * compilers own malloc() and free() implementations. - * - * This file can only be used if the linker is configured to to generate - * a heap memory area. - * - * See heap_1.c, heap_2.c and heap_4.c for alternative implementations, and the - * memory management pages of http://www.FreeRTOS.org for more information. - */ - -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -void *pvReturn; - - vTaskSuspendAll(); - { - pvReturn = malloc( xWantedSize ); - traceMALLOC( pvReturn, xWantedSize ); - } - ( void ) xTaskResumeAll(); - - #if( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - } - #endif - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ - if( pv ) - { - vTaskSuspendAll(); - { - free( pv ); - traceFREE( pv, 0 ); - } - ( void ) xTaskResumeAll(); - } -} - - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_4.c b/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_4.c deleted file mode 100644 index 8df0e9a..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_4.c +++ /dev/null @@ -1,474 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/* - * A sample implementation of pvPortMalloc() and vPortFree() that combines - * (coalescences) adjacent memory blocks as they are freed, and in so doing - * limits memory fragmentation. - * - * See heap_1.c, heap_2.c and heap_3.c for alternative implementations, and the - * memory management pages of http://www.FreeRTOS.org for more information. - */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* Block sizes must not get too small. */ -#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize * 2 ) ) - -/* Assumes 8bit bytes! */ -#define heapBITS_PER_BYTE ( ( size_t ) 8 ) - -/* Allocate the memory for the heap. */ -#if( configAPPLICATION_ALLOCATED_HEAP == 1 ) - /* The application writer has already defined the array used for the RTOS - heap - probably so it can be placed in a special segment or address. */ - extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; -#else - static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; -#endif /* configAPPLICATION_ALLOCATED_HEAP */ - -/* Define the linked list structure. This is used to link free blocks in order -of their memory address. */ -typedef struct A_BLOCK_LINK -{ - struct A_BLOCK_LINK *pxNextFreeBlock; /*<< The next free block in the list. */ - size_t xBlockSize; /*<< The size of the free block. */ -} BlockLink_t; - -/*-----------------------------------------------------------*/ - -/* - * Inserts a block of memory that is being freed into the correct position in - * the list of free memory blocks. The block being freed will be merged with - * the block in front it and/or the block behind it if the memory blocks are - * adjacent to each other. - */ -static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ); - -/* - * Called automatically to setup the required heap structures the first time - * pvPortMalloc() is called. - */ -static void prvHeapInit( void ); - -/*-----------------------------------------------------------*/ - -/* The size of the structure placed at the beginning of each allocated memory -block must by correctly byte aligned. */ -static const size_t xHeapStructSize = ( ( sizeof( BlockLink_t ) + ( ( ( size_t ) portBYTE_ALIGNMENT_MASK ) - ( size_t ) 1 ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK ) ); - -/* Create a couple of list links to mark the start and end of the list. */ -static BlockLink_t xStart, *pxEnd = NULL; - -/* Keeps track of the number of free bytes remaining, but says nothing about -fragmentation. */ -static size_t xFreeBytesRemaining = 0U; -static size_t xMinimumEverFreeBytesRemaining = 0U; - -/* Gets set to the top bit of an size_t type. When this bit in the xBlockSize -member of an BlockLink_t structure is set then the block belongs to the -application. When the bit is free the block is still part of the free heap -space. */ -static size_t xBlockAllocatedBit = 0; - -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; -void *pvReturn = NULL; - - vTaskSuspendAll(); - { - /* If this is the first call to malloc then the heap will require - initialisation to setup the list of free blocks. */ - if( pxEnd == NULL ) - { - prvHeapInit(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Check the requested block size is not so large that the top bit is - set. The top bit of the block size member of the BlockLink_t structure - is used to determine who owns the block - the application or the - kernel, so it must be free. */ - if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) - { - /* The wanted size is increased so it can contain a BlockLink_t - structure in addition to the requested amount of bytes. */ - if( xWantedSize > 0 ) - { - xWantedSize += xHeapStructSize; - - /* Ensure that blocks are always aligned to the required number - of bytes. */ - if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) - { - /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - configASSERT( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) == 0 ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) - { - /* Traverse the list from the start (lowest address) block until - one of adequate size is found. */ - pxPreviousBlock = &xStart; - pxBlock = xStart.pxNextFreeBlock; - while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) - { - pxPreviousBlock = pxBlock; - pxBlock = pxBlock->pxNextFreeBlock; - } - - /* If the end marker was reached then a block of adequate size - was not found. */ - if( pxBlock != pxEnd ) - { - /* Return the memory space pointed to - jumping over the - BlockLink_t structure at its start. */ - pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); - - /* This block is being returned for use so must be taken out - of the list of free blocks. */ - pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; - - /* If the block is larger than required it can be split into - two. */ - if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) - { - /* This block is to be split into two. Create a new - block following the number of bytes requested. The void - cast is used to prevent byte alignment warnings from the - compiler. */ - pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); - configASSERT( ( ( ( uint32_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 ); - - /* Calculate the sizes of two blocks split from the - single block. */ - pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; - pxBlock->xBlockSize = xWantedSize; - - /* Insert the new block into the list of free blocks. */ - prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - xFreeBytesRemaining -= pxBlock->xBlockSize; - - if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) - { - xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* The block is being returned - it is allocated and owned - by the application and has no "next" block. */ - pxBlock->xBlockSize |= xBlockAllocatedBit; - pxBlock->pxNextFreeBlock = NULL; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - traceMALLOC( pvReturn, xWantedSize ); - } - ( void ) xTaskResumeAll(); - - #if( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif - - configASSERT( ( ( ( uint32_t ) pvReturn ) & portBYTE_ALIGNMENT_MASK ) == 0 ); - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ -uint8_t *puc = ( uint8_t * ) pv; -BlockLink_t *pxLink; - - if( pv != NULL ) - { - /* The memory being freed will have an BlockLink_t structure immediately - before it. */ - puc -= xHeapStructSize; - - /* This casting is to keep the compiler from issuing warnings. */ - pxLink = ( void * ) puc; - - /* Check the block is actually allocated. */ - configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); - configASSERT( pxLink->pxNextFreeBlock == NULL ); - - if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) - { - if( pxLink->pxNextFreeBlock == NULL ) - { - /* The block is being returned to the heap - it is no longer - allocated. */ - pxLink->xBlockSize &= ~xBlockAllocatedBit; - - vTaskSuspendAll(); - { - /* Add this block to the list of free blocks. */ - xFreeBytesRemaining += pxLink->xBlockSize; - traceFREE( pv, pxLink->xBlockSize ); - prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); - } - ( void ) xTaskResumeAll(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } -} -/*-----------------------------------------------------------*/ - -size_t xPortGetFreeHeapSize( void ) -{ - return xFreeBytesRemaining; -} -/*-----------------------------------------------------------*/ - -size_t xPortGetMinimumEverFreeHeapSize( void ) -{ - return xMinimumEverFreeBytesRemaining; -} -/*-----------------------------------------------------------*/ - -void vPortInitialiseBlocks( void ) -{ - /* This just exists to keep the linker quiet. */ -} -/*-----------------------------------------------------------*/ - -static void prvHeapInit( void ) -{ -BlockLink_t *pxFirstFreeBlock; -uint8_t *pucAlignedHeap; -uint32_t ulAddress; -size_t xTotalHeapSize = configTOTAL_HEAP_SIZE; - - /* Ensure the heap starts on a correctly aligned boundary. */ - ulAddress = ( uint32_t ) ucHeap; - - if( ( ulAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) - { - ulAddress += ( portBYTE_ALIGNMENT - 1 ); - ulAddress &= ~( ( uint32_t ) portBYTE_ALIGNMENT_MASK ); - xTotalHeapSize -= ulAddress - ( uint32_t ) ucHeap; - } - - pucAlignedHeap = ( uint8_t * ) ulAddress; - - /* xStart is used to hold a pointer to the first item in the list of free - blocks. The void cast is used to prevent compiler warnings. */ - xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap; - xStart.xBlockSize = ( size_t ) 0; - - /* pxEnd is used to mark the end of the list of free blocks and is inserted - at the end of the heap space. */ - ulAddress = ( ( uint32_t ) pucAlignedHeap ) + xTotalHeapSize; - ulAddress -= xHeapStructSize; - ulAddress &= ~( ( uint32_t ) portBYTE_ALIGNMENT_MASK ); - pxEnd = ( void * ) ulAddress; - pxEnd->xBlockSize = 0; - pxEnd->pxNextFreeBlock = NULL; - - /* To start with there is a single free block that is sized to take up the - entire heap space, minus the space taken by pxEnd. */ - pxFirstFreeBlock = ( void * ) pucAlignedHeap; - pxFirstFreeBlock->xBlockSize = ulAddress - ( uint32_t ) pxFirstFreeBlock; - pxFirstFreeBlock->pxNextFreeBlock = pxEnd; - - /* Only one block exists - and it covers the entire usable heap space. */ - xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; - xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; - - /* Work out the position of the top bit in a size_t variable. */ - xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 ); -} -/*-----------------------------------------------------------*/ - -static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) -{ -BlockLink_t *pxIterator; -uint8_t *puc; - - /* Iterate through the list until a block is found that has a higher address - than the block being inserted. */ - for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) - { - /* Nothing to do here, just iterate to the right position. */ - } - - /* Do the block being inserted, and the block it is being inserted after - make a contiguous block of memory? */ - puc = ( uint8_t * ) pxIterator; - if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) - { - pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; - pxBlockToInsert = pxIterator; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Do the block being inserted, and the block it is being inserted before - make a contiguous block of memory? */ - puc = ( uint8_t * ) pxBlockToInsert; - if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) - { - if( pxIterator->pxNextFreeBlock != pxEnd ) - { - /* Form one big block from the two blocks. */ - pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; - pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; - } - else - { - pxBlockToInsert->pxNextFreeBlock = pxEnd; - } - } - else - { - pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; - } - - /* If the block being inserted plugged a gab, so was merged with the block - before and the block after, then it's pxNextFreeBlock pointer will have - already been set, and should not be set here as that would make it point - to itself. */ - if( pxIterator != pxBlockToInsert ) - { - pxIterator->pxNextFreeBlock = pxBlockToInsert; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } -} - diff --git a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_5.c b/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_5.c deleted file mode 100644 index b7bcaae..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/MemMang/heap_5.c +++ /dev/null @@ -1,523 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/* - * A sample implementation of pvPortMalloc() that allows the heap to be defined - * across multiple non-contigous blocks and combines (coalescences) adjacent - * memory blocks as they are freed. - * - * See heap_1.c, heap_2.c, heap_3.c and heap_4.c for alternative - * implementations, and the memory management pages of http://www.FreeRTOS.org - * for more information. - * - * Usage notes: - * - * vPortDefineHeapRegions() ***must*** be called before pvPortMalloc(). - * pvPortMalloc() will be called if any task objects (tasks, queues, event - * groups, etc.) are created, therefore vPortDefineHeapRegions() ***must*** be - * called before any other objects are defined. - * - * vPortDefineHeapRegions() takes a single parameter. The parameter is an array - * of HeapRegion_t structures. HeapRegion_t is defined in portable.h as - * - * typedef struct HeapRegion - * { - * uint8_t *pucStartAddress; << Start address of a block of memory that will be part of the heap. - * size_t xSizeInBytes; << Size of the block of memory. - * } HeapRegion_t; - * - * The array is terminated using a NULL zero sized region definition, and the - * memory regions defined in the array ***must*** appear in address order from - * low address to high address. So the following is a valid example of how - * to use the function. - * - * HeapRegion_t xHeapRegions[] = - * { - * { ( uint8_t * ) 0x80000000UL, 0x10000 }, << Defines a block of 0x10000 bytes starting at address 0x80000000 - * { ( uint8_t * ) 0x90000000UL, 0xa0000 }, << Defines a block of 0xa0000 bytes starting at address of 0x90000000 - * { NULL, 0 } << Terminates the array. - * }; - * - * vPortDefineHeapRegions( xHeapRegions ); << Pass the array into vPortDefineHeapRegions(). - * - * Note 0x80000000 is the lower address so appears in the array first. - * - */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* Block sizes must not get too small. */ -#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( uxHeapStructSize << 1 ) ) - -/* Assumes 8bit bytes! */ -#define heapBITS_PER_BYTE ( ( size_t ) 8 ) - -/* Define the linked list structure. This is used to link free blocks in order -of their memory address. */ -typedef struct A_BLOCK_LINK -{ - struct A_BLOCK_LINK *pxNextFreeBlock; /*<< The next free block in the list. */ - size_t xBlockSize; /*<< The size of the free block. */ -} BlockLink_t; - -/*-----------------------------------------------------------*/ - -/* - * Inserts a block of memory that is being freed into the correct position in - * the list of free memory blocks. The block being freed will be merged with - * the block in front it and/or the block behind it if the memory blocks are - * adjacent to each other. - */ -static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ); - -/*-----------------------------------------------------------*/ - -/* The size of the structure placed at the beginning of each allocated memory -block must by correctly byte aligned. */ -static const uint32_t uxHeapStructSize = ( ( sizeof ( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK ); - -/* Create a couple of list links to mark the start and end of the list. */ -static BlockLink_t xStart, *pxEnd = NULL; - -/* Keeps track of the number of free bytes remaining, but says nothing about -fragmentation. */ -static size_t xFreeBytesRemaining = 0; -static size_t xMinimumEverFreeBytesRemaining = 0; - -/* Gets set to the top bit of an size_t type. When this bit in the xBlockSize -member of an BlockLink_t structure is set then the block belongs to the -application. When the bit is free the block is still part of the free heap -space. */ -static size_t xBlockAllocatedBit = 0; - -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; -void *pvReturn = NULL; - - /* The heap must be initialised before the first call to - prvPortMalloc(). */ - configASSERT( pxEnd ); - - vTaskSuspendAll(); - { - /* Check the requested block size is not so large that the top bit is - set. The top bit of the block size member of the BlockLink_t structure - is used to determine who owns the block - the application or the - kernel, so it must be free. */ - if( ( xWantedSize & xBlockAllocatedBit ) == 0 ) - { - /* The wanted size is increased so it can contain a BlockLink_t - structure in addition to the requested amount of bytes. */ - if( xWantedSize > 0 ) - { - xWantedSize += uxHeapStructSize; - - /* Ensure that blocks are always aligned to the required number - of bytes. */ - if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) - { - /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) - { - /* Traverse the list from the start (lowest address) block until - one of adequate size is found. */ - pxPreviousBlock = &xStart; - pxBlock = xStart.pxNextFreeBlock; - while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) - { - pxPreviousBlock = pxBlock; - pxBlock = pxBlock->pxNextFreeBlock; - } - - /* If the end marker was reached then a block of adequate size - was not found. */ - if( pxBlock != pxEnd ) - { - /* Return the memory space pointed to - jumping over the - BlockLink_t structure at its start. */ - pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + uxHeapStructSize ); - - /* This block is being returned for use so must be taken out - of the list of free blocks. */ - pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; - - /* If the block is larger than required it can be split into - two. */ - if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) - { - /* This block is to be split into two. Create a new - block following the number of bytes requested. The void - cast is used to prevent byte alignment warnings from the - compiler. */ - pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ); - - /* Calculate the sizes of two blocks split from the - single block. */ - pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; - pxBlock->xBlockSize = xWantedSize; - - /* Insert the new block into the list of free blocks. */ - prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - xFreeBytesRemaining -= pxBlock->xBlockSize; - - if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) - { - xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* The block is being returned - it is allocated and owned - by the application and has no "next" block. */ - pxBlock->xBlockSize |= xBlockAllocatedBit; - pxBlock->pxNextFreeBlock = NULL; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - traceMALLOC( pvReturn, xWantedSize ); - } - ( void ) xTaskResumeAll(); - - #if( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ -uint8_t *puc = ( uint8_t * ) pv; -BlockLink_t *pxLink; - - if( pv != NULL ) - { - /* The memory being freed will have an BlockLink_t structure immediately - before it. */ - puc -= uxHeapStructSize; - - /* This casting is to keep the compiler from issuing warnings. */ - pxLink = ( void * ) puc; - - /* Check the block is actually allocated. */ - configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ); - configASSERT( pxLink->pxNextFreeBlock == NULL ); - - if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) - { - if( pxLink->pxNextFreeBlock == NULL ) - { - /* The block is being returned to the heap - it is no longer - allocated. */ - pxLink->xBlockSize &= ~xBlockAllocatedBit; - - vTaskSuspendAll(); - { - /* Add this block to the list of free blocks. */ - xFreeBytesRemaining += pxLink->xBlockSize; - traceFREE( pv, pxLink->xBlockSize ); - prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) ); - } - ( void ) xTaskResumeAll(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } -} -/*-----------------------------------------------------------*/ - -size_t xPortGetFreeHeapSize( void ) -{ - return xFreeBytesRemaining; -} -/*-----------------------------------------------------------*/ - -size_t xPortGetMinimumEverFreeHeapSize( void ) -{ - return xMinimumEverFreeBytesRemaining; -} -/*-----------------------------------------------------------*/ - -static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) -{ -BlockLink_t *pxIterator; -uint8_t *puc; - - /* Iterate through the list until a block is found that has a higher address - than the block being inserted. */ - for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) - { - /* Nothing to do here, just iterate to the right position. */ - } - - /* Do the block being inserted, and the block it is being inserted after - make a contiguous block of memory? */ - puc = ( uint8_t * ) pxIterator; - if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) - { - pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; - pxBlockToInsert = pxIterator; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Do the block being inserted, and the block it is being inserted before - make a contiguous block of memory? */ - puc = ( uint8_t * ) pxBlockToInsert; - if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) - { - if( pxIterator->pxNextFreeBlock != pxEnd ) - { - /* Form one big block from the two blocks. */ - pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; - pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; - } - else - { - pxBlockToInsert->pxNextFreeBlock = pxEnd; - } - } - else - { - pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; - } - - /* If the block being inserted plugged a gab, so was merged with the block - before and the block after, then it's pxNextFreeBlock pointer will have - already been set, and should not be set here as that would make it point - to itself. */ - if( pxIterator != pxBlockToInsert ) - { - pxIterator->pxNextFreeBlock = pxBlockToInsert; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } -} -/*-----------------------------------------------------------*/ - -void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) -{ -BlockLink_t *pxFirstFreeBlockInRegion = NULL, *pxPreviousFreeBlock; -uint8_t *pucAlignedHeap; -size_t xTotalRegionSize, xTotalHeapSize = 0; -BaseType_t xDefinedRegions = 0; -uint32_t ulAddress; -const HeapRegion_t *pxHeapRegion; - - /* Can only call once! */ - configASSERT( pxEnd == NULL ); - - pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] ); - - while( pxHeapRegion->xSizeInBytes > 0 ) - { - xTotalRegionSize = pxHeapRegion->xSizeInBytes; - - /* Ensure the heap region starts on a correctly aligned boundary. */ - ulAddress = ( uint32_t ) pxHeapRegion->pucStartAddress; - if( ( ulAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) - { - ulAddress += ( portBYTE_ALIGNMENT - 1 ); - ulAddress &= ~portBYTE_ALIGNMENT_MASK; - - /* Adjust the size for the bytes lost to alignment. */ - xTotalRegionSize -= ulAddress - ( uint32_t ) pxHeapRegion->pucStartAddress; - } - - pucAlignedHeap = ( uint8_t * ) ulAddress; - - /* Set xStart if it has not already been set. */ - if( xDefinedRegions == 0 ) - { - /* xStart is used to hold a pointer to the first item in the list of - free blocks. The void cast is used to prevent compiler warnings. */ - xStart.pxNextFreeBlock = ( BlockLink_t * ) pucAlignedHeap; - xStart.xBlockSize = ( size_t ) 0; - } - else - { - /* Should only get here if one region has already been added to the - heap. */ - configASSERT( pxEnd != NULL ); - - /* Check blocks are passed in with increasing start addresses. */ - configASSERT( ulAddress > ( uint32_t ) pxEnd ); - } - - /* Remember the location of the end marker in the previous region, if - any. */ - pxPreviousFreeBlock = pxEnd; - - /* pxEnd is used to mark the end of the list of free blocks and is - inserted at the end of the region space. */ - ulAddress = ( ( uint32_t ) pucAlignedHeap ) + xTotalRegionSize; - ulAddress -= uxHeapStructSize; - ulAddress &= ~portBYTE_ALIGNMENT_MASK; - pxEnd = ( BlockLink_t * ) ulAddress; - pxEnd->xBlockSize = 0; - pxEnd->pxNextFreeBlock = NULL; - - /* To start with there is a single free block in this region that is - sized to take up the entire heap region minus the space taken by the - free block structure. */ - pxFirstFreeBlockInRegion = ( BlockLink_t * ) pucAlignedHeap; - pxFirstFreeBlockInRegion->xBlockSize = ulAddress - ( uint32_t ) pxFirstFreeBlockInRegion; - pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd; - - /* If this is not the first region that makes up the entire heap space - then link the previous region to this region. */ - if( pxPreviousFreeBlock != NULL ) - { - pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion; - } - - xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize; - - /* Move onto the next HeapRegion_t structure. */ - xDefinedRegions++; - pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] ); - } - - xMinimumEverFreeBytesRemaining = xTotalHeapSize; - xFreeBytesRemaining = xTotalHeapSize; - - /* Check something was actually defined before it is accessed. */ - configASSERT( xTotalHeapSize ); - - /* Work out the position of the top bit in a size_t variable. */ - xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 ); -} - diff --git a/GD32F1/libraries/FreeRTOS821/utility/StackMacros.h b/GD32F1/libraries/FreeRTOS821/utility/StackMacros.h deleted file mode 100644 index 2658f23..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/StackMacros.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef STACK_MACROS_H -#define STACK_MACROS_H - -/* - * Call the stack overflow hook function if the stack of the task being swapped - * out is currently overflowed, or looks like it might have overflowed in the - * past. - * - * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check - * the current stack state only - comparing the current top of stack value to - * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 - * will also cause the last few stack bytes to be checked to ensure the value - * to which the bytes were set when the task was created have not been - * overwritten. Note this second test does not guarantee that an overflowed - * stack will always be recognised. - */ - -/*-----------------------------------------------------------*/ - -#if( configCHECK_FOR_STACK_OVERFLOW == 0 ) - - /* FreeRTOSConfig.h is not set to check for stack overflows. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() - -#endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */ -/*-----------------------------------------------------------*/ - -#if( configCHECK_FOR_STACK_OVERFLOW == 1 ) - - /* FreeRTOSConfig.h is only set to use the first method of - overflow checking. */ - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() - -#endif -/*-----------------------------------------------------------*/ - -#if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) - - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */ -/*-----------------------------------------------------------*/ - -#if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) - - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ -/*-----------------------------------------------------------*/ - -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ -/*-----------------------------------------------------------*/ - -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ - } - -#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ -/*-----------------------------------------------------------*/ - -#endif /* STACK_MACROS_H */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/croutine.c b/GD32F1/libraries/FreeRTOS821/utility/croutine.c deleted file mode 100644 index 4502ee8..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/croutine.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#include "FreeRTOS.h" -#include "task.h" -#include "croutine.h" - -/* Remove the whole file is co-routines are not being used. */ -#if( configUSE_CO_ROUTINES != 0 ) - -/* - * Some kernel aware debuggers require data to be viewed to be global, rather - * than file scope. - */ -#ifdef portREMOVE_STATIC_QUALIFIER - #define static -#endif - - -/* Lists for ready and blocked co-routines. --------------------*/ -static List_t pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ]; /*< Prioritised ready co-routines. */ -static List_t xDelayedCoRoutineList1; /*< Delayed co-routines. */ -static List_t xDelayedCoRoutineList2; /*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */ -static List_t * pxDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used. */ -static List_t * pxOverflowDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */ -static List_t xPendingReadyCoRoutineList; /*< Holds co-routines that have been readied by an external event. They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */ - -/* Other file private variables. --------------------------------*/ -CRCB_t * pxCurrentCoRoutine = NULL; -static UBaseType_t uxTopCoRoutineReadyPriority = 0; -static TickType_t xCoRoutineTickCount = 0, xLastTickCount = 0, xPassedTicks = 0; - -/* The initial state of the co-routine when it is created. */ -#define corINITIAL_STATE ( 0 ) - -/* - * Place the co-routine represented by pxCRCB into the appropriate ready queue - * for the priority. It is inserted at the end of the list. - * - * This macro accesses the co-routine ready lists and therefore must not be - * used from within an ISR. - */ -#define prvAddCoRoutineToReadyQueue( pxCRCB ) \ -{ \ - if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority ) \ - { \ - uxTopCoRoutineReadyPriority = pxCRCB->uxPriority; \ - } \ - vListInsertEnd( ( List_t * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) ); \ -} - -/* - * Utility to ready all the lists used by the scheduler. This is called - * automatically upon the creation of the first co-routine. - */ -static void prvInitialiseCoRoutineLists( void ); - -/* - * Co-routines that are readied by an interrupt cannot be placed directly into - * the ready lists (there is no mutual exclusion). Instead they are placed in - * in the pending ready list in order that they can later be moved to the ready - * list by the co-routine scheduler. - */ -static void prvCheckPendingReadyList( void ); - -/* - * Macro that looks at the list of co-routines that are currently delayed to - * see if any require waking. - * - * Co-routines are stored in the queue in the order of their wake time - - * meaning once one co-routine has been found whose timer has not expired - * we need not look any further down the list. - */ -static void prvCheckDelayedList( void ); - -/*-----------------------------------------------------------*/ - -BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex ) -{ -BaseType_t xReturn; -CRCB_t *pxCoRoutine; - - /* Allocate the memory that will store the co-routine control block. */ - pxCoRoutine = ( CRCB_t * ) pvPortMalloc( sizeof( CRCB_t ) ); - if( pxCoRoutine ) - { - /* If pxCurrentCoRoutine is NULL then this is the first co-routine to - be created and the co-routine data structures need initialising. */ - if( pxCurrentCoRoutine == NULL ) - { - pxCurrentCoRoutine = pxCoRoutine; - prvInitialiseCoRoutineLists(); - } - - /* Check the priority is within limits. */ - if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES ) - { - uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1; - } - - /* Fill out the co-routine control block from the function parameters. */ - pxCoRoutine->uxState = corINITIAL_STATE; - pxCoRoutine->uxPriority = uxPriority; - pxCoRoutine->uxIndex = uxIndex; - pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode; - - /* Initialise all the other co-routine control block parameters. */ - vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) ); - vListInitialiseItem( &( pxCoRoutine->xEventListItem ) ); - - /* Set the co-routine control block as a link back from the ListItem_t. - This is so we can get back to the containing CRCB from a generic item - in a list. */ - listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine ); - listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine ); - - /* Event lists are always in priority order. */ - listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), ( ( TickType_t ) configMAX_CO_ROUTINE_PRIORITIES - ( TickType_t ) uxPriority ) ); - - /* Now the co-routine has been initialised it can be added to the ready - list at the correct priority. */ - prvAddCoRoutineToReadyQueue( pxCoRoutine ); - - xReturn = pdPASS; - } - else - { - xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ) -{ -TickType_t xTimeToWake; - - /* Calculate the time to wake - this may overflow but this is - not a problem. */ - xTimeToWake = xCoRoutineTickCount + xTicksToDelay; - - /* We must remove ourselves from the ready list before adding - ourselves to the blocked list as the same list item is used for - both lists. */ - ( void ) uxListRemove( ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) ); - - /* The list item will be inserted in wake time order. */ - listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake ); - - if( xTimeToWake < xCoRoutineTickCount ) - { - /* Wake time has overflowed. Place this item in the - overflow list. */ - vListInsert( ( List_t * ) pxOverflowDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) ); - } - else - { - /* The wake time has not overflowed, so we can use the - current block list. */ - vListInsert( ( List_t * ) pxDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) ); - } - - if( pxEventList ) - { - /* Also add the co-routine to an event list. If this is done then the - function must be called with interrupts disabled. */ - vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) ); - } -} -/*-----------------------------------------------------------*/ - -static void prvCheckPendingReadyList( void ) -{ - /* Are there any co-routines waiting to get moved to the ready list? These - are co-routines that have been readied by an ISR. The ISR cannot access - the ready lists itself. */ - while( listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) == pdFALSE ) - { - CRCB_t *pxUnblockedCRCB; - - /* The pending ready list can be accessed by an ISR. */ - portDISABLE_INTERRUPTS(); - { - pxUnblockedCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyCoRoutineList) ); - ( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) ); - } - portENABLE_INTERRUPTS(); - - ( void ) uxListRemove( &( pxUnblockedCRCB->xGenericListItem ) ); - prvAddCoRoutineToReadyQueue( pxUnblockedCRCB ); - } -} -/*-----------------------------------------------------------*/ - -static void prvCheckDelayedList( void ) -{ -CRCB_t *pxCRCB; - - xPassedTicks = xTaskGetTickCount() - xLastTickCount; - while( xPassedTicks ) - { - xCoRoutineTickCount++; - xPassedTicks--; - - /* If the tick count has overflowed we need to swap the ready lists. */ - if( xCoRoutineTickCount == 0 ) - { - List_t * pxTemp; - - /* Tick count has overflowed so we need to swap the delay lists. If there are - any items in pxDelayedCoRoutineList here then there is an error! */ - pxTemp = pxDelayedCoRoutineList; - pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList; - pxOverflowDelayedCoRoutineList = pxTemp; - } - - /* See if this tick has made a timeout expire. */ - while( listLIST_IS_EMPTY( pxDelayedCoRoutineList ) == pdFALSE ) - { - pxCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList ); - - if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) ) - { - /* Timeout not yet expired. */ - break; - } - - portDISABLE_INTERRUPTS(); - { - /* The event could have occurred just before this critical - section. If this is the case then the generic list item will - have been moved to the pending ready list and the following - line is still valid. Also the pvContainer parameter will have - been set to NULL so the following lines are also valid. */ - ( void ) uxListRemove( &( pxCRCB->xGenericListItem ) ); - - /* Is the co-routine waiting on an event also? */ - if( pxCRCB->xEventListItem.pvContainer ) - { - ( void ) uxListRemove( &( pxCRCB->xEventListItem ) ); - } - } - portENABLE_INTERRUPTS(); - - prvAddCoRoutineToReadyQueue( pxCRCB ); - } - } - - xLastTickCount = xCoRoutineTickCount; -} -/*-----------------------------------------------------------*/ - -void vCoRoutineSchedule( void ) -{ - /* See if any co-routines readied by events need moving to the ready lists. */ - prvCheckPendingReadyList(); - - /* See if any delayed co-routines have timed out. */ - prvCheckDelayedList(); - - /* Find the highest priority queue that contains ready co-routines. */ - while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) ) - { - if( uxTopCoRoutineReadyPriority == 0 ) - { - /* No more co-routines to check. */ - return; - } - --uxTopCoRoutineReadyPriority; - } - - /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines - of the same priority get an equal share of the processor time. */ - listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ); - - /* Call the co-routine. */ - ( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex ); - - return; -} -/*-----------------------------------------------------------*/ - -static void prvInitialiseCoRoutineLists( void ) -{ -UBaseType_t uxPriority; - - for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ ) - { - vListInitialise( ( List_t * ) &( pxReadyCoRoutineLists[ uxPriority ] ) ); - } - - vListInitialise( ( List_t * ) &xDelayedCoRoutineList1 ); - vListInitialise( ( List_t * ) &xDelayedCoRoutineList2 ); - vListInitialise( ( List_t * ) &xPendingReadyCoRoutineList ); - - /* Start with pxDelayedCoRoutineList using list1 and the - pxOverflowDelayedCoRoutineList using list2. */ - pxDelayedCoRoutineList = &xDelayedCoRoutineList1; - pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2; -} -/*-----------------------------------------------------------*/ - -BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList ) -{ -CRCB_t *pxUnblockedCRCB; -BaseType_t xReturn; - - /* This function is called from within an interrupt. It can only access - event lists and the pending ready list. This function assumes that a - check has already been made to ensure pxEventList is not empty. */ - pxUnblockedCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); - ( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) ); - vListInsertEnd( ( List_t * ) &( xPendingReadyCoRoutineList ), &( pxUnblockedCRCB->xEventListItem ) ); - - if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} - -#endif /* configUSE_CO_ROUTINES == 0 */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/croutine.h b/GD32F1/libraries/FreeRTOS821/utility/croutine.h deleted file mode 100644 index 632c726..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/croutine.h +++ /dev/null @@ -1,762 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef CO_ROUTINE_H -#define CO_ROUTINE_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include croutine.h" -#endif - -#include "list.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Used to hide the implementation of the co-routine control block. The -control block structure however has to be included in the header due to -the macro implementation of the co-routine functionality. */ -typedef void * CoRoutineHandle_t; - -/* Defines the prototype to which co-routine functions must conform. */ -typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t ); - -typedef struct corCoRoutineControlBlock -{ - crCOROUTINE_CODE pxCoRoutineFunction; - ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ - ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */ - UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ - UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ - uint16_t uxState; /*< Used internally by the co-routine implementation. */ -} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ - -/** - * croutine. h - *
- BaseType_t xCoRoutineCreate(
-                                 crCOROUTINE_CODE pxCoRoutineCode,
-                                 UBaseType_t uxPriority,
-                                 UBaseType_t uxIndex
-                               );
- * - * Create a new co-routine and add it to the list of co-routines that are - * ready to run. - * - * @param pxCoRoutineCode Pointer to the co-routine function. Co-routine - * functions require special syntax - see the co-routine section of the WEB - * documentation for more information. - * - * @param uxPriority The priority with respect to other co-routines at which - * the co-routine will run. - * - * @param uxIndex Used to distinguish between different co-routines that - * execute the same function. See the example below and the co-routine section - * of the WEB documentation for further information. - * - * @return pdPASS if the co-routine was successfully created and added to a ready - * list, otherwise an error code defined with ProjDefs.h. - * - * Example usage: -
- // Co-routine to be created.
- void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- static const char cLedToFlash[ 2 ] = { 5, 6 };
- static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // This co-routine just delays for a fixed period, then toggles
-         // an LED.  Two co-routines are created using this function, so
-         // the uxIndex parameter is used to tell the co-routine which
-         // LED to flash and how int32_t to delay.  This assumes xQueue has
-         // already been created.
-         vParTestToggleLED( cLedToFlash[ uxIndex ] );
-         crDELAY( xHandle, uxFlashRates[ uxIndex ] );
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
-
- // Function that creates two co-routines.
- void vOtherFunction( void )
- {
- uint8_t ucParameterToPass;
- TaskHandle_t xHandle;
-
-     // Create two co-routines at priority 0.  The first is given index 0
-     // so (from the code above) toggles LED 5 every 200 ticks.  The second
-     // is given index 1 so toggles LED 6 every 400 ticks.
-     for( uxIndex = 0; uxIndex < 2; uxIndex++ )
-     {
-         xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
-     }
- }
-   
- * \defgroup xCoRoutineCreate xCoRoutineCreate - * \ingroup Tasks - */ -BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex ); - - -/** - * croutine. h - *
- void vCoRoutineSchedule( void );
- * - * Run a co-routine. - * - * vCoRoutineSchedule() executes the highest priority co-routine that is able - * to run. The co-routine will execute until it either blocks, yields or is - * preempted by a task. Co-routines execute cooperatively so one - * co-routine cannot be preempted by another, but can be preempted by a task. - * - * If an application comprises of both tasks and co-routines then - * vCoRoutineSchedule should be called from the idle task (in an idle task - * hook). - * - * Example usage: -
- // This idle task hook will schedule a co-routine each time it is called.
- // The rest of the idle task will execute between co-routine calls.
- void vApplicationIdleHook( void )
- {
-	vCoRoutineSchedule();
- }
-
- // Alternatively, if you do not require any other part of the idle task to
- // execute, the idle task hook can call vCoRoutineScheduler() within an
- // infinite loop.
- void vApplicationIdleHook( void )
- {
-    for( ;; )
-    {
-        vCoRoutineSchedule();
-    }
- }
- 
- * \defgroup vCoRoutineSchedule vCoRoutineSchedule - * \ingroup Tasks - */ -void vCoRoutineSchedule( void ); - -/** - * croutine. h - *
- crSTART( CoRoutineHandle_t xHandle );
- * - * This macro MUST always be called at the start of a co-routine function. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crSTART crSTART - * \ingroup Tasks - */ -#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: - -/** - * croutine. h - *
- crEND();
- * - * This macro MUST always be called at the end of a co-routine function. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crSTART crSTART - * \ingroup Tasks - */ -#define crEND() } - -/* - * These macros are intended for internal use by the co-routine implementation - * only. The macros should not be used directly by application writers. - */ -#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): -#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): - -/** - * croutine. h - *
- crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );
- * - * Delay a co-routine for a fixed period of time. - * - * crDELAY can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * @param xHandle The handle of the co-routine to delay. This is the xHandle - * parameter of the co-routine function. - * - * @param xTickToDelay The number of ticks that the co-routine should delay - * for. The actual amount of time this equates to is defined by - * configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant portTICK_PERIOD_MS - * can be used to convert ticks to milliseconds. - * - * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- // We are to delay for 200ms.
- static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-        // Delay for 200ms.
-        crDELAY( xHandle, xDelayTime );
-
-        // Do something here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
- * \defgroup crDELAY crDELAY - * \ingroup Tasks - */ -#define crDELAY( xHandle, xTicksToDelay ) \ - if( ( xTicksToDelay ) > 0 ) \ - { \ - vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ - } \ - crSET_STATE0( ( xHandle ) ); - -/** - *
- crQUEUE_SEND(
-                  CoRoutineHandle_t xHandle,
-                  QueueHandle_t pxQueue,
-                  void *pvItemToQueue,
-                  TickType_t xTicksToWait,
-                  BaseType_t *pxResult
-             )
- * - * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine - * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. - * - * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas - * xQueueSend() and xQueueReceive() can only be used from tasks. - * - * crQUEUE_SEND can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xHandle The handle of the calling co-routine. This is the xHandle - * parameter of the co-routine function. - * - * @param pxQueue The handle of the queue on which the data will be posted. - * The handle is obtained as the return value when the queue is created using - * the xQueueCreate() API function. - * - * @param pvItemToQueue A pointer to the data being posted onto the queue. - * The number of bytes of each queued item is specified when the queue is - * created. This number of bytes is copied from pvItemToQueue into the queue - * itself. - * - * @param xTickToDelay The number of ticks that the co-routine should block - * to wait for space to become available on the queue, should space not be - * available immediately. The actual amount of time this equates to is defined - * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant - * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see example - * below). - * - * @param pxResult The variable pointed to by pxResult will be set to pdPASS if - * data was successfully posted onto the queue, otherwise it will be set to an - * error defined within ProjDefs.h. - * - * Example usage: -
- // Co-routine function that blocks for a fixed period then posts a number onto
- // a queue.
- static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xNumberToPost = 0;
- static BaseType_t xResult;
-
-    // Co-routines must begin with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // This assumes the queue has already been created.
-        crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
-
-        if( xResult != pdPASS )
-        {
-            // The message was not posted!
-        }
-
-        // Increment the number to be posted onto the queue.
-        xNumberToPost++;
-
-        // Delay for 100 ticks.
-        crDELAY( xHandle, 100 );
-    }
-
-    // Co-routines must end with a call to crEND().
-    crEND();
- }
- * \defgroup crQUEUE_SEND crQUEUE_SEND - * \ingroup Tasks - */ -#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ - } \ - if( *pxResult == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *pxResult = pdPASS; \ - } \ -} - -/** - * croutine. h - *
-  crQUEUE_RECEIVE(
-                     CoRoutineHandle_t xHandle,
-                     QueueHandle_t pxQueue,
-                     void *pvBuffer,
-                     TickType_t xTicksToWait,
-                     BaseType_t *pxResult
-                 )
- * - * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine - * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. - * - * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas - * xQueueSend() and xQueueReceive() can only be used from tasks. - * - * crQUEUE_RECEIVE can only be called from the co-routine function itself - not - * from within a function called by the co-routine function. This is because - * co-routines do not maintain their own stack. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xHandle The handle of the calling co-routine. This is the xHandle - * parameter of the co-routine function. - * - * @param pxQueue The handle of the queue from which the data will be received. - * The handle is obtained as the return value when the queue is created using - * the xQueueCreate() API function. - * - * @param pvBuffer The buffer into which the received item is to be copied. - * The number of bytes of each queued item is specified when the queue is - * created. This number of bytes is copied into pvBuffer. - * - * @param xTickToDelay The number of ticks that the co-routine should block - * to wait for data to become available from the queue, should data not be - * available immediately. The actual amount of time this equates to is defined - * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant - * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see the - * crQUEUE_SEND example). - * - * @param pxResult The variable pointed to by pxResult will be set to pdPASS if - * data was successfully retrieved from the queue, otherwise it will be set to - * an error code as defined within ProjDefs.h. - * - * Example usage: -
- // A co-routine receives the number of an LED to flash from a queue.  It
- // blocks on the queue until the number is received.
- static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xResult;
- static UBaseType_t uxLEDToFlash;
-
-    // All co-routines must start with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // Wait for data to become available on the queue.
-        crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-        if( xResult == pdPASS )
-        {
-            // We received the LED to flash - flash it!
-            vParTestToggleLED( uxLEDToFlash );
-        }
-    }
-
-    crEND();
- }
- * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE - * \ingroup Tasks - */ -#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \ - } \ - if( *( pxResult ) == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *( pxResult ) = pdPASS; \ - } \ -} - -/** - * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvItemToQueue,
-                            BaseType_t xCoRoutinePreviouslyWoken
-                       )
- * - * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the - * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() - * functions used by tasks. - * - * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to - * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and - * xQueueReceiveFromISR() can only be used to pass data between a task and and - * ISR. - * - * crQUEUE_SEND_FROM_ISR can only be called from an ISR to send data to a queue - * that is being used from within a co-routine. - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xCoRoutinePreviouslyWoken This is included so an ISR can post onto - * the same queue multiple times from a single interrupt. The first call - * should always pass in pdFALSE. Subsequent calls should pass in - * the value returned from the previous call. - * - * @return pdTRUE if a co-routine was woken by posting onto the queue. This is - * used by the ISR to determine if a context switch may be required following - * the ISR. - * - * Example usage: -
- // A co-routine that blocks on a queue waiting for characters to be received.
- static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- char cRxedChar;
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Wait for data to become available on the queue.  This assumes the
-         // queue xCommsRxQueue has already been created!
-         crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-         // Was a character received?
-         if( xResult == pdPASS )
-         {
-             // Process the character here.
-         }
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to send characters received on a serial port to
- // a co-routine.
- void vUART_ISR( void )
- {
- char cRxedChar;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     // We loop around reading characters until there are none left in the UART.
-     while( UART_RX_REG_NOT_EMPTY() )
-     {
-         // Obtain the character from the UART.
-         cRxedChar = UART_RX_REG;
-
-         // Post the character onto a queue.  xCRWokenByPost will be pdFALSE
-         // the first time around the loop.  If the post causes a co-routine
-         // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
-         // In this manner we can ensure that if more than one co-routine is
-         // blocked on the queue only one is woken by this ISR no matter how
-         // many characters are posted to the queue.
-         xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
-     }
- }
- * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR - * \ingroup Tasks - */ -#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) - - -/** - * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvBuffer,
-                            BaseType_t * pxCoRoutineWoken
-                       )
- * - * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the - * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() - * functions used by tasks. - * - * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to - * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and - * xQueueReceiveFromISR() can only be used to pass data between a task and and - * ISR. - * - * crQUEUE_RECEIVE_FROM_ISR can only be called from an ISR to receive data - * from a queue that is being used from within a co-routine (a co-routine - * posted to the queue). - * - * See the co-routine section of the WEB documentation for information on - * passing data between tasks and co-routines and between ISR's and - * co-routines. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvBuffer A pointer to a buffer into which the received item will be - * placed. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from the queue into - * pvBuffer. - * - * @param pxCoRoutineWoken A co-routine may be blocked waiting for space to become - * available on the queue. If crQUEUE_RECEIVE_FROM_ISR causes such a - * co-routine to unblock *pxCoRoutineWoken will get set to pdTRUE, otherwise - * *pxCoRoutineWoken will remain unchanged. - * - * @return pdTRUE an item was successfully received from the queue, otherwise - * pdFALSE. - * - * Example usage: -
- // A co-routine that posts a character to a queue then blocks for a fixed
- // period.  The character is incremented each time.
- static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // cChar holds its value while this co-routine is blocked and must therefore
- // be declared static.
- static char cCharToTx = 'a';
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Send the next character to the queue.
-         crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
-
-         if( xResult == pdPASS )
-         {
-             // The character was successfully posted to the queue.
-         }
-		 else
-		 {
-			// Could not post the character to the queue.
-		 }
-
-         // Enable the UART Tx interrupt to cause an interrupt in this
-		 // hypothetical UART.  The interrupt will obtain the character
-		 // from the queue and send it.
-		 ENABLE_RX_INTERRUPT();
-
-		 // Increment to the next character then block for a fixed period.
-		 // cCharToTx will maintain its value across the delay as it is
-		 // declared static.
-		 cCharToTx++;
-		 if( cCharToTx > 'x' )
-		 {
-			cCharToTx = 'a';
-		 }
-		 crDELAY( 100 );
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to receive characters to send on a UART.
- void vUART_ISR( void )
- {
- char cCharToTx;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     while( UART_TX_REG_EMPTY() )
-     {
-         // Are there any characters in the queue waiting to be sent?
-		 // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
-		 // is woken by the post - ensuring that only a single co-routine is
-		 // woken no matter how many times we go around this loop.
-         if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
-		 {
-			 SEND_CHARACTER( cCharToTx );
-		 }
-     }
- }
- * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR - * \ingroup Tasks - */ -#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) - -/* - * This function is intended for internal use by the co-routine macros only. - * The macro nature of the co-routine implementation requires that the - * prototype appears here. The function should not be used by application - * writers. - * - * Removes the current co-routine from its ready list and places it in the - * appropriate delayed list. - */ -void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ); - -/* - * This function is intended for internal use by the queue implementation only. - * The function should not be used by application writers. - * - * Removes the highest priority co-routine from the event list and places it in - * the pending ready list. - */ -BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList ); - -#ifdef __cplusplus -} -#endif - -#endif /* CO_ROUTINE_H */ diff --git a/GD32F1/libraries/FreeRTOS821/utility/deprecated_definitions.h b/GD32F1/libraries/FreeRTOS821/utility/deprecated_definitions.h deleted file mode 100644 index 194934c..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/deprecated_definitions.h +++ /dev/null @@ -1,321 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef DEPRECATED_DEFINITIONS_H -#define DEPRECATED_DEFINITIONS_H - - -/* Each FreeRTOS port has a unique portmacro.h header file. Originally a -pre-processor definition was used to ensure the pre-processor found the correct -portmacro.h file for the port being used. That scheme was deprecated in favour -of setting the compiler's include path such that it found the correct -portmacro.h file - removing the need for the constant and allowing the -portmacro.h file to be located anywhere in relation to the port being used. The -definitions below remain in the code for backward compatibility only. New -projects should not use them. */ - -#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT - #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); -#endif - -#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT - #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); -#endif - -#ifdef GCC_MEGA_AVR - #include "../portable/GCC/ATMega323/portmacro.h" -#endif - -#ifdef IAR_MEGA_AVR - #include "../portable/IAR/ATMega323/portmacro.h" -#endif - -#ifdef MPLAB_PIC24_PORT - #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" -#endif - -#ifdef MPLAB_DSPIC_PORT - #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" -#endif - -#ifdef MPLAB_PIC18F_PORT - #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" -#endif - -#ifdef MPLAB_PIC32MX_PORT - #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" -#endif - -#ifdef _FEDPICC - #include "libFreeRTOS/Include/portmacro.h" -#endif - -#ifdef SDCC_CYGNAL - #include "../../Source/portable/SDCC/Cygnal/portmacro.h" -#endif - -#ifdef GCC_ARM7 - #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" -#endif - -#ifdef GCC_ARM7_ECLIPSE - #include "portmacro.h" -#endif - -#ifdef ROWLEY_LPC23xx - #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" -#endif - -#ifdef IAR_MSP430 - #include "..\..\Source\portable\IAR\MSP430\portmacro.h" -#endif - -#ifdef GCC_MSP430 - #include "../../Source/portable/GCC/MSP430F449/portmacro.h" -#endif - -#ifdef ROWLEY_MSP430 - #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" -#endif - -#ifdef ARM7_LPC21xx_KEIL_RVDS - #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" -#endif - -#ifdef SAM7_GCC - #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" -#endif - -#ifdef SAM7_IAR - #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" -#endif - -#ifdef SAM9XE_IAR - #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" -#endif - -#ifdef LPC2000_IAR - #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" -#endif - -#ifdef STR71X_IAR - #include "..\..\Source\portable\IAR\STR71x\portmacro.h" -#endif - -#ifdef STR75X_IAR - #include "..\..\Source\portable\IAR\STR75x\portmacro.h" -#endif - -#ifdef STR75X_GCC - #include "..\..\Source\portable\GCC\STR75x\portmacro.h" -#endif - -#ifdef STR91X_IAR - #include "..\..\Source\portable\IAR\STR91x\portmacro.h" -#endif - -#ifdef GCC_H8S - #include "../../Source/portable/GCC/H8S2329/portmacro.h" -#endif - -#ifdef GCC_AT91FR40008 - #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" -#endif - -#ifdef RVDS_ARMCM3_LM3S102 - #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" -#endif - -#ifdef GCC_ARMCM3_LM3S102 - #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" -#endif - -#ifdef GCC_ARMCM3 - #include "portmacro.h" -#endif - -#ifdef IAR_ARM_CM3 - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" -#endif - -#ifdef IAR_ARMCM3_LM - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" -#endif - -#ifdef HCS12_CODE_WARRIOR - #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" -#endif - -#ifdef MICROBLAZE_GCC - #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" -#endif - -#ifdef TERN_EE - #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" -#endif - -#ifdef GCC_HCS12 - #include "../../Source/portable/GCC/HCS12/portmacro.h" -#endif - -#ifdef GCC_MCF5235 - #include "../../Source/portable/GCC/MCF5235/portmacro.h" -#endif - -#ifdef COLDFIRE_V2_GCC - #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" -#endif - -#ifdef COLDFIRE_V2_CODEWARRIOR - #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" -#endif - -#ifdef GCC_PPC405 - #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" -#endif - -#ifdef GCC_PPC440 - #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" -#endif - -#ifdef _16FX_SOFTUNE - #include "..\..\Source\portable\Softune\MB96340\portmacro.h" -#endif - -#ifdef BCC_INDUSTRIAL_PC_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); -#endif - -#ifdef BCC_FLASH_LITE_186_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); -#endif - -#ifdef __GNUC__ - #ifdef __AVR32_AVR32A__ - #include "portmacro.h" - #endif -#endif - -#ifdef __ICCAVR32__ - #ifdef __CORE__ - #if __CORE__ == __AVR32A__ - #include "portmacro.h" - #endif - #endif -#endif - -#ifdef __91467D - #include "portmacro.h" -#endif - -#ifdef __96340 - #include "portmacro.h" -#endif - - -#ifdef __IAR_V850ES_Fx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_V850ES_Jx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_V850ES_Jx3_L__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_V850ES_Jx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_V850ES_Hx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" -#endif - -#ifdef __IAR_78K0R_Kx3__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" -#endif - -#ifdef __IAR_78K0R_Kx3L__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" -#endif - -#endif /* DEPRECATED_DEFINITIONS_H */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/event_groups.c b/GD32F1/libraries/FreeRTOS821/utility/event_groups.c deleted file mode 100644 index aeafeb0..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/event_groups.c +++ /dev/null @@ -1,683 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/* Standard includes. */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "event_groups.h" - -/* Lint e961 and e750 are suppressed as a MISRA exception justified because the -MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the -header files above, but not in this file, in order to generate the correct -privileged Vs unprivileged linkage and placement. */ -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */ - -#if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( configUSE_TIMERS == 0 ) - #error configUSE_TIMERS must be set to 1 to make the xEventGroupSetBitFromISR() function available. -#endif - -#if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 0 ) - #error INCLUDE_xTimerPendFunctionCall must also be set to one to make the xEventGroupSetBitFromISR() function available. -#endif - -/* The following bit fields convey control information in a task's event list -item value. It is important they don't clash with the -taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */ -#if configUSE_16_BIT_TICKS == 1 - #define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100U - #define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200U - #define eventWAIT_FOR_ALL_BITS 0x0400U - #define eventEVENT_BITS_CONTROL_BYTES 0xff00U -#else - #define eventCLEAR_EVENTS_ON_EXIT_BIT 0x01000000UL - #define eventUNBLOCKED_DUE_TO_BIT_SET 0x02000000UL - #define eventWAIT_FOR_ALL_BITS 0x04000000UL - #define eventEVENT_BITS_CONTROL_BYTES 0xff000000UL -#endif - -typedef struct xEventGroupDefinition -{ - EventBits_t uxEventBits; - List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */ - - #if( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxEventGroupNumber; - #endif - -} EventGroup_t; - -/*-----------------------------------------------------------*/ - -/* - * Test the bits set in uxCurrentEventBits to see if the wait condition is met. - * The wait condition is defined by xWaitForAllBits. If xWaitForAllBits is - * pdTRUE then the wait condition is met if all the bits set in uxBitsToWaitFor - * are also set in uxCurrentEventBits. If xWaitForAllBits is pdFALSE then the - * wait condition is met if any of the bits set in uxBitsToWait for are also set - * in uxCurrentEventBits. - */ -static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits ); - -/*-----------------------------------------------------------*/ - -EventGroupHandle_t xEventGroupCreate( void ) -{ -EventGroup_t *pxEventBits; - - pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) ); - if( pxEventBits != NULL ) - { - pxEventBits->uxEventBits = 0; - vListInitialise( &( pxEventBits->xTasksWaitingForBits ) ); - traceEVENT_GROUP_CREATE( pxEventBits ); - } - else - { - traceEVENT_GROUP_CREATE_FAILED(); - } - - return ( EventGroupHandle_t ) pxEventBits; -} -/*-----------------------------------------------------------*/ - -EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) -{ -EventBits_t uxOriginalBitValue, uxReturn; -EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; -BaseType_t xAlreadyYielded; -BaseType_t xTimeoutOccurred = pdFALSE; - - configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ); - configASSERT( uxBitsToWaitFor != 0 ); - #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) - { - configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); - } - #endif - - vTaskSuspendAll(); - { - uxOriginalBitValue = pxEventBits->uxEventBits; - - ( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet ); - - if( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor ) - { - /* All the rendezvous bits are now set - no need to block. */ - uxReturn = ( uxOriginalBitValue | uxBitsToSet ); - - /* Rendezvous always clear the bits. They will have been cleared - already unless this is the only task in the rendezvous. */ - pxEventBits->uxEventBits &= ~uxBitsToWaitFor; - - xTicksToWait = 0; - } - else - { - if( xTicksToWait != ( TickType_t ) 0 ) - { - traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ); - - /* Store the bits that the calling task is waiting for in the - task's event list item so the kernel knows when a match is - found. Then enter the blocked state. */ - vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | eventCLEAR_EVENTS_ON_EXIT_BIT | eventWAIT_FOR_ALL_BITS ), xTicksToWait ); - - /* This assignment is obsolete as uxReturn will get set after - the task unblocks, but some compilers mistakenly generate a - warning about uxReturn being returned without being set if the - assignment is omitted. */ - uxReturn = 0; - } - else - { - /* The rendezvous bits were not set, but no block time was - specified - just return the current event bit value. */ - uxReturn = pxEventBits->uxEventBits; - } - } - } - xAlreadyYielded = xTaskResumeAll(); - - if( xTicksToWait != ( TickType_t ) 0 ) - { - if( xAlreadyYielded == pdFALSE ) - { - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* The task blocked to wait for its required bits to be set - at this - point either the required bits were set or the block time expired. If - the required bits were set they will have been stored in the task's - event list item, and they should now be retrieved then cleared. */ - uxReturn = uxTaskResetEventItemValue(); - - if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 ) - { - /* The task timed out, just return the current event bit value. */ - taskENTER_CRITICAL(); - { - uxReturn = pxEventBits->uxEventBits; - - /* Although the task got here because it timed out before the - bits it was waiting for were set, it is possible that since it - unblocked another task has set the bits. If this is the case - then it needs to clear the bits before exiting. */ - if( ( uxReturn & uxBitsToWaitFor ) == uxBitsToWaitFor ) - { - pxEventBits->uxEventBits &= ~uxBitsToWaitFor; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - taskEXIT_CRITICAL(); - - xTimeoutOccurred = pdTRUE; - } - else - { - /* The task unblocked because the bits were set. */ - } - - /* Control bits might be set as the task had blocked should not be - returned. */ - uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES; - } - - traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ); - - return uxReturn; -} -/*-----------------------------------------------------------*/ - -EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) -{ -EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; -EventBits_t uxReturn, uxControlBits = 0; -BaseType_t xWaitConditionMet, xAlreadyYielded; -BaseType_t xTimeoutOccurred = pdFALSE; - - /* Check the user is not attempting to wait on the bits used by the kernel - itself, and that at least one bit is being requested. */ - configASSERT( xEventGroup ); - configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ); - configASSERT( uxBitsToWaitFor != 0 ); - #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) - { - configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); - } - #endif - - vTaskSuspendAll(); - { - const EventBits_t uxCurrentEventBits = pxEventBits->uxEventBits; - - /* Check to see if the wait condition is already met or not. */ - xWaitConditionMet = prvTestWaitCondition( uxCurrentEventBits, uxBitsToWaitFor, xWaitForAllBits ); - - if( xWaitConditionMet != pdFALSE ) - { - /* The wait condition has already been met so there is no need to - block. */ - uxReturn = uxCurrentEventBits; - xTicksToWait = ( TickType_t ) 0; - - /* Clear the wait bits if requested to do so. */ - if( xClearOnExit != pdFALSE ) - { - pxEventBits->uxEventBits &= ~uxBitsToWaitFor; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else if( xTicksToWait == ( TickType_t ) 0 ) - { - /* The wait condition has not been met, but no block time was - specified, so just return the current value. */ - uxReturn = uxCurrentEventBits; - } - else - { - /* The task is going to block to wait for its required bits to be - set. uxControlBits are used to remember the specified behaviour of - this call to xEventGroupWaitBits() - for use when the event bits - unblock the task. */ - if( xClearOnExit != pdFALSE ) - { - uxControlBits |= eventCLEAR_EVENTS_ON_EXIT_BIT; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - if( xWaitForAllBits != pdFALSE ) - { - uxControlBits |= eventWAIT_FOR_ALL_BITS; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Store the bits that the calling task is waiting for in the - task's event list item so the kernel knows when a match is - found. Then enter the blocked state. */ - vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xTicksToWait ); - - /* This is obsolete as it will get set after the task unblocks, but - some compilers mistakenly generate a warning about the variable - being returned without being set if it is not done. */ - uxReturn = 0; - - traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ); - } - } - xAlreadyYielded = xTaskResumeAll(); - - if( xTicksToWait != ( TickType_t ) 0 ) - { - if( xAlreadyYielded == pdFALSE ) - { - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* The task blocked to wait for its required bits to be set - at this - point either the required bits were set or the block time expired. If - the required bits were set they will have been stored in the task's - event list item, and they should now be retrieved then cleared. */ - uxReturn = uxTaskResetEventItemValue(); - - if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 ) - { - taskENTER_CRITICAL(); - { - /* The task timed out, just return the current event bit value. */ - uxReturn = pxEventBits->uxEventBits; - - /* It is possible that the event bits were updated between this - task leaving the Blocked state and running again. */ - if( prvTestWaitCondition( uxReturn, uxBitsToWaitFor, xWaitForAllBits ) != pdFALSE ) - { - if( xClearOnExit != pdFALSE ) - { - pxEventBits->uxEventBits &= ~uxBitsToWaitFor; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - taskEXIT_CRITICAL(); - - /* Prevent compiler warnings when trace macros are not used. */ - xTimeoutOccurred = pdFALSE; - } - else - { - /* The task unblocked because the bits were set. */ - } - - /* The task blocked so control bits may have been set. */ - uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES; - } - traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ); - - return uxReturn; -} -/*-----------------------------------------------------------*/ - -EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) -{ -EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; -EventBits_t uxReturn; - - /* Check the user is not attempting to clear the bits used by the kernel - itself. */ - configASSERT( xEventGroup ); - configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 ); - - taskENTER_CRITICAL(); - { - traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ); - - /* The value returned is the event group value prior to the bits being - cleared. */ - uxReturn = pxEventBits->uxEventBits; - - /* Clear the bits. */ - pxEventBits->uxEventBits &= ~uxBitsToClear; - } - taskEXIT_CRITICAL(); - - return uxReturn; -} -/*-----------------------------------------------------------*/ - -#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) - - BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) - { - BaseType_t xReturn; - - traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ); - xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ); - - return xReturn; - } - -#endif -/*-----------------------------------------------------------*/ - -EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) -{ -UBaseType_t uxSavedInterruptStatus; -EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; -EventBits_t uxReturn; - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - uxReturn = pxEventBits->uxEventBits; - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return uxReturn; -} -/*-----------------------------------------------------------*/ - -EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) -{ -ListItem_t *pxListItem, *pxNext; -ListItem_t const *pxListEnd; -List_t *pxList; -EventBits_t uxBitsToClear = 0, uxBitsWaitedFor, uxControlBits; -EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; -BaseType_t xMatchFound = pdFALSE; - - /* Check the user is not attempting to set the bits used by the kernel - itself. */ - configASSERT( xEventGroup ); - configASSERT( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 ); - - pxList = &( pxEventBits->xTasksWaitingForBits ); - pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */ - vTaskSuspendAll(); - { - traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ); - - pxListItem = listGET_HEAD_ENTRY( pxList ); - - /* Set the bits. */ - pxEventBits->uxEventBits |= uxBitsToSet; - - /* See if the new bit value should unblock any tasks. */ - while( pxListItem != pxListEnd ) - { - pxNext = listGET_NEXT( pxListItem ); - uxBitsWaitedFor = listGET_LIST_ITEM_VALUE( pxListItem ); - xMatchFound = pdFALSE; - - /* Split the bits waited for from the control bits. */ - uxControlBits = uxBitsWaitedFor & eventEVENT_BITS_CONTROL_BYTES; - uxBitsWaitedFor &= ~eventEVENT_BITS_CONTROL_BYTES; - - if( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( EventBits_t ) 0 ) - { - /* Just looking for single bit being set. */ - if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( EventBits_t ) 0 ) - { - xMatchFound = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor ) - { - /* All bits are set. */ - xMatchFound = pdTRUE; - } - else - { - /* Need all bits to be set, but not all the bits were set. */ - } - - if( xMatchFound != pdFALSE ) - { - /* The bits match. Should the bits be cleared on exit? */ - if( ( uxControlBits & eventCLEAR_EVENTS_ON_EXIT_BIT ) != ( EventBits_t ) 0 ) - { - uxBitsToClear |= uxBitsWaitedFor; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Store the actual event flag value in the task's event list - item before removing the task from the event list. The - eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows - that is was unblocked due to its required bits matching, rather - than because it timed out. */ - ( void ) xTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET ); - } - - /* Move onto the next list item. Note pxListItem->pxNext is not - used here as the list item may have been removed from the event list - and inserted into the ready/pending reading list. */ - pxListItem = pxNext; - } - - /* Clear any bits that matched when the eventCLEAR_EVENTS_ON_EXIT_BIT - bit was set in the control word. */ - pxEventBits->uxEventBits &= ~uxBitsToClear; - } - ( void ) xTaskResumeAll(); - - return pxEventBits->uxEventBits; -} -/*-----------------------------------------------------------*/ - -void vEventGroupDelete( EventGroupHandle_t xEventGroup ) -{ -EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; -const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits ); - - vTaskSuspendAll(); - { - traceEVENT_GROUP_DELETE( xEventGroup ); - - while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 ) - { - /* Unblock the task, returning 0 as the event list is being deleted - and cannot therefore have any bits set. */ - configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) ); - ( void ) xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET ); - } - - vPortFree( pxEventBits ); - } - ( void ) xTaskResumeAll(); -} -/*-----------------------------------------------------------*/ - -/* For internal use only - execute a 'set bits' command that was pended from -an interrupt. */ -void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) -{ - ( void ) xEventGroupSetBits( pvEventGroup, ( EventBits_t ) ulBitsToSet ); -} -/*-----------------------------------------------------------*/ - -/* For internal use only - execute a 'clear bits' command that was pended from -an interrupt. */ -void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) -{ - ( void ) xEventGroupClearBits( pvEventGroup, ( EventBits_t ) ulBitsToClear ); -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits ) -{ -BaseType_t xWaitConditionMet = pdFALSE; - - if( xWaitForAllBits == pdFALSE ) - { - /* Task only has to wait for one bit within uxBitsToWaitFor to be - set. Is one already set? */ - if( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( EventBits_t ) 0 ) - { - xWaitConditionMet = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* Task has to wait for all the bits in uxBitsToWaitFor to be set. - Are they set already? */ - if( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor ) - { - xWaitConditionMet = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - return xWaitConditionMet; -} -/*-----------------------------------------------------------*/ - -#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) - - BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ) - { - BaseType_t xReturn; - - traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ); - xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ); - - return xReturn; - } - -#endif -/*-----------------------------------------------------------*/ - -#if (configUSE_TRACE_FACILITY == 1) - - UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) - { - UBaseType_t xReturn; - EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; - - if( xEventGroup == NULL ) - { - xReturn = 0; - } - else - { - xReturn = pxEventBits->uxEventGroupNumber; - } - - return xReturn; - } - -#endif - diff --git a/GD32F1/libraries/FreeRTOS821/utility/event_groups.h b/GD32F1/libraries/FreeRTOS821/utility/event_groups.h deleted file mode 100644 index 92f5744..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/event_groups.h +++ /dev/null @@ -1,730 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef EVENT_GROUPS_H -#define EVENT_GROUPS_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" -#endif - -#include "timers.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * An event group is a collection of bits to which an application can assign a - * meaning. For example, an application may create an event group to convey - * the status of various CAN bus related events in which bit 0 might mean "A CAN - * message has been received and is ready for processing", bit 1 might mean "The - * application has queued a message that is ready for sending onto the CAN - * network", and bit 2 might mean "It is time to send a SYNC message onto the - * CAN network" etc. A task can then test the bit values to see which events - * are active, and optionally enter the Blocked state to wait for a specified - * bit or a group of specified bits to be active. To continue the CAN bus - * example, a CAN controlling task can enter the Blocked state (and therefore - * not consume any processing time) until either bit 0, bit 1 or bit 2 are - * active, at which time the bit that was actually active would inform the task - * which action it had to take (process a received message, send a message, or - * send a SYNC). - * - * The event groups implementation contains intelligence to avoid race - * conditions that would otherwise occur were an application to use a simple - * variable for the same purpose. This is particularly important with respect - * to when a bit within an event group is to be cleared, and when bits have to - * be set and then tested atomically - as is the case where event groups are - * used to create a synchronisation point between multiple tasks (a - * 'rendezvous'). - * - * \defgroup EventGroup - */ - - - -/** - * event_groups.h - * - * Type by which event groups are referenced. For example, a call to - * xEventGroupCreate() returns an EventGroupHandle_t variable that can then - * be used as a parameter to other event group functions. - * - * \defgroup EventGroupHandle_t EventGroupHandle_t - * \ingroup EventGroup - */ -typedef void * EventGroupHandle_t; - -/* - * The type that holds event bits always matches TickType_t - therefore the - * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1, - * 32 bits if set to 0. - * - * \defgroup EventBits_t EventBits_t - * \ingroup EventGroup - */ -typedef TickType_t EventBits_t; - -/** - * event_groups.h - *
- EventGroupHandle_t xEventGroupCreate( void );
- 
- * - * Create a new event group. This function cannot be called from an interrupt. - * - * Although event groups are not related to ticks, for internal implementation - * reasons the number of bits available for use in an event group is dependent - * on the configUSE_16_BIT_TICKS setting in FreeRTOSConfig.h. If - * configUSE_16_BIT_TICKS is 1 then each event group contains 8 usable bits (bit - * 0 to bit 7). If configUSE_16_BIT_TICKS is set to 0 then each event group has - * 24 usable bits (bit 0 to bit 23). The EventBits_t type is used to store - * event bits within an event group. - * - * @return If the event group was created then a handle to the event group is - * returned. If there was insufficient FreeRTOS heap available to create the - * event group then NULL is returned. See http://www.freertos.org/a00111.html - * - * Example usage: -
-	// Declare a variable to hold the created event group.
-	EventGroupHandle_t xCreatedEventGroup;
-
-	// Attempt to create the event group.
-	xCreatedEventGroup = xEventGroupCreate();
-
-	// Was the event group created successfully?
-	if( xCreatedEventGroup == NULL )
-	{
-		// The event group was not created because there was insufficient
-		// FreeRTOS heap available.
-	}
-	else
-	{
-		// The event group was created.
-	}
-   
- * \defgroup xEventGroupCreate xEventGroupCreate - * \ingroup EventGroup - */ -EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; - -/** - * event_groups.h - *
-	EventBits_t xEventGroupWaitBits( 	EventGroupHandle_t xEventGroup,
-										const EventBits_t uxBitsToWaitFor,
-										const BaseType_t xClearOnExit,
-										const BaseType_t xWaitForAllBits,
-										const TickType_t xTicksToWait );
- 
- * - * [Potentially] block to wait for one or more bits to be set within a - * previously created event group. - * - * This function cannot be called from an interrupt. - * - * @param xEventGroup The event group in which the bits are being tested. The - * event group must have previously been created using a call to - * xEventGroupCreate(). - * - * @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test - * inside the event group. For example, to wait for bit 0 and/or bit 2 set - * uxBitsToWaitFor to 0x05. To wait for bits 0 and/or bit 1 and/or bit 2 set - * uxBitsToWaitFor to 0x07. Etc. - * - * @param xClearOnExit If xClearOnExit is set to pdTRUE then any bits within - * uxBitsToWaitFor that are set within the event group will be cleared before - * xEventGroupWaitBits() returns if the wait condition was met (if the function - * returns for a reason other than a timeout). If xClearOnExit is set to - * pdFALSE then the bits set in the event group are not altered when the call to - * xEventGroupWaitBits() returns. - * - * @param xWaitForAllBits If xWaitForAllBits is set to pdTRUE then - * xEventGroupWaitBits() will return when either all the bits in uxBitsToWaitFor - * are set or the specified block time expires. If xWaitForAllBits is set to - * pdFALSE then xEventGroupWaitBits() will return when any one of the bits set - * in uxBitsToWaitFor is set or the specified block time expires. The block - * time is specified by the xTicksToWait parameter. - * - * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait - * for one/all (depending on the xWaitForAllBits value) of the bits specified by - * uxBitsToWaitFor to become set. - * - * @return The value of the event group at the time either the bits being waited - * for became set, or the block time expired. Test the return value to know - * which bits were set. If xEventGroupWaitBits() returned because its timeout - * expired then not all the bits being waited for will be set. If - * xEventGroupWaitBits() returned because the bits it was waiting for were set - * then the returned value is the event group value before any bits were - * automatically cleared in the case that xClearOnExit parameter was set to - * pdTRUE. - * - * Example usage: -
-   #define BIT_0	( 1 << 0 )
-   #define BIT_4	( 1 << 4 )
-
-   void aFunction( EventGroupHandle_t xEventGroup )
-   {
-   EventBits_t uxBits;
-   const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
-
-		// Wait a maximum of 100ms for either bit 0 or bit 4 to be set within
-		// the event group.  Clear the bits before exiting.
-		uxBits = xEventGroupWaitBits(
-					xEventGroup,	// The event group being tested.
-					BIT_0 | BIT_4,	// The bits within the event group to wait for.
-					pdTRUE,			// BIT_0 and BIT_4 should be cleared before returning.
-					pdFALSE,		// Don't wait for both bits, either bit will do.
-					xTicksToWait );	// Wait a maximum of 100ms for either bit to be set.
-
-		if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
-		{
-			// xEventGroupWaitBits() returned because both bits were set.
-		}
-		else if( ( uxBits & BIT_0 ) != 0 )
-		{
-			// xEventGroupWaitBits() returned because just BIT_0 was set.
-		}
-		else if( ( uxBits & BIT_4 ) != 0 )
-		{
-			// xEventGroupWaitBits() returned because just BIT_4 was set.
-		}
-		else
-		{
-			// xEventGroupWaitBits() returned because xTicksToWait ticks passed
-			// without either BIT_0 or BIT_4 becoming set.
-		}
-   }
-   
- * \defgroup xEventGroupWaitBits xEventGroupWaitBits - * \ingroup EventGroup - */ -EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - -/** - * event_groups.h - *
-	EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );
- 
- * - * Clear bits within an event group. This function cannot be called from an - * interrupt. - * - * @param xEventGroup The event group in which the bits are to be cleared. - * - * @param uxBitsToClear A bitwise value that indicates the bit or bits to clear - * in the event group. For example, to clear bit 3 only, set uxBitsToClear to - * 0x08. To clear bit 3 and bit 0 set uxBitsToClear to 0x09. - * - * @return The value of the event group before the specified bits were cleared. - * - * Example usage: -
-   #define BIT_0	( 1 << 0 )
-   #define BIT_4	( 1 << 4 )
-
-   void aFunction( EventGroupHandle_t xEventGroup )
-   {
-   EventBits_t uxBits;
-
-		// Clear bit 0 and bit 4 in xEventGroup.
-		uxBits = xEventGroupClearBits(
-								xEventGroup,	// The event group being updated.
-								BIT_0 | BIT_4 );// The bits being cleared.
-
-		if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
-		{
-			// Both bit 0 and bit 4 were set before xEventGroupClearBits() was
-			// called.  Both will now be clear (not set).
-		}
-		else if( ( uxBits & BIT_0 ) != 0 )
-		{
-			// Bit 0 was set before xEventGroupClearBits() was called.  It will
-			// now be clear.
-		}
-		else if( ( uxBits & BIT_4 ) != 0 )
-		{
-			// Bit 4 was set before xEventGroupClearBits() was called.  It will
-			// now be clear.
-		}
-		else
-		{
-			// Neither bit 0 nor bit 4 were set in the first place.
-		}
-   }
-   
- * \defgroup xEventGroupClearBits xEventGroupClearBits - * \ingroup EventGroup - */ -EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; - -/** - * event_groups.h - *
-	BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
- 
- * - * A version of xEventGroupClearBits() that can be called from an interrupt. - * - * Setting bits in an event group is not a deterministic operation because there - * are an unknown number of tasks that may be waiting for the bit or bits being - * set. FreeRTOS does not allow nondeterministic operations to be performed - * while interrupts are disabled, so protects event groups that are accessed - * from tasks by suspending the scheduler rather than disabling interrupts. As - * a result event groups cannot be accessed directly from an interrupt service - * routine. Therefore xEventGroupClearBitsFromISR() sends a message to the - * timer task to have the clear operation performed in the context of the timer - * task. - * - * @param xEventGroup The event group in which the bits are to be cleared. - * - * @param uxBitsToClear A bitwise value that indicates the bit or bits to clear. - * For example, to clear bit 3 only, set uxBitsToClear to 0x08. To clear bit 3 - * and bit 0 set uxBitsToClear to 0x09. - * - * @return If the request to execute the function was posted successfully then - * pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned - * if the timer service queue was full. - * - * Example usage: -
-   #define BIT_0	( 1 << 0 )
-   #define BIT_4	( 1 << 4 )
-
-   // An event group which it is assumed has already been created by a call to
-   // xEventGroupCreate().
-   EventGroupHandle_t xEventGroup;
-
-   void anInterruptHandler( void )
-   {
-		// Clear bit 0 and bit 4 in xEventGroup.
-		xResult = xEventGroupClearBitsFromISR(
-							xEventGroup,	 // The event group being updated.
-							BIT_0 | BIT_4 ); // The bits being set.
-
-		if( xResult == pdPASS )
-		{
-			// The message was posted successfully.
-		}
-  }
-   
- * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR - * \ingroup EventGroup - */ -#if( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); -#else - #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) -#endif - -/** - * event_groups.h - *
-	EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
- 
- * - * Set bits within an event group. - * This function cannot be called from an interrupt. xEventGroupSetBitsFromISR() - * is a version that can be called from an interrupt. - * - * Setting bits in an event group will automatically unblock tasks that are - * blocked waiting for the bits. - * - * @param xEventGroup The event group in which the bits are to be set. - * - * @param uxBitsToSet A bitwise value that indicates the bit or bits to set. - * For example, to set bit 3 only, set uxBitsToSet to 0x08. To set bit 3 - * and bit 0 set uxBitsToSet to 0x09. - * - * @return The value of the event group at the time the call to - * xEventGroupSetBits() returns. There are two reasons why the returned value - * might have the bits specified by the uxBitsToSet parameter cleared. First, - * if setting a bit results in a task that was waiting for the bit leaving the - * blocked state then it is possible the bit will be cleared automatically - * (see the xClearBitOnExit parameter of xEventGroupWaitBits()). Second, any - * unblocked (or otherwise Ready state) task that has a priority above that of - * the task that called xEventGroupSetBits() will execute and may change the - * event group value before the call to xEventGroupSetBits() returns. - * - * Example usage: -
-   #define BIT_0	( 1 << 0 )
-   #define BIT_4	( 1 << 4 )
-
-   void aFunction( EventGroupHandle_t xEventGroup )
-   {
-   EventBits_t uxBits;
-
-		// Set bit 0 and bit 4 in xEventGroup.
-		uxBits = xEventGroupSetBits(
-							xEventGroup,	// The event group being updated.
-							BIT_0 | BIT_4 );// The bits being set.
-
-		if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
-		{
-			// Both bit 0 and bit 4 remained set when the function returned.
-		}
-		else if( ( uxBits & BIT_0 ) != 0 )
-		{
-			// Bit 0 remained set when the function returned, but bit 4 was
-			// cleared.  It might be that bit 4 was cleared automatically as a
-			// task that was waiting for bit 4 was removed from the Blocked
-			// state.
-		}
-		else if( ( uxBits & BIT_4 ) != 0 )
-		{
-			// Bit 4 remained set when the function returned, but bit 0 was
-			// cleared.  It might be that bit 0 was cleared automatically as a
-			// task that was waiting for bit 0 was removed from the Blocked
-			// state.
-		}
-		else
-		{
-			// Neither bit 0 nor bit 4 remained set.  It might be that a task
-			// was waiting for both of the bits to be set, and the bits were
-			// cleared as the task left the Blocked state.
-		}
-   }
-   
- * \defgroup xEventGroupSetBits xEventGroupSetBits - * \ingroup EventGroup - */ -EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; - -/** - * event_groups.h - *
-	BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );
- 
- * - * A version of xEventGroupSetBits() that can be called from an interrupt. - * - * Setting bits in an event group is not a deterministic operation because there - * are an unknown number of tasks that may be waiting for the bit or bits being - * set. FreeRTOS does not allow nondeterministic operations to be performed in - * interrupts or from critical sections. Therefore xEventGroupSetBitFromISR() - * sends a message to the timer task to have the set operation performed in the - * context of the timer task - where a scheduler lock is used in place of a - * critical section. - * - * @param xEventGroup The event group in which the bits are to be set. - * - * @param uxBitsToSet A bitwise value that indicates the bit or bits to set. - * For example, to set bit 3 only, set uxBitsToSet to 0x08. To set bit 3 - * and bit 0 set uxBitsToSet to 0x09. - * - * @param pxHigherPriorityTaskWoken As mentioned above, calling this function - * will result in a message being sent to the timer daemon task. If the - * priority of the timer daemon task is higher than the priority of the - * currently running task (the task the interrupt interrupted) then - * *pxHigherPriorityTaskWoken will be set to pdTRUE by - * xEventGroupSetBitsFromISR(), indicating that a context switch should be - * requested before the interrupt exits. For that reason - * *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the - * example code below. - * - * @return If the request to execute the function was posted successfully then - * pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned - * if the timer service queue was full. - * - * Example usage: -
-   #define BIT_0	( 1 << 0 )
-   #define BIT_4	( 1 << 4 )
-
-   // An event group which it is assumed has already been created by a call to
-   // xEventGroupCreate().
-   EventGroupHandle_t xEventGroup;
-
-   void anInterruptHandler( void )
-   {
-   BaseType_t xHigherPriorityTaskWoken, xResult;
-
-		// xHigherPriorityTaskWoken must be initialised to pdFALSE.
-		xHigherPriorityTaskWoken = pdFALSE;
-
-		// Set bit 0 and bit 4 in xEventGroup.
-		xResult = xEventGroupSetBitsFromISR(
-							xEventGroup,	// The event group being updated.
-							BIT_0 | BIT_4   // The bits being set.
-							&xHigherPriorityTaskWoken );
-
-		// Was the message posted successfully?
-		if( xResult == pdPASS )
-		{
-			// If xHigherPriorityTaskWoken is now set to pdTRUE then a context
-			// switch should be requested.  The macro used is port specific and 
-			// will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - 
-			// refer to the documentation page for the port being used.
-			portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
-		}
-  }
-   
- * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR - * \ingroup EventGroup - */ -#if( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ); -#else - #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) -#endif - -/** - * event_groups.h - *
-	EventBits_t xEventGroupSync(	EventGroupHandle_t xEventGroup,
-									const EventBits_t uxBitsToSet,
-									const EventBits_t uxBitsToWaitFor,
-									TickType_t xTicksToWait );
- 
- * - * Atomically set bits within an event group, then wait for a combination of - * bits to be set within the same event group. This functionality is typically - * used to synchronise multiple tasks, where each task has to wait for the other - * tasks to reach a synchronisation point before proceeding. - * - * This function cannot be used from an interrupt. - * - * The function will return before its block time expires if the bits specified - * by the uxBitsToWait parameter are set, or become set within that time. In - * this case all the bits specified by uxBitsToWait will be automatically - * cleared before the function returns. - * - * @param xEventGroup The event group in which the bits are being tested. The - * event group must have previously been created using a call to - * xEventGroupCreate(). - * - * @param uxBitsToSet The bits to set in the event group before determining - * if, and possibly waiting for, all the bits specified by the uxBitsToWait - * parameter are set. - * - * @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test - * inside the event group. For example, to wait for bit 0 and bit 2 set - * uxBitsToWaitFor to 0x05. To wait for bits 0 and bit 1 and bit 2 set - * uxBitsToWaitFor to 0x07. Etc. - * - * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait - * for all of the bits specified by uxBitsToWaitFor to become set. - * - * @return The value of the event group at the time either the bits being waited - * for became set, or the block time expired. Test the return value to know - * which bits were set. If xEventGroupSync() returned because its timeout - * expired then not all the bits being waited for will be set. If - * xEventGroupSync() returned because all the bits it was waiting for were - * set then the returned value is the event group value before any bits were - * automatically cleared. - * - * Example usage: -
- // Bits used by the three tasks.
- #define TASK_0_BIT		( 1 << 0 )
- #define TASK_1_BIT		( 1 << 1 )
- #define TASK_2_BIT		( 1 << 2 )
-
- #define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )
-
- // Use an event group to synchronise three tasks.  It is assumed this event
- // group has already been created elsewhere.
- EventGroupHandle_t xEventBits;
-
- void vTask0( void *pvParameters )
- {
- EventBits_t uxReturn;
- TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
-
-	 for( ;; )
-	 {
-		// Perform task functionality here.
-
-		// Set bit 0 in the event flag to note this task has reached the
-		// sync point.  The other two tasks will set the other two bits defined
-		// by ALL_SYNC_BITS.  All three tasks have reached the synchronisation
-		// point when all the ALL_SYNC_BITS are set.  Wait a maximum of 100ms
-		// for this to happen.
-		uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );
-
-		if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )
-		{
-			// All three tasks reached the synchronisation point before the call
-			// to xEventGroupSync() timed out.
-		}
-	}
- }
-
- void vTask1( void *pvParameters )
- {
-	 for( ;; )
-	 {
-		// Perform task functionality here.
-
-		// Set bit 1 in the event flag to note this task has reached the
-		// synchronisation point.  The other two tasks will set the other two
-		// bits defined by ALL_SYNC_BITS.  All three tasks have reached the
-		// synchronisation point when all the ALL_SYNC_BITS are set.  Wait
-		// indefinitely for this to happen.
-		xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );
-
-		// xEventGroupSync() was called with an indefinite block time, so
-		// this task will only reach here if the syncrhonisation was made by all
-		// three tasks, so there is no need to test the return value.
-	 }
- }
-
- void vTask2( void *pvParameters )
- {
-	 for( ;; )
-	 {
-		// Perform task functionality here.
-
-		// Set bit 2 in the event flag to note this task has reached the
-		// synchronisation point.  The other two tasks will set the other two
-		// bits defined by ALL_SYNC_BITS.  All three tasks have reached the
-		// synchronisation point when all the ALL_SYNC_BITS are set.  Wait
-		// indefinitely for this to happen.
-		xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );
-
-		// xEventGroupSync() was called with an indefinite block time, so
-		// this task will only reach here if the syncrhonisation was made by all
-		// three tasks, so there is no need to test the return value.
-	}
- }
-
- 
- * \defgroup xEventGroupSync xEventGroupSync - * \ingroup EventGroup - */ -EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - - -/** - * event_groups.h - *
-	EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );
- 
- * - * Returns the current value of the bits in an event group. This function - * cannot be used from an interrupt. - * - * @param xEventGroup The event group being queried. - * - * @return The event group bits at the time xEventGroupGetBits() was called. - * - * \defgroup xEventGroupGetBits xEventGroupGetBits - * \ingroup EventGroup - */ -#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) - -/** - * event_groups.h - *
-	EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
- 
- * - * A version of xEventGroupGetBits() that can be called from an ISR. - * - * @param xEventGroup The event group being queried. - * - * @return The event group bits at the time xEventGroupGetBitsFromISR() was called. - * - * \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR - * \ingroup EventGroup - */ -EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ); - -/** - * event_groups.h - *
-	void xEventGroupDelete( EventGroupHandle_t xEventGroup );
- 
- * - * Delete an event group that was previously created by a call to - * xEventGroupCreate(). Tasks that are blocked on the event group will be - * unblocked and obtain 0 as the event group's value. - * - * @param xEventGroup The event group being deleted. - */ -void vEventGroupDelete( EventGroupHandle_t xEventGroup ); - -/* For internal use only. */ -void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ); -void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ); - -#if (configUSE_TRACE_FACILITY == 1) - UBaseType_t uxEventGroupGetNumber( void* xEventGroup ); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* EVENT_GROUPS_H */ - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/heap_1.c b/GD32F1/libraries/FreeRTOS821/utility/heap_1.c deleted file mode 100644 index 178ff7c..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/heap_1.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -/* - * The simplest possible implementation of pvPortMalloc(). Note that this - * implementation does NOT allow allocated memory to be freed again. - * - * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the - * memory management pages of http://www.FreeRTOS.org for more information. - */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* A few bytes might be lost to byte aligning the heap start address. */ -#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) - -/* Allocate the memory for the heap. */ -static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; -static size_t xNextFreeByte = ( size_t ) 0; - -/*-----------------------------------------------------------*/ - -void *pvPortMalloc( size_t xWantedSize ) -{ -void *pvReturn = NULL; -static uint8_t *pucAlignedHeap = NULL; - - /* Ensure that blocks are always aligned to the required number of bytes. */ - #if portBYTE_ALIGNMENT != 1 - if( xWantedSize & portBYTE_ALIGNMENT_MASK ) - { - /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - } - #endif - - vTaskSuspendAll(); - { - if( pucAlignedHeap == NULL ) - { - /* Ensure the heap starts on a correctly aligned boundary. */ - pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); - } - - /* Check there is enough room left for the allocation. */ - if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && - ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */ - { - /* Return the next free byte then increment the index past this - block. */ - pvReturn = pucAlignedHeap + xNextFreeByte; - xNextFreeByte += xWantedSize; - } - - traceMALLOC( pvReturn, xWantedSize ); - } - ( void ) xTaskResumeAll(); - - #if( configUSE_MALLOC_FAILED_HOOK == 1 ) - { - if( pvReturn == NULL ) - { - extern void vApplicationMallocFailedHook( void ); - vApplicationMallocFailedHook(); - } - } - #endif - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vPortFree( void *pv ) -{ - /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and - heap_4.c for alternative implementations, and the memory management pages of - http://www.FreeRTOS.org for more information. */ - ( void ) pv; - - /* Force an assert as it is invalid to call this function. */ - configASSERT( pv == NULL ); -} -/*-----------------------------------------------------------*/ - -void vPortInitialiseBlocks( void ) -{ - /* Only required when static memory is not cleared. */ - xNextFreeByte = ( size_t ) 0; -} -/*-----------------------------------------------------------*/ - -size_t xPortGetFreeHeapSize( void ) -{ - return ( configADJUSTED_HEAP_SIZE - xNextFreeByte ); -} - - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/list.c b/GD32F1/libraries/FreeRTOS821/utility/list.c deleted file mode 100644 index 27d7029..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/list.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -#include -#include "FreeRTOS.h" -#include "list.h" - -/*----------------------------------------------------------- - * PUBLIC LIST API documented in list.h - *----------------------------------------------------------*/ - -void vListInitialise( List_t * const pxList ) -{ - /* The list structure contains a list item which is used to mark the - end of the list. To initialise the list the list end is inserted - as the only list entry. */ - pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */ - - /* The list end value is the highest possible value in the list to - ensure it remains at the end of the list. */ - pxList->xListEnd.xItemValue = portMAX_DELAY; - - /* The list end next and previous pointers point to itself so we know - when the list is empty. */ - pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */ - pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */ - - pxList->uxNumberOfItems = ( UBaseType_t ) 0U; - - /* Write known values into the list if - configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ); - listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ); -} -/*-----------------------------------------------------------*/ - -void vListInitialiseItem( ListItem_t * const pxItem ) -{ - /* Make sure the list item is not recorded as being on a list. */ - pxItem->pvContainer = NULL; - - /* Write known values into the list item if - configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ); - listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ); -} -/*-----------------------------------------------------------*/ - -void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) -{ -ListItem_t * const pxIndex = pxList->pxIndex; - - /* Only effective when configASSERT() is also defined, these tests may catch - the list data structures being overwritten in memory. They will not catch - data errors caused by incorrect configuration or use of FreeRTOS. */ - listTEST_LIST_INTEGRITY( pxList ); - listTEST_LIST_ITEM_INTEGRITY( pxNewListItem ); - - /* Insert a new list item into pxList, but rather than sort the list, - makes the new list item the last item to be removed by a call to - listGET_OWNER_OF_NEXT_ENTRY(). */ - pxNewListItem->pxNext = pxIndex; - pxNewListItem->pxPrevious = pxIndex->pxPrevious; - - /* Only used during decision coverage testing. */ - mtCOVERAGE_TEST_DELAY(); - - pxIndex->pxPrevious->pxNext = pxNewListItem; - pxIndex->pxPrevious = pxNewListItem; - - /* Remember which list the item is in. */ - pxNewListItem->pvContainer = ( void * ) pxList; - - ( pxList->uxNumberOfItems )++; -} -/*-----------------------------------------------------------*/ - -void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) -{ -ListItem_t *pxIterator; -const TickType_t xValueOfInsertion = pxNewListItem->xItemValue; - - /* Only effective when configASSERT() is also defined, these tests may catch - the list data structures being overwritten in memory. They will not catch - data errors caused by incorrect configuration or use of FreeRTOS. */ - listTEST_LIST_INTEGRITY( pxList ); - listTEST_LIST_ITEM_INTEGRITY( pxNewListItem ); - - /* Insert the new list item into the list, sorted in xItemValue order. - - If the list already contains a list item with the same item value then the - new list item should be placed after it. This ensures that TCB's which are - stored in ready lists (all of which have the same xItemValue value) get a - share of the CPU. However, if the xItemValue is the same as the back marker - the iteration loop below will not end. Therefore the value is checked - first, and the algorithm slightly modified if necessary. */ - if( xValueOfInsertion == portMAX_DELAY ) - { - pxIterator = pxList->xListEnd.pxPrevious; - } - else - { - /* *** NOTE *********************************************************** - If you find your application is crashing here then likely causes are - listed below. In addition see http://www.freertos.org/FAQHelp.html for - more tips, and ensure configASSERT() is defined! - http://www.freertos.org/a00110.html#configASSERT - - 1) Stack overflow - - see http://www.freertos.org/Stacks-and-stack-overflow-checking.html - 2) Incorrect interrupt priority assignment, especially on Cortex-M - parts where numerically high priority values denote low actual - interrupt priorities, which can seem counter intuitive. See - http://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition - of configMAX_SYSCALL_INTERRUPT_PRIORITY on - http://www.freertos.org/a00110.html - 3) Calling an API function from within a critical section or when - the scheduler is suspended, or calling an API function that does - not end in "FromISR" from an interrupt. - 4) Using a queue or semaphore before it has been initialised or - before the scheduler has been started (are interrupts firing - before vTaskStartScheduler() has been called?). - **********************************************************************/ - - for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */ - { - /* There is nothing to do here, just iterating to the wanted - insertion position. */ - } - } - - pxNewListItem->pxNext = pxIterator->pxNext; - pxNewListItem->pxNext->pxPrevious = pxNewListItem; - pxNewListItem->pxPrevious = pxIterator; - pxIterator->pxNext = pxNewListItem; - - /* Remember which list the item is in. This allows fast removal of the - item later. */ - pxNewListItem->pvContainer = ( void * ) pxList; - - ( pxList->uxNumberOfItems )++; -} -/*-----------------------------------------------------------*/ - -UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) -{ -/* The list item knows which list it is in. Obtain the list from the list -item. */ -List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer; - - pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious; - pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext; - - /* Only used during decision coverage testing. */ - mtCOVERAGE_TEST_DELAY(); - - /* Make sure the index is left pointing to a valid item. */ - if( pxList->pxIndex == pxItemToRemove ) - { - pxList->pxIndex = pxItemToRemove->pxPrevious; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - pxItemToRemove->pvContainer = NULL; - ( pxList->uxNumberOfItems )--; - - return pxList->uxNumberOfItems; -} -/*-----------------------------------------------------------*/ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/list.h b/GD32F1/libraries/FreeRTOS821/utility/list.h deleted file mode 100644 index 4599e89..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/list.h +++ /dev/null @@ -1,453 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/* - * This is the list implementation used by the scheduler. While it is tailored - * heavily for the schedulers needs, it is also available for use by - * application code. - * - * list_ts can only store pointers to list_item_ts. Each ListItem_t contains a - * numeric value (xItemValue). Most of the time the lists are sorted in - * descending item value order. - * - * Lists are created already containing one list item. The value of this - * item is the maximum possible that can be stored, it is therefore always at - * the end of the list and acts as a marker. The list member pxHead always - * points to this marker - even though it is at the tail of the list. This - * is because the tail contains a wrap back pointer to the true head of - * the list. - * - * In addition to it's value, each list item contains a pointer to the next - * item in the list (pxNext), a pointer to the list it is in (pxContainer) - * and a pointer to back to the object that contains it. These later two - * pointers are included for efficiency of list manipulation. There is - * effectively a two way link between the object containing the list item and - * the list item itself. - * - * - * \page ListIntroduction List Implementation - * \ingroup FreeRTOSIntro - */ - -#ifndef INC_FREERTOS_H - #error FreeRTOS.h must be included before list.h -#endif - -#ifndef LIST_H -#define LIST_H - -/* - * The list structure members are modified from within interrupts, and therefore - * by rights should be declared volatile. However, they are only modified in a - * functionally atomic way (within critical sections of with the scheduler - * suspended) and are either passed by reference into a function or indexed via - * a volatile variable. Therefore, in all use cases tested so far, the volatile - * qualifier can be omitted in order to provide a moderate performance - * improvement without adversely affecting functional behaviour. The assembly - * instructions generated by the IAR, ARM and GCC compilers when the respective - * compiler's options were set for maximum optimisation has been inspected and - * deemed to be as intended. That said, as compiler technology advances, and - * especially if aggressive cross module optimisation is used (a use case that - * has not been exercised to any great extend) then it is feasible that the - * volatile qualifier will be needed for correct optimisation. It is expected - * that a compiler removing essential code because, without the volatile - * qualifier on the list structure members and with aggressive cross module - * optimisation, the compiler deemed the code unnecessary will result in - * complete and obvious failure of the scheduler. If this is ever experienced - * then the volatile qualifier can be inserted in the relevant places within the - * list structures by simply defining configLIST_VOLATILE to volatile in - * FreeRTOSConfig.h (as per the example at the bottom of this comment block). - * If configLIST_VOLATILE is not defined then the preprocessor directives below - * will simply #define configLIST_VOLATILE away completely. - * - * To use volatile list structure members then add the following line to - * FreeRTOSConfig.h (without the quotes): - * "#define configLIST_VOLATILE volatile" - */ -#ifndef configLIST_VOLATILE - #define configLIST_VOLATILE -#endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Macros that can be used to place known values within the list structures, -then check that the known values do not get corrupted during the execution of -the application. These may catch the list data structures being overwritten in -memory. They will not catch data errors caused by incorrect configuration or -use of FreeRTOS.*/ -#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) - /* Define the macros to do nothing. */ - #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE - #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE - #define listFIRST_LIST_INTEGRITY_CHECK_VALUE - #define listSECOND_LIST_INTEGRITY_CHECK_VALUE - #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) - #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) - #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) - #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) - #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) - #define listTEST_LIST_INTEGRITY( pxList ) -#else - /* Define macros that add new members into the list structures. */ - #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; - #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; - #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; - #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; - - /* Define macros that set the new structure members to known values. */ - #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE - #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE - #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE - #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE - - /* Define macros that will assert if one of the structure members does not - contain its expected value. */ - #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) - #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) -#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */ - - -/* - * Definition of the only type of object that a list can contain. - */ -struct xLIST_ITEM -{ - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ - struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ - struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ - void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ - void * configLIST_VOLATILE pvContainer; /*< Pointer to the list in which this list item is placed (if any). */ - listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ -}; -typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ - -struct xMINI_LIST_ITEM -{ - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; - struct xLIST_ITEM * configLIST_VOLATILE pxNext; - struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; -}; -typedef struct xMINI_LIST_ITEM MiniListItem_t; - -/* - * Definition of the type of queue used by the scheduler. - */ -typedef struct xLIST -{ - listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE UBaseType_t uxNumberOfItems; - ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ - MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ - listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ -} List_t; - -/* - * Access macro to set the owner of a list item. The owner of a list item - * is the object (usually a TCB) that contains the list item. - * - * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER - * \ingroup LinkedList - */ -#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) ) - -/* - * Access macro to get the owner of a list item. The owner of a list item - * is the object (usually a TCB) that contains the list item. - * - * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER - * \ingroup LinkedList - */ -#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner ) - -/* - * Access macro to set the value of the list item. In most cases the value is - * used to sort the list in descending order. - * - * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE - * \ingroup LinkedList - */ -#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) ) - -/* - * Access macro to retrieve the value of the list item. The value can - * represent anything - for example the priority of a task, or the time at - * which a task should be unblocked. - * - * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE - * \ingroup LinkedList - */ -#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) - -/* - * Access macro to retrieve the value of the list item at the head of a given - * list. - * - * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE - * \ingroup LinkedList - */ -#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) - -/* - * Return the list item at the head of the list. - * - * \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY - * \ingroup LinkedList - */ -#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext ) - -/* - * Return the list item at the head of the list. - * - * \page listGET_NEXT listGET_NEXT - * \ingroup LinkedList - */ -#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext ) - -/* - * Return the list item that marks the end of the list - * - * \page listGET_END_MARKER listGET_END_MARKER - * \ingroup LinkedList - */ -#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) ) - -/* - * Access macro to determine if a list contains any items. The macro will - * only have the value true if the list is empty. - * - * \page listLIST_IS_EMPTY listLIST_IS_EMPTY - * \ingroup LinkedList - */ -#define listLIST_IS_EMPTY( pxList ) ( ( BaseType_t ) ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ) - -/* - * Access macro to return the number of items in the list. - */ -#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) - -/* - * Access function to obtain the owner of the next entry in a list. - * - * The list member pxIndex is used to walk through a list. Calling - * listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list - * and returns that entry's pxOwner parameter. Using multiple calls to this - * function it is therefore possible to move through every item contained in - * a list. - * - * The pxOwner parameter of a list item is a pointer to the object that owns - * the list item. In the scheduler this is normally a task control block. - * The pxOwner parameter effectively creates a two way link between the list - * item and its owner. - * - * @param pxTCB pxTCB is set to the address of the owner of the next list item. - * @param pxList The list from which the next item owner is to be returned. - * - * \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY - * \ingroup LinkedList - */ -#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ -{ \ -List_t * const pxConstList = ( pxList ); \ - /* Increment the index to the next item and return the item, ensuring */ \ - /* we don't return the marker used at the end of the list. */ \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ - { \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - } \ - ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ -} - - -/* - * Access function to obtain the owner of the first entry in a list. Lists - * are normally sorted in ascending item value order. - * - * This function returns the pxOwner member of the first item in the list. - * The pxOwner parameter of a list item is a pointer to the object that owns - * the list item. In the scheduler this is normally a task control block. - * The pxOwner parameter effectively creates a two way link between the list - * item and its owner. - * - * @param pxList The list from which the owner of the head item is to be - * returned. - * - * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY - * \ingroup LinkedList - */ -#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner ) - -/* - * Check to see if a list item is within a list. The list item maintains a - * "container" pointer that points to the list it is in. All this macro does - * is check to see if the container and the list match. - * - * @param pxList The list we want to know if the list item is within. - * @param pxListItem The list item we want to know if is in the list. - * @return pdTRUE if the list item is in the list, otherwise pdFALSE. - */ -#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( BaseType_t ) ( ( pxListItem )->pvContainer == ( void * ) ( pxList ) ) ) - -/* - * Return the list a list item is contained within (referenced from). - * - * @param pxListItem The list item being queried. - * @return A pointer to the List_t object that references the pxListItem - */ -#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pvContainer ) - -/* - * This provides a crude means of knowing if a list has been initialised, as - * pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise() - * function. - */ -#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY ) - -/* - * Must be called before a list is used! This initialises all the members - * of the list structure and inserts the xListEnd item into the list as a - * marker to the back of the list. - * - * @param pxList Pointer to the list being initialised. - * - * \page vListInitialise vListInitialise - * \ingroup LinkedList - */ -void vListInitialise( List_t * const pxList ); - -/* - * Must be called before a list item is used. This sets the list container to - * null so the item does not think that it is already contained in a list. - * - * @param pxItem Pointer to the list item being initialised. - * - * \page vListInitialiseItem vListInitialiseItem - * \ingroup LinkedList - */ -void vListInitialiseItem( ListItem_t * const pxItem ); - -/* - * Insert a list item into a list. The item will be inserted into the list in - * a position determined by its item value (descending item value order). - * - * @param pxList The list into which the item is to be inserted. - * - * @param pxNewListItem The item that is to be placed in the list. - * - * \page vListInsert vListInsert - * \ingroup LinkedList - */ -void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ); - -/* - * Insert a list item into a list. The item will be inserted in a position - * such that it will be the last item within the list returned by multiple - * calls to listGET_OWNER_OF_NEXT_ENTRY. - * - * The list member pvIndex is used to walk through a list. Calling - * listGET_OWNER_OF_NEXT_ENTRY increments pvIndex to the next item in the list. - * Placing an item in a list using vListInsertEnd effectively places the item - * in the list position pointed to by pvIndex. This means that every other - * item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before - * the pvIndex parameter again points to the item being inserted. - * - * @param pxList The list into which the item is to be inserted. - * - * @param pxNewListItem The list item to be inserted into the list. - * - * \page vListInsertEnd vListInsertEnd - * \ingroup LinkedList - */ -void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ); - -/* - * Remove an item from a list. The list item has a pointer to the list that - * it is in, so only the list item need be passed into the function. - * - * @param uxListRemove The item to be removed. The item will remove itself from - * the list pointed to by it's pxContainer parameter. - * - * @return The number of items that remain in the list after the list item has - * been removed. - * - * \page uxListRemove uxListRemove - * \ingroup LinkedList - */ -UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/GD32F1/libraries/FreeRTOS821/utility/mpu_wrappers.h b/GD32F1/libraries/FreeRTOS821/utility/mpu_wrappers.h deleted file mode 100644 index 2e30964..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/mpu_wrappers.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef MPU_WRAPPERS_H -#define MPU_WRAPPERS_H - -/* This file redefines API functions to be called through a wrapper macro, but -only for ports that are using the MPU. */ -#ifdef portUSING_MPU_WRAPPERS - - /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is - included from queue.c or task.c to prevent it from having an effect within - those files. */ - #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - - #define xTaskGenericCreate MPU_xTaskGenericCreate - #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions - #define vTaskDelete MPU_vTaskDelete - #define vTaskDelayUntil MPU_vTaskDelayUntil - #define vTaskDelay MPU_vTaskDelay - #define uxTaskPriorityGet MPU_uxTaskPriorityGet - #define vTaskPrioritySet MPU_vTaskPrioritySet - #define eTaskGetState MPU_eTaskGetState - #define vTaskSuspend MPU_vTaskSuspend - #define vTaskResume MPU_vTaskResume - #define vTaskSuspendAll MPU_vTaskSuspendAll - #define xTaskResumeAll MPU_xTaskResumeAll - #define xTaskGetTickCount MPU_xTaskGetTickCount - #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks - #define vTaskList MPU_vTaskList - #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats - #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag - #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag - #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook - #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark - #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle - #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState - #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle - #define uxTaskGetSystemState MPU_uxTaskGetSystemState - - #define xQueueGenericCreate MPU_xQueueGenericCreate - #define xQueueCreateMutex MPU_xQueueCreateMutex - #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive - #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive - #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore - #define xQueueGenericSend MPU_xQueueGenericSend - #define xQueueAltGenericSend MPU_xQueueAltGenericSend - #define xQueueAltGenericReceive MPU_xQueueAltGenericReceive - #define xQueueGenericReceive MPU_xQueueGenericReceive - #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting - #define vQueueDelete MPU_vQueueDelete - #define xQueueGenericReset MPU_xQueueGenericReset - #define xQueueCreateSet MPU_xQueueCreateSet - #define xQueueSelectFromSet MPU_xQueueSelectFromSet - #define xQueueAddToSet MPU_xQueueAddToSet - #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet - #define xQueuePeekFromISR MPU_xQueuePeekFromISR - #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder - - #define pvPortMalloc MPU_pvPortMalloc - #define vPortFree MPU_vPortFree - #define xPortGetFreeHeapSize MPU_xPortGetFreeHeapSize - #define vPortInitialiseBlocks MPU_vPortInitialiseBlocks - - #if configQUEUE_REGISTRY_SIZE > 0 - #define vQueueAddToRegistry MPU_vQueueAddToRegistry - #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue - #endif - - /* Remove the privileged function macro. */ - #define PRIVILEGED_FUNCTION - - #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - - /* Ensure API functions go in the privileged execution section. */ - #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - - #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - -#else /* portUSING_MPU_WRAPPERS */ - - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA - #define portUSING_MPU_WRAPPERS 0 - -#endif /* portUSING_MPU_WRAPPERS */ - - -#endif /* MPU_WRAPPERS_H */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/port.c b/GD32F1/libraries/FreeRTOS821/utility/port.c deleted file mode 100644 index 94ffc4d..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/port.c +++ /dev/null @@ -1,758 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/*----------------------------------------------------------- - * Implementation of functions defined in portable.h for the ARM CM3 port. - *----------------------------------------------------------*/ - -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" - -/* For backward compatibility, ensure configKERNEL_INTERRUPT_PRIORITY is -defined. The value should also ensure backward compatibility. -FreeRTOS.org versions prior to V4.4.0 did not include this definition. */ -#ifndef configKERNEL_INTERRUPT_PRIORITY - #define configKERNEL_INTERRUPT_PRIORITY 255 -#endif - -#ifndef configSYSTICK_CLOCK_HZ - #define configSYSTICK_CLOCK_HZ configCPU_CLOCK_HZ - /* Ensure the SysTick is clocked at the same frequency as the core. */ - #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL ) -#else - /* The way the SysTick is clocked is not modified in case it is not the same - as the core. */ - #define portNVIC_SYSTICK_CLK_BIT ( 0 ) -#endif - -/* Constants required to manipulate the core. Registers first... */ -#define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000e010 ) ) -#define portNVIC_SYSTICK_LOAD_REG ( * ( ( volatile uint32_t * ) 0xe000e014 ) ) -#define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) ) -#define portNVIC_SYSPRI2_REG ( * ( ( volatile uint32_t * ) 0xe000ed20 ) ) -/* ...then bits in the registers. */ -#define portNVIC_SYSTICK_INT_BIT ( 1UL << 1UL ) -#define portNVIC_SYSTICK_ENABLE_BIT ( 1UL << 0UL ) -#define portNVIC_SYSTICK_COUNT_FLAG_BIT ( 1UL << 16UL ) -#define portNVIC_PENDSVCLEAR_BIT ( 1UL << 27UL ) -#define portNVIC_PEND_SYSTICK_CLEAR_BIT ( 1UL << 25UL ) - -#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL ) -#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL ) - -/* Constants required to check the validity of an interrupt priority. */ -#define portFIRST_USER_INTERRUPT_NUMBER ( 16 ) -#define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 ) -#define portAIRCR_REG ( * ( ( volatile uint32_t * ) 0xE000ED0C ) ) -#define portMAX_8_BIT_VALUE ( ( uint8_t ) 0xff ) -#define portTOP_BIT_OF_BYTE ( ( uint8_t ) 0x80 ) -#define portMAX_PRIGROUP_BITS ( ( uint8_t ) 7 ) -#define portPRIORITY_GROUP_MASK ( 0x07UL << 8UL ) -#define portPRIGROUP_SHIFT ( 8UL ) - -/* Masks off all bits but the VECTACTIVE bits in the ICSR register. */ -#define portVECTACTIVE_MASK ( 0xFFUL ) - -/* Constants required to set up the initial stack. */ -#define portINITIAL_XPSR ( 0x01000000UL ) - -/* The systick is a 24-bit counter. */ -#define portMAX_24_BIT_NUMBER ( 0xffffffUL ) - -/* A fiddle factor to estimate the number of SysTick counts that would have -occurred while the SysTick counter is stopped during tickless idle -calculations. */ -#define portMISSED_COUNTS_FACTOR ( 45UL ) - -/* Let the user override the pre-loading of the initial LR with the address of -prvTaskExitError() in case is messes up unwinding of the stack in the -debugger. */ -#ifdef configTASK_RETURN_ADDRESS - #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS -#else - #define portTASK_RETURN_ADDRESS prvTaskExitError -#endif - -/* Each task maintains its own interrupt status in the critical nesting -variable. */ -static UBaseType_t uxCriticalNesting = 0xaaaaaaaa; - -/* - * Setup the timer to generate the tick interrupts. The implementation in this - * file is weak to allow application writers to change the timer used to - * generate the tick interrupt. - */ -void vPortSetupTimerInterrupt( void ); - -/* - * Exception handlers. - */ -void xPortPendSVHandler( void ) __attribute__ (( naked )); -void xPortSysTickHandler( void ); -void vPortSVCHandler( void ) __attribute__ (( naked )); - -/* - * Start first task is a separate function so it can be tested in isolation. - */ -static void prvPortStartFirstTask( void ) __attribute__ (( naked )); - -/* - * Used to catch tasks that attempt to return from their implementing function. - */ -static void prvTaskExitError( void ); - -/*-----------------------------------------------------------*/ - -/* - * The number of SysTick increments that make up one tick period. - */ -#if configUSE_TICKLESS_IDLE == 1 - static uint32_t ulTimerCountsForOneTick = 0; -#endif /* configUSE_TICKLESS_IDLE */ - -/* - * The maximum number of tick periods that can be suppressed is limited by the - * 24 bit resolution of the SysTick timer. - */ -#if configUSE_TICKLESS_IDLE == 1 - static uint32_t xMaximumPossibleSuppressedTicks = 0; -#endif /* configUSE_TICKLESS_IDLE */ - -/* - * Compensate for the CPU cycles that pass while the SysTick is stopped (low - * power functionality only. - */ -#if configUSE_TICKLESS_IDLE == 1 - static uint32_t ulStoppedTimerCompensation = 0; -#endif /* configUSE_TICKLESS_IDLE */ - -/* - * Used by the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() macro to ensure - * FreeRTOS API functions are not called from interrupts that have been assigned - * a priority above configMAX_SYSCALL_INTERRUPT_PRIORITY. - */ -#if ( configASSERT_DEFINED == 1 ) - static uint8_t ucMaxSysCallPriority = 0; - static uint32_t ulMaxPRIGROUPValue = 0; - static const volatile uint8_t * const pcInterruptPriorityRegisters = ( const volatile uint8_t * const ) portNVIC_IP_REGISTERS_OFFSET_16; -#endif /* configASSERT_DEFINED */ - -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) -{ - /* Simulate the stack frame as it would be created by a context switch - interrupt. */ - pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ - *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) pxCode; /* PC */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* LR */ - pxTopOfStack -= 5; /* R12, R3, R2 and R1. */ - *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ - pxTopOfStack -= 8; /* R11, R10, R9, R8, R7, R6, R5 and R4. */ - - return pxTopOfStack; -} -/*-----------------------------------------------------------*/ - -static void prvTaskExitError( void ) -{ - /* A function that implements a task must not exit or attempt to return to - its caller as there is nothing to return to. If a task wants to exit it - should instead call vTaskDelete( NULL ). - - Artificially force an assert() to be triggered if configASSERT() is - defined, then stop here so application writers can catch the error. */ - configASSERT( uxCriticalNesting == ~0UL ); - portDISABLE_INTERRUPTS(); - for( ;; ); -} -/*-----------------------------------------------------------*/ - -// !!! Maple -//void vPortSVCHandler( void ) -void __exc_svc( void ) -// !!! Maple -{ - __asm volatile ( - " ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */ - " ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */ - " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */ - " ldmia r0!, {r4-r11} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */ - " msr psp, r0 \n" /* Restore the task stack pointer. */ - " isb \n" - " mov r0, #0 \n" - " msr basepri, r0 \n" - " orr r14, #0xd \n" - " bx r14 \n" - " \n" - " .align 2 \n" - "pxCurrentTCBConst2: .word pxCurrentTCB \n" - ); -} -/*-----------------------------------------------------------*/ - -static void prvPortStartFirstTask( void ) -{ - __asm volatile( - " ldr r0, =0xE000ED08 \n" /* Use the NVIC offset register to locate the stack. */ - " ldr r0, [r0] \n" - " ldr r0, [r0] \n" - " msr msp, r0 \n" /* Set the msp back to the start of the stack. */ - " cpsie i \n" /* Globally enable interrupts. */ - " cpsie f \n" - " dsb \n" - " isb \n" - " svc 0 \n" /* System call to start first task. */ - " nop \n" - ); -} -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -BaseType_t xPortStartScheduler( void ) -{ - /* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. - See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ - configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY ); - - #if( configASSERT_DEFINED == 1 ) - { - volatile uint32_t ulOriginalPriority; - volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( portNVIC_IP_REGISTERS_OFFSET_16 + portFIRST_USER_INTERRUPT_NUMBER ); - volatile uint8_t ucMaxPriorityValue; - - /* Determine the maximum priority from which ISR safe FreeRTOS API - functions can be called. ISR safe functions are those that end in - "FromISR". FreeRTOS maintains separate thread and ISR API functions to - ensure interrupt entry is as fast and simple as possible. - - Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = *pucFirstUserPriorityRegister; - - /* Determine the number of priority bits available. First write to all - possible bits. */ - *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE; - - /* Read the value back to see how many bits stuck. */ - ucMaxPriorityValue = *pucFirstUserPriorityRegister; - - /* Use the same mask on the maximum system call priority. */ - ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue; - - /* Calculate the maximum acceptable priority group value for the number - of bits read back. */ - ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS; - while( ( ucMaxPriorityValue & portTOP_BIT_OF_BYTE ) == portTOP_BIT_OF_BYTE ) - { - ulMaxPRIGROUPValue--; - ucMaxPriorityValue <<= ( uint8_t ) 0x01; - } - - /* Shift the priority group value back to its position within the AIRCR - register. */ - ulMaxPRIGROUPValue <<= portPRIGROUP_SHIFT; - ulMaxPRIGROUPValue &= portPRIORITY_GROUP_MASK; - - /* Restore the clobbered interrupt priority register to its original - value. */ - *pucFirstUserPriorityRegister = ulOriginalPriority; - } - #endif /* conifgASSERT_DEFINED */ - - /* Make PendSV and SysTick the lowest priority interrupts. */ - portNVIC_SYSPRI2_REG |= portNVIC_PENDSV_PRI; - portNVIC_SYSPRI2_REG |= portNVIC_SYSTICK_PRI; - - // !!! Maple - /* Start the timer that generates the tick ISR. Interrupts are disabled - here already. */ - //vPortSetupTimerInterrupt(); - systick_attach_callback(&xPortSysTickHandler); - // !!! Maple - - /* Initialise the critical nesting count ready for the first task. */ - uxCriticalNesting = 0; - - /* Start the first task. */ - prvPortStartFirstTask(); - - /* Should never get here as the tasks will now be executing! Call the task - exit error function to prevent compiler warnings about a static function - not being called in the case that the application writer overrides this - functionality by defining configTASK_RETURN_ADDRESS. */ - prvTaskExitError(); - - /* Should not get here! */ - return 0; -} -/*-----------------------------------------------------------*/ - -void vPortEndScheduler( void ) -{ - /* Not implemented in ports where there is nothing to return to. - Artificially force an assert. */ - configASSERT( uxCriticalNesting == 1000UL ); -} -/*-----------------------------------------------------------*/ - -void vPortYield( void ) -{ - /* Set a PendSV to request a context switch. */ - portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; - - /* Barriers are normally not required but do ensure the code is completely - within the specified behaviour for the architecture. */ - __asm volatile( "dsb" ); - __asm volatile( "isb" ); -} -/*-----------------------------------------------------------*/ - -void vPortEnterCritical( void ) -{ - portDISABLE_INTERRUPTS(); - uxCriticalNesting++; - __asm volatile( "dsb" ); - __asm volatile( "isb" ); - - /* This is not the interrupt safe version of the enter critical function so - assert() if it is being called from an interrupt context. Only API - functions that end in "FromISR" can be used in an interrupt. Only assert if - the critical nesting count is 1 to protect against recursive calls if the - assert function also uses a critical section. */ - if( uxCriticalNesting == 1 ) - { - configASSERT( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) == 0 ); - } -} -/*-----------------------------------------------------------*/ - -void vPortExitCritical( void ) -{ - configASSERT( uxCriticalNesting ); - uxCriticalNesting--; - if( uxCriticalNesting == 0 ) - { - portENABLE_INTERRUPTS(); - } -} -/*-----------------------------------------------------------*/ - -__attribute__(( naked )) uint32_t ulPortSetInterruptMask( void ) -{ - __asm volatile \ - ( \ - " mrs r0, basepri \n" \ - " mov r1, %0 \n" \ - " msr basepri, r1 \n" \ - " bx lr \n" \ - :: "i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) : "r0", "r1" \ - ); - - /* This return will not be reached but is necessary to prevent compiler - warnings. */ - return 0; -} -/*-----------------------------------------------------------*/ - -__attribute__(( naked )) void vPortClearInterruptMask( uint32_t ulNewMaskValue ) -{ - __asm volatile \ - ( \ - " msr basepri, r0 \n" \ - " bx lr \n" \ - :::"r0" \ - ); - - /* Just to avoid compiler warnings. */ - ( void ) ulNewMaskValue; -} -/*-----------------------------------------------------------*/ - -// !!! Maple -//void xPortPendSVHandler( void ) -void __exc_pendsv( void ) -// !!! Maple -{ - /* This is a naked function. */ - - __asm volatile - ( - " mrs r0, psp \n" - " isb \n" - " \n" - " ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */ - " ldr r2, [r3] \n" - " \n" - " stmdb r0!, {r4-r11} \n" /* Save the remaining registers. */ - " str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */ - " \n" - " stmdb sp!, {r3, r14} \n" - " mov r0, %0 \n" - " msr basepri, r0 \n" - " bl vTaskSwitchContext \n" - " mov r0, #0 \n" - " msr basepri, r0 \n" - " ldmia sp!, {r3, r14} \n" - " \n" /* Restore the context, including the critical nesting count. */ - " ldr r1, [r3] \n" - " ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */ - " ldmia r0!, {r4-r11} \n" /* Pop the registers. */ - " msr psp, r0 \n" - " isb \n" - " bx r14 \n" - " \n" - " .align 2 \n" - "pxCurrentTCBConst: .word pxCurrentTCB \n" - ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) - ); -} -/*-----------------------------------------------------------*/ - -void xPortSysTickHandler( void ) -{ - /* The SysTick runs at the lowest interrupt priority, so when this interrupt - executes all interrupts must be unmasked. There is therefore no need to - save and then restore the interrupt mask value as its value is already - known. */ - ( void ) portSET_INTERRUPT_MASK_FROM_ISR(); - { - /* Increment the RTOS tick. */ - if( xTaskIncrementTick() != pdFALSE ) - { - /* A context switch is required. Context switching is performed in - the PendSV interrupt. Pend the PendSV interrupt. */ - portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 ); -} -/*-----------------------------------------------------------*/ - -#if configUSE_TICKLESS_IDLE == 1 - - __attribute__((weak)) void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ) - { - uint32_t ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickDecrements, ulSysTickCTRL; - TickType_t xModifiableIdleTime; - - /* Make sure the SysTick reload value does not overflow the counter. */ - if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks ) - { - xExpectedIdleTime = xMaximumPossibleSuppressedTicks; - } - - /* Stop the SysTick momentarily. The time the SysTick is stopped for - is accounted for as best it can be, but using the tickless mode will - inevitably result in some tiny drift of the time maintained by the - kernel with respect to calendar time. */ - portNVIC_SYSTICK_CTRL_REG &= ~portNVIC_SYSTICK_ENABLE_BIT; - - /* Calculate the reload value required to wait xExpectedIdleTime - tick periods. -1 is used because this code will execute part way - through one of the tick periods. */ - ulReloadValue = portNVIC_SYSTICK_CURRENT_VALUE_REG + ( ulTimerCountsForOneTick * ( xExpectedIdleTime - 1UL ) ); - if( ulReloadValue > ulStoppedTimerCompensation ) - { - ulReloadValue -= ulStoppedTimerCompensation; - } - - /* Enter a critical section but don't use the taskENTER_CRITICAL() - method as that will mask interrupts that should exit sleep mode. */ - __asm volatile( "cpsid i" ); - - /* If a context switch is pending or a task is waiting for the scheduler - to be unsuspended then abandon the low power entry. */ - if( eTaskConfirmSleepModeStatus() == eAbortSleep ) - { - /* Restart from whatever is left in the count register to complete - this tick period. */ - portNVIC_SYSTICK_LOAD_REG = portNVIC_SYSTICK_CURRENT_VALUE_REG; - - /* Restart SysTick. */ - portNVIC_SYSTICK_CTRL_REG |= portNVIC_SYSTICK_ENABLE_BIT; - - /* Reset the reload register to the value required for normal tick - periods. */ - portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL; - - /* Re-enable interrupts - see comments above the cpsid instruction() - above. */ - __asm volatile( "cpsie i" ); - } - else - { - /* Set the new reload value. */ - portNVIC_SYSTICK_LOAD_REG = ulReloadValue; - - /* Clear the SysTick count flag and set the count value back to - zero. */ - portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL; - - /* Restart SysTick. */ - portNVIC_SYSTICK_CTRL_REG |= portNVIC_SYSTICK_ENABLE_BIT; - - /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can - set its parameter to 0 to indicate that its implementation contains - its own wait for interrupt or wait for event instruction, and so wfi - should not be executed again. However, the original expected idle - time variable must remain unmodified, so a copy is taken. */ - xModifiableIdleTime = xExpectedIdleTime; - configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); - if( xModifiableIdleTime > 0 ) - { - __asm volatile( "dsb" ); - __asm volatile( "wfi" ); - __asm volatile( "isb" ); - } - configPOST_SLEEP_PROCESSING( xExpectedIdleTime ); - - /* Stop SysTick. Again, the time the SysTick is stopped for is - accounted for as best it can be, but using the tickless mode will - inevitably result in some tiny drift of the time maintained by the - kernel with respect to calendar time. */ - ulSysTickCTRL = portNVIC_SYSTICK_CTRL_REG; - portNVIC_SYSTICK_CTRL_REG = ( ulSysTickCTRL & ~portNVIC_SYSTICK_ENABLE_BIT ); - - /* Re-enable interrupts - see comments above the cpsid instruction() - above. */ - __asm volatile( "cpsie i" ); - - if( ( ulSysTickCTRL & portNVIC_SYSTICK_COUNT_FLAG_BIT ) != 0 ) - { - uint32_t ulCalculatedLoadValue; - - /* The tick interrupt has already executed, and the SysTick - count reloaded with ulReloadValue. Reset the - portNVIC_SYSTICK_LOAD_REG with whatever remains of this tick - period. */ - ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL ) - ( ulReloadValue - portNVIC_SYSTICK_CURRENT_VALUE_REG ); - - /* Don't allow a tiny value, or values that have somehow - underflowed because the post sleep hook did something - that took too long. */ - if( ( ulCalculatedLoadValue < ulStoppedTimerCompensation ) || ( ulCalculatedLoadValue > ulTimerCountsForOneTick ) ) - { - ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL ); - } - - portNVIC_SYSTICK_LOAD_REG = ulCalculatedLoadValue; - - /* The tick interrupt handler will already have pended the tick - processing in the kernel. As the pending tick will be - processed as soon as this function exits, the tick value - maintained by the tick is stepped forward by one less than the - time spent waiting. */ - ulCompleteTickPeriods = xExpectedIdleTime - 1UL; - } - else - { - /* Something other than the tick interrupt ended the sleep. - Work out how long the sleep lasted rounded to complete tick - periods (not the ulReload value which accounted for part - ticks). */ - ulCompletedSysTickDecrements = ( xExpectedIdleTime * ulTimerCountsForOneTick ) - portNVIC_SYSTICK_CURRENT_VALUE_REG; - - /* How many complete tick periods passed while the processor - was waiting? */ - ulCompleteTickPeriods = ulCompletedSysTickDecrements / ulTimerCountsForOneTick; - - /* The reload value is set to whatever fraction of a single tick - period remains. */ - portNVIC_SYSTICK_LOAD_REG = ( ( ulCompleteTickPeriods + 1 ) * ulTimerCountsForOneTick ) - ulCompletedSysTickDecrements; - } - - /* Restart SysTick so it runs from portNVIC_SYSTICK_LOAD_REG - again, then set portNVIC_SYSTICK_LOAD_REG back to its standard - value. The critical section is used to ensure the tick interrupt - can only execute once in the case that the reload register is near - zero. */ - portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL; - portENTER_CRITICAL(); - { - portNVIC_SYSTICK_CTRL_REG |= portNVIC_SYSTICK_ENABLE_BIT; - vTaskStepTick( ulCompleteTickPeriods ); - portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL; - } - portEXIT_CRITICAL(); - } - } - -#endif /* #if configUSE_TICKLESS_IDLE */ -/*-----------------------------------------------------------*/ - -/* - * Setup the systick timer to generate the tick interrupts at the required - * frequency. - */ -__attribute__(( weak )) void vPortSetupTimerInterrupt( void ) -{ - /* Calculate the constants required to configure the tick interrupt. */ - #if configUSE_TICKLESS_IDLE == 1 - { - ulTimerCountsForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ); - xMaximumPossibleSuppressedTicks = portMAX_24_BIT_NUMBER / ulTimerCountsForOneTick; - ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ ); - } - #endif /* configUSE_TICKLESS_IDLE */ - - /* Configure SysTick to interrupt at the requested rate. */ - portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; - portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT ); -} -/*-----------------------------------------------------------*/ - -#if( configASSERT_DEFINED == 1 ) - - void vPortValidateInterruptPriority( void ) - { - uint32_t ulCurrentInterrupt; - uint8_t ucCurrentPriority; - - /* Obtain the number of the currently executing interrupt. */ - __asm volatile( "mrs %0, ipsr" : "=r"( ulCurrentInterrupt ) ); - - /* Is the interrupt number a user defined interrupt? */ - if( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER ) - { - /* Look up the interrupt's priority. */ - ucCurrentPriority = pcInterruptPriorityRegisters[ ulCurrentInterrupt ]; - - /* The following assertion will fail if a service routine (ISR) for - an interrupt that has been assigned a priority above - configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API - function. ISR safe FreeRTOS API functions must *only* be called - from interrupts that have been assigned a priority at or below - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - Numerically low interrupt priority numbers represent logically high - interrupt priorities, therefore the priority of the interrupt must - be set to a value equal to or numerically *higher* than - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - Interrupts that use the FreeRTOS API must not be left at their - default priority of zero as that is the highest possible priority, - which is guaranteed to be above configMAX_SYSCALL_INTERRUPT_PRIORITY, - and therefore also guaranteed to be invalid. - - FreeRTOS maintains separate thread and ISR API functions to ensure - interrupt entry is as fast and simple as possible. - - The following links provide detailed information: - http://www.freertos.org/RTOS-Cortex-M3-M4.html - http://www.freertos.org/FAQHelp.html */ - configASSERT( ucCurrentPriority >= ucMaxSysCallPriority ); - } - - /* Priority grouping: The interrupt controller (NVIC) allows the bits - that define each interrupt's priority to be split between bits that - define the interrupt's pre-emption priority bits and bits that define - the interrupt's sub-priority. For simplicity all bits must be defined - to be pre-emption priority bits. The following assertion will fail if - this is not the case (if some bits represent a sub-priority). - - If the application only uses CMSIS libraries for interrupt - configuration then the correct setting can be achieved on all Cortex-M - devices by calling NVIC_SetPriorityGrouping( 0 ); before starting the - scheduler. Note however that some vendor specific peripheral libraries - assume a non-zero priority group setting, in which cases using a value - of zero will result in unpredicable behaviour. */ - configASSERT( ( portAIRCR_REG & portPRIORITY_GROUP_MASK ) <= ulMaxPRIGROUPValue ); - } - -#endif /* configASSERT_DEFINED */ - - - - - - - - - - - - - - - - - - - - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/portable.h b/GD32F1/libraries/FreeRTOS821/utility/portable.h deleted file mode 100644 index cf6c614..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/portable.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/*----------------------------------------------------------- - * Portable layer API. Each function must be defined for each port. - *----------------------------------------------------------*/ - -#ifndef PORTABLE_H -#define PORTABLE_H - -/* Each FreeRTOS port has a unique portmacro.h header file. Originally a -pre-processor definition was used to ensure the pre-processor found the correct -portmacro.h file for the port being used. That scheme was deprecated in favour -of setting the compiler's include path such that it found the correct -portmacro.h file - removing the need for the constant and allowing the -portmacro.h file to be located anywhere in relation to the port being used. -Purely for reasons of backward compatibility the old method is still valid, but -to make it clear that new projects should not use it, support for the port -specific constants has been moved into the deprecated_definitions.h header -file. */ -#include "deprecated_definitions.h" - -/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h -did not result in a portmacro.h header file being included - and it should be -included here. In this case the path to the correct portmacro.h header file -must be set in the compiler's include path. */ -#ifndef portENTER_CRITICAL - #include "portmacro.h" -#endif - -#if portBYTE_ALIGNMENT == 8 - #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) -#endif - -#if portBYTE_ALIGNMENT == 4 - #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) -#endif - -#if portBYTE_ALIGNMENT == 2 - #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) -#endif - -#if portBYTE_ALIGNMENT == 1 - #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) -#endif - -#ifndef portBYTE_ALIGNMENT_MASK - #error "Invalid portBYTE_ALIGNMENT definition" -#endif - -#ifndef portNUM_CONFIGURABLE_REGIONS - #define portNUM_CONFIGURABLE_REGIONS 1 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include "mpu_wrappers.h" - -/* - * Setup the stack of a new task so it is ready to be placed under the - * scheduler control. The registers have to be placed on the stack in - * the order that the port expects to find them. - * - */ -#if( portUSING_MPU_WRAPPERS == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; -#else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; -#endif - -/* Used by heap_5.c. */ -typedef struct HeapRegion -{ - uint8_t *pucStartAddress; - size_t xSizeInBytes; -} HeapRegion_t; - -/* - * Used to define multiple heap regions for use by heap_5.c. This function - * must be called before any calls to pvPortMalloc() - not creating a task, - * queue, semaphore, mutex, software timer, event group, etc. will result in - * pvPortMalloc being called. - * - * pxHeapRegions passes in an array of HeapRegion_t structures - each of which - * defines a region of memory that can be used as the heap. The array is - * terminated by a HeapRegions_t structure that has a size of 0. The region - * with the lowest start address must appear first in the array. - */ -void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ); - - -/* - * Map to the memory management routines required for the port. - */ -void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; -void vPortFree( void *pv ) PRIVILEGED_FUNCTION; -void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; -size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; -size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; - -/* - * Setup the hardware ready for the scheduler to take control. This generally - * sets up a tick interrupt and sets timers for the correct tick frequency. - */ -BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; - -/* - * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so - * the hardware is left in its original condition after the scheduler stops - * executing. - */ -void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; - -/* - * The structures and methods of manipulating the MPU are contained within the - * port layer. - * - * Fills the xMPUSettings structure with the memory region information - * contained in xRegions. - */ -#if( portUSING_MPU_WRAPPERS == 1 ) - struct xMEMORY_REGION; - void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint16_t usStackDepth ) PRIVILEGED_FUNCTION; -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* PORTABLE_H */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/portmacro.h b/GD32F1/libraries/FreeRTOS821/utility/portmacro.h deleted file mode 100644 index 1d28ae7..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/portmacro.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*----------------------------------------------------------- - * Port specific definitions. - * - * The settings in this file configure FreeRTOS correctly for the - * given hardware and compiler. - * - * These settings should not be altered. - *----------------------------------------------------------- - */ - -/* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE uint32_t -#define portBASE_TYPE long - -typedef portSTACK_TYPE StackType_t; -typedef long BaseType_t; -typedef unsigned long UBaseType_t; - -#if( configUSE_16_BIT_TICKS == 1 ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff -#else - typedef uint32_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffffffffUL - - /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do - not need to be guarded with a critical section. */ - #define portTICK_TYPE_IS_ATOMIC 1 -#endif -/*-----------------------------------------------------------*/ - -/* Architecture specifics. */ -#define portSTACK_GROWTH ( -1 ) -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 8 -/*-----------------------------------------------------------*/ - - -/* Scheduler utilities. */ -extern void vPortYield( void ); -#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) ) -#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) -#define portYIELD() vPortYield() -#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT -#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) -/*-----------------------------------------------------------*/ - -/* Critical section management. */ -extern void vPortEnterCritical( void ); -extern void vPortExitCritical( void ); -extern uint32_t ulPortSetInterruptMask( void ); -extern void vPortClearInterruptMask( uint32_t ulNewMaskValue ); -#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetInterruptMask() -#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x) -#define portDISABLE_INTERRUPTS() ulPortSetInterruptMask() -#define portENABLE_INTERRUPTS() vPortClearInterruptMask(0) -#define portENTER_CRITICAL() vPortEnterCritical() -#define portEXIT_CRITICAL() vPortExitCritical() -/*-----------------------------------------------------------*/ - -/* Task function macros as described on the FreeRTOS.org WEB site. These are -not necessary for to use this port. They are defined so the common demo files -(which build with all the ports) will build. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) -#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) -/*-----------------------------------------------------------*/ - -/* Tickless idle/low power functionality. */ -#ifndef portSUPPRESS_TICKS_AND_SLEEP - extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); - #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime ) -#endif -/*-----------------------------------------------------------*/ - -/* Architecture specific optimisations. */ -#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION - #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 - - /* Generic helper function. */ - __attribute__( ( always_inline ) ) static inline uint8_t ucPortCountLeadingZeros( uint32_t ulBitmap ) - { - uint8_t ucReturn; - - __asm volatile ( "clz %0, %1" : "=r" ( ucReturn ) : "r" ( ulBitmap ) ); - return ucReturn; - } - - /* Check the configuration. */ - #if( configMAX_PRIORITIES > 32 ) - #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice. - #endif - - /* Store/clear the ready priorities in a bit map. */ - #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) ) - #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ) - - /*-----------------------------------------------------------*/ - - #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - ucPortCountLeadingZeros( ( uxReadyPriorities ) ) ) - -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -/*-----------------------------------------------------------*/ - -#ifdef configASSERT - void vPortValidateInterruptPriority( void ); - #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() -#endif - -/* portNOP() is not required by this port. */ -#define portNOP() - -#ifdef __cplusplus -} -#endif - -#endif /* PORTMACRO_H */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/projdefs.h b/GD32F1/libraries/FreeRTOS821/utility/projdefs.h deleted file mode 100644 index d975d57..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/projdefs.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef PROJDEFS_H -#define PROJDEFS_H - -/* - * Defines the prototype to which task functions must conform. Defined in this - * file to ensure the type is known before portable.h is included. - */ -typedef void (*TaskFunction_t)( void * ); - -/* Converts a time in milliseconds to a time in ticks. */ -#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) - -#define pdFALSE ( ( BaseType_t ) 0 ) -#define pdTRUE ( ( BaseType_t ) 1 ) - -#define pdPASS ( pdTRUE ) -#define pdFAIL ( pdFALSE ) -#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) -#define errQUEUE_FULL ( ( BaseType_t ) 0 ) - -/* FreeRTOS error definitions. */ -#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) -#define errQUEUE_BLOCKED ( -4 ) -#define errQUEUE_YIELD ( -5 ) - -/* Macros used for basic data corruption checks. */ -#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES - #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 -#endif - -#if( configUSE_16_BIT_TICKS == 1 ) - #define pdINTEGRITY_CHECK_VALUE 0x5a5a -#else - #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL -#endif - -/* The following endian values are used by FreeRTOS+ components, not FreeRTOS -itself. */ -#define pdFREERTOS_LITTLE_ENDIAN 0 -#define pdFREERTOS_BIG_ENDIAN 1 - -#endif /* PROJDEFS_H */ - - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/queue.c b/GD32F1/libraries/FreeRTOS821/utility/queue.c deleted file mode 100644 index f757b93..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/queue.c +++ /dev/null @@ -1,2612 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#include -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" - -#if ( configUSE_CO_ROUTINES == 1 ) - #include "croutine.h" -#endif - -/* Lint e961 and e750 are suppressed as a MISRA exception justified because the -MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the -header files above, but not in this file, in order to generate the correct -privileged Vs unprivileged linkage and placement. */ -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */ - - -/* Constants used with the xRxLock and xTxLock structure members. */ -#define queueUNLOCKED ( ( BaseType_t ) -1 ) -#define queueLOCKED_UNMODIFIED ( ( BaseType_t ) 0 ) - -/* When the Queue_t structure is used to represent a base queue its pcHead and -pcTail members are used as pointers into the queue storage area. When the -Queue_t structure is used to represent a mutex pcHead and pcTail pointers are -not necessary, and the pcHead pointer is set to NULL to indicate that the -pcTail pointer actually points to the mutex holder (if any). Map alternative -names to the pcHead and pcTail structure members to ensure the readability of -the code is maintained despite this dual use of two structure members. An -alternative implementation would be to use a union, but use of a union is -against the coding standard (although an exception to the standard has been -permitted where the dual use also significantly changes the type of the -structure member). */ -#define pxMutexHolder pcTail -#define uxQueueType pcHead -#define queueQUEUE_IS_MUTEX NULL - -/* Semaphores do not actually store or copy data, so have an item size of -zero. */ -#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 ) -#define queueMUTEX_GIVE_BLOCK_TIME ( ( TickType_t ) 0U ) - -#if( configUSE_PREEMPTION == 0 ) - /* If the cooperative scheduler is being used then a yield should not be - performed just because a higher priority task has been woken. */ - #define queueYIELD_IF_USING_PREEMPTION() -#else - #define queueYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API() -#endif - -/* - * Definition of the queue used by the scheduler. - * Items are queued by copy, not reference. See the following link for the - * rationale: http://www.freertos.org/Embedded-RTOS-Queues.html - */ -typedef struct QueueDefinition -{ - int8_t *pcHead; /*< Points to the beginning of the queue storage area. */ - int8_t *pcTail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */ - int8_t *pcWriteTo; /*< Points to the free next place in the storage area. */ - - union /* Use of a union is an exception to the coding standard to ensure two mutually exclusive structure members don't appear simultaneously (wasting RAM). */ - { - int8_t *pcReadFrom; /*< Points to the last place that a queued item was read from when the structure is used as a queue. */ - UBaseType_t uxRecursiveCallCount;/*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */ - } u; - - List_t xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */ - List_t xTasksWaitingToReceive; /*< List of tasks that are blocked waiting to read from this queue. Stored in priority order. */ - - volatile UBaseType_t uxMessagesWaiting;/*< The number of items currently in the queue. */ - UBaseType_t uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */ - UBaseType_t uxItemSize; /*< The size of each items that the queue will hold. */ - - volatile BaseType_t xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ - volatile BaseType_t xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxQueueNumber; - uint8_t ucQueueType; - #endif - - #if ( configUSE_QUEUE_SETS == 1 ) - struct QueueDefinition *pxQueueSetContainer; - #endif - -} xQUEUE; - -/* The old xQUEUE name is maintained above then typedefed to the new Queue_t -name below to enable the use of older kernel aware debuggers. */ -typedef xQUEUE Queue_t; - -/*-----------------------------------------------------------*/ - -/* - * The queue registry is just a means for kernel aware debuggers to locate - * queue structures. It has no other purpose so is an optional component. - */ -#if ( configQUEUE_REGISTRY_SIZE > 0 ) - - /* The type stored within the queue registry array. This allows a name - to be assigned to each queue making kernel aware debugging a little - more user friendly. */ - typedef struct QUEUE_REGISTRY_ITEM - { - const char *pcQueueName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - QueueHandle_t xHandle; - } xQueueRegistryItem; - - /* The old xQueueRegistryItem name is maintained above then typedefed to the - new xQueueRegistryItem name below to enable the use of older kernel aware - debuggers. */ - typedef xQueueRegistryItem QueueRegistryItem_t; - - /* The queue registry is simply an array of QueueRegistryItem_t structures. - The pcQueueName member of a structure being NULL is indicative of the - array position being vacant. */ - QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ]; - -#endif /* configQUEUE_REGISTRY_SIZE */ - -/* - * Unlocks a queue locked by a call to prvLockQueue. Locking a queue does not - * prevent an ISR from adding or removing items to the queue, but does prevent - * an ISR from removing tasks from the queue event lists. If an ISR finds a - * queue is locked it will instead increment the appropriate queue lock count - * to indicate that a task may require unblocking. When the queue in unlocked - * these lock counts are inspected, and the appropriate action taken. - */ -static void prvUnlockQueue( Queue_t * const pxQueue ) PRIVILEGED_FUNCTION; - -/* - * Uses a critical section to determine if there is any data in a queue. - * - * @return pdTRUE if the queue contains no items, otherwise pdFALSE. - */ -static BaseType_t prvIsQueueEmpty( const Queue_t *pxQueue ) PRIVILEGED_FUNCTION; - -/* - * Uses a critical section to determine if there is any space in a queue. - * - * @return pdTRUE if there is no space, otherwise pdFALSE; - */ -static BaseType_t prvIsQueueFull( const Queue_t *pxQueue ) PRIVILEGED_FUNCTION; - -/* - * Copies an item into the queue, either at the front of the queue or the - * back of the queue. - */ -static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition ) PRIVILEGED_FUNCTION; - -/* - * Copies an item out of a queue. - */ -static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION; - -#if ( configUSE_QUEUE_SETS == 1 ) - /* - * Checks to see if a queue is a member of a queue set, and if so, notifies - * the queue set that the queue contains data. - */ - static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; -#endif - -/*-----------------------------------------------------------*/ - -/* - * Macro to mark a queue as locked. Locking a queue prevents an ISR from - * accessing the queue event lists. - */ -#define prvLockQueue( pxQueue ) \ - taskENTER_CRITICAL(); \ - { \ - if( ( pxQueue )->xRxLock == queueUNLOCKED ) \ - { \ - ( pxQueue )->xRxLock = queueLOCKED_UNMODIFIED; \ - } \ - if( ( pxQueue )->xTxLock == queueUNLOCKED ) \ - { \ - ( pxQueue )->xTxLock = queueLOCKED_UNMODIFIED; \ - } \ - } \ - taskEXIT_CRITICAL() -/*-----------------------------------------------------------*/ - -BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) -{ -Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - - taskENTER_CRITICAL(); - { - pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); - pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; - pxQueue->pcWriteTo = pxQueue->pcHead; - pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( UBaseType_t ) 1U ) * pxQueue->uxItemSize ); - pxQueue->xRxLock = queueUNLOCKED; - pxQueue->xTxLock = queueUNLOCKED; - - if( xNewQueue == pdFALSE ) - { - /* If there are tasks blocked waiting to read from the queue, then - the tasks will remain blocked as after this function exits the queue - will still be empty. If there are tasks blocked waiting to write to - the queue, then one should be unblocked as after this function exits - it will be possible to write to it. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) - { - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* Ensure the event queues start in the correct state. */ - vListInitialise( &( pxQueue->xTasksWaitingToSend ) ); - vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); - } - } - taskEXIT_CRITICAL(); - - /* A value is returned for calling semantic consistency with previous - versions. */ - return pdPASS; -} -/*-----------------------------------------------------------*/ - -QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) -{ -Queue_t *pxNewQueue; -size_t xQueueSizeInBytes; -QueueHandle_t xReturn = NULL; -int8_t *pcAllocatedBuffer; - - /* Remove compiler warnings about unused parameters should - configUSE_TRACE_FACILITY not be set to 1. */ - ( void ) ucQueueType; - - configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); - - if( uxItemSize == ( UBaseType_t ) 0 ) - { - /* There is not going to be a queue storage area. */ - xQueueSizeInBytes = ( size_t ) 0; - } - else - { - /* The queue is one byte longer than asked for to make wrap checking - easier/faster. */ - xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - } - - /* Allocate the new queue structure and storage area. */ - pcAllocatedBuffer = ( int8_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); - - if( pcAllocatedBuffer != NULL ) - { - pxNewQueue = ( Queue_t * ) pcAllocatedBuffer; /*lint !e826 MISRA The buffer cannot be too small because it was dimensioned by sizeof( Queue_t ) + xQueueSizeInBytes. */ - - if( uxItemSize == ( UBaseType_t ) 0 ) - { - /* No RAM was allocated for the queue storage area, but PC head - cannot be set to NULL because NULL is used as a key to say the queue - is used as a mutex. Therefore just set pcHead to point to the queue - as a benign value that is known to be within the memory map. */ - pxNewQueue->pcHead = ( int8_t * ) pxNewQueue; - } - else - { - /* Jump past the queue structure to find the location of the queue - storage area - adding the padding bytes to get a better alignment. */ - pxNewQueue->pcHead = pcAllocatedBuffer + sizeof( Queue_t ); - } - - /* Initialise the queue members as described above where the queue type - is defined. */ - pxNewQueue->uxLength = uxQueueLength; - pxNewQueue->uxItemSize = uxItemSize; - ( void ) xQueueGenericReset( pxNewQueue, pdTRUE ); - - #if ( configUSE_TRACE_FACILITY == 1 ) - { - pxNewQueue->ucQueueType = ucQueueType; - } - #endif /* configUSE_TRACE_FACILITY */ - - #if( configUSE_QUEUE_SETS == 1 ) - { - pxNewQueue->pxQueueSetContainer = NULL; - } - #endif /* configUSE_QUEUE_SETS */ - - traceQUEUE_CREATE( pxNewQueue ); - xReturn = pxNewQueue; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - configASSERT( xReturn ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_MUTEXES == 1 ) - - QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) - { - Queue_t *pxNewQueue; - - /* Prevent compiler warnings about unused parameters if - configUSE_TRACE_FACILITY does not equal 1. */ - ( void ) ucQueueType; - - /* Allocate the new queue structure. */ - pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) ); - if( pxNewQueue != NULL ) - { - /* Information required for priority inheritance. */ - pxNewQueue->pxMutexHolder = NULL; - pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX; - - /* Queues used as a mutex no data is actually copied into or out - of the queue. */ - pxNewQueue->pcWriteTo = NULL; - pxNewQueue->u.pcReadFrom = NULL; - - /* Each mutex has a length of 1 (like a binary semaphore) and - an item size of 0 as nothing is actually copied into or out - of the mutex. */ - pxNewQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; - pxNewQueue->uxLength = ( UBaseType_t ) 1U; - pxNewQueue->uxItemSize = ( UBaseType_t ) 0U; - pxNewQueue->xRxLock = queueUNLOCKED; - pxNewQueue->xTxLock = queueUNLOCKED; - - #if ( configUSE_TRACE_FACILITY == 1 ) - { - pxNewQueue->ucQueueType = ucQueueType; - } - #endif - - #if ( configUSE_QUEUE_SETS == 1 ) - { - pxNewQueue->pxQueueSetContainer = NULL; - } - #endif - - /* Ensure the event queues start with the correct state. */ - vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) ); - vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) ); - - traceCREATE_MUTEX( pxNewQueue ); - - /* Start with the semaphore in the expected state. */ - ( void ) xQueueGenericSend( pxNewQueue, NULL, ( TickType_t ) 0U, queueSEND_TO_BACK ); - } - else - { - traceCREATE_MUTEX_FAILED(); - } - - configASSERT( pxNewQueue ); - return pxNewQueue; - } - -#endif /* configUSE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) - - void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) - { - void *pxReturn; - - /* This function is called by xSemaphoreGetMutexHolder(), and should not - be called directly. Note: This is a good way of determining if the - calling task is the mutex holder, but not a good way of determining the - identity of the mutex holder, as the holder may change between the - following critical section exiting and the function returning. */ - taskENTER_CRITICAL(); - { - if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX ) - { - pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder; - } - else - { - pxReturn = NULL; - } - } - taskEXIT_CRITICAL(); - - return pxReturn; - } /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */ - -#endif -/*-----------------------------------------------------------*/ - -#if ( configUSE_RECURSIVE_MUTEXES == 1 ) - - BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) - { - BaseType_t xReturn; - Queue_t * const pxMutex = ( Queue_t * ) xMutex; - - configASSERT( pxMutex ); - - /* If this is the task that holds the mutex then pxMutexHolder will not - change outside of this task. If this task does not hold the mutex then - pxMutexHolder can never coincidentally equal the tasks handle, and as - this is the only condition we are interested in it does not matter if - pxMutexHolder is accessed simultaneously by another task. Therefore no - mutual exclusion is required to test the pxMutexHolder variable. */ - if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as TaskHandle_t is a typedef. */ - { - traceGIVE_MUTEX_RECURSIVE( pxMutex ); - - /* uxRecursiveCallCount cannot be zero if pxMutexHolder is equal to - the task handle, therefore no underflow check is required. Also, - uxRecursiveCallCount is only modified by the mutex holder, and as - there can only be one, no mutual exclusion is required to modify the - uxRecursiveCallCount member. */ - ( pxMutex->u.uxRecursiveCallCount )--; - - /* Have we unwound the call count? */ - if( pxMutex->u.uxRecursiveCallCount == ( UBaseType_t ) 0 ) - { - /* Return the mutex. This will automatically unblock any other - task that might be waiting to access the mutex. */ - ( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - xReturn = pdPASS; - } - else - { - /* The mutex cannot be given because the calling task is not the - holder. */ - xReturn = pdFAIL; - - traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ); - } - - return xReturn; - } - -#endif /* configUSE_RECURSIVE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_RECURSIVE_MUTEXES == 1 ) - - BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) - { - BaseType_t xReturn; - Queue_t * const pxMutex = ( Queue_t * ) xMutex; - - configASSERT( pxMutex ); - - /* Comments regarding mutual exclusion as per those within - xQueueGiveMutexRecursive(). */ - - traceTAKE_MUTEX_RECURSIVE( pxMutex ); - - if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */ - { - ( pxMutex->u.uxRecursiveCallCount )++; - xReturn = pdPASS; - } - else - { - xReturn = xQueueGenericReceive( pxMutex, NULL, xTicksToWait, pdFALSE ); - - /* pdPASS will only be returned if the mutex was successfully - obtained. The calling task may have entered the Blocked state - before reaching here. */ - if( xReturn == pdPASS ) - { - ( pxMutex->u.uxRecursiveCallCount )++; - } - else - { - traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ); - } - } - - return xReturn; - } - -#endif /* configUSE_RECURSIVE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_COUNTING_SEMAPHORES == 1 ) - - QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) - { - QueueHandle_t xHandle; - - configASSERT( uxMaxCount != 0 ); - configASSERT( uxInitialCount <= uxMaxCount ); - - xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); - - if( xHandle != NULL ) - { - ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; - - traceCREATE_COUNTING_SEMAPHORE(); - } - else - { - traceCREATE_COUNTING_SEMAPHORE_FAILED(); - } - - configASSERT( xHandle ); - return xHandle; - } - -#endif /* configUSE_COUNTING_SEMAPHORES */ -/*-----------------------------------------------------------*/ - -BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) -{ -BaseType_t xEntryTimeSet = pdFALSE, xYieldRequired; -TimeOut_t xTimeOut; -Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) ); - #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) - { - configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); - } - #endif - - - /* This function relaxes the coding standard somewhat to allow return - statements within the function itself. This is done in the interest - of execution time efficiency. */ - for( ;; ) - { - taskENTER_CRITICAL(); - { - /* Is there room on the queue now? The running task must be the - highest priority task wanting to access the queue. If the head item - in the queue is to be overwritten then it does not matter if the - queue is full. */ - if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) - { - traceQUEUE_SEND( pxQueue ); - xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); - - #if ( configUSE_QUEUE_SETS == 1 ) - { - if( pxQueue->pxQueueSetContainer != NULL ) - { - if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE ) - { - /* The queue is a member of a queue set, and posting - to the queue set caused a higher priority task to - unblock. A context switch is required. */ - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* If there was a task waiting for data to arrive on the - queue then unblock it now. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE ) - { - /* The unblocked task has a priority higher than - our own so yield immediately. Yes it is ok to - do this from within the critical section - the - kernel takes care of that. */ - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else if( xYieldRequired != pdFALSE ) - { - /* This path is a special case that will only get - executed if the task was holding multiple mutexes - and the mutexes were given back in an order that is - different to that in which they were taken. */ - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - #else /* configUSE_QUEUE_SETS */ - { - /* If there was a task waiting for data to arrive on the - queue then unblock it now. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE ) - { - /* The unblocked task has a priority higher than - our own so yield immediately. Yes it is ok to do - this from within the critical section - the kernel - takes care of that. */ - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else if( xYieldRequired != pdFALSE ) - { - /* This path is a special case that will only get - executed if the task was holding multiple mutexes and - the mutexes were given back in an order that is - different to that in which they were taken. */ - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_QUEUE_SETS */ - - taskEXIT_CRITICAL(); - return pdPASS; - } - else - { - if( xTicksToWait == ( TickType_t ) 0 ) - { - /* The queue was full and no block time is specified (or - the block time has expired) so leave now. */ - taskEXIT_CRITICAL(); - - /* Return to the original privilege level before exiting - the function. */ - traceQUEUE_SEND_FAILED( pxQueue ); - return errQUEUE_FULL; - } - else if( xEntryTimeSet == pdFALSE ) - { - /* The queue was full and a block time was specified so - configure the timeout structure. */ - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - else - { - /* Entry time was already set. */ - mtCOVERAGE_TEST_MARKER(); - } - } - } - taskEXIT_CRITICAL(); - - /* Interrupts and other tasks can send to and receive from the queue - now the critical section has been exited. */ - - vTaskSuspendAll(); - prvLockQueue( pxQueue ); - - /* Update the timeout state to see if it has expired yet. */ - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if( prvIsQueueFull( pxQueue ) != pdFALSE ) - { - traceBLOCKING_ON_QUEUE_SEND( pxQueue ); - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); - - /* Unlocking the queue means queue events can effect the - event list. It is possible that interrupts occurring now - remove this task from the event list again - but as the - scheduler is suspended the task will go onto the pending - ready last instead of the actual ready list. */ - prvUnlockQueue( pxQueue ); - - /* Resuming the scheduler will move tasks from the pending - ready list into the ready list - so it is feasible that this - task is already in a ready list before it yields - in which - case the yield will not cause a context switch unless there - is also a higher priority task in the pending ready list. */ - if( xTaskResumeAll() == pdFALSE ) - { - portYIELD_WITHIN_API(); - } - } - else - { - /* Try again. */ - prvUnlockQueue( pxQueue ); - ( void ) xTaskResumeAll(); - } - } - else - { - /* The timeout has expired. */ - prvUnlockQueue( pxQueue ); - ( void ) xTaskResumeAll(); - - /* Return to the original privilege level before exiting the - function. */ - traceQUEUE_SEND_FAILED( pxQueue ); - return errQUEUE_FULL; - } - } -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_ALTERNATIVE_API == 1 ) - - BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ) - { - BaseType_t xEntryTimeSet = pdFALSE; - TimeOut_t xTimeOut; - Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - - for( ;; ) - { - taskENTER_CRITICAL(); - { - /* Is there room on the queue now? To be running we must be - the highest priority task wanting to access the queue. */ - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - traceQUEUE_SEND( pxQueue ); - prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); - - /* If there was a task waiting for data to arrive on the - queue then unblock it now. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE ) - { - /* The unblocked task has a priority higher than - our own so yield immediately. */ - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - taskEXIT_CRITICAL(); - return pdPASS; - } - else - { - if( xTicksToWait == ( TickType_t ) 0 ) - { - taskEXIT_CRITICAL(); - return errQUEUE_FULL; - } - else if( xEntryTimeSet == pdFALSE ) - { - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - } - } - taskEXIT_CRITICAL(); - - taskENTER_CRITICAL(); - { - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if( prvIsQueueFull( pxQueue ) != pdFALSE ) - { - traceBLOCKING_ON_QUEUE_SEND( pxQueue ); - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - taskEXIT_CRITICAL(); - traceQUEUE_SEND_FAILED( pxQueue ); - return errQUEUE_FULL; - } - } - taskEXIT_CRITICAL(); - } - } - -#endif /* configUSE_ALTERNATIVE_API */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_ALTERNATIVE_API == 1 ) - - BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking ) - { - BaseType_t xEntryTimeSet = pdFALSE; - TimeOut_t xTimeOut; - int8_t *pcOriginalReadPosition; - Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - - for( ;; ) - { - taskENTER_CRITICAL(); - { - if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) - { - /* Remember our read position in case we are just peeking. */ - pcOriginalReadPosition = pxQueue->u.pcReadFrom; - - prvCopyDataFromQueue( pxQueue, pvBuffer ); - - if( xJustPeeking == pdFALSE ) - { - traceQUEUE_RECEIVE( pxQueue ); - - /* Data is actually being removed (not just peeked). */ - --( pxQueue->uxMessagesWaiting ); - - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - /* Record the information required to implement - priority inheritance should it become necessary. */ - pxQueue->pxMutexHolder = ( int8_t * ) xTaskGetCurrentTaskHandle(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif - - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) - { - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - else - { - traceQUEUE_PEEK( pxQueue ); - - /* The data is not being removed, so reset our read - pointer. */ - pxQueue->u.pcReadFrom = pcOriginalReadPosition; - - /* The data is being left in the queue, so see if there are - any other tasks waiting for the data. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority than this task. */ - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - taskEXIT_CRITICAL(); - return pdPASS; - } - else - { - if( xTicksToWait == ( TickType_t ) 0 ) - { - taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - else if( xEntryTimeSet == pdFALSE ) - { - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - } - } - taskEXIT_CRITICAL(); - - taskENTER_CRITICAL(); - { - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) - { - traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); - - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - taskENTER_CRITICAL(); - { - vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); - } - taskEXIT_CRITICAL(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif - - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - } - taskEXIT_CRITICAL(); - } - } - - -#endif /* configUSE_ALTERNATIVE_API */ -/*-----------------------------------------------------------*/ - -BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) -{ -BaseType_t xReturn; -UBaseType_t uxSavedInterruptStatus; -Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) ); - - /* RTOS ports that support interrupt nesting have the concept of a maximum - system call (or maximum API call) interrupt priority. Interrupts that are - above the maximum system call priority are kept permanently enabled, even - when the RTOS kernel is in a critical section, but cannot make any calls to - FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h - then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has been - assigned a priority above the configured maximum system call priority. - Only FreeRTOS functions that end in FromISR can be called from interrupts - that have been assigned a priority at or (logically) below the maximum - system call interrupt priority. FreeRTOS maintains a separate interrupt - safe API to ensure interrupt entry is as fast and as simple as possible. - More information (albeit Cortex-M specific) is provided on the following - link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - /* Similar to xQueueGenericSend, except without blocking if there is no room - in the queue. Also don't directly wake a task that was blocked on a queue - read, instead return a flag to say whether a context switch is required or - not (i.e. has a task with a higher priority than us been woken by this - post). */ - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) - { - traceQUEUE_SEND_FROM_ISR( pxQueue ); - - /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a - semaphore or mutex. That means prvCopyDataToQueue() cannot result - in a task disinheriting a priority and prvCopyDataToQueue() can be - called here even though the disinherit function does not check if - the scheduler is suspended before accessing the ready lists. */ - ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); - - /* The event list is not altered if the queue is locked. This will - be done when the queue is unlocked later. */ - if( pxQueue->xTxLock == queueUNLOCKED ) - { - #if ( configUSE_QUEUE_SETS == 1 ) - { - if( pxQueue->pxQueueSetContainer != NULL ) - { - if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE ) - { - /* The queue is a member of a queue set, and posting - to the queue set caused a higher priority task to - unblock. A context switch is required. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so - record that a context switch is required. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - #else /* configUSE_QUEUE_SETS */ - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so record that a - context switch is required. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_QUEUE_SETS */ - } - else - { - /* Increment the lock count so the task that unlocks the queue - knows that data was posted while it was locked. */ - ++( pxQueue->xTxLock ); - } - - xReturn = pdPASS; - } - else - { - traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); - xReturn = errQUEUE_FULL; - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) -{ -BaseType_t xReturn; -UBaseType_t uxSavedInterruptStatus; -Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - /* Similar to xQueueGenericSendFromISR() but used with semaphores where the - item size is 0. Don't directly wake a task that was blocked on a queue - read, instead return a flag to say whether a context switch is required or - not (i.e. has a task with a higher priority than us been woken by this - post). */ - - configASSERT( pxQueue ); - - /* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR() - if the item size is not 0. */ - configASSERT( pxQueue->uxItemSize == 0 ); - - /* Normally a mutex would not be given from an interrupt, and doing so is - definitely wrong if there is a mutex holder as priority inheritance makes no - sense for an interrupts, only tasks. */ - configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) ); - - /* RTOS ports that support interrupt nesting have the concept of a maximum - system call (or maximum API call) interrupt priority. Interrupts that are - above the maximum system call priority are kept permanently enabled, even - when the RTOS kernel is in a critical section, but cannot make any calls to - FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h - then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has been - assigned a priority above the configured maximum system call priority. - Only FreeRTOS functions that end in FromISR can be called from interrupts - that have been assigned a priority at or (logically) below the maximum - system call interrupt priority. FreeRTOS maintains a separate interrupt - safe API to ensure interrupt entry is as fast and as simple as possible. - More information (albeit Cortex-M specific) is provided on the following - link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - /* When the queue is used to implement a semaphore no data is ever - moved through the queue but it is still valid to see if the queue 'has - space'. */ - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - traceQUEUE_SEND_FROM_ISR( pxQueue ); - - /* A task can only have an inherited priority if it is a mutex - holder - and if there is a mutex holder then the mutex cannot be - given from an ISR. As this is the ISR version of the function it - can be assumed there is no mutex holder and no need to determine if - priority disinheritance is needed. Simply increase the count of - messages (semaphores) available. */ - ++( pxQueue->uxMessagesWaiting ); - - /* The event list is not altered if the queue is locked. This will - be done when the queue is unlocked later. */ - if( pxQueue->xTxLock == queueUNLOCKED ) - { - #if ( configUSE_QUEUE_SETS == 1 ) - { - if( pxQueue->pxQueueSetContainer != NULL ) - { - if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE ) - { - /* The semaphore is a member of a queue set, and - posting to the queue set caused a higher priority - task to unblock. A context switch is required. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so - record that a context switch is required. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - #else /* configUSE_QUEUE_SETS */ - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so record that a - context switch is required. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_QUEUE_SETS */ - } - else - { - /* Increment the lock count so the task that unlocks the queue - knows that data was posted while it was locked. */ - ++( pxQueue->xTxLock ); - } - - xReturn = pdPASS; - } - else - { - traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); - xReturn = errQUEUE_FULL; - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeeking ) -{ -BaseType_t xEntryTimeSet = pdFALSE; -TimeOut_t xTimeOut; -int8_t *pcOriginalReadPosition; -Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) - { - configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); - } - #endif - - /* This function relaxes the coding standard somewhat to allow return - statements within the function itself. This is done in the interest - of execution time efficiency. */ - - for( ;; ) - { - taskENTER_CRITICAL(); - { - /* Is there data in the queue now? To be running the calling task - must be the highest priority task wanting to access the queue. */ - if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) - { - /* Remember the read position in case the queue is only being - peeked. */ - pcOriginalReadPosition = pxQueue->u.pcReadFrom; - - prvCopyDataFromQueue( pxQueue, pvBuffer ); - - if( xJustPeeking == pdFALSE ) - { - traceQUEUE_RECEIVE( pxQueue ); - - /* Actually removing data, not just peeking. */ - --( pxQueue->uxMessagesWaiting ); - - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - /* Record the information required to implement - priority inheritance should it become necessary. */ - pxQueue->pxMutexHolder = ( int8_t * ) pvTaskIncrementMutexHeldCount(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */ - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_MUTEXES */ - - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) - { - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - traceQUEUE_PEEK( pxQueue ); - - /* The data is not being removed, so reset the read - pointer. */ - pxQueue->u.pcReadFrom = pcOriginalReadPosition; - - /* The data is being left in the queue, so see if there are - any other tasks waiting for the data. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority than this task. */ - queueYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - taskEXIT_CRITICAL(); - return pdPASS; - } - else - { - if( xTicksToWait == ( TickType_t ) 0 ) - { - /* The queue was empty and no block time is specified (or - the block time has expired) so leave now. */ - taskEXIT_CRITICAL(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - else if( xEntryTimeSet == pdFALSE ) - { - /* The queue was empty and a block time was specified so - configure the timeout structure. */ - vTaskSetTimeOutState( &xTimeOut ); - xEntryTimeSet = pdTRUE; - } - else - { - /* Entry time was already set. */ - mtCOVERAGE_TEST_MARKER(); - } - } - } - taskEXIT_CRITICAL(); - - /* Interrupts and other tasks can send to and receive from the queue - now the critical section has been exited. */ - - vTaskSuspendAll(); - prvLockQueue( pxQueue ); - - /* Update the timeout state to see if it has expired yet. */ - if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ) - { - if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) - { - traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); - - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - taskENTER_CRITICAL(); - { - vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder ); - } - taskEXIT_CRITICAL(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif - - vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); - prvUnlockQueue( pxQueue ); - if( xTaskResumeAll() == pdFALSE ) - { - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* Try again. */ - prvUnlockQueue( pxQueue ); - ( void ) xTaskResumeAll(); - } - } - else - { - prvUnlockQueue( pxQueue ); - ( void ) xTaskResumeAll(); - traceQUEUE_RECEIVE_FAILED( pxQueue ); - return errQUEUE_EMPTY; - } - } -} -/*-----------------------------------------------------------*/ - -BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) -{ -BaseType_t xReturn; -UBaseType_t uxSavedInterruptStatus; -Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - - /* RTOS ports that support interrupt nesting have the concept of a maximum - system call (or maximum API call) interrupt priority. Interrupts that are - above the maximum system call priority are kept permanently enabled, even - when the RTOS kernel is in a critical section, but cannot make any calls to - FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h - then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has been - assigned a priority above the configured maximum system call priority. - Only FreeRTOS functions that end in FromISR can be called from interrupts - that have been assigned a priority at or (logically) below the maximum - system call interrupt priority. FreeRTOS maintains a separate interrupt - safe API to ensure interrupt entry is as fast and as simple as possible. - More information (albeit Cortex-M specific) is provided on the following - link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - /* Cannot block in an ISR, so check there is data available. */ - if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) - { - traceQUEUE_RECEIVE_FROM_ISR( pxQueue ); - - prvCopyDataFromQueue( pxQueue, pvBuffer ); - --( pxQueue->uxMessagesWaiting ); - - /* If the queue is locked the event list will not be modified. - Instead update the lock count so the task that unlocks the queue - will know that an ISR has removed data while the queue was - locked. */ - if( pxQueue->xRxLock == queueUNLOCKED ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) - { - /* The task waiting has a higher priority than us so - force a context switch. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* Increment the lock count so the task that unlocks the queue - knows that data was removed while it was locked. */ - ++( pxQueue->xRxLock ); - } - - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ); - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) -{ -BaseType_t xReturn; -UBaseType_t uxSavedInterruptStatus; -int8_t *pcOriginalReadPosition; -Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); - configASSERT( pxQueue->uxItemSize != 0 ); /* Can't peek a semaphore. */ - - /* RTOS ports that support interrupt nesting have the concept of a maximum - system call (or maximum API call) interrupt priority. Interrupts that are - above the maximum system call priority are kept permanently enabled, even - when the RTOS kernel is in a critical section, but cannot make any calls to - FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h - then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has been - assigned a priority above the configured maximum system call priority. - Only FreeRTOS functions that end in FromISR can be called from interrupts - that have been assigned a priority at or (logically) below the maximum - system call interrupt priority. FreeRTOS maintains a separate interrupt - safe API to ensure interrupt entry is as fast and as simple as possible. - More information (albeit Cortex-M specific) is provided on the following - link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - /* Cannot block in an ISR, so check there is data available. */ - if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) - { - traceQUEUE_PEEK_FROM_ISR( pxQueue ); - - /* Remember the read position so it can be reset as nothing is - actually being removed from the queue. */ - pcOriginalReadPosition = pxQueue->u.pcReadFrom; - prvCopyDataFromQueue( pxQueue, pvBuffer ); - pxQueue->u.pcReadFrom = pcOriginalReadPosition; - - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ); - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) -{ -UBaseType_t uxReturn; - - configASSERT( xQueue ); - - taskENTER_CRITICAL(); - { - uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting; - } - taskEXIT_CRITICAL(); - - return uxReturn; -} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */ -/*-----------------------------------------------------------*/ - -UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) -{ -UBaseType_t uxReturn; -Queue_t *pxQueue; - - pxQueue = ( Queue_t * ) xQueue; - configASSERT( pxQueue ); - - taskENTER_CRITICAL(); - { - uxReturn = pxQueue->uxLength - pxQueue->uxMessagesWaiting; - } - taskEXIT_CRITICAL(); - - return uxReturn; -} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */ -/*-----------------------------------------------------------*/ - -UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) -{ -UBaseType_t uxReturn; - - configASSERT( xQueue ); - - uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting; - - return uxReturn; -} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */ -/*-----------------------------------------------------------*/ - -void vQueueDelete( QueueHandle_t xQueue ) -{ -Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - configASSERT( pxQueue ); - - traceQUEUE_DELETE( pxQueue ); - #if ( configQUEUE_REGISTRY_SIZE > 0 ) - { - vQueueUnregisterQueue( pxQueue ); - } - #endif - vPortFree( pxQueue ); -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) - { - return ( ( Queue_t * ) xQueue )->uxQueueNumber; - } - -#endif /* configUSE_TRACE_FACILITY */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) - { - ( ( Queue_t * ) xQueue )->uxQueueNumber = uxQueueNumber; - } - -#endif /* configUSE_TRACE_FACILITY */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) - { - return ( ( Queue_t * ) xQueue )->ucQueueType; - } - -#endif /* configUSE_TRACE_FACILITY */ -/*-----------------------------------------------------------*/ - -static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition ) -{ -BaseType_t xReturn = pdFALSE; - - if( pxQueue->uxItemSize == ( UBaseType_t ) 0 ) - { - #if ( configUSE_MUTEXES == 1 ) - { - if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) - { - /* The mutex is no longer being held. */ - xReturn = xTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder ); - pxQueue->pxMutexHolder = NULL; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_MUTEXES */ - } - else if( xPosition == queueSEND_TO_BACK ) - { - ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports, plus previous logic ensures a null pointer can only be passed to memcpy() if the copy size is 0. */ - pxQueue->pcWriteTo += pxQueue->uxItemSize; - if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ - { - pxQueue->pcWriteTo = pxQueue->pcHead; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - ( void ) memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - pxQueue->u.pcReadFrom -= pxQueue->uxItemSize; - if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */ - { - pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - if( xPosition == queueOVERWRITE ) - { - if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) - { - /* An item is not being added but overwritten, so subtract - one from the recorded number of items in the queue so when - one is added again below the number of recorded items remains - correct. */ - --( pxQueue->uxMessagesWaiting ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - ++( pxQueue->uxMessagesWaiting ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer ) -{ - if( pxQueue->uxItemSize != ( UBaseType_t ) 0 ) - { - pxQueue->u.pcReadFrom += pxQueue->uxItemSize; - if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */ - { - pxQueue->u.pcReadFrom = pxQueue->pcHead; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports. Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. */ - } -} -/*-----------------------------------------------------------*/ - -static void prvUnlockQueue( Queue_t * const pxQueue ) -{ - /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */ - - /* The lock counts contains the number of extra data items placed or - removed from the queue while the queue was locked. When a queue is - locked items can be added or removed, but the event lists cannot be - updated. */ - taskENTER_CRITICAL(); - { - /* See if data was added to the queue while it was locked. */ - while( pxQueue->xTxLock > queueLOCKED_UNMODIFIED ) - { - /* Data was posted while the queue was locked. Are any tasks - blocked waiting for data to become available? */ - #if ( configUSE_QUEUE_SETS == 1 ) - { - if( pxQueue->pxQueueSetContainer != NULL ) - { - if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE ) - { - /* The queue is a member of a queue set, and posting to - the queue set caused a higher priority task to unblock. - A context switch is required. */ - vTaskMissedYield(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so record that a - context switch is required. */ - vTaskMissedYield(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - break; - } - } - } - #else /* configUSE_QUEUE_SETS */ - { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority so record that a - context switch is required. */ - vTaskMissedYield(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - break; - } - } - #endif /* configUSE_QUEUE_SETS */ - - --( pxQueue->xTxLock ); - } - - pxQueue->xTxLock = queueUNLOCKED; - } - taskEXIT_CRITICAL(); - - /* Do the same for the Rx lock. */ - taskENTER_CRITICAL(); - { - while( pxQueue->xRxLock > queueLOCKED_UNMODIFIED ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) - { - vTaskMissedYield(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - --( pxQueue->xRxLock ); - } - else - { - break; - } - } - - pxQueue->xRxLock = queueUNLOCKED; - } - taskEXIT_CRITICAL(); -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvIsQueueEmpty( const Queue_t *pxQueue ) -{ -BaseType_t xReturn; - - taskENTER_CRITICAL(); - { - if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - } - taskEXIT_CRITICAL(); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) -{ -BaseType_t xReturn; - - configASSERT( xQueue ); - if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( UBaseType_t ) 0 ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */ -/*-----------------------------------------------------------*/ - -static BaseType_t prvIsQueueFull( const Queue_t *pxQueue ) -{ -BaseType_t xReturn; - - taskENTER_CRITICAL(); - { - if( pxQueue->uxMessagesWaiting == pxQueue->uxLength ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - } - taskEXIT_CRITICAL(); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) -{ -BaseType_t xReturn; - - configASSERT( xQueue ); - if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( ( Queue_t * ) xQueue )->uxLength ) - { - xReturn = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_CO_ROUTINES == 1 ) - - BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait ) - { - BaseType_t xReturn; - Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - /* If the queue is already full we may have to block. A critical section - is required to prevent an interrupt removing something from the queue - between the check to see if the queue is full and blocking on the queue. */ - portDISABLE_INTERRUPTS(); - { - if( prvIsQueueFull( pxQueue ) != pdFALSE ) - { - /* The queue is full - do we want to block or just leave without - posting? */ - if( xTicksToWait > ( TickType_t ) 0 ) - { - /* As this is called from a coroutine we cannot block directly, but - return indicating that we need to block. */ - vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) ); - portENABLE_INTERRUPTS(); - return errQUEUE_BLOCKED; - } - else - { - portENABLE_INTERRUPTS(); - return errQUEUE_FULL; - } - } - } - portENABLE_INTERRUPTS(); - - portDISABLE_INTERRUPTS(); - { - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - /* There is room in the queue, copy the data into the queue. */ - prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); - xReturn = pdPASS; - - /* Were any co-routines waiting for data to become available? */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - /* In this instance the co-routine could be placed directly - into the ready list as we are within a critical section. - Instead the same pending ready list mechanism is used as if - the event were caused from within an interrupt. */ - if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The co-routine waiting has a higher priority so record - that a yield might be appropriate. */ - xReturn = errQUEUE_YIELD; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - xReturn = errQUEUE_FULL; - } - } - portENABLE_INTERRUPTS(); - - return xReturn; - } - -#endif /* configUSE_CO_ROUTINES */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_CO_ROUTINES == 1 ) - - BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait ) - { - BaseType_t xReturn; - Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - /* If the queue is already empty we may have to block. A critical section - is required to prevent an interrupt adding something to the queue - between the check to see if the queue is empty and blocking on the queue. */ - portDISABLE_INTERRUPTS(); - { - if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 ) - { - /* There are no messages in the queue, do we want to block or just - leave with nothing? */ - if( xTicksToWait > ( TickType_t ) 0 ) - { - /* As this is a co-routine we cannot block directly, but return - indicating that we need to block. */ - vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) ); - portENABLE_INTERRUPTS(); - return errQUEUE_BLOCKED; - } - else - { - portENABLE_INTERRUPTS(); - return errQUEUE_FULL; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - portENABLE_INTERRUPTS(); - - portDISABLE_INTERRUPTS(); - { - if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) - { - /* Data is available from the queue. */ - pxQueue->u.pcReadFrom += pxQueue->uxItemSize; - if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) - { - pxQueue->u.pcReadFrom = pxQueue->pcHead; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - --( pxQueue->uxMessagesWaiting ); - ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); - - xReturn = pdPASS; - - /* Were any co-routines waiting for space to become available? */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - /* In this instance the co-routine could be placed directly - into the ready list as we are within a critical section. - Instead the same pending ready list mechanism is used as if - the event were caused from within an interrupt. */ - if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) - { - xReturn = errQUEUE_YIELD; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - xReturn = pdFAIL; - } - } - portENABLE_INTERRUPTS(); - - return xReturn; - } - -#endif /* configUSE_CO_ROUTINES */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_CO_ROUTINES == 1 ) - - BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken ) - { - Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - /* Cannot block within an ISR so if there is no space on the queue then - exit without doing anything. */ - if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) - { - prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK ); - - /* We only want to wake one co-routine per ISR, so check that a - co-routine has not already been woken. */ - if( xCoRoutinePreviouslyWoken == pdFALSE ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) - { - return pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - return xCoRoutinePreviouslyWoken; - } - -#endif /* configUSE_CO_ROUTINES */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_CO_ROUTINES == 1 ) - - BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxCoRoutineWoken ) - { - BaseType_t xReturn; - Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - /* We cannot block from an ISR, so check there is data available. If - not then just leave without doing anything. */ - if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) - { - /* Copy the data from the queue. */ - pxQueue->u.pcReadFrom += pxQueue->uxItemSize; - if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) - { - pxQueue->u.pcReadFrom = pxQueue->pcHead; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - --( pxQueue->uxMessagesWaiting ); - ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize ); - - if( ( *pxCoRoutineWoken ) == pdFALSE ) - { - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) - { - if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) - { - *pxCoRoutineWoken = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - } - - return xReturn; - } - -#endif /* configUSE_CO_ROUTINES */ -/*-----------------------------------------------------------*/ - -#if ( configQUEUE_REGISTRY_SIZE > 0 ) - - void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - { - UBaseType_t ux; - - /* See if there is an empty space in the registry. A NULL name denotes - a free slot. */ - for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) - { - if( xQueueRegistry[ ux ].pcQueueName == NULL ) - { - /* Store the information on this queue. */ - xQueueRegistry[ ux ].pcQueueName = pcQueueName; - xQueueRegistry[ ux ].xHandle = xQueue; - - traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ); - break; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - -#endif /* configQUEUE_REGISTRY_SIZE */ -/*-----------------------------------------------------------*/ - -#if ( configQUEUE_REGISTRY_SIZE > 0 ) - - void vQueueUnregisterQueue( QueueHandle_t xQueue ) - { - UBaseType_t ux; - - /* See if the handle of the queue being unregistered in actually in the - registry. */ - for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) - { - if( xQueueRegistry[ ux ].xHandle == xQueue ) - { - /* Set the name to NULL to show that this slot if free again. */ - xQueueRegistry[ ux ].pcQueueName = NULL; - break; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - } /*lint !e818 xQueue could not be pointer to const because it is a typedef. */ - -#endif /* configQUEUE_REGISTRY_SIZE */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_TIMERS == 1 ) - - void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait ) - { - Queue_t * const pxQueue = ( Queue_t * ) xQueue; - - /* This function should not be called by application code hence the - 'Restricted' in its name. It is not part of the public API. It is - designed for use by kernel code, and has special calling requirements. - It can result in vListInsert() being called on a list that can only - possibly ever have one item in it, so the list will be fast, but even - so it should be called with the scheduler locked and not from a critical - section. */ - - /* Only do anything if there are no messages in the queue. This function - will not actually cause the task to block, just place it on a blocked - list. It will not block until the scheduler is unlocked - at which - time a yield will be performed. If an item is added to the queue while - the queue is locked, and the calling task blocks on the queue, then the - calling task will be immediately unblocked when the queue is unlocked. */ - prvLockQueue( pxQueue ); - if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U ) - { - /* There is nothing in the queue, block for the specified period. */ - vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - prvUnlockQueue( pxQueue ); - } - -#endif /* configUSE_TIMERS */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_QUEUE_SETS == 1 ) - - QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) - { - QueueSetHandle_t pxQueue; - - pxQueue = xQueueGenericCreate( uxEventQueueLength, sizeof( Queue_t * ), queueQUEUE_TYPE_SET ); - - return pxQueue; - } - -#endif /* configUSE_QUEUE_SETS */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_QUEUE_SETS == 1 ) - - BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) - { - BaseType_t xReturn; - - taskENTER_CRITICAL(); - { - if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL ) - { - /* Cannot add a queue/semaphore to more than one queue set. */ - xReturn = pdFAIL; - } - else if( ( ( Queue_t * ) xQueueOrSemaphore )->uxMessagesWaiting != ( UBaseType_t ) 0 ) - { - /* Cannot add a queue/semaphore to a queue set if there are already - items in the queue/semaphore. */ - xReturn = pdFAIL; - } - else - { - ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer = xQueueSet; - xReturn = pdPASS; - } - } - taskEXIT_CRITICAL(); - - return xReturn; - } - -#endif /* configUSE_QUEUE_SETS */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_QUEUE_SETS == 1 ) - - BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) - { - BaseType_t xReturn; - Queue_t * const pxQueueOrSemaphore = ( Queue_t * ) xQueueOrSemaphore; - - if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet ) - { - /* The queue was not a member of the set. */ - xReturn = pdFAIL; - } - else if( pxQueueOrSemaphore->uxMessagesWaiting != ( UBaseType_t ) 0 ) - { - /* It is dangerous to remove a queue from a set when the queue is - not empty because the queue set will still hold pending events for - the queue. */ - xReturn = pdFAIL; - } - else - { - taskENTER_CRITICAL(); - { - /* The queue is no longer contained in the set. */ - pxQueueOrSemaphore->pxQueueSetContainer = NULL; - } - taskEXIT_CRITICAL(); - xReturn = pdPASS; - } - - return xReturn; - } /*lint !e818 xQueueSet could not be declared as pointing to const as it is a typedef. */ - -#endif /* configUSE_QUEUE_SETS */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_QUEUE_SETS == 1 ) - - QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, TickType_t const xTicksToWait ) - { - QueueSetMemberHandle_t xReturn = NULL; - - ( void ) xQueueGenericReceive( ( QueueHandle_t ) xQueueSet, &xReturn, xTicksToWait, pdFALSE ); /*lint !e961 Casting from one typedef to another is not redundant. */ - return xReturn; - } - -#endif /* configUSE_QUEUE_SETS */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_QUEUE_SETS == 1 ) - - QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) - { - QueueSetMemberHandle_t xReturn = NULL; - - ( void ) xQueueReceiveFromISR( ( QueueHandle_t ) xQueueSet, &xReturn, NULL ); /*lint !e961 Casting from one typedef to another is not redundant. */ - return xReturn; - } - -#endif /* configUSE_QUEUE_SETS */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_QUEUE_SETS == 1 ) - - static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) - { - Queue_t *pxQueueSetContainer = pxQueue->pxQueueSetContainer; - BaseType_t xReturn = pdFALSE; - - /* This function must be called form a critical section. */ - - configASSERT( pxQueueSetContainer ); - configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ); - - if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ) - { - traceQUEUE_SEND( pxQueueSetContainer ); - - /* The data copied is the handle of the queue that contains data. */ - xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition ); - - if( pxQueueSetContainer->xTxLock == queueUNLOCKED ) - { - if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE ) - { - if( xTaskRemoveFromEventList( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) != pdFALSE ) - { - /* The task waiting has a higher priority. */ - xReturn = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - ( pxQueueSetContainer->xTxLock )++; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - return xReturn; - } - -#endif /* configUSE_QUEUE_SETS */ - - - - - - - - - - - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/queue.h b/GD32F1/libraries/FreeRTOS821/utility/queue.h deleted file mode 100644 index 09b62bb..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/queue.h +++ /dev/null @@ -1,1691 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -#ifndef QUEUE_H -#define QUEUE_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include queue.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Type by which queues are referenced. For example, a call to xQueueCreate() - * returns an QueueHandle_t variable that can then be used as a parameter to - * xQueueSend(), xQueueReceive(), etc. - */ -typedef void * QueueHandle_t; - -/** - * Type by which queue sets are referenced. For example, a call to - * xQueueCreateSet() returns an xQueueSet variable that can then be used as a - * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc. - */ -typedef void * QueueSetHandle_t; - -/** - * Queue sets can contain both queues and semaphores, so the - * QueueSetMemberHandle_t is defined as a type to be used where a parameter or - * return value can be either an QueueHandle_t or an SemaphoreHandle_t. - */ -typedef void * QueueSetMemberHandle_t; - -/* For internal use only. */ -#define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) -#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) -#define queueOVERWRITE ( ( BaseType_t ) 2 ) - -/* For internal use only. These definitions *must* match those in queue.c. */ -#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U ) -#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) -#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U ) -#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U ) -#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) -#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) - -/** - * queue. h - *
- QueueHandle_t xQueueCreate(
-							  UBaseType_t uxQueueLength,
-							  UBaseType_t uxItemSize
-						  );
- * 
- * - * Creates a new queue instance. This allocates the storage required by the - * new queue and returns a handle for the queue. - * - * @param uxQueueLength The maximum number of items that the queue can contain. - * - * @param uxItemSize The number of bytes each item in the queue will require. - * Items are queued by copy, not by reference, so this is the number of bytes - * that will be copied for each posted item. Each item on the queue must be - * the same size. - * - * @return If the queue is successfully create then a handle to the newly - * created queue is returned. If the queue cannot be created then 0 is - * returned. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- };
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-	if( xQueue1 == 0 )
-	{
-		// Queue was not created and must not be used.
-	}
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue2 == 0 )
-	{
-		// Queue was not created and must not be used.
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueCreate xQueueCreate - * \ingroup QueueManagement - */ -#define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( uxQueueLength, uxItemSize, queueQUEUE_TYPE_BASE ) - -/** - * queue. h - *
- BaseType_t xQueueSendToToFront(
-								   QueueHandle_t	xQueue,
-								   const void		*pvItemToQueue,
-								   TickType_t		xTicksToWait
-							   );
- * 
- * - * This is a macro that calls xQueueGenericSend(). - * - * Post an item to the front of a queue. The item is queued by copy, not by - * reference. This function must not be called from an interrupt service - * routine. See xQueueSendFromISR () for an alternative which may be used - * in an ISR. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for space to become available on the queue, should it already - * be full. The call will return immediately if this is set to 0 and the - * queue is full. The time is defined in tick periods so the constant - * portTICK_PERIOD_MS should be used to convert to real time if this is required. - * - * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- uint32_t ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an uint32_t.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend - * \ingroup QueueManagement - */ -#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) - -/** - * queue. h - *
- BaseType_t xQueueSendToBack(
-								   QueueHandle_t	xQueue,
-								   const void		*pvItemToQueue,
-								   TickType_t		xTicksToWait
-							   );
- * 
- * - * This is a macro that calls xQueueGenericSend(). - * - * Post an item to the back of a queue. The item is queued by copy, not by - * reference. This function must not be called from an interrupt service - * routine. See xQueueSendFromISR () for an alternative which may be used - * in an ISR. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for space to become available on the queue, should it already - * be full. The call will return immediately if this is set to 0 and the queue - * is full. The time is defined in tick periods so the constant - * portTICK_PERIOD_MS should be used to convert to real time if this is required. - * - * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- uint32_t ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an uint32_t.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend - * \ingroup QueueManagement - */ -#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) - -/** - * queue. h - *
- BaseType_t xQueueSend(
-							  QueueHandle_t xQueue,
-							  const void * pvItemToQueue,
-							  TickType_t xTicksToWait
-						 );
- * 
- * - * This is a macro that calls xQueueGenericSend(). It is included for - * backward compatibility with versions of FreeRTOS.org that did not - * include the xQueueSendToFront() and xQueueSendToBack() macros. It is - * equivalent to xQueueSendToBack(). - * - * Post an item on a queue. The item is queued by copy, not by reference. - * This function must not be called from an interrupt service routine. - * See xQueueSendFromISR () for an alternative which may be used in an ISR. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for space to become available on the queue, should it already - * be full. The call will return immediately if this is set to 0 and the - * queue is full. The time is defined in tick periods so the constant - * portTICK_PERIOD_MS should be used to convert to real time if this is required. - * - * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- uint32_t ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an uint32_t.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend - * \ingroup QueueManagement - */ -#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) - -/** - * queue. h - *
- BaseType_t xQueueOverwrite(
-							  QueueHandle_t xQueue,
-							  const void * pvItemToQueue
-						 );
- * 
- * - * Only for use with queues that have a length of one - so the queue is either - * empty or full. - * - * Post an item on a queue. If the queue is already full then overwrite the - * value held in the queue. The item is queued by copy, not by reference. - * - * This function must not be called from an interrupt service routine. - * See xQueueOverwriteFromISR () for an alternative which may be used in an ISR. - * - * @param xQueue The handle of the queue to which the data is being sent. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @return xQueueOverwrite() is a macro that calls xQueueGenericSend(), and - * therefore has the same return values as xQueueSendToFront(). However, pdPASS - * is the only value that can be returned because xQueueOverwrite() will write - * to the queue even when the queue is already full. - * - * Example usage: -
-
- void vFunction( void *pvParameters )
- {
- QueueHandle_t xQueue;
- uint32_t ulVarToSend, ulValReceived;
-
-	// Create a queue to hold one uint32_t value.  It is strongly
-	// recommended *not* to use xQueueOverwrite() on queues that can
-	// contain more than one value, and doing so will trigger an assertion
-	// if configASSERT() is defined.
-	xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
-
-	// Write the value 10 to the queue using xQueueOverwrite().
-	ulVarToSend = 10;
-	xQueueOverwrite( xQueue, &ulVarToSend );
-
-	// Peeking the queue should now return 10, but leave the value 10 in
-	// the queue.  A block time of zero is used as it is known that the
-	// queue holds a value.
-	ulValReceived = 0;
-	xQueuePeek( xQueue, &ulValReceived, 0 );
-
-	if( ulValReceived != 10 )
-	{
-		// Error unless the item was removed by a different task.
-	}
-
-	// The queue is still full.  Use xQueueOverwrite() to overwrite the
-	// value held in the queue with 100.
-	ulVarToSend = 100;
-	xQueueOverwrite( xQueue, &ulVarToSend );
-
-	// This time read from the queue, leaving the queue empty once more.
-	// A block time of 0 is used again.
-	xQueueReceive( xQueue, &ulValReceived, 0 );
-
-	// The value read should be the last value written, even though the
-	// queue was already full when the value was written.
-	if( ulValReceived != 100 )
-	{
-		// Error!
-	}
-
-	// ...
-}
- 
- * \defgroup xQueueOverwrite xQueueOverwrite - * \ingroup QueueManagement - */ -#define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) - - -/** - * queue. h - *
- BaseType_t xQueueGenericSend(
-									QueueHandle_t xQueue,
-									const void * pvItemToQueue,
-									TickType_t xTicksToWait
-									BaseType_t xCopyPosition
-								);
- * 
- * - * It is preferred that the macros xQueueSend(), xQueueSendToFront() and - * xQueueSendToBack() are used in place of calling this function directly. - * - * Post an item on a queue. The item is queued by copy, not by reference. - * This function must not be called from an interrupt service routine. - * See xQueueSendFromISR () for an alternative which may be used in an ISR. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for space to become available on the queue, should it already - * be full. The call will return immediately if this is set to 0 and the - * queue is full. The time is defined in tick periods so the constant - * portTICK_PERIOD_MS should be used to convert to real time if this is required. - * - * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the - * item at the back of the queue, or queueSEND_TO_FRONT to place the item - * at the front of the queue (for high priority messages). - * - * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- uint32_t ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an uint32_t.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend - * \ingroup QueueManagement - */ -BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; - -/** - * queue. h - *
- BaseType_t xQueuePeek(
-							 QueueHandle_t xQueue,
-							 void *pvBuffer,
-							 TickType_t xTicksToWait
-						 );
- * - * This is a macro that calls the xQueueGenericReceive() function. - * - * Receive an item from a queue without removing the item from the queue. - * The item is received by copy so a buffer of adequate size must be - * provided. The number of bytes copied into the buffer was defined when - * the queue was created. - * - * Successfully received items remain on the queue so will be returned again - * by the next call, or a call to xQueueReceive(). - * - * This macro must not be used in an interrupt service routine. See - * xQueuePeekFromISR() for an alternative that can be called from an interrupt - * service routine. - * - * @param xQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for an item to receive should the queue be empty at the time - * of the call. The time is defined in tick periods so the constant - * portTICK_PERIOD_MS should be used to convert to real time if this is required. - * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue - * is empty. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- QueueHandle_t xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to peek the data from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Peek a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask, but the item still remains on the queue.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive - * \ingroup QueueManagement - */ -#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) - -/** - * queue. h - *
- BaseType_t xQueuePeekFromISR(
-									QueueHandle_t xQueue,
-									void *pvBuffer,
-								);
- * - * A version of xQueuePeek() that can be called from an interrupt service - * routine (ISR). - * - * Receive an item from a queue without removing the item from the queue. - * The item is received by copy so a buffer of adequate size must be - * provided. The number of bytes copied into the buffer was defined when - * the queue was created. - * - * Successfully received items remain on the queue so will be returned again - * by the next call, or a call to xQueueReceive(). - * - * @param xQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * \defgroup xQueuePeekFromISR xQueuePeekFromISR - * \ingroup QueueManagement - */ -BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION; - -/** - * queue. h - *
- BaseType_t xQueueReceive(
-								 QueueHandle_t xQueue,
-								 void *pvBuffer,
-								 TickType_t xTicksToWait
-							);
- * - * This is a macro that calls the xQueueGenericReceive() function. - * - * Receive an item from a queue. The item is received by copy so a buffer of - * adequate size must be provided. The number of bytes copied into the buffer - * was defined when the queue was created. - * - * Successfully received items are removed from the queue. - * - * This function must not be used in an interrupt service routine. See - * xQueueReceiveFromISR for an alternative that can. - * - * @param xQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for an item to receive should the queue be empty at the time - * of the call. xQueueReceive() will return immediately if xTicksToWait - * is zero and the queue is empty. The time is defined in tick periods so the - * constant portTICK_PERIOD_MS should be used to convert to real time if this is - * required. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- QueueHandle_t xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to receive from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Receive a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive - * \ingroup QueueManagement - */ -#define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) - - -/** - * queue. h - *
- BaseType_t xQueueGenericReceive(
-									   QueueHandle_t	xQueue,
-									   void	*pvBuffer,
-									   TickType_t	xTicksToWait
-									   BaseType_t	xJustPeek
-									);
- * - * It is preferred that the macro xQueueReceive() be used rather than calling - * this function directly. - * - * Receive an item from a queue. The item is received by copy so a buffer of - * adequate size must be provided. The number of bytes copied into the buffer - * was defined when the queue was created. - * - * This function must not be used in an interrupt service routine. See - * xQueueReceiveFromISR for an alternative that can. - * - * @param xQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param xTicksToWait The maximum amount of time the task should block - * waiting for an item to receive should the queue be empty at the time - * of the call. The time is defined in tick periods so the constant - * portTICK_PERIOD_MS should be used to convert to real time if this is required. - * xQueueGenericReceive() will return immediately if the queue is empty and - * xTicksToWait is 0. - * - * @param xJustPeek When set to true, the item received from the queue is not - * actually removed from the queue - meaning a subsequent call to - * xQueueReceive() will return the same item. When set to false, the item - * being received from the queue is also removed from the queue. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- QueueHandle_t xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to receive from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Receive a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive - * \ingroup QueueManagement - */ -BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek ) PRIVILEGED_FUNCTION; - -/** - * queue. h - *
UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );
- * - * Return the number of messages stored in a queue. - * - * @param xQueue A handle to the queue being queried. - * - * @return The number of messages available in the queue. - * - * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting - * \ingroup QueueManagement - */ -UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; - -/** - * queue. h - *
UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );
- * - * Return the number of free spaces available in a queue. This is equal to the - * number of items that can be sent to the queue before the queue becomes full - * if no items are removed. - * - * @param xQueue A handle to the queue being queried. - * - * @return The number of spaces available in the queue. - * - * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting - * \ingroup QueueManagement - */ -UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; - -/** - * queue. h - *
void vQueueDelete( QueueHandle_t xQueue );
- * - * Delete a queue - freeing all the memory allocated for storing of items - * placed on the queue. - * - * @param xQueue A handle to the queue to be deleted. - * - * \defgroup vQueueDelete vQueueDelete - * \ingroup QueueManagement - */ -void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; - -/** - * queue. h - *
- BaseType_t xQueueSendToFrontFromISR(
-										 QueueHandle_t xQueue,
-										 const void *pvItemToQueue,
-										 BaseType_t *pxHigherPriorityTaskWoken
-									  );
- 
- * - * This is a macro that calls xQueueGenericSendFromISR(). - * - * Post an item to the front of a queue. It is safe to use this macro from - * within an interrupt service routine. - * - * Items are queued by copy not reference so it is preferable to only - * queue small items, especially when called from an ISR. In most cases - * it would be preferable to store a pointer to the item being queued. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the data was successfully sent to the queue, otherwise - * errQUEUE_FULL. - * - * Example usage for buffered IO (where the ISR can obtain more than one value - * per call): -
- void vBufferISR( void )
- {
- char cIn;
- BaseType_t xHigherPrioritTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		taskYIELD ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR - * \ingroup QueueManagement - */ -#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) - - -/** - * queue. h - *
- BaseType_t xQueueSendToBackFromISR(
-										 QueueHandle_t xQueue,
-										 const void *pvItemToQueue,
-										 BaseType_t *pxHigherPriorityTaskWoken
-									  );
- 
- * - * This is a macro that calls xQueueGenericSendFromISR(). - * - * Post an item to the back of a queue. It is safe to use this macro from - * within an interrupt service routine. - * - * Items are queued by copy not reference so it is preferable to only - * queue small items, especially when called from an ISR. In most cases - * it would be preferable to store a pointer to the item being queued. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the data was successfully sent to the queue, otherwise - * errQUEUE_FULL. - * - * Example usage for buffered IO (where the ISR can obtain more than one value - * per call): -
- void vBufferISR( void )
- {
- char cIn;
- BaseType_t xHigherPriorityTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		taskYIELD ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR - * \ingroup QueueManagement - */ -#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) - -/** - * queue. h - *
- BaseType_t xQueueOverwriteFromISR(
-							  QueueHandle_t xQueue,
-							  const void * pvItemToQueue,
-							  BaseType_t *pxHigherPriorityTaskWoken
-						 );
- * 
- * - * A version of xQueueOverwrite() that can be used in an interrupt service - * routine (ISR). - * - * Only for use with queues that can hold a single item - so the queue is either - * empty or full. - * - * Post an item on a queue. If the queue is already full then overwrite the - * value held in the queue. The item is queued by copy, not by reference. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueOverwriteFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return xQueueOverwriteFromISR() is a macro that calls - * xQueueGenericSendFromISR(), and therefore has the same return values as - * xQueueSendToFrontFromISR(). However, pdPASS is the only value that can be - * returned because xQueueOverwriteFromISR() will write to the queue even when - * the queue is already full. - * - * Example usage: -
-
- QueueHandle_t xQueue;
-
- void vFunction( void *pvParameters )
- {
- 	// Create a queue to hold one uint32_t value.  It is strongly
-	// recommended *not* to use xQueueOverwriteFromISR() on queues that can
-	// contain more than one value, and doing so will trigger an assertion
-	// if configASSERT() is defined.
-	xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
-}
-
-void vAnInterruptHandler( void )
-{
-// xHigherPriorityTaskWoken must be set to pdFALSE before it is used.
-BaseType_t xHigherPriorityTaskWoken = pdFALSE;
-uint32_t ulVarToSend, ulValReceived;
-
-	// Write the value 10 to the queue using xQueueOverwriteFromISR().
-	ulVarToSend = 10;
-	xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
-
-	// The queue is full, but calling xQueueOverwriteFromISR() again will still
-	// pass because the value held in the queue will be overwritten with the
-	// new value.
-	ulVarToSend = 100;
-	xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
-
-	// Reading from the queue will now return 100.
-
-	// ...
-
-	if( xHigherPrioritytaskWoken == pdTRUE )
-	{
-		// Writing to the queue caused a task to unblock and the unblocked task
-		// has a priority higher than or equal to the priority of the currently
-		// executing task (the task this interrupt interrupted).  Perform a context
-		// switch so this interrupt returns directly to the unblocked task.
-		portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port.
-	}
-}
- 
- * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR - * \ingroup QueueManagement - */ -#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) - -/** - * queue. h - *
- BaseType_t xQueueSendFromISR(
-									 QueueHandle_t xQueue,
-									 const void *pvItemToQueue,
-									 BaseType_t *pxHigherPriorityTaskWoken
-								);
- 
- * - * This is a macro that calls xQueueGenericSendFromISR(). It is included - * for backward compatibility with versions of FreeRTOS.org that did not - * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR() - * macros. - * - * Post an item to the back of a queue. It is safe to use this function from - * within an interrupt service routine. - * - * Items are queued by copy not reference so it is preferable to only - * queue small items, especially when called from an ISR. In most cases - * it would be preferable to store a pointer to the item being queued. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueSendFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the data was successfully sent to the queue, otherwise - * errQUEUE_FULL. - * - * Example usage for buffered IO (where the ISR can obtain more than one value - * per call): -
- void vBufferISR( void )
- {
- char cIn;
- BaseType_t xHigherPriorityTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		// Actual macro used here is port specific.
-		portYIELD_FROM_ISR ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR - * \ingroup QueueManagement - */ -#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) - -/** - * queue. h - *
- BaseType_t xQueueGenericSendFromISR(
-										   QueueHandle_t		xQueue,
-										   const	void	*pvItemToQueue,
-										   BaseType_t	*pxHigherPriorityTaskWoken,
-										   BaseType_t	xCopyPosition
-									   );
- 
- * - * It is preferred that the macros xQueueSendFromISR(), - * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place - * of calling this function directly. xQueueGiveFromISR() is an - * equivalent for use by semaphores that don't actually copy any data. - * - * Post an item on a queue. It is safe to use this function from within an - * interrupt service routine. - * - * Items are queued by copy not reference so it is preferable to only - * queue small items, especially when called from an ISR. In most cases - * it would be preferable to store a pointer to the item being queued. - * - * @param xQueue The handle to the queue on which the item is to be posted. - * - * @param pvItemToQueue A pointer to the item that is to be placed on the - * queue. The size of the items the queue will hold was defined when the - * queue was created, so this many bytes will be copied from pvItemToQueue - * into the queue storage area. - * - * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the - * item at the back of the queue, or queueSEND_TO_FRONT to place the item - * at the front of the queue (for high priority messages). - * - * @return pdTRUE if the data was successfully sent to the queue, otherwise - * errQUEUE_FULL. - * - * Example usage for buffered IO (where the ISR can obtain more than one value - * per call): -
- void vBufferISR( void )
- {
- char cIn;
- BaseType_t xHigherPriorityTaskWokenByPost;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWokenByPost = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post each byte.
-		xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.  Note that the
-	// name of the yield function required is port specific.
-	if( xHigherPriorityTaskWokenByPost )
-	{
-		taskYIELD_YIELD_FROM_ISR();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR - * \ingroup QueueManagement - */ -BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; -BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; - -/** - * queue. h - *
- BaseType_t xQueueReceiveFromISR(
-									   QueueHandle_t	xQueue,
-									   void	*pvBuffer,
-									   BaseType_t *pxTaskWoken
-								   );
- * 
- * - * Receive an item from a queue. It is safe to use this function from within an - * interrupt service routine. - * - * @param xQueue The handle to the queue from which the item is to be - * received. - * - * @param pvBuffer Pointer to the buffer into which the received item will - * be copied. - * - * @param pxTaskWoken A task may be blocked waiting for space to become - * available on the queue. If xQueueReceiveFromISR causes such a task to - * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will - * remain unchanged. - * - * @return pdTRUE if an item was successfully received from the queue, - * otherwise pdFALSE. - * - * Example usage: -
-
- QueueHandle_t xQueue;
-
- // Function to create a queue and post some values.
- void vAFunction( void *pvParameters )
- {
- char cValueToPost;
- const TickType_t xTicksToWait = ( TickType_t )0xff;
-
-	// Create a queue capable of containing 10 characters.
-	xQueue = xQueueCreate( 10, sizeof( char ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Post some characters that will be used within an ISR.  If the queue
-	// is full then this task will block for xTicksToWait ticks.
-	cValueToPost = 'a';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
-	cValueToPost = 'b';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
-
-	// ... keep posting characters ... this task may block when the queue
-	// becomes full.
-
-	cValueToPost = 'c';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
- }
-
- // ISR that outputs all the characters received on the queue.
- void vISR_Routine( void )
- {
- BaseType_t xTaskWokenByReceive = pdFALSE;
- char cRxedChar;
-
-	while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
-	{
-		// A character was received.  Output the character now.
-		vOutputCharacter( cRxedChar );
-
-		// If removing the character from the queue woke the task that was
-		// posting onto the queue cTaskWokenByReceive will have been set to
-		// pdTRUE.  No matter how many times this loop iterates only one
-		// task will be woken.
-	}
-
-	if( cTaskWokenByPost != ( char ) pdFALSE;
-	{
-		taskYIELD ();
-	}
- }
- 
- * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR - * \ingroup QueueManagement - */ -BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; - -/* - * Utilities to query queues that are safe to use from an ISR. These utilities - * should be used only from witin an ISR, or within a critical section. - */ -BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; -BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; -UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; - - -/* - * xQueueAltGenericSend() is an alternative version of xQueueGenericSend(). - * Likewise xQueueAltGenericReceive() is an alternative version of - * xQueueGenericReceive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ); -BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking ); -#define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) -#define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) -#define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) -#define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) - -/* - * The functions defined above are for passing data to and from tasks. The - * functions below are the equivalents for passing data to and from - * co-routines. - * - * These functions are called from the co-routine macro implementation and - * should not be called directly from application code. Instead use the macro - * wrappers defined within croutine.h. - */ -BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken ); -BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken ); -BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait ); -BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait ); - -/* - * For internal use only. Use xSemaphoreCreateMutex(), - * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling - * these functions directly. - */ -QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; -void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; - -/* - * For internal use only. Use xSemaphoreTakeMutexRecursive() or - * xSemaphoreGiveMutexRecursive() instead of calling these functions directly. - */ -BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION; - -/* - * Reset a queue back to its original empty state. The return value is now - * obsolete and is always set to pdPASS. - */ -#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) - -/* - * The registry is provided as a means for kernel aware debuggers to - * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add - * a queue, semaphore or mutex handle to the registry if you want the handle - * to be available to a kernel aware debugger. If you are not using a kernel - * aware debugger then this function can be ignored. - * - * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the - * registry can hold. configQUEUE_REGISTRY_SIZE must be greater than 0 - * within FreeRTOSConfig.h for the registry to be available. Its value - * does not effect the number of queues, semaphores and mutexes that can be - * created - just the number that the registry can hold. - * - * @param xQueue The handle of the queue being added to the registry. This - * is the handle returned by a call to xQueueCreate(). Semaphore and mutex - * handles can also be passed in here. - * - * @param pcName The name to be associated with the handle. This is the - * name that the kernel aware debugger will display. The queue registry only - * stores a pointer to the string - so the string must be persistent (global or - * preferably in ROM/Flash), not on the stack. - */ -#if configQUEUE_REGISTRY_SIZE > 0 - void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ -#endif - -/* - * The registry is provided as a means for kernel aware debuggers to - * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add - * a queue, semaphore or mutex handle to the registry if you want the handle - * to be available to a kernel aware debugger, and vQueueUnregisterQueue() to - * remove the queue, semaphore or mutex from the register. If you are not using - * a kernel aware debugger then this function can be ignored. - * - * @param xQueue The handle of the queue being removed from the registry. - */ -#if configQUEUE_REGISTRY_SIZE > 0 - void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; -#endif - -/* - * Generic version of the queue creation function, which is in turn called by - * any queue, semaphore or mutex creation function or macro. - */ -QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; - -/* - * Queue sets provide a mechanism to allow a task to block (pend) on a read - * operation from multiple queues or semaphores simultaneously. - * - * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this - * function. - * - * A queue set must be explicitly created using a call to xQueueCreateSet() - * before it can be used. Once created, standard FreeRTOS queues and semaphores - * can be added to the set using calls to xQueueAddToSet(). - * xQueueSelectFromSet() is then used to determine which, if any, of the queues - * or semaphores contained in the set is in a state where a queue read or - * semaphore take operation would be successful. - * - * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html - * for reasons why queue sets are very rarely needed in practice as there are - * simpler methods of blocking on multiple objects. - * - * Note 2: Blocking on a queue set that contains a mutex will not cause the - * mutex holder to inherit the priority of the blocked task. - * - * Note 3: An additional 4 bytes of RAM is required for each space in a every - * queue added to a queue set. Therefore counting semaphores that have a high - * maximum count value should not be added to a queue set. - * - * Note 4: A receive (in the case of a queue) or take (in the case of a - * semaphore) operation must not be performed on a member of a queue set unless - * a call to xQueueSelectFromSet() has first returned a handle to that set member. - * - * @param uxEventQueueLength Queue sets store events that occur on - * the queues and semaphores contained in the set. uxEventQueueLength specifies - * the maximum number of events that can be queued at once. To be absolutely - * certain that events are not lost uxEventQueueLength should be set to the - * total sum of the length of the queues added to the set, where binary - * semaphores and mutexes have a length of 1, and counting semaphores have a - * length set by their maximum count value. Examples: - * + If a queue set is to hold a queue of length 5, another queue of length 12, - * and a binary semaphore, then uxEventQueueLength should be set to - * (5 + 12 + 1), or 18. - * + If a queue set is to hold three binary semaphores then uxEventQueueLength - * should be set to (1 + 1 + 1 ), or 3. - * + If a queue set is to hold a counting semaphore that has a maximum count of - * 5, and a counting semaphore that has a maximum count of 3, then - * uxEventQueueLength should be set to (5 + 3), or 8. - * - * @return If the queue set is created successfully then a handle to the created - * queue set is returned. Otherwise NULL is returned. - */ -QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION; - -/* - * Adds a queue or semaphore to a queue set that was previously created by a - * call to xQueueCreateSet(). - * - * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this - * function. - * - * Note 1: A receive (in the case of a queue) or take (in the case of a - * semaphore) operation must not be performed on a member of a queue set unless - * a call to xQueueSelectFromSet() has first returned a handle to that set member. - * - * @param xQueueOrSemaphore The handle of the queue or semaphore being added to - * the queue set (cast to an QueueSetMemberHandle_t type). - * - * @param xQueueSet The handle of the queue set to which the queue or semaphore - * is being added. - * - * @return If the queue or semaphore was successfully added to the queue set - * then pdPASS is returned. If the queue could not be successfully added to the - * queue set because it is already a member of a different queue set then pdFAIL - * is returned. - */ -BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; - -/* - * Removes a queue or semaphore from a queue set. A queue or semaphore can only - * be removed from a set if the queue or semaphore is empty. - * - * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this - * function. - * - * @param xQueueOrSemaphore The handle of the queue or semaphore being removed - * from the queue set (cast to an QueueSetMemberHandle_t type). - * - * @param xQueueSet The handle of the queue set in which the queue or semaphore - * is included. - * - * @return If the queue or semaphore was successfully removed from the queue set - * then pdPASS is returned. If the queue was not in the queue set, or the - * queue (or semaphore) was not empty, then pdFAIL is returned. - */ -BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; - -/* - * xQueueSelectFromSet() selects from the members of a queue set a queue or - * semaphore that either contains data (in the case of a queue) or is available - * to take (in the case of a semaphore). xQueueSelectFromSet() effectively - * allows a task to block (pend) on a read operation on all the queues and - * semaphores in a queue set simultaneously. - * - * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this - * function. - * - * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html - * for reasons why queue sets are very rarely needed in practice as there are - * simpler methods of blocking on multiple objects. - * - * Note 2: Blocking on a queue set that contains a mutex will not cause the - * mutex holder to inherit the priority of the blocked task. - * - * Note 3: A receive (in the case of a queue) or take (in the case of a - * semaphore) operation must not be performed on a member of a queue set unless - * a call to xQueueSelectFromSet() has first returned a handle to that set member. - * - * @param xQueueSet The queue set on which the task will (potentially) block. - * - * @param xTicksToWait The maximum time, in ticks, that the calling task will - * remain in the Blocked state (with other tasks executing) to wait for a member - * of the queue set to be ready for a successful queue read or semaphore take - * operation. - * - * @return xQueueSelectFromSet() will return the handle of a queue (cast to - * a QueueSetMemberHandle_t type) contained in the queue set that contains data, - * or the handle of a semaphore (cast to a QueueSetMemberHandle_t type) contained - * in the queue set that is available, or NULL if no such queue or semaphore - * exists before before the specified block time expires. - */ -QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - -/* - * A version of xQueueSelectFromSet() that can be used from an ISR. - */ -QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; - -/* Not public API functions. */ -void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION; -void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION; -UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; -uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; - - -#ifdef __cplusplus -} -#endif - -#endif /* QUEUE_H */ - diff --git a/GD32F1/libraries/FreeRTOS821/utility/readme.txt b/GD32F1/libraries/FreeRTOS821/utility/readme.txt deleted file mode 100644 index 58480c5..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -Each real time kernel port consists of three files that contain the core kernel -components and are common to every port, and one or more files that are -specific to a particular microcontroller and or compiler. - -+ The FreeRTOS/Source directory contains the three files that are common to -every port - list.c, queue.c and tasks.c. The kernel is contained within these -three files. croutine.c implements the optional co-routine functionality - which -is normally only used on very memory limited systems. - -+ The FreeRTOS/Source/Portable directory contains the files that are specific to -a particular microcontroller and or compiler. - -+ The FreeRTOS/Source/include directory contains the real time kernel header -files. - -See the readme file in the FreeRTOS/Source/Portable directory for more -information. \ No newline at end of file diff --git a/GD32F1/libraries/FreeRTOS821/utility/semphr.h b/GD32F1/libraries/FreeRTOS821/utility/semphr.h deleted file mode 100644 index 3f811a6..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/semphr.h +++ /dev/null @@ -1,844 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef SEMAPHORE_H -#define SEMAPHORE_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include semphr.h" -#endif - -#include "queue.h" - -typedef QueueHandle_t SemaphoreHandle_t; - -#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) -#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) -#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) - - -/** - * semphr. h - *
vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )
- * - * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the - * xSemaphoreCreateBinary() function. Note that binary semaphores created using - * the vSemaphoreCreateBinary() macro are created in a state such that the - * first call to 'take' the semaphore would pass, whereas binary semaphores - * created using xSemaphoreCreateBinary() are created in a state such that the - * the semaphore must first be 'given' before it can be 'taken'. - * - * Macro that implements a semaphore by using the existing queue mechanism. - * The queue length is 1 as this is a binary semaphore. The data size is 0 - * as we don't want to actually store any data - we just want to know if the - * queue is empty or full. - * - * This type of semaphore can be used for pure synchronisation between tasks or - * between an interrupt and a task. The semaphore need not be given back once - * obtained, so one task/interrupt can continuously 'give' the semaphore while - * another continuously 'takes' the semaphore. For this reason this type of - * semaphore does not use a priority inheritance mechanism. For an alternative - * that does use priority inheritance see xSemaphoreCreateMutex(). - * - * @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
-    // This is a macro so pass the variable in directly.
-    vSemaphoreCreateBinary( xSemaphore );
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary - * \ingroup Semaphores - */ -#define vSemaphoreCreateBinary( xSemaphore ) \ - { \ - ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ - if( ( xSemaphore ) != NULL ) \ - { \ - ( void ) xSemaphoreGive( ( xSemaphore ) ); \ - } \ - } - -/** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateBinary( void )
- * - * The old vSemaphoreCreateBinary() macro is now deprecated in favour of this - * xSemaphoreCreateBinary() function. Note that binary semaphores created using - * the vSemaphoreCreateBinary() macro are created in a state such that the - * first call to 'take' the semaphore would pass, whereas binary semaphores - * created using xSemaphoreCreateBinary() are created in a state such that the - * the semaphore must first be 'given' before it can be 'taken'. - * - * Function that creates a semaphore by using the existing queue mechanism. - * The queue length is 1 as this is a binary semaphore. The data size is 0 - * as nothing is actually stored - all that is important is whether the queue is - * empty or full (the binary semaphore is available or not). - * - * This type of semaphore can be used for pure synchronisation between tasks or - * between an interrupt and a task. The semaphore need not be given back once - * obtained, so one task/interrupt can continuously 'give' the semaphore while - * another continuously 'takes' the semaphore. For this reason this type of - * semaphore does not use a priority inheritance mechanism. For an alternative - * that does use priority inheritance see xSemaphoreCreateMutex(). - * - * @return Handle to the created semaphore. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateBinary();
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary - * \ingroup Semaphores - */ -#define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) - -/** - * semphr. h - *
xSemaphoreTake(
- *                   SemaphoreHandle_t xSemaphore,
- *                   TickType_t xBlockTime
- *               )
- * - * Macro to obtain a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or - * xSemaphoreCreateCounting(). - * - * @param xSemaphore A handle to the semaphore being taken - obtained when - * the semaphore was created. - * - * @param xBlockTime The time in ticks to wait for the semaphore to become - * available. The macro portTICK_PERIOD_MS can be used to convert this to a - * real time. A block time of zero can be used to poll the semaphore. A block - * time of portMAX_DELAY can be used to block indefinitely (provided - * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h). - * - * @return pdTRUE if the semaphore was obtained. pdFALSE - * if xBlockTime expired without the semaphore becoming available. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- // A task that creates a semaphore.
- void vATask( void * pvParameters )
- {
-    // Create the semaphore to guard a shared resource.
-    vSemaphoreCreateBinary( xSemaphore );
- }
-
- // A task that uses the semaphore.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xSemaphore != NULL )
-    {
-        // See if we can obtain the semaphore.  If the semaphore is not available
-        // wait 10 ticks to see if it becomes free.
-        if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the semaphore and can now access the
-            // shared resource.
-
-            // ...
-
-            // We have finished accessing the shared resource.  Release the
-            // semaphore.
-            xSemaphoreGive( xSemaphore );
-        }
-        else
-        {
-            // We could not obtain the semaphore and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreTake xSemaphoreTake - * \ingroup Semaphores - */ -#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) - -/** - * semphr. h - * xSemaphoreTakeRecursive( - * SemaphoreHandle_t xMutex, - * TickType_t xBlockTime - * ) - * - * Macro to recursively obtain, or 'take', a mutex type semaphore. - * The mutex must have previously been created using a call to - * xSemaphoreCreateRecursiveMutex(); - * - * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this - * macro to be available. - * - * This macro must not be used on mutexes created using xSemaphoreCreateMutex(). - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * @param xMutex A handle to the mutex being obtained. This is the - * handle returned by xSemaphoreCreateRecursiveMutex(); - * - * @param xBlockTime The time in ticks to wait for the semaphore to become - * available. The macro portTICK_PERIOD_MS can be used to convert this to a - * real time. A block time of zero can be used to poll the semaphore. If - * the task already owns the semaphore then xSemaphoreTakeRecursive() will - * return immediately no matter what the value of xBlockTime. - * - * @return pdTRUE if the semaphore was obtained. pdFALSE if xBlockTime - * expired without the semaphore becoming available. - * - * Example usage: -
- SemaphoreHandle_t xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
-    // Create the mutex to guard a shared resource.
-    xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xMutex != NULL )
-    {
-        // See if we can obtain the mutex.  If the mutex is not available
-        // wait 10 ticks to see if it becomes free.
-        if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the mutex and can now access the
-            // shared resource.
-
-            // ...
-            // For some reason due to the nature of the code further calls to
-			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
-			// code these would not be just sequential calls as this would make
-			// no sense.  Instead the calls are likely to be buried inside
-			// a more complex call structure.
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-
-            // The mutex has now been 'taken' three times, so will not be
-			// available to another task until it has also been given back
-			// three times.  Again it is unlikely that real code would have
-			// these calls sequentially, but instead buried in a more complex
-			// call structure.  This is just for illustrative purposes.
-            xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-
-			// Now the mutex can be taken by other tasks.
-        }
-        else
-        {
-            // We could not obtain the mutex and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive - * \ingroup Semaphores - */ -#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) - - -/* - * xSemaphoreAltTake() is an alternative version of xSemaphoreTake(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) - -/** - * semphr. h - *
xSemaphoreGive( SemaphoreHandle_t xSemaphore )
- * - * Macro to release a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or - * xSemaphoreCreateCounting(). and obtained using sSemaphoreTake(). - * - * This macro must not be used from an ISR. See xSemaphoreGiveFromISR () for - * an alternative which can be used from an ISR. - * - * This macro must also not be used on semaphores created using - * xSemaphoreCreateRecursiveMutex(). - * - * @param xSemaphore A handle to the semaphore being released. This is the - * handle returned when the semaphore was created. - * - * @return pdTRUE if the semaphore was released. pdFALSE if an error occurred. - * Semaphores are implemented using queues. An error can occur if there is - * no space on the queue to post a message - indicating that the - * semaphore was not first obtained correctly. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Create the semaphore to guard a shared resource.
-    vSemaphoreCreateBinary( xSemaphore );
-
-    if( xSemaphore != NULL )
-    {
-        if( xSemaphoreGive( xSemaphore ) != pdTRUE )
-        {
-            // We would expect this call to fail because we cannot give
-            // a semaphore without first "taking" it!
-        }
-
-        // Obtain the semaphore - don't block if the semaphore is not
-        // immediately available.
-        if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )
-        {
-            // We now have the semaphore and can access the shared resource.
-
-            // ...
-
-            // We have finished accessing the shared resource so can free the
-            // semaphore.
-            if( xSemaphoreGive( xSemaphore ) != pdTRUE )
-            {
-                // We would not expect this call to fail because we must have
-                // obtained the semaphore to get here.
-            }
-        }
-    }
- }
- 
- * \defgroup xSemaphoreGive xSemaphoreGive - * \ingroup Semaphores - */ -#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** - * semphr. h - *
xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )
- * - * Macro to recursively release, or 'give', a mutex type semaphore. - * The mutex must have previously been created using a call to - * xSemaphoreCreateRecursiveMutex(); - * - * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this - * macro to be available. - * - * This macro must not be used on mutexes created using xSemaphoreCreateMutex(). - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * @param xMutex A handle to the mutex being released, or 'given'. This is the - * handle returned by xSemaphoreCreateMutex(); - * - * @return pdTRUE if the semaphore was given. - * - * Example usage: -
- SemaphoreHandle_t xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
-    // Create the mutex to guard a shared resource.
-    xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xMutex != NULL )
-    {
-        // See if we can obtain the mutex.  If the mutex is not available
-        // wait 10 ticks to see if it becomes free.
-        if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the mutex and can now access the
-            // shared resource.
-
-            // ...
-            // For some reason due to the nature of the code further calls to
-			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
-			// code these would not be just sequential calls as this would make
-			// no sense.  Instead the calls are likely to be buried inside
-			// a more complex call structure.
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-
-            // The mutex has now been 'taken' three times, so will not be
-			// available to another task until it has also been given back
-			// three times.  Again it is unlikely that real code would have
-			// these calls sequentially, it would be more likely that the calls
-			// to xSemaphoreGiveRecursive() would be called as a call stack
-			// unwound.  This is just for demonstrative purposes.
-            xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-
-			// Now the mutex can be taken by other tasks.
-        }
-        else
-        {
-            // We could not obtain the mutex and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive - * \ingroup Semaphores - */ -#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) - -/* - * xSemaphoreAltGive() is an alternative version of xSemaphoreGive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** - * semphr. h - *
- xSemaphoreGiveFromISR(
-                          SemaphoreHandle_t xSemaphore,
-                          BaseType_t *pxHigherPriorityTaskWoken
-                      )
- * - * Macro to release a semaphore. The semaphore must have previously been - * created with a call to vSemaphoreCreateBinary() or xSemaphoreCreateCounting(). - * - * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) - * must not be used with this macro. - * - * This macro can be used from an ISR. - * - * @param xSemaphore A handle to the semaphore being released. This is the - * handle returned when the semaphore was created. - * - * @param pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if giving the semaphore caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xSemaphoreGiveFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the semaphore was successfully given, otherwise errQUEUE_FULL. - * - * Example usage: -
- \#define LONG_TIME 0xffff
- \#define TICKS_TO_WAIT	10
- SemaphoreHandle_t xSemaphore = NULL;
-
- // Repetitive task.
- void vATask( void * pvParameters )
- {
-    for( ;; )
-    {
-        // We want this task to run every 10 ticks of a timer.  The semaphore
-        // was created before this task was started.
-
-        // Block waiting for the semaphore to become available.
-        if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
-        {
-            // It is time to execute.
-
-            // ...
-
-            // We have finished our task.  Return to the top of the loop where
-            // we will block on the semaphore until it is time to execute
-            // again.  Note when using the semaphore for synchronisation with an
-			// ISR in this manner there is no need to 'give' the semaphore back.
-        }
-    }
- }
-
- // Timer ISR
- void vTimerISR( void * pvParameters )
- {
- static uint8_t ucLocalTickCount = 0;
- static BaseType_t xHigherPriorityTaskWoken;
-
-    // A timer tick has occurred.
-
-    // ... Do other time functions.
-
-    // Is it time for vATask () to run?
-	xHigherPriorityTaskWoken = pdFALSE;
-    ucLocalTickCount++;
-    if( ucLocalTickCount >= TICKS_TO_WAIT )
-    {
-        // Unblock the task by releasing the semaphore.
-        xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
-
-        // Reset the count so we release the semaphore again in 10 ticks time.
-        ucLocalTickCount = 0;
-    }
-
-    if( xHigherPriorityTaskWoken != pdFALSE )
-    {
-        // We can force a context switch here.  Context switching from an
-        // ISR uses port specific syntax.  Check the demo task for your port
-        // to find the syntax required.
-    }
- }
- 
- * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR - * \ingroup Semaphores - */ -#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) - -/** - * semphr. h - *
- xSemaphoreTakeFromISR(
-                          SemaphoreHandle_t xSemaphore,
-                          BaseType_t *pxHigherPriorityTaskWoken
-                      )
- * - * Macro to take a semaphore from an ISR. The semaphore must have - * previously been created with a call to vSemaphoreCreateBinary() or - * xSemaphoreCreateCounting(). - * - * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex()) - * must not be used with this macro. - * - * This macro can be used from an ISR, however taking a semaphore from an ISR - * is not a common operation. It is likely to only be useful when taking a - * counting semaphore when an interrupt is obtaining an object from a resource - * pool (when the semaphore count indicates the number of resources available). - * - * @param xSemaphore A handle to the semaphore being taken. This is the - * handle returned when the semaphore was created. - * - * @param pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if taking the semaphore caused a task - * to unblock, and the unblocked task has a priority higher than the currently - * running task. If xSemaphoreTakeFromISR() sets this value to pdTRUE then - * a context switch should be requested before the interrupt is exited. - * - * @return pdTRUE if the semaphore was successfully taken, otherwise - * pdFALSE - */ -#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) - -/** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateMutex( void )
- * - * Macro that implements a mutex semaphore by using the existing queue - * mechanism. - * - * Mutexes created using this macro can be accessed using the xSemaphoreTake() - * and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and - * xSemaphoreGiveRecursive() macros should not be used. - * - * This type of semaphore uses a priority inheritance mechanism so a task - * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the - * semaphore it is no longer required. - * - * Mutex type semaphores cannot be used from within interrupt service routines. - * - * See vSemaphoreCreateBinary() for an alternative implementation that can be - * used for pure synchronisation (where one task or interrupt always 'gives' the - * semaphore and another always 'takes' the semaphore) and from within interrupt - * service routines. - * - * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * SemaphoreHandle_t. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateMutex();
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex - * \ingroup Semaphores - */ -#define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) - - -/** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )
- * - * Macro that implements a recursive mutex by using the existing queue - * mechanism. - * - * Mutexes created using this macro can be accessed using the - * xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() macros. The - * xSemaphoreTake() and xSemaphoreGive() macros should not be used. - * - * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex - * doesn't become available again until the owner has called - * xSemaphoreGiveRecursive() for each successful 'take' request. For example, - * if a task successfully 'takes' the same mutex 5 times then the mutex will - * not be available to any other task until it has also 'given' the mutex back - * exactly five times. - * - * This type of semaphore uses a priority inheritance mechanism so a task - * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the - * semaphore it is no longer required. - * - * Mutex type semaphores cannot be used from within interrupt service routines. - * - * See vSemaphoreCreateBinary() for an alternative implementation that can be - * used for pure synchronisation (where one task or interrupt always 'gives' the - * semaphore and another always 'takes' the semaphore) and from within interrupt - * service routines. - * - * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * SemaphoreHandle_t. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateRecursiveMutex();
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex - * \ingroup Semaphores - */ -#define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) - -/** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount )
- * - * Macro that creates a counting semaphore by using the existing - * queue mechanism. - * - * Counting semaphores are typically used for two things: - * - * 1) Counting events. - * - * In this usage scenario an event handler will 'give' a semaphore each time - * an event occurs (incrementing the semaphore count value), and a handler - * task will 'take' a semaphore each time it processes an event - * (decrementing the semaphore count value). The count value is therefore - * the difference between the number of events that have occurred and the - * number that have been processed. In this case it is desirable for the - * initial count value to be zero. - * - * 2) Resource management. - * - * In this usage scenario the count value indicates the number of resources - * available. To obtain control of a resource a task must first obtain a - * semaphore - decrementing the semaphore count value. When the count value - * reaches zero there are no free resources. When a task finishes with the - * resource it 'gives' the semaphore back - incrementing the semaphore count - * value. In this case it is desirable for the initial count value to be - * equal to the maximum count value, indicating that all resources are free. - * - * @param uxMaxCount The maximum count value that can be reached. When the - * semaphore reaches this value it can no longer be 'given'. - * - * @param uxInitialCount The count value assigned to the semaphore when it is - * created. - * - * @return Handle to the created semaphore. Null if the semaphore could not be - * created. - * - * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
- SemaphoreHandle_t xSemaphore = NULL;
-
-    // Semaphore cannot be used before a call to xSemaphoreCreateCounting().
-    // The max value to which the semaphore can count should be 10, and the
-    // initial value assigned to the count should be 0.
-    xSemaphore = xSemaphoreCreateCounting( 10, 0 );
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting - * \ingroup Semaphores - */ -#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) - -/** - * semphr. h - *
void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );
- * - * Delete a semaphore. This function must be used with care. For example, - * do not delete a mutex type semaphore if the mutex is held by a task. - * - * @param xSemaphore A handle to the semaphore to be deleted. - * - * \defgroup vSemaphoreDelete vSemaphoreDelete - * \ingroup Semaphores - */ -#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) - -/** - * semphr.h - *
TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );
- * - * If xMutex is indeed a mutex type semaphore, return the current mutex holder. - * If xMutex is not a mutex type semaphore, or the mutex is available (not held - * by a task), return NULL. - * - * Note: This is a good way of determining if the calling task is the mutex - * holder, but not a good way of determining the identity of the mutex holder as - * the holder may change between the function exiting and the returned value - * being tested. - */ -#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) - -#endif /* SEMAPHORE_H */ - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/stdint.readme b/GD32F1/libraries/FreeRTOS821/utility/stdint.readme deleted file mode 100644 index 4414c29..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/stdint.readme +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef FREERTOS_STDINT -#define FREERTOS_STDINT - -/******************************************************************************* - * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions - * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be - * built using compilers that do not provide their own stdint.h definition. - * - * To use this file: - * - * 1) Copy this file into the directory that contains your FreeRTOSConfig.h - * header file, as that directory will already be in the compilers include - * path. - * - * 2) Rename the copied file stdint.h. - * - */ - -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef long int32_t; -typedef unsigned long uint32_t; - -#endif /* FREERTOS_STDINT */ diff --git a/GD32F1/libraries/FreeRTOS821/utility/task.h b/GD32F1/libraries/FreeRTOS821/utility/task.h deleted file mode 100644 index 93a1f66..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/task.h +++ /dev/null @@ -1,2019 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -#ifndef INC_TASK_H -#define INC_TASK_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include task.h" -#endif - -#include "list.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*----------------------------------------------------------- - * MACROS AND DEFINITIONS - *----------------------------------------------------------*/ - -#define tskKERNEL_VERSION_NUMBER "V8.2.1" -#define tskKERNEL_VERSION_MAJOR 8 -#define tskKERNEL_VERSION_MINOR 2 -#define tskKERNEL_VERSION_BUILD 1 - -/** - * task. h - * - * Type by which tasks are referenced. For example, a call to xTaskCreate - * returns (via a pointer parameter) an TaskHandle_t variable that can then - * be used as a parameter to vTaskDelete to delete the task. - * - * \defgroup TaskHandle_t TaskHandle_t - * \ingroup Tasks - */ -typedef void * TaskHandle_t; - -/* - * Defines the prototype to which the application task hook function must - * conform. - */ -typedef BaseType_t (*TaskHookFunction_t)( void * ); - -/* Task states returned by eTaskGetState. */ -typedef enum -{ - eRunning = 0, /* A task is querying the state of itself, so must be running. */ - eReady, /* The task being queried is in a read or pending ready list. */ - eBlocked, /* The task being queried is in the Blocked state. */ - eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ - eDeleted /* The task being queried has been deleted, but its TCB has not yet been freed. */ -} eTaskState; - -/* Actions that can be performed when vTaskNotify() is called. */ -typedef enum -{ - eNoAction = 0, /* Notify the task without updating its notify value. */ - eSetBits, /* Set bits in the task's notification value. */ - eIncrement, /* Increment the task's notification value. */ - eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */ - eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */ -} eNotifyAction; - -/* - * Used internally only. - */ -typedef struct xTIME_OUT -{ - BaseType_t xOverflowCount; - TickType_t xTimeOnEntering; -} TimeOut_t; - -/* - * Defines the memory ranges allocated to the task when an MPU is used. - */ -typedef struct xMEMORY_REGION -{ - void *pvBaseAddress; - uint32_t ulLengthInBytes; - uint32_t ulParameters; -} MemoryRegion_t; - -/* - * Parameters required to create an MPU protected task. - */ -typedef struct xTASK_PARAMETERS -{ - TaskFunction_t pvTaskCode; - const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - uint16_t usStackDepth; - void *pvParameters; - UBaseType_t uxPriority; - StackType_t *puxStackBuffer; - MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; -} TaskParameters_t; - -/* Used with the uxTaskGetSystemState() function to return the state of each task -in the system. */ -typedef struct xTASK_STATUS -{ - TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */ - const char *pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - UBaseType_t xTaskNumber; /* A number unique to the task. */ - eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */ - UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */ - UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ - uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ - uint16_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ -} TaskStatus_t; - -/* Possible return values for eTaskConfirmSleepModeStatus(). */ -typedef enum -{ - eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */ - eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */ - eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */ -} eSleepModeStatus; - - -/** - * Defines the priority used by the idle task. This must not be modified. - * - * \ingroup TaskUtils - */ -#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) - -/** - * task. h - * - * Macro for forcing a context switch. - * - * \defgroup taskYIELD taskYIELD - * \ingroup SchedulerControl - */ -#define taskYIELD() portYIELD() - -/** - * task. h - * - * Macro to mark the start of a critical code region. Preemptive context - * switches cannot occur when in a critical region. - * - * NOTE: This may alter the stack (depending on the portable implementation) - * so must be used with care! - * - * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL - * \ingroup SchedulerControl - */ -#define taskENTER_CRITICAL() portENTER_CRITICAL() -#define taskENTER_CRITICAL_FROM_ISR( x ) portSET_INTERRUPT_MASK_FROM_ISR( x ) - -/** - * task. h - * - * Macro to mark the end of a critical code region. Preemptive context - * switches cannot occur when in a critical region. - * - * NOTE: This may alter the stack (depending on the portable implementation) - * so must be used with care! - * - * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL - * \ingroup SchedulerControl - */ -#define taskEXIT_CRITICAL() portEXIT_CRITICAL() -#define taskEXIT_CRITICAL_FROM_ISR() portCLEAR_INTERRUPT_MASK_FROM_ISR() -/** - * task. h - * - * Macro to disable all maskable interrupts. - * - * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS - * \ingroup SchedulerControl - */ -#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() - -/** - * task. h - * - * Macro to enable microcontroller interrupts. - * - * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS - * \ingroup SchedulerControl - */ -#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() - -/* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is -0 to generate more optimal code when configASSERT() is defined as the constant -is used in assert() statements. */ -#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) -#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) -#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) - - -/*----------------------------------------------------------- - * TASK CREATION API - *----------------------------------------------------------*/ - -/** - * task. h - *
- BaseType_t xTaskCreate(
-							  TaskFunction_t pvTaskCode,
-							  const char * const pcName,
-							  uint16_t usStackDepth,
-							  void *pvParameters,
-							  UBaseType_t uxPriority,
-							  TaskHandle_t *pvCreatedTask
-						  );
- * - * Create a new task and add it to the list of tasks that are ready to run. - * - * xTaskCreate() can only be used to create a task that has unrestricted - * access to the entire microcontroller memory map. Systems that include MPU - * support can alternatively create an MPU constrained task using - * xTaskCreateRestricted(). - * - * @param pvTaskCode Pointer to the task entry function. Tasks - * must be implemented to never return (i.e. continuous loop). - * - * @param pcName A descriptive name for the task. This is mainly used to - * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default - * is 16. - * - * @param usStackDepth The size of the task stack specified as the number of - * variables the stack can hold - not the number of bytes. For example, if - * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes - * will be allocated for stack storage. - * - * @param pvParameters Pointer that will be used as the parameter for the task - * being created. - * - * @param uxPriority The priority at which the task should run. Systems that - * include MPU support can optionally create tasks in a privileged (system) - * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For - * example, to create a privileged task at priority 2 the uxPriority parameter - * should be set to ( 2 | portPRIVILEGE_BIT ). - * - * @param pvCreatedTask Used to pass back a handle by which the created task - * can be referenced. - * - * @return pdPASS if the task was successfully created and added to a ready - * list, otherwise an error code defined in the file projdefs.h - * - * Example usage: -
- // Task to be created.
- void vTaskCode( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-	 }
- }
-
- // Function that creates a task.
- void vOtherFunction( void )
- {
- static uint8_t ucParameterToPass;
- TaskHandle_t xHandle = NULL;
-
-	 // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass
-	 // must exist for the lifetime of the task, so in this case is declared static.  If it was just an
-	 // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
-	 // the new task attempts to access it.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
-     configASSERT( xHandle );
-
-	 // Use the handle to delete the task.
-     if( xHandle != NULL )
-     {
-	     vTaskDelete( xHandle );
-     }
- }
-   
- * \defgroup xTaskCreate xTaskCreate - * \ingroup Tasks - */ -#define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) ) - -/** - * task. h - *
- BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
- * - * xTaskCreateRestricted() should only be used in systems that include an MPU - * implementation. - * - * Create a new task and add it to the list of tasks that are ready to run. - * The function parameters define the memory regions and associated access - * permissions allocated to the task. - * - * @param pxTaskDefinition Pointer to a structure that contains a member - * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API - * documentation) plus an optional stack buffer and the memory region - * definitions. - * - * @param pxCreatedTask Used to pass back a handle by which the created task - * can be referenced. - * - * @return pdPASS if the task was successfully created and added to a ready - * list, otherwise an error code defined in the file projdefs.h - * - * Example usage: -
-// Create an TaskParameters_t structure that defines the task to be created.
-static const TaskParameters_t xCheckTaskParameters =
-{
-	vATask,		// pvTaskCode - the function that implements the task.
-	"ATask",	// pcName - just a text name for the task to assist debugging.
-	100,		// usStackDepth	- the stack size DEFINED IN WORDS.
-	NULL,		// pvParameters - passed into the task function as the function parameters.
-	( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
-	cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
-
-	// xRegions - Allocate up to three separate memory regions for access by
-	// the task, with appropriate access permissions.  Different processors have
-	// different memory alignment requirements - refer to the FreeRTOS documentation
-	// for full information.
-	{
-		// Base address					Length	Parameters
-        { cReadWriteArray,				32,		portMPU_REGION_READ_WRITE },
-        { cReadOnlyArray,				32,		portMPU_REGION_READ_ONLY },
-        { cPrivilegedOnlyAccessArray,	128,	portMPU_REGION_PRIVILEGED_READ_WRITE }
-	}
-};
-
-int main( void )
-{
-TaskHandle_t xHandle;
-
-	// Create a task from the const structure defined above.  The task handle
-	// is requested (the second parameter is not NULL) but in this case just for
-	// demonstration purposes as its not actually used.
-	xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
-
-	// Start the scheduler.
-	vTaskStartScheduler();
-
-	// Will only get here if there was insufficient memory to create the idle
-	// and/or timer task.
-	for( ;; );
-}
-   
- * \defgroup xTaskCreateRestricted xTaskCreateRestricted - * \ingroup Tasks - */ -#define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) ) - -/** - * task. h - *
- void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
- * - * Memory regions are assigned to a restricted task when the task is created by - * a call to xTaskCreateRestricted(). These regions can be redefined using - * vTaskAllocateMPURegions(). - * - * @param xTask The handle of the task being updated. - * - * @param xRegions A pointer to an MemoryRegion_t structure that contains the - * new memory region definitions. - * - * Example usage: -
-// Define an array of MemoryRegion_t structures that configures an MPU region
-// allowing read/write access for 1024 bytes starting at the beginning of the
-// ucOneKByte array.  The other two of the maximum 3 definable regions are
-// unused so set to zero.
-static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
-{
-	// Base address		Length		Parameters
-	{ ucOneKByte,		1024,		portMPU_REGION_READ_WRITE },
-	{ 0,				0,			0 },
-	{ 0,				0,			0 }
-};
-
-void vATask( void *pvParameters )
-{
-	// This task was created such that it has access to certain regions of
-	// memory as defined by the MPU configuration.  At some point it is
-	// desired that these MPU regions are replaced with that defined in the
-	// xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()
-	// for this purpose.  NULL is used as the task handle to indicate that this
-	// function should modify the MPU regions of the calling task.
-	vTaskAllocateMPURegions( NULL, xAltRegions );
-
-	// Now the task can continue its function, but from this point on can only
-	// access its stack and the ucOneKByte array (unless any other statically
-	// defined or shared regions have been declared elsewhere).
-}
-   
- * \defgroup xTaskCreateRestricted xTaskCreateRestricted - * \ingroup Tasks - */ -void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskDelete( TaskHandle_t xTask );
- * - * INCLUDE_vTaskDelete must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Remove a task from the RTOS real time kernel's management. The task being - * deleted will be removed from all ready, blocked, suspended and event lists. - * - * NOTE: The idle task is responsible for freeing the kernel allocated - * memory from tasks that have been deleted. It is therefore important that - * the idle task is not starved of microcontroller processing time if your - * application makes any calls to vTaskDelete (). Memory allocated by the - * task code is not automatically freed, and should be freed before the task - * is deleted. - * - * See the demo application file death.c for sample code that utilises - * vTaskDelete (). - * - * @param xTask The handle of the task to be deleted. Passing NULL will - * cause the calling task to be deleted. - * - * Example usage: -
- void vOtherFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create the task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // Use the handle to delete the task.
-	 vTaskDelete( xHandle );
- }
-   
- * \defgroup vTaskDelete vTaskDelete - * \ingroup Tasks - */ -void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; - -/*----------------------------------------------------------- - * TASK CONTROL API - *----------------------------------------------------------*/ - -/** - * task. h - *
void vTaskDelay( const TickType_t xTicksToDelay );
- * - * Delay a task for a given number of ticks. The actual time that the - * task remains blocked depends on the tick rate. The constant - * portTICK_PERIOD_MS can be used to calculate real time from the tick - * rate - with the resolution of one tick period. - * - * INCLUDE_vTaskDelay must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * - * vTaskDelay() specifies a time at which the task wishes to unblock relative to - * the time at which vTaskDelay() is called. For example, specifying a block - * period of 100 ticks will cause the task to unblock 100 ticks after - * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method - * of controlling the frequency of a periodic task as the path taken through the - * code, as well as other task and interrupt activity, will effect the frequency - * at which vTaskDelay() gets called and therefore the time at which the task - * next executes. See vTaskDelayUntil() for an alternative API function designed - * to facilitate fixed frequency execution. It does this by specifying an - * absolute time (rather than a relative time) at which the calling task should - * unblock. - * - * @param xTicksToDelay The amount of time, in tick periods, that - * the calling task should block. - * - * Example usage: - - void vTaskFunction( void * pvParameters ) - { - // Block for 500ms. - const TickType_t xDelay = 500 / portTICK_PERIOD_MS; - - for( ;; ) - { - // Simply toggle the LED every 500ms, blocking between each toggle. - vToggleLED(); - vTaskDelay( xDelay ); - } - } - - * \defgroup vTaskDelay vTaskDelay - * \ingroup TaskCtrl - */ -void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
- * - * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Delay a task until a specified time. This function can be used by periodic - * tasks to ensure a constant execution frequency. - * - * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will - * cause a task to block for the specified number of ticks from the time vTaskDelay () is - * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed - * execution frequency as the time between a task starting to execute and that task - * calling vTaskDelay () may not be fixed [the task may take a different path though the - * code between calls, or may get interrupted or preempted a different number of times - * each time it executes]. - * - * Whereas vTaskDelay () specifies a wake time relative to the time at which the function - * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to - * unblock. - * - * The constant portTICK_PERIOD_MS can be used to calculate real time from the tick - * rate - with the resolution of one tick period. - * - * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the - * task was last unblocked. The variable must be initialised with the current time - * prior to its first use (see the example below). Following this the variable is - * automatically updated within vTaskDelayUntil (). - * - * @param xTimeIncrement The cycle time period. The task will be unblocked at - * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the - * same xTimeIncrement parameter value will cause the task to execute with - * a fixed interface period. - * - * Example usage: -
- // Perform an action every 10 ticks.
- void vTaskFunction( void * pvParameters )
- {
- TickType_t xLastWakeTime;
- const TickType_t xFrequency = 10;
-
-	 // Initialise the xLastWakeTime variable with the current time.
-	 xLastWakeTime = xTaskGetTickCount ();
-	 for( ;; )
-	 {
-		 // Wait for the next cycle.
-		 vTaskDelayUntil( &xLastWakeTime, xFrequency );
-
-		 // Perform action here.
-	 }
- }
-   
- * \defgroup vTaskDelayUntil vTaskDelayUntil - * \ingroup TaskCtrl - */ -void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );
- * - * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Obtain the priority of any task. - * - * @param xTask Handle of the task to be queried. Passing a NULL - * handle results in the priority of the calling task being returned. - * - * @return The priority of xTask. - * - * Example usage: -
- void vAFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to obtain the priority of the created task.
-	 // It was created with tskIDLE_PRIORITY, but may have changed
-	 // it itself.
-	 if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
-	 {
-		 // The task has changed it's priority.
-	 }
-
-	 // ...
-
-	 // Is our priority higher than the created task?
-	 if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
-	 {
-		 // Our priority (obtained using NULL handle) is higher.
-	 }
- }
-   
- * \defgroup uxTaskPriorityGet uxTaskPriorityGet - * \ingroup TaskCtrl - */ -UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask );
- * - * A version of uxTaskPriorityGet() that can be used from an ISR. - */ -UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
eTaskState eTaskGetState( TaskHandle_t xTask );
- * - * INCLUDE_eTaskGetState must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Obtain the state of any task. States are encoded by the eTaskState - * enumerated type. - * - * @param xTask Handle of the task to be queried. - * - * @return The state of xTask at the time the function was called. Note the - * state of the task might change between the function being called, and the - * functions return value being tested by the calling task. - */ -eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
- * - * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Set the priority of any task. - * - * A context switch will occur before the function returns if the priority - * being set is higher than the currently executing task. - * - * @param xTask Handle to the task for which the priority is being set. - * Passing a NULL handle results in the priority of the calling task being set. - * - * @param uxNewPriority The priority to which the task will be set. - * - * Example usage: -
- void vAFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to raise the priority of the created task.
-	 vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
-
-	 // ...
-
-	 // Use a NULL handle to raise our priority to the same value.
-	 vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
- }
-   
- * \defgroup vTaskPrioritySet vTaskPrioritySet - * \ingroup TaskCtrl - */ -void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskSuspend( TaskHandle_t xTaskToSuspend );
- * - * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Suspend any task. When suspended a task will never get any microcontroller - * processing time, no matter what its priority. - * - * Calls to vTaskSuspend are not accumulative - - * i.e. calling vTaskSuspend () twice on the same task still only requires one - * call to vTaskResume () to ready the suspended task. - * - * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL - * handle will cause the calling task to be suspended. - * - * Example usage: -
- void vAFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to suspend the created task.
-	 vTaskSuspend( xHandle );
-
-	 // ...
-
-	 // The created task will not run during this period, unless
-	 // another task calls vTaskResume( xHandle ).
-
-	 //...
-
-
-	 // Suspend ourselves.
-	 vTaskSuspend( NULL );
-
-	 // We cannot get here unless another task calls vTaskResume
-	 // with our handle as the parameter.
- }
-   
- * \defgroup vTaskSuspend vTaskSuspend - * \ingroup TaskCtrl - */ -void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskResume( TaskHandle_t xTaskToResume );
- * - * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Resumes a suspended task. - * - * A task that has been suspended by one or more calls to vTaskSuspend () - * will be made available for running again by a single call to - * vTaskResume (). - * - * @param xTaskToResume Handle to the task being readied. - * - * Example usage: -
- void vAFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to suspend the created task.
-	 vTaskSuspend( xHandle );
-
-	 // ...
-
-	 // The created task will not run during this period, unless
-	 // another task calls vTaskResume( xHandle ).
-
-	 //...
-
-
-	 // Resume the suspended task ourselves.
-	 vTaskResume( xHandle );
-
-	 // The created task will once again get microcontroller processing
-	 // time in accordance with its priority within the system.
- }
-   
- * \defgroup vTaskResume vTaskResume - * \ingroup TaskCtrl - */ -void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
- * - * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be - * available. See the configuration section for more information. - * - * An implementation of vTaskResume() that can be called from within an ISR. - * - * A task that has been suspended by one or more calls to vTaskSuspend () - * will be made available for running again by a single call to - * xTaskResumeFromISR (). - * - * xTaskResumeFromISR() should not be used to synchronise a task with an - * interrupt if there is a chance that the interrupt could arrive prior to the - * task being suspended - as this can lead to interrupts being missed. Use of a - * semaphore as a synchronisation mechanism would avoid this eventuality. - * - * @param xTaskToResume Handle to the task being readied. - * - * @return pdTRUE if resuming the task should result in a context switch, - * otherwise pdFALSE. This is used by the ISR to determine if a context switch - * may be required following the ISR. - * - * \defgroup vTaskResumeFromISR vTaskResumeFromISR - * \ingroup TaskCtrl - */ -BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; - -/*----------------------------------------------------------- - * SCHEDULER CONTROL - *----------------------------------------------------------*/ - -/** - * task. h - *
void vTaskStartScheduler( void );
- * - * Starts the real time kernel tick processing. After calling the kernel - * has control over which tasks are executed and when. - * - * See the demo application file main.c for an example of creating - * tasks and starting the kernel. - * - * Example usage: -
- void vAFunction( void )
- {
-	 // Create at least one task before starting the kernel.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
-
-	 // Start the real time kernel with preemption.
-	 vTaskStartScheduler ();
-
-	 // Will not get here unless a task calls vTaskEndScheduler ()
- }
-   
- * - * \defgroup vTaskStartScheduler vTaskStartScheduler - * \ingroup SchedulerControl - */ -void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskEndScheduler( void );
- * - * NOTE: At the time of writing only the x86 real mode port, which runs on a PC - * in place of DOS, implements this function. - * - * Stops the real time kernel tick. All created tasks will be automatically - * deleted and multitasking (either preemptive or cooperative) will - * stop. Execution then resumes from the point where vTaskStartScheduler () - * was called, as if vTaskStartScheduler () had just returned. - * - * See the demo application file main. c in the demo/PC directory for an - * example that uses vTaskEndScheduler (). - * - * vTaskEndScheduler () requires an exit function to be defined within the - * portable layer (see vPortEndScheduler () in port. c for the PC port). This - * performs hardware specific operations such as stopping the kernel tick. - * - * vTaskEndScheduler () will cause all of the resources allocated by the - * kernel to be freed - but will not free resources allocated by application - * tasks. - * - * Example usage: -
- void vTaskCode( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // At some point we want to end the real time kernel processing
-		 // so call ...
-		 vTaskEndScheduler ();
-	 }
- }
-
- void vAFunction( void )
- {
-	 // Create at least one task before starting the kernel.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
-
-	 // Start the real time kernel with preemption.
-	 vTaskStartScheduler ();
-
-	 // Will only get here when the vTaskCode () task has called
-	 // vTaskEndScheduler ().  When we get here we are back to single task
-	 // execution.
- }
-   
- * - * \defgroup vTaskEndScheduler vTaskEndScheduler - * \ingroup SchedulerControl - */ -void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
void vTaskSuspendAll( void );
- * - * Suspends the scheduler without disabling interrupts. Context switches will - * not occur while the scheduler is suspended. - * - * After calling vTaskSuspendAll () the calling task will continue to execute - * without risk of being swapped out until a call to xTaskResumeAll () has been - * made. - * - * API functions that have the potential to cause a context switch (for example, - * vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler - * is suspended. - * - * Example usage: -
- void vTask1( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // ...
-
-		 // At some point the task wants to perform a long operation during
-		 // which it does not want to get swapped out.  It cannot use
-		 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
-		 // operation may cause interrupts to be missed - including the
-		 // ticks.
-
-		 // Prevent the real time kernel swapping out the task.
-		 vTaskSuspendAll ();
-
-		 // Perform the operation here.  There is no need to use critical
-		 // sections as we have all the microcontroller processing time.
-		 // During this time interrupts will still operate and the kernel
-		 // tick count will be maintained.
-
-		 // ...
-
-		 // The operation is complete.  Restart the kernel.
-		 xTaskResumeAll ();
-	 }
- }
-   
- * \defgroup vTaskSuspendAll vTaskSuspendAll - * \ingroup SchedulerControl - */ -void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
BaseType_t xTaskResumeAll( void );
- * - * Resumes scheduler activity after it was suspended by a call to - * vTaskSuspendAll(). - * - * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks - * that were previously suspended by a call to vTaskSuspend(). - * - * @return If resuming the scheduler caused a context switch then pdTRUE is - * returned, otherwise pdFALSE is returned. - * - * Example usage: -
- void vTask1( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // ...
-
-		 // At some point the task wants to perform a long operation during
-		 // which it does not want to get swapped out.  It cannot use
-		 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
-		 // operation may cause interrupts to be missed - including the
-		 // ticks.
-
-		 // Prevent the real time kernel swapping out the task.
-		 vTaskSuspendAll ();
-
-		 // Perform the operation here.  There is no need to use critical
-		 // sections as we have all the microcontroller processing time.
-		 // During this time interrupts will still operate and the real
-		 // time kernel tick count will be maintained.
-
-		 // ...
-
-		 // The operation is complete.  Restart the kernel.  We want to force
-		 // a context switch - but there is no point if resuming the scheduler
-		 // caused a context switch already.
-		 if( !xTaskResumeAll () )
-		 {
-			  taskYIELD ();
-		 }
-	 }
- }
-   
- * \defgroup xTaskResumeAll xTaskResumeAll - * \ingroup SchedulerControl - */ -BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; - -/*----------------------------------------------------------- - * TASK UTILITIES - *----------------------------------------------------------*/ - -/** - * task. h - *
TickType_t xTaskGetTickCount( void );
- * - * @return The count of ticks since vTaskStartScheduler was called. - * - * \defgroup xTaskGetTickCount xTaskGetTickCount - * \ingroup TaskUtils - */ -TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
TickType_t xTaskGetTickCountFromISR( void );
- * - * @return The count of ticks since vTaskStartScheduler was called. - * - * This is a version of xTaskGetTickCount() that is safe to be called from an - * ISR - provided that TickType_t is the natural word size of the - * microcontroller being used or interrupt nesting is either not supported or - * not being used. - * - * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR - * \ingroup TaskUtils - */ -TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
uint16_t uxTaskGetNumberOfTasks( void );
- * - * @return The number of tasks that the real time kernel is currently managing. - * This includes all ready, blocked and suspended tasks. A task that - * has been deleted but not yet freed by the idle task will also be - * included in the count. - * - * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks - * \ingroup TaskUtils - */ -UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION; - -/** - * task. h - *
char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery );
- * - * @return The text (human readable) name of the task referenced by the handle - * xTaskToQuery. A task can query its own name by either passing in its own - * handle, or by setting xTaskToQuery to NULL. INCLUDE_pcTaskGetTaskName must be - * set to 1 in FreeRTOSConfig.h for pcTaskGetTaskName() to be available. - * - * \defgroup pcTaskGetTaskName pcTaskGetTaskName - * \ingroup TaskUtils - */ -char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/** - * task.h - *
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
- * - * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for - * this function to be available. - * - * Returns the high water mark of the stack associated with xTask. That is, - * the minimum free stack space there has been (in words, so on a 32 bit machine - * a value of 1 means 4 bytes) since the task started. The smaller the returned - * number the closer the task has come to overflowing its stack. - * - * @param xTask Handle of the task associated with the stack to be checked. - * Set xTask to NULL to check the stack of the calling task. - * - * @return The smallest amount of free stack space there has been (in words, so - * actual spaces on the stack rather than bytes) since the task referenced by - * xTask was created. - */ -UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - -/* When using trace macros it is sometimes necessary to include task.h before -FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, -so the following two prototypes will cause a compilation error. This can be -fixed by simply guarding against the inclusion of these two prototypes unless -they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration -constant. */ -#ifdef configUSE_APPLICATION_TASK_TAG - #if configUSE_APPLICATION_TASK_TAG == 1 - /** - * task.h - *
void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
- * - * Sets pxHookFunction to be the task hook function used by the task xTask. - * Passing xTask as NULL has the effect of setting the calling tasks hook - * function. - */ - void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION; - - /** - * task.h - *
void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
- * - * Returns the pxHookFunction value assigned to the task xTask. - */ - TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ -#endif /* ifdef configUSE_APPLICATION_TASK_TAG */ - -#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - - /* Each task contains an array of pointers that is dimensioned by the - configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The - kernel does not use the pointers itself, so the application writer can use - the pointers for any purpose they wish. The following two functions are - used to set and query a pointer respectively. */ - void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ); - void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ); - -#endif - -/** - * task.h - *
BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
- * - * Calls the hook function associated with xTask. Passing xTask as NULL has - * the effect of calling the Running tasks (the calling task) hook function. - * - * pvParameter is passed to the hook function for the task to interpret as it - * wants. The return value is the value returned by the task hook function - * registered by the user. - */ -BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) PRIVILEGED_FUNCTION; - -/** - * xTaskGetIdleTaskHandle() is only available if - * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h. - * - * Simply returns the handle of the idle task. It is not valid to call - * xTaskGetIdleTaskHandle() before the scheduler has been started. - */ -TaskHandle_t xTaskGetIdleTaskHandle( void ); - -/** - * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for - * uxTaskGetSystemState() to be available. - * - * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in - * the system. TaskStatus_t structures contain, among other things, members - * for the task handle, task name, task priority, task state, and total amount - * of run time consumed by the task. See the TaskStatus_t structure - * definition in this file for the full member list. - * - * NOTE: This function is intended for debugging use only as its use results in - * the scheduler remaining suspended for an extended period. - * - * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures. - * The array must contain at least one TaskStatus_t structure for each task - * that is under the control of the RTOS. The number of tasks under the control - * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function. - * - * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray - * parameter. The size is specified as the number of indexes in the array, or - * the number of TaskStatus_t structures contained in the array, not by the - * number of bytes in the array. - * - * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in - * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the - * total run time (as defined by the run time stats clock, see - * http://www.freertos.org/rtos-run-time-stats.html) since the target booted. - * pulTotalRunTime can be set to NULL to omit the total run time information. - * - * @return The number of TaskStatus_t structures that were populated by - * uxTaskGetSystemState(). This should equal the number returned by the - * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed - * in the uxArraySize parameter was too small. - * - * Example usage: -
-    // This example demonstrates how a human readable table of run time stats
-	// information is generated from raw data provided by uxTaskGetSystemState().
-	// The human readable table is written to pcWriteBuffer
-	void vTaskGetRunTimeStats( char *pcWriteBuffer )
-	{
-	TaskStatus_t *pxTaskStatusArray;
-	volatile UBaseType_t uxArraySize, x;
-	uint32_t ulTotalRunTime, ulStatsAsPercentage;
-
-		// Make sure the write buffer does not contain a string.
-		*pcWriteBuffer = 0x00;
-
-		// Take a snapshot of the number of tasks in case it changes while this
-		// function is executing.
-		uxArraySize = uxTaskGetNumberOfTasks();
-
-		// Allocate a TaskStatus_t structure for each task.  An array could be
-		// allocated statically at compile time.
-		pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
-
-		if( pxTaskStatusArray != NULL )
-		{
-			// Generate raw status information about each task.
-			uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
-
-			// For percentage calculations.
-			ulTotalRunTime /= 100UL;
-
-			// Avoid divide by zero errors.
-			if( ulTotalRunTime > 0 )
-			{
-				// For each populated position in the pxTaskStatusArray array,
-				// format the raw data as human readable ASCII data
-				for( x = 0; x < uxArraySize; x++ )
-				{
-					// What percentage of the total run time has the task used?
-					// This will always be rounded down to the nearest integer.
-					// ulTotalRunTimeDiv100 has already been divided by 100.
-					ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
-
-					if( ulStatsAsPercentage > 0UL )
-					{
-						sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
-					}
-					else
-					{
-						// If the percentage is zero here then the task has
-						// consumed less than 1% of the total run time.
-						sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
-					}
-
-					pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
-				}
-			}
-
-			// The array is no longer needed, free the memory it consumes.
-			vPortFree( pxTaskStatusArray );
-		}
-	}
-	
- */ -UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ); - -/** - * task. h - *
void vTaskList( char *pcWriteBuffer );
- * - * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must - * both be defined as 1 for this function to be available. See the - * configuration section of the FreeRTOS.org website for more information. - * - * NOTE 1: This function will disable interrupts for its duration. It is - * not intended for normal application runtime use but as a debug aid. - * - * Lists all the current tasks, along with their current state and stack - * usage high water mark. - * - * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or - * suspended ('S'). - * - * PLEASE NOTE: - * - * This function is provided for convenience only, and is used by many of the - * demo applications. Do not consider it to be part of the scheduler. - * - * vTaskList() calls uxTaskGetSystemState(), then formats part of the - * uxTaskGetSystemState() output into a human readable table that displays task - * names, states and stack usage. - * - * vTaskList() has a dependency on the sprintf() C library function that might - * bloat the code size, use a lot of stack, and provide different results on - * different platforms. An alternative, tiny, third party, and limited - * functionality implementation of sprintf() is provided in many of the - * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note - * printf-stdarg.c does not provide a full snprintf() implementation!). - * - * It is recommended that production systems call uxTaskGetSystemState() - * directly to get access to raw stats data, rather than indirectly through a - * call to vTaskList(). - * - * @param pcWriteBuffer A buffer into which the above mentioned details - * will be written, in ASCII form. This buffer is assumed to be large - * enough to contain the generated report. Approximately 40 bytes per - * task should be sufficient. - * - * \defgroup vTaskList vTaskList - * \ingroup TaskUtils - */ -void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/** - * task. h - *
void vTaskGetRunTimeStats( char *pcWriteBuffer );
- * - * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS - * must both be defined as 1 for this function to be available. The application - * must also then provide definitions for - * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() - * to configure a peripheral timer/counter and return the timers current count - * value respectively. The counter should be at least 10 times the frequency of - * the tick count. - * - * NOTE 1: This function will disable interrupts for its duration. It is - * not intended for normal application runtime use but as a debug aid. - * - * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total - * accumulated execution time being stored for each task. The resolution - * of the accumulated time value depends on the frequency of the timer - * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. - * Calling vTaskGetRunTimeStats() writes the total execution time of each - * task into a buffer, both as an absolute count value and as a percentage - * of the total system execution time. - * - * NOTE 2: - * - * This function is provided for convenience only, and is used by many of the - * demo applications. Do not consider it to be part of the scheduler. - * - * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the - * uxTaskGetSystemState() output into a human readable table that displays the - * amount of time each task has spent in the Running state in both absolute and - * percentage terms. - * - * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function - * that might bloat the code size, use a lot of stack, and provide different - * results on different platforms. An alternative, tiny, third party, and - * limited functionality implementation of sprintf() is provided in many of the - * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note - * printf-stdarg.c does not provide a full snprintf() implementation!). - * - * It is recommended that production systems call uxTaskGetSystemState() directly - * to get access to raw stats data, rather than indirectly through a call to - * vTaskGetRunTimeStats(). - * - * @param pcWriteBuffer A buffer into which the execution times will be - * written, in ASCII form. This buffer is assumed to be large enough to - * contain the generated report. Approximately 40 bytes per task should - * be sufficient. - * - * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats - * \ingroup TaskUtils - */ -void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/** - * task. h - *
BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
- * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. - * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). - * - * Events can be sent to a task using an intermediary object. Examples of such - * objects are queues, semaphores, mutexes and event groups. Task notifications - * are a method of sending an event directly to a task without the need for such - * an intermediary object. - * - * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. - * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does - * not consume any CPU time while it is in the Blocked state. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. - * - * @param xTaskToNotify The handle of the task being notified. The handle to a - * task can be returned from the xTaskCreate() API function used to create the - * task, and the handle of the currently running task can be obtained by calling - * xTaskGetCurrentTaskHandle(). - * - * @param ulValue Data that can be sent with the notification. How the data is - * used depends on the value of the eAction parameter. - * - * @param eAction Specifies how the notification updates the task's notification - * value, if at all. Valid values for eAction are as follows: - * - * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() - * always returns pdPASS in this case. - * - * eIncrement - - * The task's notification value is incremented. ulValue is not used and - * xTaskNotify() always returns pdPASS in this case. - * - * eSetValueWithOverwrite - - * The task's notification value is set to the value of ulValue, even if the - * task being notified had not yet processed the previous notification (the - * task already had a notification pending). xTaskNotify() always returns - * pdPASS in this case. - * - * eSetValueWithoutOverwrite - - * If the task being notified did not already have a notification pending then - * the task's notification value is set to ulValue and xTaskNotify() will - * return pdPASS. If the task being notified already had a notification - * pending then no action is performed and pdFAIL is returned. - * - * eNoAction - - * The task receives a notification without its notification value being - * updated. ulValue is not used and xTaskNotify() always returns pdPASS in - * this case. - * - * pulPreviousNotificationValue - - * Can be used to pass out the subject task's notification value before any - * bits are modified by the notify function. - * - * @return Dependent on the value of eAction. See the description of the - * eAction parameter. - * - * \defgroup xTaskNotify xTaskNotify - * \ingroup TaskNotifications - */ -BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ); -#define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL ) -#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) - -/** - * task. h - *
BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
- * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. - * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). - * - * A version of xTaskNotify() that can be used from an interrupt service routine - * (ISR). - * - * Events can be sent to a task using an intermediary object. Examples of such - * objects are queues, semaphores, mutexes and event groups. Task notifications - * are a method of sending an event directly to a task without the need for such - * an intermediary object. - * - * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. - * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does - * not consume any CPU time while it is in the Blocked state. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. - * - * @param xTaskToNotify The handle of the task being notified. The handle to a - * task can be returned from the xTaskCreate() API function used to create the - * task, and the handle of the currently running task can be obtained by calling - * xTaskGetCurrentTaskHandle(). - * - * @param ulValue Data that can be sent with the notification. How the data is - * used depends on the value of the eAction parameter. - * - * @param eAction Specifies how the notification updates the task's notification - * value, if at all. Valid values for eAction are as follows: - * - * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() - * always returns pdPASS in this case. - * - * eIncrement - - * The task's notification value is incremented. ulValue is not used and - * xTaskNotify() always returns pdPASS in this case. - * - * eSetValueWithOverwrite - - * The task's notification value is set to the value of ulValue, even if the - * task being notified had not yet processed the previous notification (the - * task already had a notification pending). xTaskNotify() always returns - * pdPASS in this case. - * - * eSetValueWithoutOverwrite - - * If the task being notified did not already have a notification pending then - * the task's notification value is set to ulValue and xTaskNotify() will - * return pdPASS. If the task being notified already had a notification - * pending then no action is performed and pdFAIL is returned. - * - * eNoAction - - * The task receives a notification without its notification value being - * updated. ulValue is not used and xTaskNotify() always returns pdPASS in - * this case. - * - * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set - * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the - * task to which the notification was sent to leave the Blocked state, and the - * unblocked task has a priority higher than the currently running task. If - * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should - * be requested before the interrupt is exited. How a context switch is - * requested from an ISR is dependent on the port - see the documentation page - * for the port in use. - * - * @return Dependent on the value of eAction. See the description of the - * eAction parameter. - * - * \defgroup xTaskNotify xTaskNotify - * \ingroup TaskNotifications - */ -BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); - -/** - * task. h - *
BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
- * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. - * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). - * - * Events can be sent to a task using an intermediary object. Examples of such - * objects are queues, semaphores, mutexes and event groups. Task notifications - * are a method of sending an event directly to a task without the need for such - * an intermediary object. - * - * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. - * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does - * not consume any CPU time while it is in the Blocked state. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. - * - * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value - * will be cleared in the calling task's notification value before the task - * checks to see if any notifications are pending, and optionally blocks if no - * notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if - * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have - * the effect of resetting the task's notification value to 0. Setting - * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged. - * - * @param ulBitsToClearOnExit If a notification is pending or received before - * the calling task exits the xTaskNotifyWait() function then the task's - * notification value (see the xTaskNotify() API function) is passed out using - * the pulNotificationValue parameter. Then any bits that are set in - * ulBitsToClearOnExit will be cleared in the task's notification value (note - * *pulNotificationValue is set before any bits are cleared). Setting - * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL - * (if limits.h is not included) will have the effect of resetting the task's - * notification value to 0 before the function exits. Setting - * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged - * when the function exits (in which case the value passed out in - * pulNotificationValue will match the task's notification value). - * - * @param pulNotificationValue Used to pass the task's notification value out - * of the function. Note the value passed out will not be effected by the - * clearing of any bits caused by ulBitsToClearOnExit being non-zero. - * - * @param xTicksToWait The maximum amount of time that the task should wait in - * the Blocked state for a notification to be received, should a notification - * not already be pending when xTaskNotifyWait() was called. The task - * will not consume any processing time while it is in the Blocked state. This - * is specified in kernel ticks, the macro pdMS_TO_TICSK( value_in_ms ) can be - * used to convert a time specified in milliseconds to a time specified in - * ticks. - * - * @return If a notification was received (including notifications that were - * already pending when xTaskNotifyWait was called) then pdPASS is - * returned. Otherwise pdFAIL is returned. - * - * \defgroup xTaskNotifyWait xTaskNotifyWait - * \ingroup TaskNotifications - */ -BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); - -/** - * task. h - *
BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );
- * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro - * to be available. - * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). - * - * Events can be sent to a task using an intermediary object. Examples of such - * objects are queues, semaphores, mutexes and event groups. Task notifications - * are a method of sending an event directly to a task without the need for such - * an intermediary object. - * - * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. - * - * xTaskNotifyGive() is a helper macro intended for use when task notifications - * are used as light weight and faster binary or counting semaphore equivalents. - * Actual FreeRTOS semaphores are given using the xSemaphoreGive() API function, - * the equivalent action that instead uses a task notification is - * xTaskNotifyGive(). - * - * When task notifications are being used as a binary or counting semaphore - * equivalent then the task being notified should wait for the notification - * using the ulTaskNotificationTake() API function rather than the - * xTaskNotifyWait() API function. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details. - * - * @param xTaskToNotify The handle of the task being notified. The handle to a - * task can be returned from the xTaskCreate() API function used to create the - * task, and the handle of the currently running task can be obtained by calling - * xTaskGetCurrentTaskHandle(). - * - * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the - * eAction parameter set to eIncrement - so pdPASS is always returned. - * - * \defgroup xTaskNotifyGive xTaskNotifyGive - * \ingroup TaskNotifications - */ -#define xTaskNotifyGive( xTaskToNotify ) xTaskNotify( ( xTaskToNotify ), 0, eIncrement ); - -/** - * task. h - *
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
- *
- * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
- * to be available.
- *
- * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
- * "notification value", which is a 32-bit unsigned integer (uint32_t).
- *
- * A version of xTaskNotifyGive() that can be called from an interrupt service
- * routine (ISR).
- *
- * Events can be sent to a task using an intermediary object.  Examples of such
- * objects are queues, semaphores, mutexes and event groups.  Task notifications
- * are a method of sending an event directly to a task without the need for such
- * an intermediary object.
- *
- * A notification sent to a task can optionally perform an action, such as
- * update, overwrite or increment the task's notification value.  In that way
- * task notifications can be used to send data to a task, or be used as light
- * weight and fast binary or counting semaphores.
- *
- * vTaskNotifyGiveFromISR() is intended for use when task notifications are
- * used as light weight and faster binary or counting semaphore equivalents.
- * Actual FreeRTOS semaphores are given from an ISR using the
- * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
- * a task notification is vTaskNotifyGiveFromISR().
- *
- * When task notifications are being used as a binary or counting semaphore
- * equivalent then the task being notified should wait for the notification
- * using the ulTaskNotificationTake() API function rather than the
- * xTaskNotifyWait() API function.
- *
- * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
- *
- * @param xTaskToNotify The handle of the task being notified.  The handle to a
- * task can be returned from the xTaskCreate() API function used to create the
- * task, and the handle of the currently running task can be obtained by calling
- * xTaskGetCurrentTaskHandle().
- *
- * @param pxHigherPriorityTaskWoken  vTaskNotifyGiveFromISR() will set
- * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
- * task to which the notification was sent to leave the Blocked state, and the
- * unblocked task has a priority higher than the currently running task.  If
- * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
- * should be requested before the interrupt is exited.  How a context switch is
- * requested from an ISR is dependent on the port - see the documentation page
- * for the port in use.
- *
- * \defgroup xTaskNotifyWait xTaskNotifyWait
- * \ingroup TaskNotifications
- */
-void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken );
-
-/**
- * task. h
- * 
uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
- * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. - * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). - * - * Events can be sent to a task using an intermediary object. Examples of such - * objects are queues, semaphores, mutexes and event groups. Task notifications - * are a method of sending an event directly to a task without the need for such - * an intermediary object. - * - * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. - * - * ulTaskNotifyTake() is intended for use when a task notification is used as a - * faster and lighter weight binary or counting semaphore alternative. Actual - * FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the - * equivalent action that instead uses a task notification is - * ulTaskNotifyTake(). - * - * When a task is using its notification value as a binary or counting semaphore - * other tasks should send notifications to it using the xTaskNotifyGive() - * macro, or xTaskNotify() function with the eAction parameter set to - * eIncrement. - * - * ulTaskNotifyTake() can either clear the task's notification value to - * zero on exit, in which case the notification value acts like a binary - * semaphore, or decrement the task's notification value on exit, in which case - * the notification value acts like a counting semaphore. - * - * A task can use ulTaskNotifyTake() to [optionally] block to wait for a - * the task's notification value to be non-zero. The task does not consume any - * CPU time while it is in the Blocked state. - * - * Where as xTaskNotifyWait() will return when a notification is pending, - * ulTaskNotifyTake() will return when the task's notification value is - * not zero. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. - * - * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's - * notification value is decremented when the function exits. In this way the - * notification value acts like a counting semaphore. If xClearCountOnExit is - * not pdFALSE then the task's notification value is cleared to zero when the - * function exits. In this way the notification value acts like a binary - * semaphore. - * - * @param xTicksToWait The maximum amount of time that the task should wait in - * the Blocked state for the task's notification value to be greater than zero, - * should the count not already be greater than zero when - * ulTaskNotifyTake() was called. The task will not consume any processing - * time while it is in the Blocked state. This is specified in kernel ticks, - * the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time - * specified in milliseconds to a time specified in ticks. - * - * @return The task's notification count before it is either cleared to zero or - * decremented (see the xClearCountOnExit parameter). - * - * \defgroup ulTaskNotifyTake ulTaskNotifyTake - * \ingroup TaskNotifications - */ -uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); - -/*----------------------------------------------------------- - * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES - *----------------------------------------------------------*/ - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY - * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS - * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * Called from the real time kernel tick (either preemptive or cooperative), - * this increments the tick count and checks if any tasks that are blocked - * for a finite period required removing from a blocked list and placing on - * a ready list. If a non-zero value is returned then a context switch is - * required because either: - * + A task was removed from a blocked list because its timeout had expired, - * or - * + Time slicing is in use and there is a task of equal priority to the - * currently running task. - */ -BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN - * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. - * - * Removes the calling task from the ready list and places it both - * on the list of tasks waiting for a particular event, and the - * list of delayed tasks. The task will be removed from both lists - * and replaced on the ready list should either the event occur (and - * there be no higher priority tasks waiting on the same event) or - * the delay period expires. - * - * The 'unordered' version replaces the event list item value with the - * xItemValue value, and inserts the list item at the end of the list. - * - * The 'ordered' version uses the existing event list item value (which is the - * owning tasks priority) to insert the list item into the event list is task - * priority order. - * - * @param pxEventList The list containing tasks that are blocked waiting - * for the event to occur. - * - * @param xItemValue The item value to use for the event list item when the - * event list is not ordered by task priority. - * - * @param xTicksToWait The maximum amount of time that the task should wait - * for the event to occur. This is specified in kernel ticks,the constant - * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time - * period. - */ -void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN - * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. - * - * This function performs nearly the same function as vTaskPlaceOnEventList(). - * The difference being that this function does not permit tasks to block - * indefinitely, whereas vTaskPlaceOnEventList() does. - * - */ -void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN - * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED. - * - * Removes a task from both the specified event list and the list of blocked - * tasks, and places it on a ready queue. - * - * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called - * if either an event occurs to unblock a task, or the block timeout period - * expires. - * - * xTaskRemoveFromEventList() is used when the event list is in task priority - * order. It removes the list item from the head of the event list as that will - * have the highest priority owning task of all the tasks on the event list. - * xTaskRemoveFromUnorderedEventList() is used when the event list is not - * ordered and the event list items hold something other than the owning tasks - * priority. In this case the event list item value is updated to the value - * passed in the xItemValue parameter. - * - * @return pdTRUE if the task being removed has a higher priority than the task - * making the call, otherwise pdFALSE. - */ -BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION; -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION; - -/* - * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY - * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS - * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER. - * - * Sets the pointer to the current TCB to the TCB of the highest priority task - * that is ready to run. - */ -void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; - -/* - * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY - * THE EVENT BITS MODULE. - */ -TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION; - -/* - * Return the handle of the calling task. - */ -TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION; - -/* - * Capture the current time status for future reference. - */ -void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; - -/* - * Compare the time status now with that previously captured to see if the - * timeout has expired. - */ -BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; - -/* - * Shortcut used by the queue implementation to prevent unnecessary call to - * taskYIELD(); - */ -void vTaskMissedYield( void ) PRIVILEGED_FUNCTION; - -/* - * Returns the scheduler state as taskSCHEDULER_RUNNING, - * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED. - */ -BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION; - -/* - * Raises the priority of the mutex holder to that of the calling task should - * the mutex holder have a priority less than the calling task. - */ -void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION; - -/* - * Set the priority of a task back to its proper priority in the case that it - * inherited a higher priority while it was holding a semaphore. - */ -BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION; - -/* - * Generic version of the task creation function which is in turn called by the - * xTaskCreate() and xTaskCreateRestricted() macros. - */ -BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/* - * Get the uxTCBNumber assigned to the task referenced by the xTask parameter. - */ -UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - -/* - * Set the uxTaskNumber of the task referenced by the xTask parameter to - * uxHandle. - */ -void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; - -/* - * Only available when configUSE_TICKLESS_IDLE is set to 1. - * If tickless mode is being used, or a low power mode is implemented, then - * the tick interrupt will not execute during idle periods. When this is the - * case, the tick count value maintained by the scheduler needs to be kept up - * to date with the actual execution time by being skipped forward by a time - * equal to the idle period. - */ -void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION; - -/* - * Only avilable when configUSE_TICKLESS_IDLE is set to 1. - * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port - * specific sleep function to determine if it is ok to proceed with the sleep, - * and if it is ok to proceed, if it is ok to sleep indefinitely. - * - * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only - * called with the scheduler suspended, not from within a critical section. It - * is therefore possible for an interrupt to request a context switch between - * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being - * entered. eTaskConfirmSleepModeStatus() should be called from a short - * critical section between the timer being stopped and the sleep mode being - * entered to ensure it is ok to proceed into the sleep mode. - */ -eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION; - -/* - * For internal use only. Increment the mutex held count when a mutex is - * taken and return the handle of the task that has taken the mutex. - */ -void *pvTaskIncrementMutexHeldCount( void ); - -#ifdef __cplusplus -} -#endif -#endif /* INC_TASK_H */ - - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/tasks.c b/GD32F1/libraries/FreeRTOS821/utility/tasks.c deleted file mode 100644 index df08d30..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/tasks.c +++ /dev/null @@ -1,4387 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/* Standard includes. */ -#include -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "StackMacros.h" - -/* Lint e961 and e750 are suppressed as a MISRA exception justified because the -MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the -header files above, but not in this file, in order to generate the correct -privileged Vs unprivileged linkage and placement. */ -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */ - -/* Set configUSE_STATS_FORMATTING_FUNCTIONS to 2 to include the stats formatting -functions but without including stdio.h here. */ -#if ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) - /* At the bottom of this file are two optional functions that can be used - to generate human readable text from the raw data generated by the - uxTaskGetSystemState() function. Note the formatting functions are provided - for convenience only, and are NOT considered part of the kernel. */ - #include -#endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */ - -/* Sanity check the configuration. */ -#if configUSE_TICKLESS_IDLE != 0 - #if INCLUDE_vTaskSuspend != 1 - #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 - #endif /* INCLUDE_vTaskSuspend */ -#endif /* configUSE_TICKLESS_IDLE */ - -/* - * Defines the size, in words, of the stack allocated to the idle task. - */ -#define tskIDLE_STACK_SIZE configMINIMAL_STACK_SIZE - -#if( configUSE_PREEMPTION == 0 ) - /* If the cooperative scheduler is being used then a yield should not be - performed just because a higher priority task has been woken. */ - #define taskYIELD_IF_USING_PREEMPTION() -#else - #define taskYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API() -#endif - -/* Value that can be assigned to the eNotifyState member of the TCB. */ -typedef enum -{ - eNotWaitingNotification = 0, - eWaitingNotification, - eNotified -} eNotifyValue; - -/* - * Task control block. A task control block (TCB) is allocated for each task, - * and stores task state information, including a pointer to the task's context - * (the task's run time environment, including register values) - */ -typedef struct tskTaskControlBlock -{ - volatile StackType_t *pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */ - - #if ( portUSING_MPU_WRAPPERS == 1 ) - xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */ - BaseType_t xUsingStaticallyAllocatedStack; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */ - #endif - - ListItem_t xGenericListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */ - ListItem_t xEventListItem; /*< Used to reference a task from an event list. */ - UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */ - StackType_t *pxStack; /*< Points to the start of the stack. */ - char pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - - #if ( portSTACK_GROWTH > 0 ) - StackType_t *pxEndOfStack; /*< Points to the end of the stack on architectures where the stack grows up from low memory. */ - #endif - - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - UBaseType_t uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */ - #endif - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxTCBNumber; /*< Stores a number that increments each time a TCB is created. It allows debuggers to determine when a task has been deleted and then recreated. */ - UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */ - #endif - - #if ( configUSE_MUTEXES == 1 ) - UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */ - UBaseType_t uxMutexesHeld; - #endif - - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - TaskHookFunction_t pxTaskTag; - #endif - - #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #endif - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */ - #endif - - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - /* Allocate a Newlib reent structure that is specific to this task. - Note Newlib support has been included by popular demand, but is not - used by the FreeRTOS maintainers themselves. FreeRTOS is not - responsible for resulting newlib operation. User must be familiar with - newlib and must provide system-wide implementations of the necessary - stubs. Be warned that (at the time of writing) the current newlib design - implements a system-wide malloc() that must be provided with locks. */ - struct _reent xNewLib_reent; - #endif - - #if ( configUSE_TASK_NOTIFICATIONS == 1 ) - volatile uint32_t ulNotifiedValue; - volatile eNotifyValue eNotifyState; - #endif - -} tskTCB; - -/* The old tskTCB name is maintained above then typedefed to the new TCB_t name -below to enable the use of older kernel aware debuggers. */ -typedef tskTCB TCB_t; - -/* - * Some kernel aware debuggers require the data the debugger needs access to to - * be global, rather than file scope. - */ -#ifdef portREMOVE_STATIC_QUALIFIER - #define static -#endif - -/*lint -e956 A manual analysis and inspection has been used to determine which -static variables must be declared volatile. */ - -PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL; - -/* Lists for ready and blocked tasks. --------------------*/ -PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ];/*< Prioritised ready tasks. */ -PRIVILEGED_DATA static List_t xDelayedTaskList1; /*< Delayed tasks. */ -PRIVILEGED_DATA static List_t xDelayedTaskList2; /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */ -PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList; /*< Points to the delayed task list currently being used. */ -PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList; /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */ -PRIVILEGED_DATA static List_t xPendingReadyList; /*< Tasks that have been readied while the scheduler was suspended. They will be moved to the ready list when the scheduler is resumed. */ - -#if ( INCLUDE_vTaskDelete == 1 ) - - PRIVILEGED_DATA static List_t xTasksWaitingTermination; /*< Tasks that have been deleted - but their memory not yet freed. */ - PRIVILEGED_DATA static volatile UBaseType_t uxTasksDeleted = ( UBaseType_t ) 0U; - -#endif - -#if ( INCLUDE_vTaskSuspend == 1 ) - - PRIVILEGED_DATA static List_t xSuspendedTaskList; /*< Tasks that are currently suspended. */ - -#endif - -#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) - - PRIVILEGED_DATA static TaskHandle_t xIdleTaskHandle = NULL; /*< Holds the handle of the idle task. The idle task is created automatically when the scheduler is started. */ - -#endif - -/* Other file private variables. --------------------------------*/ -PRIVILEGED_DATA static volatile UBaseType_t uxCurrentNumberOfTasks = ( UBaseType_t ) 0U; -PRIVILEGED_DATA static volatile TickType_t xTickCount = ( TickType_t ) 0U; -PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY; -PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning = pdFALSE; -PRIVILEGED_DATA static volatile UBaseType_t uxPendedTicks = ( UBaseType_t ) 0U; -PRIVILEGED_DATA static volatile BaseType_t xYieldPending = pdFALSE; -PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0; -PRIVILEGED_DATA static UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U; -PRIVILEGED_DATA static volatile TickType_t xNextTaskUnblockTime = portMAX_DELAY; - -/* Context switches are held pending while the scheduler is suspended. Also, -interrupts must not manipulate the xGenericListItem of a TCB, or any of the -lists the xGenericListItem can be referenced from, if the scheduler is suspended. -If an interrupt needs to unblock a task while the scheduler is suspended then it -moves the task's event list item into the xPendingReadyList, ready for the -kernel to move the task from the pending ready list into the real ready list -when the scheduler is unsuspended. The pending ready list itself can only be -accessed from a critical section. */ -PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) pdFALSE; - -#if ( configGENERATE_RUN_TIME_STATS == 1 ) - - PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */ - PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */ - -#endif - -/*lint +e956 */ - -/* Debugging and trace facilities private variables and macros. ------------*/ - -/* - * The value used to fill the stack of a task when the task is created. This - * is used purely for checking the high water mark for tasks. - */ -#define tskSTACK_FILL_BYTE ( 0xa5U ) - -/* - * Macros used by vListTask to indicate which state a task is in. - */ -#define tskBLOCKED_CHAR ( 'B' ) -#define tskREADY_CHAR ( 'R' ) -#define tskDELETED_CHAR ( 'D' ) -#define tskSUSPENDED_CHAR ( 'S' ) - -/*-----------------------------------------------------------*/ - -#if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) - - /* If configUSE_PORT_OPTIMISED_TASK_SELECTION is 0 then task selection is - performed in a generic way that is not optimised to any particular - microcontroller architecture. */ - - /* uxTopReadyPriority holds the priority of the highest priority ready - state task. */ - #define taskRECORD_READY_PRIORITY( uxPriority ) \ - { \ - if( ( uxPriority ) > uxTopReadyPriority ) \ - { \ - uxTopReadyPriority = ( uxPriority ); \ - } \ - } /* taskRECORD_READY_PRIORITY */ - - /*-----------------------------------------------------------*/ - - #define taskSELECT_HIGHEST_PRIORITY_TASK() \ - { \ - /* Find the highest priority queue that contains ready tasks. */ \ - while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) ) \ - { \ - configASSERT( uxTopReadyPriority ); \ - --uxTopReadyPriority; \ - } \ - \ - /* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of \ - the same priority get an equal share of the processor time. */ \ - listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) ); \ - } /* taskSELECT_HIGHEST_PRIORITY_TASK */ - - /*-----------------------------------------------------------*/ - - /* Define away taskRESET_READY_PRIORITY() and portRESET_READY_PRIORITY() as - they are only required when a port optimised method of task selection is - being used. */ - #define taskRESET_READY_PRIORITY( uxPriority ) - #define portRESET_READY_PRIORITY( uxPriority, uxTopReadyPriority ) - -#else /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - - /* If configUSE_PORT_OPTIMISED_TASK_SELECTION is 1 then task selection is - performed in a way that is tailored to the particular microcontroller - architecture being used. */ - - /* A port optimised version is provided. Call the port defined macros. */ - #define taskRECORD_READY_PRIORITY( uxPriority ) portRECORD_READY_PRIORITY( uxPriority, uxTopReadyPriority ) - - /*-----------------------------------------------------------*/ - - #define taskSELECT_HIGHEST_PRIORITY_TASK() \ - { \ - UBaseType_t uxTopPriority; \ - \ - /* Find the highest priority queue that contains ready tasks. */ \ - portGET_HIGHEST_PRIORITY( uxTopPriority, uxTopReadyPriority ); \ - configASSERT( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ uxTopPriority ] ) ) > 0 ); \ - listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) ); \ - } /* taskSELECT_HIGHEST_PRIORITY_TASK() */ - - /*-----------------------------------------------------------*/ - - /* A port optimised version is provided, call it only if the TCB being reset - is being referenced from a ready list. If it is referenced from a delayed - or suspended list then it won't be in a ready list. */ - #define taskRESET_READY_PRIORITY( uxPriority ) \ - { \ - if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ ( uxPriority ) ] ) ) == ( UBaseType_t ) 0 ) \ - { \ - portRESET_READY_PRIORITY( ( uxPriority ), ( uxTopReadyPriority ) ); \ - } \ - } - -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -/*-----------------------------------------------------------*/ - -/* pxDelayedTaskList and pxOverflowDelayedTaskList are switched when the tick -count overflows. */ -#define taskSWITCH_DELAYED_LISTS() \ -{ \ - List_t *pxTemp; \ - \ - /* The delayed tasks list should be empty when the lists are switched. */ \ - configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) ); \ - \ - pxTemp = pxDelayedTaskList; \ - pxDelayedTaskList = pxOverflowDelayedTaskList; \ - pxOverflowDelayedTaskList = pxTemp; \ - xNumOfOverflows++; \ - prvResetNextTaskUnblockTime(); \ -} - -/*-----------------------------------------------------------*/ - -/* - * Place the task represented by pxTCB into the appropriate ready list for - * the task. It is inserted at the end of the list. - */ -#define prvAddTaskToReadyList( pxTCB ) \ - traceMOVED_TASK_TO_READY_STATE( pxTCB ); \ - taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \ - vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) ) -/*-----------------------------------------------------------*/ - -/* - * Several functions take an TaskHandle_t parameter that can optionally be NULL, - * where NULL is used to indicate that the handle of the currently executing - * task should be used in place of the parameter. This macro simply checks to - * see if the parameter is NULL and returns a pointer to the appropriate TCB. - */ -#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( TCB_t * ) pxCurrentTCB : ( TCB_t * ) ( pxHandle ) ) - -/* The item value of the event list item is normally used to hold the priority -of the task to which it belongs (coded to allow it to be held in reverse -priority order). However, it is occasionally borrowed for other purposes. It -is important its value is not updated due to a task priority change while it is -being used for another purpose. The following bit definition is used to inform -the scheduler that the value should not be changed - in which case it is the -responsibility of whichever module is using the value to ensure it gets set back -to its original value when it is released. */ -#if configUSE_16_BIT_TICKS == 1 - #define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x8000U -#else - #define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x80000000UL -#endif - -/* Callback function prototypes. --------------------------*/ -#if configCHECK_FOR_STACK_OVERFLOW > 0 - extern void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName ); -#endif - -#if configUSE_TICK_HOOK > 0 - extern void vApplicationTickHook( void ); -#endif - -/* File private functions. --------------------------------*/ - -/* - * Utility to ready a TCB for a given task. Mainly just copies the parameters - * into the TCB structure. - */ -static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/** - * Utility task that simply returns pdTRUE if the task referenced by xTask is - * currently in the Suspended state, or pdFALSE if the task referenced by xTask - * is in any other state. - */ -#if ( INCLUDE_vTaskSuspend == 1 ) - static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; -#endif /* INCLUDE_vTaskSuspend */ - -/* - * Utility to ready all the lists used by the scheduler. This is called - * automatically upon the creation of the first task. - */ -static void prvInitialiseTaskLists( void ) PRIVILEGED_FUNCTION; - -/* - * The idle task, which as all tasks is implemented as a never ending loop. - * The idle task is automatically created and added to the ready lists upon - * creation of the first user task. - * - * The portTASK_FUNCTION_PROTO() macro is used to allow port/compiler specific - * language extensions. The equivalent prototype for this function is: - * - * void prvIdleTask( void *pvParameters ); - * - */ -static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ); - -/* - * Utility to free all memory allocated by the scheduler to hold a TCB, - * including the stack pointed to by the TCB. - * - * This does not free memory allocated by the task itself (i.e. memory - * allocated by calls to pvPortMalloc from within the tasks application code). - */ -#if ( INCLUDE_vTaskDelete == 1 ) - - static void prvDeleteTCB( TCB_t *pxTCB ) PRIVILEGED_FUNCTION; - -#endif - -/* - * Used only by the idle task. This checks to see if anything has been placed - * in the list of tasks waiting to be deleted. If so the task is cleaned up - * and its TCB deleted. - */ -static void prvCheckTasksWaitingTermination( void ) PRIVILEGED_FUNCTION; - -/* - * The currently executing task is entering the Blocked state. Add the task to - * either the current or the overflow delayed task list. - */ -static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake ) PRIVILEGED_FUNCTION; - -/* - * Allocates memory from the heap for a TCB and associated stack. Checks the - * allocation was successful. - */ -static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer ) PRIVILEGED_FUNCTION; - -/* - * Fills an TaskStatus_t structure with information on each task that is - * referenced from the pxList list (which may be a ready list, a delayed list, - * a suspended list, etc.). - * - * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM - * NORMAL APPLICATION CODE. - */ -#if ( configUSE_TRACE_FACILITY == 1 ) - - static UBaseType_t prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState ) PRIVILEGED_FUNCTION; - -#endif - -/* - * When a task is created, the stack of the task is filled with a known value. - * This function determines the 'high water mark' of the task stack by - * determining how much of the stack remains at the original preset value. - */ -#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) - - static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION; - -#endif - -/* - * Return the amount of time, in ticks, that will pass before the kernel will - * next move a task from the Blocked state to the Running state. - * - * This conditional compilation should use inequality to 0, not equality to 1. - * This is to ensure portSUPPRESS_TICKS_AND_SLEEP() can be called when user - * defined low power mode implementations require configUSE_TICKLESS_IDLE to be - * set to a value other than 1. - */ -#if ( configUSE_TICKLESS_IDLE != 0 ) - - static TickType_t prvGetExpectedIdleTime( void ) PRIVILEGED_FUNCTION; - -#endif - -/* - * Set xNextTaskUnblockTime to the time at which the next Blocked state task - * will exit the Blocked state. - */ -static void prvResetNextTaskUnblockTime( void ); - -#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) - - /* - * Helper function used to pad task names with spaces when printing out - * human readable tables of task information. - */ - static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName ); - -#endif -/*-----------------------------------------------------------*/ - -BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, const MemoryRegion_t * const xRegions ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ -{ -BaseType_t xReturn; -TCB_t * pxNewTCB; -StackType_t *pxTopOfStack; - - configASSERT( pxTaskCode ); - configASSERT( ( ( uxPriority & ( UBaseType_t ) ( ~portPRIVILEGE_BIT ) ) < ( UBaseType_t ) configMAX_PRIORITIES ) ); - - /* Allocate the memory required by the TCB and stack for the new task, - checking that the allocation was successful. */ - pxNewTCB = prvAllocateTCBAndStack( usStackDepth, puxStackBuffer ); - - if( pxNewTCB != NULL ) - { - #if( portUSING_MPU_WRAPPERS == 1 ) - /* Should the task be created in privileged mode? */ - BaseType_t xRunPrivileged; - if( ( uxPriority & portPRIVILEGE_BIT ) != 0U ) - { - xRunPrivileged = pdTRUE; - } - else - { - xRunPrivileged = pdFALSE; - } - uxPriority &= ~portPRIVILEGE_BIT; - - if( puxStackBuffer != NULL ) - { - /* The application provided its own stack. Note this so no - attempt is made to delete the stack should that task be - deleted. */ - pxNewTCB->xUsingStaticallyAllocatedStack = pdTRUE; - } - else - { - /* The stack was allocated dynamically. Note this so it can be - deleted again if the task is deleted. */ - pxNewTCB->xUsingStaticallyAllocatedStack = pdFALSE; - } - #endif /* portUSING_MPU_WRAPPERS == 1 */ - - /* Calculate the top of stack address. This depends on whether the - stack grows from high memory to low (as per the 80x86) or vice versa. - portSTACK_GROWTH is used to make the result positive or negative as - required by the port. */ - #if( portSTACK_GROWTH < 0 ) - { - pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( uint16_t ) 1 ); - pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. */ - - /* Check the alignment of the calculated top of stack is correct. */ - configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); - } - #else /* portSTACK_GROWTH */ - { - pxTopOfStack = pxNewTCB->pxStack; - - /* Check the alignment of the stack buffer is correct. */ - configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxNewTCB->pxStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); - - /* If we want to use stack checking on architectures that use - a positive stack growth direction then we also need to store the - other extreme of the stack space. */ - pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 ); - } - #endif /* portSTACK_GROWTH */ - - /* Setup the newly allocated TCB with the initial state of the task. */ - prvInitialiseTCBVariables( pxNewTCB, pcName, uxPriority, xRegions, usStackDepth ); - - /* Initialize the TCB stack to look as if the task was already running, - but had been interrupted by the scheduler. The return address is set - to the start of the task function. Once the stack has been initialised - the top of stack variable is updated. */ - #if( portUSING_MPU_WRAPPERS == 1 ) - { - pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged ); - } - #else /* portUSING_MPU_WRAPPERS */ - { - pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); - } - #endif /* portUSING_MPU_WRAPPERS */ - - if( ( void * ) pxCreatedTask != NULL ) - { - /* Pass the TCB out - in an anonymous way. The calling function/ - task can use this as a handle to delete the task later if - required.*/ - *pxCreatedTask = ( TaskHandle_t ) pxNewTCB; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Ensure interrupts don't access the task lists while they are being - updated. */ - taskENTER_CRITICAL(); - { - uxCurrentNumberOfTasks++; - if( pxCurrentTCB == NULL ) - { - /* There are no other tasks, or all the other tasks are in - the suspended state - make this the current task. */ - pxCurrentTCB = pxNewTCB; - - if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 ) - { - /* This is the first task to be created so do the preliminary - initialisation required. We will not recover if this call - fails, but we will report the failure. */ - prvInitialiseTaskLists(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* If the scheduler is not already running, make this task the - current task if it is the highest priority task to be created - so far. */ - if( xSchedulerRunning == pdFALSE ) - { - if( pxCurrentTCB->uxPriority <= uxPriority ) - { - pxCurrentTCB = pxNewTCB; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - uxTaskNumber++; - - #if ( configUSE_TRACE_FACILITY == 1 ) - { - /* Add a counter into the TCB for tracing only. */ - pxNewTCB->uxTCBNumber = uxTaskNumber; - } - #endif /* configUSE_TRACE_FACILITY */ - traceTASK_CREATE( pxNewTCB ); - - prvAddTaskToReadyList( pxNewTCB ); - - xReturn = pdPASS; - portSETUP_TCB( pxNewTCB ); - } - taskEXIT_CRITICAL(); - } - else - { - xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY; - traceTASK_CREATE_FAILED(); - } - - if( xReturn == pdPASS ) - { - if( xSchedulerRunning != pdFALSE ) - { - /* If the created task is of a higher priority than the current task - then it should run now. */ - if( pxCurrentTCB->uxPriority < uxPriority ) - { - taskYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskDelete == 1 ) - - void vTaskDelete( TaskHandle_t xTaskToDelete ) - { - TCB_t *pxTCB; - - taskENTER_CRITICAL(); - { - /* If null is passed in here then it is the calling task that is - being deleted. */ - pxTCB = prvGetTCBFromHandle( xTaskToDelete ); - - /* Remove task from the ready list and place in the termination list. - This will stop the task from be scheduled. The idle task will check - the termination list and free up any memory allocated by the - scheduler for the TCB and stack. */ - if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - taskRESET_READY_PRIORITY( pxTCB->uxPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Is the task waiting on an event also? */ - if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) - { - ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - vListInsertEnd( &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) ); - - /* Increment the ucTasksDeleted variable so the idle task knows - there is a task that has been deleted and that it should therefore - check the xTasksWaitingTermination list. */ - ++uxTasksDeleted; - - /* Increment the uxTaskNumberVariable also so kernel aware debuggers - can detect that the task lists need re-generating. */ - uxTaskNumber++; - - traceTASK_DELETE( pxTCB ); - } - taskEXIT_CRITICAL(); - - /* Force a reschedule if it is the currently running task that has just - been deleted. */ - if( xSchedulerRunning != pdFALSE ) - { - if( pxTCB == pxCurrentTCB ) - { - configASSERT( uxSchedulerSuspended == 0 ); - - /* The pre-delete hook is primarily for the Windows simulator, - in which Windows specific clean up operations are performed, - after which it is not possible to yield away from this task - - hence xYieldPending is used to latch that a context switch is - required. */ - portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending ); - portYIELD_WITHIN_API(); - } - else - { - /* Reset the next expected unblock time in case it referred to - the task that has just been deleted. */ - taskENTER_CRITICAL(); - { - prvResetNextTaskUnblockTime(); - } - taskEXIT_CRITICAL(); - } - } - } - -#endif /* INCLUDE_vTaskDelete */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskDelayUntil == 1 ) - - void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) - { - TickType_t xTimeToWake; - BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE; - - configASSERT( pxPreviousWakeTime ); - configASSERT( ( xTimeIncrement > 0U ) ); - configASSERT( uxSchedulerSuspended == 0 ); - - vTaskSuspendAll(); - { - /* Minor optimisation. The tick count cannot change in this - block. */ - const TickType_t xConstTickCount = xTickCount; - - /* Generate the tick time at which the task wants to wake. */ - xTimeToWake = *pxPreviousWakeTime + xTimeIncrement; - - if( xConstTickCount < *pxPreviousWakeTime ) - { - /* The tick count has overflowed since this function was - lasted called. In this case the only time we should ever - actually delay is if the wake time has also overflowed, - and the wake time is greater than the tick time. When this - is the case it is as if neither time had overflowed. */ - if( ( xTimeToWake < *pxPreviousWakeTime ) && ( xTimeToWake > xConstTickCount ) ) - { - xShouldDelay = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* The tick time has not overflowed. In this case we will - delay if either the wake time has overflowed, and/or the - tick time is less than the wake time. */ - if( ( xTimeToWake < *pxPreviousWakeTime ) || ( xTimeToWake > xConstTickCount ) ) - { - xShouldDelay = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - /* Update the wake time ready for the next call. */ - *pxPreviousWakeTime = xTimeToWake; - - if( xShouldDelay != pdFALSE ) - { - traceTASK_DELAY_UNTIL(); - - /* Remove the task from the ready list before adding it to the - blocked list as the same list item is used for both lists. */ - if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is - no need to check, and the port reset macro can be called - directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - xAlreadyYielded = xTaskResumeAll(); - - /* Force a reschedule if xTaskResumeAll has not already done so, we may - have put ourselves to sleep. */ - if( xAlreadyYielded == pdFALSE ) - { - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - -#endif /* INCLUDE_vTaskDelayUntil */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskDelay == 1 ) - - void vTaskDelay( const TickType_t xTicksToDelay ) - { - TickType_t xTimeToWake; - BaseType_t xAlreadyYielded = pdFALSE; - - - /* A delay time of zero just forces a reschedule. */ - if( xTicksToDelay > ( TickType_t ) 0U ) - { - configASSERT( uxSchedulerSuspended == 0 ); - vTaskSuspendAll(); - { - traceTASK_DELAY(); - - /* A task that is removed from the event list while the - scheduler is suspended will not get placed in the ready - list or removed from the blocked list until the scheduler - is resumed. - - This task cannot be in an event list as it is the currently - executing task. */ - - /* Calculate the time to wake - this may overflow but this is - not a problem. */ - xTimeToWake = xTickCount + xTicksToDelay; - - /* We must remove ourselves from the ready list before adding - ourselves to the blocked list as the same list item is used for - both lists. */ - if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is - no need to check, and the port reset macro can be called - directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - xAlreadyYielded = xTaskResumeAll(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Force a reschedule if xTaskResumeAll has not already done so, we may - have put ourselves to sleep. */ - if( xAlreadyYielded == pdFALSE ) - { - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - -#endif /* INCLUDE_vTaskDelay */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_eTaskGetState == 1 ) - - eTaskState eTaskGetState( TaskHandle_t xTask ) - { - eTaskState eReturn; - List_t *pxStateList; - const TCB_t * const pxTCB = ( TCB_t * ) xTask; - - configASSERT( pxTCB ); - - if( pxTCB == pxCurrentTCB ) - { - /* The task calling this function is querying its own state. */ - eReturn = eRunning; - } - else - { - taskENTER_CRITICAL(); - { - pxStateList = ( List_t * ) listLIST_ITEM_CONTAINER( &( pxTCB->xGenericListItem ) ); - } - taskEXIT_CRITICAL(); - - if( ( pxStateList == pxDelayedTaskList ) || ( pxStateList == pxOverflowDelayedTaskList ) ) - { - /* The task being queried is referenced from one of the Blocked - lists. */ - eReturn = eBlocked; - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - else if( pxStateList == &xSuspendedTaskList ) - { - /* The task being queried is referenced from the suspended - list. Is it genuinely suspended or is it block - indefinitely? */ - if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ) - { - eReturn = eSuspended; - } - else - { - eReturn = eBlocked; - } - } - #endif - - #if ( INCLUDE_vTaskDelete == 1 ) - else if( pxStateList == &xTasksWaitingTermination ) - { - /* The task being queried is referenced from the deleted - tasks list. */ - eReturn = eDeleted; - } - #endif - - else /*lint !e525 Negative indentation is intended to make use of pre-processor clearer. */ - { - /* If the task is not in any other state, it must be in the - Ready (including pending ready) state. */ - eReturn = eReady; - } - } - - return eReturn; - } /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */ - -#endif /* INCLUDE_eTaskGetState */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_uxTaskPriorityGet == 1 ) - - UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) - { - TCB_t *pxTCB; - UBaseType_t uxReturn; - - taskENTER_CRITICAL(); - { - /* If null is passed in here then we are changing the - priority of the calling function. */ - pxTCB = prvGetTCBFromHandle( xTask ); - uxReturn = pxTCB->uxPriority; - } - taskEXIT_CRITICAL(); - - return uxReturn; - } - -#endif /* INCLUDE_uxTaskPriorityGet */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_uxTaskPriorityGet == 1 ) - - UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) - { - TCB_t *pxTCB; - UBaseType_t uxReturn, uxSavedInterruptState; - - /* RTOS ports that support interrupt nesting have the concept of a - maximum system call (or maximum API call) interrupt priority. - Interrupts that are above the maximum system call priority are keep - permanently enabled, even when the RTOS kernel is in a critical section, - but cannot make any calls to FreeRTOS API functions. If configASSERT() - is defined in FreeRTOSConfig.h then - portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has - been assigned a priority above the configured maximum system call - priority. Only FreeRTOS functions that end in FromISR can be called - from interrupts that have been assigned a priority at or (logically) - below the maximum system call interrupt priority. FreeRTOS maintains a - separate interrupt safe API to ensure interrupt entry is as fast and as - simple as possible. More information (albeit Cortex-M specific) is - provided on the following link: - http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - uxSavedInterruptState = portSET_INTERRUPT_MASK_FROM_ISR(); - { - /* If null is passed in here then it is the priority of the calling - task that is being queried. */ - pxTCB = prvGetTCBFromHandle( xTask ); - uxReturn = pxTCB->uxPriority; - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptState ); - - return uxReturn; - } - -#endif /* INCLUDE_uxTaskPriorityGet */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskPrioritySet == 1 ) - - void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) - { - TCB_t *pxTCB; - UBaseType_t uxCurrentBasePriority, uxPriorityUsedOnEntry; - BaseType_t xYieldRequired = pdFALSE; - - configASSERT( ( uxNewPriority < configMAX_PRIORITIES ) ); - - /* Ensure the new priority is valid. */ - if( uxNewPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) - { - uxNewPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - taskENTER_CRITICAL(); - { - /* If null is passed in here then it is the priority of the calling - task that is being changed. */ - pxTCB = prvGetTCBFromHandle( xTask ); - - traceTASK_PRIORITY_SET( pxTCB, uxNewPriority ); - - #if ( configUSE_MUTEXES == 1 ) - { - uxCurrentBasePriority = pxTCB->uxBasePriority; - } - #else - { - uxCurrentBasePriority = pxTCB->uxPriority; - } - #endif - - if( uxCurrentBasePriority != uxNewPriority ) - { - /* The priority change may have readied a task of higher - priority than the calling task. */ - if( uxNewPriority > uxCurrentBasePriority ) - { - if( pxTCB != pxCurrentTCB ) - { - /* The priority of a task other than the currently - running task is being raised. Is the priority being - raised above that of the running task? */ - if( uxNewPriority >= pxCurrentTCB->uxPriority ) - { - xYieldRequired = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - /* The priority of the running task is being raised, - but the running task must already be the highest - priority task able to run so no yield is required. */ - } - } - else if( pxTCB == pxCurrentTCB ) - { - /* Setting the priority of the running task down means - there may now be another task of higher priority that - is ready to execute. */ - xYieldRequired = pdTRUE; - } - else - { - /* Setting the priority of any other task down does not - require a yield as the running task must be above the - new priority of the task being modified. */ - } - - /* Remember the ready list the task might be referenced from - before its uxPriority member is changed so the - taskRESET_READY_PRIORITY() macro can function correctly. */ - uxPriorityUsedOnEntry = pxTCB->uxPriority; - - #if ( configUSE_MUTEXES == 1 ) - { - /* Only change the priority being used if the task is not - currently using an inherited priority. */ - if( pxTCB->uxBasePriority == pxTCB->uxPriority ) - { - pxTCB->uxPriority = uxNewPriority; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* The base priority gets set whatever. */ - pxTCB->uxBasePriority = uxNewPriority; - } - #else - { - pxTCB->uxPriority = uxNewPriority; - } - #endif - - /* Only reset the event list item value if the value is not - being used for anything else. */ - if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) - { - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxNewPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* If the task is in the blocked or suspended list we need do - nothing more than change it's priority variable. However, if - the task is in a ready list it needs to be removed and placed - in the list appropriate to its new priority. */ - if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE ) - { - /* The task is currently in its ready list - remove before adding - it to it's new ready list. As we are in a critical section we - can do this even if the scheduler is suspended. */ - if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* It is known that the task is in its ready list so - there is no need to check again and the port level - reset macro can be called directly. */ - portRESET_READY_PRIORITY( uxPriorityUsedOnEntry, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - prvAddTaskToReadyList( pxTCB ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - if( xYieldRequired == pdTRUE ) - { - taskYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Remove compiler warning about unused variables when the port - optimised task selection is not being used. */ - ( void ) uxPriorityUsedOnEntry; - } - } - taskEXIT_CRITICAL(); - } - -#endif /* INCLUDE_vTaskPrioritySet */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskSuspend == 1 ) - - void vTaskSuspend( TaskHandle_t xTaskToSuspend ) - { - TCB_t *pxTCB; - - taskENTER_CRITICAL(); - { - /* If null is passed in here then it is the running task that is - being suspended. */ - pxTCB = prvGetTCBFromHandle( xTaskToSuspend ); - - traceTASK_SUSPEND( pxTCB ); - - /* Remove task from the ready/delayed list and place in the - suspended list. */ - if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - taskRESET_READY_PRIORITY( pxTCB->uxPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Is the task waiting on an event also? */ - if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) - { - ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ); - } - taskEXIT_CRITICAL(); - - if( pxTCB == pxCurrentTCB ) - { - if( xSchedulerRunning != pdFALSE ) - { - /* The current task has just been suspended. */ - configASSERT( uxSchedulerSuspended == 0 ); - portYIELD_WITHIN_API(); - } - else - { - /* The scheduler is not running, but the task that was pointed - to by pxCurrentTCB has just been suspended and pxCurrentTCB - must be adjusted to point to a different task. */ - if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks ) - { - /* No other tasks are ready, so set pxCurrentTCB back to - NULL so when the next task is created pxCurrentTCB will - be set to point to it no matter what its relative priority - is. */ - pxCurrentTCB = NULL; - } - else - { - vTaskSwitchContext(); - } - } - } - else - { - if( xSchedulerRunning != pdFALSE ) - { - /* A task other than the currently running task was suspended, - reset the next expected unblock time in case it referred to the - task that is now in the Suspended state. */ - taskENTER_CRITICAL(); - { - prvResetNextTaskUnblockTime(); - } - taskEXIT_CRITICAL(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - -#endif /* INCLUDE_vTaskSuspend */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskSuspend == 1 ) - - static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask ) - { - BaseType_t xReturn = pdFALSE; - const TCB_t * const pxTCB = ( TCB_t * ) xTask; - - /* Accesses xPendingReadyList so must be called from a critical - section. */ - - /* It does not make sense to check if the calling task is suspended. */ - configASSERT( xTask ); - - /* Is the task being resumed actually in the suspended list? */ - if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE ) - { - /* Has the task already been resumed from within an ISR? */ - if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) == pdFALSE ) - { - /* Is it in the suspended list because it is in the Suspended - state, or because is is blocked with no timeout? */ - if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE ) - { - xReturn = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - return xReturn; - } /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */ - -#endif /* INCLUDE_vTaskSuspend */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskSuspend == 1 ) - - void vTaskResume( TaskHandle_t xTaskToResume ) - { - TCB_t * const pxTCB = ( TCB_t * ) xTaskToResume; - - /* It does not make sense to resume the calling task. */ - configASSERT( xTaskToResume ); - - /* The parameter cannot be NULL as it is impossible to resume the - currently executing task. */ - if( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) ) - { - taskENTER_CRITICAL(); - { - if( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE ) - { - traceTASK_RESUME( pxTCB ); - - /* As we are in a critical section we can access the ready - lists even if the scheduler is suspended. */ - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyList( pxTCB ); - - /* We may have just resumed a higher priority task. */ - if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) - { - /* This yield may not cause the task just resumed to run, - but will leave the lists in the correct state for the - next yield. */ - taskYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - taskEXIT_CRITICAL(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - -#endif /* INCLUDE_vTaskSuspend */ - -/*-----------------------------------------------------------*/ - -#if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) - - BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) - { - BaseType_t xYieldRequired = pdFALSE; - TCB_t * const pxTCB = ( TCB_t * ) xTaskToResume; - UBaseType_t uxSavedInterruptStatus; - - configASSERT( xTaskToResume ); - - /* RTOS ports that support interrupt nesting have the concept of a - maximum system call (or maximum API call) interrupt priority. - Interrupts that are above the maximum system call priority are keep - permanently enabled, even when the RTOS kernel is in a critical section, - but cannot make any calls to FreeRTOS API functions. If configASSERT() - is defined in FreeRTOSConfig.h then - portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has - been assigned a priority above the configured maximum system call - priority. Only FreeRTOS functions that end in FromISR can be called - from interrupts that have been assigned a priority at or (logically) - below the maximum system call interrupt priority. FreeRTOS maintains a - separate interrupt safe API to ensure interrupt entry is as fast and as - simple as possible. More information (albeit Cortex-M specific) is - provided on the following link: - http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - if( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE ) - { - traceTASK_RESUME_FROM_ISR( pxTCB ); - - /* Check the ready lists can be accessed. */ - if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) - { - /* Ready lists can be accessed so move the task from the - suspended list to the ready list directly. */ - if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) - { - xYieldRequired = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyList( pxTCB ); - } - else - { - /* The delayed or ready lists cannot be accessed so the task - is held in the pending ready list until the scheduler is - unsuspended. */ - vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xYieldRequired; - } - -#endif /* ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) */ -/*-----------------------------------------------------------*/ - -void vTaskStartScheduler( void ) -{ -BaseType_t xReturn; - - /* Add the idle task at the lowest priority. */ - #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) - { - /* Create the idle task, storing its handle in xIdleTaskHandle so it can - be returned by the xTaskGetIdleTaskHandle() function. */ - xReturn = xTaskCreate( prvIdleTask, "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), &xIdleTaskHandle ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ - } - #else - { - /* Create the idle task without storing its handle. */ - xReturn = xTaskCreate( prvIdleTask, "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), NULL ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */ - } - #endif /* INCLUDE_xTaskGetIdleTaskHandle */ - - #if ( configUSE_TIMERS == 1 ) - { - if( xReturn == pdPASS ) - { - xReturn = xTimerCreateTimerTask(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_TIMERS */ - - if( xReturn == pdPASS ) - { - /* Interrupts are turned off here, to ensure a tick does not occur - before or during the call to xPortStartScheduler(). The stacks of - the created tasks contain a status word with interrupts switched on - so interrupts will automatically get re-enabled when the first task - starts to run. */ - portDISABLE_INTERRUPTS(); - - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - { - /* Switch Newlib's _impure_ptr variable to point to the _reent - structure specific to the task that will run first. */ - _impure_ptr = &( pxCurrentTCB->xNewLib_reent ); - } - #endif /* configUSE_NEWLIB_REENTRANT */ - - xSchedulerRunning = pdTRUE; - xTickCount = ( TickType_t ) 0U; - - /* If configGENERATE_RUN_TIME_STATS is defined then the following - macro must be defined to configure the timer/counter used to generate - the run time counter time base. */ - portCONFIGURE_TIMER_FOR_RUN_TIME_STATS(); - - /* Setting up the timer tick is hardware specific and thus in the - portable interface. */ - if( xPortStartScheduler() != pdFALSE ) - { - /* Should not reach here as if the scheduler is running the - function will not return. */ - } - else - { - /* Should only reach here if a task calls xTaskEndScheduler(). */ - } - } - else - { - /* This line will only be reached if the kernel could not be started, - because there was not enough FreeRTOS heap to create the idle task - or the timer task. */ - configASSERT( xReturn ); - } -} -/*-----------------------------------------------------------*/ - -void vTaskEndScheduler( void ) -{ - /* Stop the scheduler interrupts and call the portable scheduler end - routine so the original ISRs can be restored if necessary. The port - layer must ensure interrupts enable bit is left in the correct state. */ - portDISABLE_INTERRUPTS(); - xSchedulerRunning = pdFALSE; - vPortEndScheduler(); -} -/*----------------------------------------------------------*/ - -void vTaskSuspendAll( void ) -{ - /* A critical section is not required as the variable is of type - BaseType_t. Please read Richard Barry's reply in the following link to a - post in the FreeRTOS support forum before reporting this as a bug! - - http://goo.gl/wu4acr */ - ++uxSchedulerSuspended; -} -/*----------------------------------------------------------*/ - -#if ( configUSE_TICKLESS_IDLE != 0 ) - - static TickType_t prvGetExpectedIdleTime( void ) - { - TickType_t xReturn; - - if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY ) - { - xReturn = 0; - } - else if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > 1 ) - { - /* There are other idle priority tasks in the ready state. If - time slicing is used then the very next tick interrupt must be - processed. */ - xReturn = 0; - } - else - { - xReturn = xNextTaskUnblockTime - xTickCount; - } - - return xReturn; - } - -#endif /* configUSE_TICKLESS_IDLE */ -/*----------------------------------------------------------*/ - -BaseType_t xTaskResumeAll( void ) -{ -TCB_t *pxTCB; -BaseType_t xAlreadyYielded = pdFALSE; - - /* If uxSchedulerSuspended is zero then this function does not match a - previous call to vTaskSuspendAll(). */ - configASSERT( uxSchedulerSuspended ); - - /* It is possible that an ISR caused a task to be removed from an event - list while the scheduler was suspended. If this was the case then the - removed task will have been added to the xPendingReadyList. Once the - scheduler has been resumed it is safe to move all the pending ready - tasks from this list into their appropriate ready list. */ - taskENTER_CRITICAL(); - { - --uxSchedulerSuspended; - - if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) - { - if( uxCurrentNumberOfTasks > ( UBaseType_t ) 0U ) - { - /* Move any readied tasks from the pending list into the - appropriate ready list. */ - while( listLIST_IS_EMPTY( &xPendingReadyList ) == pdFALSE ) - { - pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) ); - ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyList( pxTCB ); - - /* If the moved task has a priority higher than the current - task then a yield must be performed. */ - if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) - { - xYieldPending = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - /* If any ticks occurred while the scheduler was suspended then - they should be processed now. This ensures the tick count does - not slip, and that any delayed tasks are resumed at the correct - time. */ - if( uxPendedTicks > ( UBaseType_t ) 0U ) - { - while( uxPendedTicks > ( UBaseType_t ) 0U ) - { - if( xTaskIncrementTick() != pdFALSE ) - { - xYieldPending = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - --uxPendedTicks; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - if( xYieldPending == pdTRUE ) - { - #if( configUSE_PREEMPTION != 0 ) - { - xAlreadyYielded = pdTRUE; - } - #endif - taskYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - taskEXIT_CRITICAL(); - - return xAlreadyYielded; -} -/*-----------------------------------------------------------*/ - -TickType_t xTaskGetTickCount( void ) -{ -TickType_t xTicks; - - /* Critical section required if running on a 16 bit processor. */ - portTICK_TYPE_ENTER_CRITICAL(); - { - xTicks = xTickCount; - } - portTICK_TYPE_EXIT_CRITICAL(); - - return xTicks; -} -/*-----------------------------------------------------------*/ - -TickType_t xTaskGetTickCountFromISR( void ) -{ -TickType_t xReturn; -UBaseType_t uxSavedInterruptStatus; - - /* RTOS ports that support interrupt nesting have the concept of a maximum - system call (or maximum API call) interrupt priority. Interrupts that are - above the maximum system call priority are kept permanently enabled, even - when the RTOS kernel is in a critical section, but cannot make any calls to - FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h - then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has been - assigned a priority above the configured maximum system call priority. - Only FreeRTOS functions that end in FromISR can be called from interrupts - that have been assigned a priority at or (logically) below the maximum - system call interrupt priority. FreeRTOS maintains a separate interrupt - safe API to ensure interrupt entry is as fast and as simple as possible. - More information (albeit Cortex-M specific) is provided on the following - link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - uxSavedInterruptStatus = portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR(); - { - xReturn = xTickCount; - } - portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -UBaseType_t uxTaskGetNumberOfTasks( void ) -{ - /* A critical section is not required because the variables are of type - BaseType_t. */ - return uxCurrentNumberOfTasks; -} -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_pcTaskGetTaskName == 1 ) - - char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - { - TCB_t *pxTCB; - - /* If null is passed in here then the name of the calling task is being queried. */ - pxTCB = prvGetTCBFromHandle( xTaskToQuery ); - configASSERT( pxTCB ); - return &( pxTCB->pcTaskName[ 0 ] ); - } - -#endif /* INCLUDE_pcTaskGetTaskName */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) - { - UBaseType_t uxTask = 0, uxQueue = configMAX_PRIORITIES; - - vTaskSuspendAll(); - { - /* Is there a space in the array for each task in the system? */ - if( uxArraySize >= uxCurrentNumberOfTasks ) - { - /* Fill in an TaskStatus_t structure with information on each - task in the Ready state. */ - do - { - uxQueue--; - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady ); - - } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - - /* Fill in an TaskStatus_t structure with information on each - task in the Blocked state. */ - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked ); - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxOverflowDelayedTaskList, eBlocked ); - - #if( INCLUDE_vTaskDelete == 1 ) - { - /* Fill in an TaskStatus_t structure with information on - each task that has been deleted but not yet cleaned up. */ - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted ); - } - #endif - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - /* Fill in an TaskStatus_t structure with information on - each task in the Suspended state. */ - uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended ); - } - #endif - - #if ( configGENERATE_RUN_TIME_STATS == 1) - { - if( pulTotalRunTime != NULL ) - { - #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE - portALT_GET_RUN_TIME_COUNTER_VALUE( ( *pulTotalRunTime ) ); - #else - *pulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); - #endif - } - } - #else - { - if( pulTotalRunTime != NULL ) - { - *pulTotalRunTime = 0; - } - } - #endif - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - ( void ) xTaskResumeAll(); - - return uxTask; - } - -#endif /* configUSE_TRACE_FACILITY */ -/*----------------------------------------------------------*/ - -#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) - - TaskHandle_t xTaskGetIdleTaskHandle( void ) - { - /* If xTaskGetIdleTaskHandle() is called before the scheduler has been - started, then xIdleTaskHandle will be NULL. */ - configASSERT( ( xIdleTaskHandle != NULL ) ); - return xIdleTaskHandle; - } - -#endif /* INCLUDE_xTaskGetIdleTaskHandle */ -/*----------------------------------------------------------*/ - -/* This conditional compilation should use inequality to 0, not equality to 1. -This is to ensure vTaskStepTick() is available when user defined low power mode -implementations require configUSE_TICKLESS_IDLE to be set to a value other than -1. */ -#if ( configUSE_TICKLESS_IDLE != 0 ) - - void vTaskStepTick( const TickType_t xTicksToJump ) - { - /* Correct the tick count value after a period during which the tick - was suppressed. Note this does *not* call the tick hook function for - each stepped tick. */ - configASSERT( ( xTickCount + xTicksToJump ) <= xNextTaskUnblockTime ); - xTickCount += xTicksToJump; - traceINCREASE_TICK_COUNT( xTicksToJump ); - } - -#endif /* configUSE_TICKLESS_IDLE */ -/*----------------------------------------------------------*/ - -BaseType_t xTaskIncrementTick( void ) -{ -TCB_t * pxTCB; -TickType_t xItemValue; -BaseType_t xSwitchRequired = pdFALSE; - - /* Called by the portable layer each time a tick interrupt occurs. - Increments the tick then checks to see if the new tick value will cause any - tasks to be unblocked. */ - traceTASK_INCREMENT_TICK( xTickCount ); - if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) - { - /* Increment the RTOS tick, switching the delayed and overflowed - delayed lists if it wraps to 0. */ - ++xTickCount; - - { - /* Minor optimisation. The tick count cannot change in this - block. */ - const TickType_t xConstTickCount = xTickCount; - - if( xConstTickCount == ( TickType_t ) 0U ) - { - taskSWITCH_DELAYED_LISTS(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* See if this tick has made a timeout expire. Tasks are stored in - the queue in the order of their wake time - meaning once one task - has been found whose block time has not expired there is no need to - look any further down the list. */ - if( xConstTickCount >= xNextTaskUnblockTime ) - { - for( ;; ) - { - if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) - { - /* The delayed list is empty. Set xNextTaskUnblockTime - to the maximum possible value so it is extremely - unlikely that the - if( xTickCount >= xNextTaskUnblockTime ) test will pass - next time through. */ - xNextTaskUnblockTime = portMAX_DELAY; - break; - } - else - { - /* The delayed list is not empty, get the value of the - item at the head of the delayed list. This is the time - at which the task at the head of the delayed list must - be removed from the Blocked state. */ - pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); - xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) ); - - if( xConstTickCount < xItemValue ) - { - /* It is not time to unblock this item yet, but the - item value is the time at which the task at the head - of the blocked list must be removed from the Blocked - state - so record the item value in - xNextTaskUnblockTime. */ - xNextTaskUnblockTime = xItemValue; - break; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* It is time to remove the item from the Blocked state. */ - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - - /* Is the task waiting on an event also? If so remove - it from the event list. */ - if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) - { - ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Place the unblocked task into the appropriate ready - list. */ - prvAddTaskToReadyList( pxTCB ); - - /* A task being unblocked cannot cause an immediate - context switch if preemption is turned off. */ - #if ( configUSE_PREEMPTION == 1 ) - { - /* Preemption is on, but a context switch should - only be performed if the unblocked task has a - priority that is equal to or higher than the - currently executing task. */ - if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) - { - xSwitchRequired = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_PREEMPTION */ - } - } - } - } - - /* Tasks of equal priority to the currently running task will share - processing time (time slice) if preemption is on, and the application - writer has not explicitly turned time slicing off. */ - #if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) - { - if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 ) - { - xSwitchRequired = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */ - - #if ( configUSE_TICK_HOOK == 1 ) - { - /* Guard against the tick hook being called when the pended tick - count is being unwound (when the scheduler is being unlocked). */ - if( uxPendedTicks == ( UBaseType_t ) 0U ) - { - vApplicationTickHook(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_TICK_HOOK */ - } - else - { - ++uxPendedTicks; - - /* The tick hook gets called at regular intervals, even if the - scheduler is locked. */ - #if ( configUSE_TICK_HOOK == 1 ) - { - vApplicationTickHook(); - } - #endif - } - - #if ( configUSE_PREEMPTION == 1 ) - { - if( xYieldPending != pdFALSE ) - { - xSwitchRequired = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_PREEMPTION */ - - return xSwitchRequired; -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_APPLICATION_TASK_TAG == 1 ) - - void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) - { - TCB_t *xTCB; - - /* If xTask is NULL then it is the task hook of the calling task that is - getting set. */ - if( xTask == NULL ) - { - xTCB = ( TCB_t * ) pxCurrentTCB; - } - else - { - xTCB = ( TCB_t * ) xTask; - } - - /* Save the hook function in the TCB. A critical section is required as - the value can be accessed from an interrupt. */ - taskENTER_CRITICAL(); - xTCB->pxTaskTag = pxHookFunction; - taskEXIT_CRITICAL(); - } - -#endif /* configUSE_APPLICATION_TASK_TAG */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_APPLICATION_TASK_TAG == 1 ) - - TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) - { - TCB_t *xTCB; - TaskHookFunction_t xReturn; - - /* If xTask is NULL then we are setting our own task hook. */ - if( xTask == NULL ) - { - xTCB = ( TCB_t * ) pxCurrentTCB; - } - else - { - xTCB = ( TCB_t * ) xTask; - } - - /* Save the hook function in the TCB. A critical section is required as - the value can be accessed from an interrupt. */ - taskENTER_CRITICAL(); - { - xReturn = xTCB->pxTaskTag; - } - taskEXIT_CRITICAL(); - - return xReturn; - } - -#endif /* configUSE_APPLICATION_TASK_TAG */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_APPLICATION_TASK_TAG == 1 ) - - BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) - { - TCB_t *xTCB; - BaseType_t xReturn; - - /* If xTask is NULL then we are calling our own task hook. */ - if( xTask == NULL ) - { - xTCB = ( TCB_t * ) pxCurrentTCB; - } - else - { - xTCB = ( TCB_t * ) xTask; - } - - if( xTCB->pxTaskTag != NULL ) - { - xReturn = xTCB->pxTaskTag( pvParameter ); - } - else - { - xReturn = pdFAIL; - } - - return xReturn; - } - -#endif /* configUSE_APPLICATION_TASK_TAG */ -/*-----------------------------------------------------------*/ - -void vTaskSwitchContext( void ) -{ - if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE ) - { - /* The scheduler is currently suspended - do not allow a context - switch. */ - xYieldPending = pdTRUE; - } - else - { - xYieldPending = pdFALSE; - traceTASK_SWITCHED_OUT(); - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - { - #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE - portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime ); - #else - ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); - #endif - - /* Add the amount of time the task has been running to the - accumulated time so far. The time the task started running was - stored in ulTaskSwitchedInTime. Note that there is no overflow - protection here so count values are only valid until the timer - overflows. The guard against negative values is to protect - against suspect run time stat counter implementations - which - are provided by the application, not the kernel. */ - if( ulTotalRunTime > ulTaskSwitchedInTime ) - { - pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - ulTaskSwitchedInTime = ulTotalRunTime; - } - #endif /* configGENERATE_RUN_TIME_STATS */ - - /* Check for stack overflow, if configured. */ - taskFIRST_CHECK_FOR_STACK_OVERFLOW(); - taskSECOND_CHECK_FOR_STACK_OVERFLOW(); - - /* Select a new task to run using either the generic C or port - optimised asm code. */ - taskSELECT_HIGHEST_PRIORITY_TASK(); - traceTASK_SWITCHED_IN(); - - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - { - /* Switch Newlib's _impure_ptr variable to point to the _reent - structure specific to this task. */ - _impure_ptr = &( pxCurrentTCB->xNewLib_reent ); - } - #endif /* configUSE_NEWLIB_REENTRANT */ - } -} -/*-----------------------------------------------------------*/ - -void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) -{ -TickType_t xTimeToWake; - - configASSERT( pxEventList ); - - /* THIS FUNCTION MUST BE CALLED WITH EITHER INTERRUPTS DISABLED OR THE - SCHEDULER SUSPENDED AND THE QUEUE BEING ACCESSED LOCKED. */ - - /* Place the event list item of the TCB in the appropriate event list. - This is placed in the list in priority order so the highest priority task - is the first to be woken by the event. The queue that contains the event - list is locked, preventing simultaneous access from interrupts. */ - vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) ); - - /* The task must be removed from from the ready list before it is added to - the blocked list as the same list item is used for both lists. Exclusive - access to the ready lists guaranteed because the scheduler is locked. */ - if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is no need to - check, and the port reset macro can be called directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if( xTicksToWait == portMAX_DELAY ) - { - /* Add the task to the suspended task list instead of a delayed task - list to ensure the task is not woken by a timing event. It will - block indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be woken if the event - does not occur. This may overflow but this doesn't matter, the - scheduler will handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else /* INCLUDE_vTaskSuspend */ - { - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter, the scheduler - will handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif /* INCLUDE_vTaskSuspend */ -} -/*-----------------------------------------------------------*/ - -void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) -{ -TickType_t xTimeToWake; - - configASSERT( pxEventList ); - - /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by - the event groups implementation. */ - configASSERT( uxSchedulerSuspended != 0 ); - - /* Store the item value in the event list item. It is safe to access the - event list item here as interrupts won't access the event list item of a - task that is not in the Blocked state. */ - listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE ); - - /* Place the event list item of the TCB at the end of the appropriate event - list. It is safe to access the event list here because it is part of an - event group implementation - and interrupts don't access event groups - directly (instead they access them indirectly by pending function calls to - the task level). */ - vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) ); - - /* The task must be removed from the ready list before it is added to the - blocked list. Exclusive access can be assured to the ready list as the - scheduler is locked. */ - if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is no need to - check, and the port reset macro can be called directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if( xTicksToWait == portMAX_DELAY ) - { - /* Add the task to the suspended task list instead of a delayed task - list to ensure it is not woken by a timing event. It will block - indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be woken if the event - does not occur. This may overflow but this doesn't matter, the - kernel will manage it correctly. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else /* INCLUDE_vTaskSuspend */ - { - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter, the kernel - will manage it correctly. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif /* INCLUDE_vTaskSuspend */ -} -/*-----------------------------------------------------------*/ - -#if configUSE_TIMERS == 1 - - void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait ) - { - TickType_t xTimeToWake; - - configASSERT( pxEventList ); - - /* This function should not be called by application code hence the - 'Restricted' in its name. It is not part of the public API. It is - designed for use by kernel code, and has special calling requirements - - it should be called with the scheduler suspended. */ - - - /* Place the event list item of the TCB in the appropriate event list. - In this case it is assume that this is the only task that is going to - be waiting on this event list, so the faster vListInsertEnd() function - can be used in place of vListInsert. */ - vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) ); - - /* We must remove this task from the ready list before adding it to the - blocked list as the same list item is used for both lists. This - function is called with the scheduler locked so interrupts will not - access the lists at the same time. */ - if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is no need to - check, and the port reset macro can be called directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Calculate the time at which the task should be woken if the event does - not occur. This may overflow but this doesn't matter. */ - xTimeToWake = xTickCount + xTicksToWait; - - traceTASK_DELAY_UNTIL(); - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - -#endif /* configUSE_TIMERS */ -/*-----------------------------------------------------------*/ - -BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) -{ -TCB_t *pxUnblockedTCB; -BaseType_t xReturn; - - /* THIS FUNCTION MUST BE CALLED FROM A CRITICAL SECTION. It can also be - called from a critical section within an ISR. */ - - /* The event list is sorted in priority order, so the first in the list can - be removed as it is known to be the highest priority. Remove the TCB from - the delayed list, and add it to the ready list. - - If an event is for a queue that is locked then this function will never - get called - the lock count on the queue will get modified instead. This - means exclusive access to the event list is guaranteed here. - - This function assumes that a check has already been made to ensure that - pxEventList is not empty. */ - pxUnblockedTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); - configASSERT( pxUnblockedTCB ); - ( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) ); - - if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) - { - ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) ); - prvAddTaskToReadyList( pxUnblockedTCB ); - } - else - { - /* The delayed and ready lists cannot be accessed, so hold this task - pending until the scheduler is resumed. */ - vListInsertEnd( &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) ); - } - - if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) - { - /* Return true if the task removed from the event list has a higher - priority than the calling task. This allows the calling task to know if - it should force a context switch now. */ - xReturn = pdTRUE; - - /* Mark that a yield is pending in case the user is not using the - "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */ - xYieldPending = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - #if( configUSE_TICKLESS_IDLE == 1 ) - { - /* If a task is blocked on a kernel object then xNextTaskUnblockTime - might be set to the blocked task's time out time. If the task is - unblocked for a reason other than a timeout xNextTaskUnblockTime is - normally left unchanged, because it is automatically get reset to a new - value when the tick count equals xNextTaskUnblockTime. However if - tickless idling is used it might be more important to enter sleep mode - at the earliest possible time - so reset xNextTaskUnblockTime here to - ensure it is updated at the earliest possible time. */ - prvResetNextTaskUnblockTime(); - } - #endif - - return xReturn; -} -/*-----------------------------------------------------------*/ - -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) -{ -TCB_t *pxUnblockedTCB; -BaseType_t xReturn; - - /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by - the event flags implementation. */ - configASSERT( uxSchedulerSuspended != pdFALSE ); - - /* Store the new item value in the event list. */ - listSET_LIST_ITEM_VALUE( pxEventListItem, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE ); - - /* Remove the event list form the event flag. Interrupts do not access - event flags. */ - pxUnblockedTCB = ( TCB_t * ) listGET_LIST_ITEM_OWNER( pxEventListItem ); - configASSERT( pxUnblockedTCB ); - ( void ) uxListRemove( pxEventListItem ); - - /* Remove the task from the delayed list and add it to the ready list. The - scheduler is suspended so interrupts will not be accessing the ready - lists. */ - ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) ); - prvAddTaskToReadyList( pxUnblockedTCB ); - - if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) - { - /* Return true if the task removed from the event list has - a higher priority than the calling task. This allows - the calling task to know if it should force a context - switch now. */ - xReturn = pdTRUE; - - /* Mark that a yield is pending in case the user is not using the - "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */ - xYieldPending = pdTRUE; - } - else - { - xReturn = pdFALSE; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) -{ - configASSERT( pxTimeOut ); - pxTimeOut->xOverflowCount = xNumOfOverflows; - pxTimeOut->xTimeOnEntering = xTickCount; -} -/*-----------------------------------------------------------*/ - -BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) -{ -BaseType_t xReturn; - - configASSERT( pxTimeOut ); - configASSERT( pxTicksToWait ); - - taskENTER_CRITICAL(); - { - /* Minor optimisation. The tick count cannot change in this block. */ - const TickType_t xConstTickCount = xTickCount; - - #if ( INCLUDE_vTaskSuspend == 1 ) - /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is - the maximum block time then the task should block indefinitely, and - therefore never time out. */ - if( *pxTicksToWait == portMAX_DELAY ) - { - xReturn = pdFALSE; - } - else /* We are not blocking indefinitely, perform the checks below. */ - #endif - - if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xConstTickCount >= pxTimeOut->xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */ - { - /* The tick count is greater than the time at which vTaskSetTimeout() - was called, but has also overflowed since vTaskSetTimeOut() was called. - It must have wrapped all the way around and gone past us again. This - passed since vTaskSetTimeout() was called. */ - xReturn = pdTRUE; - } - else if( ( xConstTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait ) - { - /* Not a genuine timeout. Adjust parameters for time remaining. */ - *pxTicksToWait -= ( xConstTickCount - pxTimeOut->xTimeOnEntering ); - vTaskSetTimeOutState( pxTimeOut ); - xReturn = pdFALSE; - } - else - { - xReturn = pdTRUE; - } - } - taskEXIT_CRITICAL(); - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vTaskMissedYield( void ) -{ - xYieldPending = pdTRUE; -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) - { - UBaseType_t uxReturn; - TCB_t *pxTCB; - - if( xTask != NULL ) - { - pxTCB = ( TCB_t * ) xTask; - uxReturn = pxTCB->uxTaskNumber; - } - else - { - uxReturn = 0U; - } - - return uxReturn; - } - -#endif /* configUSE_TRACE_FACILITY */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) - { - TCB_t *pxTCB; - - if( xTask != NULL ) - { - pxTCB = ( TCB_t * ) xTask; - pxTCB->uxTaskNumber = uxHandle; - } - } - -#endif /* configUSE_TRACE_FACILITY */ - -/* - * ----------------------------------------------------------- - * The Idle task. - * ---------------------------------------------------------- - * - * The portTASK_FUNCTION() macro is used to allow port/compiler specific - * language extensions. The equivalent prototype for this function is: - * - * void prvIdleTask( void *pvParameters ); - * - */ -static portTASK_FUNCTION( prvIdleTask, pvParameters ) -{ - /* Stop warnings. */ - ( void ) pvParameters; - - for( ;; ) - { - /* See if any tasks have been deleted. */ - prvCheckTasksWaitingTermination(); - - #if ( configUSE_PREEMPTION == 0 ) - { - /* If we are not using preemption we keep forcing a task switch to - see if any other task has become available. If we are using - preemption we don't need to do this as any task becoming available - will automatically get the processor anyway. */ - taskYIELD(); - } - #endif /* configUSE_PREEMPTION */ - - #if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) - { - /* When using preemption tasks of equal priority will be - timesliced. If a task that is sharing the idle priority is ready - to run then the idle task should yield before the end of the - timeslice. - - A critical region is not required here as we are just reading from - the list, and an occasional incorrect value will not matter. If - the ready list at the idle priority contains more than one task - then a task other than the idle task is ready to execute. */ - if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( UBaseType_t ) 1 ) - { - taskYIELD(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */ - - #if ( configUSE_IDLE_HOOK == 1 ) - { - extern void vApplicationIdleHook( void ); - - /* Call the user defined function from within the idle task. This - allows the application designer to add background functionality - without the overhead of a separate task. - NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, - CALL A FUNCTION THAT MIGHT BLOCK. */ - vApplicationIdleHook(); - } - #endif /* configUSE_IDLE_HOOK */ - - /* This conditional compilation should use inequality to 0, not equality - to 1. This is to ensure portSUPPRESS_TICKS_AND_SLEEP() is called when - user defined low power mode implementations require - configUSE_TICKLESS_IDLE to be set to a value other than 1. */ - #if ( configUSE_TICKLESS_IDLE != 0 ) - { - TickType_t xExpectedIdleTime; - - /* It is not desirable to suspend then resume the scheduler on - each iteration of the idle task. Therefore, a preliminary - test of the expected idle time is performed without the - scheduler suspended. The result here is not necessarily - valid. */ - xExpectedIdleTime = prvGetExpectedIdleTime(); - - if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) - { - vTaskSuspendAll(); - { - /* Now the scheduler is suspended, the expected idle - time can be sampled again, and this time its value can - be used. */ - configASSERT( xNextTaskUnblockTime >= xTickCount ); - xExpectedIdleTime = prvGetExpectedIdleTime(); - - if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) - { - traceLOW_POWER_IDLE_BEGIN(); - portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ); - traceLOW_POWER_IDLE_END(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - ( void ) xTaskResumeAll(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_TICKLESS_IDLE */ - } -} -/*-----------------------------------------------------------*/ - -#if configUSE_TICKLESS_IDLE != 0 - - eSleepModeStatus eTaskConfirmSleepModeStatus( void ) - { - eSleepModeStatus eReturn = eStandardSleep; - - if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 ) - { - /* A task was made ready while the scheduler was suspended. */ - eReturn = eAbortSleep; - } - else if( xYieldPending != pdFALSE ) - { - /* A yield was pended while the scheduler was suspended. */ - eReturn = eAbortSleep; - } - else - { - #if configUSE_TIMERS == 0 - { - /* The idle task exists in addition to the application tasks. */ - const UBaseType_t uxNonApplicationTasks = 1; - - /* If timers are not being used and all the tasks are in the - suspended list (which might mean they have an infinite block - time rather than actually being suspended) then it is safe to - turn all clocks off and just wait for external interrupts. */ - if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) ) - { - eReturn = eNoTasksWaitingTimeout; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configUSE_TIMERS */ - } - - return eReturn; - } -#endif /* configUSE_TICKLESS_IDLE */ -/*-----------------------------------------------------------*/ - -static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ -{ -UBaseType_t x; - - /* Store the task name in the TCB. */ - for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ ) - { - pxTCB->pcTaskName[ x ] = pcName[ x ]; - - /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than - configMAX_TASK_NAME_LEN characters just in case the memory after the - string is not accessible (extremely unlikely). */ - if( pcName[ x ] == 0x00 ) - { - break; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - /* Ensure the name string is terminated in the case that the string length - was greater or equal to configMAX_TASK_NAME_LEN. */ - pxTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0'; - - /* This is used as an array index so must ensure it's not too large. First - remove the privilege bit if one is present. */ - if( uxPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) - { - uxPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - pxTCB->uxPriority = uxPriority; - #if ( configUSE_MUTEXES == 1 ) - { - pxTCB->uxBasePriority = uxPriority; - pxTCB->uxMutexesHeld = 0; - } - #endif /* configUSE_MUTEXES */ - - vListInitialiseItem( &( pxTCB->xGenericListItem ) ); - vListInitialiseItem( &( pxTCB->xEventListItem ) ); - - /* Set the pxTCB as a link back from the ListItem_t. This is so we can get - back to the containing TCB from a generic item in a list. */ - listSET_LIST_ITEM_OWNER( &( pxTCB->xGenericListItem ), pxTCB ); - - /* Event lists are always in priority order. */ - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - listSET_LIST_ITEM_OWNER( &( pxTCB->xEventListItem ), pxTCB ); - - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - { - pxTCB->uxCriticalNesting = ( UBaseType_t ) 0U; - } - #endif /* portCRITICAL_NESTING_IN_TCB */ - - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - { - pxTCB->pxTaskTag = NULL; - } - #endif /* configUSE_APPLICATION_TASK_TAG */ - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - { - pxTCB->ulRunTimeCounter = 0UL; - } - #endif /* configGENERATE_RUN_TIME_STATS */ - - #if ( portUSING_MPU_WRAPPERS == 1 ) - { - vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, pxTCB->pxStack, usStackDepth ); - } - #else /* portUSING_MPU_WRAPPERS */ - { - ( void ) xRegions; - ( void ) usStackDepth; - } - #endif /* portUSING_MPU_WRAPPERS */ - - #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) - { - for( x = 0; x < ( UBaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS; x++ ) - { - pxTCB->pvThreadLocalStoragePointers[ x ] = NULL; - } - } - #endif - - #if ( configUSE_TASK_NOTIFICATIONS == 1 ) - { - pxTCB->ulNotifiedValue = 0; - pxTCB->eNotifyState = eNotWaitingNotification; - } - #endif - - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - { - /* Initialise this task's Newlib reent structure. */ - _REENT_INIT_PTR( ( &( pxTCB->xNewLib_reent ) ) ); - } - #endif /* configUSE_NEWLIB_REENTRANT */ -} -/*-----------------------------------------------------------*/ - -#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) - - void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) - { - TCB_t *pxTCB; - - if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) - { - pxTCB = prvGetTCBFromHandle( xTaskToSet ); - pxTCB->pvThreadLocalStoragePointers[ xIndex ] = pvValue; - } - } - -#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */ -/*-----------------------------------------------------------*/ - -#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) - - void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) - { - void *pvReturn = NULL; - TCB_t *pxTCB; - - if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) - { - pxTCB = prvGetTCBFromHandle( xTaskToQuery ); - pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ]; - } - else - { - pvReturn = NULL; - } - - return pvReturn; - } - -#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */ -/*-----------------------------------------------------------*/ - -#if ( portUSING_MPU_WRAPPERS == 1 ) - - void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify, const MemoryRegion_t * const xRegions ) - { - TCB_t *pxTCB; - - /* If null is passed in here then we are deleting ourselves. */ - pxTCB = prvGetTCBFromHandle( xTaskToModify ); - - vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 ); - } - -#endif /* portUSING_MPU_WRAPPERS */ -/*-----------------------------------------------------------*/ - -static void prvInitialiseTaskLists( void ) -{ -UBaseType_t uxPriority; - - for( uxPriority = ( UBaseType_t ) 0U; uxPriority < ( UBaseType_t ) configMAX_PRIORITIES; uxPriority++ ) - { - vListInitialise( &( pxReadyTasksLists[ uxPriority ] ) ); - } - - vListInitialise( &xDelayedTaskList1 ); - vListInitialise( &xDelayedTaskList2 ); - vListInitialise( &xPendingReadyList ); - - #if ( INCLUDE_vTaskDelete == 1 ) - { - vListInitialise( &xTasksWaitingTermination ); - } - #endif /* INCLUDE_vTaskDelete */ - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - vListInitialise( &xSuspendedTaskList ); - } - #endif /* INCLUDE_vTaskSuspend */ - - /* Start with pxDelayedTaskList using list1 and the pxOverflowDelayedTaskList - using list2. */ - pxDelayedTaskList = &xDelayedTaskList1; - pxOverflowDelayedTaskList = &xDelayedTaskList2; -} -/*-----------------------------------------------------------*/ - -static void prvCheckTasksWaitingTermination( void ) -{ - #if ( INCLUDE_vTaskDelete == 1 ) - { - BaseType_t xListIsEmpty; - - /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called - too often in the idle task. */ - while( uxTasksDeleted > ( UBaseType_t ) 0U ) - { - vTaskSuspendAll(); - { - xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination ); - } - ( void ) xTaskResumeAll(); - - if( xListIsEmpty == pdFALSE ) - { - TCB_t *pxTCB; - - taskENTER_CRITICAL(); - { - pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) ); - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - --uxCurrentNumberOfTasks; - --uxTasksDeleted; - } - taskEXIT_CRITICAL(); - - prvDeleteTCB( pxTCB ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - #endif /* vTaskDelete */ -} -/*-----------------------------------------------------------*/ - -static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake ) -{ - /* The list item will be inserted in wake time order. */ - listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake ); - - if( xTimeToWake < xTickCount ) - { - /* Wake time has overflowed. Place this item in the overflow list. */ - vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* The wake time has not overflowed, so the current block list is used. */ - vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - - /* If the task entering the blocked state was placed at the head of the - list of blocked tasks then xNextTaskUnblockTime needs to be updated - too. */ - if( xTimeToWake < xNextTaskUnblockTime ) - { - xNextTaskUnblockTime = xTimeToWake; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } -} -/*-----------------------------------------------------------*/ - -static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer ) -{ -TCB_t *pxNewTCB; - - /* If the stack grows down then allocate the stack then the TCB so the stack - does not grow into the TCB. Likewise if the stack grows up then allocate - the TCB then the stack. */ - #if( portSTACK_GROWTH > 0 ) - { - /* Allocate space for the TCB. Where the memory comes from depends on - the implementation of the port malloc function. */ - pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); - - if( pxNewTCB != NULL ) - { - /* Allocate space for the stack used by the task being created. - The base of the stack memory stored in the TCB so the task can - be deleted later if required. */ - pxNewTCB->pxStack = ( StackType_t * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - - if( pxNewTCB->pxStack == NULL ) - { - /* Could not allocate the stack. Delete the allocated TCB. */ - vPortFree( pxNewTCB ); - pxNewTCB = NULL; - } - } - } - #else /* portSTACK_GROWTH */ - { - StackType_t *pxStack; - - /* Allocate space for the stack used by the task being created. */ - pxStack = ( StackType_t * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - - if( pxStack != NULL ) - { - /* Allocate space for the TCB. Where the memory comes from depends - on the implementation of the port malloc function. */ - pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) ); - - if( pxNewTCB != NULL ) - { - /* Store the stack location in the TCB. */ - pxNewTCB->pxStack = pxStack; - } - else - { - /* The stack cannot be used as the TCB was not created. Free it - again. */ - vPortFree( pxStack ); - } - } - else - { - pxNewTCB = NULL; - } - } - #endif /* portSTACK_GROWTH */ - - if( pxNewTCB != NULL ) - { - /* Avoid dependency on memset() if it is not required. */ - #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) - { - /* Just to help debugging. */ - ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) usStackDepth * sizeof( StackType_t ) ); - } - #endif /* ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) ) */ - } - - return pxNewTCB; -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_TRACE_FACILITY == 1 ) - - static UBaseType_t prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState ) - { - volatile TCB_t *pxNextTCB, *pxFirstTCB; - UBaseType_t uxTask = 0; - - if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 ) - { - listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); - - /* Populate an TaskStatus_t structure within the - pxTaskStatusArray array for each task that is referenced from - pxList. See the definition of TaskStatus_t in task.h for the - meaning of each TaskStatus_t structure member. */ - do - { - listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); - - pxTaskStatusArray[ uxTask ].xHandle = ( TaskHandle_t ) pxNextTCB; - pxTaskStatusArray[ uxTask ].pcTaskName = ( const char * ) &( pxNextTCB->pcTaskName [ 0 ] ); - pxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber; - pxTaskStatusArray[ uxTask ].eCurrentState = eState; - pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority; - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - /* If the task is in the suspended list then there is a chance - it is actually just blocked indefinitely - so really it should - be reported as being in the Blocked state. */ - if( eState == eSuspended ) - { - if( listLIST_ITEM_CONTAINER( &( pxNextTCB->xEventListItem ) ) != NULL ) - { - pxTaskStatusArray[ uxTask ].eCurrentState = eBlocked; - } - } - } - #endif /* INCLUDE_vTaskSuspend */ - - #if ( configUSE_MUTEXES == 1 ) - { - pxTaskStatusArray[ uxTask ].uxBasePriority = pxNextTCB->uxBasePriority; - } - #else - { - pxTaskStatusArray[ uxTask ].uxBasePriority = 0; - } - #endif - - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - { - pxTaskStatusArray[ uxTask ].ulRunTimeCounter = pxNextTCB->ulRunTimeCounter; - } - #else - { - pxTaskStatusArray[ uxTask ].ulRunTimeCounter = 0; - } - #endif - - #if ( portSTACK_GROWTH > 0 ) - { - pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxEndOfStack ); - } - #else - { - pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxStack ); - } - #endif - - uxTask++; - - } while( pxNextTCB != pxFirstTCB ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - return uxTask; - } - -#endif /* configUSE_TRACE_FACILITY */ -/*-----------------------------------------------------------*/ - -#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) - - static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) - { - uint32_t ulCount = 0U; - - while( *pucStackByte == ( uint8_t ) tskSTACK_FILL_BYTE ) - { - pucStackByte -= portSTACK_GROWTH; - ulCount++; - } - - ulCount /= ( uint32_t ) sizeof( StackType_t ); /*lint !e961 Casting is not redundant on smaller architectures. */ - - return ( uint16_t ) ulCount; - } - -#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) - - UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) - { - TCB_t *pxTCB; - uint8_t *pucEndOfStack; - UBaseType_t uxReturn; - - pxTCB = prvGetTCBFromHandle( xTask ); - - #if portSTACK_GROWTH < 0 - { - pucEndOfStack = ( uint8_t * ) pxTCB->pxStack; - } - #else - { - pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack; - } - #endif - - uxReturn = ( UBaseType_t ) prvTaskCheckFreeStackSpace( pucEndOfStack ); - - return uxReturn; - } - -#endif /* INCLUDE_uxTaskGetStackHighWaterMark */ -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_vTaskDelete == 1 ) - - static void prvDeleteTCB( TCB_t *pxTCB ) - { - /* This call is required specifically for the TriCore port. It must be - above the vPortFree() calls. The call is also used by ports/demos that - want to allocate and clean RAM statically. */ - portCLEAN_UP_TCB( pxTCB ); - - /* Free up the memory allocated by the scheduler for the task. It is up - to the task to free any memory allocated at the application level. */ - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - { - _reclaim_reent( &( pxTCB->xNewLib_reent ) ); - } - #endif /* configUSE_NEWLIB_REENTRANT */ - - #if( portUSING_MPU_WRAPPERS == 1 ) - { - /* Only free the stack if it was allocated dynamically in the first - place. */ - if( pxTCB->xUsingStaticallyAllocatedStack == pdFALSE ) - { - vPortFreeAligned( pxTCB->pxStack ); - } - } - #else - { - vPortFreeAligned( pxTCB->pxStack ); - } - #endif - - vPortFree( pxTCB ); - } - -#endif /* INCLUDE_vTaskDelete */ -/*-----------------------------------------------------------*/ - -static void prvResetNextTaskUnblockTime( void ) -{ -TCB_t *pxTCB; - - if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) - { - /* The new current delayed list is empty. Set xNextTaskUnblockTime to - the maximum possible value so it is extremely unlikely that the - if( xTickCount >= xNextTaskUnblockTime ) test will pass until - there is an item in the delayed list. */ - xNextTaskUnblockTime = portMAX_DELAY; - } - else - { - /* The new current delayed list is not empty, get the value of - the item at the head of the delayed list. This is the time at - which the task at the head of the delayed list should be removed - from the Blocked state. */ - ( pxTCB ) = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); - xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( ( pxTCB )->xGenericListItem ) ); - } -} -/*-----------------------------------------------------------*/ - -#if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) - - TaskHandle_t xTaskGetCurrentTaskHandle( void ) - { - TaskHandle_t xReturn; - - /* A critical section is not required as this is not called from - an interrupt and the current TCB will always be the same for any - individual execution thread. */ - xReturn = pxCurrentTCB; - - return xReturn; - } - -#endif /* ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */ -/*-----------------------------------------------------------*/ - -#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) - - BaseType_t xTaskGetSchedulerState( void ) - { - BaseType_t xReturn; - - if( xSchedulerRunning == pdFALSE ) - { - xReturn = taskSCHEDULER_NOT_STARTED; - } - else - { - if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) - { - xReturn = taskSCHEDULER_RUNNING; - } - else - { - xReturn = taskSCHEDULER_SUSPENDED; - } - } - - return xReturn; - } - -#endif /* ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_MUTEXES == 1 ) - - void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) - { - TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder; - - /* If the mutex was given back by an interrupt while the queue was - locked then the mutex holder might now be NULL. */ - if( pxMutexHolder != NULL ) - { - /* If the holder of the mutex has a priority below the priority of - the task attempting to obtain the mutex then it will temporarily - inherit the priority of the task attempting to obtain the mutex. */ - if( pxTCB->uxPriority < pxCurrentTCB->uxPriority ) - { - /* Adjust the mutex holder state to account for its new - priority. Only reset the event list item value if the value is - not being used for anything else. */ - if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) - { - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* If the task being modified is in the ready state it will need - to be moved into a new list. */ - if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE ) - { - if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - taskRESET_READY_PRIORITY( pxTCB->uxPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Inherit the priority before being moved into the new list. */ - pxTCB->uxPriority = pxCurrentTCB->uxPriority; - prvAddTaskToReadyList( pxTCB ); - } - else - { - /* Just inherit the priority. */ - pxTCB->uxPriority = pxCurrentTCB->uxPriority; - } - - traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB->uxPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - -#endif /* configUSE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if ( configUSE_MUTEXES == 1 ) - - BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) - { - TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder; - BaseType_t xReturn = pdFALSE; - - if( pxMutexHolder != NULL ) - { - /* A task can only have an inherited priority if it holds the mutex. - If the mutex is held by a task then it cannot be given from an - interrupt, and if a mutex is given by the holding task then it must - be the running state task. */ - configASSERT( pxTCB == pxCurrentTCB ); - - configASSERT( pxTCB->uxMutexesHeld ); - ( pxTCB->uxMutexesHeld )--; - - /* Has the holder of the mutex inherited the priority of another - task? */ - if( pxTCB->uxPriority != pxTCB->uxBasePriority ) - { - /* Only disinherit if no other mutexes are held. */ - if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 ) - { - /* A task can only have an inherited priority if it holds - the mutex. If the mutex is held by a task then it cannot be - given from an interrupt, and if a mutex is given by the - holding task then it must be the running state task. Remove - the holding task from the ready list. */ - if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - taskRESET_READY_PRIORITY( pxTCB->uxPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Disinherit the priority before adding the task into the - new ready list. */ - traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority ); - pxTCB->uxPriority = pxTCB->uxBasePriority; - - /* Reset the event list item value. It cannot be in use for - any other purpose if this task is running, and it must be - running to give back the mutex. */ - listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - prvAddTaskToReadyList( pxTCB ); - - /* Return true to indicate that a context switch is required. - This is only actually required in the corner case whereby - multiple mutexes were held and the mutexes were given back - in an order different to that in which they were taken. - If a context switch did not occur when the first mutex was - returned, even if a task was waiting on it, then a context - switch should occur when the last mutex is returned whether - a task is waiting on it or not. */ - xReturn = pdTRUE; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - return xReturn; - } - -#endif /* configUSE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if ( portCRITICAL_NESTING_IN_TCB == 1 ) - - void vTaskEnterCritical( void ) - { - portDISABLE_INTERRUPTS(); - - if( xSchedulerRunning != pdFALSE ) - { - ( pxCurrentTCB->uxCriticalNesting )++; - - /* This is not the interrupt safe version of the enter critical - function so assert() if it is being called from an interrupt - context. Only API functions that end in "FromISR" can be used in an - interrupt. Only assert if the critical nesting count is 1 to - protect against recursive calls if the assert function also uses a - critical section. */ - if( pxCurrentTCB->uxCriticalNesting == 1 ) - { - portASSERT_IF_IN_ISR(); - } - - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - -#endif /* portCRITICAL_NESTING_IN_TCB */ -/*-----------------------------------------------------------*/ - -#if ( portCRITICAL_NESTING_IN_TCB == 1 ) - - void vTaskExitCritical( void ) - { - if( xSchedulerRunning != pdFALSE ) - { - if( pxCurrentTCB->uxCriticalNesting > 0U ) - { - ( pxCurrentTCB->uxCriticalNesting )--; - - if( pxCurrentTCB->uxCriticalNesting == 0U ) - { - portENABLE_INTERRUPTS(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - -#endif /* portCRITICAL_NESTING_IN_TCB */ -/*-----------------------------------------------------------*/ - -#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) - - static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName ) - { - BaseType_t x; - - /* Start by copying the entire string. */ - strcpy( pcBuffer, pcTaskName ); - - /* Pad the end of the string with spaces to ensure columns line up when - printed out. */ - for( x = strlen( pcBuffer ); x < ( configMAX_TASK_NAME_LEN - 1 ); x++ ) - { - pcBuffer[ x ] = ' '; - } - - /* Terminate. */ - pcBuffer[ x ] = 0x00; - - /* Return the new end of string. */ - return &( pcBuffer[ x ] ); - } - -#endif /* ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) */ -/*-----------------------------------------------------------*/ - -#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) - - void vTaskList( char * pcWriteBuffer ) - { - TaskStatus_t *pxTaskStatusArray; - volatile UBaseType_t uxArraySize, x; - char cStatus; - - /* - * PLEASE NOTE: - * - * This function is provided for convenience only, and is used by many - * of the demo applications. Do not consider it to be part of the - * scheduler. - * - * vTaskList() calls uxTaskGetSystemState(), then formats part of the - * uxTaskGetSystemState() output into a human readable table that - * displays task names, states and stack usage. - * - * vTaskList() has a dependency on the sprintf() C library function that - * might bloat the code size, use a lot of stack, and provide different - * results on different platforms. An alternative, tiny, third party, - * and limited functionality implementation of sprintf() is provided in - * many of the FreeRTOS/Demo sub-directories in a file called - * printf-stdarg.c (note printf-stdarg.c does not provide a full - * snprintf() implementation!). - * - * It is recommended that production systems call uxTaskGetSystemState() - * directly to get access to raw stats data, rather than indirectly - * through a call to vTaskList(). - */ - - - /* Make sure the write buffer does not contain a string. */ - *pcWriteBuffer = 0x00; - - /* Take a snapshot of the number of tasks in case it changes while this - function is executing. */ - uxArraySize = uxCurrentNumberOfTasks; - - /* Allocate an array index for each task. */ - pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); - - if( pxTaskStatusArray != NULL ) - { - /* Generate the (binary) data. */ - uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, NULL ); - - /* Create a human readable table from the binary data. */ - for( x = 0; x < uxArraySize; x++ ) - { - switch( pxTaskStatusArray[ x ].eCurrentState ) - { - case eReady: cStatus = tskREADY_CHAR; - break; - - case eBlocked: cStatus = tskBLOCKED_CHAR; - break; - - case eSuspended: cStatus = tskSUSPENDED_CHAR; - break; - - case eDeleted: cStatus = tskDELETED_CHAR; - break; - - default: /* Should not get here, but it is included - to prevent static checking errors. */ - cStatus = 0x00; - break; - } - - /* Write the task name to the string, padding with spaces so it - can be printed in tabular form more easily. */ - pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); - - /* Write the rest of the string. */ - sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); - pcWriteBuffer += strlen( pcWriteBuffer ); - } - - /* Free the array again. */ - vPortFree( pxTaskStatusArray ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - -#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */ -/*----------------------------------------------------------*/ - -#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) - - void vTaskGetRunTimeStats( char *pcWriteBuffer ) - { - TaskStatus_t *pxTaskStatusArray; - volatile UBaseType_t uxArraySize, x; - uint32_t ulTotalTime, ulStatsAsPercentage; - - #if( configUSE_TRACE_FACILITY != 1 ) - { - #error configUSE_TRACE_FACILITY must also be set to 1 in FreeRTOSConfig.h to use vTaskGetRunTimeStats(). - } - #endif - - /* - * PLEASE NOTE: - * - * This function is provided for convenience only, and is used by many - * of the demo applications. Do not consider it to be part of the - * scheduler. - * - * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part - * of the uxTaskGetSystemState() output into a human readable table that - * displays the amount of time each task has spent in the Running state - * in both absolute and percentage terms. - * - * vTaskGetRunTimeStats() has a dependency on the sprintf() C library - * function that might bloat the code size, use a lot of stack, and - * provide different results on different platforms. An alternative, - * tiny, third party, and limited functionality implementation of - * sprintf() is provided in many of the FreeRTOS/Demo sub-directories in - * a file called printf-stdarg.c (note printf-stdarg.c does not provide - * a full snprintf() implementation!). - * - * It is recommended that production systems call uxTaskGetSystemState() - * directly to get access to raw stats data, rather than indirectly - * through a call to vTaskGetRunTimeStats(). - */ - - /* Make sure the write buffer does not contain a string. */ - *pcWriteBuffer = 0x00; - - /* Take a snapshot of the number of tasks in case it changes while this - function is executing. */ - uxArraySize = uxCurrentNumberOfTasks; - - /* Allocate an array index for each task. */ - pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) ); - - if( pxTaskStatusArray != NULL ) - { - /* Generate the (binary) data. */ - uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalTime ); - - /* For percentage calculations. */ - ulTotalTime /= 100UL; - - /* Avoid divide by zero errors. */ - if( ulTotalTime > 0 ) - { - /* Create a human readable table from the binary data. */ - for( x = 0; x < uxArraySize; x++ ) - { - /* What percentage of the total run time has the task used? - This will always be rounded down to the nearest integer. - ulTotalRunTimeDiv100 has already been divided by 100. */ - ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalTime; - - /* Write the task name to the string, padding with - spaces so it can be printed in tabular form more - easily. */ - pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); - - if( ulStatsAsPercentage > 0UL ) - { - #ifdef portLU_PRINTF_SPECIFIER_REQUIRED - { - sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); - } - #else - { - /* sizeof( int ) == sizeof( long ) so a smaller - printf() library can be used. */ - sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); - } - #endif - } - else - { - /* If the percentage is zero here then the task has - consumed less than 1% of the total run time. */ - #ifdef portLU_PRINTF_SPECIFIER_REQUIRED - { - sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter ); - } - #else - { - /* sizeof( int ) == sizeof( long ) so a smaller - printf() library can be used. */ - sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter ); - } - #endif - } - - pcWriteBuffer += strlen( pcWriteBuffer ); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Free the array again. */ - vPortFree( pxTaskStatusArray ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - -#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */ -/*-----------------------------------------------------------*/ - -TickType_t uxTaskResetEventItemValue( void ) -{ -TickType_t uxReturn; - - uxReturn = listGET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ) ); - - /* Reset the event list item to its normal value - so it can be used with - queues and semaphores. */ - listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - - return uxReturn; -} -/*-----------------------------------------------------------*/ - -#if ( configUSE_MUTEXES == 1 ) - - void *pvTaskIncrementMutexHeldCount( void ) - { - /* If xSemaphoreCreateMutex() is called before any tasks have been created - then pxCurrentTCB will be NULL. */ - if( pxCurrentTCB != NULL ) - { - ( pxCurrentTCB->uxMutexesHeld )++; - } - - return pxCurrentTCB; - } - -#endif /* configUSE_MUTEXES */ -/*-----------------------------------------------------------*/ - -#if( configUSE_TASK_NOTIFICATIONS == 1 ) - - uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) - { - TickType_t xTimeToWake; - uint32_t ulReturn; - - taskENTER_CRITICAL(); - { - /* Only block if the notification count is not already non-zero. */ - if( pxCurrentTCB->ulNotifiedValue == 0UL ) - { - /* Mark this task as waiting for a notification. */ - pxCurrentTCB->eNotifyState = eWaitingNotification; - - if( xTicksToWait > ( TickType_t ) 0 ) - { - /* The task is going to block. First it must be removed - from the ready list. */ - if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is - no need to check, and the port reset macro can be called - directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if( xTicksToWait == portMAX_DELAY ) - { - /* Add the task to the suspended task list instead - of a delayed task list to ensure the task is not - woken by a timing event. It will block - indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be - woken if no notification events occur. This may - overflow but this doesn't matter, the scheduler will - handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else /* INCLUDE_vTaskSuspend */ - { - /* Calculate the time at which the task should be - woken if the event does not occur. This may - overflow but this doesn't matter, the scheduler will - handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif /* INCLUDE_vTaskSuspend */ - - /* All ports are written to allow a yield in a critical - section (some will yield immediately, others wait until the - critical section exits) - but it is not something that - application code should ever do. */ - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - taskEXIT_CRITICAL(); - - taskENTER_CRITICAL(); - { - ulReturn = pxCurrentTCB->ulNotifiedValue; - - if( ulReturn != 0UL ) - { - if( xClearCountOnExit != pdFALSE ) - { - pxCurrentTCB->ulNotifiedValue = 0UL; - } - else - { - ( pxCurrentTCB->ulNotifiedValue )--; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - pxCurrentTCB->eNotifyState = eNotWaitingNotification; - } - taskEXIT_CRITICAL(); - - return ulReturn; - } - -#endif /* configUSE_TASK_NOTIFICATIONS */ -/*-----------------------------------------------------------*/ - -#if( configUSE_TASK_NOTIFICATIONS == 1 ) - - BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) - { - TickType_t xTimeToWake; - BaseType_t xReturn; - - taskENTER_CRITICAL(); - { - /* Only block if a notification is not already pending. */ - if( pxCurrentTCB->eNotifyState != eNotified ) - { - /* Clear bits in the task's notification value as bits may get - set by the notifying task or interrupt. This can be used to - clear the value to zero. */ - pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnEntry; - - /* Mark this task as waiting for a notification. */ - pxCurrentTCB->eNotifyState = eWaitingNotification; - - if( xTicksToWait > ( TickType_t ) 0 ) - { - /* The task is going to block. First it must be removed - from the ready list. */ - if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) - { - /* The current task must be in a ready list, so there is - no need to check, and the port reset macro can be called - directly. */ - portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - #if ( INCLUDE_vTaskSuspend == 1 ) - { - if( xTicksToWait == portMAX_DELAY ) - { - /* Add the task to the suspended task list instead - of a delayed task list to ensure the task is not - woken by a timing event. It will block - indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) ); - } - else - { - /* Calculate the time at which the task should be - woken if no notification events occur. This may - overflow but this doesn't matter, the scheduler will - handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - } - #else /* INCLUDE_vTaskSuspend */ - { - /* Calculate the time at which the task should be - woken if the event does not occur. This may - overflow but this doesn't matter, the scheduler will - handle it. */ - xTimeToWake = xTickCount + xTicksToWait; - prvAddCurrentTaskToDelayedList( xTimeToWake ); - } - #endif /* INCLUDE_vTaskSuspend */ - - /* All ports are written to allow a yield in a critical - section (some will yield immediately, others wait until the - critical section exits) - but it is not something that - application code should ever do. */ - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - taskEXIT_CRITICAL(); - - taskENTER_CRITICAL(); - { - if( pulNotificationValue != NULL ) - { - /* Output the current notification value, which may or may not - have changed. */ - *pulNotificationValue = pxCurrentTCB->ulNotifiedValue; - } - - /* If eNotifyValue is set then either the task never entered the - blocked state (because a notification was already pending) or the - task unblocked because of a notification. Otherwise the task - unblocked because of a timeout. */ - if( pxCurrentTCB->eNotifyState == eWaitingNotification ) - { - /* A notification was not received. */ - xReturn = pdFALSE; - } - else - { - /* A notification was already pending or a notification was - received while the task was waiting. */ - pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnExit; - xReturn = pdTRUE; - } - - pxCurrentTCB->eNotifyState = eNotWaitingNotification; - } - taskEXIT_CRITICAL(); - - return xReturn; - } - -#endif /* configUSE_TASK_NOTIFICATIONS */ -/*-----------------------------------------------------------*/ - -#if( configUSE_TASK_NOTIFICATIONS == 1 ) - - BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) - { - TCB_t * pxTCB; - eNotifyValue eOriginalNotifyState; - BaseType_t xReturn = pdPASS; - - configASSERT( xTaskToNotify ); - pxTCB = ( TCB_t * ) xTaskToNotify; - - taskENTER_CRITICAL(); - { - if( pulPreviousNotificationValue != NULL ) - { - *pulPreviousNotificationValue = pxTCB->ulNotifiedValue; - } - - eOriginalNotifyState = pxTCB->eNotifyState; - - pxTCB->eNotifyState = eNotified; - - switch( eAction ) - { - case eSetBits : - pxTCB->ulNotifiedValue |= ulValue; - break; - - case eIncrement : - ( pxTCB->ulNotifiedValue )++; - break; - - case eSetValueWithOverwrite : - pxTCB->ulNotifiedValue = ulValue; - break; - - case eSetValueWithoutOverwrite : - if( eOriginalNotifyState != eNotified ) - { - pxTCB->ulNotifiedValue = ulValue; - } - else - { - /* The value could not be written to the task. */ - xReturn = pdFAIL; - } - break; - - case eNoAction: - /* The task is being notified without its notify value being - updated. */ - break; - } - - - /* If the task is in the blocked state specifically to wait for a - notification then unblock it now. */ - if( eOriginalNotifyState == eWaitingNotification ) - { - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyList( pxTCB ); - - /* The task should not have been on an event list. */ - configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); - - if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) - { - /* The notified task has a priority above the currently - executing task so a yield is required. */ - taskYIELD_IF_USING_PREEMPTION(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - taskEXIT_CRITICAL(); - - return xReturn; - } - -#endif /* configUSE_TASK_NOTIFICATIONS */ -/*-----------------------------------------------------------*/ - -#if( configUSE_TASK_NOTIFICATIONS == 1 ) - - BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ) - { - TCB_t * pxTCB; - eNotifyValue eOriginalNotifyState; - BaseType_t xReturn = pdPASS; - UBaseType_t uxSavedInterruptStatus; - - configASSERT( xTaskToNotify ); - - /* RTOS ports that support interrupt nesting have the concept of a - maximum system call (or maximum API call) interrupt priority. - Interrupts that are above the maximum system call priority are keep - permanently enabled, even when the RTOS kernel is in a critical section, - but cannot make any calls to FreeRTOS API functions. If configASSERT() - is defined in FreeRTOSConfig.h then - portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has - been assigned a priority above the configured maximum system call - priority. Only FreeRTOS functions that end in FromISR can be called - from interrupts that have been assigned a priority at or (logically) - below the maximum system call interrupt priority. FreeRTOS maintains a - separate interrupt safe API to ensure interrupt entry is as fast and as - simple as possible. More information (albeit Cortex-M specific) is - provided on the following link: - http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - pxTCB = ( TCB_t * ) xTaskToNotify; - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - eOriginalNotifyState = pxTCB->eNotifyState; - - pxTCB->eNotifyState = eNotified; - - switch( eAction ) - { - case eSetBits : - pxTCB->ulNotifiedValue |= ulValue; - break; - - case eIncrement : - ( pxTCB->ulNotifiedValue )++; - break; - - case eSetValueWithOverwrite : - pxTCB->ulNotifiedValue = ulValue; - break; - - case eSetValueWithoutOverwrite : - if( eOriginalNotifyState != eNotified ) - { - pxTCB->ulNotifiedValue = ulValue; - } - else - { - /* The value could not be written to the task. */ - xReturn = pdFAIL; - } - break; - - case eNoAction : - /* The task is being notified without its notify value being - updated. */ - break; - } - - - /* If the task is in the blocked state specifically to wait for a - notification then unblock it now. */ - if( eOriginalNotifyState == eWaitingNotification ) - { - /* The task should not have been on an event list. */ - configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); - - if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) - { - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyList( pxTCB ); - } - else - { - /* The delayed and ready lists cannot be accessed, so hold - this task pending until the scheduler is resumed. */ - vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); - } - - if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) - { - /* The notified task has a priority above the currently - executing task so a yield is required. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - - return xReturn; - } - -#endif /* configUSE_TASK_NOTIFICATIONS */ -/*-----------------------------------------------------------*/ - -#if( configUSE_TASK_NOTIFICATIONS == 1 ) - - void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) - { - TCB_t * pxTCB; - eNotifyValue eOriginalNotifyState; - UBaseType_t uxSavedInterruptStatus; - - configASSERT( xTaskToNotify ); - - /* RTOS ports that support interrupt nesting have the concept of a - maximum system call (or maximum API call) interrupt priority. - Interrupts that are above the maximum system call priority are keep - permanently enabled, even when the RTOS kernel is in a critical section, - but cannot make any calls to FreeRTOS API functions. If configASSERT() - is defined in FreeRTOSConfig.h then - portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion - failure if a FreeRTOS API function is called from an interrupt that has - been assigned a priority above the configured maximum system call - priority. Only FreeRTOS functions that end in FromISR can be called - from interrupts that have been assigned a priority at or (logically) - below the maximum system call interrupt priority. FreeRTOS maintains a - separate interrupt safe API to ensure interrupt entry is as fast and as - simple as possible. More information (albeit Cortex-M specific) is - provided on the following link: - http://www.freertos.org/RTOS-Cortex-M3-M4.html */ - portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - - pxTCB = ( TCB_t * ) xTaskToNotify; - - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - { - eOriginalNotifyState = pxTCB->eNotifyState; - pxTCB->eNotifyState = eNotified; - - /* 'Giving' is equivalent to incrementing a count in a counting - semaphore. */ - ( pxTCB->ulNotifiedValue )++; - - /* If the task is in the blocked state specifically to wait for a - notification then unblock it now. */ - if( eOriginalNotifyState == eWaitingNotification ) - { - /* The task should not have been on an event list. */ - configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ); - - if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) - { - ( void ) uxListRemove( &( pxTCB->xGenericListItem ) ); - prvAddTaskToReadyList( pxTCB ); - } - else - { - /* The delayed and ready lists cannot be accessed, so hold - this task pending until the scheduler is resumed. */ - vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); - } - - if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) - { - /* The notified task has a priority above the currently - executing task so a yield is required. */ - if( pxHigherPriorityTaskWoken != NULL ) - { - *pxHigherPriorityTaskWoken = pdTRUE; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); - } - -#endif /* configUSE_TASK_NOTIFICATIONS */ - -/*-----------------------------------------------------------*/ - - -#ifdef FREERTOS_MODULE_TEST - #include "tasks_test_access_functions.h" -#endif - diff --git a/GD32F1/libraries/FreeRTOS821/utility/timers.c b/GD32F1/libraries/FreeRTOS821/utility/timers.c deleted file mode 100644 index 08d66ab..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/timers.c +++ /dev/null @@ -1,917 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/* Standard includes. */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "timers.h" - -#if ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 0 ) - #error configUSE_TIMERS must be set to 1 to make the xTimerPendFunctionCall() function available. -#endif - -/* Lint e961 and e750 are suppressed as a MISRA exception justified because the -MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the -header files above, but not in this file, in order to generate the correct -privileged Vs unprivileged linkage and placement. */ -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */ - - -/* This entire source file will be skipped if the application is not configured -to include software timer functionality. This #if is closed at the very bottom -of this file. If you want to include software timer functionality then ensure -configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */ -#if ( configUSE_TIMERS == 1 ) - -/* Misc definitions. */ -#define tmrNO_DELAY ( TickType_t ) 0U - -/* The definition of the timers themselves. */ -typedef struct tmrTimerControl -{ - const char *pcTimerName; /*<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - ListItem_t xTimerListItem; /*<< Standard linked list item as used by all kernel features for event management. */ - TickType_t xTimerPeriodInTicks;/*<< How quickly and often the timer expires. */ - UBaseType_t uxAutoReload; /*<< Set to pdTRUE if the timer should be automatically restarted once expired. Set to pdFALSE if the timer is, in effect, a one-shot timer. */ - void *pvTimerID; /*<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. */ - TimerCallbackFunction_t pxCallbackFunction; /*<< The function that will be called when the timer expires. */ - #if( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxTimerNumber; /*<< An ID assigned by trace tools such as FreeRTOS+Trace */ - #endif -} xTIMER; - -/* The old xTIMER name is maintained above then typedefed to the new Timer_t -name below to enable the use of older kernel aware debuggers. */ -typedef xTIMER Timer_t; - -/* The definition of messages that can be sent and received on the timer queue. -Two types of message can be queued - messages that manipulate a software timer, -and messages that request the execution of a non-timer related callback. The -two message types are defined in two separate structures, xTimerParametersType -and xCallbackParametersType respectively. */ -typedef struct tmrTimerParameters -{ - TickType_t xMessageValue; /*<< An optional value used by a subset of commands, for example, when changing the period of a timer. */ - Timer_t * pxTimer; /*<< The timer to which the command will be applied. */ -} TimerParameter_t; - - -typedef struct tmrCallbackParameters -{ - PendedFunction_t pxCallbackFunction; /* << The callback function to execute. */ - void *pvParameter1; /* << The value that will be used as the callback functions first parameter. */ - uint32_t ulParameter2; /* << The value that will be used as the callback functions second parameter. */ -} CallbackParameters_t; - -/* The structure that contains the two message types, along with an identifier -that is used to determine which message type is valid. */ -typedef struct tmrTimerQueueMessage -{ - BaseType_t xMessageID; /*<< The command being sent to the timer service task. */ - union - { - TimerParameter_t xTimerParameters; - - /* Don't include xCallbackParameters if it is not going to be used as - it makes the structure (and therefore the timer queue) larger. */ - #if ( INCLUDE_xTimerPendFunctionCall == 1 ) - CallbackParameters_t xCallbackParameters; - #endif /* INCLUDE_xTimerPendFunctionCall */ - } u; -} DaemonTaskMessage_t; - -/*lint -e956 A manual analysis and inspection has been used to determine which -static variables must be declared volatile. */ - -/* The list in which active timers are stored. Timers are referenced in expire -time order, with the nearest expiry time at the front of the list. Only the -timer service task is allowed to access these lists. */ -PRIVILEGED_DATA static List_t xActiveTimerList1; -PRIVILEGED_DATA static List_t xActiveTimerList2; -PRIVILEGED_DATA static List_t *pxCurrentTimerList; -PRIVILEGED_DATA static List_t *pxOverflowTimerList; - -/* A queue that is used to send commands to the timer service task. */ -PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL; - -#if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 ) - - PRIVILEGED_DATA static TaskHandle_t xTimerTaskHandle = NULL; - -#endif - -/*lint +e956 */ - -/*-----------------------------------------------------------*/ - -/* - * Initialise the infrastructure used by the timer service task if it has not - * been initialised already. - */ -static void prvCheckForValidListAndQueue( void ) PRIVILEGED_FUNCTION; - -/* - * The timer service task (daemon). Timer functionality is controlled by this - * task. Other tasks communicate with the timer service task using the - * xTimerQueue queue. - */ -static void prvTimerTask( void *pvParameters ) PRIVILEGED_FUNCTION; - -/* - * Called by the timer service task to interpret and process a command it - * received on the timer queue. - */ -static void prvProcessReceivedCommands( void ) PRIVILEGED_FUNCTION; - -/* - * Insert the timer into either xActiveTimerList1, or xActiveTimerList2, - * depending on if the expire time causes a timer counter overflow. - */ -static BaseType_t prvInsertTimerInActiveList( Timer_t * const pxTimer, const TickType_t xNextExpiryTime, const TickType_t xTimeNow, const TickType_t xCommandTime ) PRIVILEGED_FUNCTION; - -/* - * An active timer has reached its expire time. Reload the timer if it is an - * auto reload timer, then call its callback. - */ -static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow ) PRIVILEGED_FUNCTION; - -/* - * The tick count has overflowed. Switch the timer lists after ensuring the - * current timer list does not still reference some timers. - */ -static void prvSwitchTimerLists( void ) PRIVILEGED_FUNCTION; - -/* - * Obtain the current tick count, setting *pxTimerListsWereSwitched to pdTRUE - * if a tick count overflow occurred since prvSampleTimeNow() was last called. - */ -static TickType_t prvSampleTimeNow( BaseType_t * const pxTimerListsWereSwitched ) PRIVILEGED_FUNCTION; - -/* - * If the timer list contains any active timers then return the expire time of - * the timer that will expire first and set *pxListWasEmpty to false. If the - * timer list does not contain any timers then return 0 and set *pxListWasEmpty - * to pdTRUE. - */ -static TickType_t prvGetNextExpireTime( BaseType_t * const pxListWasEmpty ) PRIVILEGED_FUNCTION; - -/* - * If a timer has expired, process it. Otherwise, block the timer service task - * until either a timer does expire or a command is received. - */ -static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty ) PRIVILEGED_FUNCTION; - -/*-----------------------------------------------------------*/ - -BaseType_t xTimerCreateTimerTask( void ) -{ -BaseType_t xReturn = pdFAIL; - - /* This function is called when the scheduler is started if - configUSE_TIMERS is set to 1. Check that the infrastructure used by the - timer service task has been created/initialised. If timers have already - been created then the initialisation will already have been performed. */ - prvCheckForValidListAndQueue(); - - if( xTimerQueue != NULL ) - { - #if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 ) - { - /* Create the timer task, storing its handle in xTimerTaskHandle so - it can be returned by the xTimerGetTimerDaemonTaskHandle() function. */ - xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle ); - } - #else - { - /* Create the timer task without storing its handle. */ - xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL); - } - #endif - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - configASSERT( xReturn ); - return xReturn; -} -/*-----------------------------------------------------------*/ - -TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ -{ -Timer_t *pxNewTimer; - - /* Allocate the timer structure. */ - if( xTimerPeriodInTicks == ( TickType_t ) 0U ) - { - pxNewTimer = NULL; - } - else - { - pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) ); - if( pxNewTimer != NULL ) - { - /* Ensure the infrastructure used by the timer service task has been - created/initialised. */ - prvCheckForValidListAndQueue(); - - /* Initialise the timer structure members using the function parameters. */ - pxNewTimer->pcTimerName = pcTimerName; - pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks; - pxNewTimer->uxAutoReload = uxAutoReload; - pxNewTimer->pvTimerID = pvTimerID; - pxNewTimer->pxCallbackFunction = pxCallbackFunction; - vListInitialiseItem( &( pxNewTimer->xTimerListItem ) ); - - traceTIMER_CREATE( pxNewTimer ); - } - else - { - traceTIMER_CREATE_FAILED(); - } - } - - /* 0 is not a valid value for xTimerPeriodInTicks. */ - configASSERT( ( xTimerPeriodInTicks > 0 ) ); - - return ( TimerHandle_t ) pxNewTimer; -} -/*-----------------------------------------------------------*/ - -BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) -{ -BaseType_t xReturn = pdFAIL; -DaemonTaskMessage_t xMessage; - - /* Send a message to the timer service task to perform a particular action - on a particular timer definition. */ - if( xTimerQueue != NULL ) - { - /* Send a command to the timer service task to start the xTimer timer. */ - xMessage.xMessageID = xCommandID; - xMessage.u.xTimerParameters.xMessageValue = xOptionalValue; - xMessage.u.xTimerParameters.pxTimer = ( Timer_t * ) xTimer; - - if( xCommandID < tmrFIRST_FROM_ISR_COMMAND ) - { - if( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING ) - { - xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait ); - } - else - { - xReturn = xQueueSendToBack( xTimerQueue, &xMessage, tmrNO_DELAY ); - } - } - else - { - xReturn = xQueueSendToBackFromISR( xTimerQueue, &xMessage, pxHigherPriorityTaskWoken ); - } - - traceTIMER_COMMAND_SEND( xTimer, xCommandID, xOptionalValue, xReturn ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -#if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 ) - - TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) - { - /* If xTimerGetTimerDaemonTaskHandle() is called before the scheduler has been - started, then xTimerTaskHandle will be NULL. */ - configASSERT( ( xTimerTaskHandle != NULL ) ); - return xTimerTaskHandle; - } - -#endif -/*-----------------------------------------------------------*/ - -const char * pcTimerGetTimerName( TimerHandle_t xTimer ) -{ -Timer_t *pxTimer = ( Timer_t * ) xTimer; - - return pxTimer->pcTimerName; -} -/*-----------------------------------------------------------*/ - -static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow ) -{ -BaseType_t xResult; -Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); - - /* Remove the timer from the list of active timers. A check has already - been performed to ensure the list is not empty. */ - ( void ) uxListRemove( &( pxTimer->xTimerListItem ) ); - traceTIMER_EXPIRED( pxTimer ); - - /* If the timer is an auto reload timer then calculate the next - expiry time and re-insert the timer in the list of active timers. */ - if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) - { - /* The timer is inserted into a list using a time relative to anything - other than the current time. It will therefore be inserted into the - correct list relative to the time this task thinks it is now. */ - if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) == pdTRUE ) - { - /* The timer expired before it was added to the active timer - list. Reload it now. */ - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Call the timer callback. */ - pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); -} -/*-----------------------------------------------------------*/ - -static void prvTimerTask( void *pvParameters ) -{ -TickType_t xNextExpireTime; -BaseType_t xListWasEmpty; - - /* Just to avoid compiler warnings. */ - ( void ) pvParameters; - - for( ;; ) - { - /* Query the timers list to see if it contains any timers, and if so, - obtain the time at which the next timer will expire. */ - xNextExpireTime = prvGetNextExpireTime( &xListWasEmpty ); - - /* If a timer has expired, process it. Otherwise, block this task - until either a timer does expire, or a command is received. */ - prvProcessTimerOrBlockTask( xNextExpireTime, xListWasEmpty ); - - /* Empty the command queue. */ - prvProcessReceivedCommands(); - } -} -/*-----------------------------------------------------------*/ - -static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty ) -{ -TickType_t xTimeNow; -BaseType_t xTimerListsWereSwitched; - - vTaskSuspendAll(); - { - /* Obtain the time now to make an assessment as to whether the timer - has expired or not. If obtaining the time causes the lists to switch - then don't process this timer as any timers that remained in the list - when the lists were switched will have been processed within the - prvSampleTimeNow() function. */ - xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched ); - if( xTimerListsWereSwitched == pdFALSE ) - { - /* The tick count has not overflowed, has the timer expired? */ - if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) ) - { - ( void ) xTaskResumeAll(); - prvProcessExpiredTimer( xNextExpireTime, xTimeNow ); - } - else - { - /* The tick count has not overflowed, and the next expire - time has not been reached yet. This task should therefore - block to wait for the next expire time or a command to be - received - whichever comes first. The following line cannot - be reached unless xNextExpireTime > xTimeNow, except in the - case when the current timer list is empty. */ - vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ) ); - - if( xTaskResumeAll() == pdFALSE ) - { - /* Yield to wait for either a command to arrive, or the - block time to expire. If a command arrived between the - critical section being exited and this yield then the yield - will not cause the task to block. */ - portYIELD_WITHIN_API(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - } - else - { - ( void ) xTaskResumeAll(); - } - } -} -/*-----------------------------------------------------------*/ - -static TickType_t prvGetNextExpireTime( BaseType_t * const pxListWasEmpty ) -{ -TickType_t xNextExpireTime; - - /* Timers are listed in expiry time order, with the head of the list - referencing the task that will expire first. Obtain the time at which - the timer with the nearest expiry time will expire. If there are no - active timers then just set the next expire time to 0. That will cause - this task to unblock when the tick count overflows, at which point the - timer lists will be switched and the next expiry time can be - re-assessed. */ - *pxListWasEmpty = listLIST_IS_EMPTY( pxCurrentTimerList ); - if( *pxListWasEmpty == pdFALSE ) - { - xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList ); - } - else - { - /* Ensure the task unblocks when the tick count rolls over. */ - xNextExpireTime = ( TickType_t ) 0U; - } - - return xNextExpireTime; -} -/*-----------------------------------------------------------*/ - -static TickType_t prvSampleTimeNow( BaseType_t * const pxTimerListsWereSwitched ) -{ -TickType_t xTimeNow; -PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Variable is only accessible to one task. */ - - xTimeNow = xTaskGetTickCount(); - - if( xTimeNow < xLastTime ) - { - prvSwitchTimerLists(); - *pxTimerListsWereSwitched = pdTRUE; - } - else - { - *pxTimerListsWereSwitched = pdFALSE; - } - - xLastTime = xTimeNow; - - return xTimeNow; -} -/*-----------------------------------------------------------*/ - -static BaseType_t prvInsertTimerInActiveList( Timer_t * const pxTimer, const TickType_t xNextExpiryTime, const TickType_t xTimeNow, const TickType_t xCommandTime ) -{ -BaseType_t xProcessTimerNow = pdFALSE; - - listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xNextExpiryTime ); - listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer ); - - if( xNextExpiryTime <= xTimeNow ) - { - /* Has the expiry time elapsed between the command to start/reset a - timer was issued, and the time the command was processed? */ - if( ( xTimeNow - xCommandTime ) >= pxTimer->xTimerPeriodInTicks ) - { - /* The time between a command being issued and the command being - processed actually exceeds the timers period. */ - xProcessTimerNow = pdTRUE; - } - else - { - vListInsert( pxOverflowTimerList, &( pxTimer->xTimerListItem ) ); - } - } - else - { - if( ( xTimeNow < xCommandTime ) && ( xNextExpiryTime >= xCommandTime ) ) - { - /* If, since the command was issued, the tick count has overflowed - but the expiry time has not, then the timer must have already passed - its expiry time and should be processed immediately. */ - xProcessTimerNow = pdTRUE; - } - else - { - vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) ); - } - } - - return xProcessTimerNow; -} -/*-----------------------------------------------------------*/ - -static void prvProcessReceivedCommands( void ) -{ -DaemonTaskMessage_t xMessage; -Timer_t *pxTimer; -BaseType_t xTimerListsWereSwitched, xResult; -TickType_t xTimeNow; - - while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) /*lint !e603 xMessage does not have to be initialised as it is passed out, not in, and it is not used unless xQueueReceive() returns pdTRUE. */ - { - #if ( INCLUDE_xTimerPendFunctionCall == 1 ) - { - /* Negative commands are pended function calls rather than timer - commands. */ - if( xMessage.xMessageID < ( BaseType_t ) 0 ) - { - const CallbackParameters_t * const pxCallback = &( xMessage.u.xCallbackParameters ); - - /* The timer uses the xCallbackParameters member to request a - callback be executed. Check the callback is not NULL. */ - configASSERT( pxCallback ); - - /* Call the function. */ - pxCallback->pxCallbackFunction( pxCallback->pvParameter1, pxCallback->ulParameter2 ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* INCLUDE_xTimerPendFunctionCall */ - - /* Commands that are positive are timer commands rather than pended - function calls. */ - if( xMessage.xMessageID >= ( BaseType_t ) 0 ) - { - /* The messages uses the xTimerParameters member to work on a - software timer. */ - pxTimer = xMessage.u.xTimerParameters.pxTimer; - - if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE ) - { - /* The timer is in a list, remove it. */ - ( void ) uxListRemove( &( pxTimer->xTimerListItem ) ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - traceTIMER_COMMAND_RECEIVED( pxTimer, xMessage.xMessageID, xMessage.u.xTimerParameters.xMessageValue ); - - /* In this case the xTimerListsWereSwitched parameter is not used, but - it must be present in the function call. prvSampleTimeNow() must be - called after the message is received from xTimerQueue so there is no - possibility of a higher priority task adding a message to the message - queue with a time that is ahead of the timer daemon task (because it - pre-empted the timer daemon task after the xTimeNow value was set). */ - xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched ); - - switch( xMessage.xMessageID ) - { - case tmrCOMMAND_START : - case tmrCOMMAND_START_FROM_ISR : - case tmrCOMMAND_RESET : - case tmrCOMMAND_RESET_FROM_ISR : - case tmrCOMMAND_START_DONT_TRACE : - /* Start or restart a timer. */ - if( prvInsertTimerInActiveList( pxTimer, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow, xMessage.u.xTimerParameters.xMessageValue ) == pdTRUE ) - { - /* The timer expired before it was added to the active - timer list. Process it now. */ - pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); - traceTIMER_EXPIRED( pxTimer ); - - if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) - { - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - break; - - case tmrCOMMAND_STOP : - case tmrCOMMAND_STOP_FROM_ISR : - /* The timer has already been removed from the active list. - There is nothing to do here. */ - break; - - case tmrCOMMAND_CHANGE_PERIOD : - case tmrCOMMAND_CHANGE_PERIOD_FROM_ISR : - pxTimer->xTimerPeriodInTicks = xMessage.u.xTimerParameters.xMessageValue; - configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) ); - - /* The new period does not really have a reference, and can be - longer or shorter than the old one. The command time is - therefore set to the current time, and as the period cannot be - zero the next expiry time can only be in the future, meaning - (unlike for the xTimerStart() case above) there is no fail case - that needs to be handled here. */ - ( void ) prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow ); - break; - - case tmrCOMMAND_DELETE : - /* The timer has already been removed from the active list, - just free up the memory. */ - vPortFree( pxTimer ); - break; - - default : - /* Don't expect to get here. */ - break; - } - } - } -} -/*-----------------------------------------------------------*/ - -static void prvSwitchTimerLists( void ) -{ -TickType_t xNextExpireTime, xReloadTime; -List_t *pxTemp; -Timer_t *pxTimer; -BaseType_t xResult; - - /* The tick count has overflowed. The timer lists must be switched. - If there are any timers still referenced from the current timer list - then they must have expired and should be processed before the lists - are switched. */ - while( listLIST_IS_EMPTY( pxCurrentTimerList ) == pdFALSE ) - { - xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList ); - - /* Remove the timer from the list. */ - pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); - ( void ) uxListRemove( &( pxTimer->xTimerListItem ) ); - traceTIMER_EXPIRED( pxTimer ); - - /* Execute its callback, then send a command to restart the timer if - it is an auto-reload timer. It cannot be restarted here as the lists - have not yet been switched. */ - pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); - - if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE ) - { - /* Calculate the reload value, and if the reload value results in - the timer going into the same timer list then it has already expired - and the timer should be re-inserted into the current list so it is - processed again within this loop. Otherwise a command should be sent - to restart the timer to ensure it is only inserted into a list after - the lists have been swapped. */ - xReloadTime = ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ); - if( xReloadTime > xNextExpireTime ) - { - listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xReloadTime ); - listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer ); - vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) ); - } - else - { - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - - pxTemp = pxCurrentTimerList; - pxCurrentTimerList = pxOverflowTimerList; - pxOverflowTimerList = pxTemp; -} -/*-----------------------------------------------------------*/ - -static void prvCheckForValidListAndQueue( void ) -{ - /* Check that the list from which active timers are referenced, and the - queue used to communicate with the timer service, have been - initialised. */ - taskENTER_CRITICAL(); - { - if( xTimerQueue == NULL ) - { - vListInitialise( &xActiveTimerList1 ); - vListInitialise( &xActiveTimerList2 ); - pxCurrentTimerList = &xActiveTimerList1; - pxOverflowTimerList = &xActiveTimerList2; - xTimerQueue = xQueueCreate( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, sizeof( DaemonTaskMessage_t ) ); - configASSERT( xTimerQueue ); - - #if ( configQUEUE_REGISTRY_SIZE > 0 ) - { - if( xTimerQueue != NULL ) - { - vQueueAddToRegistry( xTimerQueue, "TmrQ" ); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - #endif /* configQUEUE_REGISTRY_SIZE */ - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - taskEXIT_CRITICAL(); -} -/*-----------------------------------------------------------*/ - -BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) -{ -BaseType_t xTimerIsInActiveList; -Timer_t *pxTimer = ( Timer_t * ) xTimer; - - /* Is the timer in the list of active timers? */ - taskENTER_CRITICAL(); - { - /* Checking to see if it is in the NULL list in effect checks to see if - it is referenced from either the current or the overflow timer lists in - one go, but the logic has to be reversed, hence the '!'. */ - xTimerIsInActiveList = ( BaseType_t ) !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) ); - } - taskEXIT_CRITICAL(); - - return xTimerIsInActiveList; -} /*lint !e818 Can't be pointer to const due to the typedef. */ -/*-----------------------------------------------------------*/ - -void *pvTimerGetTimerID( const TimerHandle_t xTimer ) -{ -Timer_t * const pxTimer = ( Timer_t * ) xTimer; -void *pvReturn; - - configASSERT( xTimer ); - - taskENTER_CRITICAL(); - { - pvReturn = pxTimer->pvTimerID; - } - taskEXIT_CRITICAL(); - - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID ) -{ -Timer_t * const pxTimer = ( Timer_t * ) xTimer; - - configASSERT( xTimer ); - - taskENTER_CRITICAL(); - { - pxTimer->pvTimerID = pvNewID; - } - taskEXIT_CRITICAL(); -} -/*-----------------------------------------------------------*/ - -#if( INCLUDE_xTimerPendFunctionCall == 1 ) - - BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) - { - DaemonTaskMessage_t xMessage; - BaseType_t xReturn; - - /* Complete the message with the function parameters and post it to the - daemon task. */ - xMessage.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR; - xMessage.u.xCallbackParameters.pxCallbackFunction = xFunctionToPend; - xMessage.u.xCallbackParameters.pvParameter1 = pvParameter1; - xMessage.u.xCallbackParameters.ulParameter2 = ulParameter2; - - xReturn = xQueueSendFromISR( xTimerQueue, &xMessage, pxHigherPriorityTaskWoken ); - - tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, xReturn ); - - return xReturn; - } - -#endif /* INCLUDE_xTimerPendFunctionCall */ -/*-----------------------------------------------------------*/ - -#if( INCLUDE_xTimerPendFunctionCall == 1 ) - - BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) - { - DaemonTaskMessage_t xMessage; - BaseType_t xReturn; - - /* This function can only be called after a timer has been created or - after the scheduler has been started because, until then, the timer - queue does not exist. */ - configASSERT( xTimerQueue ); - - /* Complete the message with the function parameters and post it to the - daemon task. */ - xMessage.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK; - xMessage.u.xCallbackParameters.pxCallbackFunction = xFunctionToPend; - xMessage.u.xCallbackParameters.pvParameter1 = pvParameter1; - xMessage.u.xCallbackParameters.ulParameter2 = ulParameter2; - - xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait ); - - tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, xReturn ); - - return xReturn; - } - -#endif /* INCLUDE_xTimerPendFunctionCall */ -/*-----------------------------------------------------------*/ - -/* This entire source file will be skipped if the application is not configured -to include software timer functionality. If you want to include software timer -functionality then ensure configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */ -#endif /* configUSE_TIMERS == 1 */ - - - diff --git a/GD32F1/libraries/FreeRTOS821/utility/timers.h b/GD32F1/libraries/FreeRTOS821/utility/timers.h deleted file mode 100644 index a64c019..0000000 --- a/GD32F1/libraries/FreeRTOS821/utility/timers.h +++ /dev/null @@ -1,1146 +0,0 @@ -/* - FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - - -#ifndef TIMERS_H -#define TIMERS_H - -#ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include timers.h" -#endif - -/*lint -e537 This headers are only multiply included if the application code -happens to also be including task.h. */ -#include "task.h" -/*lint +e537 */ - -#ifdef __cplusplus -extern "C" { -#endif - -/*----------------------------------------------------------- - * MACROS AND DEFINITIONS - *----------------------------------------------------------*/ - -/* IDs for commands that can be sent/received on the timer queue. These are to -be used solely through the macros that make up the public software timer API, -as defined below. The commands that are sent from interrupts must use the -highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task -or interrupt version of the queue send function should be used. */ -#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) -#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) -#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) -#define tmrCOMMAND_START ( ( BaseType_t ) 1 ) -#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 ) -#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 ) -#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 ) -#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 ) - -#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 ) -#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 ) -#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 ) -#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 ) -#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 ) - - -/** - * Type by which software timers are referenced. For example, a call to - * xTimerCreate() returns an TimerHandle_t variable that can then be used to - * reference the subject timer in calls to other software timer API functions - * (for example, xTimerStart(), xTimerReset(), etc.). - */ -typedef void * TimerHandle_t; - -/* - * Defines the prototype to which timer callback functions must conform. - */ -typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer ); - -/* - * Defines the prototype to which functions used with the - * xTimerPendFunctionCallFromISR() function must conform. - */ -typedef void (*PendedFunction_t)( void *, uint32_t ); - -/** - * TimerHandle_t xTimerCreate( const char * const pcTimerName, - * TickType_t xTimerPeriodInTicks, - * UBaseType_t uxAutoReload, - * void * pvTimerID, - * TimerCallbackFunction_t pxCallbackFunction ); - * - * Creates a new software timer instance. This allocates the storage required - * by the new timer, initialises the new timers internal state, and returns a - * handle by which the new timer can be referenced. - * - * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), - * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and - * xTimerChangePeriodFromISR() API functions can all be used to transition a - * timer into the active state. - * - * @param pcTimerName A text name that is assigned to the timer. This is done - * purely to assist debugging. The kernel itself only ever references a timer - * by its handle, and never by its name. - * - * @param xTimerPeriodInTicks The timer period. The time is defined in tick - * periods so the constant portTICK_PERIOD_MS can be used to convert a time that - * has been specified in milliseconds. For example, if the timer must expire - * after 100 ticks, then xTimerPeriodInTicks should be set to 100. - * Alternatively, if the timer must expire after 500ms, then xPeriod can be set - * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or - * equal to 1000. - * - * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will - * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. - * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and - * enter the dormant state after it expires. - * - * @param pvTimerID An identifier that is assigned to the timer being created. - * Typically this would be used in the timer callback function to identify which - * timer expired when the same callback function is assigned to more than one - * timer. - * - * @param pxCallbackFunction The function to call when the timer expires. - * Callback functions must have the prototype defined by TimerCallbackFunction_t, - * which is "void vCallbackFunction( TimerHandle_t xTimer );". - * - * @return If the timer is successfully created then a handle to the newly - * created timer is returned. If the timer cannot be created (because either - * there is insufficient FreeRTOS heap remaining to allocate the timer - * structures, or the timer period was set to 0) then NULL is returned. - * - * Example usage: - * @verbatim - * #define NUM_TIMERS 5 - * - * // An array to hold handles to the created timers. - * TimerHandle_t xTimers[ NUM_TIMERS ]; - * - * // An array to hold a count of the number of times each timer expires. - * int32_t lExpireCounters[ NUM_TIMERS ] = { 0 }; - * - * // Define a callback function that will be used by multiple timer instances. - * // The callback function does nothing but count the number of times the - * // associated timer expires, and stop the timer once the timer has expired - * // 10 times. - * void vTimerCallback( TimerHandle_t pxTimer ) - * { - * int32_t lArrayIndex; - * const int32_t xMaxExpiryCountBeforeStopping = 10; - * - * // Optionally do something if the pxTimer parameter is NULL. - * configASSERT( pxTimer ); - * - * // Which timer expired? - * lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer ); - * - * // Increment the number of times that pxTimer has expired. - * lExpireCounters[ lArrayIndex ] += 1; - * - * // If the timer has expired 10 times then stop it from running. - * if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping ) - * { - * // Do not use a block time if calling a timer API function from a - * // timer callback function, as doing so could cause a deadlock! - * xTimerStop( pxTimer, 0 ); - * } - * } - * - * void main( void ) - * { - * int32_t x; - * - * // Create then start some timers. Starting the timers before the scheduler - * // has been started means the timers will start running immediately that - * // the scheduler starts. - * for( x = 0; x < NUM_TIMERS; x++ ) - * { - * xTimers[ x ] = xTimerCreate( "Timer", // Just a text name, not used by the kernel. - * ( 100 * x ), // The timer period in ticks. - * pdTRUE, // The timers will auto-reload themselves when they expire. - * ( void * ) x, // Assign each timer a unique id equal to its array index. - * vTimerCallback // Each timer calls the same callback when it expires. - * ); - * - * if( xTimers[ x ] == NULL ) - * { - * // The timer was not created. - * } - * else - * { - * // Start the timer. No block time is specified, and even if one was - * // it would be ignored because the scheduler has not yet been - * // started. - * if( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) - * { - * // The timer could not be set into the Active state. - * } - * } - * } - * - * // ... - * // Create tasks here. - * // ... - * - * // Starting the scheduler will start the timers running as they have already - * // been set into the active state. - * xTaskStartScheduler(); - * - * // Should not reach here. - * for( ;; ); - * } - * @endverbatim - */ -TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/** - * void *pvTimerGetTimerID( TimerHandle_t xTimer ); - * - * Returns the ID assigned to the timer. - * - * IDs are assigned to timers using the pvTimerID parameter of the call to - * xTimerCreated() that was used to create the timer, and by calling the - * vTimerSetTimerID() API function. - * - * If the same callback function is assigned to multiple timers then the timer - * ID can be used as time specific (timer local) storage. - * - * @param xTimer The timer being queried. - * - * @return The ID assigned to the timer being queried. - * - * Example usage: - * - * See the xTimerCreate() API function example usage scenario. - */ -void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; - -/** - * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); - * - * Sets the ID assigned to the timer. - * - * IDs are assigned to timers using the pvTimerID parameter of the call to - * xTimerCreated() that was used to create the timer. - * - * If the same callback function is assigned to multiple timers then the timer - * ID can be used as time specific (timer local) storage. - * - * @param xTimer The timer being updated. - * - * @param pvNewID The ID to assign to the timer. - * - * Example usage: - * - * See the xTimerCreate() API function example usage scenario. - */ -void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION; - -/** - * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ); - * - * Queries a timer to see if it is active or dormant. - * - * A timer will be dormant if: - * 1) It has been created but not started, or - * 2) It is an expired one-shot timer that has not been restarted. - * - * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), - * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and - * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the - * active state. - * - * @param xTimer The timer being queried. - * - * @return pdFALSE will be returned if the timer is dormant. A value other than - * pdFALSE will be returned if the timer is active. - * - * Example usage: - * @verbatim - * // This function assumes xTimer has already been created. - * void vAFunction( TimerHandle_t xTimer ) - * { - * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" - * { - * // xTimer is active, do something. - * } - * else - * { - * // xTimer is not active, do something else. - * } - * } - * @endverbatim - */ -BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; - -/** - * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); - * - * xTimerGetTimerDaemonTaskHandle() is only available if - * INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h. - * - * Simply returns the handle of the timer service/daemon task. It it not valid - * to call xTimerGetTimerDaemonTaskHandle() before the scheduler has been started. - */ -TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); - -/** - * BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * through a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerStart() starts a timer that was previously created using the - * xTimerCreate() API function. If the timer had already been started and was - * already in the active state, then xTimerStart() has equivalent functionality - * to the xTimerReset() API function. - * - * Starting a timer ensures the timer is in the active state. If the timer - * is not stopped, deleted, or reset in the mean time, the callback function - * associated with the timer will get called 'n' ticks after xTimerStart() was - * called, where 'n' is the timers defined period. - * - * It is valid to call xTimerStart() before the scheduler has been started, but - * when this is done the timer will not actually start until the scheduler is - * started, and the timers expiry time will be relative to when the scheduler is - * started, not relative to when xTimerStart() was called. - * - * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStart() - * to be available. - * - * @param xTimer The handle of the timer being started/restarted. - * - * @param xTicksToWait Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the start command to be successfully - * sent to the timer command queue, should the queue already be full when - * xTimerStart() was called. xTicksToWait is ignored if xTimerStart() is called - * before the scheduler is started. - * - * @return pdFAIL will be returned if the start command could not be sent to - * the timer command queue even after xTicksToWait ticks had passed. pdPASS will - * be returned if the command was successfully sent to the timer command queue. - * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system, although the - * timers expiry time is relative to when xTimerStart() is actually called. The - * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * - * See the xTimerCreate() API function example usage scenario. - * - */ -#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) - -/** - * BaseType_t xTimerStop( TimerHandle_t xTimer, TickType_t xTicksToWait ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * through a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerStop() stops a timer that was previously started using either of the - * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), - * xTimerChangePeriod() or xTimerChangePeriodFromISR() API functions. - * - * Stopping a timer ensures the timer is not in the active state. - * - * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStop() - * to be available. - * - * @param xTimer The handle of the timer being stopped. - * - * @param xTicksToWait Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the stop command to be successfully - * sent to the timer command queue, should the queue already be full when - * xTimerStop() was called. xTicksToWait is ignored if xTimerStop() is called - * before the scheduler is started. - * - * @return pdFAIL will be returned if the stop command could not be sent to - * the timer command queue even after xTicksToWait ticks had passed. pdPASS will - * be returned if the command was successfully sent to the timer command queue. - * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system. The timer - * service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * - * See the xTimerCreate() API function example usage scenario. - * - */ -#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) ) - -/** - * BaseType_t xTimerChangePeriod( TimerHandle_t xTimer, - * TickType_t xNewPeriod, - * TickType_t xTicksToWait ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * through a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerChangePeriod() changes the period of a timer that was previously - * created using the xTimerCreate() API function. - * - * xTimerChangePeriod() can be called to change the period of an active or - * dormant state timer. - * - * The configUSE_TIMERS configuration constant must be set to 1 for - * xTimerChangePeriod() to be available. - * - * @param xTimer The handle of the timer that is having its period changed. - * - * @param xNewPeriod The new period for xTimer. Timer periods are specified in - * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time - * that has been specified in milliseconds. For example, if the timer must - * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, - * if the timer must expire after 500ms, then xNewPeriod can be set to - * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than - * or equal to 1000. - * - * @param xTicksToWait Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the change period command to be - * successfully sent to the timer command queue, should the queue already be - * full when xTimerChangePeriod() was called. xTicksToWait is ignored if - * xTimerChangePeriod() is called before the scheduler is started. - * - * @return pdFAIL will be returned if the change period command could not be - * sent to the timer command queue even after xTicksToWait ticks had passed. - * pdPASS will be returned if the command was successfully sent to the timer - * command queue. When the command is actually processed will depend on the - * priority of the timer service/daemon task relative to other tasks in the - * system. The timer service/daemon task priority is set by the - * configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * @verbatim - * // This function assumes xTimer has already been created. If the timer - * // referenced by xTimer is already active when it is called, then the timer - * // is deleted. If the timer referenced by xTimer is not active when it is - * // called, then the period of the timer is set to 500ms and the timer is - * // started. - * void vAFunction( TimerHandle_t xTimer ) - * { - * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" - * { - * // xTimer is already active - delete it. - * xTimerDelete( xTimer ); - * } - * else - * { - * // xTimer is not active, change its period to 500ms. This will also - * // cause the timer to start. Block for a maximum of 100 ticks if the - * // change period command cannot immediately be sent to the timer - * // command queue. - * if( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS ) - * { - * // The command was successfully sent. - * } - * else - * { - * // The command could not be sent, even after waiting for 100 ticks - * // to pass. Take appropriate action here. - * } - * } - * } - * @endverbatim - */ - #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) ) - -/** - * BaseType_t xTimerDelete( TimerHandle_t xTimer, TickType_t xTicksToWait ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * through a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerDelete() deletes a timer that was previously created using the - * xTimerCreate() API function. - * - * The configUSE_TIMERS configuration constant must be set to 1 for - * xTimerDelete() to be available. - * - * @param xTimer The handle of the timer being deleted. - * - * @param xTicksToWait Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the delete command to be - * successfully sent to the timer command queue, should the queue already be - * full when xTimerDelete() was called. xTicksToWait is ignored if xTimerDelete() - * is called before the scheduler is started. - * - * @return pdFAIL will be returned if the delete command could not be sent to - * the timer command queue even after xTicksToWait ticks had passed. pdPASS will - * be returned if the command was successfully sent to the timer command queue. - * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system. The timer - * service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * - * See the xTimerChangePeriod() API function example usage scenario. - */ -#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) ) - -/** - * BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait ); - * - * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * through a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the - * configTIMER_QUEUE_LENGTH configuration constant. - * - * xTimerReset() re-starts a timer that was previously created using the - * xTimerCreate() API function. If the timer had already been started and was - * already in the active state, then xTimerReset() will cause the timer to - * re-evaluate its expiry time so that it is relative to when xTimerReset() was - * called. If the timer was in the dormant state then xTimerReset() has - * equivalent functionality to the xTimerStart() API function. - * - * Resetting a timer ensures the timer is in the active state. If the timer - * is not stopped, deleted, or reset in the mean time, the callback function - * associated with the timer will get called 'n' ticks after xTimerReset() was - * called, where 'n' is the timers defined period. - * - * It is valid to call xTimerReset() before the scheduler has been started, but - * when this is done the timer will not actually start until the scheduler is - * started, and the timers expiry time will be relative to when the scheduler is - * started, not relative to when xTimerReset() was called. - * - * The configUSE_TIMERS configuration constant must be set to 1 for xTimerReset() - * to be available. - * - * @param xTimer The handle of the timer being reset/started/restarted. - * - * @param xTicksToWait Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the reset command to be successfully - * sent to the timer command queue, should the queue already be full when - * xTimerReset() was called. xTicksToWait is ignored if xTimerReset() is called - * before the scheduler is started. - * - * @return pdFAIL will be returned if the reset command could not be sent to - * the timer command queue even after xTicksToWait ticks had passed. pdPASS will - * be returned if the command was successfully sent to the timer command queue. - * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system, although the - * timers expiry time is relative to when xTimerStart() is actually called. The - * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * @verbatim - * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In - * // this case, the timer is a one-shot timer. - * - * TimerHandle_t xBacklightTimer = NULL; - * - * // The callback function assigned to the one-shot timer. In this case the - * // parameter is not used. - * void vBacklightTimerCallback( TimerHandle_t pxTimer ) - * { - * // The timer expired, therefore 5 seconds must have passed since a key - * // was pressed. Switch off the LCD back-light. - * vSetBacklightState( BACKLIGHT_OFF ); - * } - * - * // The key press event handler. - * void vKeyPressEventHandler( char cKey ) - * { - * // Ensure the LCD back-light is on, then reset the timer that is - * // responsible for turning the back-light off after 5 seconds of - * // key inactivity. Wait 10 ticks for the command to be successfully sent - * // if it cannot be sent immediately. - * vSetBacklightState( BACKLIGHT_ON ); - * if( xTimerReset( xBacklightTimer, 100 ) != pdPASS ) - * { - * // The reset command was not executed successfully. Take appropriate - * // action here. - * } - * - * // Perform the rest of the key processing here. - * } - * - * void main( void ) - * { - * int32_t x; - * - * // Create then start the one-shot timer that is responsible for turning - * // the back-light off if no keys are pressed within a 5 second period. - * xBacklightTimer = xTimerCreate( "BacklightTimer", // Just a text name, not used by the kernel. - * ( 5000 / portTICK_PERIOD_MS), // The timer period in ticks. - * pdFALSE, // The timer is a one-shot timer. - * 0, // The id is not used by the callback so can take any value. - * vBacklightTimerCallback // The callback function that switches the LCD back-light off. - * ); - * - * if( xBacklightTimer == NULL ) - * { - * // The timer was not created. - * } - * else - * { - * // Start the timer. No block time is specified, and even if one was - * // it would be ignored because the scheduler has not yet been - * // started. - * if( xTimerStart( xBacklightTimer, 0 ) != pdPASS ) - * { - * // The timer could not be set into the Active state. - * } - * } - * - * // ... - * // Create tasks here. - * // ... - * - * // Starting the scheduler will start the timer running as it has already - * // been set into the active state. - * xTaskStartScheduler(); - * - * // Should not reach here. - * for( ;; ); - * } - * @endverbatim - */ -#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) - -/** - * BaseType_t xTimerStartFromISR( TimerHandle_t xTimer, - * BaseType_t *pxHigherPriorityTaskWoken ); - * - * A version of xTimerStart() that can be called from an interrupt service - * routine. - * - * @param xTimer The handle of the timer being started/restarted. - * - * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most - * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerStartFromISR() writes a message to the timer - * command queue, so has the potential to transition the timer service/daemon - * task out of the Blocked state. If calling xTimerStartFromISR() causes the - * timer service/daemon task to leave the Blocked state, and the timer service/ - * daemon task has a priority equal to or greater than the currently executing - * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will - * get set to pdTRUE internally within the xTimerStartFromISR() function. If - * xTimerStartFromISR() sets this value to pdTRUE then a context switch should - * be performed before the interrupt exits. - * - * @return pdFAIL will be returned if the start command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system, although the timers expiry time is - * relative to when xTimerStartFromISR() is actually called. The timer - * service/daemon task priority is set by the configTIMER_TASK_PRIORITY - * configuration constant. - * - * Example usage: - * @verbatim - * // This scenario assumes xBacklightTimer has already been created. When a - * // key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In - * // this case, the timer is a one-shot timer, and unlike the example given for - * // the xTimerReset() function, the key press event handler is an interrupt - * // service routine. - * - * // The callback function assigned to the one-shot timer. In this case the - * // parameter is not used. - * void vBacklightTimerCallback( TimerHandle_t pxTimer ) - * { - * // The timer expired, therefore 5 seconds must have passed since a key - * // was pressed. Switch off the LCD back-light. - * vSetBacklightState( BACKLIGHT_OFF ); - * } - * - * // The key press interrupt service routine. - * void vKeyPressEventInterruptHandler( void ) - * { - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; - * - * // Ensure the LCD back-light is on, then restart the timer that is - * // responsible for turning the back-light off after 5 seconds of - * // key inactivity. This is an interrupt service routine so can only - * // call FreeRTOS API functions that end in "FromISR". - * vSetBacklightState( BACKLIGHT_ON ); - * - * // xTimerStartFromISR() or xTimerResetFromISR() could be called here - * // as both cause the timer to re-calculate its expiry time. - * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was - * // declared (in this function). - * if( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) - * { - * // The start command was not executed successfully. Take appropriate - * // action here. - * } - * - * // Perform the rest of the key processing here. - * - * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch - * // should be performed. The syntax required to perform a context switch - * // from inside an ISR varies from port to port, and from compiler to - * // compiler. Inspect the demos for the port you are using to find the - * // actual syntax required. - * if( xHigherPriorityTaskWoken != pdFALSE ) - * { - * // Call the interrupt safe yield function here (actual function - * // depends on the FreeRTOS port being used). - * } - * } - * @endverbatim - */ -#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) - -/** - * BaseType_t xTimerStopFromISR( TimerHandle_t xTimer, - * BaseType_t *pxHigherPriorityTaskWoken ); - * - * A version of xTimerStop() that can be called from an interrupt service - * routine. - * - * @param xTimer The handle of the timer being stopped. - * - * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most - * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerStopFromISR() writes a message to the timer - * command queue, so has the potential to transition the timer service/daemon - * task out of the Blocked state. If calling xTimerStopFromISR() causes the - * timer service/daemon task to leave the Blocked state, and the timer service/ - * daemon task has a priority equal to or greater than the currently executing - * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will - * get set to pdTRUE internally within the xTimerStopFromISR() function. If - * xTimerStopFromISR() sets this value to pdTRUE then a context switch should - * be performed before the interrupt exits. - * - * @return pdFAIL will be returned if the stop command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system. The timer service/daemon task - * priority is set by the configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * @verbatim - * // This scenario assumes xTimer has already been created and started. When - * // an interrupt occurs, the timer should be simply stopped. - * - * // The interrupt service routine that stops the timer. - * void vAnExampleInterruptServiceRoutine( void ) - * { - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; - * - * // The interrupt has occurred - simply stop the timer. - * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined - * // (within this function). As this is an interrupt service routine, only - * // FreeRTOS API functions that end in "FromISR" can be used. - * if( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) - * { - * // The stop command was not executed successfully. Take appropriate - * // action here. - * } - * - * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch - * // should be performed. The syntax required to perform a context switch - * // from inside an ISR varies from port to port, and from compiler to - * // compiler. Inspect the demos for the port you are using to find the - * // actual syntax required. - * if( xHigherPriorityTaskWoken != pdFALSE ) - * { - * // Call the interrupt safe yield function here (actual function - * // depends on the FreeRTOS port being used). - * } - * } - * @endverbatim - */ -#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U ) - -/** - * BaseType_t xTimerChangePeriodFromISR( TimerHandle_t xTimer, - * TickType_t xNewPeriod, - * BaseType_t *pxHigherPriorityTaskWoken ); - * - * A version of xTimerChangePeriod() that can be called from an interrupt - * service routine. - * - * @param xTimer The handle of the timer that is having its period changed. - * - * @param xNewPeriod The new period for xTimer. Timer periods are specified in - * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time - * that has been specified in milliseconds. For example, if the timer must - * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, - * if the timer must expire after 500ms, then xNewPeriod can be set to - * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than - * or equal to 1000. - * - * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most - * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerChangePeriodFromISR() writes a message to the - * timer command queue, so has the potential to transition the timer service/ - * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR() - * causes the timer service/daemon task to leave the Blocked state, and the - * timer service/daemon task has a priority equal to or greater than the - * currently executing task (the task that was interrupted), then - * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the - * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets - * this value to pdTRUE then a context switch should be performed before the - * interrupt exits. - * - * @return pdFAIL will be returned if the command to change the timers period - * could not be sent to the timer command queue. pdPASS will be returned if the - * command was successfully sent to the timer command queue. When the command - * is actually processed will depend on the priority of the timer service/daemon - * task relative to other tasks in the system. The timer service/daemon task - * priority is set by the configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * @verbatim - * // This scenario assumes xTimer has already been created and started. When - * // an interrupt occurs, the period of xTimer should be changed to 500ms. - * - * // The interrupt service routine that changes the period of xTimer. - * void vAnExampleInterruptServiceRoutine( void ) - * { - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; - * - * // The interrupt has occurred - change the period of xTimer to 500ms. - * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined - * // (within this function). As this is an interrupt service routine, only - * // FreeRTOS API functions that end in "FromISR" can be used. - * if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) - * { - * // The command to change the timers period was not executed - * // successfully. Take appropriate action here. - * } - * - * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch - * // should be performed. The syntax required to perform a context switch - * // from inside an ISR varies from port to port, and from compiler to - * // compiler. Inspect the demos for the port you are using to find the - * // actual syntax required. - * if( xHigherPriorityTaskWoken != pdFALSE ) - * { - * // Call the interrupt safe yield function here (actual function - * // depends on the FreeRTOS port being used). - * } - * } - * @endverbatim - */ -#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U ) - -/** - * BaseType_t xTimerResetFromISR( TimerHandle_t xTimer, - * BaseType_t *pxHigherPriorityTaskWoken ); - * - * A version of xTimerReset() that can be called from an interrupt service - * routine. - * - * @param xTimer The handle of the timer that is to be started, reset, or - * restarted. - * - * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most - * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerResetFromISR() writes a message to the timer - * command queue, so has the potential to transition the timer service/daemon - * task out of the Blocked state. If calling xTimerResetFromISR() causes the - * timer service/daemon task to leave the Blocked state, and the timer service/ - * daemon task has a priority equal to or greater than the currently executing - * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will - * get set to pdTRUE internally within the xTimerResetFromISR() function. If - * xTimerResetFromISR() sets this value to pdTRUE then a context switch should - * be performed before the interrupt exits. - * - * @return pdFAIL will be returned if the reset command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system, although the timers expiry time is - * relative to when xTimerResetFromISR() is actually called. The timer service/daemon - * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. - * - * Example usage: - * @verbatim - * // This scenario assumes xBacklightTimer has already been created. When a - * // key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In - * // this case, the timer is a one-shot timer, and unlike the example given for - * // the xTimerReset() function, the key press event handler is an interrupt - * // service routine. - * - * // The callback function assigned to the one-shot timer. In this case the - * // parameter is not used. - * void vBacklightTimerCallback( TimerHandle_t pxTimer ) - * { - * // The timer expired, therefore 5 seconds must have passed since a key - * // was pressed. Switch off the LCD back-light. - * vSetBacklightState( BACKLIGHT_OFF ); - * } - * - * // The key press interrupt service routine. - * void vKeyPressEventInterruptHandler( void ) - * { - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; - * - * // Ensure the LCD back-light is on, then reset the timer that is - * // responsible for turning the back-light off after 5 seconds of - * // key inactivity. This is an interrupt service routine so can only - * // call FreeRTOS API functions that end in "FromISR". - * vSetBacklightState( BACKLIGHT_ON ); - * - * // xTimerStartFromISR() or xTimerResetFromISR() could be called here - * // as both cause the timer to re-calculate its expiry time. - * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was - * // declared (in this function). - * if( xTimerResetFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) - * { - * // The reset command was not executed successfully. Take appropriate - * // action here. - * } - * - * // Perform the rest of the key processing here. - * - * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch - * // should be performed. The syntax required to perform a context switch - * // from inside an ISR varies from port to port, and from compiler to - * // compiler. Inspect the demos for the port you are using to find the - * // actual syntax required. - * if( xHigherPriorityTaskWoken != pdFALSE ) - * { - * // Call the interrupt safe yield function here (actual function - * // depends on the FreeRTOS port being used). - * } - * } - * @endverbatim - */ -#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) - - -/** - * BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, - * void *pvParameter1, - * uint32_t ulParameter2, - * BaseType_t *pxHigherPriorityTaskWoken ); - * - * - * Used from application interrupt service routines to defer the execution of a - * function to the RTOS daemon task (the timer service task, hence this function - * is implemented in timers.c and is prefixed with 'Timer'). - * - * Ideally an interrupt service routine (ISR) is kept as short as possible, but - * sometimes an ISR either has a lot of processing to do, or needs to perform - * processing that is not deterministic. In these cases - * xTimerPendFunctionCallFromISR() can be used to defer processing of a function - * to the RTOS daemon task. - * - * A mechanism is provided that allows the interrupt to return directly to the - * task that will subsequently execute the pended callback function. This - * allows the callback function to execute contiguously in time with the - * interrupt - just as if the callback had executed in the interrupt itself. - * - * @param xFunctionToPend The function to execute from the timer service/ - * daemon task. The function must conform to the PendedFunction_t - * prototype. - * - * @param pvParameter1 The value of the callback function's first parameter. - * The parameter has a void * type to allow it to be used to pass any type. - * For example, unsigned longs can be cast to a void *, or the void * can be - * used to point to a structure. - * - * @param ulParameter2 The value of the callback function's second parameter. - * - * @param pxHigherPriorityTaskWoken As mentioned above, calling this function - * will result in a message being sent to the timer daemon task. If the - * priority of the timer daemon task (which is set using - * configTIMER_TASK_PRIORITY in FreeRTOSConfig.h) is higher than the priority of - * the currently running task (the task the interrupt interrupted) then - * *pxHigherPriorityTaskWoken will be set to pdTRUE within - * xTimerPendFunctionCallFromISR(), indicating that a context switch should be - * requested before the interrupt exits. For that reason - * *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the - * example code below. - * - * @return pdPASS is returned if the message was successfully sent to the - * timer daemon task, otherwise pdFALSE is returned. - * - * Example usage: - * @verbatim - * - * // The callback function that will execute in the context of the daemon task. - * // Note callback functions must all use this same prototype. - * void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 ) - * { - * BaseType_t xInterfaceToService; - * - * // The interface that requires servicing is passed in the second - * // parameter. The first parameter is not used in this case. - * xInterfaceToService = ( BaseType_t ) ulParameter2; - * - * // ...Perform the processing here... - * } - * - * // An ISR that receives data packets from multiple interfaces - * void vAnISR( void ) - * { - * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; - * - * // Query the hardware to determine which interface needs processing. - * xInterfaceToService = prvCheckInterfaces(); - * - * // The actual processing is to be deferred to a task. Request the - * // vProcessInterface() callback function is executed, passing in the - * // number of the interface that needs processing. The interface to - * // service is passed in the second parameter. The first parameter is - * // not used in this case. - * xHigherPriorityTaskWoken = pdFALSE; - * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); - * - * // If xHigherPriorityTaskWoken is now set to pdTRUE then a context - * // switch should be requested. The macro used is port specific and will - * // be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - refer to - * // the documentation page for the port being used. - * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - * - * } - * @endverbatim - */ -BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ); - - /** - * BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, - * void *pvParameter1, - * uint32_t ulParameter2, - * TickType_t xTicksToWait ); - * - * - * Used to defer the execution of a function to the RTOS daemon task (the timer - * service task, hence this function is implemented in timers.c and is prefixed - * with 'Timer'). - * - * @param xFunctionToPend The function to execute from the timer service/ - * daemon task. The function must conform to the PendedFunction_t - * prototype. - * - * @param pvParameter1 The value of the callback function's first parameter. - * The parameter has a void * type to allow it to be used to pass any type. - * For example, unsigned longs can be cast to a void *, or the void * can be - * used to point to a structure. - * - * @param ulParameter2 The value of the callback function's second parameter. - * - * @param xTicksToWait Calling this function will result in a message being - * sent to the timer daemon task on a queue. xTicksToWait is the amount of - * time the calling task should remain in the Blocked state (so not using any - * processing time) for space to become available on the timer queue if the - * queue is found to be full. - * - * @return pdPASS is returned if the message was successfully sent to the - * timer daemon task, otherwise pdFALSE is returned. - * - */ -BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ); - -/** - * const char * const pcTimerGetTimerName( TimerHandle_t xTimer ); - * - * Returns the name that was assigned to a timer when the timer was created. - * - * @param xTimer The handle of the timer being queried. - * - * @return The name assigned to the timer specified by the xTimer parameter. - */ -const char * pcTimerGetTimerName( TimerHandle_t xTimer ); /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/* - * Functions beyond this part are not part of the public API and are intended - * for use by the kernel only. - */ -BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION; -BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - -#ifdef __cplusplus -} -#endif -#endif /* TIMERS_H */ - - - diff --git a/GD32F1/libraries/ILI9341_due_STM/ILI9341_due.cpp b/GD32F1/libraries/ILI9341_due_STM/ILI9341_due.cpp deleted file mode 100644 index 1338e5a..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/ILI9341_due.cpp +++ /dev/null @@ -1,1670 +0,0 @@ -/* -ILI9341_due_.cpp - Arduino Due library for interfacing with ILI9341-based TFTs - -Copyright (c) 2014 Marek Buriak -Modified 03/19/2015 by Victor Perez to add STM32F1 Maple mini DMA support - -This library is based on ILI9341_t3 library from Paul Stoffregen -(https://github.com/PaulStoffregen/ILI9341_t3), Adafruit_ILI9341 -and Adafruit_GFX libraries from Limor Fried/Ladyada -(https://github.com/adafruit/Adafruit_ILI9341). - -This file is part of the Arduino ILI9341_due library. -Sources for this library can be found at https://github.com/marekburiak/ILI9341_Due. - -ILI9341_due is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 of the License, or -(at your option) any later version. - -ILI9341_due is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with ILI9341_due. If not, see . - -*/ - -/*************************************************** -This is our library for the Adafruit ILI9341 Breakout and Shield -----> http://www.adafruit.com/products/1651 - -Check out the links above for our tutorials and wiring diagrams -These displays use SPI to communicate, 4 or 5 pins are required to -interface (RST is optional) -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -MIT license, all text above must be included in any redistribution -****************************************************/ - -#include "ILI9341_due.h" -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED -#include -#elif SPI_MODE_DMA -#include "ILI_SdSpi.h" -#include -#endif -//#include "..\Streaming\Streaming.h" - - -static const uint8_t init_commands[] PROGMEM = { - 4, 0xEF, 0x03, 0x80, 0x02, - 4, 0xCF, 0x00, 0XC1, 0X30, - 5, 0xED, 0x64, 0x03, 0X12, 0X81, - 4, 0xE8, 0x85, 0x00, 0x78, - 6, 0xCB, 0x39, 0x2C, 0x00, 0x34, 0x02, - 2, 0xF7, 0x20, - 3, 0xEA, 0x00, 0x00, - 2, ILI9341_PWCTR1, 0x23, // Power control - 2, ILI9341_PWCTR2, 0x10, // Power control - 3, ILI9341_VMCTR1, 0x3e, 0x28, // VCM control - 2, ILI9341_VMCTR2, 0x86, // VCM control2 - 2, ILI9341_MADCTL, 0x48, // Memory Access Control - 2, ILI9341_PIXFMT, 0x55, - 3, ILI9341_FRMCTR1, 0x00, 0x18, - 4, ILI9341_DFUNCTR, 0x08, 0x82, 0x27, // Display Function Control - 2, 0xF2, 0x00, // Gamma Function Disable - 2, ILI9341_GAMMASET, 0x01, // Gamma curve selected - 16, ILI9341_GMCTRP1, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, - 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, // Set Gamma - 16, ILI9341_GMCTRN1, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, - 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, // Set Gamma - 0 -}; - - -ILI9341_due::ILI9341_due(uint8_t cs, uint8_t dc, uint8_t rst) -{ - _cs = cs; - _dc = dc; - _rst = rst; - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - _rotation = iliRotation0; -#ifdef FEATURE_PRINT_ENABLED - _cursorY = _cursorX = 0; - _textsize = 1; - _textcolor = _textbgcolor = 0xFFFF; - _wrap = true; -#endif -#ifdef FEATURE_ARC_ENABLED - _arcAngleMax = ARC_ANGLE_MAX; - _arcAngleOffset = ARC_ANGLE_OFFSET; -#endif -} - - -bool ILI9341_due::begin(void) -{ - if (pinIsChipSelect(_cs)) { - pinMode(_dc, OUTPUT); - _dcport = portOutputRegister(digitalPinToPort(_dc)); - _dcpinmask = digitalPinToBitMask(_dc); - -#if SPI_MODE_NORMAL | SPI_MODE_DMA - pinMode(_cs, OUTPUT); - _csport = portOutputRegister(digitalPinToPort(_cs)); - _cspinmask = digitalPinToBitMask(_cs); -#endif - -#if SPI_MODE_NORMAL - SPI.begin(); - SPI.setClockDivider(ILI9341_SPI_CLKDIVIDER); - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); -#ifdef __AVR__ - _SPCR = SPCR; -#endif -#elif SPI_MODE_EXTENDED - SPI.begin(_cs); - SPI.setClockDivider(_cs, ILI9341_SPI_CLKDIVIDER); - SPI.setBitOrder(_cs, MSBFIRST); - SPI.setDataMode(_cs, SPI_MODE0); -#elif SPI_MODE_DMA - _dmaSpi.begin(); - _dmaSpi.init(ILI9341_SPI_CLKDIVIDER); -#endif - - // toggle RST low to reset - if (_rst < 255) { - pinMode(_rst, OUTPUT); - digitalWrite(_rst, HIGH); - delay(5); - digitalWrite(_rst, LOW); - delay(20); - digitalWrite(_rst, HIGH); - delay(150); - } - - const uint8_t *addr = init_commands; - while (1) { - uint8_t count = pgm_read_byte(addr++); - if (count-- == 0) break; - writecommand_cont(pgm_read_byte(addr++)); - while (count-- > 0) { - writedata8_cont(pgm_read_byte(addr++)); - } - } - - writecommand_last(ILI9341_SLPOUT); // Exit Sleep - delay(120); - writecommand_last(ILI9341_DISPON); // Display on - delay(120); - _isInSleep = _isIdle = false; - - uint8_t x = readcommand8(ILI9341_RDMODE); - Serial.print(F("\nDisplay Power Mode: 0x")); Serial.println(x, HEX); - x = readcommand8(ILI9341_RDMADCTL); - Serial.print(F("\nMADCTL Mode: 0x")); Serial.println(x, HEX); - x = readcommand8(ILI9341_RDPIXFMT); - Serial.print(F("\nPixel Format: 0x")); Serial.println(x, HEX); - x = readcommand8(ILI9341_RDIMGFMT); - Serial.print(F("\nImage Format: 0x")); Serial.println(x, HEX); - x = readcommand8(ILI9341_RDSELFDIAG); - Serial.print(F("\nSelf Diagnostic: 0x")); Serial.println(x, HEX); - - return true; - } - else { - return false; - } -} - -bool ILI9341_due::pinIsChipSelect(uint8_t cs) -{ -#if SPI_MODE_EXTENDED - if(cs == 4 || cs == 10 || cs == 52) // in Extended SPI mode only these pins are valid - { - return true; - } - else - { - Serial.print("Pin "); - Serial.print(_cs); - Serial.println(" is not a valid Chip Select pin for SPI Extended Mode. Valid pins are 4, 10, 52"); - return false; - } -#elif SPI_MODE_NORMAL | SPI_MODE_DMA - return true; -#endif -} - -void ILI9341_due::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) -{ - setAddrAndRW_cont(x0, y0, x1, y1); - disableCS(); -} - -void ILI9341_due::setSPIClockDivider(uint8_t divider) -{ -#if SPI_MODE_NORMAL - SPI.setClockDivider(divider); -#elif SPI_MODE_EXTENDED - SPI.setClockDivider(_cs, divider); -#elif SPI_MODE_DMA - _dmaSpi.init(divider); -#endif -} - -void ILI9341_due::pushColor(uint16_t color) -{ - enableCS(); - writedata16_last(color); -} - -void ILI9341_due::pushColors(uint16_t *colors, uint16_t offset, uint16_t len) { - enableCS(); - setDCForData(); - colors = colors + offset * 2; -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - for (uint16_t i = 0; i < len; i++) { - write16_cont(colors[i]); - } -#elif SPI_MODE_DMA - for (uint16_t i = 0; i < (len << 1); i += 2) { - uint16_t color = *colors; - _scanlineBuffer[i] = highByte(color); - _scanlineBuffer[i + 1] = lowByte(color); - colors++; - } - writeScanline_cont(len); -#endif - disableCS(); -} - -// pushes pixels stored in the colors array (one color is 2 bytes) -// in big endian (high byte first) -// len should be the length of the array (so to push 320 pixels, -// you have to have a 640-byte array and len should be 640) -void ILI9341_due::pushColors565(uint8_t *colors, uint16_t offset, uint16_t len) { - enableCS(); - setDCForData(); - colors = colors + offset; - -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - for (uint16_t i = 0; i < len; i++) { - write8_cont(colors[i]); - } -#elif SPI_MODE_DMA - write_cont(colors, len); -#endif - disableCS(); -} - - -void ILI9341_due::drawPixel(int16_t x, int16_t y, uint16_t color) { - - if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) return; - writePixel_last(x, y, color); -} - -void ILI9341_due::drawPixel_cont(int16_t x, int16_t y, uint16_t color) { - - if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) return; - writePixel_cont(x, y, color); -} - -void ILI9341_due::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) -{ - // Rudimentary clipping - if ((x >= _width) || (y >= _height || h == 0)) return; - if ((y + h - 1) >= _height) h = _height - y; - - setAddrAndRW_cont(x, y, x, y + h - 1); -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - setDCForData(); - while (h-- > 1) { - write16_cont(color); - } - write16_last(color); -#elif SPI_MODE_DMA - fillScanline(color, h); - writeScanline_last(h); -#endif -} - -void ILI9341_due::drawFastVLine_cont_noFill(int16_t x, int16_t y, int16_t h, uint16_t color) -{ - // Rudimentary clipping - if ((x >= _width) || (y >= _height || h == 0)) return; - if ((y + h - 1) >= _height) h = _height - y; - - setAddrAndRW_cont(x, y, x, y + h - 1); -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - setDCForData(); - while (h-- > 0) { - write16_cont(color); - } -#elif SPI_MODE_DMA - writeScanline_cont(h); -#endif -} - -void ILI9341_due::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) -{ - // Rudimentary clipping - if ((x >= _width) || (y >= _height || w == 0)) return; - if ((x + w - 1) >= _width) w = _width - x; - - setAddrAndRW_cont(x, y, x + w - 1, y); -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - setDCForData(); - while (w-- > 1) { - write16_cont(color); - } - writedata16_last(color); -#elif SPI_MODE_DMA - fillScanline(color, w); - writeScanline_last(w); -#endif -} - -void ILI9341_due::fillScreen(uint16_t color) -{ -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - fillRect(0, 0, _width, _height, color); -#elif SPI_MODE_DMA - - fillScanline(color); - - setAddrAndRW_cont(0, 0, _width - 1, _height - 1); - setDCForData(); - const uint16_t bytesToWrite = _width << 1; - for (uint16_t y = 0; y < _height; y++) - { - write_cont(_scanlineBuffer, bytesToWrite); - } - disableCS(); - -#endif -} - -// fill a rectangle -void ILI9341_due::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) -{ - //Serial << "x:" << x << " y:" << y << " w:" << x << " h:" << h << " width:" << _width << " height:" << _height <= _width) || (y >= _height || w == 0 || h == 0)) return; - if ((x + w - 1) >= _width) w = _width - x; - if ((y + h - 1) >= _height) h = _height - y; - - setAddrAndRW_cont(x, y, x + w - 1, y + h - 1); -#if SPI_MODE_DMA - const uint16_t maxNumLinesInScanlineBuffer = (SCANLINE_BUFFER_SIZE >> 1) / w; - const uint16_t numPixelsInOneGo = w*maxNumLinesInScanlineBuffer; - - fillScanline(color, numPixelsInOneGo); - - for (uint16_t p = 0; p < h / maxNumLinesInScanlineBuffer; p++) - { - writeScanline_cont(numPixelsInOneGo); - } - writeScanline_last((w*h) % numPixelsInOneGo); - -#elif SPI_MODE_NORMAL | SPI_MODE_EXTENDED - // TODO: this can result in a very long transaction time - // should break this into multiple transactions, even though - // it'll cost more overhead, so we don't stall other SPI libs - //enableCS(); //setAddrAndRW_cont will enable CS - setDCForData(); - - y=h; - while(y--) { - x=w; - while(x--) - { - write16_cont(color); - } - } - - disableCS(); -#endif -} - - -#define MADCTL_MY 0x80 -#define MADCTL_MX 0x40 -#define MADCTL_MV 0x20 -#define MADCTL_ML 0x10 -#define MADCTL_RGB 0x00 -#define MADCTL_BGR 0x08 -#define MADCTL_MH 0x04 - -void ILI9341_due::setRotation(iliRotation r) -{ - writecommand_cont(ILI9341_MADCTL); - _rotation = r; - switch (r) { - case iliRotation0: - writedata8_last(MADCTL_MX | MADCTL_BGR); - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - break; - case iliRotation90: - writedata8_last(MADCTL_MV | MADCTL_BGR); - _width = ILI9341_TFTHEIGHT; - _height = ILI9341_TFTWIDTH; - break; - case iliRotation180: - writedata8_last(MADCTL_MY | MADCTL_BGR); - _width = ILI9341_TFTWIDTH; - _height = ILI9341_TFTHEIGHT; - break; - case iliRotation270: - writedata8_last(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); - _width = ILI9341_TFTHEIGHT; - _height = ILI9341_TFTWIDTH; - break; - } -} - - -void ILI9341_due::invertDisplay(boolean i) -{ - writecommand_last(i ? ILI9341_INVON : ILI9341_INVOFF); -} - - -uint8_t ILI9341_due::readcommand8(uint8_t c, uint8_t index) { - writecommand_cont(0xD9); // woo sekret command? - writedata8_last(0x10 + index); - writecommand_cont(c); - - return readdata8_last(); -} - -// Reads one pixel/color from the TFT's GRAM -uint16_t ILI9341_due::readPixel(int16_t x, int16_t y) -{ - setAddr_cont(x, y, x + 1, y + 1); - writecommand_cont(ILI9341_RAMRD); // read from RAM - readdata8_cont(); // dummy read - uint8_t red = read8_cont(); - uint8_t green = read8_cont(); - uint8_t blue = read8_last(); - return color565(red, green, blue); -} - -//void ILI9341_due::drawArc(uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, uint16_t start, uint16_t end, uint16_t color) { -// //void graphics_draw_arc(GContext *ctx, GPoint p, int radius, int thickness, int start, int end) { -// start = start % 360; -// end = end % 360; -// -// while (start < 0) start += 360; -// while (end < 0) end += 360; -// -// if (end == 0) end = 360; -// -// //Serial << "start: " << start << " end:" << end << endl; -// -// // Serial << (float)cos_lookup(start * ARC_MAX_STEPS / 360) << " x " << (float)sin_lookup(start * ARC_MAX_STEPS / 360) << endl; -// -// float sslope = (float)cos_lookup(start * ARC_MAX_STEPS / 360) / (float)sin_lookup(start * ARC_MAX_STEPS / 360); -// float eslope = (float)cos_lookup(end * ARC_MAX_STEPS / 360) / (float)sin_lookup(end * ARC_MAX_STEPS / 360); -// -// //Serial << "sslope: " << sslope << " eslope:" << eslope << endl; -// -// if (end == 360) eslope = -1000000; -// -// int ir2 = (radius - thickness) * (radius - thickness); -// int or2 = radius * radius; -// -// for (int x = -radius; x <= radius; x++) -// for (int y = -radius; y <= radius; y++) -// { -// int x2 = x * x; -// int y2 = y * y; -// -// if ( -// (x2 + y2 < or2 && x2 + y2 >= ir2) && -// ( -// (y > 0 && start < 180 && x <= y * sslope) || -// (y < 0 && start > 180 && x >= y * sslope) || -// (y < 0 && start <= 180) || -// (y == 0 && start <= 180 && x < 0) || -// (y == 0 && start == 0 && x > 0) -// ) && -// ( -// (y > 0 && end < 180 && x >= y * eslope) || -// (y < 0 && end > 180 && x <= y * eslope) || -// (y > 0 && end >= 180) || -// (y == 0 && end >= 180 && x < 0) || -// (y == 0 && start == 0 && x > 0) -// ) -// ) -// drawPixel_cont(cx+x, cy+y, color); -// } -//} - - - -#ifdef FEATURE_ARC_ENABLED -// DrawArc function thanks to Jnmattern and his Arc_2.0 (https://github.com/Jnmattern) -void ILI9341_due::drawArcOffsetted(uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float start, float end, uint16_t color) { - int16_t xmin = 65535, xmax = -32767, ymin = 32767, ymax = -32767; - float cosStart, sinStart, cosEnd, sinEnd; - float r, t; - float startAngle, endAngle; - - //Serial << "start: " << start << " end: " << end << endl; - startAngle = (start / _arcAngleMax) * 360; // 252 - endAngle = (end / _arcAngleMax) * 360; // 807 - //Serial << "startAngle: " << startAngle << " endAngle: " << endAngle << endl; - - while (startAngle < 0) startAngle += 360; - while (endAngle < 0) endAngle += 360; - while (startAngle > 360) startAngle -= 360; - while (endAngle > 360) endAngle -= 360; - //Serial << "startAngleAdj: " << startAngle << " endAngleAdj: " << endAngle << endl; - //if (endAngle == 0) endAngle = 360; - - if (startAngle > endAngle) { - drawArcOffsetted(cx, cy, radius, thickness, ((startAngle) / (float)360) * _arcAngleMax, _arcAngleMax, color); - drawArcOffsetted(cx, cy, radius, thickness, 0, ((endAngle) / (float)360) * _arcAngleMax, color); - } - else { - // Calculate bounding box for the arc to be drawn - cosStart = cosDegrees(startAngle); - sinStart = sinDegrees(startAngle); - cosEnd = cosDegrees(endAngle); - sinEnd = sinDegrees(endAngle); - - //Serial << cosStart << " " << sinStart << " " << cosEnd << " " << sinEnd << endl; - - r = radius; - // Point 1: radius & startAngle - t = r * cosStart; - if (t < xmin) xmin = t; - if (t > xmax) xmax = t; - t = r * sinStart; - if (t < ymin) ymin = t; - if (t > ymax) ymax = t; - - // Point 2: radius & endAngle - t = r * cosEnd; - if (t < xmin) xmin = t; - if (t > xmax) xmax = t; - t = r * sinEnd; - if (t < ymin) ymin = t; - if (t > ymax) ymax = t; - - r = radius - thickness; - // Point 3: radius-thickness & startAngle - t = r * cosStart; - if (t < xmin) xmin = t; - if (t > xmax) xmax = t; - t = r * sinStart; - if (t < ymin) ymin = t; - if (t > ymax) ymax = t; - - // Point 4: radius-thickness & endAngle - t = r * cosEnd; - if (t < xmin) xmin = t; - if (t > xmax) xmax = t; - t = r * sinEnd; - if (t < ymin) ymin = t; - if (t > ymax) ymax = t; - - - //Serial << xmin << " " << xmax << " " << ymin << " " << ymax << endl; - // Corrections if arc crosses X or Y axis - if ((startAngle < 90) && (endAngle > 90)) { - ymax = radius; - } - - if ((startAngle < 180) && (endAngle > 180)) { - xmin = -radius; - } - - if ((startAngle < 270) && (endAngle > 270)) { - ymin = -radius; - } - - // Slopes for the two sides of the arc - float sslope = (float)cosStart / (float)sinStart; - float eslope = (float)cosEnd / (float)sinEnd; - - //Serial << "sslope2: " << sslope << " eslope2:" << eslope << endl; - - if (endAngle == 360) eslope = -1000000; - - int ir2 = (radius - thickness) * (radius - thickness); - int or2 = radius * radius; - //Serial << "ymin: " << ymin << " ymax: " << ymax << endl; -#if SPI_MODE_DMA - fillScanline(color, radius << 1); -#endif - for (int x = xmin; x <= xmax; x++) { - bool y1StartFound = false, y2StartFound = false; - bool y1EndFound = false, y2EndSearching = false; - int y1s = 0, y1e = 0, y2s = 0, y2e = 0; - for (int y = ymin; y <= ymax; y++) - { - int x2 = x * x; - int y2 = y * y; - - if ( - (x2 + y2 < or2 && x2 + y2 >= ir2) && ( - (y > 0 && startAngle < 180 && x <= y * sslope) || - (y < 0 && startAngle > 180 && x >= y * sslope) || - (y < 0 && startAngle <= 180) || - (y == 0 && startAngle <= 180 && x < 0) || - (y == 0 && startAngle == 0 && x > 0) - ) && ( - (y > 0 && endAngle < 180 && x >= y * eslope) || - (y < 0 && endAngle > 180 && x <= y * eslope) || - (y > 0 && endAngle >= 180) || - (y == 0 && endAngle >= 180 && x < 0) || - (y == 0 && startAngle == 0 && x > 0))) - { - if (!y1StartFound) //start of the higher line found - { - y1StartFound = true; - y1s = y; - } - else if (y1EndFound && !y2StartFound) //start of the lower line found - { - //Serial << "Found y2 start x: " << x << " y:" << y << endl; - y2StartFound = true; - //drawPixel_cont(cx+x, cy+y, ILI9341_BLUE); - y2s = y; - y += y1e - y1s - 1; // calculate the most probable end of the lower line (in most cases the length of lower line is equal to length of upper line), in the next loop we will validate if the end of line is really there - if (y > ymax - 1) // the most probable end of line 2 is beyond ymax so line 2 must be shorter, thus continue with pixel by pixel search - { - y = y2s; // reset y and continue with pixel by pixel search - y2EndSearching = true; - } - - //Serial << "Upper line length: " << (y1e - y1s) << " Setting y to " << y << endl; - } - else if (y2StartFound && !y2EndSearching) - { - // we validated that the probable end of the lower line has a pixel, continue with pixel by pixel search, in most cases next loop with confirm the end of lower line as it will not find a valid pixel - y2EndSearching = true; - } - //Serial << "x:" << x << " y:" << y << endl; - //drawPixel_cont(cx+x, cy+y, ILI9341_BLUE); - } - else - { - if (y1StartFound && !y1EndFound) //higher line end found - { - y1EndFound = true; - y1e = y - 1; - //Serial << "line: " << y1s << " - " << y1e << endl; - drawFastVLine_cont_noFill(cx + x, cy + y1s, y - y1s, color); - if (y < 0) - { - //Serial << x << " " << y << endl; - y = abs(y); // skip the empty middle - } - else - break; - } - else if (y2StartFound) - { - if (y2EndSearching) - { - //Serial << "Found final end at y: " << y << endl; - // we found the end of the lower line after pixel by pixel search - drawFastVLine_cont_noFill(cx + x, cy + y2s, y - y2s, color); - y2EndSearching = false; - break; - } - else - { - //Serial << "Expected end not found" << endl; - // the expected end of the lower line is not there so the lower line must be shorter - y = y2s; // put the y back to the lower line start and go pixel by pixel to find the end - y2EndSearching = true; - } - } - //else - //drawPixel_cont(cx+x, cy+y, ILI9341_RED); - } - // - - //delay(75); - } - if (y1StartFound && !y1EndFound) - { - y1e = ymax; - //Serial << "line: " << y1s << " - " << y1e << endl; - drawFastVLine_cont_noFill(cx + x, cy + y1s, y1e - y1s + 1, color); - } - else if (y2StartFound && y2EndSearching) // we found start of lower line but we are still searching for the end - { // which we haven't found in the loop so the last pixel in a column must be the end - drawFastVLine_cont_noFill(cx + x, cy + y2s, ymax - y2s + 1, color); - } - } - disableCS(); - } -} -#endif - -void ILI9341_due::screenshotToConsole() -{ - uint16_t color565; - uint8_t lastColor[3]; - uint8_t color[3]; - uint32_t sameColorPixelCount = 0; - uint16_t sameColorPixelCount16 = 0; - uint32_t sameColorStartIndex = 0; - uint32_t totalImageDataLength = 0; - - Serial.println(F("==== PIXEL DATA START ====")); - //uint16_t x=0; - //uint16_t y=0; - setAddr_cont(0, 0, _width - 1, _height - 1); - writecommand_cont(ILI9341_RAMRD); // read from RAM - readdata8_cont(); // dummy read, also sets DC high - -#if SPI_MODE_DMA - read_cont(color, 3); - lastColor[0] = color[0]; - lastColor[1] = color[1]; - lastColor[2] = color[2]; -#elif SPI_MODE_NORMAL | SPI_MODE_EXTENDED - lastColor[0] = color[0] = read8_cont(); - lastColor[1] = color[1] = read8_cont(); - lastColor[2] = color[2] = read8_cont(); -#endif - printHex8(color, 3); //write color of the first pixel - totalImageDataLength += 6; - sameColorStartIndex = 0; - - for (uint32_t i = 1; i < _width*_height; i++) - { -#if SPI_MODE_DMA - read_cont(color, 3); -#elif SPI_MODE_NORMAL | SPI_MODE_EXTENDED - color[0] = read8_cont(); - color[1] = read8_cont(); - color[2] = read8_cont(); -#endif - - if (color[0] != lastColor[0] || - color[1] != lastColor[1] || - color[2] != lastColor[2]) - { - sameColorPixelCount = i - sameColorStartIndex; - if (sameColorPixelCount > 65535) - { - sameColorPixelCount16 = 65535; - printHex16(&sameColorPixelCount16, 1); - printHex8(lastColor, 3); - totalImageDataLength += 10; - sameColorPixelCount16 = sameColorPixelCount - 65535; - } - else - sameColorPixelCount16 = sameColorPixelCount; - printHex16(&sameColorPixelCount16, 1); - printHex8(color, 3); - totalImageDataLength += 10; - - sameColorStartIndex = i; - lastColor[0] = color[0]; - lastColor[1] = color[1]; - lastColor[2] = color[2]; - } - } - sameColorPixelCount = _width*_height - sameColorStartIndex; - if (sameColorPixelCount > 65535) - { - sameColorPixelCount16 = 65535; - printHex16(&sameColorPixelCount16, 1); - printHex8(lastColor, 3); - totalImageDataLength += 10; - sameColorPixelCount16 = sameColorPixelCount - 65535; - } - else - sameColorPixelCount16 = sameColorPixelCount; - printHex16(&sameColorPixelCount16, 1); - totalImageDataLength += 4; - printHex32(&totalImageDataLength, 1); - - /*for(uint16_t x=0; x<_width; x++) - { - for(uint16_t y=0; y<_height; y++) - { - color[0] = read8(); - color[1] = read8(); - color[2] = read8(); - - if(color[0] != lastColor[0] || - color[1] != lastColor[1] || - color[2] != lastColor[2]) - { - - } - - PrintHex8(color, 3); - } - }*/ - Serial.println(); - Serial.println(F("==== PIXEL DATA END ====")); - Serial.print(F("Total Image Data Length: ")); - Serial.println(totalImageDataLength); -#if SPI_MODE_DMA - _dmaSpi.init(ILI9341_SPI_CLKDIVIDER); -#endif - disableCS(); -} - -/* -This is the core graphics library for all our displays, providing a common -set of graphics primitives (points, lines, circles, etc.). It needs to bex -paired with a hardware-specific library for each display device we carry -(to handle the lower-level functions). - -Adafruit invests time and resources providing this open source code, please -support Adafruit & open-source hardware by purchasing products from Adafruit! - -Copyright (c) 2013 Adafruit Industries. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "glcdfont.c" - -// Draw a circle outline -void ILI9341_due::drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color) -{ - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - drawPixel_cont(x0, y0 + r, color); - drawPixel_cont(x0, y0 - r, color); - drawPixel_cont(x0 + r, y0, color); - drawPixel_cont(x0 - r, y0, color); - - while (x < y) { - if (f >= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - drawPixel_cont(x0 + x, y0 + y, color); - drawPixel_cont(x0 - x, y0 + y, color); - drawPixel_cont(x0 + x, y0 - y, color); - drawPixel_cont(x0 - x, y0 - y, color); - drawPixel_cont(x0 + y, y0 + x, color); - drawPixel_cont(x0 - y, y0 + x, color); - drawPixel_cont(x0 + y, y0 - x, color); - drawPixel_cont(x0 - y, y0 - x, color); - } - disableCS(); -} - - -void ILI9341_due::drawCircleHelper(int16_t x0, int16_t y0, - int16_t r, uint8_t cornername, uint16_t color) -{ - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - while (x < y) { - if (f >= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - if (cornername & 0x4) { - drawPixel_cont(x0 + x, y0 + y, color); - drawPixel_cont(x0 + y, y0 + x, color); - } - if (cornername & 0x2) { - drawPixel_cont(x0 + x, y0 - y, color); - drawPixel_cont(x0 + y, y0 - x, color); - } - if (cornername & 0x8) { - drawPixel_cont(x0 - y, y0 + x, color); - drawPixel_cont(x0 - x, y0 + y, color); - } - if (cornername & 0x1) { - drawPixel_cont(x0 - y, y0 - x, color); - drawPixel_cont(x0 - x, y0 - y, color); - } - } - disableCS(); -} - -void ILI9341_due::fillCircle(int16_t x0, int16_t y0, int16_t r, - uint16_t color) -{ - drawFastVLine(x0, y0 - r, 2 * r + 1, color); - fillCircleHelper(x0, y0, r, 3, 0, color); -} - -// Used to do circles and roundrects -void ILI9341_due::fillCircleHelper(int16_t x0, int16_t y0, int16_t r, - uint8_t cornername, int16_t delta, uint16_t color) -{ - - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - -#if SPI_MODE_DMA - fillScanline(color, 2 * max(x, y) + 1 + delta); -#endif - enableCS(); - while (x < y) { - if (f >= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - if (cornername & 0x1) { - drawFastVLine_cont_noFill(x0 + x, y0 - y, 2 * y + 1 + delta, color); - drawFastVLine_cont_noFill(x0 + y, y0 - x, 2 * x + 1 + delta, color); - } - if (cornername & 0x2) { - drawFastVLine_cont_noFill(x0 - x, y0 - y, 2 * y + 1 + delta, color); - drawFastVLine_cont_noFill(x0 - y, y0 - x, 2 * x + 1 + delta, color); - } - } - disableCS(); -} - -// Bresenham's algorithm - thx wikpedia -void ILI9341_due::drawLine(int16_t x0, int16_t y0, - int16_t x1, int16_t y1, uint16_t color) -{ - if (y0 == y1) { - if (x1 > x0) { - drawFastHLine(x0, y0, x1 - x0 + 1, color); - } - else if (x1 < x0) { - drawFastHLine(x1, y0, x0 - x1 + 1, color); - } - else { - drawPixel(x0, y0, color); - } - return; - } - else if (x0 == x1) { - if (y1 > y0) { - drawFastVLine(x0, y0, y1 - y0 + 1, color); - } - else { - drawFastVLine(x0, y1, y0 - y1 + 1, color); - } - return; - } - - bool steep = abs(y1 - y0) > abs(x1 - x0); - if (steep) { - swap(x0, y0); - swap(x1, y1); - } - if (x0 > x1) { - swap(x0, x1); - swap(y0, y1); - } - - int16_t dx, dy; - dx = x1 - x0; - dy = abs(y1 - y0); - - int16_t err = dx / 2; - int16_t ystep; - - if (y0 < y1) { - ystep = 1; - } - else { - ystep = -1; - } - - int16_t xbegin = x0; -#if SPI_MODE_DMA - fillScanline(color); -#endif - enableCS(); - if (steep) { - for (; x0 <= x1; x0++) { - err -= dy; - if (err < 0) { - int16_t len = x0 - xbegin; - if (len) { - writeVLine_cont_noCS_noFill(y0, xbegin, len + 1, color); - } - else { - writePixel_cont_noCS(y0, x0, color); - } - xbegin = x0 + 1; - y0 += ystep; - err += dx; - } - } - if (x0 > xbegin + 1) { - writeVLine_cont_noCS_noFill(y0, xbegin, x0 - xbegin, color); - } - - } - else { - for (; x0 <= x1; x0++) { - err -= dy; - if (err < 0) { - int16_t len = x0 - xbegin; - if (len) { - writeHLine_cont_noCS_noFill(xbegin, y0, len + 1, color); - } - else { - writePixel_cont_noCS(x0, y0, color); - } - xbegin = x0 + 1; - y0 += ystep; - err += dx; - } - } - if (x0 > xbegin + 1) { - writeHLine_cont_noCS_noFill(xbegin, y0, x0 - xbegin, color); - } - } - disableCS(); -} - - -// Draw a rectangle -//void ILI9341_due::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) -//{ -// writeHLine_cont(x, y, w, color); -// writeHLine_cont(x, y+h-1, w, color); -// writeVLine_cont(x, y, h, color); -// writeVLine_last(x+w-1, y, h, color); -//} - -void ILI9341_due::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) -{ -#if SPI_MODE_DMA - fillScanline(color, max(w, h)); -#endif - enableCS(); - writeHLine_cont_noCS_noFill(x, y, w, color); - writeHLine_cont_noCS_noFill(x, y + h - 1, w, color); - writeVLine_cont_noCS_noFill(x, y, h, color); - writeVLine_cont_noCS_noFill(x + w - 1, y, h, color); - disableCS(); -} - -// Draw a rounded rectangle -void ILI9341_due::drawRoundRect(int16_t x, int16_t y, int16_t w, - int16_t h, int16_t r, uint16_t color) -{ - if ( h <= 2 * r || w <= 2 * r) return; -#if SPI_MODE_DMA - fillScanline(color, max(w, h)); -#endif - enableCS(); - // smarter version - writeHLine_cont_noCS_noFill(x + r, y, w - 2 * r, color); // Top - writeHLine_cont_noCS_noFill(x + r, y + h - 1, w - 2 * r, color); // Bottom - writeVLine_cont_noCS_noFill(x, y + r, h - 2 * r, color); // Left - writeVLine_cont_noCS_noFill(x + w - 1, y + r, h - 2 * r, color); // Right - disableCS(); - // draw four corners - drawCircleHelper(x + r, y + r, r, 1, color); - drawCircleHelper(x + w - r - 1, y + r, r, 2, color); - drawCircleHelper(x + w - r - 1, y + h - r - 1, r, 4, color); - drawCircleHelper(x + r, y + h - r - 1, r, 8, color); -} - -// Fill a rounded rectangle -void ILI9341_due::fillRoundRect(int16_t x, int16_t y, int16_t w, - int16_t h, int16_t r, uint16_t color) -{ - // smarter version - fillRect(x + r, y, w - 2 * r, h, color); - - // draw four corners - fillCircleHelper(x + w - r - 1, y + r, r, 1, h - 2 * r - 1, color); - fillCircleHelper(x + r, y + r, r, 2, h - 2 * r - 1, color); -} - -// Draw a triangle -void ILI9341_due::drawTriangle(int16_t x0, int16_t y0, - int16_t x1, int16_t y1, - int16_t x2, int16_t y2, uint16_t color) -{ - drawLine(x0, y0, x1, y1, color); - drawLine(x1, y1, x2, y2, color); - drawLine(x2, y2, x0, y0, color); -} - -// Fill a triangle -void ILI9341_due::fillTriangle(int16_t x0, int16_t y0, - int16_t x1, int16_t y1, - int16_t x2, int16_t y2, uint16_t color) -{ - - int16_t a, b, y, last; - - // Sort coordinates by Y order (y2 >= y1 >= y0) - if (y0 > y1) { - swap(y0, y1); swap(x0, x1); - } - if (y1 > y2) { - swap(y2, y1); swap(x2, x1); - } - if (y0 > y1) { - swap(y0, y1); swap(x0, x1); - } - - if (y0 == y2) { // Handle awkward all-on-same-line case as its own thing - a = b = x0; - if (x1 < a) a = x1; - else if (x1 > b) b = x1; - if (x2 < a) a = x2; - else if (x2 > b) b = x2; - drawFastHLine(a, y0, b - a + 1, color); - return; - } - - int16_t - dx01 = x1 - x0, - dy01 = y1 - y0, - dx02 = x2 - x0, - dy02 = y2 - y0, - dx12 = x2 - x1, - dy12 = y2 - y1, - sa = 0, - sb = 0; - - // For upper part of triangle, find scanline crossings for segments - // 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1 - // is included here (and second loop will be skipped, avoiding a /0 - // error there), otherwise scanline y1 is skipped here and handled - // in the second loop...which also avoids a /0 error here if y0=y1 - // (flat-topped triangle). - if (y1 == y2) last = y1; // Include y1 scanline - else last = y1 - 1; // Skip it - -#if SPI_MODE_DMA - fillScanline(color, max(x0, max(x1, x2)) - min(x0, min(x1, x2))); // fill scanline with the widest scanline that'll be used -#endif - enableCS(); - for (y = y0; y <= last; y++) { - a = x0 + sa / dy01; - b = x0 + sb / dy02; - sa += dx01; - sb += dx02; - /* longhand: - a = x0 + (x1 - x0) * (y - y0) / (y1 - y0); - b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); - */ - if (a > b) swap(a, b); - writeHLine_cont_noCS_noFill(a, y, b - a + 1, color); - } - - // For lower part of triangle, find scanline crossings for segments - // 0-2 and 1-2. This loop is skipped if y1=y2. - sa = dx12 * (y - y1); - sb = dx02 * (y - y0); - for (; y <= y2; y++) { - a = x1 + sa / dy12; - b = x0 + sb / dy02; - sa += dx12; - sb += dx02; - /* longhand: - a = x1 + (x2 - x1) * (y - y1) / (y2 - y1); - b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); - */ - if (a > b) swap(a, b); - writeHLine_cont_noCS_noFill(a, y, b - a + 1, color); - } - disableCS(); -} - -// draws monochrome (single color) bitmaps -void ILI9341_due::drawBitmap(int16_t x, int16_t y, - const uint8_t *bitmap, int16_t w, int16_t h, - uint16_t color) -{ - - int16_t i, j, byteWidth = (w + 7) / 8; - -#if SPI_MODE_DMA - _hiByte = highByte(color); - _loByte = lowByte(color); - fillScanline(color, w); -#endif - - for (j = 0; j < h; j++) - { - for (i = 0; i < w; i++) - { - if (pgm_read_byte(bitmap + j * byteWidth + i / 8) & (128 >> (i & 7))) { -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - drawPixel(x+i, y+j, color); -#elif SPI_MODE_DMA - _scanlineBuffer[i << 1] = _hiByte; - _scanlineBuffer[(i << 1) + 1] = _loByte; -#endif - } - } -#if SPI_MODE_DMA - setAddrAndRW_cont(x + i, y + j, x + w - 1, y + j); - writeScanline_cont(w); -#endif - } - disableCS(); -} - -#ifdef FEATURE_PRINT_ENABLED -size_t ILI9341_due::write(uint8_t c) { - if (c == '\n') { - _cursorY += _textsize * 8; - _cursorX = 0; - } - else if (c == '\r') { - // skip em - } - else { - drawChar(_cursorX, _cursorY, c, _textcolor, _textbgcolor, _textsize); - _cursorX += _textsize * 6; - if (_wrap && (_cursorX > (_width - _textsize * 6))) { - _cursorY += _textsize * 8; - _cursorX = 0; - } - } - return 1; -} - -// Draw a character -void ILI9341_due::drawChar(int16_t x, int16_t y, unsigned char c, - uint16_t fgcolor, uint16_t bgcolor, uint8_t size) -{ - if ((x >= _width) || // Clip right - (y >= _height) || // Clip bottom - ((x + 6 * size - 1) < 0) || // Clip left TODO: is this correct? - ((y + 8 * size - 1) < 0)) // Clip top TODO: is this correct? - return; - - enableCS(); - - if (fgcolor == bgcolor) - { - // This transparent approach is only about 20% faster - if (size == 1) - { - uint8_t mask = 0x01; - int16_t xoff, yoff; -#if SPI_MODE_DMA - fillScanline(fgcolor, 5); -#endif - for (yoff = 0; yoff < 8; yoff++) { - uint8_t line = 0; - for (xoff = 0; xoff < 5; xoff++) { - if (font[c * 5 + xoff] & mask) line |= 1; - line <<= 1; - } - line >>= 1; - xoff = 0; - while (line) { - if (line == 0x1F) { - writeHLine_cont_noCS_noFill(x + xoff, y + yoff, 5, fgcolor); - break; - } - else if (line == 0x1E) { - writeHLine_cont_noCS_noFill(x + xoff, y + yoff, 4, fgcolor); - break; - } - else if ((line & 0x1C) == 0x1C) { - writeHLine_cont_noCS_noFill(x + xoff, y + yoff, 3, fgcolor); - line <<= 4; - xoff += 4; - } - else if ((line & 0x18) == 0x18) { - writeHLine_cont_noCS_noFill(x + xoff, y + yoff, 2, fgcolor); - line <<= 3; - xoff += 3; - } - else if ((line & 0x10) == 0x10) { - writePixel_cont_noCS(x + xoff, y + yoff, fgcolor); - line <<= 2; - xoff += 2; - } - else { - line <<= 1; - xoff += 1; - } - } - mask = mask << 1; - } - } - else { - uint8_t mask = 0x01; - int16_t xoff, yoff; - for (yoff = 0; yoff < 8; yoff++) { - uint8_t line = 0; - for (xoff = 0; xoff < 5; xoff++) { - if (font[c * 5 + xoff] & mask) line |= 1; - line <<= 1; - } - line >>= 1; - xoff = 0; - while (line) { - if (line == 0x1F) { - fillRect(x + xoff * size, y + yoff * size, - 5 * size, size, fgcolor); - break; - } - else if (line == 0x1E) { - fillRect(x + xoff * size, y + yoff * size, - 4 * size, size, fgcolor); - break; - } - else if ((line & 0x1C) == 0x1C) { - fillRect(x + xoff * size, y + yoff * size, - 3 * size, size, fgcolor); - line <<= 4; - xoff += 4; - } - else if ((line & 0x18) == 0x18) { - fillRect(x + xoff * size, y + yoff * size, - 2 * size, size, fgcolor); - line <<= 3; - xoff += 3; - } - else if ((line & 0x10) == 0x10) { - fillRect(x + xoff * size, y + yoff * size, - size, size, fgcolor); - line <<= 2; - xoff += 2; - } - else { - line <<= 1; - xoff += 1; - } - } - mask = mask << 1; - } - } - } - else { - // This solid background approach is about 5 time faster - setAddrAndRW_cont(x, y, x + 6 * size - 1, y + 8 * size); - setDCForData(); - uint8_t xr, yr; - uint8_t mask = 0x01; - uint16_t color; - uint16_t scanlineId = 0; - // for each pixel row - for (y = 0; y < 8; y++) - { - //scanlineId = 0; - for (yr = 0; yr < size; yr++) - { - scanlineId = 0; - // draw 5px horizontal "bitmap" line - for (x = 0; x < 5; x++) { - if (font[c * 5 + x] & mask) { - color = fgcolor; - } - else { - color = bgcolor; - } - for (xr = 0; xr < size; xr++) { -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - write16_cont(color); -#elif SPI_MODE_DMA - _scanlineBuffer[scanlineId++] = highByte(color); - _scanlineBuffer[scanlineId++] = lowByte(color); -#endif - } - } - // draw a gap between chars (1px for size of 1) - for (xr = 0; xr < size; xr++) { -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - write16_cont(bgcolor); -#elif SPI_MODE_DMA - _scanlineBuffer[scanlineId++] = highByte(bgcolor); - _scanlineBuffer[scanlineId++] = lowByte(bgcolor); -#endif - } -#if SPI_MODE_DMA - writeScanline_cont(scanlineId - 1); -#endif - } - mask = mask << 1; - } - // draw an empty line below a character -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - uint32_t n = 6 * size * size; - do { - write16_cont(bgcolor); - n--; - } while (n > 0); -#elif SPI_MODE_DMA - fillScanline(bgcolor, 6 * size); - for (y = 0; y < size; y++) - { - writeScanline_cont(6 * size); - } -#endif - } - disableCS(); -} - -void ILI9341_due::setCursor(int16_t x, int16_t y) { - _cursorX = x; - _cursorY = y; -} - -void ILI9341_due::setTextSize(uint8_t s) { - _textsize = (s > 0) ? s : 1; -} - -void ILI9341_due::setTextColor(uint16_t c) { - // For 'transparent' background, we'll set the bg - // to the same as fg instead of using a flag - _textcolor = _textbgcolor = c; -} - -void ILI9341_due::setTextColor(uint16_t c, uint16_t b) { - _textcolor = c; - _textbgcolor = b; -} - -void ILI9341_due::setTextWrap(boolean w) { - _wrap = w; -} -#endif - -uint8_t ILI9341_due::getRotation(void) { - return _rotation; -} - -// if true, tft will be blank (white), -// display's frame buffer is unaffected -// (you can write to it without showing content on the screen) -void ILI9341_due::display(boolean d){ - writecommand_last(d ? ILI9341_DISPON : ILI9341_DISPOFF); -} - -// puts display in/out of sleep mode -void ILI9341_due::sleep(boolean s) -{ - writecommand_last(s ? ILI9341_SLPIN : ILI9341_SLPOUT); - delay(120); -} - -void ILI9341_due::idle(boolean i){ - writecommand_last(i ? ILI9341_IDMON : ILI9341_IDMOFF); -} - - -void ILI9341_due::setPowerLevel(pwrLevel p) -{ - switch (p) - { - case PWRLEVEL_NORMAL: - if (_isIdle) { idle(false); _isIdle = false; } - if (_isInSleep) { sleep(false); _isInSleep = false; } - break; - case PWRLEVEL_IDLE: - if (!_isIdle) { idle(true); _isIdle = true; } - if (_isInSleep) { sleep(false); _isInSleep = false; } - break; - case PWRLEVEL_SLEEP: - if (!_isInSleep) { sleep(true); _isInSleep = true; } - if (_isIdle) { idle(false); _isIdle = false; } - break; - } -} - -#ifdef FEATURE_ARC_ENABLED -void ILI9341_due::setArcParams(float arcAngleMax, int arcAngleOffset) -{ - _arcAngleMax = arcAngleMax; - _arcAngleOffset = arcAngleOffset; -} -#endif - -//uint8_t ILI9341_due::spiread(void) { -// uint8_t r = 0; -// -// //SPI.setClockDivider(_cs, 12); // 8-ish MHz (full! speed!) -// //SPI.setBitOrder(_cs, MSBFIRST); -// //SPI.setDataMode(_cs, SPI_MODE0); -// r = SPI.transfer(_cs, 0x00); -// Serial.print("read: 0x"); Serial.print(r, HEX); -// -// return r; -//} -// -//void ILI9341_due::spiwrite(uint8_t c) { -// -// //Serial.print("0x"); Serial.print(c, HEX); Serial.print(", "); -// -// -// //SPI.setClockDivider(_cs, 12); // 8-ish MHz (full! speed!) -// //SPI.setBitOrder(_cs, MSBFIRST); -// //SPI.setDataMode(_cs, SPI_MODE0); -// SPI.transfer(_cs, c); -// -//} - -//void ILI9341_due::writecommand(uint8_t c) { -// //*dcport &= ~dcpinmask; -// digitalWrite(_dc, LOW); -// //*clkport &= ~clkpinmask; // clkport is a NULL pointer when hwSPI==true -// //digitalWrite(_sclk, LOW); -// //*csport &= ~cspinmask; -// //digitalWrite(_cs, LOW); -// -// spiwrite(c); -// -// //*csport |= cspinmask; -// //digitalWrite(_cs, HIGH); -//} -// -// -//void ILI9341_due::writedata(uint8_t c) { -// //*dcport |= dcpinmask; -// digitalWrite(_dc, HIGH); -// //*clkport &= ~clkpinmask; // clkport is a NULL pointer when hwSPI==true -// //digitalWrite(_sclk, LOW); -// //*csport &= ~cspinmask; -// //digitalWrite(_cs, LOW); -// -// spiwrite(c); -// -// //digitalWrite(_cs, HIGH); -// //*csport |= cspinmask; -//} - -void ILI9341_due::printHex8(uint8_t *data, uint8_t length) // prints 8-bit data in hex -{ - char tmp[length * 2 + 1]; - byte first; - byte second; - for (int i = 0; i < length; i++) { - first = (data[i] >> 4) & 0x0f; - second = data[i] & 0x0f; - // base for converting single digit numbers to ASCII is 48 - // base for 10-16 to become upper-case characters A-F is 55 - // note: difference is 7 - tmp[i * 2] = first + 48; - tmp[i * 2 + 1] = second + 48; - if (first > 9) tmp[i * 2] += 7; - if (second > 9) tmp[i * 2 + 1] += 7; - } - tmp[length * 2] = 0; - Serial.print(tmp); -} - - -void ILI9341_due::printHex16(uint16_t *data, uint8_t length) // prints 8-bit data in hex -{ - char tmp[length * 4 + 1]; - byte first; - byte second; - byte third; - byte fourth; - for (int i = 0; i < length; i++) { - first = (data[i] >> 12) & 0x0f; - second = (data[i] >> 8) & 0x0f; - third = (data[i] >> 4) & 0x0f; - fourth = data[i] & 0x0f; - //Serial << first << " " << second << " " << third << " " << fourth << endl; - // base for converting single digit numbers to ASCII is 48 - // base for 10-16 to become upper-case characters A-F is 55 - // note: difference is 7 - tmp[i * 4] = first + 48; - tmp[i * 4 + 1] = second + 48; - tmp[i * 4 + 2] = third + 48; - tmp[i * 4 + 3] = fourth + 48; - //tmp[i*5+4] = 32; // add trailing space - if (first > 9) tmp[i * 4] += 7; - if (second > 9) tmp[i * 4 + 1] += 7; - if (third > 9) tmp[i * 4 + 2] += 7; - if (fourth > 9) tmp[i * 4 + 3] += 7; - } - tmp[length * 4] = 0; - Serial.print(tmp); -} - -void ILI9341_due::printHex32(uint32_t *data, uint8_t length) // prints 8-bit data in hex -{ - char tmp[length * 8 + 1]; - byte dataByte[8]; - for (int i = 0; i < length; i++) { - dataByte[0] = (data[i] >> 28) & 0x0f; - dataByte[1] = (data[i] >> 24) & 0x0f; - dataByte[2] = (data[i] >> 20) & 0x0f; - dataByte[3] = (data[i] >> 16) & 0x0f; - dataByte[4] = (data[i] >> 12) & 0x0f; - dataByte[5] = (data[i] >> 8) & 0x0f; - dataByte[6] = (data[i] >> 4) & 0x0f; - dataByte[7] = data[i] & 0x0f; - //Serial << first << " " << second << " " << third << " " << fourth << endl; - // base for converting single digit numbers to ASCII is 48 - // base for 10-16 to become upper-case characters A-F is 55 - // note: difference is 7 - tmp[i * 4] = dataByte[0] + 48; - tmp[i * 4 + 1] = dataByte[1] + 48; - tmp[i * 4 + 2] = dataByte[2] + 48; - tmp[i * 4 + 3] = dataByte[3] + 48; - tmp[i * 4 + 4] = dataByte[4] + 48; - tmp[i * 4 + 5] = dataByte[5] + 48; - tmp[i * 4 + 6] = dataByte[6] + 48; - tmp[i * 4 + 7] = dataByte[7] + 48; - //tmp[i*5+4] = 32; // add trailing space - if (dataByte[0] > 9) tmp[i * 4] += 7; - if (dataByte[1] > 9) tmp[i * 4 + 1] += 7; - if (dataByte[2] > 9) tmp[i * 4 + 2] += 7; - if (dataByte[3] > 9) tmp[i * 4 + 3] += 7; - if (dataByte[4] > 9) tmp[i * 4 + 4] += 7; - if (dataByte[5] > 9) tmp[i * 4 + 5] += 7; - if (dataByte[6] > 9) tmp[i * 4 + 6] += 7; - if (dataByte[7] > 9) tmp[i * 4 + 7] += 7; - } - tmp[length * 8] = 0; - Serial.print(tmp); -} diff --git a/GD32F1/libraries/ILI9341_due_STM/ILI9341_due.h b/GD32F1/libraries/ILI9341_due_STM/ILI9341_due.h deleted file mode 100644 index 7b72684..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/ILI9341_due.h +++ /dev/null @@ -1,1171 +0,0 @@ -/* -v0.94.000 - -ILI9341_due_.h - Arduino Due library for interfacing with ILI9341-based TFTs - -Copyright (c) 2014 Marek Buriak - -2.4 TFT Pin-out -T_IRQ T_DO T_DIN T_CS T_CLK MISO LED CLK MOSI DC RESET CS GND VCC - -This library is based on ILI9341_t3 library from Paul Stoffregen -(https://github.com/PaulStoffregen/ILI9341_t3), Adafruit_ILI9341 -and Adafruit_GFX libraries from Limor Fried/Ladyada -(https://github.com/adafruit/Adafruit_ILI9341). - -This file is part of the Arduino ILI9341_due library. -Sources for this library can be found at https://github.com/marekburiak/ILI9341_Due. - -ILI9341_due is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 of the License, or -(at your option) any later version. - -ILI9341_due is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with ILI9341_due. If not, see . - -*/ - -/*************************************************** -This is our library for the Adafruit ILI9341 Breakout and Shield -----> http://www.adafruit.com/products/1651 - -Check out the links above for our tutorials and wiring diagrams -These displays use SPI to communicate, 4 or 5 pins are required to -interface (RST is optional) -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -MIT license, all text above must be included in any redistribution -****************************************************/ - -#ifndef _ILI9341_dueH_ -#define _ILI9341_dueH_ - -#if defined (__STM32F1__) - #include - #include - #include - #include "pins_arduino.h" - #include "wiring_private.h" - #include -#endif - -//#include "../Streaming/Streaming.h" - -// USER CONFIG SECTION START - -// comment out the SPI mode you want to use (does not matter for AVR) -//#define ILI9341_SPI_MODE_NORMAL // uses SPI library -//#define ILI9341_SPI_MODE_EXTENDED // uses Extended SPI in Due, make sure you use pin 4, 10 or 52 for CS -#define ILI9341_SPI_MODE_DMA // uses DMA in Due - -// set the clock divider -#ifdef __SAM3X8E__ -#define ILI9341_SPI_CLKDIVIDER 2 // for Due -#else -#define ILI9341_SPI_CLKDIVIDER SPI_CLOCK_DIV2 // for Uno, Mega,... -#endif - -// comment out the features you do not need to save flash memory and RAM (especially on AVR) - -// commenting out/disabling the ARC feature will exclude the drawArc function. It is going to save a few ROM bytes. -#define FEATURE_ARC_ENABLED -// commenting out/disabling the PRINT feature will exclude the drawChars and print functions, it saves around 3.6kB ROM and 1.3kB RAM(!) -// I recommend using gText for drawing the text. -#define FEATURE_PRINT_ENABLED - -// number representing the maximum angle (e.g. if 100, then if you pass in start=0 and end=50, you get a half circle) -// this can be changed with setArcParams function at runtime -#define ARC_ANGLE_MAX 360 -// rotational offset in degrees defining position of value 0 (-90 will put it at the top of circle) -// this can be changed with setArcParams function at runtime -#define ARC_ANGLE_OFFSET -90 - -// USER CONFIG SECTION END - -#ifdef __AVR__ -#define SPI_MODE_NORMAL 1 -#define SPI_MODE_EXTENDED 0 -#define SPI_MODE_DMA 0 -#else -#ifndef ILI9341_SPI_MODE_NORMAL -#define SPI_MODE_NORMAL 0 -#else -#define SPI_MODE_NORMAL 1 -#endif - -#ifndef ILI9341_SPI_MODE_EXTENDED -#define SPI_MODE_EXTENDED 0 -#else -#define SPI_MODE_EXTENDED 1 -#endif - -#ifndef ILI9341_SPI_MODE_DMA -#define SPI_MODE_DMA 0 -#else -#define SPI_MODE_DMA 1 -#endif -#endif - -#include "Arduino.h" -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED -#include -#elif SPI_MODE_DMA -#include "ILI_SdSpi.h" -#include -#endif - -#ifdef __AVR__ -#include -#endif - -#define ILI9341_TFTWIDTH 240 -#define ILI9341_TFTHEIGHT 320 - -#define ILI9341_NOP 0x00 -#define ILI9341_SWRESET 0x01 -#define ILI9341_RDDID 0x04 -#define ILI9341_RDDST 0x09 - -#define ILI9341_SLPIN 0x10 -#define ILI9341_SLPOUT 0x11 -#define ILI9341_PTLON 0x12 -#define ILI9341_NORON 0x13 - -#define ILI9341_RDMODE 0x0A -#define ILI9341_RDMADCTL 0x0B -#define ILI9341_RDPIXFMT 0x0C -#define ILI9341_RDIMGFMT 0x0A -#define ILI9341_RDSELFDIAG 0x0F - -#define ILI9341_INVOFF 0x20 -#define ILI9341_INVON 0x21 -#define ILI9341_GAMMASET 0x26 -#define ILI9341_DISPOFF 0x28 -#define ILI9341_DISPON 0x29 - -#define ILI9341_CASET 0x2A -#define ILI9341_PASET 0x2B -#define ILI9341_RAMWR 0x2C -#define ILI9341_RAMRD 0x2E - -#define ILI9341_PTLAR 0x30 -#define ILI9341_MADCTL 0x36 -#define ILI9341_IDMOFF 0x38 -#define ILI9341_IDMON 0x39 -#define ILI9341_PIXFMT 0x3A - -#define ILI9341_FRMCTR1 0xB1 -#define ILI9341_FRMCTR2 0xB2 -#define ILI9341_FRMCTR3 0xB3 -#define ILI9341_INVCTR 0xB4 -#define ILI9341_DFUNCTR 0xB6 - -#define ILI9341_PWCTR1 0xC0 -#define ILI9341_PWCTR2 0xC1 -#define ILI9341_PWCTR3 0xC2 -#define ILI9341_PWCTR4 0xC3 -#define ILI9341_PWCTR5 0xC4 -#define ILI9341_VMCTR1 0xC5 -#define ILI9341_VMCTR2 0xC7 - -#define ILI9341_RDID1 0xDA -#define ILI9341_RDID2 0xDB -#define ILI9341_RDID3 0xDC -#define ILI9341_RDID4 0xDD - -#define ILI9341_GMCTRP1 0xE0 -#define ILI9341_GMCTRN1 0xE1 -/* -#define ILI9341_PWCTR6 0xFC - -*/ - -// Color definitions -#define ILI9341_BLACK 0x0000 -#define ILI9341_BLUE 0x001F -#define ILI9341_RED 0xF800 -#define ILI9341_GREEN 0x07E0 -#define ILI9341_CYAN 0x07FF -#define ILI9341_MAGENTA 0xF81F -#define ILI9341_YELLOW 0xFFE0 -#define ILI9341_WHITE 0xFFFF - -typedef uint8_t pwrLevel; -typedef enum { - iliRotation0 = 0, - iliRotation90 = 1, - iliRotation180 = 2, - iliRotation270 = 3 -} iliRotation; - -// Normal Mode On (full display), Idle Mode Off, Sleep Out. -// In this mode, the display is able to show maximum 262,144 colors. -#define PWRLEVEL_NORMAL 1 - -// Normal Mode On (full display), Idle Mode On, Sleep Out. -// In this mode, the full display area is used but with 8 colors. -#define PWRLEVEL_IDLE 2 - -//In this mode, the DC : DC converter, Internal oscillator and panel driver circuit are stopped. Only the MCU -// interface and memory works with VDDI power supply. Contents of the memory are safe. -#define PWRLEVEL_SLEEP 3 - -#define SCANLINE_BUFFER_SIZE 640 // 320 2-byte pixels - -class ILI9341_due -#ifdef FEATURE_PRINT_ENABLED - : public Print -#endif -{ - public: - ILI9341_due(uint8_t cs, uint8_t dc, uint8_t rst = 255); -#if SPI_MODE_DMA - ILI_SdSpi _dmaSpi; - uint8_t _scanlineBuffer[SCANLINE_BUFFER_SIZE]; - uint8_t _hiByte, _loByte; - -#endif - bool _isIdle, _isInSleep; - - bool begin(void); - void pushColor(uint16_t color); - void pushColors(uint16_t *colors, uint16_t offset, uint16_t len); - void pushColors565(uint8_t *colors, uint16_t offset, uint16_t len); - void fillScreen(uint16_t color); - void drawPixel(int16_t x, int16_t y, uint16_t color); - void drawPixel_cont(int16_t x, int16_t y, uint16_t color); - void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); - void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - void setRotation(iliRotation r); - void invertDisplay(boolean i); - void display(boolean d); - void normalModeOn(); - void sleep(boolean s); - void idle(boolean i); - void setPowerLevel(pwrLevel p); - void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); - void setSPIClockDivider(uint8_t divider); - -#ifdef FEATURE_ARC_ENABLED - void setArcParams(float arcAngleMax, int arcAngleOffset); -#endif - // Pass 8-bit (each) R,G,B, get back 16-bit packed color - static uint16_t color565(uint8_t r, uint8_t g, uint8_t b) { - return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); - } - - //uint8_t readdata(void); - uint8_t readcommand8(uint8_t reg, uint8_t index = 0); - - // KJE Added functions to read pixel data... - uint16_t readPixel(int16_t x, int16_t y); - - - // from Adafruit_GFX.h - void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); - void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); - void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); - void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); - void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); - void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); - void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); - void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); - void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); - -#ifdef FEATURE_PRINT_ENABLED - void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size); - void setCursor(int16_t x, int16_t y); - void setTextColor(uint16_t c); - void setTextColor(uint16_t c, uint16_t bg); - void setTextSize(uint8_t s); - void setTextWrap(boolean w); - virtual size_t write(uint8_t); -#endif - int16_t width(void) { - return _width; - } - int16_t height(void) { - return _height; - } - uint8_t getRotation(void); - void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); - void screenshotToConsole(); - void printHex8(uint8_t *data, uint8_t length); - void printHex16(uint16_t *data, uint8_t length); - void printHex32(uint32_t *data, uint8_t length); - -#ifdef FEATURE_ARC_ENABLED - inline __attribute__((always_inline)) - void drawArc(uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float start, float end, uint16_t color) - { - if (start == 0 && end == _arcAngleMax) - drawArcOffsetted(cx, cy, radius, thickness, 0, _arcAngleMax, color); - else - drawArcOffsetted(cx, cy, radius, thickness, start + (_arcAngleOffset / (float)360)*_arcAngleMax, end + (_arcAngleOffset / (float)360)*_arcAngleMax, color); - } - - //int32_t cos_lookup(int32_t angle) - //{ - // float radians = (float)angle/_arcAngleMax * 2 * PI; - // //Serial << "COS_LOOKUP angle:" << (float)angle << " radians:" << radians << " cos:" << cos(radians) << " return: " << cos(radians) * (double)65535 << endl; - // return (cos(radians) * _arcAngleMax); - //} - - //int32_t sin_lookup(int32_t angle) - //{ - // float radians = (float)angle/_arcAngleMax * 2 * PI; - // //Serial << "SIN_LOOKUP angle:" << (float)angle << " radians:" << radians << " sin:" << sin(radians) << " return: " << sin(radians) * (double)65535 << endl; - // return (sin(radians) * _arcAngleMax); - //} - - - float cosDegrees(float angle) - { - float radians = angle / (float)360 * 2 * PI; - //Serial << "COS_LOOKUP angle:" << (float)angle << " radians:" << radians << " cos:" << cos(radians) << " return: " << cos(radians) * (double)65535 << endl; - return cos(radians); - } - - float sinDegrees(float angle) - { - float radians = angle / (float)360 * 2 * PI; - //Serial << "SIN_LOOKUP angle:" << (float)angle << " radians:" << radians << " sin:" << sin(radians) << " return: " << sin(radians) * (double)65535 << endl; - return sin(radians); - } -#endif - - inline __attribute__((always_inline)) - void spiwrite(uint8_t c) { -#if defined __AVR__ - SPDR = c; - asm volatile("nop"); - while (!(SPSR & _BV(SPIF))); // wait -#elif defined __SAM3X8E__ | __STM32F1__ - -#if SPI_MODE_NORMAL - SPI.transfer(c); -#endif -#endif - } - - inline __attribute__((always_inline)) - void spiwrite16(uint16_t d) { -#if defined __AVR__ - SPDR = highByte(d); - while (!(SPSR & _BV(SPIF))); - SPDR = lowByte(d); - while (!(SPSR & _BV(SPIF))); -#elif defined __SAM3X8E__ | __STM32F1__ -#if SPI_MODE_NORMAL - SPI.transfer(highByte(d)); - SPI.transfer(lowByte(d)); -#endif -#endif - } - - // writes 1 byte - // CS and DC have to be set prior to calling this method - inline __attribute__((always_inline)) - void write8_cont(uint8_t c) { -#if SPI_MODE_NORMAL - spiwrite(c); -#elif SPI_MODE_EXTENDED - SPI.transfer(_cs, c, SPI_CONTINUE); -#elif SPI_MODE_DMA - SPI.write(c); -// _dmaSpi.send(c); -#endif - } - - // writes 1 byte and disables CS - // CS and DC have to be set prior to calling this method - inline __attribute__((always_inline)) - void write8_last(uint8_t c) { -#if SPI_MODE_NORMAL - spiwrite(c); - disableCS(); -#elif SPI_MODE_EXTENDED - SPI.transfer(_cs, c, SPI_LAST); -#elif SPI_MODE_DMA - SPI.write(c); -// _dmaSpi.send(c); - disableCS(); -#endif - } - - // Writes 2 bytes - // CS, DC have to be set prior to calling this method - inline __attribute__((always_inline)) - void write16_cont(uint16_t d) { -#if SPI_MODE_NORMAL - spiwrite16(d); -#elif SPI_MODE_EXTENDED - SPI.transfer(_cs, highByte(d), SPI_CONTINUE); - SPI.transfer(_cs, lowByte(d), SPI_CONTINUE); -#elif SPI_MODE_DMA - SPI.transfer(highByte(d)); - SPI.transfer(lowByte(d)); - -// _dmaSpi.send(highByte(d)); -// _dmaSpi.send(lowByte(d)); -#endif - } - - inline __attribute__((always_inline)) - void write16_last(uint16_t d) { -#if SPI_MODE_NORMAL - spiwrite16(d); - disableCS(); -#elif SPI_MODE_EXTENDED - SPI.transfer(_cs, highByte(d), SPI_CONTINUE); - SPI.transfer(_cs, lowByte(d), SPI_LAST); -#elif SPI_MODE_DMA - SPI.transfer(highByte(d)); - SPI.transfer(lowByte(d)); - -// _dmaSpi.send(highByte(d)); -// _dmaSpi.send(lowByte(d)); - disableCS(); -#endif - } - - // Writes commands to set the GRAM area where data/pixels will be written - void setAddr_cont(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) - __attribute__((always_inline)) { - writecommand_cont(ILI9341_CASET); // Column addr set - writedata16_cont(x0); // XSTART - writedata16_cont(x1); // XEND - writecommand_cont(ILI9341_PASET); // Row addr set - writedata16_cont(y0); // YSTART - writedata16_cont(y1); // YEND - } - - //__attribute__((always_inline)) - //void setAddrAndRW_cont(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) - // { - // writecommand_cont(ILI9341_CASET); // Column addr set - // writedata16_cont(x0); // XSTART - // writedata16_cont(x1); // XEND - // writecommand_cont(ILI9341_PASET); // Row addr set - // writedata16_cont(y0); // YSTART - // writedata16_cont(y1); // YEND - // writecommand_cont(ILI9341_RAMWR); // write to RAM - //} - - // Enables CS, writes commands to set the GRAM area where data/pixels will be written - //__attribute__((always_inline)) - // void setAddr_cont(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) - //{ - // enableCS(); - // setDCForCommand(); - // write8_cont(ILI9341_CASET); // Column addr set - // setDCForData(); - // write16_cont(x0); // XSTART - // write16_cont(x1); // XEND - // setDCForCommand(); - // write8_cont(ILI9341_PASET); // Row addr set - // setDCForData(); - // write16_cont(y0); // XSTART - // write16_cont(y1); // XEND - //} - - // Enables CS, writes commands to set the GRAM area where data/pixels will be written - // Also sends RAM WRITE command which should be followed by writing data/pixels -#ifdef __SAM3X8E__ | __STM32F1__ - inline __attribute__((always_inline)) -#endif - void setAddrAndRW_cont(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) - { - enableCS(); - setDCForCommand(); - write8_cont(ILI9341_CASET); // Column addr set - setDCForData(); - write16_cont(x0); // XSTART - write16_cont(x1); // XEND - setDCForCommand(); - write8_cont(ILI9341_PASET); // Row addr set - setDCForData(); - write16_cont(y0); // XSTART - write16_cont(y1); // XEND - setDCForCommand(); - write8_cont(ILI9341_RAMWR); // RAM write - } - - // Writes commands to set the GRAM area where data/pixels will be written - // Also sends RAM WRITE command which should be followed by writing data/pixels - // CS has to be enabled prior to calling this method - //__attribute__((always_inline)) - // void setAddrAndRW_cont_noCS(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) - //{ - // setDCForCommand(); - // write8_cont(ILI9341_CASET); // Column addr set - // setDCForData(); - // write16_cont(x0); // XSTART - // write16_cont(x1); // XEND - // setDCForCommand(); - // write8_cont(ILI9341_PASET); // Row addr set - // setDCForData(); - // write16_cont(y0); // XSTART - // write16_cont(y1); // XEND - // setDCForCommand(); - // write8_cont(ILI9341_RAMWR); // Row addr set - //} - - // Enables CS, sets DC for Command, writes 1 byte - // Does not disable CS - // __attribute__((always_inline)) - // void writecommand_cont(uint8_t c) { - // setDCForCommand(); - //#if SPI_MODE_NORMAL - // enableCS(); - // SPI.transfer(c); - //#elif SPI_MODE_EXTENDED - // SPI.transfer(_cs, c, SPI_CONTINUE); - //#elif SPI_MODE_DMA - // enableCS(); - // _dmaSpi.send(c); - //#endif - // } - - // Enables CS, sets DC for Command, writes 1 byte - // Does not disable CS - inline __attribute__((always_inline)) - void writecommand_cont(uint8_t c) { - setDCForCommand(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - write8_cont(c); - } - - // Enables CS, sets DC for Command, writes 1 byte, disables CS - inline __attribute__((always_inline)) - void writecommand_last(uint8_t c) { - setDCForCommand(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - write8_cont(c); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - disableCS(); -#endif - } - - // Enables CS, sets DC to Data, writes 1 byte - // Does not disable CS - inline __attribute__((always_inline)) - void writedata8_cont(uint8_t c) { - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - write8_cont(c); - } - - // Enables CS, sets DC to Data, writes 1 byte, disables CS - __attribute__((always_inline)) - void writedata8_last(uint8_t c) { - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - write8_cont(c); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - disableCS(); -#endif - } - - // Enables CS, sets DC to Data, writes 2 bytes - // Does not disable CS - __attribute__((always_inline)) - void writedata16_cont(uint16_t d) { - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - write16_cont(d); - } - - // Enables CS, sets DC to Data, writes 2 bytes, disables CS - __attribute__((always_inline)) - void writedata16_last(uint16_t d) { - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - write16_last(d); - } - -#if SPI_MODE_DMA - // Enables CS, sets DC and writes n-bytes from the buffer via DMA - // Does not disable CS - /*inline __attribute__((always_inline)) - void writedata_cont(const uint8_t* buf , size_t n) { - enableCS(); - setDCForData(); - _dmaSpi.send(buf, n); - }*/ - - // Enables CS, sets DC, writes n-bytes from the buffer via DMA, disables CS - /*inline __attribute__((always_inline)) - void writedata_last(const uint8_t* buf , size_t n) { - setDCForData(); - enableCS(); - _dmaSpi.send(buf, n); - disableCS(); - }*/ - - // Writes n-bytes from the buffer via DMA - // CS and DC have to be set prior to calling this method - inline __attribute__((always_inline)) - void write_cont(uint8_t* buf, size_t n) { - _dmaSpi.send(buf, n); - } - - inline __attribute__((always_inline)) - void read_cont(uint8_t* buf, size_t n) { - _dmaSpi.receive(buf, n); - } - - // Writes n-bytes from the buffer via DMA and disables CS - // DC has to be set prior to calling this method - /*inline __attribute__((always_inline)) - void write_last(const uint8_t* buf , size_t n) { - _dmaSpi.send(buf, n << 1); - disableCS(); - }*/ - - // Enables CS, sets DC and writes n-bytes from the scanline buffer via DMA - // Does not disable CS - inline __attribute__((always_inline)) - void writeScanline_cont(size_t n) { - setDCForData(); - enableCS(); - _dmaSpi.send(_scanlineBuffer, n << 1); // each pixel is 2 bytes - } - - // writes n-bytes from the scanline buffer via DMA - // Does not enable CS nor sets DS nor disables CS - //inline __attribute__((always_inline)) - // void writeScanline_cont_noCS_noDC(size_t n) { - // _dmaSpi.send(_scanlineBuffer, n << 1); // each pixel is 2 bytes - //} - - // Enables CS, sets DC, writes n-bytes from the scanline buffer via DMA and disabled CS - inline __attribute__((always_inline)) - void writeScanline_last(size_t n) { - setDCForData(); - enableCS(); - _dmaSpi.send(_scanlineBuffer, n << 1); // each pixel is 2 bytes - disableCS(); - } - -#endif - - // Reads 1 byte - __attribute__((always_inline)) - uint8_t read8_cont() { -#if SPI_MODE_NORMAL - return SPI.transfer(ILI9341_NOP); -#elif SPI_MODE_EXTENDED - return SPI.transfer(_cs, ILI9341_NOP, SPI_CONTINUE); -#elif SPI_MODE_DMA - return _dmaSpi.receive(); -#endif - } - - __attribute__((always_inline)) - uint8_t read8_last() { -#if SPI_MODE_NORMAL - uint8_t r = SPI.transfer(ILI9341_NOP); - disableCS(); - return r; -#elif SPI_MODE_EXTENDED - return SPI.transfer(_cs, ILI9341_NOP, SPI_LAST); -#elif SPI_MODE_DMA - uint8_t r = _dmaSpi.receive(); - disableCS(); - return r; -#endif - } - - // Reads 2 bytes - __attribute__((always_inline)) - uint16_t read16() { -#if SPI_MODE_NORMAL - uint16_t r = SPI.transfer(ILI9341_NOP); - r <<= 8; - r |= SPI.transfer(ILI9341_NOP); -#elif SPI_MODE_EXTENDED - uint16_t r = SPI.transfer(_cs, ILI9341_NOP, SPI_CONTINUE); - r <<= 8; - r |= SPI.transfer(_cs, ILI9341_NOP, SPI_CONTINUE); -#elif SPI_MODE_DMA - uint16_t r = _dmaSpi.receive(); - r <<= 8; - r |= _dmaSpi.receive(); -#endif - return r; - } - - // Reads 2 bytes - __attribute__((always_inline)) - uint16_t readPixel_start_cont() { -#if SPI_MODE_NORMAL - uint16_t r = SPI.transfer(ILI9341_NOP); - r <<= 8; - r |= SPI.transfer(ILI9341_NOP); -#elif SPI_MODE_EXTENDED - uint16_t r = SPI.transfer(_cs, ILI9341_NOP, SPI_CONTINUE); - r <<= 8; - r |= SPI.transfer(_cs, ILI9341_NOP, SPI_CONTINUE); -#elif SPI_MODE_DMA - uint16_t r = _dmaSpi.receive(); - r <<= 8; - r |= _dmaSpi.receive(); -#endif - return r; - } - - // Enables CS, sets DC for Data and reads 1 byte - // Does not disable CS - __attribute__((always_inline)) - uint8_t readdata8_cont() { - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - return read8_cont(); - } - - // Enables CS, sets DC for Data, reads 1 byte and disables CS - __attribute__((always_inline)) - uint8_t readdata8_last() { - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - return read8_last(); - } - - // Enables CS, sets DC for Data and reads 2 bytes - // Does not disable CS - __attribute__((always_inline)) - uint16_t readdata16_cont() { - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - return read16(); - } - - // Enables CS, sets DC for Data, reads 2 bytes and disables CS - __attribute__((always_inline)) - uint8_t readdata16_last() { - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - enableCS(); -#endif - uint16_t r = read16(); -#if SPI_MODE_NORMAL | SPI_MODE_DMA - disableCS(); -#endif - //TOTRY - /*uint8_t buff[2]; // not tested yet - enableCS(); - _dmaSpi.receive(buff, 2); - disableCS(); - uint16_t r = makeWord(buff[1], buff[0]);*/ - - return r; - } - -#if SPI_MODE_DMA - //void fillScanline(uint8_t color) __attribute__((always_inline)) { - // //for(uint16_t i=0; i 0; --n, ++pdst, ++psrc) - // *pdst = *psrc; - - // return dst; - //} -#endif - - // // Writes a sequence that will render a horizontal line - // // At the end CS is kept enabled. - // // In case of DMA mode, the content of scanline buffer is written - // __attribute__((always_inline)) - // void writeHLine_cont(int16_t x, int16_t y, int16_t w, uint16_t color) - // { - //#if SPI_MODE_DMA - // //TOTRY move this down - // fillScanline(color, w); - //#endif - // setAddrAndRW_cont(x, y, x+w-1, y); - //#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - // setDCForData(); - // do { write16_cont(color); } while (--w > 0); - //#elif SPI_MODE_DMA - // writeScanline_cont(w); - //#endif - // } - - // // Writes a sequence that will render a horizontal line - // // At the end CS is disabled. - // // In case of DMA mode, the content of scanline buffer is written - // __attribute__((always_inline)) - // void writeHLine_last(int16_t x, int16_t y, int16_t w, uint16_t color) - // { - //#if SPI_MODE_DMA - // //TOTRY move this down - // fillScanline(color, w); - //#endif - // setAddrAndRW_cont(x, y, x+w-1, y); - //#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - // setDCForData(); - // while (w-- > 1) { - // write16_cont(color); - // } - // write16_last(color); - //#elif SPI_MODE_DMA - // writeScanline_last(w); - //#endif - // } - - // // Writes a sequence that will render a vertical line - // // At the end CS is kept enabled. - // // In case of DMA mode, the content of scanline buffer is filled and written - // __attribute__((always_inline)) - // void writeVLine_cont(int16_t x, int16_t y, int16_t h, uint16_t color) - // { - //#if SPI_MODE_DMA - // // TRY move this down - // fillScanline(color, h); - //#endif - // setAddrAndRW_cont(x, y, x, y+h-1); - //#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - // setDCForData(); - // do { write16_cont(color); } while (--h > 0); - //#elif SPI_MODE_DMA - // writeScanline_cont(h); - //#endif - // } - - // // Writes a sequence that will render a vertical line - // // At the end CS is disabled. - // // In case of DMA mode, the content of scanline buffer is filled and written - // __attribute__((always_inline)) - // void writeVLine_last(int16_t x, int16_t y, int16_t h, uint16_t color) - // { - //#if SPI_MODE_DMA - // fillScanline(color, h); - //#endif - // setAddrAndRW_cont(x, y, x, y+h-1); - //#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - // while (h-- > 1) { - // write16_cont(color); - // } - // write16_last(color); - //#elif SPI_MODE_DMA - // writeScanline_last(h); - //#endif - // } - - // Writes a sequence that will render a horizontal line - // CS must be set prior to calling this method - // for DMA mode, scanline buffer must be filled with the desired color - // Advantage over writeHLine_cont is that CS line is not being set and - // the scanlineBuffer not filled on every call - inline __attribute__((always_inline)) - void writeHLine_cont_noCS_noFill(int16_t x, int16_t y, int16_t w, uint16_t color) - __attribute__((always_inline)) { - //setAddrAndRW_cont(x, y, x+w-1, y); - setDCForCommand(); - write8_cont(ILI9341_CASET); // Column addr set - setDCForData(); - write16_cont(x); // XSTART - write16_cont(x + w - 1); // XEND - setDCForCommand(); - write8_cont(ILI9341_PASET); // Row addr set - setDCForData(); - write16_cont(y); // XSTART - write16_cont(y); // XEND - setDCForCommand(); - write8_cont(ILI9341_RAMWR); - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - do { - write16_cont(color); - } while (--w > 0); -#elif SPI_MODE_DMA - write_cont(_scanlineBuffer, w << 1); -#endif - } - - // Writes a sequence that will render a vertical line - // CS must be set prior to calling this method - // for DMA mode, scanline buffer must be filled with the desired color - // Advantage over writeVLine_cont is that CS line is not being set and - // the scanlineBuffer not filled on every call - inline __attribute__((always_inline)) - void writeVLine_cont_noCS_noFill(int16_t x, int16_t y, int16_t h, uint16_t color) - __attribute__((always_inline)) { - setDCForCommand(); - write8_cont(ILI9341_CASET); // Column addr set - setDCForData(); - write16_cont(x); // XSTART - write16_cont(x); // XEND - setDCForCommand(); - write8_cont(ILI9341_PASET); // Row addr set - setDCForData(); - write16_cont(y); // XSTART - write16_cont(y + h - 1); // XEND - setDCForCommand(); - write8_cont(ILI9341_RAMWR); - setDCForData(); -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - do { - write16_cont(color); - } while (--h > 0); -#elif SPI_MODE_DMA - write_cont(_scanlineBuffer, h << 1); -#endif - } - - - //void HLine_cont(int16_t x, int16_t y, int16_t w, uint16_t color) - // __attribute__((always_inline)) { - // setAddrAndRW_cont(x, y, x+w-1, y); - // do { writedata16_cont(color); } while (--w > 0); - //} - //void VLine_cont(int16_t x, int16_t y, int16_t h, uint16_t color) - // __attribute__((always_inline)) { - // setAddrAndRW_cont(x, y, x, y+h-1); - // do { writedata16_cont(color); } while (--h > 0); - //} - - // Writes a sequence that will render a pixel - // CS must be enabled prior to calling this method - // Advantage over writePixel_cont is that CS line is not set on every call - inline __attribute__((always_inline)) - void writePixel_cont_noCS(int16_t x, int16_t y, uint16_t color) - { - setDCForCommand(); - write8_cont(ILI9341_CASET); // Column addr set - setDCForData(); - write16_cont(x); // XSTART - write16_cont(x); // XEND - setDCForCommand(); - write8_cont(ILI9341_PASET); // Row addr set - setDCForData(); - write16_cont(y); // XSTART - write16_cont(y); // XEND - setDCForCommand(); - write8_cont(ILI9341_RAMWR); - setDCForData(); - write16_cont(color); - } - - inline __attribute__((always_inline)) - void writePixel_cont(int16_t x, int16_t y, uint16_t color) - { - enableCS(); - setDCForCommand(); - write8_cont(ILI9341_CASET); // Column addr set - setDCForData(); - write16_cont(x); // XSTART - write16_cont(x); // XEND - setDCForCommand(); - write8_cont(ILI9341_PASET); // Row addr set - setDCForData(); - write16_cont(y); // XSTART - write16_cont(y); // XEND - setDCForCommand(); - write8_cont(ILI9341_RAMWR); - setDCForData(); - write16_cont(color); - } - - // Enables CS, writes a sequence that will render a pixel and disables CS - inline __attribute__((always_inline)) - void writePixel_last(int16_t x, int16_t y, uint16_t color) - { - setAddrAndRW_cont(x, y, x, y); - setDCForData(); - write16_last(color); - } - - // Enables CS - inline __attribute__((always_inline)) - void enableCS() { -#if SPI_MODE_NORMAL | SPI_MODE_DMA - *_csport &= ~_cspinmask; -#endif - } - - // Disables CS - inline __attribute__((always_inline)) - void disableCS() { -#if SPI_MODE_NORMAL | SPI_MODE_DMA - *_csport |= _cspinmask; - //csport->PIO_SODR |= cspinmask; -#elif SPI_MODE_EXTENDED - writecommand_last(ILI9341_NOP); // have to send a byte to disable CS -#endif - } - - // Sets DC to Data (1) - inline __attribute__((always_inline)) - void setDCForData() { - *_dcport |= _dcpinmask; - //_dcport->PIO_SODR |= _dcpinmask; - } - - // Sets DC to Command (0) - inline __attribute__((always_inline)) - void setDCForCommand() { - *_dcport &= ~_dcpinmask; - } - - protected: - int16_t _width, _height; // Display w/h as modified by current rotation -#ifdef FEATURE_PRINT_ENABLED - int16_t _cursorX, _cursorY; - uint16_t _textcolor, _textbgcolor; - uint8_t _textsize; - boolean _wrap; // If set, 'wrap' text at right edge of display -#endif - iliRotation _rotation; - -#ifdef FEATURE_ARC_ENABLED - float _arcAngleMax; - int _arcAngleOffset; -#endif - - void drawFastVLine_cont_noFill(int16_t x, int16_t y, int16_t h, uint16_t color); - -#ifdef FEATURE_ARC_ENABLED - void drawArcOffsetted(uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float startAngle, float endAngle, uint16_t color); -#endif - - private: - uint8_t _rst; - //Pio *_dcport; -#ifdef __SAM3X8E__ - volatile RwReg *_dcport; - uint32_t _cs, _dc, _dcpinmask; -#elif defined (__STM32F1__) - volatile uint32 *_dcport; - uint32_t _cs, _dc, _dcpinmask; -#else - volatile uint8_t *_dcport, *_csport; - uint8_t _cs, _dc, _cspinmask, _dcpinmask, _SPCR, _backupSPCR; -#endif - - -#if SPI_MODE_NORMAL | SPI_MODE_DMA -#ifdef __SAM3X8E__ - //Pio *_csport; - volatile RwReg *_csport; - uint32_t _cspinmask; -#elif defined (__STM32F1__) - volatile uint32 *_csport; - uint32_t _cspinmask; - -#endif -#endif - bool pinIsChipSelect(uint8_t cs); -}; - -#ifndef swap -#define swap(a, b) { typeof(a) t = a; a = b; b = t; } -#endif - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/ILI9341_due_gText.cpp b/GD32F1/libraries/ILI9341_due_STM/ILI9341_due_gText.cpp deleted file mode 100644 index 89cdc96..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/ILI9341_due_gText.cpp +++ /dev/null @@ -1,1936 +0,0 @@ -/* -ILI9341_due_gText.cpp - Used for rendering GLCD fonts on Arduino Due - -Copyright (c) 2014 Marek Buriak - -The library is based on GLCD library by Bill Perry and Michael Margolis: -https://code.google.com/p/glcd-arduino - -This file is part of the Arduino ILI9341_due library. -Sources for this library can be found at https://github.com/marekburiak/ILI9341_Due. - -Fonts .h files can be created with GLCDFontCreator2 (not the one MikroElektronika): -https://code.google.com/p/glcd-arduino/downloads/detail?name=GLCDFontCreator2.zip&can=2&q= - - -ILI9341_due is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 of the License, or -(at your option) any later version. - -ILI9341_due is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with ILI9341_due. If not, see . - -*/ - -#include "ILI9341_due.h" -#include "ILI9341_due_gText.h" - -//#include "..\Streaming\Streaming.h" - -//extern glcd_Device GLCD; // this is the global GLCD instance, here upcast to the base glcd_Device class - -// This constructor creates a text area using the entire display -// The device pointer is initialized using the global GLCD instance -// New constuctors can be added to take an exlicit glcd instance pointer -// if multiple glcd instances need to be supported -ILI9341_due_gText::ILI9341_due_gText(ILI9341_due *ili) -{ - // device = (glcd_Device*)&GLCD; - _ili = ili; - _fontMode = gTextFontMode_Solid; - _fontBgColor = ILI9341_BLACK; - _fontColor = ILI9341_WHITE; - _letterSpacing = 2; - _isLastChar = false; - defineArea(0,0, _ili->width() -1, _ili->height() -1, DEFAULT_SCROLLDIR); // this should never fail - -} - -// This constructor creates a text area with the given coordinates -// full display area is used if any coordinate is invalid -ILI9341_due_gText::ILI9341_due_gText(ILI9341_due *ili, int16_t x1, int16_t y1, int16_t x2, int16_t y2) //, textMode mode) -{ - //device = (glcd_Device*)&GLCD; - _ili = ili; - if( ! defineArea(x1,y1,x2,y2)) //,mode)) - defineArea(0,0, _ili->width() -1,_ili->height() -1); //,mode); // this should never fail -} - -#if INCLUDE_NOT_WORKING_YET -ILI9341_due_gText::ILI9341_due_gText(ILI9341_due *ili, predefinedArea selection) //, textMode mode) -{ - //device = (glcd_Device*)&GLCD; - _ili = ili; - if( ! defineArea(selection)) //,mode)) - defineArea(0,0, _ili->width() -1,_ili->height() -1,mode); // this should never fail - -} -#endif - -ILI9341_due_gText::ILI9341_due_gText(ILI9341_due *ili, int16_t x1, int16_t y1, int16_t columns, int16_t rows, gTextFont font) //, textMode mode) -{ - //device = (glcd_Device*)&GLCD; - _ili = ili; - if( ! defineArea(x1,y1,columns,rows,font)) //, mode)) - { - defineArea(0,0, _ili->width() -1,_ili->height() -1); //,mode); // this should never fail - selectFont(font); - } -} - -/** -* Clear text area with the current font background color -* and home the cursor to upper left corner of the text area. -* -* @see defineArea() -*/ -void ILI9341_due_gText::clearArea(uint16_t color) -{ - /* - * fill the area with font background color - */ - //Serial << "clearing area from " << _area.x1 << " to " << _area.x2 << endl; - _ili->fillRect(_area.x1, _area.y1, _area.x2 - _area.x1+1, _area.y2-_area.y1+1, color); - - /*glcd_Device::SetPixels(_area.x1, _area.y1, - _area.x2, _area.y2, - _fontColor == BLACK ? WHITE : BLACK);*/ - /* - * put cursor at home position of text area to ensure we are always inside area. - */ - - //cursorToXY(0,0); -} - -/** -* Define a Text area by columns and rows -* -* @param x X coordinate of upper left corner -* @param y Y coordinate of upper left corner -* @param columns number of text columns -* @param rows number of text rows -* @param font a font definition -* @param mode constants SCROLL_DOWN and SCROLL_UP control scroll direction -* -* -* Defines a text area sized to hold columns characters across and rows characters tall. -* It is properly sized for the specified font. -* -* The area within the newly defined text area is intentionally not cleared. -* -* While intended for fixed width fonts, sizing will work for variable -* width fonts. -* -* When variable width fonts are used, the column is based on assuming a width -* of the widest character. -* -* x,y is an absolute coordinate and is relateive to the 0,0 origin of the -* display. -* -* mode is an optional parameter and defaults to normal/up scrolling -* -* @note -* Upon defining the text area, the cursor position for the text area will be set to x,y -* -* @see ClearArea() -*/ - -bool ILI9341_due_gText::defineArea(int16_t x, int16_t y, int16_t columns, int16_t rows, gTextFont font) //, textMode mode) -{ - textMode mode = DEFAULT_SCROLLDIR; - uint16_t x2,y2; - - selectFont(font); - - x2 = x + columns * (pgm_read_byte(_font+GTEXT_FONT_FIXED_WIDTH)+1) -1; - y2 = y + rows * (fontHeight()+1) -1; - - return defineArea(x, y, x2, y2); //, mode); -} - -/** -* Define a text area by absolute coordinates -* -* @param x1 X coordinate of upper left corner -* @param y1 Y coordinate of upper left corner -* @param x2 X coordinate of lower right corner -* @param y2 Y coordinate of lower right corner -* @param mode constants SCROLL_DOWN and SCROLL_UP control scroll direction -* -* Defines a text area based on absolute coordinates. -* The pixel coordinates for the text area are inclusive so x2,y2 is the lower right -* pixel of the text area. -* -* x1,y1 and x2,y2 are an absolute coordinates and are relateive to the 0,0 origin of the -* display. -* -* The area within the newly defined text area is intentionally not cleared. -* -* mode is an optional parameter and defaults to normal/up scrolling -* -* @returns true with the given area selected if all the coordinates are valid, -* otherwise returns returns false with the area set to the full display -* -* @note -* Upon creation of the text area, the cursor position for the text area will be set to x1, y1 -* -* @see ClearArea() -* -*/ - -bool ILI9341_due_gText::defineArea(int16_t x1, int16_t y1, int16_t x2, int16_t y2) //, textMode mode) -{ - textMode mode = DEFAULT_SCROLLDIR; - //Serial << "defineArea input " << x1 << " " << y1 << " " << x2 << " " << y2 << endl; - uint8_t ret = false; - - int16_t disp_width = _ili->width(); - int16_t disp_height = _ili->height(); - - //if( (x1 >= x2) - // || (y1 >= y2) - // || (x1 >= disp_width) - // || (y1 >= disp_height) - // || (x2 >= disp_width) - // || (y2 >= disp_height) - // ) - //{ - // // failed sanity check so set defaults and return false - // _area.x1 = 0; - // _area.y1 = 0; - // _area.x2 = disp_width -1; - // _area.y2 = disp_height -1; - // _area.mode = DEFAULT_SCROLLDIR; - //} - //else - { - _area.x1 = x1; - _area.y1 = y1; - _area.x2 = x2; - _area.y2 = y2; - _area.mode = mode; // not yet sanity checked - ret = true; - } - //Serial << "defineArea set " << _area.x1 << " " << _area.y1 << " " << _area.x2 << " " << _area.y2 << endl; - /* - * set cursor position for the area - */ - _x = x1; - _y = y1; - _scale = 1; - -#ifndef GLCD_NODEFER_SCROLL - /* - * Make sure to clear a deferred scroll operation when re defining areas. - */ - _needScroll = 0; -#endif - return ret; -} - -/** -* Define a predefined generic text area -* -* @param selection a value from @ref predefinedArea -* @param mode constants SCROLL_DOWN and SCROLL_UP control scroll direction -* -* Defines a text area using a selection form a set of predefined areas. -* -* The area within the newly defined text area is intentionally not cleared. -* -* mode is an optional parameter and defaults to normal/up scrolling -* -* @return returns @em true if successful. -* -* -* @note -* Upon defining the text area, the cursor position for the text area will be set to -* the upper left coordinate of the given predefined area -* -* @see ClearArea() -* @see predefinedArea -* -*/ -#if INCLUDE_NOT_WORKING_YET -bool ILI9341_due_gText::defineArea(predefinedArea selection, textMode mode) -{ - int16_t x1,y1,x2,y2; - TareaToken tok; - - tok.token = selection; - - x1 = tok.coord.x1; - y1 = tok.coord.y1; - x2 = tok.coord.x2; - y2 = tok.coord.y2; - - return defineArea(x1,y1,x2,y2, mode); -} -#endif -/* -* Scroll a pixel region up. -* Area scrolled is defined by x1,y1 through x2,y2 inclusive. -* x1,y1 is upper left corder, x2,y2 is lower right corner. -* -* color is the color to be used for the created space along the -* bottom. -* -* pixels is the *exact* pixels to scroll. 1 is 1 and 9 is 9 it is -* not 1 less or 1 more than what you want. It is *exact*. -*/ - -//void ILI9341_due_gText::ScrollUp(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, -// uint8_t pixels, uint8_t color) -//{ -//uint8_t dy; -//uint8_t dbyte; -//uint8_t sy; -//uint8_t sbyte; -//uint8_t col; -// -// /* -// * Scrolling up more than area height? -// */ -// if(y1 + pixels > y2) -// { -// /* -// * fill the region with "whitespace" because -// * it is being totally scrolled out. -// */ -// _ili->fillRect(x1, y1, x2 - x1, y2 - y1, color); -// return; -// } -// -// for(col = x1; col <= x2; col++) -// { -// dy = y1; -// GotoXY(col, dy & ~7); -// dbyte = glcd_Device::ReadData(); -// -// -// /* -// * preserve bits outside/above scroll region -// */ -// -// dbyte &= (_BV((dy & 7)) - 1); -// -// sy = dy + pixels; -// glcd_Device::GotoXY(col, sy & ~7); -// sbyte = glcd_Device::ReadData(); -// -// while(sy <= y2) -// { -// if(sbyte & _BV(sy & 7)) -// { -// dbyte |= _BV(dy & 7); -// } -// -// sy++; -// if((sy & 7) == 0) -// { -// /* -// * If we just crossed over, then we should be done. -// */ -// if(sy < DISPLAY_HEIGHT) -// { -// glcd_Device::GotoXY(col, sy & ~7); -// sbyte = glcd_Device::ReadData(); -// } -// } -// -// if((dy & 7) == 7) -// { -// glcd_Device::GotoXY(col, dy & ~7); // Should be able to remove this -// glcd_Device::WriteData(dbyte); -// dbyte = 0; -// } -// dy++; -// } -// -// /* -// * Handle the new area at the bottom of the region -// */ -// -// for(uint8_t p = pixels; p; p--) -// { -// if(color == BLACK) -// { -// dbyte |= _BV(dy & 7); -// } -// else -// { -// dbyte &= ~_BV(dy & 7); -// } -// -// if((dy & 7) == 7) -// { -// glcd_Device::GotoXY(col, dy & ~7); // should be able to remove this. -// glcd_Device::WriteData(dbyte); -// dbyte = 0; -// } -// dy++; -// } -// -// /* -// * Flush out the final destination byte -// */ -// -// -// if(dy & 7) -// { -// dy--; -// -// glcd_Device::GotoXY(col, dy & ~7); -// sbyte = glcd_Device::ReadData(); -// /* -// * Preserver bits outside/below region -// */ -// -// dy++; -// sbyte &= ~(_BV((dy & 7)) - 1); -// dbyte |= sbyte; -// -// glcd_Device::WriteData(dbyte); -// } -// } -// -//} - -//#ifndef GLCD_NO_SCROLLDOWN -// -//void ILI9341_due_gText::ScrollDown(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, -// uint8_t pixels, uint8_t color) -//{ -//uint8_t dy; -//uint8_t dbyte; -//uint8_t sy; -//uint8_t sbyte; -//uint8_t col; -// -// /* -// * Scrolling up more than area height? -// */ -// if(y1 + pixels > y2) -// { -// /* -// * fill the region with "whitespace" because -// * it is being totally scrolled out. -// */ -// glcd_Device::SetPixels(x1, y1, x2, y2, color); -// return; -// } -// -// /* -// * Process region from left to right -// */ -// for(col = x1; col <= x2; col++) -// { -// dy = y2; -// glcd_Device::GotoXY(col, dy & ~7); -// dbyte = glcd_Device::ReadData(); -// -// /* -// * preserve bits outside/below scroll region -// */ -// -// dbyte &= ~(_BV(((dy & 7)+1)) - 1); -// sy = dy - pixels; -// glcd_Device::GotoXY(col, sy & ~7); -// sbyte = glcd_Device::ReadData(); -// -// while(sy >= y1) -// { -// if(sbyte & _BV(sy & 7)) -// { -// dbyte |= _BV(dy & 7); -// } -// if((dy & 7) == 0) -// { -// glcd_Device::GotoXY(col, dy & ~7); // Should be able to remove this -// glcd_Device::WriteData(dbyte); -// dbyte = 0; -// } -// dy--; -// -// if(!sy) -// break; /* if we bottomed out, we are done */ -// sy--; -// if((sy & 7) == 7) -// { -// glcd_Device::GotoXY(col, sy & ~7); -// sbyte = glcd_Device::ReadData(); -// } -// -// } -// -// /* -// * Handle the new area at the top of the column -// */ -// -// for(uint8_t p = pixels; p; p--) -// { -// if(color == BLACK) -// { -// dbyte |= _BV(dy & 7); -// } -// else -// { -// dbyte &= ~_BV(dy & 7); -// } -// -// if((dy & 7) == 0) -// { -// glcd_Device::GotoXY(col, dy & ~7); // should be able to remove this. -// glcd_Device::WriteData(dbyte); -// dbyte = 0; -// } -// dy--; -// } -// -// dy++; /* point dy back to last destination row */ -// -// /* -// * Flush out the final destination byte -// */ -// -// if(dy & 7) -// { -// glcd_Device::GotoXY(col, dy & ~7); -// sbyte = glcd_Device::ReadData(); -// /* -// * Preserve bits outside/above region -// */ -// -// sbyte &= (_BV((dy & 7)) - 1); -// dbyte |= sbyte; -// glcd_Device::WriteData(dbyte); -// } -// -// } -// -//} -//#endif //GLCD_NO_SCROLLDOWN - - - - - -/* -* Handle all special processing characters -*/ -void ILI9341_due_gText::specialChar(uint8_t c) -{ - - - if(c == '\n') - { - uint8_t height = fontHeight(); - - /* - * Erase all pixels remaining to edge of text area.on all wraps - * It looks better when using inverted (WHITE) text, on proportional fonts, and - * doing WHITE scroll fills. - * - */ - - - if(_x < _area.x2) - _ili->fillRect(_x, _y, _area.x2 - _x, height, _fontBgColor); - //glcd_Device::SetPixels(_x, _y, _area.x2, _y+height, _fontColor == BLACK ? WHITE : BLACK); - - /* - * Check for scroll up vs scroll down (scrollup is normal) - */ -#ifndef GLCD_NO_SCROLLDOWN - if(_area.mode == SCROLL_UP) -#endif - { - - /* - * Normal/up scroll - */ - - /* - * Note this comparison and the pixel calcuation below takes into - * consideration that fonts - * are atually 1 pixel taller when rendered. - * This extra pixel is along the bottom for a "gap" between the character below. - */ - if(_y + 2*height >= _area.y2) - { -#ifndef GLCD_NODEFER_SCROLL - if(!_needScroll) - { - _needScroll = 1; - return; - } -#endif - - /* - * forumula for pixels to scroll is: - * (assumes "height" is one less than rendered height) - * - * pixels = height - ((_area.y2 - _y) - height) +1; - * - * The forumala below is unchanged - * But has been re-written/simplified in hopes of better code - * - */ - - uint8_t pixels = 2*height + _y - _area.y2 +1; - - /* - * Scroll everything to make room - * * NOTE: (FIXME, slight "bug") - * When less than the full character height of pixels is scrolled, - * There can be an issue with the newly created empty line. - * This is because only the # of pixels scrolled will be colored. - * What it means is that if the area starts off as white and the text - * color is also white, the newly created empty text line after a scroll - * operation will not be colored BLACK for the full height of the character. - * The only way to fix this would be alter the code use a "move pixels" - * rather than a scroll pixels, and then do a clear to end line immediately - * after the move and wrap. - * - * Currently this only shows up when - * there are are less than 2xheight pixels below the current Y coordinate to - * the bottom of the text area - * and the current background of the pixels below the current text line - * matches the text color - * and a wrap was just completed. - * - * After a full row of text is printed, the issue will resolve itself. - * - * - */ - //ScrollUp(_area.x1, _area.y1, _area.x2, _area.y2, pixels, _fontBgColor); - - _x = _area.x1; - _y = _area.y2 - height; - } - else - { - /* - * Room for simple wrap - */ - - _x = _area.x1; - _y = _y+height+1; - } - } -#ifndef GLCD_NO_SCROLLDOWN - else - { - /* - * Reverse/Down scroll - */ - - /* - * Check for Wrap vs scroll. - * - * Note this comparison and the pixel calcuation below takes into - * consideration that fonts - * are atually 1 pixel taller when rendered. - * - */ - if(_y > _area.y1 + height) - { - /* - * There is room so just do a simple wrap - */ - _x = _area.x1; - _y = _y - (height+1); - } - else - { -#ifndef GLCD_NODEFER_SCROLL - if(!_needScroll) - { - _needScroll = 1; - return; - } -#endif - - /* - * Scroll down everything to make room for new line - * (assumes "height" is one less than rendered height) - */ - - uint8_t pixels = height+1 - (_area.y1 - _y); - - //ScrollDown(_area.x1, _area.y1, _area.x2, _area.y2, pixels, _fontBgColor); - - _x = _area.x1; - _y = _area.y1; - } - } -#endif - } - -} - -/** -* output a character -* -* @param c the character to output -* -* If the character will not fit on the current text line -* inside the text area, -* the text position is wrapped to the next line. This might be -* the next lower or the next higher line depending on the -* scroll direction. -* -* If there is not enough room to fit a full line of new text after -* wrapping, the entire text area will be scrolled to make room for a new -* line of text. The scroll direction will be up or down -* depending on the scroll direction for the text area. -*/ - -int ILI9341_due_gText::putChar(uint8_t c) -{ - if(_font == 0) - { - Serial.println(F("No font selected")); - return 0; // no font selected - } - - /* - * check for special character processing - */ - - if(c < 0x20) - { - //specialChar(c); - return 1; - } - uint16_t charWidth = 0; - uint16_t charHeight = fontHeight(); - uint8_t charHeightInBytes = (charHeight+7)/8; /* calculates height in rounded up bytes */ - - uint8_t firstChar = pgm_read_byte(_font+GTEXT_FONT_FIRST_CHAR); - uint8_t charCount = pgm_read_byte(_font+GTEXT_FONT_CHAR_COUNT); - - uint16_t index = 0; - uint8_t thielefont; - - if(c < firstChar || c >= (firstChar+charCount)) { - return 0; // invalid char - } - c-= firstChar; - - if( isFixedWidthFont(_font) { - thielefont = 0; - charWidth = pgm_read_byte(_font+GTEXT_FONT_FIXED_WIDTH); - index = c*charHeightInBytes*charWidth+GTEXT_FONT_WIDTH_TABLE; - } - else{ - // variable width font, read width data, to get the index - thielefont = 1; - /* - * Because there is no table for the offset of where the data - * for each character glyph starts, run the table and add up all the - * widths of all the characters prior to the character we - * need to locate. - */ - for(uint8_t i=0; i _area.x2) - { - putChar('\n'); // fake a newline to cause wrap/scroll -#ifndef GLCD_NODEFER_SCROLL - /* - * We can't defer a scroll at this point since we need to ouput - * a character right now. - */ - if(_needScroll) - { - putChar('\n'); // fake a newline to cause wrap/scroll - _needScroll = 0; - } -#endif - } - - if(_fontMode == gTextFontMode_Solid) - drawSolidChar(c, index, charWidth, charHeight); - else if(_fontMode == gTextFontMode_Transparent) - drawTransparentChar(c, index, charWidth, charHeight); - - // last but not least, draw the character - - //glcd_Device::GotoXY(_x, _y); - - - /* - * Draw each column of the glyph (character) horizontally - * 8 bits (1 page) at a time. - * i.e. if a font is taller than 8 bits, draw upper 8 bits first, - * Then drop down and draw next 8 bits and so on, until done. - * This code depends on WriteData() doing writes that span LCD - * memory pages, which has issues because the font data isn't - * always a multiple of 8 bits. - */ - - - return 1; // valid char -} - -void ILI9341_due_gText::drawSolidChar(char c, uint16_t index, uint16_t charWidth, uint16_t charHeight) -{ - uint8_t bitId=0; - int16_t cx = _x; - int16_t cy = _y; -#if SPI_MODE_DMA - uint8_t* scanlineBuff = _ili->_scanlineBuffer; - uint8_t fontColorHi = highByte(_fontColor); - uint8_t fontColorLo = lowByte(_fontColor); - uint8_t fontBgColorHi = highByte(_fontBgColor); - uint8_t fontBgColorLo = lowByte(_fontBgColor); -#endif - uint8_t charHeightInBytes = (charHeight+7)/8; /* calculates height in rounded up bytes */ - - uint16_t lineId=0; - uint8_t numRenderBits = 8; - const uint8_t numRemainingBits = charHeight % 8; - //_ili->enableCS(); - for(uint16_t j=0; jsetAddrAndRW_cont(cx, cy, cx, cy+charHeight -1); - //_ili->setDCForData(); - for(uint8_t i=0; i 8 && charHeight < (i+1)*8) /* is it last byte of multibyte tall font? */ - { - data >>= ((i+1) << 3) - charHeight; // (i+1)*8 - } - //Serial << "data:" <writedata16_cont(_fontBgColor); -#elif SPI_MODE_DMA - scanlineBuff[lineId++] = fontBgColorHi; - scanlineBuff[lineId++] = fontBgColorLo; -#endif - } - else - { -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - _ili->writedata16_cont(_fontColor); -#elif SPI_MODE_DMA - scanlineBuff[lineId++] = fontColorHi; - scanlineBuff[lineId++] = fontColorLo; -#endif - } - data>>=1; - } - //delay(50); - } - //Serial << endl; - cx++; -#if SPI_MODE_DMA - _ili->writeScanline_cont(charHeight); // height in px * 2 bytes per px -#endif - - } - _ili->disableCS(); // to put CS line back up - - _x += charWidth; - - //Serial << " ending at " << _x << " lastChar " << _lastChar < 0 && !_isLastChar) - { - _ili->fillRect(_x, _y, _letterSpacing, charHeight, _fontBgColor); - _x+=_letterSpacing; - } - //Serial << "letterSpacing " << _letterSpacing <<" x: " << _x <fillScanline(_fontColor); //pre-fill the scanline, we will be drawing different lenghts of it -#endif - - uint8_t charHeightInBytes = (charHeight+7)/8; /* calculates height in rounded up bytes */ - - uint16_t lineId=0; - uint8_t numRenderBits = 8; - const uint8_t numRemainingBits = charHeight % 8; - - _ili->enableCS(); - - for(uint8_t j=0; j 8 && charHeight < (i+1)*8) /* is it last byte of multibyte tall font? */ - { - data >>= ((i+1) << 3) - charHeight; // (i+1)*8 - } - //Serial << "data:" <setAddrAndRW_cont(cx, cy+lineStart, cx, cy+lineEnd); - -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - _ili->setDCForData(); - for(int p=0; pwrite16_cont(_fontColor); - } -#elif SPI_MODE_DMA - _ili->writeScanline_cont(lineEnd-lineStart+1); -#endif - } - lastBit = bit; - } - else if(bit ^ 0x00) // increment only if bit is 1 - { - lineEnd++; - } - - data>>=1; - } - - if(lineEnd == charHeight - 1) // we have a line that goes all the way to the bottom - { - _ili->setAddrAndRW_cont(cx, cy+lineStart, cx, cy+lineEnd); -#if SPI_MODE_NORMAL | SPI_MODE_EXTENDED - _ili->setDCForData(); - for(int p=0; pwrite16_cont(_fontColor); - } -#elif SPI_MODE_DMA - _ili->writeScanline_cont(lineEnd-lineStart+1); -#endif - } - //delay(25); - } - //Serial << endl; - cx++; - } - _ili->disableCS(); // to put CS line back up - - _x += charWidth; - - if(_letterSpacing > 0 && !_isLastChar) - { - _x+=_letterSpacing; - } -} - -/** -* output a character string -* -* @param str pointer to a null terminated character string. -* -* Outputs all the characters in the string to the text area. -* See putChar() for a full description of how characters are -* written to the text area. -*/ - -void ILI9341_due_gText::puts(char *str) -{ - while(*str) - { - if(*(str+1) == 0) - _isLastChar = true; - putChar((uint8_t)*str); - str++; - } - _isLastChar = false; -} - -/** -* output a String class string -* -* @param str String class string -* -* Outputs all the characters in the string to the text area. -* See putChar() for a full description of how characters are -* written to the text area. -* -*/ -void ILI9341_due_gText::puts(const String &str) -{ - for (int i = 0; i < str.length(); i++) - { - write(str[i]); - } -} - -/** -* output a program memory character string -* -* @param str pointer to a null terminated character string stored in program memory -* -* Outputs all the characters in the string to the text area. -* See putChar() for a full description of how characters are -* written to the text area. -* -* @see putChar() -* @see puts() -* @see drawString() -* @see drawString_P() -* @see write() -*/ - -void ILI9341_due_gText::puts_P(PGM_P str) -{ - uint8_t c; - - while((c = pgm_read_byte(str)) != 0) - { - putChar(c); - str++; - } -} - -/** -* output a String class string at x,y coordinate -* -* @param str pointer to a null terminated character string -* @param x specifies the horizontal location -* @param y specifies the vertical location -* -* -* Outputs all the characters in the string to the text area. -* X & Y are zero based pixel coordinates and are relative to -* the upper left corner of the text area. -* -* See putChar() for a full description of how characters are -* written to the text area. -*/ -void ILI9341_due_gText::drawString(String &str, int16_t x, int16_t y) -{ - cursorToXY(x,y); - puts(str); -} - -/** -* output a program memory character string at x,y coordinate -* -* @param str pointer to a null terminated character string stored in program memory -* @param x specifies the horizontal location -* @param y specifies the vertical location -* -* -* Outputs all the characters in the string to the text area. -* X & Y are zero based pixel coordinates and are relative to -* the upper left corner of the text area. -* -* See putChar() for a full description of how characters are -* written to the text area. -*/ - -void ILI9341_due_gText::drawString_P(PGM_P str, int16_t x, int16_t y) -{ - cursorToXY(x,y); - puts_P(str); -} - -/** -* output a character string at x,y coordinate -* -* @param str String class string -* @param x specifies the horizontal location -* @param y specifies the vertical location -* -* -* Outputs all the characters in the string to the text area. -* X & Y are zero based pixel coordinates and are relative to -* the upper left corner of the text area. -* -* See putChar() for a full description of how characters are -* written to the text area. -*/ - -void ILI9341_due_gText::drawString(char *str, int16_t x, int16_t y) -{ - cursorToXY(x,y); - puts(str); -} - -void ILI9341_due_gText::drawString(char *str, int16_t x, int16_t y, uint16_t pixelsClearedOnLeft, uint16_t pixelsClearedOnRight) -{ - cursorToXY(x,y); - - // CLEAR PIXELS ON THE LEFT - if(pixelsClearedOnLeft > 0) - _ili->fillRect(_x-pixelsClearedOnLeft, _y, pixelsClearedOnLeft, fontHeight(), _fontBgColor); - - puts(str); - - // CLEAR PIXELS ON THE RIGHT - if(pixelsClearedOnRight > 0) - _ili->fillRect(_x, _y, pixelsClearedOnRight, fontHeight(), _fontBgColor); -} - -void ILI9341_due_gText::drawString(char *str, int16_t x, int16_t y, gTextEraseLine eraseLine) -{ - cursorToXY(x,y); - - // CLEAR PIXELS ON THE LEFT - if(eraseLine == gTextEraseFromBOL || eraseLine == gTextEraseFullLine) - { - uint16_t clearX1 = max(min(_x, _area.x1), _x-1024); - _ili->fillRect(clearX1, _y, _x - clearX1, fontHeight(), _fontBgColor); - } - - puts(str); - - // CLEAR PIXELS ON THE RIGHT - if(eraseLine == gTextEraseToEOL || eraseLine == gTextEraseFullLine) - { - uint16_t clearX2 = min(max(_x,_area.x2), _x+1024); - _ili->fillRect(_x, _y, clearX2 - _x, fontHeight(), _fontBgColor); - } -} - -void ILI9341_due_gText::drawString(char *str, gTextAlign align) -{ - drawStringPivotedOffseted(str, align, gTextPivotDefault, 0, 0, 0, 0); -} - -void ILI9341_due_gText::drawString(char *str, gTextAlign align, gTextEraseLine eraseLine) -{ - uint16_t pixelsClearedOnLeft = 0; - uint16_t pixelsClearedOnRight = 0; - if(eraseLine == gTextEraseFromBOL || eraseLine == gTextEraseFullLine) - pixelsClearedOnLeft = 1024; - if(eraseLine == gTextEraseToEOL || eraseLine == gTextEraseFullLine) - pixelsClearedOnRight = 1024; - drawStringPivotedOffseted(str, align, gTextPivotDefault, 0, 0, pixelsClearedOnLeft, pixelsClearedOnRight); -} - -void ILI9341_due_gText::drawString(char *str, gTextAlign align, uint16_t pixelsClearedOnLeft, uint16_t pixelsClearedOnRight) -{ - drawStringPivotedOffseted(str, align, gTextPivotDefault, 0, 0, pixelsClearedOnLeft, pixelsClearedOnRight); -} - -void ILI9341_due_gText::drawStringOffseted(char *str, gTextAlign align, uint16_t offsetX, uint16_t offsetY) -{ - drawStringPivotedOffseted(str, align, gTextPivotDefault,offsetX, offsetY, 0, 0); -} - -void ILI9341_due_gText::drawStringOffseted(char *str, gTextAlign align, uint16_t offsetX, uint16_t offsetY, gTextEraseLine eraseLine) -{ - uint16_t pixelsClearedOnLeft = 0; - uint16_t pixelsClearedOnRight = 0; - if(eraseLine == gTextEraseFromBOL || eraseLine == gTextEraseFullLine) - pixelsClearedOnLeft = 1024; - if(eraseLine == gTextEraseToEOL || eraseLine == gTextEraseFullLine) - pixelsClearedOnRight = 1024; - drawStringPivotedOffseted(str, align, gTextPivotDefault,offsetX, offsetY, pixelsClearedOnLeft, pixelsClearedOnRight); -} - -void ILI9341_due_gText::drawStringOffseted(char *str, gTextAlign align, uint16_t offsetX, uint16_t offsetY, uint16_t pixelsClearedOnLeft, uint16_t pixelsClearedOnRight) -{ - drawStringPivotedOffseted(str, align, gTextPivotDefault,offsetX, offsetY, pixelsClearedOnLeft, pixelsClearedOnRight); -} - -void ILI9341_due_gText::drawStringPivoted(char *str, int16_t x, int16_t y, gTextPivot pivot) -{ - cursorToXY(x,y); - - if(pivot != gTextPivotTopLeft && pivot != gTextPivotDefault) - applyPivot(str, pivot); - - puts(str); -} - -void ILI9341_due_gText::drawStringPivoted(char *str, gTextAlign align, gTextPivot pivot) -{ - drawStringPivotedOffseted(str, align, pivot, 0, 0, 0, 0); -} - -void ILI9341_due_gText::drawStringPivoted(char *str, gTextAlign align, gTextPivot pivot, gTextEraseLine eraseLine) -{ - uint16_t pixelsClearedOnLeft = 0; - uint16_t pixelsClearedOnRight = 0; - if(eraseLine == gTextEraseFromBOL || eraseLine == gTextEraseFullLine) - pixelsClearedOnLeft = 1024; - if(eraseLine == gTextEraseToEOL || eraseLine == gTextEraseFullLine) - pixelsClearedOnRight = 1024; - drawStringPivotedOffseted(str, align, pivot, 0, 0, pixelsClearedOnLeft, pixelsClearedOnRight); -} - -void ILI9341_due_gText::drawStringPivoted(char *str, gTextAlign align, gTextPivot pivot, uint16_t pixelsClearedOnLeft, uint16_t pixelsClearedOnRight) -{ - drawStringPivotedOffseted(str, align, pivot, 0, 0, pixelsClearedOnLeft, pixelsClearedOnRight); -} - -void ILI9341_due_gText::drawStringPivotedOffseted(char *str, gTextAlign align, gTextPivot pivot, uint16_t offsetX, uint16_t offsetY) -{ - drawStringPivotedOffseted(str, align, pivot, offsetX, offsetY, 0, 0); -} - -void ILI9341_due_gText::drawStringPivotedOffseted(char *str, gTextAlign align, gTextPivot pivot, uint16_t offsetX, uint16_t offsetY, gTextEraseLine eraseLine) -{ - uint16_t pixelsClearedOnLeft = 0; - uint16_t pixelsClearedOnRight = 0; - if(eraseLine == gTextEraseFromBOL || eraseLine == gTextEraseFullLine) - pixelsClearedOnLeft = 1024; - if(eraseLine == gTextEraseToEOL || eraseLine == gTextEraseFullLine) - pixelsClearedOnRight = 1024; - drawStringPivotedOffseted(str, align, pivot, offsetX, offsetY, pixelsClearedOnLeft, pixelsClearedOnRight); -} - -void ILI9341_due_gText::drawStringPivotedOffseted(char *str, gTextAlign align, gTextPivot pivot, uint16_t offsetX, uint16_t offsetY, uint16_t pixelsClearedOnLeft, uint16_t pixelsClearedOnRight) -{ - //Serial << pixelsClearedOnLeft << " " << pixelsClearedOnRight << endl; - _x = _area.x1; - _y = _area.y1; - - //PIVOT - if(pivot == gTextPivotDefault) - { - switch(align) - { - case gTextAlignTopLeft: { pivot = gTextPivotTopLeft; break; } - case gTextAlignTopCenter: { pivot = gTextPivotTopCenter; break; } - case gTextAlignTopRight: { pivot = gTextPivotTopRight; break; } - case gTextAlignMiddleLeft: { pivot = gTextPivotMiddleLeft; break; } - case gTextAlignMiddleCenter: { pivot = gTextPivotMiddleCenter; break; } - case gTextAlignMiddleRight: { pivot = gTextPivotMiddleRight; break; } - case gTextAlignBottomLeft: { pivot = gTextPivotBottomLeft; break; } - case gTextAlignBottomCenter: { pivot = gTextPivotBottomCenter; break; } - case gTextAlignBottomRight: { pivot = gTextPivotBottomRight; break; } - } - } - - if(pivot != gTextPivotTopLeft) - applyPivot(str, pivot); - - // ALIGN - if(align != gTextAlignTopLeft) - { - switch(align) - { - case gTextAlignTopCenter: - { - _x += (_area.x2 - _area.x1)/2; - break; - } - case gTextAlignTopRight: - { - _x += _area.x2 - _area.x1; - break; - } - case gTextAlignMiddleLeft: - { - _y += (_area.y2-_area.y1)/2; - break; - } - case gTextAlignMiddleCenter: - { - _x += (_area.x2 - _area.x1)/2; - _y += (_area.y2 - _area.y1)/2; - break; - } - case gTextAlignMiddleRight: - { - _x += _area.x2 - _area.x1; - _y += (_area.y2 - _area.y1)/2; - break; - } - case gTextAlignBottomLeft: - { - _y += _area.y2 - _area.y1; - break; - } - case gTextAlignBottomCenter: - { - _x += (_area.x2 - _area.x1)/2; - _y += _area.y2 - _area.y1; - break; - } - case gTextAlignBottomRight: - { - _x += _area.x2 - _area.x1; - _y += _area.y2 - _area.y1; - break; - } - } - } - - // OFFSET - _x+=offsetX; - _y+=offsetY; - - // CLEAR PIXELS ON THE LEFT - if(pixelsClearedOnLeft > 0) - { - int16_t clearX1 = max(min(_x, (int16_t)_area.x1), _x-(int16_t)pixelsClearedOnLeft); - //Serial.println(clearX1); - _ili->fillRect(clearX1, _y, _x - clearX1, fontHeight(), _fontBgColor); - } - - puts(str); - - // CLEAR PIXELS ON THE RIGHT - if(pixelsClearedOnRight > 0) - { - int16_t clearX2 = min(max(_x, _area.x2), _x+pixelsClearedOnRight); - //Serial << "area from " << _area.x1 << " to " << _area.x2 << endl; - //Serial << "clearing on right from " << _x << " to " << clearX2 << endl; - _ili->fillRect(_x, _y, clearX2 - _x, fontHeight(), _fontBgColor); - } -} - -void ILI9341_due_gText::applyPivot(char *str, gTextPivot pivot) -{ - switch(pivot) - { - case gTextPivotTopCenter: - { - _x -= stringWidth(str)/2; - break; - } - case gTextPivotTopRight: - { - _x -= stringWidth(str); - break; - } - case gTextPivotMiddleLeft: - { - _y -= fontHeight()/2; - break; - } - case gTextPivotMiddleCenter: - { - _x -= stringWidth(str)/2; - _y -= fontHeight()/2; - break; - } - case gTextPivotMiddleRight: - { - _x -= stringWidth(str); - _y -= fontHeight()/2; - break; - } - case gTextPivotBottomLeft: - { - _y -= fontHeight(); - break; - } - case gTextPivotBottomCenter: - { - _x -= stringWidth(str)/2; - _y -= fontHeight(); - break; - } - case gTextPivotBottomRight: - { - _x -= stringWidth(str); - _y -= fontHeight(); - break; - } - } -} - -/** -* Positions cursor to a character based column and row. -* -* @param column specifies the horizontal position -* @param row specifies the vertical position -* -* Column and Row are zero based character positions -* and are relative the the upper left corner of the -* text area base on the size of the currently selected font. -* -* While intended for fixed width fonts, positioning will work for variable -* width fonts. -* -* When variable width fonts are used, the column is based on assuming a width -* of the widest character. -* -* @see cursorToXY() -*/ - -void ILI9341_due_gText::cursorTo( uint8_t column, uint8_t row) -{ - if(_font == 0) - return; // no font selected - - /* - * Text position is relative to current text area - */ - - _x = column * (pgm_read_byte(_font+GTEXT_FONT_FIXED_WIDTH)+1) + _area.x1; - _y = row * (fontHeight()+1) + _area.y1; - -#ifndef GLCD_NODEFER_SCROLL - /* - * Make sure to clear a deferred scroll operation when repositioning - */ - _needScroll = 0; -#endif -} - -// Bill, I think the following would be a useful addition to the API -// Should we add a sanity check to these? -/** -* Positions cursor to a character based column on the current row. -* -* @param column specifies the horizontal position -* -* Column is a 0 based character position -* based on the size of the currently selected font. -* -* If column is negative then the column position is relative to the current cursor -* position. -* -* @warning -* While intended only for fixed width fonts, cursor repositioning will be done for variable -* width fonts. -* When variable width fonts are used, the column is based on assuming a width -* of the widest character in the font. -* Because the widest character is used for the amount of cursor movement, the amount -* of cursor movement when using relative positioning will often not be consistent with -* the number characters previously rendered. For example, if a letter "l" was written -* and the cursor was reposisitioned with a -1, the amount backed up will be much larger -* than the width of the "l". -* -* -* @see cursorToXY() -*/ -void ILI9341_due_gText::cursorTo(int8_t column) -{ - if(_font == 0) - return; // no font selected - /* - * Text position is relative to current text area - * negative value moves the cursor backwards - */ - if(column >= 0) - _x = column * (pgm_read_byte(_font+GTEXT_FONT_FIXED_WIDTH)+1) + _area.x1; - else - _x -= column * (pgm_read_byte(_font+GTEXT_FONT_FIXED_WIDTH)+1); - -#ifndef GLCD_NODEFER_SCROLL - /* - * Make sure to clear a deferred scroll operation when repositioning - */ - _needScroll = 0; -#endif -} - - -/** -* Positions cursor to a X,Y position -* -* @param x specifies the horizontal location -* @param y specifies the vertical location -* -* X & Y are zero based pixel coordinates and are relative to -* the upper left corner of the text area. -* -* @see cursorTo() -*/ - -void ILI9341_due_gText::cursorToXY( int16_t x, int16_t y) -{ - - /* - * Text position is relative to current text area - */ - - _x = _area.x1 + x; - _y = _area.y1 + y; - //Serial << F("cursorToXY x:") << x << F(" y:") << y << endl; - -#ifndef GLCD_NODEFER_SCROLL - /* - * Make sure to clear a deferred scroll operation when repositioning - */ - _needScroll = 0; -#endif -} - -/** -* Erase in Line -* -* @param type type of line erase -* -* @arg \ref eraseTO_EOL Erase from cursor to end of line -* @arg \ref eraseFROM_BOL Erase from beginning of line to cursor -* @arg \ref eraseFULL_LINE Erase entire line -* -* Erases all or part of a line of text depending on the type -* of erase specified. -* -* If type is not specified it is assumed to be \ref eraseTO_EOL -* -* The cursor position does not change. -* -* @see ClearArea() -* @see eraseLine_t -*/ - -void ILI9341_due_gText::eraseTextLine(uint16_t color, gTextEraseLine type) -{ - int16_t x = _x; - int16_t y = _y; - int16_t height = fontHeight(); - //uint8_t color = (_fontColor == BLACK) ? WHITE : BLACK; - - switch(type) - { - case gTextEraseToEOL: - _ili->fillRect(x, y, _area.x2-x, height, color); - //glcd_Device::SetPixels(x, y, _area.x2, y+height, color); - break; - case gTextEraseFromBOL: - _ili->fillRect(_area.x1, y, x - _area.x1, height, color); - //glcd_Device::SetPixels(_area.x1, y, x, y+height, color); - break; - case gTextEraseFullLine: - _ili->fillRect(_area.x1, y, _area.x2 - _area.x1, height, color); - //glcd_Device::SetPixels(_area.x1, y, _area.x2, y+height, color); - break; - } - - /* - * restore cursor position - */ - cursorToXY(x,y); -} - -/** -* Erase Text Line -* -* @param row row # of text to earase -* -* Erases a line of text and moves the cursor -* to the begining of the line. Rows are zero based so -* the top line/row of a text area is 0. -* -* @see ClearArea() -*/ - -void ILI9341_due_gText::eraseTextLine(uint16_t color, uint8_t row) -{ - cursorTo(0, row); - eraseTextLine(color, gTextEraseToEOL); -} - - -/** -* Select a Font and font color -* -* @param font a font definition -* @param color can be WHITE or BLACK and defaults to black -* @param callback optional font read routine -* -* -* Selects the font definition as the current font for the text area. -* -* All subsequent printing functions will use this font. -* -* Font definitions from included font definition files are stored in program memory -* You can have as many fonts defines as will fit in program memory up to 64k and can -* switch between them with this function. -* -* If the optional callback argument is ommitted, a default routine -* is selected that assumes that the font is in program memory (flash). -* -* @note -* When the display is initilized in normal mode, BLACK renders dark -* pixels on a white background and WHITE renders white pixels on -* black background; however, if the display is set to INVERTED mode -* all colors are inverted. -* -* @see setFontColor() -* @see SetTextMode() -*/ - -void ILI9341_due_gText::selectFont(gTextFont font) -{ - _font = font; -} - -void ILI9341_due_gText::selectFont(gTextFont font, uint16_t fontColor) -{ - _font = font; - _fontColor = fontColor; -} - -void ILI9341_due_gText::selectFont(gTextFont font, uint16_t fontColor, uint16_t backgroundColor) -{ - _font = font; - _fontColor = fontColor; - _fontBgColor = backgroundColor; -} - -/** -* Select a font color -* -* @param color can be WHITE or BLACK -* -* -* @see selectFont() -* @see SetTextMode() -*/ - -void ILI9341_due_gText::setFontColor(uint16_t color) -{ - _fontColor = color; -} - -void ILI9341_due_gText::setFontColor(uint8_t R, uint8_t G, uint8_t B) -{ - _fontColor = _ili->color565(R,G,B); -} - -void ILI9341_due_gText::setFontColor(uint16_t color, uint16_t backgroundColor) -{ - _fontColor = color; - _fontBgColor = backgroundColor; -} - -void ILI9341_due_gText::setFontColor(uint8_t R, uint8_t G, uint8_t B, uint8_t bgR, uint8_t bgG, uint8_t bgB) -{ - _fontColor = _ili->color565(R,G,B); - _fontBgColor = _ili->color565(bgR,bgG,bgB); -} - - -void ILI9341_due_gText::setFontLetterSpacing(uint8_t letterSpacing) -{ - _letterSpacing = letterSpacing; -} - - -void ILI9341_due_gText::setFontMode(gTextFontMode fontMode) -{ - if(fontMode == gTextFontMode_Solid || fontMode == gTextFontMode_Transparent) - _fontMode = fontMode; -} - -/** -* Set TextArea mode -* -* @param mode text area mode -* -* Currently mode is a scroll direction -* @arg SCROLL_UP -* @arg SCROLL_DOWN -* -* @see selectFont() -* @see setFontColor() -* @see defineArea() -*/ -/* -*/ -#if INLCUDE_NOT_WORKING_YET -void ILI9341_due_gText::SetTextMode(textMode mode) -{ - - /* - * when other modes are added the tarea.mode variable will hold a bitmask or enum for the modde and should be renamed - */ - _area.mode = mode; -} -#endif - - - - -/** -* Returns the pixel width of a character -* -* @param c character to be sized -* -* @return The width in pixels of the given character -* including any inter-character gap pixels following the character when the character is -* rendered on the display. -* -* @note The font for the character is the most recently selected font. -* -* @see StringWidth() -* @see StringWidth_P() -*/ - -uint16_t ILI9341_due_gText::charWidth(uint8_t c) -{ - int16_t width = 0; - - if(isFixedWidthFont(_font){ - width = pgm_read_byte(_font+GTEXT_FONT_FIXED_WIDTH); - } - else{ - // variable width font - uint8_t firstChar = pgm_read_byte(_font+GTEXT_FONT_FIRST_CHAR); - uint8_t charCount = pgm_read_byte(_font+GTEXT_FONT_CHAR_COUNT); - - // read width data - if(c >= firstChar && c < (firstChar+charCount)) { - c -= firstChar; - width = pgm_read_byte(_font+GTEXT_FONT_WIDTH_TABLE+c); - //Serial << "strWidth of " << c << " : " << width << endl; - } - } - return width; -} - -/** -* Returns the pixel width of a string -* -* @param str pointer to string stored in RAM -* -* @return the width in pixels of the sum of all the characters in the -* the string pointed to by str. -* -* @see charWidth() -* @see StringWidth_P() -*/ - -uint16_t ILI9341_due_gText::stringWidth(const char* str) -{ - uint16_t width = 0; - - while(*str != 0) { - width += charWidth(*str++) + _letterSpacing; - } - if(width > 0) - width -= _letterSpacing; - return width; -} - -/** -* Returns the pixel width of a character -* -* @param str pointer to string stored in program memory -* -* @return the width in pixels of the sum of all the characters in the -* the string pointed to by str. -* -* @see charWidth() -* @see StringWidth() -*/ - -uint16_t ILI9341_due_gText::stringWidth_P(PGM_P str) -{ - uint16_t width = 0; - - while(pgm_read_byte(str) != 0) { - width += charWidth(pgm_read_byte(str++)) + _letterSpacing; - } - width -= _letterSpacing; - return width; -} - -/** -* Returns the pixel width of a character -* -* @param str String class string -* -* @return the width in pixels of the sum of all the characters in the -* the string pointed to by str. -* -* @see charWidth() -* @see StringWidth() -*/ - -uint16_t ILI9341_due_gText::stringWidth_P(String &str) -{ - uint16_t width = 0; - - for (int i = 0; i < str.length(); i++) - { - width += charWidth(str[i]) + _letterSpacing; - } - width -= _letterSpacing; - return width; -} - - -/** -* Legacy function to print a number -* -* @param n is the number to print -* -* -* @see print(n) -*/ -void ILI9341_due_gText::printNumber(long n) -{ - uint8_t buf[10]; // prints up to 10 digits - uint8_t i=0; - if(n==0) - putChar('0'); - else{ - if(n < 0){ - putChar('-'); - n = -n; - } - while(n>0 && i <= 10){ - buf[i++] = n % 10; // n % base - n /= 10; // n/= base - } - for(; i >0; i--) - putChar((char) (buf[i-1] < 10 ? '0' + buf[i-1] : 'A' + buf[i-1] - 10)); - } -} - -/** -* output a character to the text area -* @param c the character to output -* -* This method is needed for the Print base class -* @see putChar() -*/ - - -size_t ILI9341_due_gText::write(uint8_t c) -{ - return(putChar(c)); -} - -// -//#ifndef USE_ARDUINO_FLASHSTR -//// functions to store and print strings in Progmem -//// these should be removed when Arduino supports FLASH strings in the base print class -///** -//* print a flash based string -//* @param str pointer to a null terminated character string stored in program memory -//* -//* @see puts_P() -//*/ -//void ILI9341_due_gText::printFlash(FLASHSTRING str) -//{ -// puts_P((PGM_P) str); -//} -// -///** -//* print a flash based string -//* @param str pointer to a null terminated character string stored in program memory -//* -//* The string is output followed by a newline. -//* -//* @see puts_P() -//*/ -//void ILI9341_due_gText::printFlashln(FLASHSTRING str) -//{ -// printFlash(str); -// write('\n'); -//} -//#endif - - diff --git a/GD32F1/libraries/ILI9341_due_STM/ILI9341_due_gText.h b/GD32F1/libraries/ILI9341_due_STM/ILI9341_due_gText.h deleted file mode 100644 index 415d853..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/ILI9341_due_gText.h +++ /dev/null @@ -1,385 +0,0 @@ -/* -ILI9341_due_gText.cpp - Used for rendering GLCD fonts on Arduino Due - -Copyright (c) 2014 Marek Buriak - -The library is based on GLCD library by Bill Perry and Michael Margolis: -https://code.google.com/p/glcd-arduino - -This file is part of the Arduino ILI9341_due library. -Sources for this library can be found at https://github.com/marekburiak/ILI9341_Due. - -Fonts .h files can be created with GLCDFontCreator2 (not the one MikroElektronika): -https://code.google.com/p/glcd-arduino/downloads/detail?name=GLCDFontCreator2.zip&can=2&q= - - -ILI9341_due is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 of the License, or -(at your option) any later version. - -ILI9341_due is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with ILI9341_due. If not, see . - -*/ - -#ifndef ILI9341_GTEXT_H -#define ILI9341_GTEXT_H - -//#include "WString.h" -//#include "../Streaming/Streaming.h" -#include "ILI9341_due.h" - -#define INCLUDE_NOT_WORKING_YET 0 - -#define GTEXT_VERSION 1 // software version of this code - -// Font Indices -#define GTEXT_FONT_LENGTH 0 -#define GTEXT_FONT_FIXED_WIDTH 2 -#define GTEXT_FONT_HEIGHT 3 -#define GTEXT_FONT_FIRST_CHAR 4 -#define GTEXT_FONT_CHAR_COUNT 5 -#define GTEXT_FONT_WIDTH_TABLE 6 - -#define GTEXT_DRAW_DIRECTION_RIGHT 0 -#define GTEXT_DRAW_DIRECTION_DOWN 1 -#define GTEXT_DRAW_DIRECTION_LEFT 2 -#define GTEXT_DRAW_DIRECTION_UP 3 - -typedef enum { - gTextFontMode_Solid = 0, - gTextFontMode_Transparent = 1 -} gTextFontMode; - - -// the following returns true if the given font is fixed width -// zero length is flag indicating fixed width font (array does not contain width data entries) -#define isFixedWidthFont(font) (pgm_read_byte(font+GTEXT_FONT_LENGTH) == 0 && pgm_read_byte(font+GTEXT_FONT_LENGTH+1) == 0)) - -/* -* Coodinates for predefined areas are compressed into a single 32 bit token. -* -* This works as the coordinates are cuurenly only 8 bit values. -* -* This allows the creatation of an unlmited number of predefined areas with zero code or -* data space overhead. -* -* A macro is used to create the tokens from a set of x1,y1 x2,y2 coordinates. -* -* A union is used to extract the coordinates from the 32 bit token. -* -* WARNING: -* This is non portable code in that it will only work on little endian processors. -* If you use big endian you have to switch the byte ordering in the union. -*/ - -#define MK_TareaToken(x1, y1, x2, y2) \ - (uint32_t) (((uint32_t) (x1) << 24) | ((uint32_t)(y1) << 16) | ((uint32_t)(x2) << 8) | (uint32_t)(y2)) - -/// @cond hide_from_doxygen -typedef union -{ - struct - { - uint8_t y2; - uint8_t x2; - uint8_t y1; - uint8_t x1; - }coord; - - uint32_t token; // swap byte order above for big endian - -}TareaToken; -/// @endcond - -typedef uint8_t textMode; // type holding mode for scrolling and future attributes like padding etc. -// the only textMode supported in the current release is scrolling - -const textMode SCROLL_UP = 0; -const textMode SCROLL_DOWN = 1; // this was changed from -1 so it can used in a bitmask -const textMode DEFAULT_SCROLLDIR = SCROLL_UP; - -/** -* @defgroup glcd_enum GLCD enumerations -*/ - -/** -* @ingroup glcd_enum -* @hideinitializer -* @brief Pre Defined Text areas -* -* These enumerations are used to easily define text areas -* using predefined display areas.\n -* They are used with the -* \ref gText::DefineArea(predefinedArea selection, textMode mode) "DefineArea()" function call. -*/ -typedef enum { - - //textAreaFULL = MK_TareaToken( 0, 0, DISPLAY_WIDTH -1, DISPLAY_HEIGHT -1 ), - ///**= firstChar && c < (firstChar+charCount)) { - c -= firstChar; - width = pgm_read_byte(font+GTEXT_FONT_WIDTH_TABLE+c); - } - } - return width; - }; - - static uint16_t stringWidth(const char* str, gTextFont font, uint8_t letterSpacing) - { - uint16_t width = 0; - - while(*str != 0) { - width += ILI9341_due_gText::charWidth(*str++, font) + letterSpacing; - } - if(width > 0) - width -= letterSpacing; - - return width; - }; - - //#ifndef USE_ARDUINO_FLASHSTR - // // when the following function is supported in arduino it will be removed from this library - // void printFlash(FLASHSTRING str); //this overrides the Arduino print function to implicilty store the string in flash (progmem) - // void printFlashln(FLASHSTRING str); - //#endif - - /*@}*/ - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/ILI_SdFatConfig.h b/GD32F1/libraries/ILI9341_due_STM/ILI_SdFatConfig.h deleted file mode 100644 index 84ad39a..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/ILI_SdFatConfig.h +++ /dev/null @@ -1,196 +0,0 @@ -/* Arduino SdFat Library - * Copyright (C) 2012 by William Greiman - * - * This file is part of the Arduino SdFat Library - * - * This Library is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This Library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the Arduino SdFat Library. If not, see - * . - */ -/** - * \file - * \brief configuration definitions - */ -#ifndef ILI_SdFatConfig_h -#define ILI_SdFatConfig_h -#include - -//------------------------------------------------------------------------------ -/** - * Set USE_SEPARATE_FAT_CACHE nonzero to use a second 512 byte cache - * for FAT table entries. Improves performance for large writes that - * are not a multiple of 512 bytes. - */ -#ifdef __arm__ -#define ILI_USE_SEPARATE_FAT_CACHE 1 -#else // __arm__ -#define ILI_USE_SEPARATE_FAT_CACHE 0 -#endif // __arm__ -//------------------------------------------------------------------------------ -/** - * Set USE_MULTI_BLOCK_SD_IO nonzero to use multi-block SD read/write. - * - * Don't use mult-block read/write on small AVR boards. - */ -#if defined(RAMEND) && RAMEND < 3000 -#define ILI_USE_MULTI_BLOCK_SD_IO 0 -#else -#define ILI_USE_MULTI_BLOCK_SD_IO 1 -#endif - -//------------------------------------------------------------------------------ -/** - * To enable SD card CRC checking set USE_SD_CRC nonzero. - * - * Set USE_SD_CRC to 1 to use a smaller slower CRC-CCITT function. - * - * Set USE_SD_CRC to 2 to used a larger faster table driven CRC-CCITT function. - */ -#define ILI_USE_SD_CRC 0 -//------------------------------------------------------------------------------ -/** - * To use multiple SD cards set USE_MULTIPLE_CARDS nonzero. - * - * Using multiple cards costs about 200 bytes of flash. - * - * Each card requires about 550 bytes of SRAM so use of a Mega is recommended. - */ -#define ILI_USE_MULTIPLE_CARDS 0 -//------------------------------------------------------------------------------ -/** - * Set DESTRUCTOR_CLOSES_FILE nonzero to close a file in its destructor. - * - * Causes use of lots of heap in ARM. - */ -#define ILI_DESTRUCTOR_CLOSES_FILE 0 -//------------------------------------------------------------------------------ -/** - * For AVR - * - * Set USE_SERIAL_FOR_STD_OUT nonzero to use Serial (the HardwareSerial class) - * for error messages and output from print functions like ls(). - * - * If USE_SERIAL_FOR_STD_OUT is zero, a small non-interrupt driven class - * is used to output messages to serial port zero. This allows an alternate - * Serial library like SerialPort to be used with SdFat. - * - * You can redirect stdOut with SdFat::setStdOut(Print* stream) and - * get the current stream with SdFat::stdOut(). - */ -#define ILI_USE_SERIAL_FOR_STD_OUT 0 -//------------------------------------------------------------------------------ -/** - * Call flush for endl if ENDL_CALLS_FLUSH is nonzero - * - * The standard for iostreams is to call flush. This is very costly for - * SdFat. Each call to flush causes 2048 bytes of I/O to the SD. - * - * SdFat has a single 512 byte buffer for SD I/O so it must write the current - * data block to the SD, read the directory block from the SD, update the - * directory entry, write the directory block to the SD and read the data - * block back into the buffer. - * - * The SD flash memory controller is not designed for this many rewrites - * so performance may be reduced by more than a factor of 100. - * - * If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force - * all data to be written to the SD. - */ -#define ILI_ENDL_CALLS_FLUSH 0 -//------------------------------------------------------------------------------ -/** - * Allow FAT12 volumes if FAT12_SUPPORT is nonzero. - * FAT12 has not been well tested. - */ -#define ILI_FAT12_SUPPORT 0 -//------------------------------------------------------------------------------ -/** - * SPI SCK divisor for SD initialization commands. - * or greater - */ -#ifdef __AVR__ -const uint8_t ILI_SPI_SCK_INIT_DIVISOR = 64; -#else -const uint8_t ILI_SPI_SCK_INIT_DIVISOR = 128; -#endif -//------------------------------------------------------------------------------ -/** - * Set ENABLE_SPI_TRANSACTION nonzero to enable the SPI transaction feature - * of the standard Arduino SPI library. You must include SPI.h in your - * sketches when ENABLE_SPI_TRANSACTION is nonzero. - */ -#define ILI_ENABLE_SPI_TRANSACTION 0 -//------------------------------------------------------------------------------ -/** - * Set ENABLE_SPI_YIELD nonzero to enable release of the SPI bus during - * SD card busy waits. - * - * This will allow interrupt routines to access the SPI bus if - * ENABLE_SPI_TRANSACTION is nonzero. - * - * Setting ENABLE_SPI_YIELD will introduce some extra overhead and will - * slightly slow transfer rates. A few older SD cards may fail when - * ENABLE_SPI_YIELD is nonzero. - */ -#define ILI_ENABLE_SPI_YIELD 0 -//------------------------------------------------------------------------------ -/** - * Force use of Arduino Standard SPI library if USE_ARDUINO_SPI_LIBRARY - * is nonzero. This will override native and software SPI for all boards. - */ -#define ILI_USE_ARDUINO_SPI_LIBRARY 0 -//------------------------------------------------------------------------------ -/** - * Define AVR_SOF_SPI nonzero to use software SPI on all AVR Arduinos. - */ -#define ILI_AVR_SOFT_SPI 0 -//------------------------------------------------------------------------------ -/** - * Define DUE_SOFT_SPI nonzero to use software SPI on Due Arduinos. - */ -#define ILI_DUE_SOFT_SPI 0 -//------------------------------------------------------------------------------ - -/** - * Define LEONARDO_SOFT_SPI nonzero to use software SPI on Leonardo Arduinos. - * LEONARDO_SOFT_SPI allows an unmodified 328 Shield to be used - * on Leonardo Arduinos. - */ -#define ILI_LEONARDO_SOFT_SPI 0 -//------------------------------------------------------------------------------ -/** - * Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos. - * MEGA_SOFT_SPI allows an unmodified 328 Shield to be used - * on Mega Arduinos. - */ -#define ILI_MEGA_SOFT_SPI 0 -//------------------------------------------------------------------------------ -/** - * Set TEENSY3_SOFT_SPI nonzero to use software SPI on Teensy 3.x boards. - */ -#define ILI_TEENSY3_SOFT_SPI 0 -//------------------------------------------------------------------------------ -/** - * Define software SPI pins. Default allows Uno shields to be used on other - * boards. - */ -// define software SPI pins -/** Default Software SPI chip select pin */ -uint8_t const ILI_SOFT_SPI_CS_PIN = 10; -/** Software SPI Master Out Slave In pin */ -uint8_t const ILI_SOFT_SPI_MOSI_PIN = 11; -/** Software SPI Master In Slave Out pin */ -uint8_t const ILI_SOFT_SPI_MISO_PIN = 12; -/** Software SPI Clock pin */ -uint8_t const ILI_SOFT_SPI_SCK_PIN = 13; -#endif // SdFatConfig_h diff --git a/GD32F1/libraries/ILI9341_due_STM/ILI_SdSpi.h b/GD32F1/libraries/ILI9341_due_STM/ILI_SdSpi.h deleted file mode 100644 index ee41024..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/ILI_SdSpi.h +++ /dev/null @@ -1,188 +0,0 @@ -/* Arduino SdSpi Library - * Copyright (C) 2013 by William Greiman - * - * This file is part of the Arduino SdSpi Library - * - * This Library is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This Library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the Arduino SdSpi Library. If not, see - * . - */ - /** - * \file - * \brief SdSpi class for V2 SD/SDHC cards - */ -#ifndef ILI_SdSpi_h -#define ILI_SdSpi_h -#include -#include "ILI_SdFatConfig.h" - -#if !ILI_USE_ARDUINO_SPI_LIBRARY -// AVR Arduinos -#ifdef __AVR__ -#if ILI_AVR_SOFT_SPI -#define ILI_USE_SOFTWARE_SPI 1 -#elif ILI_LEONARDO_SOFT_SPI && defined(__AVR_ATmega32U4__) && !defined(CORE_TEENSY) -#define ILI_USE_SOFTWARE_SPI 1 -#elif ILI_MEGA_SOFT_SPI && (defined(__AVR_ATmega1280__)\ - ||defined(__AVR_ATmega2560__)) -#define ILI_USE_SOFTWARE_SPI 1 -#else // ILI_USE_SOFTWARE_SPI -#define ILI_USE_NATIVE_AVR_SPI 1 -#endif // ILI_USE_SOFTWARE_SPI -#endif // __AVR__ -// Due -#if defined(__arm__) && !defined(CORE_TEENSY) && !defined(__STM32F1__) -#if ILI_DUE_SOFT_SPI -#define ILI_USE_SOFTWARE_SPI 1 -#else // ILI_DUE_SOFT_SPI -/** Nonzero - use native SAM3X SPI */ -#define ILI_USE_NATIVE_SAM3X_SPI 1 -#endif // ILI_DUE_SOFT_SPI -#endif // defined(__arm__) && !defined(CORE_TEENSY | __STM32F1__) - -// STM32F1 Maple Mini -#if defined(__arm__) && defined(__STM32F1__) -#if ILI_DUE_SOFT_SPI -#define ILI_USE_SOFTWARE_SPI 1 -#else // ILI_DUE_SOFT_SPI -/** Nonzero - use native STM32F1 SPI */ -#define ILI_USE_NATIVE_STM32F1_SPI 1 -#endif // ILI_DUE_SOFT_SPI -#endif // defined(__arm__) && defined(__STM32F1__) - -// Teensy 3.0 -#if defined(__arm__) && defined(CORE_TEENSY) -#if ILI_TEENSY3_SOFT_SPI -#define ILI_USE_SOFTWARE_SPI 1 -#else // ILI_TEENSY3_SOFT_SPI -/** Nonzero - use native MK20DX128 SPI */ -#define ILI_USE_NATIVE_TEENSY3_SPI 1 -#endif // ILI_TEENSY3_SOFT_SPI -#endif // defined(__arm__) && defined(CORE_TEENSY) -#endif // !ILI_USE_ARDUINO_SPI_LIBRARY - -#ifndef ILI_USE_SOFTWARE_SPI -#define ILI_USE_SOFTWARE_SPI 0 -#endif // ILI_USE_SOFTWARE_SPI - -#ifndef ILI_USE_NATIVE_AVR_SPI -#define ILI_USE_NATIVE_AVR_SPI 0 -#endif - -#ifndef ILI_USE_NATIVE_SAM3X_SPI -#define ILI_USE_NATIVE_SAM3X_SPI 0 -#endif // ILI_USE_NATIVE_SAM3X_SPI - -#ifndef ILI_USE_NATIVE_STM32F1_SPI -#define ILI_USE_NATIVE_STM32F1_SPI 0 -#endif // ILI_USE_NATIVE_STM32F1_SPI - -#ifndef ILI_USE_NATIVE_TEENSY3_SPI -#define ILI_USE_NATIVE_TEENSY3_SPI 0 -#endif // ILI_USE_NATIVE_TEENSY3_SPI -//------------------------------------------------------------------------------ -// define default chip select pin -// -#if !ILI_USE_SOFTWARE_SPI -/** The default chip select pin for the SD card is SS. */ -uint8_t const ILI_SD_CHIP_SELECT_PIN = SS; -#else // USE_AVR_SOFTWARE_SPI -/** SPI chip select pin for software SPI. */ -uint8_t const ILI_SD_CHIP_SELECT_PIN = SOFT_SPI_CS_PIN; -#endif // USE_AVR_SOFTWARE_SPI - -//------------------------------------------------------------------------------ -/** - * \class SdSpi - * \brief SPI class for access to SD and SDHC flash memory cards. - */ -class ILI_SdSpi { - public: - /** Initialize the SPI bus */ - void begin(); - /** Set SPI options for access to SD/SDHC cards. - * - * \param[in] spiDivisor SCK clock divider relative to the system clock. - */ - void init(uint8_t spiDivisor); - /** Receive a byte. - * - * \return The byte. - */ - uint8_t receive(); - /** Receive multiple bytes. - * - * \param[out] buf Buffer to receive the data. - * \param[in] n Number of bytes to receive. - * - * \return Zero for no error or nonzero error code. - */ - uint8_t receive(uint8_t* buf, size_t n); - /** Send a byte. - * - * \param[in] data Byte to send - */ - void send(uint8_t data); - /** Send multiple bytes. - * - * \param[in] buf Buffer for data to be sent. - * \param[in] n Number of bytes to send. - */ - void send(uint8_t* buf, size_t n); -}; -//------------------------------------------------------------------------------ -// Use of inline for AVR results in up to 10% better write performance. -// Inline also save a little flash memory. -/** inline avr native functions if nonzero. */ -#define ILI_USE_AVR_NATIVE_SPI_INLINE 1 -#if ILI_USE_NATIVE_AVR_SPI && ILI_USE_AVR_NATIVE_SPI_INLINE -inline uint8_t ILI_SdSpi::receive() { - SPDR = 0XFF; - while (!(SPSR & (1 << SPIF))) {} - return SPDR; -} -inline uint8_t ILI_SdSpi::receive(uint8_t* buf, size_t n) { - if (n-- == 0) return 0; - SPDR = 0XFF; - for (size_t i = 0; i < n; i++) { - while (!(SPSR & (1 << SPIF))) {} - uint8_t b = SPDR; - SPDR = 0XFF; - buf[i] = b; - } - while (!(SPSR & (1 << SPIF))) {} - buf[n] = SPDR; - return 0; -} -inline void ILI_SdSpi::send(uint8_t data) { - SPDR = data; - while (!(SPSR & (1 << SPIF))) {} -} -inline void ILI_SdSpi::send(const uint8_t* buf , size_t n) { - if (n == 0) return; - SPDR = buf[0]; - if (n > 1) { - uint8_t b = buf[1]; - size_t i = 2; - while (1) { - while (!(SPSR & (1 << SPIF))) {} - SPDR = b; - if (i == n) break; - b = buf[i++]; - } - } - while (!(SPSR & (1 << SPIF))) {} -} -#endif // ILI_USE_NATIVE_AVR_SPI && ILI_USE_AVR_NATIVE_SPI_INLINE -#endif // ILI_SdSpi_h - diff --git a/GD32F1/libraries/ILI9341_due_STM/ILI_SdSpiSAM3X.cpp b/GD32F1/libraries/ILI9341_due_STM/ILI_SdSpiSAM3X.cpp deleted file mode 100644 index 1108e60..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/ILI_SdSpiSAM3X.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* Arduino SdSpi Library - * Copyright (C) 2013 by William Greiman - * - * This file is part of the Arduino SdSpi Library - * - * This Library is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This Library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the Arduino SdSpi Library. If not, see - * . - */ -#include "ILI_SdSpi.h" -#if ILI_USE_NATIVE_SAM3X_SPI -/** Use SAM3X DMAC if nonzero */ -#define ILI_USE_SAM3X_DMAC 1 -/** Use extra Bus Matrix arbitration fix if nonzero */ -#define ILI_USE_SAM3X_BUS_MATRIX_FIX 0 -/** Time in ms for DMA receive timeout */ -#define ILI_SAM3X_DMA_TIMEOUT 100 -/** chip select register number */ -#define ILI_SPI_CHIP_SEL 3 -/** DMAC receive channel */ -#define ILI_SPI_DMAC_RX_CH 1 -/** DMAC transmit channel */ -#define ILI_SPI_DMAC_TX_CH 0 -/** DMAC Channel HW Interface Number for SPI TX. */ -#define ILI_SPI_TX_IDX 1 -/** DMAC Channel HW Interface Number for SPI RX. */ -#define ILI_SPI_RX_IDX 2 -//------------------------------------------------------------------------------ -/** Disable DMA Controller. */ -static void ILI_dmac_disable() { - DMAC->DMAC_EN &= (~DMAC_EN_ENABLE); -} -/** Enable DMA Controller. */ -static void ILI_dmac_enable() { - DMAC->DMAC_EN = DMAC_EN_ENABLE; -} -/** Disable DMA Channel. */ -static void ILI_dmac_channel_disable(uint32_t ul_num) { - DMAC->DMAC_CHDR = DMAC_CHDR_DIS0 << ul_num; -} -/** Enable DMA Channel. */ -static void ILI_dmac_channel_enable(uint32_t ul_num) { - DMAC->DMAC_CHER = DMAC_CHER_ENA0 << ul_num; -} -/** Poll for transfer complete. */ -static bool ILI_dmac_channel_transfer_done(uint32_t ul_num) { - return (DMAC->DMAC_CHSR & (DMAC_CHSR_ENA0 << ul_num)) ? false : true; -} -//------------------------------------------------------------------------------ -void ILI_SdSpi::begin() { - PIO_Configure( - g_APinDescription[PIN_SPI_MOSI].pPort, - g_APinDescription[PIN_SPI_MOSI].ulPinType, - g_APinDescription[PIN_SPI_MOSI].ulPin, - g_APinDescription[PIN_SPI_MOSI].ulPinConfiguration); - PIO_Configure( - g_APinDescription[PIN_SPI_MISO].pPort, - g_APinDescription[PIN_SPI_MISO].ulPinType, - g_APinDescription[PIN_SPI_MISO].ulPin, - g_APinDescription[PIN_SPI_MISO].ulPinConfiguration); - PIO_Configure( - g_APinDescription[PIN_SPI_SCK].pPort, - g_APinDescription[PIN_SPI_SCK].ulPinType, - g_APinDescription[PIN_SPI_SCK].ulPin, - g_APinDescription[PIN_SPI_SCK].ulPinConfiguration); - pmc_enable_periph_clk(ID_SPI0); -#if ILI_USE_SAM3X_DMAC - pmc_enable_periph_clk(ID_DMAC); - ILI_dmac_disable(); - DMAC->DMAC_GCFG = DMAC_GCFG_ARB_CFG_FIXED; - ILI_dmac_enable(); -#if ILI_USE_SAM3X_BUS_MATRIX_FIX - MATRIX->MATRIX_WPMR = 0x4d415400; - MATRIX->MATRIX_MCFG[1] = 1; - MATRIX->MATRIX_MCFG[2] = 1; - MATRIX->MATRIX_SCFG[0] = 0x01000010; - MATRIX->MATRIX_SCFG[1] = 0x01000010; - MATRIX->MATRIX_SCFG[7] = 0x01000010; -#endif // ILI_USE_SAM3X_BUS_MATRIX_FIX -#endif // ILI_USE_SAM3X_DMAC -} -//------------------------------------------------------------------------------ -// start RX DMA -static void ILI_spiDmaRX(uint8_t* dst, uint16_t count) { - ILI_dmac_channel_disable(ILI_SPI_DMAC_RX_CH); - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_RX_CH].DMAC_SADDR = (uint32_t)&SPI0->SPI_RDR; - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_RX_CH].DMAC_DADDR = (uint32_t)dst; - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_RX_CH].DMAC_DSCR = 0; - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_RX_CH].DMAC_CTRLA = count | - DMAC_CTRLA_SRC_WIDTH_BYTE | DMAC_CTRLA_DST_WIDTH_BYTE; - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_RX_CH].DMAC_CTRLB = DMAC_CTRLB_SRC_DSCR | - DMAC_CTRLB_DST_DSCR | DMAC_CTRLB_FC_PER2MEM_DMA_FC | - DMAC_CTRLB_SRC_INCR_FIXED | DMAC_CTRLB_DST_INCR_INCREMENTING; - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_RX_CH].DMAC_CFG = DMAC_CFG_SRC_PER(ILI_SPI_RX_IDX) | - DMAC_CFG_SRC_H2SEL | DMAC_CFG_SOD | DMAC_CFG_FIFOCFG_ASAP_CFG; - ILI_dmac_channel_enable(ILI_SPI_DMAC_RX_CH); -} -//------------------------------------------------------------------------------ -// start TX DMA -static void ILI_spiDmaTX(const uint8_t* src, uint16_t count) { - static uint8_t ff = 0XFF; - uint32_t src_incr = DMAC_CTRLB_SRC_INCR_INCREMENTING; - if (!src) { - src = &ff; - src_incr = DMAC_CTRLB_SRC_INCR_FIXED; - } - ILI_dmac_channel_disable(ILI_SPI_DMAC_TX_CH); - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_TX_CH].DMAC_SADDR = (uint32_t)src; - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_TX_CH].DMAC_DADDR = (uint32_t)&SPI0->SPI_TDR; - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_TX_CH].DMAC_DSCR = 0; - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_TX_CH].DMAC_CTRLA = count | - DMAC_CTRLA_SRC_WIDTH_BYTE | DMAC_CTRLA_DST_WIDTH_BYTE; - - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_TX_CH].DMAC_CTRLB = DMAC_CTRLB_SRC_DSCR | - DMAC_CTRLB_DST_DSCR | DMAC_CTRLB_FC_MEM2PER_DMA_FC | - src_incr | DMAC_CTRLB_DST_INCR_FIXED; - - DMAC->DMAC_CH_NUM[ILI_SPI_DMAC_TX_CH].DMAC_CFG = DMAC_CFG_DST_PER(ILI_SPI_TX_IDX) | - DMAC_CFG_DST_H2SEL | DMAC_CFG_SOD | DMAC_CFG_FIFOCFG_ALAP_CFG; - - ILI_dmac_channel_enable(ILI_SPI_DMAC_TX_CH); -} -//------------------------------------------------------------------------------ -// initialize SPI controller -void ILI_SdSpi::init(uint8_t sckDivisor) { - uint8_t scbr = sckDivisor; - Spi* pSpi = SPI0; - // disable SPI - pSpi->SPI_CR = SPI_CR_SPIDIS; - // reset SPI - pSpi->SPI_CR = SPI_CR_SWRST; - // no mode fault detection, set master mode - pSpi->SPI_MR = SPI_PCS(ILI_SPI_CHIP_SEL) | SPI_MR_MODFDIS | SPI_MR_MSTR; - // mode 0, 8-bit, - pSpi->SPI_CSR[ILI_SPI_CHIP_SEL] = SPI_CSR_SCBR(scbr) | SPI_CSR_NCPHA; - // enable SPI - pSpi->SPI_CR |= SPI_CR_SPIEN; -} -//------------------------------------------------------------------------------ -static inline uint8_t ILI_spiTransfer(uint8_t b) { - Spi* pSpi = SPI0; - - pSpi->SPI_TDR = b; - while ((pSpi->SPI_SR & SPI_SR_RDRF) == 0) {} - b = pSpi->SPI_RDR; - return b; -} -//------------------------------------------------------------------------------ -/** SPI receive a byte */ -uint8_t ILI_SdSpi::receive() { - return ILI_spiTransfer(0XFF); -} -//------------------------------------------------------------------------------ -/** SPI receive multiple bytes */ -uint8_t ILI_SdSpi::receive(uint8_t* buf, size_t n) { - Spi* pSpi = SPI0; - int rtn = 0; -#if ILI_USE_SAM3X_DMAC - // clear overrun error - uint32_t s = pSpi->SPI_SR; - - ILI_spiDmaRX(buf, n); - ILI_spiDmaTX(0, n); - - uint32_t m = millis(); - while (!ILI_dmac_channel_transfer_done(ILI_SPI_DMAC_RX_CH)) { - if ((millis() - m) > ILI_SAM3X_DMA_TIMEOUT) { - ILI_dmac_channel_disable(ILI_SPI_DMAC_RX_CH); - ILI_dmac_channel_disable(ILI_SPI_DMAC_TX_CH); - rtn = 2; - break; - } - } - if (pSpi->SPI_SR & SPI_SR_OVRES) rtn |= 1; -#else // ILI_USE_SAM3X_DMAC - for (size_t i = 0; i < n; i++) { - pSpi->SPI_TDR = 0XFF; - while ((pSpi->SPI_SR & SPI_SR_RDRF) == 0) {} - buf[i] = pSpi->SPI_RDR; - } -#endif // ILI_USE_SAM3X_DMAC - return rtn; -} -//------------------------------------------------------------------------------ -/** SPI send a byte */ -void ILI_SdSpi::send(uint8_t b) { - ILI_spiTransfer(b); -} -//------------------------------------------------------------------------------ -void ILI_SdSpi::send(const uint8_t* buf , size_t n) { - Spi* pSpi = SPI0; -#if ILI_USE_SAM3X_DMAC - ILI_spiDmaTX(buf, n); - while (!ILI_dmac_channel_transfer_done(ILI_SPI_DMAC_TX_CH)) {} -#else // #if ILI_USE_SAM3X_DMAC - while ((pSpi->SPI_SR & SPI_SR_TXEMPTY) == 0) {} - for (size_t i = 0; i < n; i++) { - pSpi->SPI_TDR = buf[i]; - while ((pSpi->SPI_SR & SPI_SR_TDRE) == 0) {} - } -#endif // #if ILI_USE_SAM3X_DMAC - while ((pSpi->SPI_SR & SPI_SR_TXEMPTY) == 0) {} - // leave RDR empty - uint8_t b = pSpi->SPI_RDR; -} -#endif // ILI_USE_NATIVE_SAM3X_SPI - -//********************************************************* -// STM32F1 section -//********************************************************* - -#if ILI_USE_NATIVE_STM32F1_SPI -#include -#include -/** Use SAM3X DMAC if nonzero */ -#define ILI_USE_STM32F1_DMAC 1 -/** Time in ms for DMA receive timeout */ -#define ILI_STM32F1_DMA_TIMEOUT 100 -/** chip select register number */ -#define ILI_SPI_CHIP_SEL 3 -/** DMAC receive channel */ -#define ILI_SPI_DMAC_RX_CH DMA_CH2 -/** DMAC transmit channel */ -#define ILI_SPI_DMAC_TX_CH DMA_CH3 -/** DMAC Channel HW Interface Number for SPI TX. */ -#define ILI_SPI_TX_IDX 1 -/** DMAC Channel HW Interface Number for SPI RX. */ -#define ILI_SPI_RX_IDX 2 - -volatile bool SPI_DMA_TX_Active = false; -volatile bool SPI_DMA_RX_Active = false; - -inline void SPI_DMA_TX_Event() { - SPI_DMA_TX_Active = false; - dma_disable(DMA1, DMA_CH3); -} - -inline void SPI_DMA_RX_Event() { - SPI_DMA_RX_Active = false; - dma_disable(DMA1, DMA_CH2); -} -//------------------------------------------------------------------------------ -/** Disable DMA Controller. */ -//static void ILI_dmac_disable() { -// DMAC->DMAC_EN &= (~DMAC_EN_ENABLE); -//} -/** Enable DMA Controller. */ -//static void ILI_dmac_enable() { -// DMAC->DMAC_EN = DMAC_EN_ENABLE; -//} -/** Disable DMA Channel. */ -static void ILI_dmac_channel_disable(dma_channel ul_num) { - dma_disable(DMA1, ul_num); -} -/** Enable DMA Channel. */ -static void ILI_dmac_channel_enable(dma_channel ul_num) { - dma_enable(DMA1, ul_num); -} -/** Poll for transfer complete. */ -//static bool ILI_dmac_channel_transfer_done(dma_tube tube) { -// uint8 shift = (tube - 1) * 4; -// return ((DMA1->regs->ISR >> shift) & 0x02) ? false : true; - -// return (DMAC->DMAC_CHSR & (DMAC_CHSR_ENA0 << ul_num)) ? false : true; -//} -//------------------------------------------------------------------------------ -void ILI_SdSpi::begin() { - SPI.begin(); - SPI.setClockDivider(SPI_CLOCK_DIV2); - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - // DMA setup stuff. We use a line buffer and usa DMA for filling lines and blocks. - - - -#if ILI_USE_STM32F1_DMAC - dma_init(DMA1); - dma_attach_interrupt(DMA1, DMA_CH3, SPI_DMA_TX_Event); - dma_attach_interrupt(DMA1, DMA_CH2, SPI_DMA_RX_Event); - spi_tx_dma_enable(SPI1); - spi_rx_dma_enable(SPI1); - - -#endif // ILI_USE_STM32F1_DMAC -} -//------------------------------------------------------------------------------ -// start RX DMA - -static void ILI_spiDmaRX(uint8_t* dst, uint16_t count) { -// spi_rx_dma_enable(SPI1); - if (count < 1) return; - dma_setup_transfer(DMA1, DMA_CH2, &SPI1->regs->DR, DMA_SIZE_8BITS, - dst, DMA_SIZE_8BITS, (DMA_MINC_MODE | DMA_TRNS_CMPLT)); - dma_set_num_transfers(DMA1, DMA_CH2, count); // 2 bytes per pixel - SPI_DMA_RX_Active = true; - dma_enable(DMA1, DMA_CH2); - - -} -//------------------------------------------------------------------------------ -// start TX DMA -static void ILI_spiDmaTX(uint8_t* src, uint16_t count) { - if (count < 1) return; - static uint8_t ff = 0XFF; -// spi_tx_dma_enable(SPI1); - // dma_init(DMA1); - // dma_attach_interrupt(DMA1, DMA_CH3, SPI_DMA_TX_Event); - - - if (!src) { - src = &ff; - dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS, - src, DMA_SIZE_8BITS, (DMA_FROM_MEM | DMA_TRNS_CMPLT)); - } - else { - dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS, - src, DMA_SIZE_8BITS, (DMA_MINC_MODE | DMA_FROM_MEM | DMA_TRNS_CMPLT)); - } - dma_set_num_transfers(DMA1, DMA_CH3, count); // 2 bytes per pixel - SPI_DMA_TX_Active = true; - dma_enable(DMA1, DMA_CH3); - -} -//------------------------------------------------------------------------------ -// initialize SPI controller STM32F1 -void ILI_SdSpi::init(uint8_t sckDivisor) { - SPI.setClockDivider(sckDivisor); - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - spi_tx_dma_enable(SPI1); - spi_rx_dma_enable(SPI1); - -} -//------------------------------------------------------------------------------ -// STM32 -static inline uint8_t ILI_spiTransfer(uint8_t b) { - return SPI.transfer(b); -} -//------------------------------------------------------------------------------ -// should be valid for STM32 -/** SPI receive a byte */ -uint8_t ILI_SdSpi::receive() { - return ILI_spiTransfer(0xFF); -} -//------------------------------------------------------------------------------ -/** SPI receive multiple bytes */ -// check and finish. - -uint8_t ILI_SdSpi::receive(uint8_t* buf, size_t n) { - int rtn = 0; - -#if ILI_USE_STM32F1_DMAC - // clear overrun error - // uint32_t s = pSpi->SPI_SR; - ILI_spiDmaRX(buf, n); - ILI_spiDmaTX(0, n); - - - uint32_t m = millis(); - while (SPI_DMA_RX_Active) { - if ((millis() - m) > ILI_STM32F1_DMA_TIMEOUT) { - ILI_dmac_channel_disable(ILI_SPI_DMAC_RX_CH); - ILI_dmac_channel_disable(ILI_SPI_DMAC_TX_CH); - rtn = 2; - break; - } - } - // if (pSpi->SPI_SR & SPI_SR_OVRES) rtn |= 1; -#else // ILI_USE_STM32F1_DMAC - for (size_t i = 0; i < n; i++) { - buf[i] = SPI.transfer (0xFF); - } -#endif // ILI_USE_STM32F1_DMAC - return rtn; -} -//------------------------------------------------------------------------------ -/** SPI send a byte */ -void ILI_SdSpi::send(uint8_t b) { - ILI_spiTransfer(b); -} -//------------------------------------------------------------------------------ -void ILI_SdSpi::send(uint8_t* buf , size_t n) { - -#if ILI_USE_STM32F1_DMAC - ILI_spiDmaTX(buf, n); - while (SPI_DMA_TX_Active) {} - - // uint32_t m = millis(); - // while (SPI_DMA_TX_Active) { - // if ((millis() - m) > ILI_STM32F1_DMA_TIMEOUT) { - // ILI_dmac_channel_disable(ILI_SPI_DMAC_TX_CH); - // break; - // } - // } -#else // #if ILI_USE_STM32F1_DMAC - SPI.write (buf, n) -#endif // #if ILI_USE_STM32F1_DMAC - // leave RDR empty - // uint8_t b = pSpi->SPI_RDR; -} -#endif // ILI_USE_NATIVE_STM32F1_SPI diff --git a/GD32F1/libraries/ILI9341_due_STM/README.md b/GD32F1/libraries/ILI9341_due_STM/README.md deleted file mode 100644 index 5b52f79..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/README.md +++ /dev/null @@ -1,48 +0,0 @@ -ILI9341_due -=========== - -Please see http://marekburiak.github.io/ILI9341_due - - -Version History: -``` -v0.94.000 - Added AVR compatibility, the library can now be also used on Uno, Mega and alike. - Please check the github.io page for more information (especially if you want to - use gText) -v0.93.000 - Breaking changes: - - setRotation now needs iliRotation enum as a parameter (instead of an int) - - the meaning of some gText drawString parameters have changed - (event though the parameter type is the same) - - new additions: - - gText drawString with new parameters - - new gText drawStringOffseted, drawStringPivoted, drawStringPivotedOffseted - functions - - gText fontLetterSpacing default value is now 2 (previously 0) - - examples updated - -v0.92.002 - Fixed drawArc - - Added setArcParams function to change maxArcAngle and arcAngleOffset at runtime - -v0.92.001 - Added fontHeight function in gText - - fixes for NORMAL and EXTENDED mode - -v0.92.000 - Added drawArc function for drawing arcs and circles with thickness and pies - - Added screenshotToConsole method and ILIScreenShotViewer app for taking - screenshots from the display - - Added alignment options for drawString in ILI9341_due_gText - -v0.91.002 - Updated graphicstestWithStats example sketch so it does not use Streaming.h - -v0.91.001 - Performance improvements (especially fill circle) - - Fixed a scanline fill bug, clean up commented out code - -v0.91.000 - Added functions for controlling TFT power levels (sleep, idle, setPowerLevel) - -v0.90.026 - Fixed fillScreen after recent changes - -v0.90.025 - Added PushColors565 function - - Added BMP24toILI565 tool - - Updated sdFatTftBitmap example - -v0.90.010 - Initial version -``` \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/arcs/arcs.ino b/GD32F1/libraries/ILI9341_due_STM/examples/arcs/arcs.ino deleted file mode 100644 index a1fe059..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/arcs/arcs.ino +++ /dev/null @@ -1,243 +0,0 @@ - -//#include -#include -#include "ILI_SdSpi.h" -#include "ILI_SdFatConfig.h" -#include "ILI9341_due_gText.h" -#include "ILI9341_due.h" -#include "Arial_bold_14.h" -#include "roboto16.h" -#include "roboto32.h" -#include "roboto70.h" - -#define TFT_DC 10 -#define TFT_CS 8 -#define rst 9 - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, rst); - -char textBuff[20]; - -ILI9341_due_gText t1(&tft); -ILI9341_due_gText t2(&tft); -ILI9341_due_gText t3(&tft); -uint16_t colorLightGray = tft.color565(192,192,192); -uint16_t colorGray = tft.color565(127,127,127); -uint16_t colorDarkGray = tft.color565(64,64,64); - -void setup() -{ - Serial.begin(9600); - while (!Serial) ; // wait for Arduino Serial Monitor - - tft.begin(); - tft.setRotation(iliRotation270); - - screenIntro(); - delay(2000); - screenLoading(); - screenClock(); - screenPie(); - delay(2000); - screenSensors(); -} - -void screenIntro() -{ - tft.fillScreen(ILI9341_BLUE); - t1.defineArea(100, 100, 220, 140); - t1.selectFont(Arial_bold_14); - t1.setFontLetterSpacing(5); - t1.setFontColor(ILI9341_WHITE, ILI9341_BLUE); - strcpy(textBuff, "Arcs demo"); - t1.drawString(textBuff, gTextAlignMiddleCenter); -} - -void screenLoading() -{ - const uint16_t x = 159; - const uint16_t y = 149; - tft.fillScreen(ILI9341_BLACK); - t1.selectFont(roboto32); - t1.setFontLetterSpacing(5); - t1.setFontColor(ILI9341_WHITE, ILI9341_BLACK); - t1.defineArea(100, 85, 220, 140); - strcpy(textBuff, "Loading..."); - t1.drawString(textBuff, gTextAlignTopCenter, 0, 0); - tft.drawArc(x, y, 10, 5, 0, 360, colorLightGray); - - for(int i=0; i<2880; i+=4) - { - tft.drawArc(x, y, 10, 5, (i >> 1)-45, (i >> 1)+45, colorDarkGray); - tft.drawArc(x, y, 10, 5, (i >> 1)-45-4, (i >> 1)-45, colorLightGray); - - tft.drawArc(x, y, 20, 5, 1440-i-45, 1440-i+45, colorDarkGray); - tft.drawArc(x, y, 20, 5, 1440-i+45, 1440-i+45+4, colorLightGray); - } -} - -void screenClock() -{ - const uint16_t x = 159; - const uint16_t y = 119; - tft.fillScreen(ILI9341_BLACK); - t1.selectFont(roboto70); - t1.setFontLetterSpacing(5); - t1.setFontColor(ILI9341_WHITE, ILI9341_BLACK); - t1.drawString("15:06", gTextAlignMiddleCenter); - tft.drawArc(x,y,102,11,0,225, colorLightGray); // 15 hours - tft.drawArc(x,y,113,8,0,36, colorGray); // 6 minutes - tft.drawArc(x,y,120,5,0,360, colorDarkGray); // seconds - - for(uint16_t d=324; d<372; d++) - { - tft.drawArc(x,y,120,5,d-1,d+1, ILI9341_RED); - tft.drawArc(x,y,120,5,d-2,d-1, colorDarkGray); // to erase the red - if(d == 360) - { - t1.drawString("15:07", gTextAlignMiddleCenter); - tft.drawArc(x,y,113,8,0,42, colorGray); // 7 minutes - } - delay(166); - } -} - -void screenPie() -{ - const uint16_t x = 159; - const uint16_t y = 119; - const uint16_t radius = 80; - - tft.fillScreen(ILI9341_BLACK); - t1.selectFont(roboto16); - t1.setFontLetterSpacing(2); - tft.drawArc(x+3,y-2,radius,radius,0,60, tft.color565(198,255,13)); - tft.drawArc(x-3,y+7,radius+10,radius+10,60,340, tft.color565(255,0,54)); - tft.drawArc(x-2,y-3,radius,radius,340,360, tft.color565(0,255,241)); - - t1.defineArea(0,0,220,180); - t1.selectFont(roboto16); - t1.setFontMode(gTextFontMode_Transparent); - t1.setFontColor(ILI9341_BLACK); - t1.drawString("16%",175,70); - t1.drawString("78%",140,150); - t1.setFontColor(colorLightGray); - t1.drawString("6%",132,18); - delay(2000); -} - -void screenSensors() -{ - const uint16_t radius = 55; - float temp=22.4; - uint16_t hum=73, lux=1154; - - const uint16_t s1x = 0; - const uint16_t s1y = 10; - - const uint16_t s2x = 110; - const uint16_t s2y = 70; - - const uint16_t s3x = 210; - const uint16_t s3y = 130; - - tft.fillScreen(ILI9341_BLACK); - - t1.setFontMode(gTextFontMode_Solid); - t1.setFontLetterSpacing(3); - t2.setFontMode(gTextFontMode_Solid); - t2.setFontLetterSpacing(3); - t3.setFontMode(gTextFontMode_Solid); - t3.setFontLetterSpacing(3); - - t1.defineArea(s1x,s1y,s1x+2*radius,s1y+2*radius); - t2.defineArea(s2x,s2y,s2x+2*radius,s2y+2*radius); - t3.defineArea(s3x,s3y,s3x+2*radius,s3y+2*radius); - - t1.setFontColor(ILI9341_WHITE); - tft.drawArc(s1x+radius,s1y+radius,radius,10,-3,3, tft.color565(127,0,27)); - t1.selectFont(roboto16); - t1.drawStringOffseted("C", gTextAlignMiddleCenter, 0, 25); - t1.selectFont(roboto32); - sprintf(textBuff, "%4.1f", temp); - t1.drawString(textBuff, gTextAlignMiddleCenter); - tft.fillRect(s1x+radius-7,s1y+radius+17,2,2,ILI9341_WHITE); // degrees symbol - - for(uint16_t d=1; d220 && d % 15 == 0) - { - temp+=0.1; - sprintf(textBuff, "%4.1f", temp); - t1.drawString(textBuff, gTextAlignMiddleCenter, 3, 3); - tft.drawArc(s1x+radius,s1y+radius,radius,10,temp*10,temp*10+3, tft.color565(127,0,27)); - tft.drawArc(s1x+radius,s1y+radius,radius-3,4,temp*10-2,temp*10, tft.color565(255,0,54)); - delay(random(350, 700)); - } - if(d>300 && d<600 && d % 38 == 0) - { - hum+=1; - sprintf(textBuff, "%d", hum); - t2.drawString(textBuff, gTextAlignMiddleCenter, 3, 3); - tft.drawArc(s2x+radius,s2y+radius,radius,10,(float)hum*3.6-4,(float)hum*3.6+3, tft.color565(0,43,127)); - tft.drawArc(s2x+radius,s2y+radius,radius-3,4,(float)hum*3.6-5,(float)hum*3.6, tft.color565(0,86,255)); - } - } -} - - -void loop() -{ - setup (); - /* add main program code here */ - -} diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto16.h b/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto16.h deleted file mode 100644 index 89b83c6..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto16.h +++ /dev/null @@ -1,167 +0,0 @@ - - -/* - * - * roboto16 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : roboto16.h - * Date : 18.09.2014 - * Font size in bytes : 10574 - * Font width : 10 - * Font height : 17 - * Font first char : 32 - * Font last char : 145 - * Font used chars : 113 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef ROBOTO16_H -#define ROBOTO16_H - -#define ROBOTO16_WIDTH 10 -#define ROBOTO16_HEIGHT 17 - -static const uint8_t roboto16[] PROGMEM = { - 0x29, 0x4E, // size - 0x0A, // width - 0x11, // height - 0x20, // first char - 0x71, // char count - - // char widths - 0x00, 0x01, 0x03, 0x08, 0x07, 0x0A, 0x08, 0x01, 0x04, 0x04, - 0x07, 0x07, 0x02, 0x04, 0x01, 0x06, 0x07, 0x03, 0x07, 0x07, - 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x01, 0x02, 0x06, 0x07, - 0x07, 0x06, 0x0D, 0x0A, 0x08, 0x08, 0x09, 0x08, 0x08, 0x09, - 0x09, 0x01, 0x06, 0x09, 0x07, 0x0B, 0x09, 0x09, 0x08, 0x09, - 0x09, 0x08, 0x09, 0x08, 0x0A, 0x0D, 0x09, 0x09, 0x08, 0x03, - 0x06, 0x03, 0x05, 0x07, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x04, 0x07, 0x07, 0x01, 0x02, 0x07, 0x01, 0x0C, 0x07, 0x07, - 0x07, 0x07, 0x04, 0x06, 0x05, 0x07, 0x08, 0x0B, 0x07, 0x08, - 0x06, 0x04, 0x01, 0x05, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, - - // font data - 0xFC, 0x11, 0x00, // 33 - 0x1E, 0x10, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 34 - 0x20, 0x20, 0xF8, 0x24, 0x20, 0xE0, 0x3C, 0x20, 0x02, 0x1E, 0x03, 0x02, 0x1E, 0x03, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 35 - 0x38, 0x44, 0x44, 0x83, 0x84, 0x04, 0x18, 0x0C, 0x10, 0x10, 0x70, 0x10, 0x11, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 36 - 0x3C, 0x44, 0x42, 0x3C, 0x80, 0x40, 0x30, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06, 0x01, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 37 - 0x00, 0xBC, 0x44, 0xC2, 0x24, 0x1C, 0x00, 0x00, 0x0F, 0x10, 0x10, 0x10, 0x13, 0x14, 0x08, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 38 - 0x0E, 0x00, 0x00, // 39 - 0xE0, 0x1C, 0x02, 0x01, 0x0F, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x80, // 40 - 0x01, 0x06, 0x18, 0xE0, 0x00, 0xC0, 0x30, 0x0F, 0x80, 0x00, 0x00, 0x00, // 41 - 0x10, 0x90, 0x50, 0x3C, 0x50, 0x90, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 42 - 0x80, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 43 - 0x00, 0x00, 0x40, 0x70, 0x00, 0x00, // 44 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, // 45 - 0x00, 0x10, 0x00, // 46 - 0x00, 0x00, 0x00, 0xE0, 0x1C, 0x04, 0x20, 0x1C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 47 - 0xF8, 0x04, 0x04, 0x02, 0x04, 0x04, 0xF8, 0x07, 0x18, 0x10, 0x10, 0x10, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 48 - 0x04, 0x04, 0xFC, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, // 49 - 0x18, 0x04, 0x04, 0x02, 0x84, 0x6C, 0x10, 0x10, 0x18, 0x14, 0x13, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 50 - 0x18, 0x04, 0x84, 0x82, 0x84, 0xC4, 0x38, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 51 - 0x00, 0x80, 0x60, 0x10, 0x0C, 0xFC, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x1F, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 52 - 0xC0, 0xBC, 0x44, 0x44, 0x44, 0x44, 0x84, 0x04, 0x18, 0x10, 0x10, 0x10, 0x10, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 53 - 0xF0, 0x4C, 0x44, 0x24, 0x42, 0x44, 0x80, 0x07, 0x08, 0x10, 0x10, 0x10, 0x10, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 54 - 0x04, 0x04, 0x04, 0xC4, 0x24, 0x1C, 0x04, 0x00, 0x00, 0x1E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 55 - 0x38, 0xC4, 0x84, 0x82, 0x84, 0xC4, 0x38, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 56 - 0xF8, 0x04, 0x04, 0x02, 0x04, 0x8C, 0xF0, 0x00, 0x11, 0x11, 0x12, 0x11, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 57 - 0x20, 0x10, 0x00, // 58 - 0x00, 0x20, 0x40, 0x70, 0x00, 0x00, // 59 - 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 - 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 - 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x80, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 62 - 0x0C, 0x04, 0x02, 0x84, 0x6C, 0x10, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 63 - 0xC0, 0x30, 0x08, 0x08, 0x84, 0x44, 0x24, 0x24, 0xC4, 0x04, 0x08, 0x30, 0xC0, 0x1F, 0x60, 0x80, 0x8F, 0x10, 0x10, 0x10, 0x08, 0x9F, 0x10, 0x10, 0x0C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, // 64 - 0x00, 0x00, 0x80, 0x70, 0x0C, 0x0C, 0x70, 0x80, 0x00, 0x00, 0x10, 0x0C, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x0C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 65 - 0xFC, 0x84, 0x84, 0x84, 0x84, 0xC4, 0xEC, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 66 - 0xF0, 0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x18, 0x07, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 67 - 0xFC, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x18, 0xE0, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 68 - 0xFC, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x04, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 69 - 0xFC, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x04, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 0xF0, 0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x0C, 0x10, 0x03, 0x0C, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 71 - 0xFC, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFC, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 72 - 0xFC, 0x1F, 0x00, // 73 - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 74 - 0xFC, 0x80, 0x80, 0xC0, 0x20, 0x10, 0x08, 0x04, 0x04, 0x1F, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0C, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 75 - 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 76 - 0xFC, 0x04, 0x38, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x18, 0xFC, 0x1F, 0x00, 0x00, 0x00, 0x07, 0x18, 0x0C, 0x03, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 77 - 0xFC, 0x04, 0x18, 0x20, 0xC0, 0x00, 0x00, 0x00, 0xFC, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 78 - 0xF0, 0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x08, 0xF0, 0x07, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 79 - 0xFC, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x78, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 0xF0, 0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x08, 0xF0, 0x07, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x2C, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 81 - 0xFC, 0x84, 0x84, 0x84, 0x84, 0x84, 0x44, 0x38, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 82 - 0x38, 0x44, 0x44, 0x82, 0x82, 0x84, 0x04, 0x18, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 83 - 0x04, 0x04, 0x04, 0x04, 0xFC, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 84 - 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x07, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 85 - 0x04, 0x1C, 0xE0, 0x00, 0x00, 0x00, 0x80, 0x60, 0x1C, 0x04, 0x00, 0x00, 0x00, 0x03, 0x1C, 0x1C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 86 - 0x3C, 0xC0, 0x00, 0x00, 0xE0, 0x1C, 0x1C, 0xE0, 0x00, 0x00, 0x80, 0x78, 0x04, 0x00, 0x03, 0x1C, 0x0E, 0x01, 0x00, 0x00, 0x00, 0x07, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 87 - 0x00, 0x04, 0x08, 0x30, 0xC0, 0xC0, 0x30, 0x08, 0x04, 0x10, 0x18, 0x0C, 0x02, 0x01, 0x01, 0x02, 0x0C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 88 - 0x04, 0x0C, 0x30, 0x40, 0x80, 0x80, 0x60, 0x18, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89 - 0x04, 0x04, 0x04, 0x84, 0x64, 0x14, 0x0C, 0x04, 0x18, 0x14, 0x13, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 - 0xFF, 0x01, 0x01, 0x7F, 0x40, 0x40, 0x00, 0x00, 0x00, // 91 - 0x04, 0x1C, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1C, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 92 - 0x01, 0x01, 0xFF, 0x40, 0x40, 0x7F, 0x00, 0x00, 0x00, // 93 - 0x60, 0x18, 0x0C, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 94 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 95 - 0x02, 0x0C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 96 - 0x40, 0x20, 0x10, 0x10, 0x20, 0xE0, 0x00, 0x1E, 0x12, 0x11, 0x11, 0x11, 0x1F, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 97 - 0xFE, 0x20, 0x20, 0x10, 0x10, 0x20, 0xC0, 0x1F, 0x08, 0x10, 0x10, 0x10, 0x18, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 98 - 0xC0, 0x20, 0x10, 0x10, 0x20, 0x60, 0x80, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 99 - 0xC0, 0x20, 0x10, 0x10, 0x20, 0x40, 0xFE, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x08, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 100 - 0xC0, 0x20, 0x10, 0x10, 0x20, 0x60, 0x80, 0x0F, 0x19, 0x11, 0x11, 0x11, 0x19, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 101 - 0x20, 0xFE, 0x22, 0x22, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 102 - 0xC0, 0x20, 0x10, 0x10, 0x20, 0x40, 0xE0, 0x0F, 0x90, 0x90, 0x90, 0x90, 0xC8, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 103 - 0xFE, 0x20, 0x20, 0x10, 0x10, 0x20, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 104 - 0xE2, 0x1F, 0x00, // 105 - 0x00, 0xE2, 0x80, 0xFF, 0x00, 0x00, // 106 - 0xFE, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x1F, 0x01, 0x01, 0x02, 0x0C, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 107 - 0xFE, 0x1F, 0x00, // 108 - 0xE0, 0x20, 0x20, 0x10, 0x10, 0x60, 0xC0, 0x20, 0x10, 0x10, 0x20, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 109 - 0xE0, 0x20, 0x20, 0x10, 0x10, 0x20, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 110 - 0xC0, 0x20, 0x20, 0x10, 0x20, 0x20, 0xC0, 0x0F, 0x18, 0x10, 0x10, 0x10, 0x18, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 111 - 0xE0, 0x20, 0x20, 0x10, 0x10, 0x20, 0xC0, 0xFF, 0x08, 0x10, 0x10, 0x10, 0x18, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 112 - 0xC0, 0x20, 0x10, 0x10, 0x20, 0x40, 0xE0, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x08, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 113 - 0xE0, 0x20, 0x20, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 114 - 0xE0, 0x20, 0x10, 0x10, 0x20, 0x60, 0x08, 0x11, 0x11, 0x11, 0x12, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 115 - 0x20, 0x20, 0xFC, 0x20, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 116 - 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x07, 0x18, 0x10, 0x10, 0x10, 0x08, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 117 - 0x20, 0xE0, 0x00, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x00, 0x03, 0x1C, 0x1C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 118 - 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x20, 0x00, 0x0F, 0x18, 0x07, 0x00, 0x00, 0x07, 0x18, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 119 - 0x00, 0x20, 0x40, 0x80, 0x80, 0x40, 0x20, 0x10, 0x18, 0x0C, 0x03, 0x03, 0x0C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 120 - 0x20, 0xE0, 0x00, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x83, 0x7C, 0x1C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 121 - 0x20, 0x20, 0x20, 0xA0, 0x60, 0x20, 0x18, 0x14, 0x13, 0x11, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 122 - 0x00, 0xF8, 0x06, 0x02, 0x01, 0x3E, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, // 123 - 0xFC, 0x7F, 0x00, // 124 - 0x02, 0x02, 0xFC, 0x00, 0x00, 0x80, 0x80, 0x7E, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // 125 - 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto32.h b/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto32.h deleted file mode 100644 index 3964699..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto32.h +++ /dev/null @@ -1,165 +0,0 @@ - - -/* - * - * roboto32 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : roboto32.h - * Date : 18.09.2014 - * Font size in bytes : 40065 - * Font width : 10 - * Font height : 33 - * Font first char : 32 - * Font last char : 128 - * Font used chars : 96 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef ROBOTO32_H -#define ROBOTO32_H - -#define ROBOTO32_WIDTH 10 -#define ROBOTO32_HEIGHT 33 - -static const uint8_t roboto32[] PROGMEM = { - 0x9C, 0x81, // size - 0x0A, // width - 0x21, // height - 0x20, // first char - 0x60, // char count - - // char widths - 0x00, 0x03, 0x05, 0x11, 0x0E, 0x14, 0x12, 0x02, 0x08, 0x08, - 0x0D, 0x10, 0x03, 0x07, 0x02, 0x0C, 0x0E, 0x08, 0x0E, 0x0E, - 0x10, 0x0D, 0x0E, 0x0F, 0x0E, 0x0F, 0x02, 0x04, 0x0D, 0x0D, - 0x0D, 0x0C, 0x19, 0x13, 0x0F, 0x11, 0x10, 0x0E, 0x0F, 0x11, - 0x11, 0x02, 0x0E, 0x11, 0x0D, 0x16, 0x11, 0x12, 0x0F, 0x12, - 0x10, 0x11, 0x11, 0x10, 0x12, 0x1B, 0x12, 0x12, 0x11, 0x05, - 0x0B, 0x05, 0x0B, 0x0E, 0x06, 0x0D, 0x0E, 0x0D, 0x0D, 0x0E, - 0x0A, 0x0D, 0x0D, 0x02, 0x05, 0x0E, 0x02, 0x18, 0x0D, 0x0F, - 0x0E, 0x0D, 0x09, 0x0C, 0x08, 0x0D, 0x0E, 0x16, 0x0E, 0x0E, - 0x0E, 0x09, 0x01, 0x09, 0x12, 0x00, - - // font data - 0x00, 0xF8, 0xF8, 0x00, 0xFF, 0xFF, 0x80, 0x87, 0x87, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, // 33 - 0xFC, 0x1C, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 34 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0x08, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x78, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0xF4, 0x7F, 0x05, 0x04, 0x04, 0x04, 0xC4, 0xFE, 0x0F, 0x04, 0x04, 0x04, 0x0C, 0x0C, 0x0C, 0xCC, 0xFE, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0xFC, 0x7F, 0x0D, 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 35 - 0x00, 0xC0, 0xF0, 0x30, 0x18, 0x18, 0x1F, 0x1F, 0x18, 0x18, 0x30, 0x70, 0xE0, 0x80, 0x00, 0x0F, 0x1E, 0x30, 0x30, 0x60, 0x60, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x03, 0x03, 0x78, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x83, 0xFF, 0x7C, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x1E, 0x1E, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 36 - 0xE0, 0x30, 0x18, 0x08, 0x08, 0x18, 0x10, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1C, 0x10, 0x30, 0x10, 0x10, 0x18, 0x0F, 0x03, 0x80, 0xE0, 0x38, 0x0C, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x38, 0x0C, 0x07, 0x01, 0x00, 0xF8, 0xFE, 0x03, 0x01, 0x01, 0x01, 0x03, 0xCE, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02, 0x02, 0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 37 - 0x00, 0x00, 0x00, 0xE0, 0x70, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0xDE, 0x78, 0x60, 0xF0, 0x98, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xFE, 0xC7, 0x81, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0E, 0x1C, 0xB0, 0xE0, 0xF0, 0xBF, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x00, 0x01, 0x03, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 38 - 0xFC, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 39 - 0x00, 0x00, 0xC0, 0xF0, 0x38, 0x0C, 0x07, 0x02, 0xE0, 0xFE, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x1C, 0x70, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, // 40 - 0x03, 0x06, 0x0C, 0x38, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFE, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x1F, 0x00, 0x80, 0xC0, 0x70, 0x1C, 0x0F, 0x01, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 41 - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x01, 0x81, 0xE3, 0x73, 0x1A, 0x0F, 0x0F, 0x3A, 0x63, 0xC3, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 42 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 43 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x20, 0x3F, 0x0F, 0x00, 0x00, 0x00, // 44 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // 46 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x38, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x3C, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x3E, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0E, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 47 - 0x00, 0xC0, 0x70, 0x30, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0xE0, 0xC0, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3F, 0xFF, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x7F, 0x1F, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 48 - 0x20, 0x30, 0x30, 0x30, 0x10, 0x10, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 49 - 0xC0, 0xE0, 0x30, 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0xE0, 0xC0, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x70, 0x3F, 0x0F, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x1C, 0x0E, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 50 - 0xC0, 0xE0, 0x70, 0x30, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0xF0, 0xC0, 0x00, 0x01, 0x01, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x60, 0xE0, 0xB0, 0x9F, 0x0F, 0x00, 0x70, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xFF, 0x3C, 0x00, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 51 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0x38, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x70, 0x38, 0x0E, 0x07, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x08, 0x0E, 0x0B, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0xFF, 0xFF, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 52 - 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0xFC, 0xFF, 0x20, 0x30, 0x10, 0x10, 0x18, 0x18, 0x30, 0x30, 0x60, 0xE0, 0x80, 0xF0, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x3F, 0x00, 0x01, 0x01, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 53 - 0x00, 0x80, 0xE0, 0x70, 0x30, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, 0xFC, 0xFF, 0x61, 0x30, 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0xE0, 0xC0, 0x0F, 0x7F, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF1, 0x7F, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 54 - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x98, 0xD8, 0x78, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0x3C, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 55 - 0x80, 0xE0, 0x70, 0x30, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0xF0, 0xE0, 0x00, 0x07, 0x1F, 0xB8, 0xB0, 0xE0, 0x60, 0x40, 0x60, 0x60, 0xE0, 0xB0, 0x9C, 0x0F, 0x03, 0xFE, 0xE7, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xFF, 0x7E, 0x00, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 56 - 0x00, 0xC0, 0xE0, 0x70, 0x30, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, 0x70, 0xE0, 0xC0, 0x00, 0x1E, 0xFF, 0xE1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC1, 0xFF, 0xFC, 0x00, 0x00, 0x01, 0x03, 0x03, 0x06, 0x06, 0x06, 0x06, 0x02, 0x03, 0x81, 0xF0, 0x7F, 0x07, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 57 - 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // 58 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x80, 0x80, 0x00, 0x20, 0x3F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, // 59 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x60, 0x60, 0x20, 0x30, 0x30, 0x18, 0x18, 0x0C, 0x0C, 0x06, 0x01, 0x01, 0x03, 0x03, 0x02, 0x06, 0x04, 0x0C, 0x0C, 0x18, 0x18, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0C, 0x0C, 0x08, 0x18, 0x10, 0x30, 0x30, 0x60, 0x60, 0x40, 0xC0, 0x80, 0x30, 0x30, 0x18, 0x18, 0x0C, 0x0C, 0x04, 0x06, 0x06, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 62 - 0xC0, 0xE0, 0x70, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0xF0, 0xC0, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x1F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 63 - 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x60, 0x20, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x30, 0x20, 0x60, 0x40, 0xC0, 0x80, 0x00, 0x00, 0xC0, 0xF8, 0x1C, 0x07, 0x01, 0x00, 0x00, 0x00, 0xC0, 0x70, 0x30, 0x18, 0x08, 0x08, 0x08, 0x18, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0E, 0xF8, 0xFF, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xCF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x3F, 0x01, 0x07, 0x1C, 0x30, 0x60, 0xC0, 0xC0, 0x80, 0x83, 0x03, 0x02, 0x02, 0x02, 0x03, 0x81, 0x80, 0x81, 0x83, 0x02, 0x02, 0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 64 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x78, 0x78, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x7C, 0x1F, 0x03, 0x00, 0x00, 0x01, 0x0F, 0x7C, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x7C, 0x1F, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0F, 0x0F, 0x7C, 0xE0, 0x80, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 65 - 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, 0x30, 0x70, 0xE0, 0xC0, 0x00, 0xFF, 0xFF, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x9F, 0x0F, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC1, 0xFF, 0x7E, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 66 - 0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0x30, 0xE0, 0xC0, 0x00, 0xFC, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x0F, 0x3F, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x78, 0x18, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 67 - 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, 0x30, 0x30, 0x60, 0xC0, 0x80, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0x70, 0x3F, 0x0F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 68 - 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 69 - 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0x70, 0xE0, 0x80, 0xFC, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x83, 0x83, 0x07, 0x3F, 0x78, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 71 - 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 72 - 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0x00, 0x00, // 73 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xFF, 0x3F, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 74 - 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x30, 0x18, 0x08, 0x00, 0xFF, 0xFF, 0x40, 0x40, 0x40, 0xE0, 0xF0, 0x98, 0x0C, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x38, 0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 75 - 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 76 - 0xF8, 0xF8, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x78, 0xF8, 0xF8, 0xFF, 0xFF, 0x00, 0x03, 0x1F, 0x78, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x3C, 0x0F, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x3C, 0xF0, 0x80, 0xC0, 0xF8, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 77 - 0xF8, 0xF8, 0x70, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xFF, 0xFF, 0x00, 0x01, 0x03, 0x0E, 0x1C, 0x70, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x1C, 0x38, 0xE0, 0xC0, 0xFF, 0xFF, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 78 - 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0x30, 0xE0, 0xC0, 0x80, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFC, 0x0F, 0x3F, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x78, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 79 - 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, 0x30, 0x70, 0xE0, 0xC0, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0x60, 0x7F, 0x1F, 0xFF, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x30, 0x30, 0xE0, 0xC0, 0x80, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFC, 0x0F, 0x3F, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x78, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x07, 0x0E, 0x1C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 81 - 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, 0x30, 0x70, 0xE0, 0xC0, 0x00, 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xB0, 0x3F, 0x0F, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0xFF, 0xFE, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 82 - 0x00, 0x80, 0xE0, 0x70, 0x30, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, 0x30, 0xE0, 0xC0, 0x00, 0x00, 0x07, 0x0F, 0x18, 0x30, 0x30, 0x60, 0x60, 0x60, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x03, 0x03, 0x10, 0x70, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0xC3, 0xFE, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 83 - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 84 - 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0xF8, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x7F, 0x1F, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 85 - 0x38, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x18, 0x00, 0x00, 0x07, 0x3F, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3E, 0xF0, 0xC0, 0xC0, 0xF8, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 86 - 0x18, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0x78, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x78, 0x08, 0x00, 0x01, 0x1F, 0xFC, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0x1F, 0x01, 0x00, 0x03, 0x3F, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0xFC, 0xC0, 0xF0, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0xFC, 0xC0, 0xF0, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 87 - 0x08, 0x18, 0x78, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0x38, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x1E, 0xB8, 0xF0, 0xF0, 0xBC, 0x0E, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0x78, 0x1C, 0x0F, 0x03, 0x00, 0x01, 0x03, 0x0E, 0x1C, 0x70, 0xE0, 0x80, 0x00, 0x00, 0x02, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 88 - 0x18, 0x78, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x70, 0x38, 0x08, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x3C, 0x70, 0xC0, 0x00, 0xC0, 0xE0, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89 - 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x98, 0xF8, 0x78, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0x38, 0x1C, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x70, 0x38, 0x0E, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 - 0xFF, 0x03, 0x03, 0x03, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, // 91 - 0x18, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x78, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 92 - 0x03, 0x03, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, // 93 - 0x00, 0x00, 0x00, 0x80, 0xF0, 0x18, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x40, 0x78, 0x1E, 0x07, 0x00, 0x00, 0x00, 0x07, 0x1E, 0x78, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 94 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 95 - 0x08, 0x08, 0x18, 0x30, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 96 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x38, 0x0C, 0x06, 0x06, 0x02, 0x02, 0x02, 0x06, 0x06, 0x1C, 0xF8, 0xE0, 0xF8, 0xDC, 0x06, 0x06, 0x02, 0x03, 0x03, 0x03, 0x03, 0x83, 0xC3, 0xFF, 0xFF, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 97 - 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18, 0x0C, 0x04, 0x06, 0x02, 0x02, 0x06, 0x06, 0x0E, 0x1C, 0xF8, 0xE0, 0xFF, 0xFF, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x3F, 0x03, 0x03, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 98 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x1C, 0x06, 0x06, 0x02, 0x02, 0x02, 0x06, 0x06, 0x0C, 0x78, 0x70, 0x7F, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x60, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 99 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFC, 0xE0, 0xF8, 0x1C, 0x0E, 0x06, 0x06, 0x02, 0x02, 0x06, 0x04, 0x0C, 0xFF, 0xFF, 0x3F, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 100 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x78, 0x1C, 0x0C, 0x06, 0x02, 0x02, 0x02, 0x06, 0x06, 0x0C, 0xF8, 0xF0, 0x07, 0x7F, 0xF3, 0xC3, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 0x03, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 101 - 0x00, 0x00, 0x00, 0xF0, 0xFC, 0x0C, 0x06, 0x06, 0x06, 0x04, 0x06, 0x06, 0x06, 0xFF, 0xFF, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 102 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x1C, 0x0E, 0x06, 0x06, 0x02, 0x02, 0x06, 0x04, 0x0C, 0xF0, 0xFE, 0x3F, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0x80, 0xC1, 0x83, 0x83, 0x82, 0x82, 0x82, 0x83, 0xC3, 0xE1, 0x7F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, // 103 - 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30, 0x08, 0x04, 0x06, 0x02, 0x02, 0x06, 0x06, 0x0E, 0x7C, 0xF8, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 104 - 0x0C, 0x0C, 0xFE, 0xFE, 0xFF, 0xFF, 0x03, 0x03, 0x00, 0x00, // 105 - 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0x80, 0xE0, 0x7F, 0x1F, 0x80, 0x80, 0x00, 0x00, 0x00, // 106 - 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x38, 0x1C, 0x0E, 0x06, 0x02, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x07, 0x0E, 0x18, 0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 107 - 0xFC, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0x00, 0x00, // 108 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x30, 0x0C, 0x04, 0x06, 0x02, 0x02, 0x06, 0x06, 0x0E, 0xFC, 0xF0, 0x38, 0x0C, 0x04, 0x06, 0x02, 0x02, 0x06, 0x06, 0x0C, 0xFC, 0xF0, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 109 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x30, 0x08, 0x04, 0x06, 0x02, 0x02, 0x06, 0x06, 0x0E, 0x7C, 0xF8, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 110 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x78, 0x1C, 0x0C, 0x06, 0x06, 0x02, 0x02, 0x06, 0x06, 0x0C, 0x1C, 0xF8, 0xE0, 0x07, 0x7F, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xFD, 0x3F, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 111 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x18, 0x0C, 0x06, 0x06, 0x02, 0x02, 0x06, 0x06, 0x0E, 0x1C, 0xF8, 0xE0, 0xFF, 0xFF, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xFF, 0x3F, 0xFF, 0xFF, 0x00, 0x01, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 112 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x1C, 0x0E, 0x06, 0x02, 0x02, 0x02, 0x06, 0x04, 0x0C, 0xFC, 0xFE, 0x3F, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, // 113 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x30, 0x0C, 0x04, 0x06, 0x06, 0x06, 0x02, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 114 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xFC, 0x8C, 0x06, 0x06, 0x02, 0x02, 0x06, 0x06, 0x0E, 0x3C, 0x38, 0xE0, 0xE0, 0x01, 0x01, 0x03, 0x03, 0x02, 0x06, 0x06, 0x0C, 0xDC, 0xF8, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 115 - 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0xFF, 0xFF, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 116 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x1F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7F, 0xFF, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 117 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x3E, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0x1E, 0x06, 0x00, 0x00, 0x00, 0x07, 0x3E, 0xF0, 0x80, 0xC0, 0xF8, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 118 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x3E, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0x1E, 0x1E, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0x3E, 0x06, 0x00, 0x00, 0x03, 0x1F, 0xFC, 0xC0, 0xE0, 0x7C, 0x0F, 0x01, 0x00, 0x00, 0x01, 0x0F, 0x7C, 0xE0, 0x80, 0xF8, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 119 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x1E, 0x38, 0xE0, 0xC0, 0x00, 0x80, 0xE0, 0x70, 0x3C, 0x0E, 0x06, 0x02, 0x00, 0x00, 0xC0, 0xE0, 0x38, 0x1D, 0x07, 0x0F, 0x1C, 0x70, 0xE0, 0x80, 0x00, 0x00, 0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 120 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x3E, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x3E, 0x06, 0x00, 0x00, 0x01, 0x07, 0x3E, 0xF8, 0xC0, 0xC0, 0xF8, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0x78, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 121 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x86, 0xC6, 0x76, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x80, 0xC0, 0x70, 0x38, 0x1C, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 122 - 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF8, 0x0C, 0x04, 0x06, 0x00, 0x00, 0x80, 0xE0, 0x7F, 0x1F, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x0E, 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 123 - 0xF8, 0xFF, 0xFF, 0x3F, 0x00, // 124 - 0x02, 0x06, 0x0C, 0x1C, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFC, 0x06, 0x03, 0x03, 0x80, 0xC0, 0xC0, 0x70, 0x3F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 125 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x06, 0x06, 0x04, 0x04, 0x06, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto70.h b/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto70.h deleted file mode 100644 index 8cbda92..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/arcs/roboto70.h +++ /dev/null @@ -1,74 +0,0 @@ - - -/* - * - * roboto70 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : roboto70.h - * Date : 18.09.2014 - * Font size in bytes : 15623 - * Font width : 10 - * Font height : 51 - * Font first char : 48 - * Font last char : 59 - * Font used chars : 11 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef ROBOTO70_H -#define ROBOTO70_H - -#define ROBOTO70_WIDTH 10 -#define ROBOTO70_HEIGHT 51 - -static const uint8_t roboto70[] PROGMEM = { - 0x3D, 0x07, // size - 0x0A, // width - 0x33, // height - 0x30, // first char - 0x0B, // char count - - // char widths - 0x1F, 0x10, 0x20, 0x20, 0x24, 0x1D, 0x1F, 0x20, 0x20, 0x1F, - 0x04, - - // font data - 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0x3C, 0x1E, 0x1E, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1E, 0x3E, 0x7C, 0xFC, 0xF8, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFC, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x01, 0x07, 0x1F, 0x3F, 0x7F, 0xFC, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xFC, 0x7F, 0x3F, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 48 - 0x38, 0x38, 0x38, 0x38, 0x3C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1E, 0x1E, 0x1E, 0xFE, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, // 49 - 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0x7C, 0x3C, 0x1E, 0x1E, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1E, 0x3E, 0x7C, 0xFC, 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7F, 0x7F, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xFE, 0x7F, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0x7E, 0x3F, 0x1F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0x7E, 0x3F, 0x1F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE, 0xBF, 0x9F, 0x87, 0x83, 0x81, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, // 50 - 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0x7C, 0x3E, 0x1E, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1E, 0x1E, 0x3E, 0xFC, 0xF8, 0xF0, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x1C, 0x1F, 0x1F, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xF0, 0x78, 0x7C, 0x3F, 0x1F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x0E, 0x0E, 0x1E, 0x3C, 0x7C, 0xF8, 0xF0, 0xE0, 0x80, 0x00, 0x70, 0xF0, 0xF0, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xFF, 0xFF, 0x38, 0x00, 0x07, 0x0F, 0x3F, 0x7F, 0x7E, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xFC, 0x7F, 0x3F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 51 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFE, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0xFE, 0x3F, 0x1F, 0x07, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xFC, 0x7E, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF8, 0xFC, 0x7F, 0x1F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0xFF, 0xFF, 0xFF, 0xFF, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 52 - 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xE0, 0xF0, 0x70, 0x78, 0x78, 0x38, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x78, 0x78, 0xF8, 0xF0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0xFF, 0xFF, 0xFE, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x1F, 0x3F, 0x7F, 0xFC, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xFC, 0x7F, 0x3F, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 53 - 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xF8, 0x7C, 0x3E, 0x1E, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1E, 0x1E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0xFF, 0x7F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xE0, 0xE0, 0x70, 0x78, 0x38, 0x3C, 0x1C, 0x1C, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1C, 0x3C, 0x7C, 0x78, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x1F, 0xFF, 0xFF, 0xFE, 0xF0, 0x0F, 0xFF, 0xFF, 0xFF, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x07, 0x0F, 0x3F, 0x7F, 0x7C, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xF8, 0x7E, 0x3F, 0x1F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 54 - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x8F, 0xCF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF8, 0xFC, 0x3F, 0x1F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0xFF, 0xFF, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 55 - 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x7C, 0x3E, 0x1E, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1F, 0x1E, 0x3E, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0x3F, 0x3E, 0x78, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0x7C, 0x3F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0x3C, 0x1C, 0x1E, 0x0E, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0E, 0x1E, 0x3C, 0x7C, 0xF8, 0xF0, 0xE0, 0xC0, 0x00, 0x78, 0xFF, 0xFF, 0xFF, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x07, 0x1F, 0x3F, 0x7F, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE, 0x7F, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 56 - 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0xFC, 0x7C, 0x3E, 0x1E, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1E, 0x1E, 0x3C, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x00, 0x00, 0xE0, 0xFE, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0xFF, 0xFF, 0xFF, 0xF0, 0x3F, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x07, 0x1F, 0x3F, 0x7F, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0x70, 0x78, 0x3E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xFC, 0x7F, 0x3F, 0x1F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x60, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 57 - 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60 // 58 - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/gTextBigFont/gTextBigFont.ino b/GD32F1/libraries/ILI9341_due_STM/examples/gTextBigFont/gTextBigFont.ino deleted file mode 100644 index 66362ea..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/gTextBigFont/gTextBigFont.ino +++ /dev/null @@ -1,63 +0,0 @@ -#include //uncomment when using SPI_MODE_NORMAL or SPI_MODE_EXTENDED -#include -#include -#include -#include - -#include "fonts\jokerman_255.h" - -#define TFT_DC 10 -#define TFT_CS 8 -#define TFT_RST 9 - -ILI9341_due myTFT(TFT_CS, TFT_DC, TFT_RST); -ILI9341_due_gText t1(&myTFT); - -void setup() -{ - Serial.begin(9600); - - bool result = myTFT.begin(); - - Serial.print("TFT begin successful: "); - Serial.println(result ? "YES" : "NO"); - myTFT.fillScreen(ILI9341_BLACK); - - t1.defineArea(18, 32, 222, 287); - t1.selectFont(jokerman_255); - //t1.setFontMode(gTextFontMode_Transparent); -} - -void loop() -{ - t1.setFontColor(255,230,0,0,0,0); - t1.drawString("0", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(232,157,12); - t1.drawString("1", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(255,88,0); - t1.drawString("2", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(232,12,15); - t1.drawString("3", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(227,13,255); - t1.drawString("4", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(57,0,255); - t1.drawString("5", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(12,103,232); - t1.drawString("6", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(0,255,243); - t1.drawString("7", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(12,232,73); - t1.drawString("8", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); - t1.setFontColor(132,255,13); - t1.drawString("9", gTextAlignMiddleCenter, gTextEraseFullLine); - delay(750); -} diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/gTextHelloWorld/gTextHelloWorld.ino b/GD32F1/libraries/ILI9341_due_STM/examples/gTextHelloWorld/gTextHelloWorld.ino deleted file mode 100644 index 7953374..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/gTextHelloWorld/gTextHelloWorld.ino +++ /dev/null @@ -1,39 +0,0 @@ -//#include //uncomment when using SPI_MODE_NORMAL or SPI_MODE_EXTENDED -#include -#include -#include -#include - -#include "fonts\Arial_bold_14.h" - -#define TFT_CS 10 -#define TFT_DC 9 - -ILI9341_due myTFT(TFT_CS, TFT_DC); - -void setup() -{ - Serial.begin(9600); - - bool result = myTFT.begin(); - - Serial.print("TFT begin successful: "); - Serial.println(result ? "YES" : "NO"); - - myTFT.fillScreen(ILI9341_BLUE); - myTFT.setRotation(iliRotation270); - - ILI9341_due_gText t1(&myTFT); - t1.defineArea(100, 110, 220, 130); - t1.selectFont(Arial_bold_14); - t1.setFontLetterSpacing(5); - t1.setFontColor(ILI9341_WHITE, ILI9341_BLUE); - t1.drawString("Hello World", gTextAlignMiddleCenter); -} - -void loop() -{ - - /* add main program code here */ - -} diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/graphicstest/graphicstest.ino b/GD32F1/libraries/ILI9341_due_STM/examples/graphicstest/graphicstest.ino deleted file mode 100644 index 09bbeeb..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/graphicstest/graphicstest.ino +++ /dev/null @@ -1,410 +0,0 @@ -/*************************************************** - This is our GFX example for the Adafruit ILI9341 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -//#include - -#include -#include -#include -#include -#include - -// For the Adafruit shield, these are the default. - -// For the Adafruit shield, these are the default. -#define TFT_DC PA15 -#define TFT_CS PB4 -#define rst PB3 - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, rst); - -void setup() { - delay (5000); - Serial.begin(115200); - while (!Serial) ; // wait for Arduino Serial Monitor - Serial.println("ILI9341 Test!"); - - tft.begin(); - - // read diagnostics (optional but can help debug problems) - uint8_t x = tft.readcommand8(ILI9341_RDMODE); - Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDMADCTL); - Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDPIXFMT); - Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDIMGFMT); - Serial.print("Image Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDSELFDIAG); - Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); - - Serial.println(F("Benchmark Time (microseconds)")); - - Serial.print(F("Screen fill ")); - Serial.println(testFillScreen()); - delay(200); - - Serial.print(F("Text ")); - Serial.println(testText()); - delay(600); - - Serial.print(F("Lines ")); - Serial.println(testLines(ILI9341_CYAN)); - delay(200); - - Serial.print(F("Horiz/Vert Lines ")); - Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE)); - delay(200); - - Serial.print(F("Rectangles (outline) ")); - Serial.println(testRects(ILI9341_GREEN)); - delay(200); - - Serial.print(F("Rectangles (filled) ")); - Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); - delay(200); - - Serial.print(F("Circles (filled) ")); - Serial.println(testFilledCircles(10, ILI9341_MAGENTA)); - - Serial.print(F("Circles (outline) ")); - Serial.println(testCircles(10, ILI9341_WHITE)); - delay(200); - - Serial.print(F("Triangles (outline) ")); - Serial.println(testTriangles()); - delay(200); - - Serial.print(F("Triangles (filled) ")); - Serial.println(testFilledTriangles()); - delay(200); - - Serial.print(F("Rounded rects (outline) ")); - Serial.println(testRoundRects()); - delay(200); - - Serial.print(F("Rounded rects (filled) ")); - Serial.println(testFilledRoundRects()); - delay(200); - - Serial.println(F("Done!")); - -} - - -void loop(void) { - runTests(); - return; - for(uint8_t rotation=0; rotation<4; rotation++) { - tft.setRotation((iliRotation)rotation); - testText(); - delay(1000); - } -} - -void runTests() -{ - Serial.print(F("Screen fill ")); - Serial.println(testFillScreen()); -// delay(200); - - Serial.print(F("Text ")); - Serial.println(testText()); - // delay(600); - - Serial.print(F("Lines ")); - Serial.println(testLines(ILI9341_CYAN)); -// delay(200); - - Serial.print(F("Horiz/Vert Lines ")); - Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE)); -// delay(200); - - Serial.print(F("Rectangles (outline) ")); - Serial.println(testRects(ILI9341_GREEN)); - delay(200); - - Serial.print(F("Rectangles (filled) ")); - Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); -// delay(200); - - Serial.print(F("Circles (filled) ")); - Serial.println(testFilledCircles(10, ILI9341_MAGENTA)); - - Serial.print(F("Circles (outline) ")); - Serial.println(testCircles(10, ILI9341_WHITE)); -// delay(200); - - Serial.print(F("Triangles (outline) ")); - Serial.println(testTriangles()); -// delay(200); - - Serial.print(F("Triangles (filled) ")); - Serial.println(testFilledTriangles()); -// delay(200); - - Serial.print(F("Rounded rects (outline) ")); - Serial.println(testRoundRects()); -// delay(200); - - Serial.print(F("Rounded rects (filled) ")); - Serial.println(testFilledRoundRects()); -// delay(200); - - -} - -unsigned long testFillScreen() { - unsigned long start = micros(); -// tft.fillScreen(ILI9341_BLACK); - tft.fillScreen(ILI9341_RED); - tft.fillScreen(ILI9341_GREEN); - tft.fillScreen(ILI9341_BLUE); - tft.fillScreen(ILI9341_BLACK); - return micros() - start; -} - -unsigned long testText() { - tft.fillScreen(ILI9341_BLACK); - unsigned long start = micros(); - tft.setCursor(0, 0); - tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); - tft.println("Hello World!"); - tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2); - tft.println(1234.56); - tft.setTextColor(ILI9341_RED); tft.setTextSize(3); - tft.println(0xDEADBEEF, HEX); - tft.println(); - tft.setTextColor(ILI9341_GREEN); - tft.setTextSize(5); - tft.println("Groop"); - tft.setTextSize(2); - tft.println("I implore thee,"); - tft.setTextSize(1); - tft.println("my foonting turlingdromes."); - tft.println("And hooptiously drangle me"); - tft.println("with crinkly bindlewurdles,"); - tft.println("Or I will rend thee"); - tft.println("in the gobberwarts"); - tft.println("with my blurglecruncheon,"); - tft.println("see if I don't!"); - return micros() - start; -} - -unsigned long testLines(uint16_t color) { - unsigned long start, t; - int x1, y1, x2, y2, - w = tft.width(), - h = tft.height(); - - tft.fillScreen(ILI9341_BLACK); - - x1 = y1 = 0; - y2 = h - 1; - start = micros(); - for(x2=0; x20; i-=6) { - i2 = i / 2; - start = micros(); - tft.fillRect(cx-i2, cy-i2, i, i, color1); - t += micros() - start; - // Outlines are not included in timing results - tft.drawRect(cx-i2, cy-i2, i, i, color2); - } - - return t; -} - -unsigned long testFilledCircles(uint8_t radius, uint16_t color) { - unsigned long start; - int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; - - tft.fillScreen(ILI9341_BLACK); - start = micros(); - for(x=radius; x10; i-=5) { - start = micros(); - tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(0, i, i)); - t += micros() - start; - tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(i, i, 0)); - } - - return t; -} - -unsigned long testRoundRects() { - unsigned long start; - int w, i, i2, - cx = tft.width() / 2 - 1, - cy = tft.height() / 2 - 1; - - tft.fillScreen(ILI9341_BLACK); - w = min(tft.width(), tft.height()); - start = micros(); - for(i=0; i20; i-=6) { - i2 = i / 2; - tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); - } - - return micros() - start; -} diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/graphicstestWithStats/graphicstestWithStats.ino b/GD32F1/libraries/ILI9341_due_STM/examples/graphicstestWithStats/graphicstestWithStats.ino deleted file mode 100644 index 74f1528..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/graphicstestWithStats/graphicstestWithStats.ino +++ /dev/null @@ -1,427 +0,0 @@ -/*************************************************** -This is our GFX example for the Adafruit ILI9341 Breakout and Shield -----> http://www.adafruit.com/products/1651 - -Check out the links above for our tutorials and wiring diagrams -These displays use SPI to communicate, 4 or 5 pins are required to -interface (RST is optional) -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -MIT license, all text above must be included in any redistribution -****************************************************/ -#include -#include -#include -#include -#include -#include "fonts\Arial_bold_14.h" - - -#define TFT_DC 10 -#define TFT_CS 8 -#define TFT_RST 9 - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, TFT_RST); - -ILI9341_due_gText t1(&tft); -long Screenfill, - Text, - Lines, - HorizVertLines, - Rectanglesoutline, - Rectanglesfilled, - Circlesfilled, - Circlesoutline, - Trianglesoutline, - Trianglesfilled, - Roundedrectsoutline, - Roundedrectsfilled; - -void setup() { - - - Serial.begin(9600); - while (!Serial) ; // wait for Arduino Serial Monitor - Serial.println("ILI9341 Test!"); - - tft.begin(); - tft.setRotation(iliRotation270); - tft.fillScreen(ILI9341_BLUE); - t1.defineArea(30, 30, 26, 12, Arial_bold_14); - t1.selectFont(Arial_bold_14); - t1.setFontLetterSpacing(2); - t1.setFontColor(ILI9341_WHITE, ILI9341_BLUE); - -#if SPI_MODE_NORMAL - char mode[] = "SPI_MODE_NORMAL"; -#elif SPI_MODE_EXTENDED - char mode[] = "SPI_MODE_EXTENDED"; -#elif SPI_MODE_DMA - char mode[] = "SPI_MODE_DMA"; - -#endif - t1.drawString(mode, tft.width()/2 - t1.stringWidth(mode) / 2 - 30, 80); - - delay(3000); - tft.setRotation(iliRotation0); - // read diagnostics (optional but can help debug problems) - uint8_t x = tft.readcommand8(ILI9341_RDMODE); - Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDMADCTL); - Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDPIXFMT); - Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDIMGFMT); - Serial.print("Image Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9341_RDSELFDIAG); - Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); - - Serial.println(F("Benchmark Time (microseconds)")); - - Serial.print(F("Screen fill ")); - unsigned long start = micros(); - Serial.println(Screenfill = testFillScreen()); - // delay(200); - - Serial.print(F("Text ")); - Serial.println(Text = testText()); - // delay(200); - - Serial.print(F("Lines ")); - Serial.println(Lines = testLines(ILI9341_CYAN)); - // delay(200); - - Serial.print(F("Horiz/Vert Lines ")); - Serial.println(HorizVertLines = testFastLines(ILI9341_RED, ILI9341_BLUE)); - // delay(200); - - Serial.print(F("Rectangles (outline) ")); - Serial.println(Rectanglesoutline = testRects(ILI9341_GREEN)); - // delay(200); - - Serial.print(F("Rectangles (filled) ")); - Serial.println(Rectanglesfilled = testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); - // delay(200); - - Serial.print(F("Circles (filled) ")); - Serial.println(Circlesfilled = testFilledCircles(10, ILI9341_MAGENTA)); - - Serial.print(F("Circles (outline) ")); - Serial.println(Circlesoutline = testCircles(10, ILI9341_WHITE)); - // delay(200); - - Serial.print(F("Triangles (outline) ")); - Serial.println(Trianglesoutline = testTriangles()); - // delay(200); - - Serial.print(F("Triangles (filled) ")); - Serial.println(Trianglesfilled = testFilledTriangles()); - // delay(200); - - Serial.print(F("Rounded rects (outline) ")); - Serial.println(Roundedrectsoutline = testRoundRects()); - // delay(200); - - Serial.print(F("Rounded rects (filled) ")); - Serial.println(Roundedrectsfilled = testFilledRoundRects()); - // delay(200); - - - Serial.println(F("Done!")); - - tft.fillScreen(ILI9341_BLUE); - tft.setRotation(iliRotation270); - t1.cursorToXY(45, 80); - t1.print("Total time: "); - t1.print((micros() - start)/1000); - t1.print(" ms"); - - delay(2000); - printStats(); - -} - -void printStats() -{ - tft.setRotation(iliRotation270); - tft.fillScreen(ILI9341_BLUE); - t1.cursorTo(0, 0); - t1.print("Screen fill "); t1.cursorTo(18); t1.print(Screenfill); - t1.cursorTo(0, 1); - t1.print("Text "); t1.cursorTo(18); t1.print(Text); - t1.cursorTo(0, 2); - t1.print("Lines "); t1.cursorTo(18); t1.print(Lines); - t1.cursorTo(0, 3); - t1.print("Horiz/Vert Lines "); t1.cursorTo(18); t1.print(HorizVertLines); - t1.cursorTo(0, 4); - t1.print("Rectangles (outline) "); t1.cursorTo(18); t1.print(Rectanglesoutline); - t1.cursorTo(0, 5); - t1.print("Rectangles (filled) "); t1.cursorTo(18); t1.print(Rectanglesfilled); - t1.cursorTo(0, 6); - t1.print("Circles (filled) "); t1.cursorTo(18); t1.print(Circlesfilled); - t1.cursorTo(0, 7); - t1.print("Circles (outline) "); t1.cursorTo(18); t1.print(Circlesoutline); - t1.cursorTo(0, 8); - t1.print("Triangles (outline) "); t1.cursorTo(18); t1.print(Trianglesoutline); - t1.cursorTo(0, 9); - t1.print("Triangles (filled) "); t1.cursorTo(18); t1.print(Trianglesfilled); - t1.cursorTo(0, 10); - t1.print("Rounded rects (outline) "); t1.cursorTo(18); t1.print(Roundedrectsoutline); - t1.cursorTo(0, 11); - t1.print("Rounded rects (filled) "); t1.cursorTo(18); t1.print(Roundedrectsfilled); - -} - -void loop(void) { - /*for(uint8_t rotation=0; rotation<4; rotation++) { - tft.setRotation(rotation); - testText(); - delay(1000); - }*/ -} - -unsigned long testFillScreen() { - unsigned long start = micros(); - tft.fillScreen(ILI9341_BLACK); - tft.fillScreen(ILI9341_RED); - tft.fillScreen(ILI9341_GREEN); - tft.fillScreen(ILI9341_BLUE); - tft.fillScreen(ILI9341_BLACK); - return micros() - start; -} - -unsigned long testText() { - tft.fillScreen(ILI9341_BLACK); - unsigned long start = micros(); - tft.setCursor(0, 0); - tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); - tft.println("Hello World!"); - tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2); - tft.println(1234.56); - tft.setTextColor(ILI9341_RED); tft.setTextSize(3); - tft.println(0xDEADBEEF, HEX); - tft.println(); - tft.setTextColor(ILI9341_GREEN); - tft.setTextSize(5); - tft.println("Groop"); - tft.setTextSize(2); - tft.println("I implore thee,"); - tft.setTextSize(1); - tft.println("my foonting turlingdromes."); - tft.println("And hooptiously drangle me"); - tft.println("with crinkly bindlewurdles,"); - tft.println("Or I will rend thee"); - tft.println("in the gobberwarts"); - tft.println("with my blurglecruncheon,"); - tft.println("see if I don't!"); - return micros() - start; -} - -unsigned long testLines(uint16_t color) { - unsigned long start, t; - int x1, y1, x2, y2, - w = tft.width(), - h = tft.height(); - - tft.fillScreen(ILI9341_BLACK); - - x1 = y1 = 0; - y2 = h - 1; - start = micros(); - for(x2=0; x20; i-=6) { - i2 = i / 2; - start = micros(); - tft.fillRect(cx-i2, cy-i2, i, i, color1); - t += micros() - start; - // Outlines are not included in timing results - tft.drawRect(cx-i2, cy-i2, i, i, color2); - } - - return t; -} - -unsigned long testFilledCircles(uint8_t radius, uint16_t color) { - unsigned long start; - int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; - - tft.fillScreen(ILI9341_BLACK); - start = micros(); - for(x=radius; x10; i-=5) { - start = micros(); - tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(0, i, i)); - t += micros() - start; - tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(i, i, 0)); - } - - return t; -} - -unsigned long testRoundRects() { - unsigned long start; - int w, i, i2, - cx = tft.width() / 2 - 1, - cy = tft.height() / 2 - 1; - - tft.fillScreen(ILI9341_BLACK); - w = min(tft.width(), tft.height()); - start = micros(); - for(i=0; i20; i-=6) { - i2 = i / 2; - tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); - } - - return micros() - start; -} diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/blacklab.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/blacklab.565 deleted file mode 100644 index 3fc8152..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/blacklab.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/blacklab.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/blacklab.bmp deleted file mode 100644 index b54b5cc..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/blacklab.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/giraffe.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/giraffe.565 deleted file mode 100644 index 5f99b1f..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/giraffe.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/giraffe.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/giraffe.bmp deleted file mode 100644 index 92f8e5d..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/giraffe.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/gloomyTears.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/gloomyTears.565 deleted file mode 100644 index cb7b693..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/gloomyTears.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/gloomyTears.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/gloomyTears.bmp deleted file mode 100644 index 1e5ca62..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/gloomyTears.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/health.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/health.565 deleted file mode 100644 index b8865f5..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/health.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/health.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/health.bmp deleted file mode 100644 index a847172..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/health.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/lambo.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/lambo.565 deleted file mode 100644 index e63b389..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/lambo.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/lambo.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/lambo.bmp deleted file mode 100644 index 99d4fa9..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/lambo.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/motivation.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/motivation.565 deleted file mode 100644 index 21cbc4f..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/motivation.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/motivation.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/motivation.bmp deleted file mode 100644 index 3dcd703..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/motivation.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/origP.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/origP.565 deleted file mode 100644 index 4f0fdc9..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/origP.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/origP.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/origP.bmp deleted file mode 100644 index 00f63c1..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/origP.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/radioP.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/radioP.565 deleted file mode 100644 index 56dc97e..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/radioP.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/radioP.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/radioP.bmp deleted file mode 100644 index dfb1ca6..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/radioP.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/smokeP.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/smokeP.565 deleted file mode 100644 index 87c64d8..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/smokeP.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/smokeP.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/smokeP.bmp deleted file mode 100644 index e4d29eb..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/smokeP.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/soldHouse.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/soldHouse.565 deleted file mode 100644 index 50c157a..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/soldHouse.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/soldHouse.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/soldHouse.bmp deleted file mode 100644 index 5c14038..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/soldHouse.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/stopP.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/stopP.565 deleted file mode 100644 index d56a789..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/stopP.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/stopP.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/stopP.bmp deleted file mode 100644 index c4446e9..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/stopP.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/woof.565 b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/woof.565 deleted file mode 100644 index 0bcd579..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/woof.565 and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/woof.bmp b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/woof.bmp deleted file mode 100644 index abf88f6..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/images/woof.bmp and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/sdFatTftBitmap.ino b/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/sdFatTftBitmap.ino deleted file mode 100644 index 22a4fe3..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/sdFatTftBitmap/sdFatTftBitmap.ino +++ /dev/null @@ -1,320 +0,0 @@ -/* -This sketch is demonstrating loading images from an SD card. -To run this sketch, copy images from the images folder into the root of an SD card -(either those with .bmp extension or those with .565 extension (those will load faster)). -Modify the extension of the files in loop() depending on which files you copied onto SD. - -Depending on the length of the cables between Arduino and SD card pins you might want -to change SD_SPI_SPEED to either SPI_FULL_SPEED (if you have a shield directly connected to -Arduino pins) or SPI_QUARTER_SPEED if you have long cables. SPI_HALF_SPEED was the maximum -I could use as I had the display with SD slot on a breadboard. -Obviously you have to modify CS, DC pins for TFT and SD appropriately. - -You can generate your own .565 images from 24bit BMPs by using BMP24toILI565 converter which -you can find in the Tools folder on GitHub: -https://github.com/marekburiak/ILI9341_due/tree/master/tools -*/ - -#include -#include -#include -#include -#include -#include -#include - -// CS and DC for the LCD -#define LCD_CS 10 // Chip Select for LCD -#define LCD_DC 9 // Command/Data for LCD - -#define SD_CS 7 // Chip Select for SD card - -#define BUFFPIXELCOUNT 320 // size of the buffer in pixels -#define SD_SPI_SPEED SPI_HALF_SPEED // SD card SPI speed, try SPI_FULL_SPEED - -SdFat sd; // set filesystem -SdFile bmpFile; // set filesystem -//ArduinoOutStream cout(Serial); - -ILI9341_due tft(LCD_CS, LCD_DC); - -// store error strings in flash to save RAM -#define error(s) sd.errorHalt_P(PSTR(s)) - -void setup() -{ - Serial.begin(9600); - - tft.begin(); - tft.setRotation(iliRotation270); // landscape - progmemPrint(PSTR("Initializing SD card...")); - - if (!sd.begin(SD_CS, SD_SPI_SPEED)){ - progmemPrintln(PSTR("failed!")); - return; - } - progmemPrintln(PSTR("OK!")); -} - -void loop() -{ - if (tft.getRotation() == iliRotation90 || tft.getRotation() == iliRotation270){ - bmpDraw("giraffe.565", 0, 0); - delay(2000); - bmpDraw("SOLDHO~1.565", 0, 0); - delay(2000); - bmpDraw("GLOOMY~1.565", 0, 0); - delay(2000); - bmpDraw("MOTIVA~1.565", 0, 0); - delay(2000); - } - else - { - bmpDraw("smokeP.565", 0, 0); - delay(2000); - bmpDraw("origP.565", 0, 0); - delay(2000); - bmpDraw("radioP.565", 0, 0); - delay(2000); - bmpDraw("stopP.565", 0, 0); - delay(2000); - } - -} - -// This function opens a Windows Bitmap (BMP) file and -// displays it at the given coordinates. It's sped up -// by reading many pixels worth of data at a time -// (rather than pixel by pixel). Increasing the buffer -// size takes more of the Arduino's RAM but -// makes loading a little faster. - -void bmpDraw(char* filename, int x, int y) { - - SdFile bmpFile; - int bmpWidth, bmpHeight; // W+H in pixels - uint8_t bmpDepth; // Bit depth (currently must be 24) - uint8_t headerSize; - uint32_t bmpImageoffset; // Start of image data in file - uint32_t rowSize; // Not always = bmpWidth; may have padding - uint32_t fileSize; - boolean goodBmp = false; // Set to true on valid header parse - boolean flip = true; // BMP is stored bottom-to-top - uint16_t w, h, row, col; - uint8_t r, g, b; - uint32_t pos = 0, startTime; - - if ((x >= tft.width()) || (y >= tft.height())) return; - - progmemPrint(PSTR("Loading image '")); - Serial.print(filename); - Serial.println('\''); - startTime = millis(); - // Open requested file on SD card - if (!bmpFile.open(filename, O_READ)) { - Serial.println("File open failed."); - return; - } - else { - //Serial.println("File opened."); - } - - // Parse BMP header - if (read16(bmpFile) == 0x4D42) { // BMP signature - fileSize = read32(bmpFile); - //progmemPrint(PSTR("File size: ")); Serial.println(fileSize); - (void)read32(bmpFile); // Read & ignore creator bytes - bmpImageoffset = read32(bmpFile); // Start of image data - //progmemPrint(PSTR("Image Offset: ")); Serial.println(bmpImageoffset, DEC); - // Read DIB header - headerSize = read32(bmpFile); - //progmemPrint(PSTR("Header size: ")); Serial.println(headerSize); - bmpWidth = read32(bmpFile); - bmpHeight = read32(bmpFile); - if (read16(bmpFile) == 1) { // # planes -- must be '1' - bmpDepth = read16(bmpFile); // bits per pixel - //progmemPrint(PSTR("Bit Depth: ")); Serial.println(bmpDepth); - if (read32(bmpFile) == 0) // 0 = uncompressed - { - //progmemPrint(PSTR("Image size: ")); - //Serial.print(bmpWidth); - //Serial.print('x'); - //Serial.println(bmpHeight); - - // If bmpHeight is negative, image is in top-down order. - // This is not canon but has been observed in the wild. - if (bmpHeight < 0) { - bmpHeight = -bmpHeight; - flip = false; - } - - // Crop area to be loaded - w = bmpWidth; - h = bmpHeight; - if ((x + w - 1) >= tft.width()) w = tft.width() - x; - if ((y + h - 1) >= tft.height()) h = tft.height() - y; - - // Set TFT address window to clipped image bounds - tft.setAddrWindow(x, y, x + w - 1, y + h - 1); - - if (bmpDepth == 16) //565 format - { - goodBmp = true; // Supported BMP format -- proceed! - - uint8_t buffer[2 * BUFFPIXELCOUNT]; // pixel buffer (contains already formatted data for ILI9341 display) - - bmpFile.seekSet(54); //skip header - uint32_t totalPixels = bmpWidth*bmpHeight; - uint16_t numFullBufferRuns = totalPixels / BUFFPIXELCOUNT; - for (uint32_t p = 0; p < numFullBufferRuns; p++) { - // read pixels into the buffer - bmpFile.read(buffer, 2 * BUFFPIXELCOUNT); - // push them to the diplay - tft.pushColors565(buffer, 0, 2 * BUFFPIXELCOUNT); - } - - // render any remaining pixels that did not fully fit the buffer - uint32_t remainingPixels = totalPixels % BUFFPIXELCOUNT; - if (remainingPixels > 0) - { - bmpFile.read(buffer, 2 * remainingPixels); - tft.pushColors565(buffer, 0, 2 * remainingPixels); - } - - } - else if (bmpDepth == 24) // standard 24bit bmp - { - goodBmp = true; // Supported BMP format -- proceed! - uint16_t bufferSize = min(w, BUFFPIXELCOUNT); - uint8_t sdbuffer[3 * bufferSize]; // pixel in buffer (R+G+B per pixel) - uint16_t lcdbuffer[bufferSize]; // pixel out buffer (16-bit per pixel) - - // BMP rows are padded (if needed) to 4-byte boundary - rowSize = (bmpWidth * 3 + 3) & ~3; - - for (row = 0; row < h; row++) { // For each scanline... - // Seek to start of scan line. It might seem labor- - // intensive to be doing this on every line, but this - // method covers a lot of gritty details like cropping - // and scanline padding. Also, the seek only takes - // place if the file position actually needs to change - // (avoids a lot of cluster math in SD library). - - if (flip) // Bitmap is stored bottom-to-top order (normal BMP) - pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize; - else // Bitmap is stored top-to-bottom - pos = bmpImageoffset + row * rowSize; - if (bmpFile.curPosition() != pos) { // Need seek? - bmpFile.seekSet(pos); - } - - for (col = 0; col < w; col += bufferSize) - { - // read pixels into the buffer - bmpFile.read(sdbuffer, 3 * bufferSize); - - // convert color - for (int p = 0; p < bufferSize; p++) - { - b = sdbuffer[3 * p]; - g = sdbuffer[3 * p + 1]; - r = sdbuffer[3 * p + 2]; - lcdbuffer[p] = tft.color565(r, g, b); - } - // push buffer to TFT - tft.pushColors(lcdbuffer, 0, bufferSize); - } - - // render any remaining pixels that did not fully fit the buffer - uint16_t remainingPixels = w % bufferSize; - if (remainingPixels > 0) - { - bmpFile.read(sdbuffer, 3 * remainingPixels); - - for (int p = 0; p < remainingPixels; p++) - { - b = sdbuffer[3 * p]; - g = sdbuffer[3 * p + 1]; - r = sdbuffer[3 * p + 2]; - lcdbuffer[p] = tft.color565(r, g, b); - } - - tft.pushColors(lcdbuffer, 0, remainingPixels); - } - } - } - else - { - progmemPrint(PSTR("Unsupported Bit Depth.")); - } - - if (goodBmp) - { - progmemPrint(PSTR("Loaded in ")); - Serial.print(millis() - startTime); - Serial.println(" ms"); - } - } - } - } - - bmpFile.close(); - if (!goodBmp) progmemPrintln(PSTR("BMP format not recognized.")); -} - - -// These read 16- and 32-bit types from the SD card file. -// BMP data is stored little-endian, Arduino is little-endian too. -// May need to reverse subscript order if porting elsewhere. - -uint16_t read16(SdFile& f) { - uint16_t result; - ((uint8_t *)&result)[0] = f.read(); // LSB - ((uint8_t *)&result)[1] = f.read(); // MSB - return result; -} - -uint32_t read32(SdFile& f) { - uint32_t result; - ((uint8_t *)&result)[0] = f.read(); // LSB - ((uint8_t *)&result)[1] = f.read(); - ((uint8_t *)&result)[2] = f.read(); - ((uint8_t *)&result)[3] = f.read(); // MSB - return result; -} - -// Copy string from flash to serial port -// Source string MUST be inside a PSTR() declaration! -void progmemPrint(const char *str) { - char c; - while (c = pgm_read_byte(str++)) Serial.print(c); -} - -// Same as above, with trailing newline -void progmemPrintln(const char *str) { - progmemPrint(str); - Serial.println(); -} - -//void PrintHex8(uint8_t *data, uint8_t length) // prints 8-bit data in hex -//{ -// char tmp[length*5+1]; -// byte first; -// byte second; -// for (int i=0; i> 4) & 0x0f; -// second = data[i] & 0x0f; -// // base for converting single digit numbers to ASCII is 48 -// // base for 10-16 to become upper-case characters A-F is 55 -// // note: difference is 7 -// tmp[i*5] = 48; // add leading 0 -// tmp[i*5+1] = 120; // add leading x -// tmp[i*5+2] = first+48; -// tmp[i*5+3] = second+48; -// tmp[i*5+4] = 32; // add trailing space -// if (first > 9) tmp[i*5+2] += 7; -// if (second > 9) tmp[i*5+3] += 7; -// } -// tmp[length*5] = 0; -// Serial.print(tmp); -//} \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/examples/utftDemo/utftDemo.ino b/GD32F1/libraries/ILI9341_due_STM/examples/utftDemo/utftDemo.ino deleted file mode 100644 index 0aec4ea..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/examples/utftDemo/utftDemo.ino +++ /dev/null @@ -1,341 +0,0 @@ -// UTFT Demo ported to ILI9341_due library by TFTLCDCyg - -// Based on Demo 320x240 Serial of UTFT library -// UTFT-web: http://www.henningkarlsen.com/electronics - -#include - -// ILI9341_due NEW lib by Marek Buriak http://marekburiak.github.io/ILI9341_due/ -#include -#include -#include -#include -#include -#include "fonts\Arial14.h" -//#include "Streaming.h" -// For the Adafruit shield, these are the default. - -#define TFT_DC 10 -#define TFT_CS 8 -#define rst 9 - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, rst); - -ILI9341_due_gText t1(&tft); -char textBuff[20]; - -// Color set -#define BLACK 0x0000 -#define RED 0xF800 -#define GREEN 0x07E0 -//#define BLUE 0x001F -#define BLUE 0x102E -#define CYAN 0x07FF -#define MAGENTA 0xF81F -#define YELLOW 0xFFE0 -#define ORANGE 0xFD20 -#define GREENYELLOW 0xAFE5 -#define DARKGREEN 0x03E0 -#define WHITE 0xFFFF - -uint16_t color; -uint16_t colorFONDO=BLACK; - -void setup() -{ - delay (5000); - randomSeed(analogRead(0)); - - // TFT 2.2" SPI - Serial.begin(115200); - tft.begin(); - tft.setRotation(iliRotation270); - tft.fillScreen(colorFONDO); - t1.defineArea(0, 0, 320, 240); - t1.selectFont(Arial14); -} - -void ILI9341duenodelay() -{ - int buf[318]; - int x, x2; - int y, y2; - int r; - - tft.fillScreen(colorFONDO); - - int timeinit= millis(); - - -//ILI9341due NEW - tft.fillRect(0, 0, 320, 15,RED); - t1.setFontColor(WHITE, RED); - t1.drawString("* ILI9341_due UTFT 240x320 Demo *", 47,0); - tft.fillRect(0, 226, 320, 240,tft.color565(64, 64, 64)); - t1.setFontColor(YELLOW, tft.color565(64, 64, 64)); - t1.drawString("", gTextAlignBottomCenter,227); - -//ILI9341due NEW - tft.drawRect(0, 15, 320, 211,BLUE); - -//ILI9341due NEW -// Draw crosshairs - tft.drawLine(159, 15, 159, 224,BLUE); - tft.drawLine(1, 119, 318, 119,BLUE); - for (int i=9; i<310; i+=10) - tft.drawLine(i, 117, i, 121,BLUE); - for (int i=19; i<220; i+=10) - tft.drawLine(157, i, 161, i, BLUE); -// Draw sin-, cos- and tan-lines - t1.setFontColor(CYAN, BLACK); - t1.drawString("Sin", 5,17); - for (int i=1; i<318; i++) - { - tft.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95),CYAN); - } - t1.setFontColor(RED, BLACK); - t1.drawString("Cos", 5,29); - for (int i=1; i<318; i++) - { - tft.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95),RED); - } - t1.setFontColor(YELLOW, BLACK); - t1.drawString("Tan", 5,41); - for (int i=1; i<318; i++) - { - tft.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)),YELLOW); - } -// delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); - tft.drawLine(159, 16, 159, 224,BLUE); - tft.drawLine(1, 119, 318, 119,BLUE); - -// Draw a moving sinewave - x=1; - for (int i=1; i<(318*20); i++) - { - x++; - if (x==319) - x=1; - if (i>319) - { - if ((x==159)||(buf[x-1]==119)) - color = BLUE; - else - color = BLACK; - tft.drawPixel(x,buf[x-1],color); - } - y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100))); - tft.drawPixel(x,y,CYAN); - buf[x-1]=y; - } -// delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); - -// Draw some filled rectangles - for (int i=1; i<6; i++) - { - switch (i) - { - case 1: - color = MAGENTA; - break; - case 2: - color = RED; - break; - case 3: - color = GREEN; - break; - case 4: - color = BLUE; - break; - case 5: - color = YELLOW; - break; - } - tft.fillRect(70+(i*20), 30+(i*20), 60, 60,color); - } -// delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); - -// Draw some filled, rounded rectangles - for (int i=1; i<6; i++) - { - switch (i) - { - case 1: - color = MAGENTA; - break; - case 2: - color = RED; - break; - case 3: - color = GREEN; - break; - case 4: - color = BLUE; - break; - case 5: - color = YELLOW; - break; - } - tft.fillRoundRect(190-(i*20), 30+(i*20), 60, 60,3,color); - } - // delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); - -// Draw some filled circles - for (int i=1; i<6; i++) - { - switch (i) - { - case 1: - color = MAGENTA; - break; - case 2: - color = RED; - break; - case 3: - color = GREEN; - break; - case 4: - color = BLUE; - break; - case 5: - color = YELLOW; - break; - } - tft.fillCircle(100+(i*20),60+(i*20), 30, color); - } -// delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); - -// Draw some lines in a pattern - for (int i=17; i<222; i+=5) - { - tft.drawLine(1, i, (i*1.44)-10, 224, RED); - } - for (int i=222; i>17; i-=5) - { - tft.drawLine(318, i, (i*1.44)-11, 15,RED); - } - for (int i=222; i>17; i-=5) - { - tft.drawLine(1, i, 331-(i*1.44), 15, CYAN); - } - for (int i=17; i<222; i+=5) - { - tft.drawLine(318, i, 330-(i*1.44), 223, CYAN); - } - // delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); - -// Draw some random circles - for (int i=0; i<100; i++) - { - color = tft.color565(random(255), random(255), random(255)); - x=32+random(256); - y=45+random(146); - r=random(30); - tft.drawCircle(x, y, r, color); - } - // delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); -// Draw some random rectangles - for (int i=0; i<100; i++) - { - color = tft.color565(random(255), random(255), random(255)); - x=2 + random(165); - y=16+ random(100); - x2=random(165); - y2=random(115); - tft.drawRect(x, y, x2, y2, color); - } -// delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); -// Draw some random rounded rectangles - for (int i=0; i<100; i++) - { - color = tft.color565(random(255), random(255), random(255)); - x=2+random(165); - y=16+random(100); - x2=random(165); - y2=random(115); - tft.drawRoundRect(x, y, x2, y2,3,color); - - } - // delay(2000); - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); - - for (int i=0; i<100; i++) - { - color = tft.color565(random(255), random(255), random(255)); - x=2+random(316); - y=16+random(209); - x2=2+random(316); - y2=16+random(209); - tft.drawLine(x, y, x2, y2, color); - } - //delay(2000); - - -//ILI9341due NEW - tft.fillRect(1,16,318,209,BLACK); - - for (int i=0; i<10000; i++) - { - color = tft.color565(random(255), random(255), random(255)); - tft.drawPixel(2+random(316), 16+random(209), color); - } - int timetest = millis() -timeinit; - //delay(2000); - - -//ILI9341due NEW - tft.fillRect(0,0,320,240,BLUE); - tft.fillRoundRect(80, 70, 159, 99,3,RED); - t1.setFontColor(WHITE, RED); - t1.drawString("That's it!", 130,93); - t1.drawString("Restarting in a", 117, 119); - t1.drawString("few seconds...", 117, 132); - - t1.setFontColor(WHITE, BLUE); - t1.drawString("Runtime: (msecs)", 112, 210); - - sprintf(textBuff, "%d", timetest); - t1.drawString(textBuff, 146, 225); -} - -void loop() -{ - ILI9341duenodelay(); - delay(5000); -} - diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/Arial14.h b/GD32F1/libraries/ILI9341_due_STM/fonts/Arial14.h deleted file mode 100644 index 9536adb..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/Arial14.h +++ /dev/null @@ -1,173 +0,0 @@ - - -/* - * - * Arial_14 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : Arial14.h - * Date : 02.05.2008 - * Font size in bytes : 7788 - * Font width : 10 - * Font height : 14 - * Font first char : 32 - * Font last char : 128 - * Font used chars : 96 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef ARIAL_14_H -#define ARIAL_14_H - -#define ARIAL_14_WIDTH 10 -#define ARIAL_14_HEIGHT 14 - -/* - * added to allow fontname to match header file name. - * as well as keep the old name for backward compability - */ - -#define Arial14 Arial_14 - -static const uint8_t Arial_14[] PROGMEM = { - 0x1E, 0x6C, // size - 0x0A, // width - 0x0E, // height - 0x20, // first char - 0x60, // char count - - // char widths - 0x00, 0x01, 0x03, 0x08, 0x07, 0x0A, 0x08, 0x01, 0x03, 0x03, - 0x05, 0x07, 0x01, 0x04, 0x01, 0x04, 0x06, 0x03, 0x06, 0x06, - 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x01, 0x06, 0x06, - 0x06, 0x06, 0x0D, 0x09, 0x07, 0x08, 0x08, 0x07, 0x07, 0x09, - 0x07, 0x01, 0x05, 0x08, 0x07, 0x09, 0x07, 0x09, 0x07, 0x09, - 0x08, 0x07, 0x07, 0x07, 0x09, 0x0D, 0x08, 0x09, 0x08, 0x02, - 0x04, 0x02, 0x05, 0x08, 0x02, 0x06, 0x06, 0x05, 0x06, 0x06, - 0x04, 0x06, 0x06, 0x01, 0x02, 0x06, 0x01, 0x09, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x05, 0x04, 0x06, 0x07, 0x09, 0x06, 0x07, - 0x06, 0x03, 0x01, 0x03, 0x07, 0x07, - - // font data - 0xFE, 0x14, // 33 - 0x1E, 0x00, 0x1E, 0x00, 0x00, 0x00, // 34 - 0x90, 0x90, 0xF8, 0x96, 0x90, 0xF8, 0x96, 0x90, 0x00, 0x1C, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, // 35 - 0x18, 0x24, 0x22, 0xFF, 0x42, 0x42, 0x84, 0x08, 0x10, 0x10, 0x3C, 0x10, 0x08, 0x04, // 36 - 0x1C, 0x22, 0x22, 0x1C, 0xC0, 0x30, 0x8C, 0x42, 0x40, 0x80, 0x00, 0x00, 0x10, 0x0C, 0x00, 0x00, 0x0C, 0x10, 0x10, 0x0C, // 37 - 0x80, 0x5C, 0x22, 0x62, 0x92, 0x0C, 0x80, 0x00, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x08, 0x10, // 38 - 0x1E, 0x00, // 39 - 0xF0, 0x0C, 0x02, 0x1C, 0x60, 0x80, // 40 - 0x02, 0x0C, 0xF0, 0x80, 0x60, 0x1C, // 41 - 0x04, 0x14, 0x0E, 0x14, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, // 42 - 0x40, 0x40, 0x40, 0xF8, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, // 43 - 0x00, 0x70, // 44 - 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, // 45 - 0x00, 0x10, // 46 - 0x00, 0xC0, 0x38, 0x06, 0x18, 0x04, 0x00, 0x00, // 47 - 0xFC, 0x02, 0x02, 0x02, 0x02, 0xFC, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 48 - 0x08, 0x04, 0xFE, 0x00, 0x00, 0x1C, // 49 - 0x0C, 0x02, 0x02, 0x82, 0x42, 0x3C, 0x10, 0x18, 0x14, 0x10, 0x10, 0x10, // 50 - 0x0C, 0x02, 0x22, 0x22, 0x22, 0xDC, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 51 - 0x80, 0x40, 0x30, 0x08, 0x04, 0xFE, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1C, 0x04, // 52 - 0x38, 0x16, 0x12, 0x12, 0x12, 0xE2, 0x0C, 0x10, 0x10, 0x10, 0x18, 0x04, // 53 - 0xF8, 0x44, 0x22, 0x22, 0x22, 0xC4, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 54 - 0x02, 0x02, 0x02, 0xE2, 0x1A, 0x06, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, // 55 - 0xDC, 0x22, 0x22, 0x22, 0x22, 0xDC, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 56 - 0x3C, 0x42, 0x42, 0x42, 0x22, 0xFC, 0x08, 0x10, 0x10, 0x10, 0x08, 0x04, // 57 - 0x08, 0x10, // 58 - 0x08, 0x70, // 59 - 0x40, 0xA0, 0xA0, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x04, 0x04, 0x08, // 60 - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 - 0x08, 0x10, 0x10, 0xA0, 0xA0, 0x40, 0x08, 0x04, 0x04, 0x00, 0x00, 0x00, // 62 - 0x0C, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, // 63 - 0xE0, 0x18, 0x04, 0xC4, 0x22, 0x12, 0x12, 0x12, 0xA2, 0x72, 0x04, 0x08, 0xF0, 0x0C, 0x30, 0x40, 0x4C, 0x90, 0x90, 0x90, 0x88, 0x9C, 0x90, 0x50, 0x4C, 0x20, // 64 - 0x00, 0x80, 0xE0, 0x9C, 0x82, 0x9C, 0xE0, 0x80, 0x00, 0x18, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18, // 65 - 0xFE, 0x22, 0x22, 0x22, 0x22, 0x22, 0xDC, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0C, // 66 - 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x04, 0x08, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, // 67 - 0xFE, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, // 68 - 0xFE, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 69 - 0xFE, 0x22, 0x22, 0x22, 0x22, 0x22, 0x02, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 0xF8, 0x04, 0x02, 0x02, 0x02, 0x42, 0x42, 0x44, 0xC8, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, // 71 - 0xFE, 0x20, 0x20, 0x20, 0x20, 0x20, 0xFE, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, // 72 - 0xFE, 0x1C, // 73 - 0x00, 0x00, 0x00, 0x00, 0xFE, 0x0C, 0x10, 0x10, 0x10, 0x0C, // 74 - 0xFE, 0x80, 0x40, 0x20, 0x50, 0x88, 0x04, 0x02, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x10, // 75 - 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 76 - 0xFE, 0x0C, 0x30, 0xC0, 0x00, 0xC0, 0x30, 0x0C, 0xFE, 0x1C, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, 0x1C, // 77 - 0xFE, 0x04, 0x18, 0x60, 0x80, 0x00, 0xFE, 0x1C, 0x00, 0x00, 0x00, 0x04, 0x08, 0x1C, // 78 - 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, // 79 - 0xFE, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x04, 0x08, 0x10, 0x10, 0x10, 0x14, 0x08, 0x1C, 0x10, // 81 - 0xFE, 0x42, 0x42, 0x42, 0xC2, 0x42, 0x42, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x10, // 82 - 0x1C, 0x22, 0x22, 0x22, 0x42, 0x42, 0x8C, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0C, // 83 - 0x02, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, // 84 - 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x04, 0x08, 0x10, 0x10, 0x10, 0x08, 0x04, // 85 - 0x06, 0x18, 0x60, 0x80, 0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, 0x00, // 86 - 0x06, 0x38, 0xC0, 0x00, 0xC0, 0x3C, 0x02, 0x3C, 0xC0, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, // 87 - 0x02, 0x0C, 0x90, 0x60, 0x60, 0x90, 0x0C, 0x02, 0x10, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x0C, 0x10, // 88 - 0x02, 0x04, 0x18, 0x20, 0xC0, 0x20, 0x18, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, // 89 - 0x00, 0x02, 0x82, 0x42, 0x22, 0x1A, 0x06, 0x02, 0x10, 0x18, 0x14, 0x10, 0x10, 0x10, 0x10, 0x10, // 90 - 0xFE, 0x02, 0xFC, 0x80, // 91 - 0x06, 0x38, 0xC0, 0x00, 0x00, 0x00, 0x04, 0x18, // 92 - 0x02, 0xFE, 0x80, 0xFC, // 93 - 0x20, 0x1C, 0x02, 0x1C, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // 94 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 95 - 0x02, 0x04, 0x00, 0x00, // 96 - 0x10, 0x88, 0x48, 0x48, 0x48, 0xF0, 0x0C, 0x10, 0x10, 0x10, 0x08, 0x1C, // 97 - 0xFE, 0x10, 0x08, 0x08, 0x08, 0xF0, 0x1C, 0x08, 0x10, 0x10, 0x10, 0x0C, // 98 - 0xF0, 0x08, 0x08, 0x08, 0x10, 0x0C, 0x10, 0x10, 0x10, 0x08, // 99 - 0xF0, 0x08, 0x08, 0x08, 0x10, 0xFE, 0x0C, 0x10, 0x10, 0x10, 0x08, 0x1C, // 100 - 0xF0, 0x48, 0x48, 0x48, 0x48, 0x70, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x08, // 101 - 0x08, 0xFC, 0x0A, 0x0A, 0x00, 0x1C, 0x00, 0x00, // 102 - 0xF0, 0x08, 0x08, 0x08, 0x10, 0xF8, 0x4C, 0x90, 0x90, 0x90, 0x88, 0x7C, // 103 - 0xFE, 0x10, 0x08, 0x08, 0x08, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x1C, // 104 - 0xFA, 0x1C, // 105 - 0x00, 0xFA, 0x80, 0x7C, // 106 - 0xFE, 0x80, 0x40, 0xA0, 0x10, 0x08, 0x1C, 0x00, 0x00, 0x00, 0x0C, 0x10, // 107 - 0xFE, 0x1C, // 108 - 0xF8, 0x10, 0x08, 0x08, 0xF0, 0x10, 0x08, 0x08, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1C, // 109 - 0xF8, 0x10, 0x08, 0x08, 0x08, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x1C, // 110 - 0xF0, 0x08, 0x08, 0x08, 0x08, 0xF0, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 111 - 0xF8, 0x10, 0x08, 0x08, 0x08, 0xF0, 0xFC, 0x08, 0x10, 0x10, 0x10, 0x0C, // 112 - 0xF0, 0x08, 0x08, 0x08, 0x10, 0xF8, 0x0C, 0x10, 0x10, 0x10, 0x08, 0xFC, // 113 - 0xF8, 0x10, 0x08, 0x08, 0x1C, 0x00, 0x00, 0x00, // 114 - 0x30, 0x48, 0x48, 0x48, 0x90, 0x08, 0x10, 0x10, 0x10, 0x0C, // 115 - 0x08, 0xFE, 0x08, 0x08, 0x00, 0x1C, 0x10, 0x10, // 116 - 0xF8, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x0C, 0x10, 0x10, 0x10, 0x08, 0x1C, // 117 - 0x18, 0x60, 0x80, 0x00, 0x80, 0x60, 0x18, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, // 118 - 0x18, 0xE0, 0x00, 0xE0, 0x18, 0xE0, 0x00, 0xE0, 0x18, 0x00, 0x04, 0x18, 0x04, 0x00, 0x04, 0x18, 0x04, 0x00, // 119 - 0x08, 0x30, 0xC0, 0xC0, 0x30, 0x08, 0x10, 0x0C, 0x00, 0x00, 0x0C, 0x10, // 120 - 0x18, 0x60, 0x80, 0x00, 0x80, 0x60, 0x18, 0x00, 0x80, 0x8C, 0x70, 0x0C, 0x00, 0x00, // 121 - 0x08, 0x08, 0x88, 0x68, 0x18, 0x08, 0x10, 0x18, 0x14, 0x10, 0x10, 0x10, // 122 - 0x80, 0x7C, 0x02, 0x00, 0x7C, 0x80, // 123 - 0xFE, 0xFC, // 124 - 0x02, 0x7C, 0x80, 0x80, 0x7C, 0x00, // 125 - 0x40, 0x20, 0x20, 0x60, 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 - 0xFC, 0x04, 0x04, 0x04, 0x04, 0x04, 0xFC, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1C // 127 - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/Arial_bold_14.h b/GD32F1/libraries/ILI9341_due_STM/fonts/Arial_bold_14.h deleted file mode 100644 index bf634c6..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/Arial_bold_14.h +++ /dev/null @@ -1,167 +0,0 @@ - - -/* - * - * Arial Bold 14 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : arial_bold_14 - * Date : 29.01.2005 - * Font size in bytes : 8712 - * Font width : 10 - * Font height : 14 - * Font first char : 32 - * Font last char : 128 - * Font used chars : 96 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef ARIAL_BOLD_14_H -#define ARIAL_BOLD_14_H - -#define ARIAL_BOLD_14_WIDTH 10 -#define ARIAL_BOLD_14_HEIGHT 14 - -static const uint8_t Arial_bold_14[] PROGMEM = { - 0x22, 0x08, // size - 0x0A, // width - 0x0E, // height - 0x20, // first char - 0x60, // char count - - // char widths - 0x04, 0x02, 0x05, 0x06, 0x07, 0x08, 0x09, 0x02, 0x03, 0x03, - 0x05, 0x08, 0x02, 0x04, 0x02, 0x04, 0x07, 0x04, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x02, 0x02, 0x07, 0x07, - 0x07, 0x08, 0x0E, 0x09, 0x08, 0x08, 0x08, 0x07, 0x07, 0x09, - 0x08, 0x02, 0x07, 0x08, 0x07, 0x0B, 0x08, 0x09, 0x07, 0x09, - 0x09, 0x07, 0x08, 0x08, 0x09, 0x0D, 0x07, 0x08, 0x08, 0x04, - 0x04, 0x04, 0x06, 0x08, 0x03, 0x07, 0x07, 0x06, 0x07, 0x07, - 0x05, 0x07, 0x07, 0x02, 0x03, 0x06, 0x02, 0x0A, 0x07, 0x07, - 0x07, 0x07, 0x05, 0x06, 0x05, 0x07, 0x07, 0x0B, 0x06, 0x07, - 0x05, 0x05, 0x01, 0x05, 0x07, 0x08, - - // font data - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 32 - 0xFE, 0xFE, 0x18, 0x18, // 33 - 0x1E, 0x1E, 0x00, 0x1E, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, // 34 - 0x90, 0xF8, 0x9E, 0x90, 0xF8, 0x9E, 0x1C, 0x00, 0x00, 0x1C, 0x00, 0x00, // 35 - 0x18, 0x3C, 0x26, 0xFF, 0x66, 0xCC, 0x88, 0x04, 0x0C, 0x18, 0x3C, 0x18, 0x0C, 0x04, // 36 - 0x1C, 0x22, 0x1C, 0xC0, 0x30, 0x8E, 0x40, 0x80, 0x00, 0x00, 0x18, 0x04, 0x00, 0x0C, 0x10, 0x0C, // 37 - 0x80, 0xCC, 0x7E, 0x72, 0xF2, 0xDE, 0x0C, 0x80, 0x00, 0x0C, 0x1C, 0x10, 0x10, 0x10, 0x1C, 0x0C, 0x1C, 0x10, // 38 - 0x1E, 0x1E, 0x00, 0x00, // 39 - 0xF0, 0xFC, 0x06, 0x1C, 0x7C, 0xC0, // 40 - 0x06, 0xFC, 0xF0, 0xC0, 0x7C, 0x1C, // 41 - 0x14, 0x14, 0x0E, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, // 42 - 0x60, 0x60, 0x60, 0xFC, 0xFC, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x00, // 43 - 0x00, 0x00, 0x58, 0x38, // 44 - 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, // 45 - 0x00, 0x00, 0x18, 0x18, // 46 - 0x00, 0xC0, 0x38, 0x06, 0x18, 0x04, 0x00, 0x00, // 47 - 0xF8, 0xFC, 0x0E, 0x06, 0x0E, 0xFC, 0xF8, 0x04, 0x0C, 0x1C, 0x18, 0x1C, 0x0C, 0x04, // 48 - 0x18, 0x0C, 0xFE, 0xFE, 0x00, 0x00, 0x1C, 0x1C, // 49 - 0x18, 0x1C, 0x86, 0xC6, 0x66, 0x3E, 0x1C, 0x18, 0x1C, 0x1C, 0x18, 0x18, 0x18, 0x18, // 50 - 0x88, 0x8C, 0x06, 0x26, 0x26, 0xFE, 0xDC, 0x04, 0x0C, 0x1C, 0x18, 0x18, 0x0C, 0x04, // 51 - 0xC0, 0xE0, 0xB8, 0x8C, 0xFE, 0xFE, 0x80, 0x04, 0x04, 0x04, 0x04, 0x1C, 0x1C, 0x04, // 52 - 0x70, 0x7E, 0x3E, 0x36, 0x36, 0xF6, 0xC6, 0x0C, 0x1C, 0x18, 0x18, 0x18, 0x0C, 0x04, // 53 - 0xF8, 0xFC, 0x6E, 0x66, 0x66, 0xEE, 0xCC, 0x04, 0x0C, 0x18, 0x18, 0x18, 0x1C, 0x0C, // 54 - 0x06, 0x06, 0x06, 0xE6, 0x76, 0x1E, 0x06, 0x00, 0x00, 0x1C, 0x1C, 0x00, 0x00, 0x00, // 55 - 0x9C, 0xFE, 0x66, 0x66, 0x66, 0xFE, 0x9C, 0x0C, 0x1C, 0x18, 0x18, 0x18, 0x1C, 0x0C, // 56 - 0x3C, 0x7E, 0x66, 0x66, 0x66, 0xFC, 0xF8, 0x0C, 0x1C, 0x18, 0x18, 0x1C, 0x0C, 0x04, // 57 - 0x18, 0x18, 0x18, 0x18, // 58 - 0x18, 0x18, 0x58, 0x38, // 59 - 0x60, 0x60, 0xF0, 0xF0, 0x98, 0x98, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x0C, // 60 - 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 - 0x0C, 0x98, 0x98, 0xF0, 0xF0, 0x60, 0x60, 0x0C, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, // 62 - 0x08, 0x0C, 0x06, 0xC6, 0xE6, 0x76, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // 63 - 0xE0, 0x30, 0x08, 0xC4, 0xF6, 0x3A, 0x1A, 0x1A, 0xF2, 0xFA, 0x7E, 0x04, 0x08, 0xF0, 0x0C, 0x30, 0x60, 0x4C, 0x9C, 0x98, 0x98, 0x8C, 0x9C, 0x9C, 0x90, 0x48, 0x4C, 0x20, // 64 - 0x00, 0xC0, 0xF8, 0xBE, 0x86, 0xBE, 0xF8, 0xC0, 0x00, 0x18, 0x1C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1C, 0x18, // 65 - 0xFE, 0xFE, 0x66, 0x66, 0x66, 0x66, 0xFE, 0xDC, 0x1C, 0x1C, 0x18, 0x18, 0x18, 0x18, 0x1C, 0x0C, // 66 - 0xF8, 0xFC, 0x0E, 0x06, 0x06, 0x0E, 0x9C, 0x08, 0x04, 0x0C, 0x1C, 0x18, 0x18, 0x1C, 0x0C, 0x04, // 67 - 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x0E, 0xFC, 0xF8, 0x1C, 0x1C, 0x18, 0x18, 0x18, 0x1C, 0x0C, 0x04, // 68 - 0xFE, 0xFE, 0x66, 0x66, 0x66, 0x66, 0x66, 0x1C, 0x1C, 0x18, 0x18, 0x18, 0x18, 0x18, // 69 - 0xFE, 0xFE, 0x66, 0x66, 0x66, 0x66, 0x06, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 0xF8, 0xFC, 0x0E, 0x06, 0x06, 0xC6, 0xCE, 0xDC, 0xC8, 0x04, 0x0C, 0x1C, 0x18, 0x18, 0x18, 0x18, 0x0C, 0x04, // 71 - 0xFE, 0xFE, 0x60, 0x60, 0x60, 0x60, 0xFE, 0xFE, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, // 72 - 0xFE, 0xFE, 0x1C, 0x1C, // 73 - 0x80, 0x80, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x0C, 0x1C, 0x18, 0x18, 0x18, 0x1C, 0x0C, // 74 - 0xFE, 0xFE, 0x60, 0x30, 0x78, 0xEC, 0x86, 0x02, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x04, 0x1C, 0x18, // 75 - 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x18, 0x18, 0x18, 0x18, 0x18, // 76 - 0xFE, 0xFE, 0x0E, 0x7C, 0xE0, 0x00, 0xE0, 0x7C, 0x0E, 0xFE, 0xFE, 0x1C, 0x1C, 0x00, 0x00, 0x0C, 0x1C, 0x0C, 0x00, 0x00, 0x1C, 0x1C, // 77 - 0xFE, 0xFE, 0x1C, 0x78, 0xE0, 0x80, 0xFE, 0xFE, 0x1C, 0x1C, 0x00, 0x00, 0x04, 0x0C, 0x1C, 0x1C, // 78 - 0xF8, 0xFC, 0x0E, 0x06, 0x06, 0x06, 0x0E, 0xFC, 0xF8, 0x04, 0x0C, 0x1C, 0x18, 0x18, 0x18, 0x1C, 0x0C, 0x04, // 79 - 0xFE, 0xFE, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 0xF8, 0xFC, 0x0E, 0x06, 0x86, 0x06, 0x0E, 0xFC, 0xF8, 0x04, 0x0C, 0x1C, 0x18, 0x18, 0x1C, 0x0C, 0x1C, 0x24, // 81 - 0xFE, 0xFE, 0x66, 0x66, 0xE6, 0xE6, 0xBE, 0x1C, 0x00, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x0C, 0x1C, 0x18, 0x10, // 82 - 0x3C, 0x7E, 0x66, 0x66, 0x66, 0xEE, 0xCC, 0x0C, 0x1C, 0x18, 0x18, 0x18, 0x1C, 0x0C, // 83 - 0x06, 0x06, 0x06, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x00, 0x00, 0x00, // 84 - 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x04, 0x0C, 0x1C, 0x18, 0x18, 0x1C, 0x0C, 0x04, // 85 - 0x02, 0x1E, 0xFC, 0xE0, 0x00, 0xE0, 0xFC, 0x1E, 0x02, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x00, 0x00, 0x00, // 86 - 0x06, 0xFE, 0xF8, 0x00, 0xF0, 0xFE, 0x0E, 0xFE, 0xF0, 0x00, 0xF8, 0xFE, 0x06, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x00, 0x00, // 87 - 0x06, 0x0E, 0xF8, 0xF0, 0xF8, 0x0E, 0x06, 0x18, 0x1C, 0x04, 0x00, 0x04, 0x1C, 0x18, // 88 - 0x06, 0x0E, 0x38, 0xF0, 0xF0, 0x38, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x00, 0x00, 0x00, // 89 - 0x06, 0x06, 0x86, 0xE6, 0x76, 0x1E, 0x0E, 0x06, 0x18, 0x1C, 0x1C, 0x18, 0x18, 0x18, 0x18, 0x18, // 90 - 0xFE, 0xFE, 0x06, 0x06, 0xFC, 0xFC, 0xC0, 0xC0, // 91 - 0x06, 0x38, 0xC0, 0x00, 0x00, 0x00, 0x04, 0x18, // 92 - 0x06, 0x06, 0xFE, 0xFE, 0xC0, 0xC0, 0xFC, 0xFC, // 93 - 0x20, 0x38, 0x0E, 0x0E, 0x38, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 94 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 95 - 0x02, 0x06, 0x04, 0x00, 0x00, 0x00, // 96 - 0x10, 0x98, 0xD8, 0x58, 0xF8, 0xF0, 0x00, 0x0C, 0x1C, 0x18, 0x18, 0x0C, 0x1C, 0x10, // 97 - 0xFE, 0xFE, 0x30, 0x18, 0x38, 0xF0, 0xE0, 0x1C, 0x1C, 0x0C, 0x18, 0x1C, 0x0C, 0x04, // 98 - 0xE0, 0xF0, 0x18, 0x18, 0x38, 0x30, 0x04, 0x0C, 0x18, 0x18, 0x1C, 0x0C, // 99 - 0xE0, 0xF0, 0x38, 0x18, 0x30, 0xFE, 0xFE, 0x04, 0x0C, 0x1C, 0x18, 0x0C, 0x1C, 0x1C, // 100 - 0xE0, 0xF0, 0xD8, 0xD8, 0xD8, 0xF0, 0xE0, 0x04, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x08, // 101 - 0x18, 0xFC, 0xFE, 0x1A, 0x1A, 0x00, 0x1C, 0x1C, 0x00, 0x00, // 102 - 0xE0, 0xF0, 0x38, 0x18, 0x30, 0xF8, 0xF8, 0x64, 0xEC, 0xDC, 0xD8, 0xCC, 0xFC, 0x7C, // 103 - 0xFE, 0xFE, 0x30, 0x18, 0x18, 0xF8, 0xF0, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x1C, // 104 - 0xFA, 0xFA, 0x1C, 0x1C, // 105 - 0x00, 0xFA, 0xFA, 0xC0, 0xFC, 0x7C, // 106 - 0xFE, 0xFE, 0xE0, 0xF0, 0x98, 0x08, 0x1C, 0x1C, 0x00, 0x04, 0x1C, 0x18, // 107 - 0xFE, 0xFE, 0x1C, 0x1C, // 108 - 0xF8, 0xF8, 0x10, 0x18, 0xF8, 0xF0, 0x18, 0x18, 0xF8, 0xF0, 0x1C, 0x1C, 0x00, 0x00, 0x1C, 0x1C, 0x00, 0x00, 0x1C, 0x1C, // 109 - 0xF8, 0xF8, 0x30, 0x18, 0x18, 0xF8, 0xF0, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x1C, // 110 - 0xE0, 0xF0, 0x38, 0x18, 0x38, 0xF0, 0xE0, 0x04, 0x0C, 0x1C, 0x18, 0x1C, 0x0C, 0x04, // 111 - 0xF8, 0xF8, 0x30, 0x18, 0x38, 0xF0, 0xE0, 0xFC, 0xFC, 0x0C, 0x18, 0x1C, 0x0C, 0x04, // 112 - 0xE0, 0xF0, 0x38, 0x18, 0x30, 0xF8, 0xF8, 0x04, 0x0C, 0x1C, 0x18, 0x0C, 0xFC, 0xFC, // 113 - 0xF8, 0xF8, 0x30, 0x18, 0x18, 0x1C, 0x1C, 0x00, 0x00, 0x00, // 114 - 0x70, 0xF8, 0xD8, 0xD8, 0xD8, 0x90, 0x08, 0x18, 0x18, 0x18, 0x1C, 0x0C, // 115 - 0x18, 0xFC, 0xFE, 0x18, 0x18, 0x00, 0x0C, 0x1C, 0x18, 0x18, // 116 - 0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x0C, 0x1C, 0x18, 0x18, 0x0C, 0x1C, 0x1C, // 117 - 0x38, 0xF8, 0xC0, 0x00, 0xC0, 0xF8, 0x38, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x00, 0x00, // 118 - 0x18, 0xF8, 0xE0, 0x00, 0xF0, 0x38, 0xF0, 0x00, 0xE0, 0xF8, 0x18, 0x00, 0x00, 0x1C, 0x1C, 0x0C, 0x00, 0x0C, 0x1C, 0x1C, 0x00, 0x00, // 119 - 0x18, 0x38, 0xE0, 0xE0, 0x38, 0x18, 0x18, 0x1C, 0x04, 0x04, 0x1C, 0x18, // 120 - 0x18, 0xF8, 0xE0, 0x00, 0xE0, 0xF8, 0x18, 0x00, 0x84, 0xFC, 0xF8, 0x3C, 0x04, 0x00, // 121 - 0x18, 0x98, 0xD8, 0x78, 0x38, 0x1C, 0x1C, 0x18, 0x18, 0x18, // 122 - 0x80, 0xFC, 0x7E, 0x06, 0x06, 0x00, 0x7C, 0xFC, 0xC0, 0xC0, // 123 - 0xFE, 0xFC, // 124 - 0x06, 0x06, 0x7E, 0xFC, 0x80, 0xC0, 0xC0, 0xFC, 0x7C, 0x00, // 125 - 0x60, 0x30, 0x30, 0x70, 0x60, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 - 0xFE, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1C // 127 - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/Corsiva_12.h b/GD32F1/libraries/ILI9341_due_STM/fonts/Corsiva_12.h deleted file mode 100644 index 74ee8d6..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/Corsiva_12.h +++ /dev/null @@ -1,167 +0,0 @@ - - -/* - * - * Corsiva_12 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : corsiva_12.h - * Date : 29.01.2005 - * Font size in bytes : 5690 - * Font width : 10 - * Font height : 11 - * Font first char : 32 - * Font last char : 128 - * Font used chars : 96 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef CORSIVA_12_H -#define CORSIVA_12_H - -#define CORSIVA_12_WIDTH 10 -#define CORSIVA_12_HEIGHT 11 - -static const uint8_t Corsiva_12[] PROGMEM = { - 0x16, 0x3A, // size - 0x0A, // width - 0x0B, // height - 0x20, // first char - 0x60, // char count - - // char widths - 0x03, 0x02, 0x02, 0x06, 0x05, 0x07, 0x09, 0x01, 0x03, 0x04, - 0x02, 0x05, 0x02, 0x03, 0x01, 0x05, 0x05, 0x04, 0x05, 0x04, - 0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x02, 0x03, 0x05, 0x05, - 0x05, 0x04, 0x07, 0x07, 0x07, 0x06, 0x08, 0x07, 0x07, 0x07, - 0x0A, 0x05, 0x06, 0x09, 0x07, 0x09, 0x0A, 0x06, 0x07, 0x09, - 0x09, 0x06, 0x08, 0x08, 0x08, 0x0B, 0x09, 0x09, 0x07, 0x03, - 0x03, 0x04, 0x03, 0x06, 0x02, 0x04, 0x04, 0x04, 0x06, 0x04, - 0x06, 0x06, 0x04, 0x03, 0x04, 0x06, 0x03, 0x06, 0x04, 0x04, - 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x06, 0x08, 0x07, 0x05, - 0x06, 0x03, 0x01, 0x04, 0x05, 0x06, - - // font data - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 32 - 0x80, 0x3E, 0x00, 0x00, // 33 - 0x08, 0x06, 0x00, 0x00, // 34 - 0xA0, 0x78, 0xAE, 0x78, 0x2E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 35 - 0x80, 0x8C, 0xF2, 0xBF, 0x62, 0x00, 0x20, 0x00, 0x00, 0x00, // 36 - 0x1C, 0x92, 0x7E, 0x0C, 0xE2, 0x90, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 37 - 0x70, 0xC8, 0xA8, 0xB8, 0x6C, 0xBE, 0x02, 0xC2, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // 38 - 0x08, 0x00, // 39 - 0xE0, 0x18, 0x06, 0x60, 0x80, 0x00, // 40 - 0x00, 0x00, 0xC3, 0x3C, 0x40, 0x20, 0x00, 0x00, // 41 - 0x0C, 0x0F, 0x00, 0x00, // 42 - 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 43 - 0x00, 0x80, 0x40, 0x20, // 44 - 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, // 45 - 0x80, 0x00, // 46 - 0x00, 0xC0, 0x30, 0x0C, 0x03, 0x60, 0x00, 0x00, 0x00, 0x00, // 47 - 0x78, 0x84, 0x82, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, // 48 - 0x80, 0x88, 0xFC, 0x86, 0x00, 0x00, 0x00, 0x00, // 49 - 0xC0, 0xC4, 0xA2, 0x92, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, // 50 - 0xC0, 0x80, 0xDA, 0x76, 0x00, 0x00, 0x00, 0x00, // 51 - 0x20, 0x30, 0xA8, 0x7E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 52 - 0x80, 0x80, 0x84, 0x4A, 0x32, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 53 - 0x70, 0xAC, 0x94, 0x72, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 54 - 0xC4, 0x32, 0x0A, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 55 - 0xE0, 0xAC, 0x92, 0x6A, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, // 56 - 0x80, 0x9C, 0x52, 0x72, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, // 57 - 0x80, 0x08, 0x00, 0x00, // 58 - 0x00, 0x80, 0x08, 0x40, 0x20, 0x00, // 59 - 0x30, 0x30, 0x48, 0x48, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 - 0x28, 0x28, 0x28, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 - 0x48, 0x48, 0x48, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // 62 - 0x80, 0x36, 0x12, 0x0C, 0x00, 0x00, 0x00, 0x00, // 63 - 0x70, 0xCC, 0xB4, 0xAA, 0xBA, 0x62, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 64 - 0x00, 0x80, 0x4C, 0x32, 0x2E, 0xFE, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 65 - 0x38, 0x24, 0x86, 0xFA, 0x8E, 0x8A, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 66 - 0xF0, 0x8C, 0x04, 0x02, 0x82, 0x0C, 0x00, 0x20, 0x20, 0x20, 0x00, 0x00, // 67 - 0x38, 0x4C, 0x86, 0xEA, 0x9A, 0x82, 0x46, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 68 - 0x38, 0x84, 0xE2, 0x9E, 0x92, 0xBA, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 69 - 0x1C, 0x86, 0xE2, 0x9E, 0x12, 0x3A, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 0x70, 0x8C, 0x84, 0x82, 0xD2, 0x32, 0x16, 0x00, 0x80, 0x80, 0xC0, 0x20, 0x00, 0x00, // 71 - 0xC0, 0x8C, 0xC2, 0x3A, 0x16, 0x90, 0xF8, 0x86, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 72 - 0x80, 0xC0, 0xFA, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 73 - 0x00, 0x00, 0x0C, 0xC2, 0x3A, 0x06, 0x60, 0x40, 0x40, 0x20, 0x00, 0x00, // 74 - 0x8C, 0x82, 0xF2, 0x1E, 0x78, 0x88, 0x06, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x40, 0x40, // 75 - 0x80, 0xC0, 0xB8, 0x84, 0x82, 0x82, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 76 - 0x80, 0x9C, 0x62, 0x1E, 0xF8, 0x60, 0x90, 0xFC, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 77 - 0x80, 0x0C, 0xE2, 0x12, 0x0E, 0xF0, 0x70, 0x0C, 0x02, 0x02, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 78 - 0x78, 0xC4, 0x82, 0x82, 0x46, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 79 - 0x38, 0xCC, 0x86, 0xFA, 0x92, 0x12, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 0x78, 0xC4, 0x82, 0x82, 0x42, 0x26, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x60, 0xC0, 0x80, 0x80, 0x40, // 81 - 0x38, 0xA4, 0x86, 0xFA, 0x32, 0xD2, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x40, 0x40, // 82 - 0x80, 0x00, 0x0C, 0x92, 0xE2, 0x0E, 0x00, 0x20, 0x20, 0x20, 0x00, 0x00, // 83 - 0x1C, 0x86, 0x82, 0xF2, 0x8E, 0x02, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 84 - 0x0C, 0x7A, 0x86, 0x80, 0x80, 0x40, 0x30, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 85 - 0x0C, 0x06, 0xFE, 0x42, 0x20, 0x10, 0x0C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 86 - 0x0C, 0x06, 0xFE, 0x32, 0x08, 0x04, 0xFE, 0x20, 0x10, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 87 - 0x00, 0x80, 0x40, 0x22, 0x1E, 0xF4, 0x82, 0x01, 0x01, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 88 - 0x1C, 0x04, 0x82, 0xC6, 0xBC, 0x8C, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89 - 0x80, 0xC0, 0xA6, 0x92, 0x8A, 0x86, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 - 0x00, 0xF0, 0x0F, 0xC0, 0xA0, 0x00, // 91 - 0x07, 0xFC, 0x80, 0x00, 0x00, 0x60, // 92 - 0x00, 0x00, 0xF1, 0x0F, 0x80, 0xE0, 0x00, 0x00, // 93 - 0x04, 0x02, 0x04, 0x00, 0x00, 0x00, // 94 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 95 - 0x01, 0x02, 0x00, 0x00, // 96 - 0xE0, 0x90, 0xC8, 0xB8, 0x00, 0x00, 0x00, 0x00, // 97 - 0xE0, 0x9E, 0x49, 0x39, 0x00, 0x00, 0x00, 0x00, // 98 - 0xE0, 0x90, 0x88, 0x48, 0x00, 0x00, 0x00, 0x00, // 99 - 0xE0, 0x90, 0x48, 0xF8, 0x4E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 100 - 0xF0, 0xB0, 0xA8, 0x58, 0x00, 0x00, 0x00, 0x00, // 101 - 0x00, 0x90, 0x78, 0x16, 0x01, 0x01, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, // 102 - 0x00, 0xE0, 0x90, 0x88, 0xE8, 0x18, 0xE0, 0x80, 0x80, 0xC0, 0x60, 0x00, // 103 - 0xE0, 0x1E, 0xD1, 0xB9, 0x00, 0x00, 0x00, 0x00, // 104 - 0xE0, 0x38, 0x02, 0x00, 0x00, 0x00, // 105 - 0x00, 0x90, 0x78, 0x02, 0x80, 0x60, 0x00, 0x00, // 106 - 0xE0, 0x3E, 0xE9, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x40, 0x40, // 107 - 0xE0, 0x9C, 0x42, 0x00, 0x00, 0x00, // 108 - 0xC8, 0x38, 0xD0, 0x38, 0xF0, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 109 - 0xE8, 0x18, 0xD0, 0xB8, 0x00, 0x00, 0x00, 0x00, // 110 - 0xF0, 0x88, 0xC8, 0x38, 0x00, 0x00, 0x00, 0x00, // 111 - 0x88, 0xF8, 0x90, 0x48, 0x38, 0xE0, 0x80, 0x00, 0x00, 0x00, // 112 - 0xE0, 0x90, 0x88, 0xE8, 0x18, 0x00, 0x80, 0xC0, 0xA0, 0x00, // 113 - 0xC8, 0x38, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, // 114 - 0xC0, 0x98, 0xE8, 0x08, 0x00, 0x00, 0x00, 0x00, // 115 - 0xE8, 0x9C, 0x88, 0x40, 0x00, 0x00, 0x00, 0x00, // 116 - 0xE8, 0x98, 0xE0, 0x98, 0x00, 0x00, 0x00, 0x00, // 117 - 0x10, 0x08, 0xF8, 0x88, 0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 118 - 0x10, 0x08, 0xF8, 0x88, 0x40, 0xF8, 0x40, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 119 - 0x80, 0xD0, 0x58, 0xF0, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x60, // 120 - 0x10, 0x18, 0xF0, 0xC0, 0x38, 0x80, 0x40, 0x20, 0x00, 0x00, // 121 - 0x80, 0xD8, 0xA8, 0x98, 0xD8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 122 - 0xA0, 0xD8, 0x07, 0xE0, 0x80, 0x00, // 123 - 0xFF, 0xE0, // 124 - 0x00, 0x00, 0xD1, 0x2F, 0x80, 0xC0, 0x20, 0x00, // 125 - 0x08, 0x08, 0x18, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 - 0xFF, 0x81, 0x81, 0x81, 0x81, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // 127 - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/SystemFont5x7.h b/GD32F1/libraries/ILI9341_due_STM/fonts/SystemFont5x7.h deleted file mode 100644 index 8959af1..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/SystemFont5x7.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * - * System5x7 - * - * - * File Name : System5x7.h - * Date : 28 Oct 2008 - * Font size in bytes : 470 - * Font width : 5 - * Font height : 7 - * Font first char : 32 - * Font last char : 127 - * Font used chars : 94 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef SYSTEM5x7_H -#define SYSTEM5x7_H - -#define SYSTEM5x7_WIDTH 5 -#define SYSTEM5x7_HEIGHT 7 - -/* - * added to allow fontname to match header file name. - * as well as keep the old name for backward compability - */ - -#define SystemFont5x7 System5x7 - -static const uint8_t System5x7[] PROGMEM = { - 0x0, 0x0, // size of zero indicates fixed width font, actual length is width * height - 0x05, // width - 0x07, // height - 0x20, // first char - 0x60, // char count - - // Fixed width; char width table not used !!!! - - // font data - 0x00, 0x00, 0x00, 0x00, 0x00,// (space) - 0x00, 0x00, 0x5F, 0x00, 0x00,// ! - 0x00, 0x07, 0x00, 0x07, 0x00,// " - 0x14, 0x7F, 0x14, 0x7F, 0x14,// # - 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ - 0x23, 0x13, 0x08, 0x64, 0x62,// % - 0x36, 0x49, 0x55, 0x22, 0x50,// & - 0x00, 0x05, 0x03, 0x00, 0x00,// ' - 0x00, 0x1C, 0x22, 0x41, 0x00,// ( - 0x00, 0x41, 0x22, 0x1C, 0x00,// ) - 0x08, 0x2A, 0x1C, 0x2A, 0x08,// * - 0x08, 0x08, 0x3E, 0x08, 0x08,// + - 0x00, 0x50, 0x30, 0x00, 0x00,// , - 0x08, 0x08, 0x08, 0x08, 0x08,// - - 0x00, 0x60, 0x60, 0x00, 0x00,// . - 0x20, 0x10, 0x08, 0x04, 0x02,// / - 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 - 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 - 0x42, 0x61, 0x51, 0x49, 0x46,// 2 - 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 - 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 - 0x27, 0x45, 0x45, 0x45, 0x39,// 5 - 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 - 0x01, 0x71, 0x09, 0x05, 0x03,// 7 - 0x36, 0x49, 0x49, 0x49, 0x36,// 8 - 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 - 0x00, 0x36, 0x36, 0x00, 0x00,// : - 0x00, 0x56, 0x36, 0x00, 0x00,// ; - 0x00, 0x08, 0x14, 0x22, 0x41,// < - 0x14, 0x14, 0x14, 0x14, 0x14,// = - 0x41, 0x22, 0x14, 0x08, 0x00,// > - 0x02, 0x01, 0x51, 0x09, 0x06,// ? - 0x32, 0x49, 0x79, 0x41, 0x3E,// @ - 0x7E, 0x11, 0x11, 0x11, 0x7E,// A - 0x7F, 0x49, 0x49, 0x49, 0x36,// B - 0x3E, 0x41, 0x41, 0x41, 0x22,// C - 0x7F, 0x41, 0x41, 0x22, 0x1C,// D - 0x7F, 0x49, 0x49, 0x49, 0x41,// E - 0x7F, 0x09, 0x09, 0x01, 0x01,// F - 0x3E, 0x41, 0x41, 0x51, 0x32,// G - 0x7F, 0x08, 0x08, 0x08, 0x7F,// H - 0x00, 0x41, 0x7F, 0x41, 0x00,// I - 0x20, 0x40, 0x41, 0x3F, 0x01,// J - 0x7F, 0x08, 0x14, 0x22, 0x41,// K - 0x7F, 0x40, 0x40, 0x40, 0x40,// L - 0x7F, 0x02, 0x04, 0x02, 0x7F,// M - 0x7F, 0x04, 0x08, 0x10, 0x7F,// N - 0x3E, 0x41, 0x41, 0x41, 0x3E,// O - 0x7F, 0x09, 0x09, 0x09, 0x06,// P - 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q - 0x7F, 0x09, 0x19, 0x29, 0x46,// R - 0x46, 0x49, 0x49, 0x49, 0x31,// S - 0x01, 0x01, 0x7F, 0x01, 0x01,// T - 0x3F, 0x40, 0x40, 0x40, 0x3F,// U - 0x1F, 0x20, 0x40, 0x20, 0x1F,// V - 0x7F, 0x20, 0x18, 0x20, 0x7F,// W - 0x63, 0x14, 0x08, 0x14, 0x63,// X - 0x03, 0x04, 0x78, 0x04, 0x03,// Y - 0x61, 0x51, 0x49, 0x45, 0x43,// Z - 0x00, 0x00, 0x7F, 0x41, 0x41,// [ - 0x02, 0x04, 0x08, 0x10, 0x20,// "\" - 0x41, 0x41, 0x7F, 0x00, 0x00,// ] - 0x04, 0x02, 0x01, 0x02, 0x04,// ^ - 0x40, 0x40, 0x40, 0x40, 0x40,// _ - 0x00, 0x01, 0x02, 0x04, 0x00,// ` - 0x20, 0x54, 0x54, 0x54, 0x78,// a - 0x7F, 0x48, 0x44, 0x44, 0x38,// b - 0x38, 0x44, 0x44, 0x44, 0x20,// c - 0x38, 0x44, 0x44, 0x48, 0x7F,// d - 0x38, 0x54, 0x54, 0x54, 0x18,// e - 0x08, 0x7E, 0x09, 0x01, 0x02,// f - 0x08, 0x14, 0x54, 0x54, 0x3C,// g - 0x7F, 0x08, 0x04, 0x04, 0x78,// h - 0x00, 0x44, 0x7D, 0x40, 0x00,// i - 0x20, 0x40, 0x44, 0x3D, 0x00,// j - 0x00, 0x7F, 0x10, 0x28, 0x44,// k - 0x00, 0x41, 0x7F, 0x40, 0x00,// l - 0x7C, 0x04, 0x18, 0x04, 0x78,// m - 0x7C, 0x08, 0x04, 0x04, 0x78,// n - 0x38, 0x44, 0x44, 0x44, 0x38,// o - 0x7C, 0x14, 0x14, 0x14, 0x08,// p - 0x08, 0x14, 0x14, 0x18, 0x7C,// q - 0x7C, 0x08, 0x04, 0x04, 0x08,// r - 0x48, 0x54, 0x54, 0x54, 0x20,// s - 0x04, 0x3F, 0x44, 0x40, 0x20,// t - 0x3C, 0x40, 0x40, 0x20, 0x7C,// u - 0x1C, 0x20, 0x40, 0x20, 0x1C,// v - 0x3C, 0x40, 0x30, 0x40, 0x3C,// w - 0x44, 0x28, 0x10, 0x28, 0x44,// x - 0x0C, 0x50, 0x50, 0x50, 0x3C,// y - 0x44, 0x64, 0x54, 0x4C, 0x44,// z - 0x00, 0x08, 0x36, 0x41, 0x00,// { - 0x00, 0x00, 0x7F, 0x00, 0x00,// | - 0x00, 0x41, 0x36, 0x08, 0x00,// } - 0x08, 0x08, 0x2A, 0x1C, 0x08,// -> - 0x08, 0x1C, 0x2A, 0x08, 0x08 // <- - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/Verdana_digits_24.h b/GD32F1/libraries/ILI9341_due_STM/fonts/Verdana_digits_24.h deleted file mode 100644 index 38e8614..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/Verdana_digits_24.h +++ /dev/null @@ -1,116 +0,0 @@ - - -/* - * - * Verdana28 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : Verdana_digits_24 - * Date : 01.05.2008 - * Font size in bytes : 3833 - * Font width : 10 - * Font height : 24 - * Font first char : 48 - * Font last char : 59 - * Font used chars : 11 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty -row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef VERDANA24_H -#define VERDANA24_H - -#define VERDANA24_WIDTH 10 -#define VERDANA24_HEIGHT 24 - -static const uint8_t Verdana24[] PROGMEM = { - 0x0E, 0xF9, // size - 0x0A, // width - 0x18, // height - 0x30, // first char - 0x0B, // char count - - // char widths - 0x10, 0x0D, 0x0F, 0x0F, 0x11, 0x0F, 0x10, 0x10, 0x10, 0x10, - 0x04, - - // font data - 0x80, 0xF0, 0xFC, 0x7E, 0x0E, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x1E, -0x7E, 0xFC, 0xF0, 0x80, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x01, 0x0F, 0x3F, 0x7E, -0x70, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0x70, 0x7E, 0x3F, 0x0F, 0x01, //48 - - 0x38, 0x38, 0x38, 0x38, 0x3C, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, -0xE0, 0xE0, 0xE0, // 49 - - 0x00, 0x1E, 0x0E, 0x0E, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x1E, 0xFE, -0xFC, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, -0x78, 0x3E, 0x1F, 0x07, 0x01, 0x00, 0xF0, 0xF8, 0xFC, 0xFE, 0xEF, 0xE7, -0xE3, 0xE1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, // 50 - - 0x00, 0x1E, 0x0E, 0x0E, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x1E, -0xFE, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x1C, -0x1E, 0x36, 0x77, 0xF3, 0xE1, 0xC0, 0x78, 0x70, 0x70, 0xF0, 0xE0, 0xE0, -0xE0, 0xE0, 0xE0, 0xF0, 0x70, 0x78, 0x3F, 0x1F, 0x0F, // 51 - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0x7C, 0x1E, 0xFF, -0xFF, 0xFF, 0x00, 0x00, 0x00, 0xE0, 0xF0, 0xFC, 0xFE, 0xDF, 0xC7, 0xC3, -0xC1, 0xC0, 0xC0, 0xC0, 0xFF, 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF, -0x01, 0x01, 0x01, // 52 - - 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, -0x07, 0x07, 0x07, 0x00, 0x1F, 0x1F, 0x0F, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, -0x1E, 0x1C, 0x3C, 0xF8, 0xF8, 0xE0, 0x78, 0x70, 0x70, 0xF0, 0xE0, 0xE0, -0xE0, 0xE0, 0xE0, 0xF0, 0x70, 0x7C, 0x3F, 0x1F, 0x07, // 53 - - 0x00, 0xC0, 0xF0, 0xF8, 0x3C, 0x1E, 0x0E, 0x0E, 0x07, 0x07, 0x07, 0x07, -0x07, 0x0F, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x1C, 0x1C, 0x0E, 0x0E, 0x0E, -0x0E, 0x0E, 0x0E, 0x1E, 0x3C, 0xF8, 0xF8, 0xE0, 0x03, 0x0F, 0x3F, 0x7C, -0x78, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x70, 0x78, 0x3F, 0x1F, 0x07, //54 - - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x87, -0xE7, 0xFF, 0x7F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, -0xF0, 0xFC, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, -0xF8, 0xFC, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //55 - - 0x00, 0xF0, 0xFC, 0xFE, 0x0E, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x1E, -0xFE, 0xFC, 0xF8, 0x00, 0x80, 0xE0, 0xF3, 0x77, 0x1F, 0x0E, 0x0E, 0x0C, -0x1C, 0x1C, 0x1C, 0x3E, 0x77, 0xF3, 0xE0, 0x80, 0x0F, 0x1F, 0x3F, 0x78, -0x70, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x70, 0x78, 0x3F, 0x1F, 0x0F, //56 - - 0xE0, 0xF8, 0xFC, 0x1E, 0x0E, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x1E, -0x3E, 0xFC, 0xF0, 0xC0, 0x07, 0x1F, 0x1F, 0x3C, 0x78, 0x70, 0x70, 0x70, -0x70, 0x70, 0x70, 0x38, 0x38, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0xF0, 0xE0, -0xE0, 0xE0, 0xE0, 0xE0, 0x70, 0x70, 0x78, 0x3C, 0x1F, 0x0F, 0x03, 0x00, //57 - - 0xC0, 0xC0, 0xC0, 0xC0, 0x03, 0x03, 0x03, 0x03, 0xF0, 0xF0, 0xF0, 0xF0 // 58 - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/allFonts.h b/GD32F1/libraries/ILI9341_due_STM/fonts/allFonts.h deleted file mode 100644 index cafd7eb..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/allFonts.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * allFonts.h font header for GLCD library - * The fonts listed below will be available in a sketch if this file is included - * - * If you create your own fonts you can add the header to this file - * - * Note that the build environment only holds a font in Flash if its selected - * so there is no penalty to including a font file here if its not used - */ - -#include "SystemFont5x7.h" // system font -#include "Arial14.h" // proportional font -#include "Arial_bold_14.h" // Bold proportional font -#include "Corsiva_12.h" -#include "Verdana_digits_24.h" // large proportional font - numerals only -#include "fixednums7x15.h" // fixed width font - numerals only -#include "fixednums8x16.h" // fixed width font - numerals only -#include "fixednums15x31.h" // fixed width font - numerals only diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums15x31.h b/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums15x31.h deleted file mode 100644 index 346e129..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums15x31.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Fixed width font for numbers - * - * This font is very useful when using overstrike as all characters & numbers - * are all the same width. - * - * This font also contains a few special characters that are nice for certain applications - * like clocks, signed values or decimal point values. - * - * The rendering code normally inserts a pad pixel so this size allows the font to fit - * perfectly on 32 and 64 tall glcd displays. - * - * Font has also been squeezed to 15 pixels wide for better alignment on 128 & 192 pixel displays. - */ - -#ifndef FIXEDNUMS15x31_H -#define FIXEDNUMS15x31_H - -#include -#include - - -static const uint8_t fixednums15x31[] PROGMEM = { - 0x0, 0x0, // size of zero indicates fixed width font - 15, // width - 31, // height - '+', // first char (48) - 16, // char count -// char '+' -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc, 0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - -// char ',' -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xcf, 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, - -// char '-' -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - -// char '.' -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, - -// char '/' -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xff, 0xff, 0x0f, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xff, 0xff, 0x0f, 0x0f, 0x00, 0x00, 0x00, -0x00, 0x00, 0xf0, 0xf0, 0xff, 0xff, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - -// char '0' -0xf0, 0xf0, 0xfc, 0xfc, 0x0f, 0x0f, 0x03, 0x03, 0x03, 0xcf, 0xcf, 0xfc, 0xfc, 0xf0, 0xf0, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xc0, 0xc0, 0x3c, 0x3f, 0x03, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0xff, 0xff, 0x3c, 0x3c, 0x03, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, - -// char '1' -0x30, 0x30, 0x30, 0x30, 0x3c, 0x3c, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - -// char '2' -0xf0, 0xf0, 0xfc, 0xfc, 0x0f, 0x0f, 0x03, 0x03, 0x03, 0x03, 0x0f, 0xff, 0xfc, 0xfc, 0xf0, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xf0, 0xff, 0x3f, 0x3f, 0x0f, -0xc0, 0xc0, 0xf0, 0xf0, 0x3c, 0x3c, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0f, 0x0f, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - -// char '3' -0xf0, 0xf0, 0xfc, 0xfc, 0x0f, 0x0f, 0x03, 0x03, 0x03, 0x03, 0x0f, 0x1f, 0xfc, 0xfc, 0xf0, -0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xff, 0xdf, 0x8f, -0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, -0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, - -// char '4' -0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xff, 0xff, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xfc, 0xfc, 0xff, 0xff, 0x03, 0x03, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xc0, 0xc0, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, - -// char '5' -0xff, 0xff, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -0x0f, 0x0f, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0xfc, 0xf0, 0xf0, 0xc0, -0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, - -// char '6' -0x00, 0x00, 0xc0, 0xc0, 0xf0, 0xf0, 0x3c, 0x3c, 0x0f, 0x0f, 0x03, 0x03, 0x03, 0x03, 0x03, -0xfc, 0xfc, 0xff, 0xff, 0x33, 0x33, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xc0, 0xc0, 0x00, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, - -// char '7' -0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xff, 0xff, 0x3f, 0x3f, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xff, 0xff, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - -// char '8' -0xf0, 0xf0, 0xfc, 0xfc, 0x0f, 0x0f, 0x03, 0x03, 0x03, 0x0f, 0x0f, 0xfc, 0xfc, 0xf0, 0xf0, -0x03, 0x03, 0xcf, 0xcf, 0xfc, 0xfc, 0x30, 0x30, 0x30, 0xfc, 0xfc, 0xcf, 0xcf, 0x03, 0x03, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, - -// char '9' -0xe0, 0xf0, 0xfc, 0xfc, 0x0f, 0x0f, 0x03, 0x03, 0x03, 0x0f, 0x0f, 0xfc, 0xfc, 0xf0, 0xe0, -0x07, 0x0f, 0x3f, 0x3f, 0xf0, 0xf0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xfc, 0xfc, 0x3f, 0x3f, 0x03, -0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0f, 0x0f, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - -// char ':' -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums7x15.h b/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums7x15.h deleted file mode 100644 index 42337e3..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums7x15.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Fixed width font for numbers - * - * This font is very useful when using overstrike as all characters & numbers - * are all the same width. - * - * This font also contains a few special characters that are nice for certain applications - * like clocks, signed values or decimal point values. - * - * When rendering code inserts a pad pixel this size allows the font to fit - * perfectly on 32 and 64 tall glcd displays as well as 128 wide displays. - */ - -#ifndef FIXEDNUMS7x15_H -#define FIXEDNUMS7x15_H - -#include -#include - - -static const uint8_t fixednums7x15[] PROGMEM = { - 0x0, 0x0, // size of zero indicates fixed width font - 7, // width - 15, // height - '+', // first char (48) - 16, // char count -// char '+' -0x00, 0x80, 0x80, 0xe0, 0xe0, 0x80, 0x80, -0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, - -// char ',' -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x58, 0x38, 0x00, 0x00, - -// char '-' -0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - -// char '.' -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, - -// char '/' -0x00, 0x00, 0x00, 0xc0, 0xf0, 0x3c, 0x0f, -0x00, 0x3c, 0x0f, 0x03, 0x00, 0x00, 0x00, - -// char '0' -0xfc, 0xfe, 0x03, 0xe1, 0x1b, 0xfe, 0xfc, -0x0f, 0x1f, 0x36, 0x21, 0x30, 0x1f, 0x0f, - -// char '1' -0x04, 0x04, 0x06, 0xff, 0xff, 0x00, 0x00, -0x20, 0x20, 0x20, 0x3f, 0x3f, 0x20, 0x20, - -// char '2' -0x0c, 0x0e, 0x03, 0x01, 0x81, 0xfe, 0x7c, -0x38, 0x3c, 0x26, 0x23, 0x21, 0x20, 0x20, - -// char '3' -0x0c, 0x0e, 0x43, 0x41, 0x43, 0xfe, 0xbc, -0x0c, 0x1c, 0x30, 0x20, 0x30, 0x1f, 0x0f, - -// char '4' -0x00, 0xe0, 0xfc, 0x1f, 0x83, 0x80, 0x00, -0x0f, 0x0f, 0x08, 0x08, 0x3f, 0x3f, 0x08, - -// char '5' -0x3f, 0x3f, 0x21, 0x21, 0x61, 0xe1, 0x81, -0x0c, 0x1c, 0x30, 0x20, 0x30, 0x3f, 0x0f, - -// char '6' -0xe0, 0xf8, 0x5c, 0x46, 0xc3, 0xc1, 0x01, -0x0f, 0x1f, 0x30, 0x20, 0x30, 0x3f, 0x0f, - -// char '7' -0x01, 0x01, 0x01, 0x81, 0xf1, 0x7f, 0x0f, -0x00, 0x00, 0x3c, 0x3f, 0x03, 0x00, 0x00, - -// char '8' -0x1c, 0xbe, 0xe3, 0x41, 0xe3, 0xbe, 0x1c, -0x0f, 0x1f, 0x30, 0x20, 0x30, 0x1f, 0x0f, - -// char '9' -0x3c, 0x7e, 0xc3, 0x81, 0x81, 0xfe, 0xfc, -0x20, 0x30, 0x38, 0x0c, 0x07, 0x03, 0x00, - -// char ':' -0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, -0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, - -}; -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums8x16.h b/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums8x16.h deleted file mode 100644 index b1981ce..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/fixednums8x16.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Fixed width font file for numbers only. - * - * This font is very useful when using overstrike as all characters & numbers - * are all the same width. - * - * This font file can be used when only numbers are needed. - * - * This font also contains a few special characters that are nice for certain applications - * like clocks, signed values or decimal point values. - * - * Font is really 16 tall but this file is set to indicate 15 to allow it to line up with the lcd page size. - * It works as the the bottom row in the glyph is whitespace anyway. - * The rendering code normally inserts a pad pixel so this size allows additional rows - * on 32 and 64 tall glcd displays. - * - */ - -#ifndef FIXEDNUMS8x16_H -#define FIXEDNUMS8x16_H - -#include -#include - - -static const uint8_t fixednums8x16[] PROGMEM = { - 0x0, 0x0, // size of zero indicates fixed width font - 8, // width - 15, // height - '+', // first char (48) - 16, // char count - - 0x80, 0x80, 0x80, 0xe0, 0xe0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, // char '+' - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x70, 0x00, 0x00, 0x00, // char ',' - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char '-' - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, // char '.' - 0x00, 0x00, 0x00, 0xc0, 0xf0, 0x3c, 0x0f, 0x03, 0x30, 0x3c, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, // char '/' - 0xfc, 0xfe, 0x03, 0x81, 0x61, 0x1b, 0xfe, 0xfc, 0x0f, 0x1f, 0x36, 0x21, 0x20, 0x30, 0x1f, 0x0f, // char '0' - 0x04, 0x04, 0x06, 0xff, 0xff, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x3f, 0x3f, 0x20, 0x20, 0x20, // char '1' - 0x0c, 0x0e, 0x03, 0x01, 0x81, 0xc3, 0x7e, 0x3c, 0x38, 0x3c, 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, // char '2' - 0x0c, 0x0e, 0x43, 0x41, 0x41, 0x43, 0xfe, 0xbc, 0x0c, 0x1c, 0x30, 0x20, 0x20, 0x30, 0x1f, 0x0f, // char '3' - 0x00, 0xe0, 0xfc, 0x1f, 0x83, 0x80, 0x00, 0x00, 0x0f, 0x0f, 0x08, 0x08, 0x3f, 0x3f, 0x08, 0x08, // char '4' - 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x61, 0xc1, 0x81, 0x0c, 0x1c, 0x30, 0x20, 0x20, 0x30, 0x1f, 0x0f, // char '5' - 0xe0, 0xf8, 0x5c, 0x46, 0x43, 0xc1, 0x81, 0x01, 0x0f, 0x1f, 0x30, 0x20, 0x20, 0x30, 0x1f, 0x0f, // char '6' - 0x01, 0x01, 0x01, 0x01, 0x81, 0xf1, 0x7f, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x3f, 0x03, 0x00, 0x00, // char '7' - 0x1c, 0xbe, 0xe3, 0x41, 0x41, 0xe3, 0xbe, 0x1c, 0x0f, 0x1f, 0x30, 0x20, 0x20, 0x30, 0x1f, 0x0f, // char '8' - 0x3c, 0x7e, 0xc3, 0x81, 0x81, 0x83, 0xfe, 0xfc, 0x20, 0x20, 0x20, 0x30, 0x18, 0x0e, 0x07, 0x01, // char '9' - 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00 // char ': -}; -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/fonts/jokerman_255.h b/GD32F1/libraries/ILI9341_due_STM/fonts/jokerman_255.h deleted file mode 100644 index 3045ce3..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/fonts/jokerman_255.h +++ /dev/null @@ -1,73 +0,0 @@ - - -/* - * - * jokerman_255 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : jokerman_255 - * Date : 04.09.2014 - * Font size in bytes : 362565 - * Font width : 10 - * Font height : 253 - * Font first char : 48 - * Font last char : 58 - * Font used chars : 10 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef JOKERMAN_255_H -#define JOKERMAN_255_H - -#define JOKERMAN_255_WIDTH 10 -#define JOKERMAN_255_HEIGHT 253 - -static const uint8_t jokerman_255[] PROGMEM = { - 0x88, 0x45, // size - 0x0A, // width - 0xFD, // height - 0x30, // first char - 0x0A, // char count - - // char widths - 0x9A, 0x4D, 0x8B, 0x9E, 0xAD, 0x91, 0x8E, 0x91, 0x90, 0x9C, - - - // font data - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x03, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x3F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xF8, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x3C, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xE0, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xFC, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x0F, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xC7, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 48 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x03, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 49 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x3F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x0F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xFC, 0xF8, 0xF8, 0xF8, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x81, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 50 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0xC7, 0xE7, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0C, 0x0E, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7E, 0x38, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x0E, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x03, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x0F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x07, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0E, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 51 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x1F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x80, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xF8, 0x78, 0x78, 0x78, 0x38, 0x38, 0x38, 0x38, 0x18, 0x18, 0x18, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 52 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x7C, 0x78, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x0F, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x1F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x78, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFC, 0xF8, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x0F, 0x1F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 53 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F, 0x0E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xE0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF0, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0F, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x0F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 54 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x81, 0xE1, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x07, 0x0F, 0x1F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x01, 0x03, 0x07, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x78, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 55 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07, 0x0F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x3F, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xEF, 0xC7, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCF, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x01, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x0F, 0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF0, 0x80, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xF0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xE0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 56 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF0, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC1, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x7C, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x3F, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x3F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x03, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xE0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE1, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x07, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1E, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // 57 - -}; - -#endif diff --git a/GD32F1/libraries/ILI9341_due_STM/glcdfont.c b/GD32F1/libraries/ILI9341_due_STM/glcdfont.c deleted file mode 100644 index d6e8af2..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/glcdfont.c +++ /dev/null @@ -1,263 +0,0 @@ -#ifndef FONT5X7_H -#define FONT5X7_H - -// Standard ASCII 5x7 font - -static const unsigned char font[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, - 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, - 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, - 0x18, 0x3C, 0x7E, 0x3C, 0x18, - 0x1C, 0x57, 0x7D, 0x57, 0x1C, - 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, - 0x00, 0x18, 0x3C, 0x18, 0x00, - 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, - 0x00, 0x18, 0x24, 0x18, 0x00, - 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, - 0x30, 0x48, 0x3A, 0x06, 0x0E, - 0x26, 0x29, 0x79, 0x29, 0x26, - 0x40, 0x7F, 0x05, 0x05, 0x07, - 0x40, 0x7F, 0x05, 0x25, 0x3F, - 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, - 0x7F, 0x3E, 0x1C, 0x1C, 0x08, - 0x08, 0x1C, 0x1C, 0x3E, 0x7F, - 0x14, 0x22, 0x7F, 0x22, 0x14, - 0x5F, 0x5F, 0x00, 0x5F, 0x5F, - 0x06, 0x09, 0x7F, 0x01, 0x7F, - 0x00, 0x66, 0x89, 0x95, 0x6A, - 0x60, 0x60, 0x60, 0x60, 0x60, - 0x94, 0xA2, 0xFF, 0xA2, 0x94, - 0x08, 0x04, 0x7E, 0x04, 0x08, - 0x10, 0x20, 0x7E, 0x20, 0x10, - 0x08, 0x08, 0x2A, 0x1C, 0x08, - 0x08, 0x1C, 0x2A, 0x08, 0x08, - 0x1E, 0x10, 0x10, 0x10, 0x10, - 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, - 0x30, 0x38, 0x3E, 0x38, 0x30, - 0x06, 0x0E, 0x3E, 0x0E, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0x00, 0x00, - 0x00, 0x07, 0x00, 0x07, 0x00, - 0x14, 0x7F, 0x14, 0x7F, 0x14, - 0x24, 0x2A, 0x7F, 0x2A, 0x12, - 0x23, 0x13, 0x08, 0x64, 0x62, - 0x36, 0x49, 0x56, 0x20, 0x50, - 0x00, 0x08, 0x07, 0x03, 0x00, - 0x00, 0x1C, 0x22, 0x41, 0x00, - 0x00, 0x41, 0x22, 0x1C, 0x00, - 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, - 0x08, 0x08, 0x3E, 0x08, 0x08, - 0x00, 0x80, 0x70, 0x30, 0x00, - 0x08, 0x08, 0x08, 0x08, 0x08, - 0x00, 0x00, 0x60, 0x60, 0x00, - 0x20, 0x10, 0x08, 0x04, 0x02, - 0x3E, 0x51, 0x49, 0x45, 0x3E, - 0x00, 0x42, 0x7F, 0x40, 0x00, - 0x72, 0x49, 0x49, 0x49, 0x46, - 0x21, 0x41, 0x49, 0x4D, 0x33, - 0x18, 0x14, 0x12, 0x7F, 0x10, - 0x27, 0x45, 0x45, 0x45, 0x39, - 0x3C, 0x4A, 0x49, 0x49, 0x31, - 0x41, 0x21, 0x11, 0x09, 0x07, - 0x36, 0x49, 0x49, 0x49, 0x36, - 0x46, 0x49, 0x49, 0x29, 0x1E, - 0x00, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x40, 0x34, 0x00, 0x00, - 0x00, 0x08, 0x14, 0x22, 0x41, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x00, 0x41, 0x22, 0x14, 0x08, - 0x02, 0x01, 0x59, 0x09, 0x06, - 0x3E, 0x41, 0x5D, 0x59, 0x4E, - 0x7C, 0x12, 0x11, 0x12, 0x7C, - 0x7F, 0x49, 0x49, 0x49, 0x36, - 0x3E, 0x41, 0x41, 0x41, 0x22, - 0x7F, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x49, 0x49, 0x49, 0x41, - 0x7F, 0x09, 0x09, 0x09, 0x01, - 0x3E, 0x41, 0x41, 0x51, 0x73, - 0x7F, 0x08, 0x08, 0x08, 0x7F, - 0x00, 0x41, 0x7F, 0x41, 0x00, - 0x20, 0x40, 0x41, 0x3F, 0x01, - 0x7F, 0x08, 0x14, 0x22, 0x41, - 0x7F, 0x40, 0x40, 0x40, 0x40, - 0x7F, 0x02, 0x1C, 0x02, 0x7F, - 0x7F, 0x04, 0x08, 0x10, 0x7F, - 0x3E, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x09, 0x09, 0x09, 0x06, - 0x3E, 0x41, 0x51, 0x21, 0x5E, - 0x7F, 0x09, 0x19, 0x29, 0x46, - 0x26, 0x49, 0x49, 0x49, 0x32, - 0x03, 0x01, 0x7F, 0x01, 0x03, - 0x3F, 0x40, 0x40, 0x40, 0x3F, - 0x1F, 0x20, 0x40, 0x20, 0x1F, - 0x3F, 0x40, 0x38, 0x40, 0x3F, - 0x63, 0x14, 0x08, 0x14, 0x63, - 0x03, 0x04, 0x78, 0x04, 0x03, - 0x61, 0x59, 0x49, 0x4D, 0x43, - 0x00, 0x7F, 0x41, 0x41, 0x41, - 0x02, 0x04, 0x08, 0x10, 0x20, - 0x00, 0x41, 0x41, 0x41, 0x7F, - 0x04, 0x02, 0x01, 0x02, 0x04, - 0x40, 0x40, 0x40, 0x40, 0x40, - 0x00, 0x03, 0x07, 0x08, 0x00, - 0x20, 0x54, 0x54, 0x78, 0x40, - 0x7F, 0x28, 0x44, 0x44, 0x38, - 0x38, 0x44, 0x44, 0x44, 0x28, - 0x38, 0x44, 0x44, 0x28, 0x7F, - 0x38, 0x54, 0x54, 0x54, 0x18, - 0x00, 0x08, 0x7E, 0x09, 0x02, - 0x18, 0xA4, 0xA4, 0x9C, 0x78, - 0x7F, 0x08, 0x04, 0x04, 0x78, - 0x00, 0x44, 0x7D, 0x40, 0x00, - 0x20, 0x40, 0x40, 0x3D, 0x00, - 0x7F, 0x10, 0x28, 0x44, 0x00, - 0x00, 0x41, 0x7F, 0x40, 0x00, - 0x7C, 0x04, 0x78, 0x04, 0x78, - 0x7C, 0x08, 0x04, 0x04, 0x78, - 0x38, 0x44, 0x44, 0x44, 0x38, - 0xFC, 0x18, 0x24, 0x24, 0x18, - 0x18, 0x24, 0x24, 0x18, 0xFC, - 0x7C, 0x08, 0x04, 0x04, 0x08, - 0x48, 0x54, 0x54, 0x54, 0x24, - 0x04, 0x04, 0x3F, 0x44, 0x24, - 0x3C, 0x40, 0x40, 0x20, 0x7C, - 0x1C, 0x20, 0x40, 0x20, 0x1C, - 0x3C, 0x40, 0x30, 0x40, 0x3C, - 0x44, 0x28, 0x10, 0x28, 0x44, - 0x4C, 0x90, 0x90, 0x90, 0x7C, - 0x44, 0x64, 0x54, 0x4C, 0x44, - 0x00, 0x08, 0x36, 0x41, 0x00, - 0x00, 0x00, 0x77, 0x00, 0x00, - 0x00, 0x41, 0x36, 0x08, 0x00, - 0x02, 0x01, 0x02, 0x04, 0x02, - 0x3C, 0x26, 0x23, 0x26, 0x3C, - 0x1E, 0xA1, 0xA1, 0x61, 0x12, - 0x3A, 0x40, 0x40, 0x20, 0x7A, - 0x38, 0x54, 0x54, 0x55, 0x59, - 0x21, 0x55, 0x55, 0x79, 0x41, - 0x21, 0x54, 0x54, 0x78, 0x41, - 0x21, 0x55, 0x54, 0x78, 0x40, - 0x20, 0x54, 0x55, 0x79, 0x40, - 0x0C, 0x1E, 0x52, 0x72, 0x12, - 0x39, 0x55, 0x55, 0x55, 0x59, - 0x39, 0x54, 0x54, 0x54, 0x59, - 0x39, 0x55, 0x54, 0x54, 0x58, - 0x00, 0x00, 0x45, 0x7C, 0x41, - 0x00, 0x02, 0x45, 0x7D, 0x42, - 0x00, 0x01, 0x45, 0x7C, 0x40, - 0xF0, 0x29, 0x24, 0x29, 0xF0, - 0xF0, 0x28, 0x25, 0x28, 0xF0, - 0x7C, 0x54, 0x55, 0x45, 0x00, - 0x20, 0x54, 0x54, 0x7C, 0x54, - 0x7C, 0x0A, 0x09, 0x7F, 0x49, - 0x32, 0x49, 0x49, 0x49, 0x32, - 0x32, 0x48, 0x48, 0x48, 0x32, - 0x32, 0x4A, 0x48, 0x48, 0x30, - 0x3A, 0x41, 0x41, 0x21, 0x7A, - 0x3A, 0x42, 0x40, 0x20, 0x78, - 0x00, 0x9D, 0xA0, 0xA0, 0x7D, - 0x39, 0x44, 0x44, 0x44, 0x39, - 0x3D, 0x40, 0x40, 0x40, 0x3D, - 0x3C, 0x24, 0xFF, 0x24, 0x24, - 0x48, 0x7E, 0x49, 0x43, 0x66, - 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, - 0xFF, 0x09, 0x29, 0xF6, 0x20, - 0xC0, 0x88, 0x7E, 0x09, 0x03, - 0x20, 0x54, 0x54, 0x79, 0x41, - 0x00, 0x00, 0x44, 0x7D, 0x41, - 0x30, 0x48, 0x48, 0x4A, 0x32, - 0x38, 0x40, 0x40, 0x22, 0x7A, - 0x00, 0x7A, 0x0A, 0x0A, 0x72, - 0x7D, 0x0D, 0x19, 0x31, 0x7D, - 0x26, 0x29, 0x29, 0x2F, 0x28, - 0x26, 0x29, 0x29, 0x29, 0x26, - 0x30, 0x48, 0x4D, 0x40, 0x20, - 0x38, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x38, - 0x2F, 0x10, 0xC8, 0xAC, 0xBA, - 0x2F, 0x10, 0x28, 0x34, 0xFA, - 0x00, 0x00, 0x7B, 0x00, 0x00, - 0x08, 0x14, 0x2A, 0x14, 0x22, - 0x22, 0x14, 0x2A, 0x14, 0x08, - 0xAA, 0x00, 0x55, 0x00, 0xAA, - 0xAA, 0x55, 0xAA, 0x55, 0xAA, - 0x00, 0x00, 0x00, 0xFF, 0x00, - 0x10, 0x10, 0x10, 0xFF, 0x00, - 0x14, 0x14, 0x14, 0xFF, 0x00, - 0x10, 0x10, 0xFF, 0x00, 0xFF, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x14, 0x14, 0x14, 0xFC, 0x00, - 0x14, 0x14, 0xF7, 0x00, 0xFF, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x14, 0x14, 0xF4, 0x04, 0xFC, - 0x14, 0x14, 0x17, 0x10, 0x1F, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0x1F, 0x00, - 0x10, 0x10, 0x10, 0xF0, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0xF0, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x14, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x00, 0x00, 0x1F, 0x10, 0x17, - 0x00, 0x00, 0xFC, 0x04, 0xF4, - 0x14, 0x14, 0x17, 0x10, 0x17, - 0x14, 0x14, 0xF4, 0x04, 0xF4, - 0x00, 0x00, 0xFF, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0xF7, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x17, 0x14, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0xF4, 0x14, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x00, 0x00, 0x1F, 0x10, 0x1F, - 0x00, 0x00, 0x00, 0x1F, 0x14, - 0x00, 0x00, 0x00, 0xFC, 0x14, - 0x00, 0x00, 0xF0, 0x10, 0xF0, - 0x10, 0x10, 0xFF, 0x10, 0xFF, - 0x14, 0x14, 0x14, 0xFF, 0x14, - 0x10, 0x10, 0x10, 0x1F, 0x00, - 0x00, 0x00, 0x00, 0xF0, 0x10, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x38, 0x44, 0x44, 0x38, 0x44, - 0x7C, 0x2A, 0x2A, 0x3E, 0x14, - 0x7E, 0x02, 0x02, 0x06, 0x06, - 0x02, 0x7E, 0x02, 0x7E, 0x02, - 0x63, 0x55, 0x49, 0x41, 0x63, - 0x38, 0x44, 0x44, 0x3C, 0x04, - 0x40, 0x7E, 0x20, 0x1E, 0x20, - 0x06, 0x02, 0x7E, 0x02, 0x02, - 0x99, 0xA5, 0xE7, 0xA5, 0x99, - 0x1C, 0x2A, 0x49, 0x2A, 0x1C, - 0x4C, 0x72, 0x01, 0x72, 0x4C, - 0x30, 0x4A, 0x4D, 0x4D, 0x30, - 0x30, 0x48, 0x78, 0x48, 0x30, - 0xBC, 0x62, 0x5A, 0x46, 0x3D, - 0x3E, 0x49, 0x49, 0x49, 0x00, - 0x7E, 0x01, 0x01, 0x01, 0x7E, - 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, - 0x44, 0x44, 0x5F, 0x44, 0x44, - 0x40, 0x51, 0x4A, 0x44, 0x40, - 0x40, 0x44, 0x4A, 0x51, 0x40, - 0x00, 0x00, 0xFF, 0x01, 0x03, - 0xE0, 0x80, 0xFF, 0x00, 0x00, - 0x08, 0x08, 0x6B, 0x6B, 0x08, - 0x36, 0x12, 0x36, 0x24, 0x36, - 0x06, 0x0F, 0x09, 0x0F, 0x06, - 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x10, 0x10, 0x00, - 0x30, 0x40, 0xFF, 0x01, 0x01, - 0x00, 0x1F, 0x01, 0x01, 0x1E, - 0x00, 0x19, 0x1D, 0x17, 0x12, - 0x00, 0x3C, 0x3C, 0x3C, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00 -}; -#endif // FONT5X7_H diff --git a/GD32F1/libraries/ILI9341_due_STM/keywords.txt b/GD32F1/libraries/ILI9341_due_STM/keywords.txt deleted file mode 100644 index 8278c0b..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/keywords.txt +++ /dev/null @@ -1,38 +0,0 @@ -ILI9341_due KEYWORD1 -ILI9341_due_gText KEYWORD1 -ILI9341_BLACK LITERAL1 -ILI9341_BLUE LITERAL1 -ILI9341_RED LITERAL1 -ILI9341_GREEN LITERAL1 -ILI9341_CYAN LITERAL1 -ILI9341_MAGENTA LITERAL1 -ILI9341_YELLOW LITERAL1 -ILI9341_WHITE LITERAL1 -pushColor KEYWORD2 -fillScreen KEYWORD2 -drawPixel KEYWORD2 -drawFastVLine KEYWORD2 -drawFastHLine KEYWORD2 -drawRect KEYWORD2 -fillRect KEYWORD2 -setRotation KEYWORD2 -invertDisplay KEYWORD2 -setAddrWindow KEYWORD2 -color565 KEYWORD2 -readcommand8 KEYWORD2 -readPixel KEYWORD2 -drawCircle KEYWORD2 -fillCircle KEYWORD2 -drawTriangle KEYWORD2 -fillTriangle KEYWORD2 -drawRoundRect KEYWORD2 -fillRoundRect KEYWORD2 -drawBitmap KEYWORD2 -drawChar KEYWORD2 -setCursor KEYWORD2 -setTextColor KEYWORD2 -setTextSize KEYWORD2 -setTextWrap KEYWORD2 -drawLine KEYWORD2 -DefineArea KEYWORD2 -SelectFont KEYWORD2 diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/BMP24toILI565.exe b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/BMP24toILI565.exe deleted file mode 100644 index c8f2e5b..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/BMP24toILI565.exe and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/App.config b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/App.config deleted file mode 100644 index 8e15646..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.csproj b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.csproj deleted file mode 100644 index 2d9c787..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.csproj +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Debug - AnyCPU - {D2F086B2-74B5-4256-BCEE-719106D306F9} - Exe - Properties - BMP24toILI565 - BMP24toILI565 - v4.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.csproj.user b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.csproj.user deleted file mode 100644 index 509f793..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.csproj.user +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.sln b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.sln deleted file mode 100644 index 803a209..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/BMP24toILI565.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMP24toILI565", "BMP24toILI565.csproj", "{D2F086B2-74B5-4256-BCEE-719106D306F9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D2F086B2-74B5-4256-BCEE-719106D306F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D2F086B2-74B5-4256-BCEE-719106D306F9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D2F086B2-74B5-4256-BCEE-719106D306F9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D2F086B2-74B5-4256-BCEE-719106D306F9}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/Program.cs b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/Program.cs deleted file mode 100644 index 995c290..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/Program.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace BMP24toILI565 -{ - internal class Program - { - static private FileStream rgb24file; - static private FileStream rgb16file; - static private int bmpWidth, bmpHeight; // W+H in pixels - static private int bmpDepth; // Bit depth (currently must be 24) - static private UInt32 bmpImageoffset; // Start of image data in file - static private int rowSize; // Not always = bmpWidth; may have padding - static private bool goodBmp = false; // Set to true on valid header parse - static private bool flip = true; // BMP is stored bottom-to-top - static private UInt16 w, h, row, col; - static private byte r, g, b; - static private long pos = 0, startTime; - static private bool first = true; - - - private static void Main(string[] args) - { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - string exeFilename = Path.GetFileName(codeBase); - - if (args.Length == 0) - { - var bmpFiles = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.bmp").ToList(); - if (bmpFiles.Count == 0) - Console.WriteLine("\nNo .bmp files found."); - else - bmpFiles.ForEach(i => ConvertImage(i)); - } - else - { - ConvertImage(args[0]); - } - } - - static void ConvertImage(string imageFilename) - { - if (File.Exists(imageFilename)) - { - try - { - Console.WriteLine("\nConverting {0}...", imageFilename); - rgb24file = new FileStream(imageFilename, FileMode.Open); - if (rgb24file == null) - { - Console.WriteLine("Could not open {0}", imageFilename); - return; - } - - rgb24file.Seek(0, SeekOrigin.Begin); - - if (read16(rgb24file) != 0x4D42) - { - Console.WriteLine("Not a BMP file"); - return; - } - - // BMP signature - Console.WriteLine("File size: {0}", read32(rgb24file)); - read32(rgb24file); // Read & ignore creator bytes - bmpImageoffset = read32(rgb24file); // Start of image data - Console.WriteLine("Image Offset: {0}", bmpImageoffset); - // Read DIB header - Console.WriteLine("Header size: {0}", read32(rgb24file)); - bmpWidth = (UInt16)read32(rgb24file); - bmpHeight = (UInt16)read32(rgb24file); - if (read16(rgb24file) != 1) // # planes -- must be '1' - { - Console.WriteLine("Number of planes must be 1"); - return; - } - - bmpDepth = read16(rgb24file); // bits per pixel - Console.WriteLine("Bit Depth: {0}", bmpDepth); - if (bmpDepth != 24) - { - Console.WriteLine("Image is not in 24bit"); - return; - } - - if (read32(rgb24file) != 0) // 0 = uncompressed - { - Console.WriteLine("BMP must be in uncompressed format"); - return; - } - - goodBmp = true; // Supported BMP format -- proceed! - Console.WriteLine("Image size: {0}x{1}", bmpWidth, bmpHeight); - - string outFilename = Path.ChangeExtension(imageFilename, "565"); - - Console.WriteLine("{0} created", outFilename); - - rgb16file = new FileStream(outFilename, FileMode.Create); - - if (rgb16file == null) - { - Console.WriteLine("Could not create file {0}", outFilename); - return; - } - - var header = new byte[54]; - - rgb24file.Seek(0, SeekOrigin.Begin); - rgb24file.Read(header, 0, 54); - - header[0x1C] = 16; // updage bit depth to 16 bpp - - rgb16file.Write(header, 0, 54); - - // BMP rows are padded (if needed) to 4-byte boundary - rowSize = (bmpWidth * 3 + 3) & ~3; - - // If bmpHeight is negative, image is in top-down order. - // This is not canon but has been observed in the wild. - if (bmpHeight < 0) - { - bmpHeight = -bmpHeight; - flip = false; - } - - var inRGB = new byte[3]; - var outRGB = new byte[2]; - - for (row = 0; row < bmpHeight; row++) - { - // For each scanline... - - if (flip) // Bitmap is stored bottom-to-top order (normal BMP) - pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize; - else // Bitmap is stored top-to-bottom - pos = bmpImageoffset + row * rowSize; - - rgb24file.Seek(pos, SeekOrigin.Begin); - - for (var c = 0; c < 3 * bmpWidth; c += 3) - { - rgb24file.Read(inRGB, 0, 3); - - UInt16 iliColor = to565(inRGB[2], inRGB[1], inRGB[0]); - outRGB[0] = (byte)(iliColor >> 8); - outRGB[1] = (byte)(iliColor & 0xFF); - rgb16file.Write(outRGB, 0, 2); - } - } - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - Console.WriteLine(ex.StackTrace); - } - finally - { - if (rgb24file != null) - { - rgb24file.Close(); - rgb24file = null; - } - if (rgb16file != null) - { - rgb16file.Close(); - rgb16file = null; - } - } - } - else - { - Console.WriteLine("File {0} does not exists"); - } - } - - static private UInt16 to565(byte r, byte g, byte b) - { - return (UInt16)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); - //return ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3); - } - - static UInt16 read16(FileStream file) - { - var bytes = new byte[2]; - - file.Read(bytes, 0, 2); - var word = (UInt16)(bytes[1] << 8 | bytes[0]); - - return word; - } - - static UInt32 read32(FileStream file) - { - var bytes = new byte[4]; - - file.Read(bytes, 0, 4); - var dword = (UInt32)(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0]); - - return dword; - } - } - - -} diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/Properties/AssemblyInfo.cs b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/Properties/AssemblyInfo.cs deleted file mode 100644 index c7a75dc..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/.NET/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("BMP24toILI565")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("BMP24toILI565")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("79edc0d8-9635-4e86-9a00-3e845d89d64b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/BMP24toILI565.exe b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/BMP24toILI565.exe deleted file mode 100644 index a1c2ee1..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/BMP24toILI565.exe and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.cpp b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.cpp deleted file mode 100644 index db3398c..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// BMP24toILI565.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include -#include -#include -#include "dirent.h" - -FILE *rgb24file; -FILE *rgb16file; -int bmpWidth, bmpHeight; // W+H in pixels -UINT16 bmpDepth; // Bit depth (currently must be 24) -UINT32 bmpImageoffset; // Start of image data in file -UINT32 rowSize; // Not always = bmpWidth; may have padding -boolean goodBmp = false; // Set to true on valid header parse -boolean flip = true; // BMP is stored bottom-to-top -UINT16 w, h, row, col; -UINT8 r, g, b; -UINT32 pos = 0, startTime; -bool first = true; -DIR* dir; -struct dirent *ent; - - -//inline UINT16 read16(FILE *file) -//{ -// UINT16 word; -// fread(&word, 2, 1, file); -// return word; -//} - -//inline UINT16 read32(FILE *file) -//{ -// UINT32 dword; -// fread(&dword, 4, 1, file); -// return dword; -//} - -UINT16 read16(FILE *file) { - UINT16 word; - fread(&(((UINT8 *)&word)[0]), 1, 1, file); - fread(&(((UINT8 *)&word)[1]), 1, 1, file); - //((UINT8 *)&word)[0] = f.read(); // LSB - //((UINT8 *)&word)[1] = f.read(); // MSB - return word; -} -// -UINT32 read32(FILE *file) { - UINT32 dword; - fread(&(((UINT8 *)&dword)[0]), 1, 1, file); - fread(&(((UINT8 *)&dword)[1]), 1, 1, file); - fread(&(((UINT8 *)&dword)[2]), 1, 1, file); - fread(&(((UINT8 *)&dword)[3]), 1, 1, file); - return dword; -} - -inline UINT16 to565(UINT8 r, UINT8 g, UINT8 b) -{ - return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); - //return ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3); -} - -int convertImage(char* filename) -{ - try - { - printf("\n"); - printf("Converting %s...\n", filename); - rgb24file = fopen(filename, "rb"); - if (rgb24file == NULL) - { - printf("Could not find file %s \n", filename); - return -1; - } - - fseek(rgb24file, 0, SEEK_SET); - - if(read16(rgb24file) != 0x4D42) // BMP signature - { - printf("Not a BMP file.\n"); - return -1; - } - - printf("File size: %u\n", read32(rgb24file)); - (void)read32(rgb24file); // Read & ignore creator bytes - bmpImageoffset = read32(rgb24file); // Start of image data - printf("Image Offset: %d\n", bmpImageoffset); - // Read DIB header - printf("Header size: %d\n", read32(rgb24file)); - bmpWidth = read32(rgb24file); - bmpHeight = read32(rgb24file); - - if(read16(rgb24file) != 1) // # planes -- must be '1' - { - printf("Number of planes must be 1\n"); - return -1; - } - - bmpDepth = read16(rgb24file); // bits per pixel - printf("Bit Depth: %d\n", bmpDepth); - - if(bmpDepth != 24) - { - printf("Image is not in 24bit\n"); - return -1; - } - - if(read32(rgb24file) != 0) // 0 = uncompressed - { - printf("BMP must be in uncompressed format\n"); - return -1; - } - - goodBmp = true; // Supported BMP format -- proceed! - printf("Image size: %dx%d\n", bmpWidth, bmpHeight); - - char outFilename[255]; - sprintf(outFilename, "%s", filename); - sprintf(outFilename+strlen(filename)-3, "565"); - - printf("%s created\n", outFilename); - rgb16file = fopen(outFilename, "wb"); - - if(rgb16file == NULL) - { - printf("Could not create file %s\n", outFilename); - return -1; - } - - UINT8 header[54]; - fseek(rgb24file, 0, SEEK_SET); - fread(header, 1, 54, rgb24file); - - header[0x1C] = 16; // updage bit depth to 16 bpp - - fwrite(header, 1, 54, rgb16file); - - // BMP rows are padded (if needed) to 4-byte boundary - rowSize = (bmpWidth * 3 + 3) & ~3; - - // If bmpHeight is negative, image is in top-down order. - // This is not canon but has been observed in the wild. - if(bmpHeight < 0) { - bmpHeight = -bmpHeight; - flip = false; - } - - UINT8 inRGB[3], outRGB[2]; - - for (row=0; row> 8; - outRGB[1] = iliColor & 0xFF; - fwrite(outRGB, 1, 2, rgb16file); - } - } - } - catch(...) - { - printf("Error converting file\n"); - } - - _fcloseall(); -} - -int main(int argc, char *argv[]) -{ - if (argc == 1) - { - if ((dir = opendir (".")) != NULL) { - /* print all the files and directories within directory */ - int bmpFilesFound = 0; - while ((ent = readdir(dir)) != NULL) { - if(strncmp(ent->d_name + ent->d_namlen - 4, ".bmp", 4) == 0) - { - convertImage(ent->d_name); - bmpFilesFound++; - } - } - closedir (dir); - if(bmpFilesFound == 0) - { - printf("\n"); - printf("No .bmp files found.\n"); - } - } else { - /* could not open directory */ - perror (""); - return EXIT_FAILURE; - } - } - else - { - convertImage(argv[1]); - } - - -} diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.sln b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.sln deleted file mode 100644 index a3eee5b..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BMP24toILI565", "BMP24toILI565.vcxproj", "{EFE947CC-711C-44E0-9FA5-605D37DD3E8C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EFE947CC-711C-44E0-9FA5-605D37DD3E8C}.Debug|Win32.ActiveCfg = Debug|Win32 - {EFE947CC-711C-44E0-9FA5-605D37DD3E8C}.Debug|Win32.Build.0 = Debug|Win32 - {EFE947CC-711C-44E0-9FA5-605D37DD3E8C}.Release|Win32.ActiveCfg = Release|Win32 - {EFE947CC-711C-44E0-9FA5-605D37DD3E8C}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.vcxproj b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.vcxproj deleted file mode 100644 index 4157e33..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.vcxproj +++ /dev/null @@ -1,95 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {EFE947CC-711C-44E0-9FA5-605D37DD3E8C} - Win32Proj - BMP24toILI565 - - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - Create - Create - - - - - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.vcxproj.filters b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.vcxproj.filters deleted file mode 100644 index 515d073..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/BMP24toILI565.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/ReadMe.txt b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/ReadMe.txt deleted file mode 100644 index b72047a..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/ReadMe.txt +++ /dev/null @@ -1,40 +0,0 @@ -======================================================================== - CONSOLE APPLICATION : BMP24toILI565 Project Overview -======================================================================== - -AppWizard has created this BMP24toILI565 application for you. - -This file contains a summary of what you will find in each of the files that -make up your BMP24toILI565 application. - - -BMP24toILI565.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -BMP24toILI565.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -BMP24toILI565.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named BMP24toILI565.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/dirent.h b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/dirent.h deleted file mode 100644 index 6f959a5..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/dirent.h +++ /dev/null @@ -1,838 +0,0 @@ -/* - * dirent.h - dirent API for Microsoft Visual Studio - * - * Copyright (C) 2006-2012 Toni Ronkko - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * ``Software''), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * $Id: dirent.h,v 1.20 2014/03/19 17:52:23 tronkko Exp $ - */ -#ifndef DIRENT_H -#define DIRENT_H - -/* - * Define architecture flags so we don't need to include windows.h. - * Avoiding windows.h makes it simpler to use windows sockets in conjunction - * with dirent.h. - */ -#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86) -# define _X86_ -#endif -#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64) -#define _AMD64_ -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Indicates that d_type field is available in dirent structure */ -#define _DIRENT_HAVE_D_TYPE - -/* Indicates that d_namlen field is available in dirent structure */ -#define _DIRENT_HAVE_D_NAMLEN - -/* Entries missing from MSVC 6.0 */ -#if !defined(FILE_ATTRIBUTE_DEVICE) -# define FILE_ATTRIBUTE_DEVICE 0x40 -#endif - -/* File type and permission flags for stat() */ -#if !defined(S_IFMT) -# define S_IFMT _S_IFMT /* File type mask */ -#endif -#if !defined(S_IFDIR) -# define S_IFDIR _S_IFDIR /* Directory */ -#endif -#if !defined(S_IFCHR) -# define S_IFCHR _S_IFCHR /* Character device */ -#endif -#if !defined(S_IFFIFO) -# define S_IFFIFO _S_IFFIFO /* Pipe */ -#endif -#if !defined(S_IFREG) -# define S_IFREG _S_IFREG /* Regular file */ -#endif -#if !defined(S_IREAD) -# define S_IREAD _S_IREAD /* Read permission */ -#endif -#if !defined(S_IWRITE) -# define S_IWRITE _S_IWRITE /* Write permission */ -#endif -#if !defined(S_IEXEC) -# define S_IEXEC _S_IEXEC /* Execute permission */ -#endif -#if !defined(S_IFIFO) -# define S_IFIFO _S_IFIFO /* Pipe */ -#endif -#if !defined(S_IFBLK) -# define S_IFBLK 0 /* Block device */ -#endif -#if !defined(S_IFLNK) -# define S_IFLNK 0 /* Link */ -#endif -#if !defined(S_IFSOCK) -# define S_IFSOCK 0 /* Socket */ -#endif - -#if defined(_MSC_VER) -# define S_IRUSR S_IREAD /* Read user */ -# define S_IWUSR S_IWRITE /* Write user */ -# define S_IXUSR 0 /* Execute user */ -# define S_IRGRP 0 /* Read group */ -# define S_IWGRP 0 /* Write group */ -# define S_IXGRP 0 /* Execute group */ -# define S_IROTH 0 /* Read others */ -# define S_IWOTH 0 /* Write others */ -# define S_IXOTH 0 /* Execute others */ -#endif - -/* Maximum length of file name */ -#if !defined(PATH_MAX) -# define PATH_MAX MAX_PATH -#endif -#if !defined(FILENAME_MAX) -# define FILENAME_MAX MAX_PATH -#endif -#if !defined(NAME_MAX) -# define NAME_MAX FILENAME_MAX -#endif - -/* File type flags for d_type */ -#define DT_UNKNOWN 0 -#define DT_REG S_IFREG -#define DT_DIR S_IFDIR -#define DT_FIFO S_IFIFO -#define DT_SOCK S_IFSOCK -#define DT_CHR S_IFCHR -#define DT_BLK S_IFBLK -#define DT_LNK S_IFLNK - -/* Macros for converting between st_mode and d_type */ -#define IFTODT(mode) ((mode) & S_IFMT) -#define DTTOIF(type) (type) - -/* - * File type macros. Note that block devices, sockets and links cannot be - * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are - * only defined for compatibility. These macros should always return false - * on Windows. - */ -#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) -#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) -#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) -#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) -#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) -#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) - -/* Return the exact length of d_namlen without zero terminator */ -#define _D_EXACT_NAMLEN(p) ((p)->d_namlen) - -/* Return number of bytes needed to store d_namlen */ -#define _D_ALLOC_NAMLEN(p) (PATH_MAX) - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Wide-character version */ -struct _wdirent { - long d_ino; /* Always zero */ - unsigned short d_reclen; /* Structure size */ - size_t d_namlen; /* Length of name without \0 */ - int d_type; /* File type */ - wchar_t d_name[PATH_MAX]; /* File name */ -}; -typedef struct _wdirent _wdirent; - -struct _WDIR { - struct _wdirent ent; /* Current directory entry */ - WIN32_FIND_DATAW data; /* Private file data */ - int cached; /* True if data is valid */ - HANDLE handle; /* Win32 search handle */ - wchar_t *patt; /* Initial directory name */ -}; -typedef struct _WDIR _WDIR; - -static _WDIR *_wopendir (const wchar_t *dirname); -static struct _wdirent *_wreaddir (_WDIR *dirp); -static int _wclosedir (_WDIR *dirp); -static void _wrewinddir (_WDIR* dirp); - - -/* For compatibility with Symbian */ -#define wdirent _wdirent -#define WDIR _WDIR -#define wopendir _wopendir -#define wreaddir _wreaddir -#define wclosedir _wclosedir -#define wrewinddir _wrewinddir - - -/* Multi-byte character versions */ -struct dirent { - long d_ino; /* Always zero */ - unsigned short d_reclen; /* Structure size */ - size_t d_namlen; /* Length of name without \0 */ - int d_type; /* File type */ - char d_name[PATH_MAX]; /* File name */ -}; -typedef struct dirent dirent; - -struct DIR { - struct dirent ent; - struct _WDIR *wdirp; -}; -typedef struct DIR DIR; - -static DIR *opendir (const char *dirname); -static struct dirent *readdir (DIR *dirp); -static int closedir (DIR *dirp); -static void rewinddir (DIR* dirp); - - -/* Internal utility functions */ -static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp); -static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp); - -static int dirent_mbstowcs_s( - size_t *pReturnValue, - wchar_t *wcstr, - size_t sizeInWords, - const char *mbstr, - size_t count); - -static int dirent_wcstombs_s( - size_t *pReturnValue, - char *mbstr, - size_t sizeInBytes, - const wchar_t *wcstr, - size_t count); - -static void dirent_set_errno (int error); - -/* - * Open directory stream DIRNAME for read and return a pointer to the - * internal working area that is used to retrieve individual directory - * entries. - */ -static _WDIR* -_wopendir( - const wchar_t *dirname) -{ - _WDIR *dirp = NULL; - int error; - - /* Must have directory name */ - if (dirname == NULL || dirname[0] == '\0') { - dirent_set_errno (ENOENT); - return NULL; - } - - /* Allocate new _WDIR structure */ - dirp = (_WDIR*) malloc (sizeof (struct _WDIR)); - if (dirp != NULL) { - DWORD n; - - /* Reset _WDIR structure */ - dirp->handle = INVALID_HANDLE_VALUE; - dirp->patt = NULL; - dirp->cached = 0; - - /* Compute the length of full path plus zero terminator */ - n = GetFullPathNameW (dirname, 0, NULL, NULL); - - /* Allocate room for absolute directory name and search pattern */ - dirp->patt = (wchar_t*) malloc (sizeof (wchar_t) * n + 16); - if (dirp->patt) { - - /* - * Convert relative directory name to an absolute one. This - * allows rewinddir() to function correctly even when current - * working directory is changed between opendir() and rewinddir(). - */ - n = GetFullPathNameW (dirname, n, dirp->patt, NULL); - if (n > 0) { - wchar_t *p; - - /* Append search pattern \* to the directory name */ - p = dirp->patt + n; - if (dirp->patt < p) { - switch (p[-1]) { - case '\\': - case '/': - case ':': - /* Directory ends in path separator, e.g. c:\temp\ */ - /*NOP*/; - break; - - default: - /* Directory name doesn't end in path separator */ - *p++ = '\\'; - } - } - *p++ = '*'; - *p = '\0'; - - /* Open directory stream and retrieve the first entry */ - if (dirent_first (dirp)) { - /* Directory stream opened successfully */ - error = 0; - } else { - /* Cannot retrieve first entry */ - error = 1; - dirent_set_errno (ENOENT); - } - - } else { - /* Cannot retrieve full path name */ - dirent_set_errno (ENOENT); - error = 1; - } - - } else { - /* Cannot allocate memory for search pattern */ - error = 1; - } - - } else { - /* Cannot allocate _WDIR structure */ - error = 1; - } - - /* Clean up in case of error */ - if (error && dirp) { - _wclosedir (dirp); - dirp = NULL; - } - - return dirp; -} - -/* - * Read next directory entry. The directory entry is returned in dirent - * structure in the d_name field. Individual directory entries returned by - * this function include regular files, sub-directories, pseudo-directories - * "." and ".." as well as volume labels, hidden files and system files. - */ -static struct _wdirent* -_wreaddir( - _WDIR *dirp) -{ - WIN32_FIND_DATAW *datap; - struct _wdirent *entp; - - /* Read next directory entry */ - datap = dirent_next (dirp); - if (datap) { - size_t n; - DWORD attr; - - /* Pointer to directory entry to return */ - entp = &dirp->ent; - - /* - * Copy file name as wide-character string. If the file name is too - * long to fit in to the destination buffer, then truncate file name - * to PATH_MAX characters and zero-terminate the buffer. - */ - n = 0; - while (n + 1 < PATH_MAX && datap->cFileName[n] != 0) { - entp->d_name[n] = datap->cFileName[n]; - n++; - } - dirp->ent.d_name[n] = 0; - - /* Length of file name excluding zero terminator */ - entp->d_namlen = n; - - /* File type */ - attr = datap->dwFileAttributes; - if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) { - entp->d_type = DT_CHR; - } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { - entp->d_type = DT_DIR; - } else { - entp->d_type = DT_REG; - } - - /* Reset dummy fields */ - entp->d_ino = 0; - entp->d_reclen = sizeof (struct _wdirent); - - } else { - - /* Last directory entry read */ - entp = NULL; - - } - - return entp; -} - -/* - * Close directory stream opened by opendir() function. This invalidates the - * DIR structure as well as any directory entry read previously by - * _wreaddir(). - */ -static int -_wclosedir( - _WDIR *dirp) -{ - int ok; - if (dirp) { - - /* Release search handle */ - if (dirp->handle != INVALID_HANDLE_VALUE) { - FindClose (dirp->handle); - dirp->handle = INVALID_HANDLE_VALUE; - } - - /* Release search pattern */ - if (dirp->patt) { - free (dirp->patt); - dirp->patt = NULL; - } - - /* Release directory structure */ - free (dirp); - ok = /*success*/0; - - } else { - /* Invalid directory stream */ - dirent_set_errno (EBADF); - ok = /*failure*/-1; - } - return ok; -} - -/* - * Rewind directory stream such that _wreaddir() returns the very first - * file name again. - */ -static void -_wrewinddir( - _WDIR* dirp) -{ - if (dirp) { - /* Release existing search handle */ - if (dirp->handle != INVALID_HANDLE_VALUE) { - FindClose (dirp->handle); - } - - /* Open new search handle */ - dirent_first (dirp); - } -} - -/* Get first directory entry (internal) */ -static WIN32_FIND_DATAW* -dirent_first( - _WDIR *dirp) -{ - WIN32_FIND_DATAW *datap; - - /* Open directory and retrieve the first entry */ - dirp->handle = FindFirstFileW (dirp->patt, &dirp->data); - if (dirp->handle != INVALID_HANDLE_VALUE) { - - /* a directory entry is now waiting in memory */ - datap = &dirp->data; - dirp->cached = 1; - - } else { - - /* Failed to re-open directory: no directory entry in memory */ - dirp->cached = 0; - datap = NULL; - - } - return datap; -} - -/* Get next directory entry (internal) */ -static WIN32_FIND_DATAW* -dirent_next( - _WDIR *dirp) -{ - WIN32_FIND_DATAW *p; - - /* Get next directory entry */ - if (dirp->cached != 0) { - - /* A valid directory entry already in memory */ - p = &dirp->data; - dirp->cached = 0; - - } else if (dirp->handle != INVALID_HANDLE_VALUE) { - - /* Get the next directory entry from stream */ - if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) { - /* Got a file */ - p = &dirp->data; - } else { - /* The very last entry has been processed or an error occured */ - FindClose (dirp->handle); - dirp->handle = INVALID_HANDLE_VALUE; - p = NULL; - } - - } else { - - /* End of directory stream reached */ - p = NULL; - - } - - return p; -} - -/* - * Open directory stream using plain old C-string. - */ -static DIR* -opendir( - const char *dirname) -{ - struct DIR *dirp; - int error; - - /* Must have directory name */ - if (dirname == NULL || dirname[0] == '\0') { - dirent_set_errno (ENOENT); - return NULL; - } - - /* Allocate memory for DIR structure */ - dirp = (DIR*) malloc (sizeof (struct DIR)); - if (dirp) { - wchar_t wname[PATH_MAX]; - size_t n; - - /* Convert directory name to wide-character string */ - error = dirent_mbstowcs_s (&n, wname, PATH_MAX, dirname, PATH_MAX); - if (!error) { - - /* Open directory stream using wide-character name */ - dirp->wdirp = _wopendir (wname); - if (dirp->wdirp) { - /* Directory stream opened */ - error = 0; - } else { - /* Failed to open directory stream */ - error = 1; - } - - } else { - /* - * Cannot convert file name to wide-character string. This - * occurs if the string contains invalid multi-byte sequences or - * the output buffer is too small to contain the resulting - * string. - */ - error = 1; - } - - } else { - /* Cannot allocate DIR structure */ - error = 1; - } - - /* Clean up in case of error */ - if (error && dirp) { - free (dirp); - dirp = NULL; - } - - return dirp; -} - -/* - * Read next directory entry. - * - * When working with text consoles, please note that file names returned by - * readdir() are represented in the default ANSI code page while any output to - * console is typically formatted on another code page. Thus, non-ASCII - * characters in file names will not usually display correctly on console. The - * problem can be fixed in two ways: (1) change the character set of console - * to 1252 using chcp utility and use Lucida Console font, or (2) use - * _cprintf function when writing to console. The _cprinf() will re-encode - * ANSI strings to the console code page so many non-ASCII characters will - * display correcly. - */ -static struct dirent* -readdir( - DIR *dirp) -{ - WIN32_FIND_DATAW *datap; - struct dirent *entp; - - /* Read next directory entry */ - datap = dirent_next (dirp->wdirp); - if (datap) { - size_t n; - int error; - - /* Attempt to convert file name to multi-byte string */ - error = dirent_wcstombs_s( - &n, dirp->ent.d_name, PATH_MAX, datap->cFileName, PATH_MAX); - - /* - * If the file name cannot be represented by a multi-byte string, - * then attempt to use old 8+3 file name. This allows traditional - * Unix-code to access some file names despite of unicode - * characters, although file names may seem unfamiliar to the user. - * - * Be ware that the code below cannot come up with a short file - * name unless the file system provides one. At least - * VirtualBox shared folders fail to do this. - */ - if (error && datap->cAlternateFileName[0] != '\0') { - error = dirent_wcstombs_s( - &n, dirp->ent.d_name, PATH_MAX, - datap->cAlternateFileName, PATH_MAX); - } - - if (!error) { - DWORD attr; - - /* Initialize directory entry for return */ - entp = &dirp->ent; - - /* Length of file name excluding zero terminator */ - entp->d_namlen = n - 1; - - /* File attributes */ - attr = datap->dwFileAttributes; - if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) { - entp->d_type = DT_CHR; - } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { - entp->d_type = DT_DIR; - } else { - entp->d_type = DT_REG; - } - - /* Reset dummy fields */ - entp->d_ino = 0; - entp->d_reclen = sizeof (struct dirent); - - } else { - /* - * Cannot convert file name to multi-byte string so construct - * an errornous directory entry and return that. Note that - * we cannot return NULL as that would stop the processing - * of directory entries completely. - */ - entp = &dirp->ent; - entp->d_name[0] = '?'; - entp->d_name[1] = '\0'; - entp->d_namlen = 1; - entp->d_type = DT_UNKNOWN; - entp->d_ino = 0; - entp->d_reclen = 0; - } - - } else { - /* No more directory entries */ - entp = NULL; - } - - return entp; -} - -/* - * Close directory stream. - */ -static int -closedir( - DIR *dirp) -{ - int ok; - if (dirp) { - - /* Close wide-character directory stream */ - ok = _wclosedir (dirp->wdirp); - dirp->wdirp = NULL; - - /* Release multi-byte character version */ - free (dirp); - - } else { - - /* Invalid directory stream */ - dirent_set_errno (EBADF); - ok = /*failure*/-1; - - } - return ok; -} - -/* - * Rewind directory stream to beginning. - */ -static void -rewinddir( - DIR* dirp) -{ - /* Rewind wide-character string directory stream */ - _wrewinddir (dirp->wdirp); -} - -/* Convert multi-byte string to wide character string */ -static int -dirent_mbstowcs_s( - size_t *pReturnValue, - wchar_t *wcstr, - size_t sizeInWords, - const char *mbstr, - size_t count) -{ - int error; - -#if defined(_MSC_VER) && _MSC_VER >= 1400 - - /* Microsoft Visual Studio 2005 or later */ - error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count); - -#else - - /* Older Visual Studio or non-Microsoft compiler */ - size_t n; - - /* Convert to wide-character string (or count characters) */ - n = mbstowcs (wcstr, mbstr, sizeInWords); - if (!wcstr || n < count) { - - /* Zero-terminate output buffer */ - if (wcstr && sizeInWords) { - if (n >= sizeInWords) { - n = sizeInWords - 1; - } - wcstr[n] = 0; - } - - /* Length of resuting multi-byte string WITH zero terminator */ - if (pReturnValue) { - *pReturnValue = n + 1; - } - - /* Success */ - error = 0; - - } else { - - /* Could not convert string */ - error = 1; - - } - -#endif - - return error; -} - -/* Convert wide-character string to multi-byte string */ -static int -dirent_wcstombs_s( - size_t *pReturnValue, - char *mbstr, - size_t sizeInBytes, /* max size of mbstr */ - const wchar_t *wcstr, - size_t count) -{ - int error; - -#if defined(_MSC_VER) && _MSC_VER >= 1400 - - /* Microsoft Visual Studio 2005 or later */ - error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count); - -#else - - /* Older Visual Studio or non-Microsoft compiler */ - size_t n; - - /* Convert to multi-byte string (or count the number of bytes needed) */ - n = wcstombs (mbstr, wcstr, sizeInBytes); - if (!mbstr || n < count) { - - /* Zero-terminate output buffer */ - if (mbstr && sizeInBytes) { - if (n >= sizeInBytes) { - n = sizeInBytes - 1; - } - mbstr[n] = '\0'; - } - - /* Lenght of resulting multi-bytes string WITH zero-terminator */ - if (pReturnValue) { - *pReturnValue = n + 1; - } - - /* Success */ - error = 0; - - } else { - - /* Cannot convert string */ - error = 1; - - } - -#endif - - return error; -} - -/* Set errno variable */ -static void -dirent_set_errno( - int error) -{ -#if defined(_MSC_VER) && _MSC_VER >= 1400 - - /* Microsoft Visual Studio 2005 and later */ - _set_errno (error); - -#else - - /* Non-Microsoft compiler or older Microsoft compiler */ - errno = error; - -#endif -} - - -#ifdef __cplusplus -} -#endif -#endif /*DIRENT_H*/ - diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/stdafx.cpp b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/stdafx.cpp deleted file mode 100644 index f913bf5..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// BMP24toILI565.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/stdafx.h b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/stdafx.h deleted file mode 100644 index b005a83..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/stdafx.h +++ /dev/null @@ -1,15 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - - - -// TODO: reference additional headers your program requires here diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/targetver.h b/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/BMP24toILI565/C/src/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/GLCDFontCreator2.zip b/GD32F1/libraries/ILI9341_due_STM/tools/GLCDFontCreator2.zip deleted file mode 100644 index c137347..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/tools/GLCDFontCreator2.zip and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/ILIScreenshotViewer.exe b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/ILIScreenshotViewer.exe deleted file mode 100644 index 5bfe1d6..0000000 Binary files a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/ILIScreenshotViewer.exe and /dev/null differ diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/App.config b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/App.config deleted file mode 100644 index 8e15646..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.Designer.cs b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.Designer.cs deleted file mode 100644 index 75a9589..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.Designer.cs +++ /dev/null @@ -1,108 +0,0 @@ -namespace ILIScreenshotViewer -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.pictureBox = new System.Windows.Forms.PictureBox(); - this.btnShow = new System.Windows.Forms.Button(); - this.lblFailed = new System.Windows.Forms.Label(); - this.btnSaveAs = new System.Windows.Forms.Button(); - this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); - this.SuspendLayout(); - // - // pictureBox - // - this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pictureBox.Location = new System.Drawing.Point(12, 12); - this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(320, 240); - this.pictureBox.TabIndex = 0; - this.pictureBox.TabStop = false; - // - // btnShow - // - this.btnShow.Location = new System.Drawing.Point(93, 258); - this.btnShow.Name = "btnShow"; - this.btnShow.Size = new System.Drawing.Size(158, 23); - this.btnShow.TabIndex = 2; - this.btnShow.Text = "Load Image from Clipboard"; - this.btnShow.UseVisualStyleBackColor = true; - this.btnShow.Click += new System.EventHandler(this.btnShow_Click); - // - // lblFailed - // - this.lblFailed.Location = new System.Drawing.Point(47, 84); - this.lblFailed.Name = "lblFailed"; - this.lblFailed.Size = new System.Drawing.Size(251, 86); - this.lblFailed.TabIndex = 3; - this.lblFailed.Text = "Failed to load an image from clipboard"; - this.lblFailed.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblFailed.Visible = false; - // - // btnSaveAs - // - this.btnSaveAs.Location = new System.Drawing.Point(258, 258); - this.btnSaveAs.Name = "btnSaveAs"; - this.btnSaveAs.Size = new System.Drawing.Size(75, 23); - this.btnSaveAs.TabIndex = 4; - this.btnSaveAs.Text = "Save As..."; - this.btnSaveAs.UseVisualStyleBackColor = true; - this.btnSaveAs.Visible = false; - this.btnSaveAs.Click += new System.EventHandler(this.btnSaveAs_Click); - // - // saveFileDialog - // - this.saveFileDialog.Filter = "*.bmp|*.bmp|*.png|*.png|*.gif|*.gif|*.jpg|*.jpg|All Files (*.*)|*.*"; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(347, 294); - this.Controls.Add(this.btnSaveAs); - this.Controls.Add(this.lblFailed); - this.Controls.Add(this.btnShow); - this.Controls.Add(this.pictureBox); - this.Name = "Form1"; - this.Text = "ILI Screenshot Viewer"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.PictureBox pictureBox; - private System.Windows.Forms.Button btnShow; - private System.Windows.Forms.Label lblFailed; - private System.Windows.Forms.Button btnSaveAs; - private System.Windows.Forms.SaveFileDialog saveFileDialog; - } -} - diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.cs b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.cs deleted file mode 100644 index bef5b3b..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ILIScreenshotViewer -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - - private void btnShow_Click(object sender, EventArgs e) - { - lblFailed.Visible = false; - var bitmap = new Bitmap(320, 240, PixelFormat.Format24bppRgb); - - //var hexString = Clipboard.GetText(); - //for (int x = 0; x < 320; x++) - //{ - // for (int y = 0; y < 240; y++) - // { - // var pixelColorString = hexString.Substring(4*x + 4*320*y, 4); - - // var pix = Convert.ToUInt16(pixelColorString, 16); - - - // //* For PixelFormat.Format16bppRgb565 - // //var r = BitConverter.GetBytes((UInt16)((pix & 0xF800) >> 11)); - - // int red = ((pix >> 11)*527 + 23) >> 6; - // int green = (((pix >> 5) & 0x003F)*259 + 33) >> 6; - // int blue = ((pix & 0x001F)*527 + 23) >> 6; - - // bitmap.SetPixel(x, y, Color.FromArgb(red, green, blue)); - // } - //} - - - try - { - string hexString = Clipboard.GetText(); - //for (int x = 0; x < 320; x++) - //{ - // for (int y = 0; y < 240; y++) - // { - // var pixelColorString = hexString.Substring(6 * (x + 320 * y), 6); - - // var r = Convert.ToByte(pixelColorString.Substring(0, 2), 16); - // var g = Convert.ToByte(pixelColorString.Substring(2, 2), 16); - // var b = Convert.ToByte(pixelColorString.Substring(4, 2), 16); - - // //* For PixelFormat.Format16bppRgb565 - // //var r = BitConverter.GetBytes((UInt16)((pix & 0xF800) >> 11)); - - // //int red = ((pix >> 11) * 527 + 23) >> 6; - // //int green = (((pix >> 5) & 0x003F) * 259 + 33) >> 6; - // //int blue = ((pix & 0x001F) * 527 + 23) >> 6; - - // bitmap.SetPixel(x, y, Color.FromArgb(r, g, b)); - // } - //} - int x = 0, y = 0; - var totalImageDataSize = Convert.ToUInt32(hexString.Substring(hexString.Length - 8, 8), 16); - if (hexString.Length - 8 == totalImageDataSize) - { - for (int i = 0; i < totalImageDataSize; i += 10) // 6 bytes for color, 4 bytes for length - { - var pixelColorString = hexString.Substring(i, 6); - var r = Convert.ToByte(pixelColorString.Substring(0, 2), 16); - var g = Convert.ToByte(pixelColorString.Substring(2, 2), 16); - var b = Convert.ToByte(pixelColorString.Substring(4, 2), 16); - - var pixelCountString = hexString.Substring(i + 6, 4); - var pixelCount = Convert.ToUInt16(pixelCountString, 16); - - for (int p = 0; p < pixelCount; p++) - { - bitmap.SetPixel(x, y, Color.FromArgb(r, g, b)); - x++; - if (x > 319) - { - x = 0; - y++; - } - } - } - - pictureBox.Image = bitmap; - btnSaveAs.Visible = true; - } - else - { - lblFailed.Text = "Image Data length mismatch."; - pictureBox.Image = null; - lblFailed.Visible = true; - btnSaveAs.Visible = false; - } - } - catch - { - lblFailed.Text = "Failed to load an image from clipboard\nTry increasing ILI9341_SPI_CLKDIVIDER or\nchange to NORMAL or EXTENDED SPI mode."; - pictureBox.Image = null; - lblFailed.Visible = true; - btnSaveAs.Visible = false; - } - } - - private void btnSaveAs_Click(object sender, EventArgs e) - { - saveFileDialog.FileName = Path.GetFileNameWithoutExtension(saveFileDialog.FileName); - var result = saveFileDialog.ShowDialog(); - if (result == DialogResult.OK) - { - ImageFormat imageFormat = ImageFormat.Bmp; - switch (Path.GetExtension(saveFileDialog.FileName).ToLower()) - { - case ".jpg": - imageFormat = ImageFormat.Jpeg; - break; - case ".png": - imageFormat = ImageFormat.Png; - break; - case ".gif": - imageFormat = ImageFormat.Gif; - break; - } - pictureBox.Image.Save(saveFileDialog.FileName, imageFormat); - } - - } - - } -} diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.resx b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.resx deleted file mode 100644 index 5e7f0a6..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Form1.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/ILIScreenshotViewer.csproj b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/ILIScreenshotViewer.csproj deleted file mode 100644 index 30d5cb1..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/ILIScreenshotViewer.csproj +++ /dev/null @@ -1,82 +0,0 @@ - - - - - Debug - AnyCPU - {AD6D4A3D-2F94-435B-836F-E617ED847F46} - WinExe - Properties - ILIScreenshotViewer - ILIScreenshotViewer - v4.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - Form - - - Form1.cs - - - - - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/ILIScreenshotViewer.sln b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/ILIScreenshotViewer.sln deleted file mode 100644 index ec191d3..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/ILIScreenshotViewer.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILIScreenshotViewer", "ILIScreenshotViewer.csproj", "{AD6D4A3D-2F94-435B-836F-E617ED847F46}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AD6D4A3D-2F94-435B-836F-E617ED847F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AD6D4A3D-2F94-435B-836F-E617ED847F46}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AD6D4A3D-2F94-435B-836F-E617ED847F46}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AD6D4A3D-2F94-435B-836F-E617ED847F46}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Program.cs b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Program.cs deleted file mode 100644 index f2930c0..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ILIScreenshotViewer -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } -} diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/AssemblyInfo.cs b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/AssemblyInfo.cs deleted file mode 100644 index b9edad9..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ILIScreenshotViewer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("ILIScreenshotViewer")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("bfab4204-5b3c-43c8-b397-d137817de176")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Resources.Designer.cs b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Resources.Designer.cs deleted file mode 100644 index de9c11b..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18063 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ILIScreenshotViewer.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ILIScreenshotViewer.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Resources.resx b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Settings.Designer.cs b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Settings.Designer.cs deleted file mode 100644 index feddeef..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18063 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ILIScreenshotViewer.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Settings.settings b/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Settings.settings deleted file mode 100644 index 3964565..0000000 --- a/GD32F1/libraries/ILI9341_due_STM/tools/ILIScreenshotViewer/src/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/GD32F1/libraries/Lcd7920_STM/examples/Lcd7920_STM/Lcd7920_STM.ino b/GD32F1/libraries/Lcd7920_STM/examples/Lcd7920_STM/Lcd7920_STM.ino deleted file mode 100644 index b97cf4e..0000000 --- a/GD32F1/libraries/Lcd7920_STM/examples/Lcd7920_STM/Lcd7920_STM.ino +++ /dev/null @@ -1,60 +0,0 @@ - -// ST7920-based 128x64 pixel graphic LCD demo program -// Written by D. Crocker, Escher Technologies Ltd. -// adapted for STM32-arduino by Matthias Diro and added some fonts and new commands (box, fillbox, fastVline, fastHline) -// library doesn't use SPI or some low level pin toggles --> too fast for the display -// setup Display: -// PSB must be set to ground for serial mode: maybe you must unsolder a resistor! -// only two lines are needed: R/W = Mosi, E=SCK, just solder RS (Slave select) to +5V, it isn't needed! -// maple mini user: you must set VCC to +5V, but you don't have it onboard! -#include "lcd7920_STM.h" -// some fonts -//extern const PROGMEM LcdFont font10x10_STM; // in glcd10x10.cpp -extern const PROGMEM LcdFont font5x7_STM; // in glcd10x10.cpp -//extern const PROGMEM LcdFont font16x16_STM; // in glcs16x16.cpp - -// Define the following as true to use SPI to drive the LCD, false to drive it slowly instead -#define LCD_USE_SPI (false) // no SPI yet for STM32 - -const int MOSIpin = 6; -const int SCLKpin = 7; - -// LCD -static Lcd7920 lcd(SCLKpin, MOSIpin, LCD_USE_SPI); - -// Initialization -void setup() -{ - lcd.begin(true); // init lcd in graphics mode - lcd.setFont(&font5x7_STM); - lcd.setCursor(35, 0); - lcd.textInvert(1); - lcd.print("Counter: "); - lcd.textInvert(0); -} - -void loop() -{ - static byte counter = 0; - // - counter++; - if (counter > 128) - { - counter = 0; - delay(1000); - lcd.clear(); - lcd.setCursor(35, 0); - lcd.print("Counter: "); - } - - lcd.box(0, 0, counter - 1, 5, PixelClear); - lcd.box(0, 0, counter, 5, PixelSet); - lcd.fillbox(0, 55, counter, 10, PixelSet); - lcd.circle(100, 31, counter / 8, PixelSet); - lcd.flush(); - lcd.setCursor(35, 55); - lcd.print(counter); - lcd.print(" "); - -} - diff --git a/GD32F1/libraries/Lcd7920_STM/glcd10x10_STM.cpp b/GD32F1/libraries/Lcd7920_STM/glcd10x10_STM.cpp deleted file mode 100644 index 46b75c0..0000000 --- a/GD32F1/libraries/Lcd7920_STM/glcd10x10_STM.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include "lcd7920_STM.h" - -//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0 -//MikroElektronika 2011 -//http://www.mikroe.com - -//GLCD FontName : glcd10x10 -//GLCD FontSize : 10 x 10 - -// Note that we replace the fullstop character by decimal point so that the Arduino print functions display a decimla point when printing numbers. -PROGMEM const uint8_t glcd10x10_STM[] = { - 0x04, 0x06, 0x00, 0x09, 0x00, 0x09, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for degree symbol  - 0x09, 0x38, 0x00, 0x45, 0x00, 0x83, 0x00, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x01, 0x82, 0x01, 0x44, 0x01, 0x38, 0x00, 0x00, 0x00, // Code for rotating arrows 1  - 0x09, 0xE0, 0x00, 0x64, 0x00, 0xA2, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x8A, 0x00, 0x4C, 0x00, 0x0E, 0x00, 0x00, 0x00, // Code for rotating arrows 2 - 0x0A, 0x10, 0x00, 0x10, 0x00, 0xFF, 0x01, 0xFE, 0x00, 0x7C, 0x00, 0x38, 0x00, 0x10, 0x00, 0xFF, 0x01, 0x10, 0x00, 0x10, 0x00, // Code for diode  - 0x08, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xFF, 0x01, 0x28, 0x00, 0x44, 0x01, 0x82, 0x01, 0xC1, 0x01, 0x00, 0x00, 0x00, 0x00, // Code for transistor  - 0x07, 0x30, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x60, 0x00, 0x18, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for tick  - 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for full stop  - 0x03, 0xFF, 0x00, 0x81, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x03, 0xFF, 0x00, 0x81, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x03, 0xFF, 0x00, 0x81, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x03, 0xFF, 0x00, 0x81, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x03, 0xFF, 0x00, 0x81, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char  - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char - 0x01, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ! - 0x03, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char " - 0x05, 0x24, 0x00, 0xFF, 0x00, 0x24, 0x00, 0xFF, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char # - 0x05, 0x46, 0x00, 0x89, 0x00, 0xFF, 0x01, 0x89, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char $ - 0x09, 0x06, 0x00, 0x09, 0x00, 0x89, 0x00, 0x66, 0x00, 0x18, 0x00, 0x66, 0x00, 0x91, 0x00, 0x90, 0x00, 0x60, 0x00, 0x00, 0x00, // Code for char % - 0x06, 0x60, 0x00, 0x96, 0x00, 0x89, 0x00, 0x99, 0x00, 0x66, 0x00, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char & - 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ' - 0x03, 0xFC, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ( - 0x03, 0x01, 0x02, 0x02, 0x01, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ) - 0x05, 0x15, 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x0E, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char * - 0x05, 0x10, 0x00, 0x10, 0x00, 0x7C, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char + - 0x02, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char , - 0x03, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char - - 0x03, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char . (extra space left and right) - 0x03, 0xC0, 0x00, 0x3C, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char / - 0x05, 0x7E, 0x00, 0x81, 0x00, 0x81, 0x00, 0x81, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 0 - 0x03, 0x04, 0x00, 0x02, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 1 - 0x05, 0x82, 0x00, 0xC1, 0x00, 0xA1, 0x00, 0x91, 0x00, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 2 - 0x05, 0x42, 0x00, 0x81, 0x00, 0x89, 0x00, 0x89, 0x00, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 3 - 0x06, 0x30, 0x00, 0x28, 0x00, 0x24, 0x00, 0x22, 0x00, 0xFF, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 4 - 0x05, 0x4F, 0x00, 0x89, 0x00, 0x89, 0x00, 0x89, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 5 - 0x05, 0x7E, 0x00, 0x89, 0x00, 0x89, 0x00, 0x89, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 6 - 0x05, 0x01, 0x00, 0xE1, 0x00, 0x19, 0x00, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 7 - 0x05, 0x76, 0x00, 0x89, 0x00, 0x89, 0x00, 0x89, 0x00, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 8 - 0x05, 0x4E, 0x00, 0x91, 0x00, 0x91, 0x00, 0x91, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 9 - 0x01, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char : - 0x01, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ; - 0x05, 0x10, 0x00, 0x10, 0x00, 0x28, 0x00, 0x28, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char < - 0x05, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char = - 0x05, 0x44, 0x00, 0x28, 0x00, 0x28, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char > - 0x05, 0x02, 0x00, 0x01, 0x00, 0xB1, 0x00, 0x09, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ? - 0x0A, 0xF8, 0x00, 0x04, 0x01, 0x72, 0x02, 0x89, 0x02, 0x85, 0x02, 0x45, 0x02, 0xF9, 0x02, 0x8D, 0x02, 0x42, 0x02, 0x3C, 0x01, // Code for char @ - 0x07, 0xC0, 0x00, 0x30, 0x00, 0x2C, 0x00, 0x23, 0x00, 0x2C, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char A - 0x06, 0xFF, 0x00, 0x89, 0x00, 0x89, 0x00, 0x89, 0x00, 0x89, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char B - 0x06, 0x3C, 0x00, 0x42, 0x00, 0x81, 0x00, 0x81, 0x00, 0x81, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char C - 0x06, 0xFF, 0x00, 0x81, 0x00, 0x81, 0x00, 0x81, 0x00, 0x42, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char D - 0x05, 0xFF, 0x00, 0x89, 0x00, 0x89, 0x00, 0x89, 0x00, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char E - 0x05, 0xFF, 0x00, 0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char F - 0x07, 0x3C, 0x00, 0x42, 0x00, 0x81, 0x00, 0x81, 0x00, 0x91, 0x00, 0x52, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char G - 0x06, 0xFF, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char H - 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char I - 0x04, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char J - 0x06, 0xFF, 0x00, 0x10, 0x00, 0x08, 0x00, 0x1C, 0x00, 0x62, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char K - 0x05, 0xFF, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char L - 0x07, 0xFF, 0x00, 0x06, 0x00, 0x18, 0x00, 0x60, 0x00, 0x18, 0x00, 0x06, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char M - 0x06, 0xFF, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x30, 0x00, 0x40, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char N - 0x07, 0x3C, 0x00, 0x42, 0x00, 0x81, 0x00, 0x81, 0x00, 0x81, 0x00, 0x42, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char O - 0x05, 0xFF, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char P - 0x07, 0x3C, 0x00, 0x42, 0x00, 0x81, 0x00, 0xA1, 0x00, 0xA1, 0x00, 0x42, 0x00, 0xBC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Q - 0x06, 0xFF, 0x00, 0x09, 0x00, 0x09, 0x00, 0x19, 0x00, 0x69, 0x00, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char R - 0x06, 0x46, 0x00, 0x89, 0x00, 0x89, 0x00, 0x91, 0x00, 0x91, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char S - 0x05, 0x01, 0x00, 0x01, 0x00, 0xFF, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char T - 0x06, 0x7F, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char U - 0x07, 0x03, 0x00, 0x0C, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char V - 0x0A, 0x03, 0x00, 0x3C, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x3C, 0x00, 0x03, 0x00, // Code for char W - 0x06, 0x81, 0x00, 0x66, 0x00, 0x18, 0x00, 0x18, 0x00, 0x66, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char X - 0x07, 0x01, 0x00, 0x06, 0x00, 0x08, 0x00, 0xF0, 0x00, 0x08, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Y - 0x06, 0x81, 0x00, 0xC1, 0x00, 0xB1, 0x00, 0x8D, 0x00, 0x83, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Z - 0x02, 0xFF, 0x03, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char [ - 0x03, 0x03, 0x00, 0x3C, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char BackSlash - 0x02, 0x01, 0x02, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ] - 0x05, 0x08, 0x00, 0x06, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ^ - 0x06, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char _ - 0x02, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ` - 0x05, 0x68, 0x00, 0x94, 0x00, 0x94, 0x00, 0x54, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char a - 0x05, 0xFF, 0x00, 0x48, 0x00, 0x84, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char b - 0x05, 0x78, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char c - 0x05, 0x78, 0x00, 0x84, 0x00, 0x84, 0x00, 0x48, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char d - 0x05, 0x78, 0x00, 0x94, 0x00, 0x94, 0x00, 0x94, 0x00, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char e - 0x03, 0x04, 0x00, 0xFE, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char f - 0x05, 0x78, 0x02, 0x84, 0x02, 0x84, 0x02, 0x48, 0x02, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char g - 0x05, 0xFF, 0x00, 0x08, 0x00, 0x04, 0x00, 0x04, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char h - 0x01, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char i - 0x02, 0x00, 0x02, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char j - 0x04, 0xFF, 0x00, 0x10, 0x00, 0x68, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char k - 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char l - 0x07, 0xFC, 0x00, 0x08, 0x00, 0x04, 0x00, 0xFC, 0x00, 0x04, 0x00, 0x04, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char m - 0x05, 0xFC, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char n - 0x05, 0x78, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char o - 0x05, 0xFC, 0x03, 0x48, 0x00, 0x84, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char p - 0x05, 0x78, 0x00, 0x84, 0x00, 0x84, 0x00, 0x48, 0x00, 0xFC, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char q - 0x03, 0xFC, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char r - 0x05, 0x48, 0x00, 0x94, 0x00, 0x94, 0x00, 0xA4, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char s - 0x02, 0xFF, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char t - 0x05, 0x7C, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char u - 0x05, 0x0C, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char v - 0x09, 0x0C, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x08, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x00, 0x00, // Code for char w - 0x05, 0x84, 0x00, 0x48, 0x00, 0x30, 0x00, 0x48, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char x - 0x05, 0x0C, 0x00, 0x30, 0x02, 0xC0, 0x01, 0x30, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char y - 0x05, 0x84, 0x00, 0xC4, 0x00, 0xB4, 0x00, 0x8C, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char z - 0x03, 0x10, 0x00, 0xEE, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char { - 0x01, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char | - 0x04, 0x00, 0x00, 0x01, 0x02, 0xEE, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char } - 0x05, 0x10, 0x00, 0x08, 0x00, 0x18, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ~ - 0x03, 0xFF, 0x00, 0x81, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Code for char  - }; - -extern const PROGMEM LcdFont font10x10_STM = -{ - glcd10x10_STM, // font data - 0x10, // first character code - 0x7F, // last character code - 10, // row height in pixels - 10 // character width in pixels -}; - - -// End - diff --git a/GD32F1/libraries/Lcd7920_STM/glcd16x16_STM.cpp b/GD32F1/libraries/Lcd7920_STM/glcd16x16_STM.cpp deleted file mode 100644 index ae670ad..0000000 --- a/GD32F1/libraries/Lcd7920_STM/glcd16x16_STM.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "lcd7920_STM.h" - -//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0 -//MikroElektronika 2011 -//http://www.mikroe.com - -//GLCD FontName : glcd16x16 -//GLCD FontSize : 16 x 16 - -static const uint8_t glcd16x16_STM[] PROGMEM = { - 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char - 0x03, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ! - 0x05, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char " - 0x09, 0x20, 0x02, 0x20, 0x1E, 0xF0, 0x03, 0x2E, 0x02, 0x20, 0x02, 0x20, 0x1E, 0xF0, 0x03, 0x2E, 0x02, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char # - 0x08, 0x00, 0x00, 0x38, 0x04, 0x44, 0x08, 0x42, 0x10, 0xFF, 0x3F, 0x82, 0x10, 0x82, 0x08, 0x0C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char $ - 0x0D, 0x00, 0x00, 0x3C, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x18, 0x3C, 0x06, 0x80, 0x01, 0x70, 0x00, 0x0C, 0x0F, 0x82, 0x10, 0x80, 0x10, 0x80, 0x10, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char % - 0x0A, 0x00, 0x00, 0x00, 0x07, 0x9C, 0x08, 0x62, 0x10, 0xC2, 0x10, 0x22, 0x11, 0x1C, 0x0A, 0x00, 0x04, 0x00, 0x0A, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char & - 0x02, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ' - 0x04, 0x00, 0x00, 0xE0, 0x0F, 0x1C, 0x70, 0x02, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ( - 0x04, 0x00, 0x00, 0x02, 0x80, 0x1C, 0x70, 0xE0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ) - 0x05, 0x04, 0x00, 0x34, 0x00, 0x0E, 0x00, 0x34, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char * - 0x08, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF0, 0x07, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char + - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char , - 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char - - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char . - 0x04, 0x00, 0x18, 0x80, 0x07, 0x78, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char / - 0x08, 0x00, 0x00, 0xF8, 0x07, 0x04, 0x08, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x04, 0x08, 0xF8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 0 - 0x06, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0xFE, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 1 - 0x08, 0x00, 0x00, 0x08, 0x10, 0x04, 0x18, 0x02, 0x14, 0x02, 0x12, 0x02, 0x11, 0xC6, 0x10, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 2 - 0x08, 0x00, 0x00, 0x08, 0x0C, 0x04, 0x08, 0x42, 0x10, 0x42, 0x10, 0x62, 0x10, 0xBC, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 3 - 0x08, 0x00, 0x03, 0x80, 0x02, 0x40, 0x02, 0x30, 0x02, 0x08, 0x02, 0x04, 0x02, 0xFE, 0x1F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 4 - 0x08, 0x00, 0x00, 0x70, 0x04, 0x2E, 0x08, 0x22, 0x10, 0x22, 0x10, 0x22, 0x10, 0x42, 0x08, 0x82, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 5 - 0x08, 0x00, 0x00, 0xF8, 0x07, 0x44, 0x08, 0x22, 0x10, 0x22, 0x10, 0x22, 0x10, 0x44, 0x08, 0x88, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 6 - 0x08, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x1C, 0xC2, 0x03, 0x32, 0x00, 0x0E, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 7 - 0x08, 0x00, 0x00, 0x18, 0x07, 0xA4, 0x08, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0xA4, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 8 - 0x08, 0x00, 0x00, 0x78, 0x04, 0x84, 0x08, 0x02, 0x11, 0x02, 0x11, 0x02, 0x11, 0x84, 0x08, 0xF8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 9 - 0x02, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char : - 0x02, 0x00, 0x00, 0x10, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ; - 0x08, 0x00, 0x00, 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char < - 0x08, 0x00, 0x00, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char = - 0x08, 0x00, 0x00, 0x10, 0x04, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x40, 0x01, 0x40, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char > - 0x08, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x17, 0x82, 0x00, 0x44, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ? - 0x10, 0x00, 0x00, 0xC0, 0x0F, 0x30, 0x10, 0x08, 0x20, 0x84, 0x47, 0x44, 0x48, 0x22, 0x90, 0x12, 0x90, 0x12, 0x90, 0x12, 0x88, 0x22, 0x9F, 0xF2, 0x90, 0x04, 0x90, 0x04, 0x48, 0x18, 0x44, 0xE0, 0x23, // Code for char @ - 0x0A, 0x00, 0x00, 0x00, 0x18, 0x00, 0x07, 0xE0, 0x01, 0x1C, 0x01, 0x02, 0x01, 0x1C, 0x01, 0xE0, 0x01, 0x00, 0x07, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char A - 0x0A, 0x00, 0x00, 0xFE, 0x1F, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0xA6, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char B - 0x0B, 0x00, 0x00, 0xF0, 0x03, 0x08, 0x04, 0x04, 0x08, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x04, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char C - 0x0B, 0x00, 0x00, 0xFE, 0x1F, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x04, 0x08, 0x08, 0x04, 0xF0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char D - 0x0A, 0x00, 0x00, 0xFE, 0x1F, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char E - 0x09, 0x00, 0x00, 0xFE, 0x1F, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char F - 0x0B, 0x00, 0x00, 0xF0, 0x03, 0x08, 0x04, 0x04, 0x08, 0x02, 0x10, 0x02, 0x10, 0x82, 0x10, 0x82, 0x10, 0x84, 0x08, 0x88, 0x04, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char G - 0x0A, 0x00, 0x00, 0xFE, 0x1F, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0xFE, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char H - 0x02, 0x00, 0x00, 0xFE, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char I - 0x07, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0xFE, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char J - 0x0A, 0x00, 0x00, 0xFE, 0x1F, 0x00, 0x01, 0x80, 0x00, 0x40, 0x00, 0xE0, 0x00, 0x10, 0x01, 0x08, 0x06, 0x04, 0x08, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char K - 0x08, 0x00, 0x00, 0xFE, 0x1F, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char L - 0x0C, 0x00, 0x00, 0xFE, 0x1F, 0x0C, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x00, 0x07, 0x00, 0x18, 0x00, 0x07, 0xC0, 0x00, 0x30, 0x00, 0x0C, 0x00, 0xFE, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char M - 0x0A, 0x00, 0x00, 0xFE, 0x1F, 0x04, 0x00, 0x18, 0x00, 0x20, 0x00, 0xC0, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x08, 0xFE, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char N - 0x0B, 0x00, 0x00, 0xF0, 0x03, 0x08, 0x04, 0x04, 0x08, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x04, 0x08, 0x08, 0x04, 0xF0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char O - 0x0A, 0x00, 0x00, 0xFE, 0x1F, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x44, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char P - 0x0B, 0x00, 0x00, 0xF0, 0x03, 0x08, 0x04, 0x04, 0x08, 0x02, 0x10, 0x02, 0x10, 0x02, 0x14, 0x02, 0x14, 0x04, 0x08, 0x08, 0x1C, 0xF0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Q - 0x0A, 0x00, 0x00, 0xFE, 0x1F, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x01, 0x82, 0x06, 0x44, 0x08, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char R - 0x0A, 0x00, 0x00, 0x18, 0x04, 0x24, 0x08, 0x42, 0x10, 0x42, 0x10, 0x42, 0x10, 0x82, 0x10, 0x82, 0x10, 0x84, 0x08, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char S - 0x09, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0xFE, 0x1F, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char T - 0x0A, 0x00, 0x00, 0xFE, 0x07, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x08, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char U - 0x0A, 0x00, 0x00, 0x06, 0x00, 0x38, 0x00, 0xC0, 0x01, 0x00, 0x06, 0x00, 0x18, 0x00, 0x06, 0xC0, 0x01, 0x38, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char V - 0x0F, 0x06, 0x00, 0x78, 0x00, 0x80, 0x07, 0x00, 0x18, 0x00, 0x07, 0xE0, 0x00, 0x1C, 0x00, 0x02, 0x00, 0x1C, 0x00, 0xE0, 0x00, 0x00, 0x07, 0x00, 0x18, 0x80, 0x07, 0x78, 0x00, 0x06, 0x00, 0x00, 0x00, // Code for char W - 0x0B, 0x00, 0x10, 0x02, 0x08, 0x04, 0x04, 0x18, 0x03, 0xA0, 0x00, 0x40, 0x00, 0xA0, 0x00, 0x18, 0x03, 0x04, 0x04, 0x02, 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char X - 0x09, 0x02, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x60, 0x00, 0x80, 0x1F, 0x60, 0x00, 0x10, 0x00, 0x0C, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Y - 0x09, 0x00, 0x10, 0x02, 0x18, 0x02, 0x16, 0x02, 0x11, 0xC2, 0x10, 0x22, 0x10, 0x1A, 0x10, 0x06, 0x10, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Z - 0x04, 0x00, 0x00, 0xFE, 0xFF, 0x02, 0x80, 0x02, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char [ - 0x04, 0x06, 0x00, 0x78, 0x00, 0x80, 0x07, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char BackSlash - 0x03, 0x02, 0x80, 0x02, 0x80, 0xFE, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ] - 0x07, 0x40, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x30, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ^ - 0x09, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char _ - 0x03, 0x00, 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ` - 0x08, 0x00, 0x00, 0x40, 0x0E, 0x20, 0x11, 0x10, 0x11, 0x10, 0x11, 0x90, 0x10, 0x90, 0x08, 0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char a - 0x08, 0x00, 0x00, 0xFE, 0x1F, 0x20, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x08, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char b - 0x07, 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char c - 0x08, 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x08, 0xFE, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char d - 0x08, 0x00, 0x00, 0xC0, 0x07, 0x20, 0x09, 0x10, 0x11, 0x10, 0x11, 0x10, 0x11, 0x20, 0x09, 0xC0, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char e - 0x04, 0x10, 0x00, 0xFC, 0x1F, 0x12, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char f - 0x08, 0x00, 0x00, 0xC0, 0x47, 0x20, 0x88, 0x10, 0x90, 0x10, 0x90, 0x10, 0x90, 0x20, 0x48, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char g - 0x07, 0x00, 0x00, 0xFE, 0x1F, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char h - 0x02, 0x00, 0x00, 0xF2, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char i - 0x02, 0x00, 0x80, 0xF2, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char j - 0x08, 0x00, 0x00, 0xFE, 0x1F, 0x00, 0x02, 0x00, 0x01, 0x80, 0x01, 0x40, 0x06, 0x20, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char k - 0x02, 0x00, 0x00, 0xFE, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char l - 0x0C, 0x00, 0x00, 0xF0, 0x1F, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x1F, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char m - 0x07, 0x00, 0x00, 0xF0, 0x1F, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char n - 0x08, 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x08, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char o - 0x08, 0x00, 0x00, 0xF0, 0xFF, 0x20, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x08, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char p - 0x08, 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x08, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char q - 0x05, 0x00, 0x00, 0xF0, 0x1F, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char r - 0x07, 0x00, 0x00, 0xE0, 0x08, 0x10, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x11, 0x20, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char s - 0x04, 0x10, 0x00, 0xFC, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char t - 0x07, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x08, 0xF0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char u - 0x07, 0x30, 0x00, 0xC0, 0x00, 0x00, 0x07, 0x00, 0x18, 0x00, 0x07, 0xC0, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char v - 0x0B, 0x30, 0x00, 0xC0, 0x07, 0x00, 0x18, 0x00, 0x07, 0xC0, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x00, 0x07, 0x00, 0x18, 0xC0, 0x07, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char w - 0x07, 0x10, 0x10, 0x20, 0x08, 0xC0, 0x06, 0x00, 0x01, 0xC0, 0x06, 0x20, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char x - 0x07, 0x70, 0x00, 0x80, 0x81, 0x00, 0x8E, 0x00, 0x70, 0x00, 0x0E, 0xC0, 0x01, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char y - 0x07, 0x10, 0x10, 0x10, 0x18, 0x10, 0x16, 0x10, 0x11, 0xD0, 0x10, 0x30, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char z - 0x05, 0x00, 0x01, 0x00, 0x01, 0xFC, 0x7E, 0x02, 0x80, 0x02, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char { - 0x02, 0x00, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char | - 0x05, 0x02, 0x80, 0x02, 0x80, 0xFC, 0x7E, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char } - 0x08, 0x80, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ~ - 0x04, 0xFE, 0x0F, 0x02, 0x08, 0x02, 0x08, 0xFE, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Code for char  - }; - -extern const PROGMEM LcdFont font16x16_STM = -{ - glcd16x16_STM, // font data - 0x20, // first character code - 0x7F, // last character code - 16, // row height in pixels - 16 // character width in pixels -}; - - -// End diff --git a/GD32F1/libraries/Lcd7920_STM/glcd5x5_STM.cpp b/GD32F1/libraries/Lcd7920_STM/glcd5x5_STM.cpp deleted file mode 100644 index f45ed94..0000000 --- a/GD32F1/libraries/Lcd7920_STM/glcd5x5_STM.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "lcd7920_STM.h" - -// Standard ASCII 6x8 font - -PROGMEM const uint8_t glcd5x5_STM[] PROGMEM = { - - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char - 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, // Code for char ! - 0x02, 0x03, 0x03, 0x00, 0x00, 0x00, // Code for char " - 0x04, 0x0A, 0x1F, 0x1F, 0x0A, 0x00, // Code for char # - 0x03, 0x16, 0x1F, 0x1A, 0x00, 0x00, // Code for char $ - 0x04, 0x12, 0x08, 0x04, 0x12, 0x00, // Code for char % - 0x04, 0x0A, 0x15, 0x0A, 0x14, 0x00, // Code for char & - 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, // Code for char ' - 0x02, 0x1E, 0x01, 0x00, 0x00, 0x00, // Code for char ( - 0x02, 0x01, 0x1E, 0x00, 0x00, 0x00, // Code for char ) - 0x02, 0x03, 0x03, 0x00, 0x00, 0x00, // Code for char * - 0x03, 0x04, 0x0E, 0x04, 0x00, 0x00, // Code for char + - 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, // Code for char , - 0x02, 0x04, 0x04, 0x00, 0x00, 0x00, // Code for char - - 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, // Code for char . - 0x02, 0x1C, 0x07, 0x00, 0x00, 0x00, // Code for char / - 0x03, 0x0E, 0x11, 0x0E, 0x00, 0x00, // Code for char 0 - 0x02, 0x02, 0x1F, 0x00, 0x00, 0x00, // Code for char 1 - 0x03, 0x19, 0x15, 0x12, 0x00, 0x00, // Code for char 2 - 0x03, 0x11, 0x15, 0x0A, 0x00, 0x00, // Code for char 3 - 0x03, 0x0C, 0x0A, 0x1F, 0x00, 0x00, // Code for char 4 - 0x03, 0x17, 0x15, 0x0D, 0x00, 0x00, // Code for char 5 - 0x03, 0x0E, 0x15, 0x08, 0x00, 0x00, // Code for char 6 - 0x03, 0x01, 0x1D, 0x03, 0x00, 0x00, // Code for char 7 - 0x03, 0x0A, 0x15, 0x0A, 0x00, 0x00, // Code for char 8 - 0x03, 0x06, 0x15, 0x0E, 0x00, 0x00, // Code for char 9 - 0x01, 0x14, 0x00, 0x00, 0x00, 0x00, // Code for char : - 0x01, 0x14, 0x00, 0x00, 0x00, 0x00, // Code for char ; - 0x02, 0x08, 0x14, 0x00, 0x00, 0x00, // Code for char < - 0x02, 0x08, 0x08, 0x00, 0x00, 0x00, // Code for char = - 0x02, 0x14, 0x08, 0x00, 0x00, 0x00, // Code for char > - 0x02, 0x15, 0x02, 0x00, 0x00, 0x00, // Code for char ? - 0x05, 0x0C, 0x12, 0x0D, 0x0D, 0x0A, // Code for char @ - 0x04, 0x1C, 0x0B, 0x0B, 0x1C, 0x00, // Code for char A - 0x04, 0x1F, 0x15, 0x15, 0x0A, 0x00, // Code for char B - 0x04, 0x0E, 0x11, 0x11, 0x0A, 0x00, // Code for char C - 0x04, 0x1F, 0x11, 0x11, 0x0E, 0x00, // Code for char D - 0x03, 0x1F, 0x15, 0x11, 0x00, 0x00, // Code for char E - 0x03, 0x1F, 0x05, 0x01, 0x00, 0x00, // Code for char F - 0x04, 0x0E, 0x11, 0x15, 0x1D, 0x00, // Code for char G - 0x04, 0x1F, 0x04, 0x04, 0x1F, 0x00, // Code for char H - 0x01, 0x1F, 0x00, 0x00, 0x00, 0x00, // Code for char I - 0x03, 0x18, 0x10, 0x0F, 0x00, 0x00, // Code for char J - 0x04, 0x1F, 0x04, 0x0A, 0x11, 0x00, // Code for char K - 0x03, 0x1F, 0x10, 0x10, 0x00, 0x00, // Code for char L - 0x05, 0x1F, 0x02, 0x04, 0x02, 0x1F, // Code for char M - 0x04, 0x1F, 0x02, 0x04, 0x1F, 0x00, // Code for char N - 0x04, 0x0E, 0x11, 0x11, 0x0E, 0x00, // Code for char O - 0x04, 0x1F, 0x05, 0x05, 0x02, 0x00, // Code for char P - 0x04, 0x0E, 0x11, 0x09, 0x16, 0x00, // Code for char Q - 0x04, 0x1F, 0x05, 0x05, 0x1A, 0x00, // Code for char R - 0x04, 0x12, 0x15, 0x15, 0x09, 0x00, // Code for char S - 0x03, 0x01, 0x1F, 0x01, 0x00, 0x00, // Code for char T - 0x04, 0x0F, 0x10, 0x10, 0x0F, 0x00, // Code for char U - 0x03, 0x07, 0x18, 0x07, 0x00, 0x00, // Code for char V - 0x05, 0x07, 0x18, 0x06, 0x18, 0x07, // Code for char W - 0x03, 0x1B, 0x04, 0x1B, 0x00, 0x00, // Code for char X - 0x03, 0x03, 0x1C, 0x03, 0x00, 0x00, // Code for char Y - 0x03, 0x19, 0x15, 0x13, 0x00, 0x00, // Code for char Z - 0x02, 0x1F, 0x01, 0x00, 0x00, 0x00, // Code for char [ - 0x02, 0x07, 0x1C, 0x00, 0x00, 0x00, // Code for char BackSlash - 0x02, 0x01, 0x1F, 0x00, 0x00, 0x00, // Code for char ] - 0x03, 0x02, 0x01, 0x02, 0x00, 0x00, // Code for char ^ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char _ - 0x02, 0x01, 0x02, 0x00, 0x00, 0x00, // Code for char ` - 0x03, 0x08, 0x14, 0x1C, 0x00, 0x00, // Code for char a - 0x03, 0x1F, 0x14, 0x08, 0x00, 0x00, // Code for char b - 0x03, 0x08, 0x14, 0x14, 0x00, 0x00, // Code for char c - 0x03, 0x08, 0x14, 0x1F, 0x00, 0x00, // Code for char d - 0x03, 0x18, 0x14, 0x08, 0x00, 0x00, // Code for char e - 0x02, 0x1E, 0x05, 0x00, 0x00, 0x00, // Code for char f - 0x03, 0x08, 0x14, 0x1C, 0x00, 0x00, // Code for char g - 0x03, 0x1F, 0x04, 0x18, 0x00, 0x00, // Code for char h - 0x01, 0x1D, 0x00, 0x00, 0x00, 0x00, // Code for char i - 0x01, 0x1D, 0x00, 0x00, 0x00, 0x00, // Code for char j - 0x03, 0x1F, 0x08, 0x14, 0x00, 0x00, // Code for char k - 0x01, 0x1F, 0x00, 0x00, 0x00, 0x00, // Code for char l - 0x05, 0x1C, 0x04, 0x1C, 0x04, 0x18, // Code for char m - 0x03, 0x1C, 0x04, 0x18, 0x00, 0x00, // Code for char n - 0x03, 0x1C, 0x14, 0x1C, 0x00, 0x00, // Code for char o - 0x03, 0x1C, 0x14, 0x08, 0x00, 0x00, // Code for char p - 0x03, 0x08, 0x14, 0x1C, 0x00, 0x00, // Code for char q - 0x02, 0x1C, 0x04, 0x00, 0x00, 0x00, // Code for char r - 0x02, 0x1C, 0x04, 0x00, 0x00, 0x00, // Code for char s - 0x02, 0x0E, 0x14, 0x00, 0x00, 0x00, // Code for char t - 0x03, 0x0C, 0x10, 0x1C, 0x00, 0x00, // Code for char u - 0x03, 0x0C, 0x10, 0x0C, 0x00, 0x00, // Code for char v - 0x04, 0x1C, 0x10, 0x10, 0x1C, 0x00, // Code for char w - 0x03, 0x14, 0x08, 0x14, 0x00, 0x00, // Code for char x - 0x03, 0x04, 0x18, 0x04, 0x00, 0x00, // Code for char y - 0x03, 0x14, 0x1C, 0x14, 0x00, 0x00, // Code for char z - 0x02, 0x0C, 0x13, 0x00, 0x00, 0x00, // Code for char { - 0x01, 0x1F, 0x00, 0x00, 0x00, 0x00, // Code for char | - 0x02, 0x13, 0x0C, 0x00, 0x00, 0x00, // Code for char } - 0x03, 0x02, 0x03, 0x01, 0x00, 0x00, // Code for char ~ - 0x01, 0x1F, 0x00, 0x00, 0x00, 0x00 // Code for char  -}; - -extern const PROGMEM LcdFont font5x5_STM = -{ - glcd5x5_STM, // font data - 0x20, // first character code - 0x7F, // last character code - 5, // row height in pixels - 5 // character width in pixels -}; diff --git a/GD32F1/libraries/Lcd7920_STM/glcd5x7_STM.cpp b/GD32F1/libraries/Lcd7920_STM/glcd5x7_STM.cpp deleted file mode 100644 index 2d14198..0000000 --- a/GD32F1/libraries/Lcd7920_STM/glcd5x7_STM.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "lcd7920_STM.h" - -// Standard ASCII 6x8 font - -PROGMEM const uint8_t glcd5x7_STM[] PROGMEM = { - - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char - 0x04, 0x00, 0x06, 0x5F, 0x06, 0x00, // Code for char ! - 0x05, 0x07, 0x03, 0x00, 0x07, 0x03, // Code for char " - 0x05, 0x24, 0x7E, 0x24, 0x7E, 0x24, // Code for char # - 0x04, 0x24, 0x2B, 0x6A, 0x12, 0x00, // Code for char $ - 0x05, 0x63, 0x13, 0x08, 0x64, 0x63, // Code for char % - 0x05, 0x36, 0x49, 0x56, 0x20, 0x50, // Code for char & - 0x03, 0x00, 0x07, 0x03, 0x00, 0x00, // Code for char ' - 0x03, 0x00, 0x3E, 0x41, 0x00, 0x00, // Code for char ( - 0x03, 0x00, 0x41, 0x3E, 0x00, 0x00, // Code for char ) - 0x05, 0x08, 0x3E, 0x1C, 0x3E, 0x08, // Code for char * - 0x05, 0x08, 0x08, 0x3E, 0x08, 0x08, // Code for char + - 0x03, 0x00, 0x60, 0x60, 0x00, 0x00, // Code for char , - 0x05, 0x08, 0x08, 0x08, 0x08, 0x08, // Code for char - - 0x03, 0x00, 0x60, 0x60, 0x00, 0x00, // Code for char . - 0x05, 0x20, 0x10, 0x08, 0x04, 0x02, // Code for char / - 0x05, 0x3E, 0x51, 0x49, 0x45, 0x3E, // Code for char 0 - 0x04, 0x00, 0x42, 0x7F, 0x40, 0x00, // Code for char 1 - 0x05, 0x62, 0x51, 0x49, 0x49, 0x46, // Code for char 2 - 0x05, 0x22, 0x49, 0x49, 0x49, 0x36, // Code for char 3 - 0x05, 0x18, 0x14, 0x12, 0x7F, 0x10, // Code for char 4 - 0x05, 0x2F, 0x49, 0x49, 0x49, 0x31, // Code for char 5 - 0x05, 0x3C, 0x4A, 0x49, 0x49, 0x30, // Code for char 6 - 0x05, 0x01, 0x71, 0x09, 0x05, 0x03, // Code for char 7 - 0x05, 0x36, 0x49, 0x49, 0x49, 0x36, // Code for char 8 - 0x05, 0x06, 0x49, 0x49, 0x29, 0x1E, // Code for char 9 - 0x03, 0x00, 0x6C, 0x6C, 0x00, 0x00, // Code for char : - 0x03, 0x00, 0x6C, 0x6C, 0x00, 0x00, // Code for char ; - 0x04, 0x08, 0x14, 0x22, 0x41, 0x00, // Code for char < - 0x05, 0x24, 0x24, 0x24, 0x24, 0x24, // Code for char = - 0x05, 0x00, 0x41, 0x22, 0x14, 0x08, // Code for char > - 0x05, 0x02, 0x01, 0x59, 0x09, 0x06, // Code for char ? - 0x05, 0x3E, 0x41, 0x5D, 0x55, 0x1E, // Code for char @ - 0x05, 0x7E, 0x11, 0x11, 0x11, 0x7E, // Code for char A - 0x05, 0x7F, 0x49, 0x49, 0x49, 0x36, // Code for char B - 0x05, 0x3E, 0x41, 0x41, 0x41, 0x22, // Code for char C - 0x05, 0x7F, 0x41, 0x41, 0x41, 0x3E, // Code for char D - 0x05, 0x7F, 0x49, 0x49, 0x49, 0x41, // Code for char E - 0x05, 0x7F, 0x09, 0x09, 0x09, 0x01, // Code for char F - 0x05, 0x3E, 0x41, 0x49, 0x49, 0x7A, // Code for char G - 0x05, 0x7F, 0x08, 0x08, 0x08, 0x7F, // Code for char H - 0x04, 0x00, 0x41, 0x7F, 0x41, 0x00, // Code for char I - 0x05, 0x30, 0x40, 0x40, 0x40, 0x3F, // Code for char J - 0x05, 0x7F, 0x08, 0x14, 0x22, 0x41, // Code for char K - 0x05, 0x7F, 0x40, 0x40, 0x40, 0x40, // Code for char L - 0x05, 0x7F, 0x02, 0x04, 0x02, 0x7F, // Code for char M - 0x05, 0x7F, 0x02, 0x04, 0x08, 0x7F, // Code for char N - 0x05, 0x3E, 0x41, 0x41, 0x41, 0x3E, // Code for char O - 0x05, 0x7F, 0x09, 0x09, 0x09, 0x06, // Code for char P - 0x05, 0x3E, 0x41, 0x51, 0x21, 0x5E, // Code for char Q - 0x05, 0x7F, 0x09, 0x09, 0x19, 0x66, // Code for char R - 0x05, 0x26, 0x49, 0x49, 0x49, 0x32, // Code for char S - 0x05, 0x01, 0x01, 0x7F, 0x01, 0x01, // Code for char T - 0x05, 0x3F, 0x40, 0x40, 0x40, 0x3F, // Code for char U - 0x05, 0x1F, 0x20, 0x40, 0x20, 0x1F, // Code for char V - 0x05, 0x3F, 0x40, 0x3C, 0x40, 0x3F, // Code for char W - 0x05, 0x63, 0x14, 0x08, 0x14, 0x63, // Code for char X - 0x05, 0x07, 0x08, 0x70, 0x08, 0x07, // Code for char Y - 0x04, 0x71, 0x49, 0x45, 0x43, 0x00, // Code for char Z - 0x04, 0x00, 0x7F, 0x41, 0x41, 0x00, // Code for char [ - 0x05, 0x02, 0x04, 0x08, 0x10, 0x20, // Code for char BackSlash - 0x04, 0x00, 0x41, 0x41, 0x7F, 0x00, // Code for char ] - 0x05, 0x04, 0x02, 0x01, 0x02, 0x04, // Code for char ^ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char _ - 0x03, 0x00, 0x03, 0x07, 0x00, 0x00, // Code for char ` - 0x05, 0x20, 0x54, 0x54, 0x54, 0x78, // Code for char a - 0x05, 0x7F, 0x44, 0x44, 0x44, 0x38, // Code for char b - 0x05, 0x38, 0x44, 0x44, 0x44, 0x28, // Code for char c - 0x05, 0x38, 0x44, 0x44, 0x44, 0x7F, // Code for char d - 0x05, 0x38, 0x54, 0x54, 0x54, 0x08, // Code for char e - 0x04, 0x08, 0x7E, 0x09, 0x09, 0x00, // Code for char f - 0x05, 0x18, 0x24, 0x24, 0x24, 0x7C, // Code for char g - 0x04, 0x7F, 0x04, 0x04, 0x78, 0x00, // Code for char h - 0x04, 0x00, 0x00, 0x7D, 0x40, 0x00, // Code for char i - 0x04, 0x40, 0x00, 0x04, 0x7D, 0x00, // Code for char j - 0x04, 0x7F, 0x10, 0x28, 0x44, 0x00, // Code for char k - 0x04, 0x00, 0x00, 0x7F, 0x40, 0x00, // Code for char l - 0x05, 0x7C, 0x04, 0x18, 0x04, 0x78, // Code for char m - 0x04, 0x7C, 0x04, 0x04, 0x78, 0x00, // Code for char n - 0x05, 0x38, 0x44, 0x44, 0x44, 0x38, // Code for char o - 0x05, 0x7C, 0x44, 0x44, 0x44, 0x38, // Code for char p - 0x05, 0x38, 0x44, 0x44, 0x44, 0x7C, // Code for char q - 0x05, 0x44, 0x78, 0x44, 0x04, 0x08, // Code for char r - 0x05, 0x08, 0x54, 0x54, 0x54, 0x20, // Code for char s - 0x04, 0x04, 0x3E, 0x44, 0x24, 0x00, // Code for char t - 0x04, 0x3C, 0x40, 0x20, 0x7C, 0x00, // Code for char u - 0x05, 0x1C, 0x20, 0x40, 0x20, 0x1C, // Code for char v - 0x05, 0x3C, 0x60, 0x30, 0x60, 0x3C, // Code for char w - 0x04, 0x6C, 0x10, 0x10, 0x6C, 0x00, // Code for char x - 0x04, 0x1C, 0x20, 0x60, 0x3C, 0x00, // Code for char y - 0x04, 0x64, 0x54, 0x54, 0x4C, 0x00, // Code for char z - 0x04, 0x08, 0x3E, 0x41, 0x41, 0x00, // Code for char { - 0x03, 0x00, 0x00, 0x77, 0x00, 0x00, // Code for char | - 0x05, 0x00, 0x41, 0x41, 0x3E, 0x08, // Code for char } - 0x04, 0x02, 0x01, 0x02, 0x01, 0x00, // Code for char ~ - 0x05, 0x3C, 0x26, 0x23, 0x26, 0x3C // Code for char  - }; - -extern const PROGMEM LcdFont font5x7_STM = -{ - glcd5x7_STM, // font data - 0x20, // first character code - 0x7F, // last character code - 7, // row height in pixels - 5 // character width in pixels -}; diff --git a/GD32F1/libraries/Lcd7920_STM/lcd7920_STM.cpp b/GD32F1/libraries/Lcd7920_STM/lcd7920_STM.cpp deleted file mode 100644 index daf74ad..0000000 --- a/GD32F1/libraries/Lcd7920_STM/lcd7920_STM.cpp +++ /dev/null @@ -1,565 +0,0 @@ -// Driver for 128x634 graphical LCD with ST7920 controller -// D Crocker, Escher Technologies Ltd. -// adapted for STM32-Arduino by Matthias Diro - -#include "lcd7920_STM.h" -#include -#include - -// LCD basic instructions. These all take 72us to execute except LcdDisplayClear, which takes 1.6ms -const uint8_t LcdDisplayClear = 0x01; -const uint8_t LcdHome = 0x02; -const uint8_t LcdEntryModeSet = 0x06; // move cursor right and indcement address when writing data -const uint8_t LcdDisplayOff = 0x08; -const uint8_t LcdDisplayOn = 0x0C; // add 0x02 for cursor on and/or 0x01 for cursor blink on -const uint8_t LcdFunctionSetBasicAlpha = 0x20; -const uint8_t LcdFunctionSetBasicGraphic = 0x22; -const uint8_t LcdFunctionSetExtendedAlpha = 0x24; -const uint8_t LcdFunctionSetExtendedGraphic = 0x26; -const uint8_t LcdSetDdramAddress = 0x80; // add the address we want to set - -// LCD extended instructions -const uint8_t LcdSetGdramAddress = 0x80; - -//const unsigned int LcdCommandDelayMicros = 72 - 24; // 72us required, less 24us time to send the command @ 1MHz -const unsigned int LcdCommandDelayMicros = 2; -const unsigned int LcdDataDelayMicros = 2;// 10; // Delay between sending data bytes -const unsigned int LcdDisplayClearDelayMillis = 2; // 1.6ms should be enough - -const unsigned int numRows = 64; -const unsigned int numCols = 128; - -Lcd7920::Lcd7920(uint8_t cPin, uint8_t dPin, bool spi) : clockPin(cPin), dataPin(dPin), useSpi(spi), currentFont(0), textInverted(false) -{ -} - -size_t Lcd7920::write(uint8_t ch) -{ - if (gfxMode) - { - if (currentFont == 0) - { - return 0; - } - const uint8_t startChar = pgm_read_byte_near(&(currentFont->startCharacter)); - const uint8_t endChar = pgm_read_byte_near(&(currentFont->endCharacter)); - - if (ch < startChar || ch > endChar) - { - return 0; - } - - const uint8_t fontWidth = pgm_read_byte_near(&(currentFont->width)); - const uint8_t fontHeight = pgm_read_byte_near(&(currentFont->height)); - const uint8_t bytesPerColumn = (fontHeight + 7)/8; - const uint8_t bytesPerChar = (bytesPerColumn * fontWidth) + 1; - PROGMEM const uint8_t *fontPtr = (PROGMEM const uint8_t*)pgm_read_word_near(&(currentFont->ptr)) + (bytesPerChar * (ch - startChar)); - uint16_t cmask = (1 << fontHeight) - 1; - - uint8_t nCols = pgm_read_byte_near(fontPtr++); - - // Update dirty rectangle coordinates, except for endCol which we do at the end - { - if (startRow > row) { startRow = row; } - if (startCol > column) { startCol = column; } - uint8_t nextRow = row + fontHeight; - if (nextRow > numRows) { nextRow = numRows; } - if (endRow < nextRow) { endRow = nextRow; } - } - - // Decide whether to add a space column first (auto-kerning) - // We don't add a space column before a space character. - // We add a space column after a space character if we would have added one between the preceding and following characters. - if (column != numCols) - { - uint16_t thisCharColData = pgm_read_word_near(fontPtr) & cmask; // atmega328p is little-endian - if (thisCharColData == 0) // for characters with deliberate space row at the start, e.g. decimal point - { - thisCharColData = pgm_read_word_near(fontPtr + 2) & cmask; - } - bool wantSpace = ((thisCharColData | (thisCharColData << 1)) & (lastCharColData | (lastCharColData << 1))) != 0; - if (wantSpace) - { - // Add space after character - uint8_t mask = 0x80 >> (column & 7); - uint8_t *p = image + ((row * (numCols/8)) + (column/8)); - for (uint8_t i = 0; i < fontHeight && p < (image + sizeof(image)); ++i) - { - if (textInverted) - { - *p |= mask; - } - else - { - *p &= ~mask; - } - p += (numCols/8); - } - ++column; - } - } - - while (nCols != 0 && column < numCols) - { - uint16_t colData = pgm_read_word_near(fontPtr); - fontPtr += bytesPerColumn; - if (colData != 0) - { - lastCharColData = colData & cmask; - } - uint8_t mask1 = 0x80 >> (column & 7); - uint8_t mask2 = ~mask1; - uint8_t *p = image + ((row * (numCols/8)) + (column/8)); - const uint16_t setPixelVal = (textInverted) ? 0 : 1; - for (uint8_t i = 0; i < fontHeight && p < (image + sizeof(image)); ++i) - { - if ((colData & 1) == setPixelVal) - { - *p |= mask1; // set pixel - } - else - { - *p &= mask2; // clear pixel - } - colData >>= 1; - p += (numCols/8); - } - --nCols; - ++column; - } - - if (column > endCol) { endCol = column; } - } - else - { - // Alphanumeric mode - if (ch == '\r') - { - setCursor(0, column); - } - else if (ch == '\n') - { - setCursor(0, row + 1); - } - else - { - if (column == 16) - { - setCursor(row + 1, 0); - } - sendLcdData(ch); - ++column; - commandDelay(); // so that we are ready to write another character immediately - } - } - return 1; -} - -// Select normal or inverted text (only works in graphics mode) -void Lcd7920::textInvert(bool b) -{ - if (b != textInverted) - { - textInverted = b; - lastCharColData = 0xFFFF; // always need space between inverted and non-inverted text - } -} - -// NB - if using SPI then the SS pin must be set to be an output before calling this! -void Lcd7920::begin(bool gmode) -{ - - // Set up the SPI interface for talking to the LCD. We have to set MOSI, SCLK and SS to outputs, then enable SPI. - digitalWrite(clockPin, LOW); - digitalWrite(dataPin, LOW); - pinMode(clockPin, OUTPUT); - pinMode(dataPin, OUTPUT); - - if (useSpi) - { - delay(1); //dummy - // SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR0); // enable SPI, master mode, clock low when idle, data sampled on rising edge, clock = f/16 (= 1MHz), send MSB first - //SPSR = (1 << SPI2X); // double the speed to 2MHz (optional) - } - - gfxMode = false; - sendLcdCommand(LcdFunctionSetBasicAlpha); - delay(1); - sendLcdCommand(LcdFunctionSetBasicAlpha); - commandDelay(); - sendLcdCommand(LcdEntryModeSet); - commandDelay(); - extendedMode = false; - - clear(); // clear alpha ram - if (gmode) - { - gfxMode = true; - clear(); // clear gfx ram - } - setCursor(0, 0); - sendLcdCommand(LcdDisplayOn); - commandDelay(); - currentFont = 0; - textInverted = false; -} - -void Lcd7920::setFont(const PROGMEM LcdFont *newFont) -{ - currentFont = newFont; -} - -void Lcd7920::clear() -{ - if (gfxMode) - { - memset(image, 0, sizeof(image)); - // flag whole image as dirty and update - startRow = 0; - endRow = numRows; - startCol = 0; - endCol = numCols; - flush(); - } - else - { - ensureBasicMode(); - sendLcdCommand(LcdDisplayClear); - delay(LcdDisplayClearDelayMillis); - } - setCursor(0, 0); - textInverted = false; -} - -// Draw a line using the Bresenham Algorithm (thanks Wikipedia) -void Lcd7920::line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, PixelMode mode) -{ - int dx = (x1 >= x0) ? x1 - x0 : x0 - x1; - int dy = (y1 >= y0) ? y1 - y0 : y0 - y1; - int sx = (x0 < x1) ? 1 : -1; - int sy = (y0 < y1) ? 1 : -1; - int err = dx - dy; - - for (;;) - { - setPixel(x0, y0, mode); - if (x0 == x1 && y0 == y1) break; - int e2 = err + err; - if (e2 > -dy) - { - err -= dy; - x0 += sx; - } - if (e2 < dx) - { - err += dx; - y0 += sy; - } - } -} -void Lcd7920::fastHline(uint8_t x0, uint8_t y0, uint8_t x1, PixelMode mode) -{ - for (byte xx=0;xx< x1;xx++) - { - setPixel(x0+xx, y0, mode); - } -} -void Lcd7920::fastVline(uint8_t x0, uint8_t y0, uint8_t y1, PixelMode mode) -{ - for (byte yy=0;yy< y1;yy++) - { - setPixel(x0, y0+yy, mode); - } -} -// draw simple box - x0,y0=start, x1,y1-length in pixel -void Lcd7920::box(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, PixelMode mode) -{ - //line( x0, y0, x0+x1, y0, mode); - fastHline(x0,y0,x1, mode); - fastHline(x0,y0+y1,x1, mode); - // line( x0, y0+y1, x0+x1, y0+y1, mode); - //line( x0, y0+1, x0, y0+y1-1, mode); - fastVline(x0,y0+1,y1-1, mode); - fastVline(x0+x1-1,y0+1,y1-1, mode); - //line( x0+x1, y0+1, x0+x1, y0+y1-1, mode); - //line( x0, y0, x0+x1, y0+y1, mode); -} - -//draw full box -void Lcd7920::fillbox(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, PixelMode mode) -{ - for (byte x=0;x= 0) - { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - setPixel(x0 + x, y0 + y, mode); - setPixel(x0 - x, y0 + y, mode); - setPixel(x0 + x, y0 - y, mode); - setPixel(x0 - x, y0 - y, mode); - setPixel(x0 + y, y0 + x, mode); - setPixel(x0 - y, y0 + x, mode); - setPixel(x0 + y, y0 - x, mode); - setPixel(x0 - y, y0 - x, mode); - } -} - -// Draw a bitmap -void Lcd7920::bitmap(uint8_t x0, uint8_t y0, uint8_t width, uint8_t height, PROGMEM const uint8_t data[]) -{ - for (uint8_t r = 0; r < height && r + y0 < numRows; ++r) - { - uint8_t *p = image + (((r + y0) * (numCols/8)) + (x0/8)); - uint16_t bitMapOffset = r * (width/8); - for (uint8_t c = 0; c < (width/8) && c + (x0/8) < numCols/8; ++c) - { - *p++ = pgm_read_byte_near(bitMapOffset++); - } - } - if (x0 < startCol) startCol = x0; - if (x0 + width > endCol) endCol = x0 + width; - if (y0 < startRow) startRow = y0; - if (y0 + height > endRow) endRow = y0 + height; -} - -// Flush the dirty part of the image to the lcd -void Lcd7920::flush() -{ - if (gfxMode && endCol > startCol && endRow > startRow) - { - uint8_t startColNum = startCol/16; - uint8_t endColNum = (endCol + 15)/16; - for (uint8_t r = startRow; r < endRow; ++r) - { - setGraphicsAddress(r, startColNum); - uint8_t *ptr = image + ((16 * r) + (2 * startColNum)); - for (uint8_t i = startColNum; i < endColNum; ++i) - { - sendLcdData(*ptr++); - //commandDelay(); // don't seem to need a delay here - sendLcdData(*ptr++); - //commandDelay(); // don't seem to need as long a delay as this - delayMicroseconds(LcdDataDelayMicros); - } - } - startRow = numRows; - startCol = numCols; - endCol = endRow = 0; - } -} - -// Set the cursor position. We can only set alternate columns. The row addressing is rather odd. -void Lcd7920::setCursor(uint8_t r, uint8_t c) -{ - if (gfxMode) - { - row = r % numRows; - column = c % numCols; - lastCharColData = 0u; // flag that we just set the cursor position, so no space before next character - } - else - { - row = r % 4; - column = c % 16; - ensureBasicMode(); - sendLcdCommand(LcdSetDdramAddress + ((row & 1) * 0x10) + (column/2) + (row >> 1) * 8); - commandDelay(); - } -} - -void Lcd7920::setPixel(uint8_t x, uint8_t y, PixelMode mode) -{ - if (y < numRows && x < numCols) - { - uint8_t *p = image + ((y * (numCols/8)) + (x/8)); - uint8_t mask = 0x80u >> (x%8); - switch(mode) - { - case PixelClear: - *p &= ~mask; - break; - case PixelSet: - *p |= mask; - break; - case PixelFlip: - *p ^= mask; - break; - } - - // Change the dirty rectangle to account for a pixel being dirty (we assume it was changed) - if (startRow > y) { startRow = y; } - if (endRow <= y) { endRow = y + 1; } - if (startCol > x) { startCol = x; } - if (endCol <= x) { endCol = x + 1; } - } -} - -bool Lcd7920::readPixel(uint8_t x, uint8_t y) -{ - if (y < numRows && x < numCols) - { - uint8_t *p = image + ((y * (numCols/8)) + (x/8)); - return (*p & (0x80u >> (x%8))) != 0; - } - return false; -} - -void Lcd7920::setGraphicsAddress(unsigned int r, unsigned int c) -{ - if (gfxMode) - { - ensureExtendedMode(); - sendLcdCommand(LcdSetGdramAddress | (r & 31)); - //commandDelay(); // don't seem to need this one - sendLcdCommand(LcdSetGdramAddress | c | ((r & 32) >> 2)); - commandDelay(); // we definitely need this one - } -} - -void Lcd7920::commandDelay() -{ - delayMicroseconds(LcdCommandDelayMicros); -} - -// Send a command to the LCD -void Lcd7920::sendLcdCommand(uint8_t command) -{ - sendLcd(0xF8, command); -} - -// Send a data byte to the LCD -void Lcd7920::sendLcdData(uint8_t data) -{ - sendLcd(0xFA, data); -} - -// Send a command to the lcd. Data1 is sent as-is, data2 is split into 2 bytes, high nibble first. -void Lcd7920::sendLcd(uint8_t data1, uint8_t data2) -{ - if (useSpi) - { - delay(1); // dummy - /* - SPDR = data1; - while ((SPSR & (1 << SPIF)) == 0) { } - SPDR = data2 & 0xF0; - while ((SPSR & (1 << SPIF)) == 0) { } - SPDR = data2 << 4; - while ((SPSR & (1 << SPIF)) == 0) { } - */ - } - else - { - sendLcdSlow(data1); - sendLcdSlow(data2 & 0xF0); - sendLcdSlow(data2 << 4); - } -} - -void Lcd7920::sendLcdSlow(uint8_t data) -{ - /* -#if 1 - - // Fast shiftOut function - volatile uint32_t *sclkPort = portOutputRegister(digitalPinToPort(clockPin)); - volatile uint32_t *mosiPort = portOutputRegister(digitalPinToPort(dataPin)); - uint8_t sclkMask = digitalPinToBitMask(clockPin); - uint8_t mosiMask = digitalPinToBitMask(dataPin); - - uint8_t oldSREG = SREG; - cli(); - for (uint8_t i = 0; i < 8; ++i) - { - if (data & 0x80) - { - *mosiPort |= mosiMask; - } - else - { - *mosiPort &= ~mosiMask; - } - *sclkPort |= sclkMask; - *sclkPort &= ~sclkMask; - data <<= 1; - } - SREG = oldSREG; - - #else - */ - // really slow version, like Arduino shiftOut function - - for (uint8_t i = 0; i < 8; ++i) - { - digitalWrite(dataPin, (data & 0x80) ? HIGH : LOW); - // mosifast((data & 0x80) ? HIGH : LOW); // faster - digitalWrite(clockPin, HIGH); // do not change to high speed! - digitalWrite(clockPin, LOW); // do not change to high speed pin change! - - data <<= 1; - - } -/* - - for (uint8_t i = 0; i < 8; ++i) - { - mosifast((data & 0x80) ? HIGH : LOW); - delayMicroseconds(1); - sckfast(HIGH); - sckfast(LOW); - data <<= 1; - } - */ - -//#endif -} - -void Lcd7920::ensureBasicMode() -{ - if (extendedMode) - { - sendLcdCommand(gfxMode ? LcdFunctionSetBasicGraphic : LcdFunctionSetBasicAlpha); - commandDelay(); - extendedMode = false; - } -} - -void Lcd7920::ensureExtendedMode() -{ - if (!extendedMode) - { - sendLcdCommand(gfxMode ? LcdFunctionSetExtendedGraphic : LcdFunctionSetExtendedAlpha); - commandDelay(); - extendedMode = true; - } -} diff --git a/GD32F1/libraries/Lcd7920_STM/lcd7920_STM.h b/GD32F1/libraries/Lcd7920_STM/lcd7920_STM.h deleted file mode 100644 index c9c0335..0000000 --- a/GD32F1/libraries/Lcd7920_STM/lcd7920_STM.h +++ /dev/null @@ -1,124 +0,0 @@ -#include -#include -#include -#define mosifast(P) gpio_write_bit(GPIOB, 10, (P)); // STM32-define mosipin not in use -> much too fast! -#define sckfast(P) gpio_write_bit(GPIOA, 8, (P));// STM32-define sck pin -// Enumeration for specifying drawing modes -enum PixelMode -{ - PixelClear = 0, // clear the pixel(s) - PixelSet = 1, // set the pixel(s) - PixelFlip = 2 // invert the pixel(s) -}; - -// Struct for describing a font table, always held in PROGMEM -struct LcdFont -{ - PROGMEM const uint8_t *ptr; // pointer to font table - uint8_t startCharacter; // character code (e.g. ASCII) of the first character in the font - uint8_t endCharacter; // character code of the last character in the font - uint8_t height; // row height in pixels - only this number of pixels will be fetched and drawn - maximum 16 in this version of the sofware - uint8_t width; // max character width in pixels (the font table contains this number of bytes or words per character, plus 1 for the active width) -}; - -// Class for driving 128x64 graphical LCD fitted wirth ST7920 controller -// This drives the GLCD in serial mode so that it needs just 2 pins. -// Preferably, we use SPI to do the comms. - -// Derive the LCD class from the Print class so that we can print stuff to it in alpha mode -class Lcd7920 : public Print -{ -public: - // Construct a GLCD driver. - // cPin = clock pin (connects to E pin of ST7920) - // dPin = data pin (connects to R/W pin of ST7920) - // useSpi = true to use hardware SPI. If true then cPin must correspond to SCLK, dPin must correspond to MOSI, and SS must be configured as an output. - Lcd7920(uint8_t cPin, uint8_t dPin, bool useSpi); // constructor - - // Write a single character in the current font. Called by the 'print' functions. Works in both graphic and alphanumeric mode. - // If in graphic mode, a call to setFont must have been made before calling this. - // c = character to write - // Returns the number of characters written (1 if we wrote it, 0 otherwise) - virtual size_t write(uint8_t c); // write a character - - // Initialize the display. Call this in setup(). If using graphics mode, also call setFont to select initial text font. - // gmode = true to use graphics mode, false to use ST7920 alphanumeric mode. - void begin(bool gmode); - - // Select the font to use for subsequent calls to write() in graphics mode. Must be called before calling write() in graphics mode. - // newFont = pointer to font descriptor in PROGMEM - void setFont(const PROGMEM LcdFont *newFont); - - // Select normal or inverted text (only works in graphics mode) - void textInvert(bool b); - - // Clear the display. Works in both graphic and alphanumeric mode. Also selects non-inverted text. - void clear(); - - // Set the cursor position - // r = row. In alphanumeric mode this is text row number. - // In graphics mode it is the number of pixels from the top of the display to the top of the character. - // c = column. In alphanumeric mode this must be even (S7920 restriction becasue the characters are double width). - // In graphics ode this is the number of pixels from the left hand edge of the display and the left hand edge of the character. - void setCursor(uint8_t r, uint8_t c); // 'c' in alpha mode, should be an even column number - - // Flush the display buffer to the display. In graphics mode, calls to write, setPixel, line and circle will not be committed to the display until this is called. - void flush(); - - // Set, clear or invert a pixel - // x = x-coordinate of the pixel, measured from left hand edge of the display - // y = y-coordinate of the pixel, measured down from the top of the display - // mode = whether we want to set, clear or invert the pixel - void setPixel(uint8_t x, uint8_t y, PixelMode mode); - - // Read a pixel. Returns true if the pixel is set, false if it is clear. - // x = x-coordinate of the pixel, measured from left hand edge of the display - // y = y-coordinate of the pixel, measured down from the top of the display - bool readPixel(uint8_t x, uint8_t y); - - // Draw a line. - // x0 = x-coordinate of one end of the line, measured from left hand edge of the display - // y0 = y-coordinate of one end of the line, measured down from the top of the display - // x1, y1 = coordinates of the other end od the line - // mode = whether we want to set, clear or invert each pixel - void line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, PixelMode mode); - void fastHline(uint8_t x0, uint8_t y0, uint8_t x1, PixelMode mode); - void fastVline(uint8_t x0, uint8_t y0, uint8_t y1, PixelMode mode); - void box(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, PixelMode mode); // new add Diro - void fillbox(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, PixelMode mode); // new add Diro - // Draw a circle - // x0 = x-coordinate of the centre, measured from left hand edge of the display - // y0 = y-coordinate of the centre, measured down from the top of the display - // redius = radius of the circle in pixels - // mode = whether we want to set, clear or invert each pixel - void circle(uint8_t x0, uint8_t y0, uint8_t radius, PixelMode mode); - - // Draw a bitmap - // x0 = x-coordinate of the top left, measured from left hand edge of the display. Currently, must be a multiple of 8. - // y0 = y-coordinate of the top left, measured down from the top of the display - // width = width of bitmap in pixels. Currently, must be a multiple of 8. - // rows = height of bitmap in pixels - // data = bitmap image in PROGMEM, must be ((width/8) * rows) bytes long - void bitmap(uint8_t x0, uint8_t y0, uint8_t width, uint8_t height, PROGMEM const uint8_t data[]); - -private: - bool gfxMode; - bool extendedMode; - bool useSpi; - bool textInverted; - uint8_t clockPin, dataPin; - uint16_t lastCharColData; // data for the last non-space column, used for kerning - uint8_t row, column; - uint8_t startRow, startCol, endRow, endCol; // coordinates of the dirty rectangle - uint8_t image[(128 * 64)/8]; // image buffer, 1K in size (= half the RAM of the Uno) - const PROGMEM struct LcdFont *currentFont; // pointer to descriptor for current font - - void sendLcdCommand(uint8_t command); - void sendLcdData(uint8_t data); - void sendLcd(uint8_t data1, uint8_t data2); - void sendLcdSlow(uint8_t data); - void commandDelay(); - void setGraphicsAddress(unsigned int r, unsigned int c); - void ensureBasicMode(); - void ensureExtendedMode(); -}; diff --git a/GD32F1/libraries/Lcd7920_STM/readme.md b/GD32F1/libraries/Lcd7920_STM/readme.md deleted file mode 100644 index 20980bb..0000000 --- a/GD32F1/libraries/Lcd7920_STM/readme.md +++ /dev/null @@ -1 +0,0 @@ -This library has been provided by Matthias (@madias from the Arduino forum) \ No newline at end of file diff --git a/GD32F1/libraries/LiquidCrystal/LiquidCrystal.cpp b/GD32F1/libraries/LiquidCrystal/LiquidCrystal.cpp deleted file mode 100644 index 2cced7a..0000000 --- a/GD32F1/libraries/LiquidCrystal/LiquidCrystal.cpp +++ /dev/null @@ -1,336 +0,0 @@ -#include "LiquidCrystal.h" - -#include -#include -#include - -// When the display powers up, it is configured as follows: -// -// 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift -// -// Note, however, that resetting the Arduino doesn't reset the LCD, so we -// can't assume that its in that state when a sketch starts (and the -// LiquidCrystal constructor is called). - -// This library has been modified to be compatible with the LeafLabs Maple; -// very conservative timing is used due to problems with delayMicroseconds() -// that should be fixed in the 0.0.7 release of the libmaple. [bnewbold] - -LiquidCrystal::LiquidCrystal(uint8 rs, uint8 rw, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3, - uint8 d4, uint8 d5, uint8 d6, uint8 d7) -{ - init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); -} - -LiquidCrystal::LiquidCrystal(uint8 rs, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3, - uint8 d4, uint8 d5, uint8 d6, uint8 d7) -{ - init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); -} - -LiquidCrystal::LiquidCrystal(uint8 rs, uint8 rw, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3) -{ - init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); -} - -LiquidCrystal::LiquidCrystal(uint8 rs, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3) -{ - init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); -} - -void LiquidCrystal::init(uint8 fourbitmode, uint8 rs, uint8 rw, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3, - uint8 d4, uint8 d5, uint8 d6, uint8 d7) -{ - _rs_pin = rs; - _rw_pin = rw; - _enable_pin = enable; - - _data_pins[0] = d0; - _data_pins[1] = d1; - _data_pins[2] = d2; - _data_pins[3] = d3; - _data_pins[4] = d4; - _data_pins[5] = d5; - _data_pins[6] = d6; - _data_pins[7] = d7; - displaymode=fourbitmode; - - if (fourbitmode) - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else - _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - // TODO: bnewbold, re-enable this? -// begin(16, 1); -} - -void LiquidCrystal::begin(uint8 cols, uint8 lines, uint8 dotsize) { - - for (int i = 0; i < 8 - displaymode * 4; i++) { - //for (int i = 0; i <4; i++) { - pinMode(_data_pins[i], OUTPUT); - } - - pinMode(_rs_pin, OUTPUT); - // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { - pinMode(_rw_pin, OUTPUT); - } - pinMode(_enable_pin, OUTPUT); - if (lines > 1) { - _displayfunction |= LCD_2LINE; - } - _numlines = lines; - _currline = 0; - - // for some 1 line displays you can select a 10 pixel high font - if ((dotsize != 0) && (lines == 1)) { - _displayfunction |= LCD_5x10DOTS; - } - - // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! according to - // datasheet, we need at least 40ms after power rises above 2.7V - // before sending commands. Arduino can turn on way befer 4.5V so - // we'll wait 50 - delay(50); // Maple mod - //delayMicroseconds(50000); - // Now we pull both RS and R/W low to begin commands - digitalWrite(_rs_pin, LOW); - digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { - digitalWrite(_rw_pin, LOW); - } - - //put the LCD into 4 bit or 8 bit mode - if (! (_displayfunction & LCD_8BITMODE)) { - // this is according to the hitachi HD44780 datasheet - // figure 24, pg 46 - - // we start in 8bit mode, try to set 4 bit mode - write4bits(0x03); - delay(5); // Maple mod - //delayMicroseconds(4500); // wait min 4.1ms - - // second try - write4bits(0x03); - delay(5); // Maple mod - //delayMicroseconds(4500); // wait min 4.1ms - - // third go! - write4bits(0x03); - delay(1); // Maple mod - //delayMicroseconds(150); - - // finally, set to 8-bit interface - write4bits(0x02); - } else { - // this is according to the hitachi HD44780 datasheet - // page 45 figure 23 - - // Send function set command sequence - command(LCD_FUNCTIONSET | _displayfunction); - delay(5); // Maple mod - //delayMicroseconds(4500); // wait more than 4.1ms - - // second try - command(LCD_FUNCTIONSET | _displayfunction); - delay(1); // Maple mod - //delayMicroseconds(150); - - // third go - command(LCD_FUNCTIONSET | _displayfunction); - } - - // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); - - // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; - display(); - - // clear it off - clear(); - - // Initialize to default text direction (for romance languages) - _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; - // set the entry mode - command(LCD_ENTRYMODESET | _displaymode); - -} - -/********** high level commands, for the user! */ -void LiquidCrystal::clear() -{ - command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero - delay(2); // Maple mod - //delayMicroseconds(2000); // this command takes a long time! -} - -void LiquidCrystal::home() -{ - command(LCD_RETURNHOME); // set cursor position to zero - delay(2); // Maple mod - //delayMicroseconds(2000); // this command takes a long time! -} - -void LiquidCrystal::setCursor(uint8 col, uint8 row) -{ - int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; - if ( row > _numlines ) { - row = _numlines-1; // we count rows starting w/0 - } - - command(LCD_SETDDRAMADDR | (col + row_offsets[row])); -} - -// Turn the display on/off (quickly) -void LiquidCrystal::noDisplay() { - _displaycontrol &= ~LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::display() { - _displaycontrol |= LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turns the underline cursor on/off -void LiquidCrystal::noCursor() { - _displaycontrol &= ~LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::cursor() { - _displaycontrol |= LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turn on and off the blinking cursor -void LiquidCrystal::noBlink() { - _displaycontrol &= ~LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::blink() { - _displaycontrol |= LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// These commands scroll the display without changing the RAM -void LiquidCrystal::scrollDisplayLeft(void) { - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); -} -void LiquidCrystal::scrollDisplayRight(void) { - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); -} - -// This is for text that flows Left to Right -void LiquidCrystal::leftToRight(void) { - _displaymode |= LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This is for text that flows Right to Left -void LiquidCrystal::rightToLeft(void) { - _displaymode &= ~LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'right justify' text from the cursor -void LiquidCrystal::autoscroll(void) { - _displaymode |= LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'left justify' text from the cursor -void LiquidCrystal::noAutoscroll(void) { - _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// Allows us to fill the first 8 CGRAM locations -// with custom characters -void LiquidCrystal::createChar(uint8 location, uint8 charmap[]) { - location &= 0x7; // we only have 8 locations 0-7 - command(LCD_SETCGRAMADDR | (location << 3)); - for (int i=0; i<8; i++) { - write(charmap[i]); - } -} - -/*********** mid level commands, for sending data/cmds */ - -inline void LiquidCrystal::command(uint8 value) { - send(value, LOW); -} - -inline size_t LiquidCrystal::write(uint8 value) { - send(value, HIGH); - return 1; -} - -/************ low level data pushing commands **********/ - -// write either command or data, with automatic 4/8-bit selection -void LiquidCrystal::send(uint8 value, uint8 mode) { - digitalWrite(_rs_pin, mode); - - // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { - digitalWrite(_rw_pin, LOW); - } - - if (_displayfunction & LCD_8BITMODE) { - write8bits(value); - } else { - write4bits(value>>4); - write4bits(value); - } -} - -void LiquidCrystal::pulseEnable(void) { - // _enable_pin should already be LOW (unless someone else messed - // with it), so don't sit around waiting for long. - digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); - - // Enable pulse must be > 450 ns. Value chosen here according to - // the following threads: - // http://forums.leaflabs.com/topic.php?id=640 - // http://forums.leaflabs.com/topic.php?id=512 - gpio_toggle_bit(PIN_MAP[_enable_pin].gpio_device, PIN_MAP[_enable_pin].gpio_bit);// togglePin(_enable_pin); - delayMicroseconds(1); - gpio_toggle_bit(PIN_MAP[_enable_pin].gpio_device, PIN_MAP[_enable_pin].gpio_bit);// togglePin(_enable_pin); - - // Commands needs > 37us to settle. - delayMicroseconds(42); -} - -void LiquidCrystal::write4bits(uint8 value) { - for (int i = 0; i < 4; i++) { - digitalWrite(_data_pins[i], (value >> i) & 0x01); - } - - pulseEnable(); -} - -void LiquidCrystal::write8bits(uint8 value) { - for (int i = 0; i < 8; i++) { - digitalWrite(_data_pins[i], (value >> i) & 0x01); - } - - pulseEnable(); -} diff --git a/GD32F1/libraries/LiquidCrystal/LiquidCrystal.h b/GD32F1/libraries/LiquidCrystal/LiquidCrystal.h deleted file mode 100644 index f81d09e..0000000 --- a/GD32F1/libraries/LiquidCrystal/LiquidCrystal.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef LiquidCrystal_h -#define LiquidCrystal_h - -//#include -#include -#include - -// commands -#define LCD_CLEARDISPLAY 0x01 -#define LCD_RETURNHOME 0x02 -#define LCD_ENTRYMODESET 0x04 -#define LCD_DISPLAYCONTROL 0x08 -#define LCD_CURSORSHIFT 0x10 -#define LCD_FUNCTIONSET 0x20 -#define LCD_SETCGRAMADDR 0x40 -#define LCD_SETDDRAMADDR 0x80 - -// flags for display entry mode -#define LCD_ENTRYRIGHT 0x00 -#define LCD_ENTRYLEFT 0x02 -#define LCD_ENTRYSHIFTINCREMENT 0x01 -#define LCD_ENTRYSHIFTDECREMENT 0x00 - -// flags for display on/off control -#define LCD_DISPLAYON 0x04 -#define LCD_DISPLAYOFF 0x00 -#define LCD_CURSORON 0x02 -#define LCD_CURSOROFF 0x00 -#define LCD_BLINKON 0x01 -#define LCD_BLINKOFF 0x00 - -// flags for display/cursor shift -#define LCD_DISPLAYMOVE 0x08 -#define LCD_CURSORMOVE 0x00 -#define LCD_MOVERIGHT 0x04 -#define LCD_MOVELEFT 0x00 - -// flags for function set -#define LCD_8BITMODE 0x10 -#define LCD_4BITMODE 0x00 -#define LCD_2LINE 0x08 -#define LCD_1LINE 0x00 -#define LCD_5x10DOTS 0x04 -#define LCD_5x8DOTS 0x00 - -class LiquidCrystal : public Print { -public: - LiquidCrystal(uint8 rs, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3, - uint8 d4, uint8 d5, uint8 d6, uint8 d7); - LiquidCrystal(uint8 rs, uint8 rw, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3, - uint8 d4, uint8 d5, uint8 d6, uint8 d7); - LiquidCrystal(uint8 rs, uint8 rw, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3); - LiquidCrystal(uint8 rs, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3); - - void init(uint8 fourbitmode, uint8 rs, uint8 rw, uint8 enable, - uint8 d0, uint8 d1, uint8 d2, uint8 d3, - uint8 d4, uint8 d5, uint8 d6, uint8 d7); - - void begin(uint8 cols, uint8 rows, uint8 charsize = LCD_5x8DOTS); - - void clear(); - void home(); - - void noDisplay(); - void display(); - void noBlink(); - void blink(); - void noCursor(); - void cursor(); - void scrollDisplayLeft(); - void scrollDisplayRight(); - void leftToRight(); - void rightToLeft(); - void autoscroll(); - void noAutoscroll(); - - void createChar(uint8, uint8[]); - void setCursor(uint8, uint8); - virtual size_t write(uint8); - void command(uint8); -private: - void send(uint8, uint8); - void write4bits(uint8); - void write8bits(uint8); - void pulseEnable(); - uint8 displaymode; - uint8 _rs_pin; // LOW: command. HIGH: character. - uint8 _rw_pin; // LOW: write to LCD. HIGH: read from LCD. - uint8 _enable_pin; // activated by a HIGH pulse. - uint8 _data_pins[8]; - - uint8 _displayfunction; - uint8 _displaycontrol; - uint8 _displaymode; - - uint8 _initialized; - - uint8 _numlines,_currline; -}; - -#endif diff --git a/GD32F1/libraries/LiquidCrystal/rules.mk b/GD32F1/libraries/LiquidCrystal/rules.mk deleted file mode 100644 index 7b18203..0000000 --- a/GD32F1/libraries/LiquidCrystal/rules.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -# Local flags -CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) - -# Local rules and targets -cSRCS_$(d) := - -cppSRCS_$(d) := LiquidCrystal.cpp - -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ - $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) \ No newline at end of file diff --git a/GD32F1/libraries/MapleCoOS/MapleCoOS.h b/GD32F1/libraries/MapleCoOS/MapleCoOS.h deleted file mode 100644 index 701f9f8..0000000 --- a/GD32F1/libraries/MapleCoOS/MapleCoOS.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _COOS_H_ -#define _COOS_H_ - -#include "WProgram.h" -extern "C" { - #include "utility/CoOS.h" -} - -#define TASK_STK_SIZE 128 /*!< Define stack size. */ - -#endif diff --git a/GD32F1/libraries/MapleCoOS/examples/coos_display_blink/coos_display_blink.ino b/GD32F1/libraries/MapleCoOS/examples/coos_display_blink/coos_display_blink.ino deleted file mode 100644 index 28c92aa..0000000 --- a/GD32F1/libraries/MapleCoOS/examples/coos_display_blink/coos_display_blink.ino +++ /dev/null @@ -1,216 +0,0 @@ -#define USE_SEMAPHORE_DMA1 -#include -#include -#include -#include - -#define __CS 8 -#define __RST 9 -#define __DC 10 - -TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST); - -OS_MutexID xDisplayFree; - -OS_STK vCube1LoopStk[TASK_STK_SIZE]; -OS_STK vCube2LoopStk[TASK_STK_SIZE]; -OS_STK vLEDFlashStk[TASK_STK_SIZE]; -OS_STK vSqrtStk[TASK_STK_SIZE]; - - -const float sin_d[] = { - 0, 0.17, 0.34, 0.5, 0.64, 0.77, 0.87, 0.94, 0.98, 1, 0.98, 0.94, - 0.87, 0.77, 0.64, 0.5, 0.34, 0.17, 0, -0.17, -0.34, -0.5, -0.64, - -0.77, -0.87, -0.94, -0.98, -1, -0.98, -0.94, -0.87, -0.77, - -0.64, -0.5, -0.34, -0.17 -}; -const float cos_d[] = { - 1, 0.98, 0.94, 0.87, 0.77, 0.64, 0.5, 0.34, 0.17, 0, -0.17, -0.34, - -0.5, -0.64, -0.77, -0.87, -0.94, -0.98, -1, -0.98, -0.94, -0.87, - -0.77, -0.64, -0.5, -0.34, -0.17, 0, 0.17, 0.34, 0.5, 0.64, 0.77, - 0.87, 0.94, 0.98 -}; -const float d = 5; -float cube1_px[] = { - -d, d, d, -d, -d, d, d, -d -}; -float cube1_py[] = { - -d, -d, d, d, -d, -d, d, d -}; -float cube1_pz[] = { - -d, -d, -d, -d, d, d, d, d -}; - -float cube1_p2x[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; -float cube1_p2y[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int cube1_r[] = { - 0, 0, 0 -}; -const float d2 = 10; -float cube2_px[] = { - -d2, d2, d2, -d2, -d2, d2, d2, -d2 -}; -float cube2_py[] = { - -d2, -d2, d2, d2, -d2, -d2, d2, d2 -}; -float cube2_pz[] = { - -d2, -d2, -d2, -d2, d2, d2, d2, d2 -}; - -float cube2_p2x[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; -float cube2_p2y[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int cube2_r[] = { - 0, 0, 0 -}; - -uint16 cube1_x, cube1_y, cube2_x, cube2_y, cube1_color, cube2_color; - -static void vLEDFlashTask(void *pdata) { - for (;;) { - CoTickDelay(950); - digitalWrite(BOARD_LED_PIN, HIGH); - CoTickDelay(50); - digitalWrite(BOARD_LED_PIN, LOW); - } -} - -static void vCube1LoopTask(void *pdata) { - while (1) { - CoEnterMutexSection (xDisplayFree); - cube(cube1_px, cube1_py, cube1_pz, cube1_p2x, cube1_p2y, cube1_r, &cube1_x, &cube1_y, &cube1_color); - CoLeaveMutexSection( xDisplayFree ); - CoTickDelay(15); - } -} - -static void vCube2LoopTask(void *pdata) { - while (1) { - CoEnterMutexSection (xDisplayFree); - cube(cube2_px, cube2_py, cube2_pz, cube2_p2x, cube2_p2y, cube2_r, &cube2_x, &cube2_y, &cube2_color); - CoLeaveMutexSection( xDisplayFree ); - CoTickDelay(40); - } -} - - -void cube(float *px, float *py, float *pz, float *p2x, float *p2y, int *r, uint16 *x, uint16 *y, uint16 *color) { - - for (int i = 0; i < 3; i++) { - tft.drawLine(p2x[i], p2y[i], p2x[i + 1], p2y[i + 1], WHITE); - tft.drawLine(p2x[i + 4], p2y[i + 4], p2x[i + 5], p2y[i + 5], WHITE); - tft.drawLine(p2x[i], p2y[i], p2x[i + 4], p2y[i + 4], WHITE); - } - tft.drawLine(p2x[3], p2y[3], p2x[0], p2y[0], WHITE); - tft.drawLine(p2x[7], p2y[7], p2x[4], p2y[4], WHITE); - tft.drawLine(p2x[3], p2y[3], p2x[7], p2y[7], WHITE); - - r[0] = r[0] + 1; - r[1] = r[1] + 1; - if (r[0] == 36) r[0] = 0; - if (r[1] == 36) r[1] = 0; - if (r[2] == 36) r[2] = 0; - for (int i = 0; i < 8; i++) - { - float px2 = px[i]; - float py2 = cos_d[r[0]] * py[i] - sin_d[r[0]] * pz[i]; - float pz2 = sin_d[r[0]] * py[i] + cos_d[r[0]] * pz[i]; - - float px3 = cos_d[r[1]] * px2 + sin_d[r[1]] * pz2; - float py3 = py2; - float pz3 = -sin_d[r[1]] * px2 + cos_d[r[1]] * pz2; - - float ax = cos_d[r[2]] * px3 - sin_d[r[2]] * py3; - float ay = sin_d[r[2]] * px3 + cos_d[r[2]] * py3; - float az = pz3 - 190; - - p2x[i] = *x + ax * 500 / az; - p2y[i] = *y + ay * 500 / az; - } - - for (int i = 0; i < 3; i++) { - tft.drawLine(p2x[i], p2y[i], p2x[i + 1], p2y[i + 1], *color); - tft.drawLine(p2x[i + 4], p2y[i + 4], p2x[i + 5], p2y[i + 5], *color); - tft.drawLine(p2x[i], p2y[i], p2x[i + 4], p2y[i + 4], *color); - } - tft.drawLine(p2x[3], p2y[3], p2x[0], p2y[0], *color); - tft.drawLine(p2x[7], p2y[7], p2x[4], p2y[4], *color); - tft.drawLine(p2x[3], p2y[3], p2x[7], p2y[7], *color); -} - -static void vSqrtTask(void *pdata) { - while (1) { - Serial.println ("Starting Sqrt calculations..."); - uint16 x = 0; - uint16 ixx[1001]; - // Library Sqrt - uint32_t t0 = millis(); - for (uint32_t n = 247583650 ; n > 247400000 ; n--) { - x = sqrt (n); - } - uint32_t t1 = millis() - t0; - Serial.print ("Sqrt calculations took (ms): "); - Serial.println (t1); - CoTickDelay (5000); - } -} - -void setup() { - // initialize the digital pin as an output: - Serial.begin(9600); - delay (5000); - Serial.println ("Running..."); - pinMode(BOARD_LED_PIN, OUTPUT); - tft.begin(); - tft.fillScreen(WHITE); - cube1_x = ((tft.width()) / 4); - cube1_y = ((tft.height()) / 4); - cube2_x = ((tft.width()) / 2); - cube2_y = ((tft.height()) / 2); - cube1_color = BLACK; - cube2_color = RED; - CoInitOS(); - xDisplayFree = CoCreateMutex(); - CoCreateTask(vLEDFlashTask, - (void *)0 , - 2, - &vLEDFlashStk[TASK_STK_SIZE - 1], - TASK_STK_SIZE - ); - - CoCreateTask(vCube1LoopTask, - (void *)0 , - 3, - &vCube1LoopStk[TASK_STK_SIZE - 1], - TASK_STK_SIZE - ); - CoCreateTask(vCube2LoopTask, - (void *)0 , - 3, - &vCube2LoopStk[TASK_STK_SIZE - 1], - TASK_STK_SIZE - ); - CoCreateTask(vSqrtTask, - (void *)0 , - 4, - &vSqrtStk[TASK_STK_SIZE - 1], - TASK_STK_SIZE - ); - - CoStartOS(); -} - -void loop() { - // Do not write any code here, it would not execute. -} - - diff --git a/GD32F1/libraries/MapleCoOS/keywords.txt b/GD32F1/libraries/MapleCoOS/keywords.txt deleted file mode 100644 index 04e603d..0000000 --- a/GD32F1/libraries/MapleCoOS/keywords.txt +++ /dev/null @@ -1,25 +0,0 @@ -####################################### -# Syntax Coloring Map For CoOS -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### -OS_STK KEYWORD1 -OS_MutexID KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -CoInitOS KEYWORD2 -CoCreateTask KEYWORD2 -CoStartOS KEYWORD2 -CoTickDelay KEYWORD2 -CoLeaveMutexSection KEYWORD2 -CoEnterMutexSection KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### -TASK_STK_SIZE LITERAL1 diff --git a/GD32F1/libraries/MapleCoOS/utility/CoOS.h b/GD32F1/libraries/MapleCoOS/utility/CoOS.h deleted file mode 100644 index e860903..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/CoOS.h +++ /dev/null @@ -1,221 +0,0 @@ -/** - ******************************************************************************* - * @file ccrtos.h - * @version V1.12 - * @date 2010.03.01 - * @brief API header file of CooCox CoOS. - * @details This file including all API functions's declare of CooCox CoOS. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - -#ifndef _CCRTOS_H -#define _CCRTOS_H -#include "OsConfig.h" -/*---------------------------- Type Define ----------------------------------*/ -typedef signed char S8; -typedef unsigned char U8; -typedef short S16; -typedef unsigned short U16; -typedef int S32; -typedef unsigned int U32; -typedef long long S64; -typedef unsigned long long U64; -typedef unsigned char BIT; -typedef unsigned char BOOL; -typedef unsigned int OS_STK; -typedef U8 OS_TID; -typedef U8 OS_TCID; -typedef U8 OS_MutexID; -typedef U8 OS_EventID; -typedef U8 OS_FlagID; -typedef U8 OS_MMID; -typedef U8 StatusType; -typedef U16 OS_VER; -typedef void (*FUNCPtr)(void*); -typedef void (*vFUNCPtr)(void); - - -/*---------------------------- Constant Define -------------------------------*/ -#ifndef NULL -#define NULL ((void *)0) -#endif - -#ifndef FALSE -#define FALSE (0) -#endif - -#ifndef TRUE -#define TRUE (1) -#endif - - -/*---------------------------- Error Codes ---------------------------------*/ -#define E_CREATE_FAIL (StatusType)-1 -#define E_OK (StatusType)0 -#define E_INVALID_ID (StatusType)1 -#define E_INVALID_PARAMETER (StatusType)2 -#define E_CALL (StatusType)3 -#define E_TASK_WAITING (StatusType)4 -#define E_TIMEOUT (StatusType)5 -#define E_SEM_FULL (StatusType)6 -#define E_MBOX_FULL (StatusType)7 -#define E_QUEUE_FULL (StatusType)8 -#define E_SEM_EMPTY (StatusType)9 -#define E_MBOX_EMPTY (StatusType)10 -#define E_QUEUE_EMPTY (StatusType)11 -#define E_FLAG_NOT_READY (StatusType)12 -#define E_ALREADY_IN_WAITING (StatusType)13 -#define E_TASK_NOT_WAITING (StatusType)14 -#define E_TASK_WAIT_OTHER (StatusType)15 -#define E_EXCEED_MAX_NUM (StatusType)16 -#define E_NOT_IN_DELAY_LIST (StatusType)17 -#define E_SEV_REQ_FULL (StatusType)18 -#define E_NOT_FREE_ALL (StatusType)19 -#define E_PROTECTED_TASK (StatusType)20 -#define E_OS_IN_LOCK (StatusType)21 - - -/*---------------------------- Wait Opreation type --------------------------*/ -#define OPT_WAIT_ALL 0 /*!< Wait for all flags. */ -#define OPT_WAIT_ANY 1 /*!< Wait for any one of flags. */ -#define OPT_WAIT_ONE 2 /*!< Waot for one flag. */ - - -/*---------------------------- Delete Opreation type ------------------------*/ -#define OPT_DEL_NO_PEND 0 /*!< Delete when no task waitting for */ -#define OPT_DEL_ANYWAY 1 /*!< Delete always. */ - - -/*---------------------------- Timer Types ----------------------------------*/ -#if CFG_TMR_EN >0 -#define TMR_TYPE_ONE_SHOT 0 /*!< Timer counter type: One-shot */ -#define TMR_TYPE_PERIODIC 1 /*!< Timer counter type: Periodic */ -#endif - - -/*---------------------------- Event Control ---------------------------------*/ -#if CFG_EVENT_EN >0 -#define EVENT_SORT_TYPE_FIFO (U8)0x01 /*!< Insert a event by FIFO */ -#define EVENT_SORT_TYPE_PRIO (U8)0x02 /*!< Insert a event by prio */ -#endif - - -/*---------------------------- Function declare-------------------------------*/ - -/* Implement in file "core.c" */ -extern void CoInitOS(void); /*!< Initialize OS */ -extern void CoStartOS(void); /*!< Start multitask */ -extern void CoEnterISR(void); /*!< Enter a ISR */ -extern void CoExitISR(void); /*!< Exit a ISR */ -extern void CoSchedLock(void); -extern void CoSchedUnlock(void); -extern OS_VER CoGetOSVersion(void); /*!< Get OS version value */ - - -/* Implement in file "task.c" */ -#define CoCreateTask(task,argv,prio,stk,stkSz) \ - CreateTask(task,argv,(prio)|((stkSz)<<8),stk) - - -#define CoCreateTaskEx(task,argv,prio,stk,stkSz,timeSlice,isWaitting) \ - CreateTask(task,argv,(prio)|((stkSz)<<8)|((timeSlice)<<20)|(isWaitting<<31),stk) - -extern void CoExitTask(void); -extern OS_TID CoGetCurTaskID(void); -extern StatusType CoDelTask(OS_TID taskID); -extern StatusType CoActivateTask(OS_TID taskID,void *argv); -extern StatusType CoAwakeTask(OS_TID taskID); -extern StatusType CoSuspendTask(OS_TID taskID); -extern StatusType CoSetPriority(OS_TID taskID,U8 priority); -extern OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk); - -/* Implement in file "time.c" */ -extern U64 CoGetOSTime(void); -extern StatusType CoTickDelay(U32 ticks); -extern StatusType CoResetTaskDelayTick(OS_TID taskID,U32 ticks); -extern StatusType CoTimeDelay(U8 hour,U8 minute,U8 sec,U16 millsec); - - -/* Implement in file "timer.c" */ -extern StatusType CoDelTmr(OS_TCID tmrID); -extern StatusType CoStopTmr(OS_TCID tmrID); -extern StatusType CoStartTmr(OS_TCID tmrID); -extern U32 CoGetCurTmrCnt(OS_TCID tmrID,StatusType* perr); -extern StatusType CoSetTmrCnt(OS_TCID tmrID,U32 tmrCnt,U32 tmrReload); -extern OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func); - - -/* Implement in file "kernelHeap.c"*/ -extern void* CoKmalloc(U32 size); -extern void CoKfree(void* memBuf); - - -/* Implement in file "mm.c" */ -extern void* CoGetMemoryBuffer(OS_MMID mmID); -extern StatusType CoDelMemoryPartition(OS_MMID mmID); -extern StatusType CoFreeMemoryBuffer(OS_MMID mmID,void* buf); -extern U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr); -extern OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum); - -/* Implement in file "mutex.c" */ -extern OS_MutexID CoCreateMutex(void); -extern StatusType CoEnterMutexSection(OS_MutexID mutexID); -extern StatusType CoLeaveMutexSection(OS_MutexID mutexID); - - -/* Implement in file "sem.c" */ -extern StatusType CoPostSem(OS_EventID id); -extern StatusType CoAcceptSem(OS_EventID id); -extern StatusType isr_PostSem(OS_EventID id); -extern StatusType CoDelSem(OS_EventID id,U8 opt); -extern StatusType CoPendSem(OS_EventID id,U32 timeout); -extern OS_EventID CoCreateSem(U16 initCnt,U16 maxCnt,U8 sortType); - - -/* Implement in file "mbox.c" */ -extern OS_EventID CoCreateMbox(U8 sortType); -extern StatusType CoDelMbox(OS_EventID id,U8 opt); -extern StatusType CoPostMail(OS_EventID id,void* pmail); -extern StatusType isr_PostMail(OS_EventID id,void* pmail); -extern void* CoAcceptMail(OS_EventID id,StatusType* perr); -extern void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr); - - -/* Implement in file "queue.c" */ -extern StatusType CoDelQueue(OS_EventID id,U8 opt); -extern StatusType CoPostQueueMail(OS_EventID id,void* pmail); -extern StatusType isr_PostQueueMail(OS_EventID id,void* pmail); -extern void* CoAcceptQueueMail(OS_EventID id,StatusType* perr); -extern OS_EventID CoCreateQueue(void **qStart, U16 size ,U8 sortType); -extern void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr); - - - -/* Implement in file "flag.c" */ -extern StatusType CoSetFlag (OS_FlagID id); -extern StatusType CoClearFlag (OS_FlagID id); -extern StatusType isr_SetFlag (OS_FlagID id); -extern StatusType CoDelFlag (OS_FlagID id,U8 opt); -extern StatusType CoAcceptSingleFlag (OS_FlagID id); -extern StatusType CoWaitForSingleFlag (OS_FlagID id,U32 timeout); -extern OS_FlagID CoCreateFlag (BOOL bAutoReset,BOOL bInitialState); -extern U32 CoAcceptMultipleFlags (U32 flags,U8 waitType,StatusType *perr); -extern U32 CoWaitForMultipleFlags (U32 flags,U8 waitType,U32 timeout,StatusType *perr); - - -/* Implement in file "utility.c" */ -extern StatusType CoTimeToTick(U8 hour,U8 minute,U8 sec,U16 millsec,U32* ticks); -extern void CoTickToTime(U32 ticks,U8* hour,U8* minute,U8* sec,U16* millsec); - - -/* Implement in file "hook.c" */ -extern void CoIdleTask(void* pdata); -extern void CoStkOverflowHook(OS_TID taskID); - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsArch.c b/GD32F1/libraries/MapleCoOS/utility/OsArch.c deleted file mode 100644 index 300dbb9..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsArch.c +++ /dev/null @@ -1,96 +0,0 @@ -/** - ******************************************************************************* - * @file cpu.c - * @version V1.12 - * @date 2010.03.01 - * @brief This file provides InitTaskContext() and SysTick_Handler(). - ******************************************************************************* - * @copy - * WRITE COPY INFORMATION USE CAPITAL LETTER - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include -U64 OSTickCnt = 0; /*!< Current system tick counter */ - -/** - ****************************************************************************** - * @brief Initial task context - * @param[in] task Entry point of task. - * @param[in] param The parameter pass to task. - * @param[in] pstk The pointer to stack top. - * @param[out] None - * @retval Returns location of new stack top. - * - * @par Description - * @details This function is called to initialize the stack frame of the - * task being created. - ****************************************************************************** - */ -OS_STK *InitTaskContext(FUNCPtr task,void *param,OS_STK *pstk) -{ - OS_STK *context; - context = pstk; - *(context--) = (U32)0x01000000L; /* xPSR */ - *(context--) = (U32)task; /* Entry point of task. */ - *(context) = (U32)0xFFFFFFFEL; - context = context - 5; - *(context) = (U32)param; /* R0: argument */ - context = context - 8; - - return (context); /* Returns location of new stack top. */ -} - - - -/** - ******************************************************************************* - * @brief System tick interrupt handler. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This is system tick interrupt headler. - * @note CoOS may schedule when exiting this ISR. - ******************************************************************************* - */ -void CoSysTick_Handler(void) -{ - OSSchedLock++; /* Lock scheduler. */ - OSTickCnt++; /* Increment systerm time. */ -#if CFG_TASK_WAITTING_EN >0 - if(DlyList != NULL) /* Have task in delay list? */ - { - if(DlyList->delayTick > 1) /* Delay time > 1? */ - { - DlyList->delayTick--; /* Decrease delay time of the list head. */ - } - else - { - DlyList->delayTick = 0; - isr_TimeDispose(); /* Call hander for delay time list */ - } - } -#endif - -#if CFG_TMR_EN > 0 - if(TmrList != NULL) /* Have timer in working? */ - { - if(TmrList->tmrCnt > 1) /* Timer time > 1? */ - { - TmrList->tmrCnt--; /* Decrease timer time of the list head. */ - } - else - { - TmrList->tmrCnt = 0; - isr_TmrDispose(); /* Call hander for timer list */ - } - } -#endif - TaskSchedReq = TRUE; - OsSchedUnlock(); -} diff --git a/GD32F1/libraries/MapleCoOS/utility/OsArch.h b/GD32F1/libraries/MapleCoOS/utility/OsArch.h deleted file mode 100644 index 0fef3d9..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsArch.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - ******************************************************************************* - * @file cpu.h - * @version V1.12 - * @date 2010.03.01 - * @brief Implement function declare related to Cortex-M3(ARM-v7) - * @details This header file including functions or defines related to - * Cortex-M3(ARM-v7). - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _CPU_H -#define _CPU_H - - -#define NVIC_ST_CTRL (*((volatile U32 *)0xE000E010)) -#define NVIC_ST_RELOAD (*((volatile U32 *)0xE000E014)) -#define RELOAD_VAL ((U32)(( (U32)CFG_CPU_FREQ) / (U32)CFG_SYSTICK_FREQ) -1) - -/*!< Initial System tick. */ -#define InitSysTick() -// NVIC_ST_RELOAD = RELOAD_VAL; \ -// NVIC_ST_CTRL = 0x0007 - -#define NVIC_SYS_PRI2 (*((volatile U32 *)0xE000ED1C)) -#define NVIC_SYS_PRI3 (*((volatile U32 *)0xE000ED20)) - -/*!< Initialize PendSV,SVC and SysTick interrupt priority to lowest. */ -#define InitInt() NVIC_SYS_PRI2 |= 0xFF000000;\ - NVIC_SYS_PRI3 |= 0xFFFF0000 - -/*---------------------------- Variable declare ------------------------------*/ -extern U64 OSTickCnt; /*!< Counter for current system ticks. */ - -/*!< Initial context of task being created */ -extern OS_STK *InitTaskContext(FUNCPtr task,void *param,OS_STK *pstk); -extern void SwitchContext(void); /*!< Switch context */ -extern void SetEnvironment(OS_STK *pstk);/*!< Set environment for run */ -extern U8 Inc8 (U8 *data); -extern U8 Dec8 (U8 *data); - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsConfig.h b/GD32F1/libraries/MapleCoOS/utility/OsConfig.h deleted file mode 100644 index f6d8e1a..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsConfig.h +++ /dev/null @@ -1,276 +0,0 @@ -/** - ******************************************************************************* - * @file config.h - * @version V1.12 - * @date 2010.03.01 - * @brief This file use by user to configuration CooCox CoOS. - * @note Ensure you have knew every item before modify this file. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _CONFIG_H -#define _CONFIG_H - - -/*!< -Defines chip type,cortex-m3(1),cortex-m0(2) -*/ -#define CFG_CHIP_TYPE (1) - -/*!< -Defines the lowest priority that be assigned. -*/ -#define CFG_LOWEST_PRIO (64) - -/*!< -Max number of tasks that can be running. -*/ -#define CFG_MAX_USER_TASKS (10) - -/*!< -Idle task stack size(word). -*/ -#define CFG_IDLE_STACK_SIZE (50) - -/*!< -System frequency (Hz). -*/ -#define CFG_CPU_FREQ (F_CPU) - -/*!< -systick frequency (Hz). -*/ -#define CFG_SYSTICK_FREQ (1000) - -/*!< -max systerm api call num in ISR. -*/ -#define CFG_MAX_SERVICE_REQUEST (5) - -/*!< -Enable(1) or disable(0) order list schedule. -If disable(0),CoOS use Binary-Scheduling Algorithm. -*/ -#if (CFG_MAX_USER_TASKS) <15 - #define CFG_ORDER_LIST_SCHEDULE_EN (1) -#else - #define CFG_ORDER_LIST_SCHEDULE_EN (0) -#endif - - -/*!< -Enable(1) or disable(0) Round-Robin Task switching. -*/ -#define CFG_ROBIN_EN (1) - -/*!< -Default slice of task. -*/ -#if CFG_ROBIN_EN > 0 -#define CFG_TIME_SLICE (10) -#endif - - -/*----------------------- Schedule model Config -----------------------------*/ -/*!< -Enable(1) or disable(0) all waiting function. -Include sem, mailbox, queue, flag, mutex, delay modules. -If CFG_TASK_WAITTING_EN=0,all these modules are disable. -*/ -#define CFG_TASK_WAITTING_EN (1) - -/*!< -Dynamic task scheduling(1) or Static Task Scheduling(0) model. -If in Static Task Scheduling model(0),cannot creat task and change task priority -after coocox os start running. In Dynamic Task Scheduling model(1), all these can. -When task terminated, if in Static Task Scheduling model(0), -CoOS do not recovered task resources, and you can activate it again. -But in Dynamic Task Scheduling model(1),task resources will be recovered. -If in Static Task Scheduling model(0),mutex module can not be used, as this model don't -support to change task priority while CoOS running. -*/ -#define CFG_TASK_SCHEDULE_EN (1) - - -/*---------------------- Task Management Config -----------------------------*/ -/*!< -Enable(1) or disable(0) CoSetPriority() API. -*/ -#if CFG_TASK_SCHEDULE_EN >0 -#define CFG_PRIORITY_SET_EN (1) -#endif - -/*!< -Enable(1) or disable(0) CoAwakeTask() and CoSuspendTask() API. -*/ -#define CFG_TASK_SUSPEND_EN (1) - - -/*---------------------- Debug Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) parameter checkout . -*/ -#define CFG_PAR_CHECKOUT_EN (1) - -/*!< -Enable(1) or disable(0) stack overflow checkout . -*/ -#define CFG_STK_CHECKOUT_EN (1) - - - -/*---------------------- Memory Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) memory management. -*/ -#define CFG_MM_EN (1) - -/*!< -Max number of memory.(must be less than 32). -*/ -#if CFG_MM_EN >0 -#define CFG_MAX_MM (2) -#endif - - - -/*-------------------- Kernel heap Management Config -------------------------*/ -/*!< -Enable(1) or disable(0) kernel heap management. -*/ -#define CFG_KHEAP_EN (1) - -/*!< -Kernel heap size(word). -*/ -#if CFG_KHEAP_EN >0 -#define KHEAP_SIZE (50) -#endif - - - -/*---------------------- Time Management Config -----------------------------*/ -/*!< -Enable(1) or disable(0) TimeDelay() API. -*/ -#if CFG_TASK_WAITTING_EN >0 -#define CFG_TIME_DELAY_EN (1) -#endif - - -/*---------------------- Timer Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) timer management. -*/ -#define CFG_TMR_EN (1) - -/*!< -Specify max number timer.(must be less than 32) -*/ -#if CFG_TMR_EN >0 -#define CFG_MAX_TMR (2) -#endif - - -/*---------------------- Event Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) events management, -events including semaphore,mailbox,queue. -*/ -#if CFG_TASK_WAITTING_EN > 0 -#define CFG_EVENT_EN (1) -#endif - -#if CFG_EVENT_EN > 0 -/*!< -Event sort type.(1)FIFO (2)PRI (3)FIFO+PRI -*/ -#define CFG_EVENT_SORT (3) - -/*!< -Max number of event.(must be less than 255) -Event = semaphore + mailbox + queue; -*/ -#define CFG_MAX_EVENT (20) - -/*!< -Enable(1) or disable(0) semaphore management. -*/ -#define CFG_SEM_EN (1) - -/*!< -Enable(1) or disable(0) mailbox management. -*/ -#define CFG_MAILBOX_EN (1) - -/*!< -Enable(1) or disable(0) queue management. -*/ -#define CFG_QUEUE_EN (1) - -/*!< -Max number of queue.(less than CFG_MAX_EVENT). -*/ -#if CFG_QUEUE_EN >0 -#define CFG_MAX_QUEUE (2) -#endif // CFG_QUEUE_EN - -#endif // CFG_EVENT_EN - - - -/*----------------------- Flag Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) flag management. -Max number of flag is 32. -*/ -#if CFG_TASK_WAITTING_EN > 0 -#define CFG_FLAG_EN (1) -#endif - - -/*---------------------- Mutex Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) mutex management. -*/ -#if CFG_TASK_WAITTING_EN > 0 -#if CFG_TASK_SCHEDULE_EN > 0 -#define CFG_MUTEX_EN (1) -#endif -#endif - - -/*!< -Max number of mutex.(must be less than 255). -*/ -#if CFG_MUTEX_EN >0 -#define CFG_MAX_MUTEX (10) -#endif - -/*---------------------- Utility Management Config --------------------------*/ -/*!< -Enable(1) or disable(0) utility management. -*/ -#define CFG_UTILITY_EN (1) - -#if CFG_UTILITY_EN >0 - -/*!< -Enable(1) or disable(0) TickToTime() utility -*/ -#define CFG_TICK_TO_TIME_EN (1) -/*!< -Enable(1) or disable(0) TimeToTick() utility -*/ -#define CFG_TIME_TO_TICK_EN (1) -#endif - - -#endif // _CONFIG_H diff --git a/GD32F1/libraries/MapleCoOS/utility/OsCore.c b/GD32F1/libraries/MapleCoOS/utility/OsCore.c deleted file mode 100644 index 7605609..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsCore.c +++ /dev/null @@ -1,242 +0,0 @@ -/** - ******************************************************************************* - * @file core.c - * @version V1.12 - * @date 2010.03.01 - * @brief Core implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include - - -/*---------------------------- Variable Define -------------------------------*/ -U8 OSIntNesting = 0; /*!< Use to indicate interrupt nesting level*/ -U8 OSSchedLock = 0; /*!< Task Switch lock. */ -BOOL TaskSchedReq = FALSE; - - -/** - ******************************************************************************* - * @brief Enter a ISR. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to notify OS when enter to an ISR. - * - * @note When you call API in ISR,you must call CoEnterISR() before your - * interrupt handler code,and call CoExitISR() after your handler - * code and before exiting from ISR. - ******************************************************************************* - */ -void CoEnterISR(void) -{ - Inc8(&OSIntNesting); /* OSIntNesting increment */ -} - - -/** - ******************************************************************************* - * @brief Exit a ISR. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called when exit from a ISR. - * - * @note - ******************************************************************************* - */ -void CoExitISR(void) -{ - Dec8(&OSIntNesting); /* OSIntNesting decrease */ - if( OSIntNesting == 0) /* Is OSIntNesting == 0? */ - { - if(TaskSchedReq == TRUE) - { - OSSchedLock++; - Schedule(); /* Call task schedule */ - OSSchedLock--; - } - } -} - - - -/** - ******************************************************************************* - * @brief Unlock schedule - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to unlock schedule(i.e.enable schedule again) - * - * @note - ******************************************************************************* - */ -void OsSchedUnlock(void) -{ - if(OSSchedLock == 1) /* Is OSSchedLock == 0? */ - { -#if CFG_TASK_WAITTING_EN > 0 - if(IsrReq == TRUE) - { - RespondSRQ(); /* Respond service request */ - } -#endif - /* Judge task state change or higher PRI task coming in */ - if(TaskSchedReq == TRUE) - { - Schedule(); /* Call task schedule */ - } - OSSchedLock = 0; - } - else - { - OSSchedLock--; - } -} - - -/** - ******************************************************************************* - * @brief Lock schedule - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in application code to lock schedule. - * - * @note - ******************************************************************************* - */ -void CoSchedLock(void) -{ - OsSchedLock(); /* Lock schedule */ -} - - -/** - ******************************************************************************* - * @brief Unlock schedule - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in APP to unlock schedule. - * - * @note - ******************************************************************************* - */ -void CoSchedUnlock(void) -{ - OsSchedUnlock(); /* Unlock schedule */ -} - - -/** - ******************************************************************************* - * @brief Initialize OS - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to initialize OS. - * - * @note You must call this function first,before any other OS API function - * - * @code There is a example for useage of this function,as follows: - * e.g. - * ... // Your target initial code. - * - * OsInit(); // Initial OS. - * CreateTask(...); // Create tasks. - * ... - * OsStart(); // Start multitask. - * @endcode - ******************************************************************************* - */ -void CoInitOS(void) -{ - InitSysTick(); /* Initialize system tick. */ - InitInt(); /* Initialize PendSV,SVC,SysTick interrupt */ - - systick_attach_callback(&CoSysTick_Handler); - - CreateTCBList(); /* Create TCB list. */ -#if CFG_EVENT_EN > 0 - CreateEventList(); /* Create event control list. */ -#endif -#if CFG_KHEAP_EN > 0 - CoCreateKheap(); /* Create kernel heap within user define */ -#endif - OsSchedLock(); /* Lock Schedule */ - /* Create first task -- IDLE task. */ - CoCreateTask( CoIdleTask, - NULL, - CFG_LOWEST_PRIO, - &idle_stk[CFG_IDLE_STACK_SIZE-1], - CFG_IDLE_STACK_SIZE - ); - /* Set PSP for CoIdleTask coming in */ - SetEnvironment(&idle_stk[CFG_IDLE_STACK_SIZE-1]); -} - - -/** - ******************************************************************************* - * @brief Start multitask - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to start multitask.After it is called, - * OS start schedule task by priority or/and time slice. - * @note This function must be called to start OS when you use CoOS,and must - * call after CoOsInit(). - ******************************************************************************* - */ -void CoStartOS(void) -{ - TCBRunning = &TCBTbl[0]; /* Get running task */ - TCBNext = TCBRunning; /* Set next scheduled task as running task */ - TCBRunning->state = TASK_RUNNING; /* Set running task status to RUNNING */ - RemoveFromTCBRdyList(TCBRunning); /* Remove running task from READY list */ - OsSchedUnlock(); /* Enable Schedule,call task schedule */ -} - - -/** - ******************************************************************************* - * @brief Get OS version - * @param[in] None - * @param[out] None - * @retval The value is version of OS mutipled by 100. - * - * @par Description - * @details This function is used to return the version number of CooCox OS. - * the return value corresponds to CooCox's version number multiplied - * by 100. In other words, version 1.02 would be returned as 102. - ******************************************************************************* - */ -OS_VER CoGetOSVersion(void) -{ - return OS_VERSION; /* Get CooCox CoOS version */ -} - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsCore.h b/GD32F1/libraries/MapleCoOS/utility/OsCore.h deleted file mode 100644 index 2d39342..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsCore.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - ******************************************************************************* - * @file core.h - * @version V1.12 - * @date 2010.03.01 - * @brief Header file related to kernel - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _CORE_H -#define _CORE_H - -#include - - -#define OsSchedLock() OSSchedLock++; /*!< Lock schedule */ -extern void OsSchedUnlock(void); - -extern void CoSysTick_Handler(void); - -#endif - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsError.h b/GD32F1/libraries/MapleCoOS/utility/OsError.h deleted file mode 100644 index 88b67ae..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsError.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - ******************************************************************************* - * @file error.h - * @version V1.12 - * @date 2010.03.01 - * @brief rror dispose header file - * @details This file use to dispose error which from error configure for OS. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _ERROR_H -#define _ERROR_H - -#if (CFG_SYSTICK_FREQ > 1000) ||(CFG_SYSTICK_FREQ < 1) - #error " OsConfig.h System Tick time must between 1ms and 1s!" -#endif - -#if CFG_MAX_USER_TASKS > 253 - #error " OsConfig.h, CFG_MAX_USER_TASKS must be <= 253! " -#endif - -#if CFG_LOWEST_PRIO > 254 - #error " OsConfig.h, CFG_LOWEST_PRIO must be <= 254! " -#endif - -#if CFG_IDLE_STACK_SIZE <25 - #error " OsConfig.h, CFG_IDLE_STACK_SIZE must be >= 25! " -#endif - - -#if CFG_ROBIN_EN > 0 - #if CFG_TIME_SLICE > 4095 - #error " OsConfig.h, CFG_TIME_SLICE must be <= 4095! " - #endif -#endif - -#if CFG_TMR_EN > 0 - #if CFG_MAX_TMR > 32 - #error " OsConfig.h, CFG_MAX_TMR must be <= 32! " - #endif -#endif - - -#if CFG_MM_EN > 0 - #if CFG_MAX_MM > 32 - #error " config.h, CFG_MAX_MM must be <= 32! " - #endif -#endif - - -#if CFG_KHEAP_EN > 0 - #if KHEAP_SIZE < 0x20 - #error " config.h, CFG_MAX_MM must be >= 0x20! " - #endif -#endif - -#if CFG_MUTEX_EN > 0 - #if CFG_MAX_MUTEX > 254 - #error " config.h, CFG_MAX_MUTEX must be <= 254! " - #endif -#endif - - -#if CFG_EVENT_EN > 0 - #if (CFG_MAX_EVENT > 254 || CFG_MAX_EVENT <= 0) - #error " config.h, CFG_MAX_EVENT must be <= 254 && > 0! " - #endif - - - #if CFG_QUEUE_EN > 0 - #if CFG_MAX_QUEUE > CFG_MAX_EVENT - #error " config.h, CFG_MAX_QUEUE must be <= CFG_MAX_EVENT! " - #endif - #endif -#endif /* CFG_EVENT_EN */ - -#endif /* _ERROR_H */ diff --git a/GD32F1/libraries/MapleCoOS/utility/OsEvent.c b/GD32F1/libraries/MapleCoOS/utility/OsEvent.c deleted file mode 100644 index 51f4a27..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsEvent.c +++ /dev/null @@ -1,410 +0,0 @@ -/** - ******************************************************************************* - * @file event.c - * @version V1.12 - * @date 2010.03.01 - * @brief event management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - - -/*---------------------------- Variable Define -------------------------------*/ -#if CFG_EVENT_EN > 0 - -ECB EventTbl[CFG_MAX_EVENT]= {{0}};/*!< Table which save event control block.*/ -P_ECB FreeEventList = NULL; /*!< Pointer to free event control block. */ - - -/** - ******************************************************************************* - * @brief Create a empty list of event control block - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called by OSInit() API to create a ECB list,supply - * a pointer to next event control block that not used. - ******************************************************************************* - */ -void CreateEventList(void) -{ - U8 i; - P_ECB pecb1; -#if CFG_MAX_EVENT > 1 - P_ECB pecb2; -#endif - i=0; - pecb1 = &EventTbl[0]; /* Get first item */ -#if CFG_MAX_EVENT == 1 /* Build event list for only one item */ - pecb1->eventPtr = NULL; - pecb1->id = i; /* Assign ID. */ - pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */ -#endif - -#if CFG_MAX_EVENT > 1 /* Build event list for more than one item */ - pecb2 = &EventTbl[1]; - for(;i< (CFG_MAX_EVENT-1);i++ ) - { - pecb1->eventPtr = (void*)pecb2; /* Set link for list */ - pecb1->id = i; /* Assign ID. */ - pecb1->eventType = EVENT_TYPE_INVALID;/* Sign that not to use. */ - pecb1++; /* Get next item */ - pecb2++; - } - pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */ - pecb1->eventPtr = NULL; /* Set link for last item */ - pecb1->id = i; -#endif - - FreeEventList = &EventTbl[0]; /* Set free event item */ -} - - - -/** - ******************************************************************************* - * @brief Release a ECB - * @param[in] pecb A pointer to event control block which be released. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to release a event control block when a - * event be deleted. - ******************************************************************************* - */ -static void ReleaseECB(P_ECB pecb) -{ - pecb->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */ - OsSchedLock(); /* Lock schedule */ - pecb->eventPtr = FreeEventList; /* Release ECB that event hold */ - FreeEventList = pecb; /* Reset free event item */ - OsSchedUnlock(); /* Unlock schedule */ -} - - - -/** - ******************************************************************************* - * @brief Create a event - * @param[in] eventType The type of event which being created. - * @param[in] eventSortType Event sort type. - * @param[in] eventCounter Event counter,ONLY for EVENT_TYPE_SEM. - * @param[in] eventPtr Event struct pointer,ONLY for Queue.NULL for other - * event type. - * @param[out] None - * @retval NULL Invalid pointer,create event fail. - * @retval others Pointer to event control block which had assigned right now. - * - * @par Description - * @details This function is called by CreateSem(),... - * to get a event control block and initial the event content. - * - * @note This is a internal function of CooCox CoOS,User can't call. - ******************************************************************************* - */ -P_ECB CreatEvent(U8 eventType,U8 eventSortType,void* eventPtr) -{ - P_ECB pecb; - - OsSchedLock(); /* Lock schedule */ - if(FreeEventList == NULL) /* Is there no free evnet item */ - { - OsSchedUnlock(); /* Yes,unlock schedule */ - return NULL; /* Return error */ - } - pecb = FreeEventList;/* Assign the free event item to this event */ - FreeEventList = FreeEventList->eventPtr; /* Reset free event item */ - OsSchedUnlock(); /* Unlock schedul */ - - pecb->eventType = eventType; /* Initialize event item as user set */ - pecb->eventSortType = eventSortType; - pecb->eventPtr = eventPtr; - pecb->eventTCBList = NULL; - return pecb; /* Return event item pointer */ -} - - -/** - ******************************************************************************* - * @brief Delete a event - * @param[in] pecb Pointer to event control block which will be deleted. - * @param[in] opt Delete option. - * @arg == OPT_DEL_ANYWAY Delete event always - * @arg == OPT_DEL_NO_PEND Delete event only when no task pending on. - * @param[out] None - * @retval E_INVALID_PARAMETER Parameter passed is invalid,deleted fail. - * @retval E_TASK_WAITTING These are one more tasks waitting event. - * @retval E_OK Delete event control block successful. - * - * @par Description - * @details This function is called to delete a event from the event wait list - * use specify option. - * - * @note This is a internal function of Coocox CoOS,user can't call. - ******************************************************************************* - */ -StatusType DeleteEvent(P_ECB pecb,U8 opt) -{ - P_OSTCB ptcb; - if(opt == OPT_DEL_NO_PEND) /* Do delete event when no task pend? */ - { - if(pecb->eventTCBList != NULL) /* Yes,is there task pend this event? */ - { - return E_TASK_WAITING; /* Yes,error return */ - } - else - { - ReleaseECB(pecb); /* No,release resource that event hold*/ - } - } - else if(opt == OPT_DEL_ANYWAY) /* Do delete event anyway? */ - { - OsSchedLock(); /* Lock schedule */ - while(pecb->eventTCBList != NULL) /* Is there task pend this event? */ - { /* Yes,remove it */ - ptcb = pecb->eventTCBList;/* Get first task in event waiting list */ - if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */ - { - RemoveDelayList(ptcb); /* Yes,remove task from delay list */ - } - - /* Set next item as event waiting list head */ - pecb->eventTCBList = ptcb->waitNext; - ptcb->waitNext = NULL; /* Clear link for event waiting list */ - ptcb->eventID = INVALID_ID; /* Sign that not to use. */ - - InsertToTCBRdyList(ptcb); /* Insert task into ready list */ - } - OsSchedUnlock(); /* Unlock schedule */ - ReleaseECB(pecb); /* Release resource that event hold */ - } - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Insert a task to event wait list - * @param[in] pecb Pointer to event control block corresponding to the event. - * @param[in] ptcb Pointer to task that will be insert to event wait list. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to insert a task by fllowing manner: - * opt == EVENT_SORT_TYPE_FIFO By FIFO. - * opt == EVENT_SORT_TYPE_PRIO By priority order,hghest priority - * as head,lowest priority as end. - * (Highest-->...-->Lowest-->NULL) - ******************************************************************************* - */ -void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb) -{ - P_OSTCB ptcb1; -#if (CFG_EVENT_SORT == 2) || (CFG_EVENT_SORT == 3) - P_OSTCB ptcb2; -#endif - - OsSchedLock(); /* Lock schedule */ - ptcb1 = pecb->eventTCBList; /* Get first task in event waiting list */ - ptcb->eventID = pecb->id; /* Set event ID for task */ - -#if CFG_EVENT_SORT == 3 /* Does event waiting list sort as FIFO? */ - - if(pecb->eventSortType == EVENT_SORT_TYPE_FIFO) -#endif - -#if (CFG_EVENT_SORT == 1) || (CFG_EVENT_SORT == 3) - { - if(ptcb1 == NULL) /* Is no item in event waiting list?*/ - { - pecb->eventTCBList = ptcb; /* Yes,set task as first item */ - } - else - { - while(ptcb1->waitNext != NULL)/* No,insert task in last */ - { - ptcb1 = ptcb1->waitNext; - } - ptcb1->waitNext = ptcb; /* Set link for list */ - ptcb->waitPrev = ptcb1; - } - } -#endif - -#if CFG_EVENT_SORT ==3 /* Does event waiting list sort as preemptive priority?*/ - else if(pecb->eventSortType == EVENT_SORT_TYPE_PRIO) -#endif -#if (CFG_EVENT_SORT == 2) || (CFG_EVENT_SORT == 3) - { - if(ptcb1 == NULL) /* Is no item in event waiting list? */ - { - pecb->eventTCBList = ptcb; /* Yes,set task as first item */ - } - /* Is PRI of task higher than list first item? */ - else if(ptcb1->prio > ptcb->prio) - { - pecb->eventTCBList = ptcb; /* Reset task as first item */ - ptcb->waitNext = ptcb1; /* Set link for list */ - ptcb1->waitPrev = ptcb; - } - else /* No,find correct place to insert */ - { - ptcb2 = ptcb1->waitNext; - while(ptcb2 != NULL) /* Is last item? */ - { - if(ptcb2->prio > ptcb->prio) /* No,is correct place? */ - { - break; /* Yes,break Circulation */ - } - ptcb1 = ptcb2; /* Save current item */ - ptcb2 = ptcb2->waitNext; /* Get next item */ - } - ptcb1->waitNext = ptcb; /* Set link for list */ - ptcb->waitPrev = ptcb1; - ptcb->waitNext = ptcb2; - if(ptcb2 != NULL) - { - ptcb2->waitPrev = ptcb; - } - } - } -#endif - ptcb->state = TASK_WAITING; /* Set task status to TASK_WAITING state */ - TaskSchedReq = TRUE; - OsSchedUnlock(); /* Unlock schedule,and call task schedule */ -} - - -/** - ******************************************************************************* - * @brief Move a task from event WAITING list to the DELAY list - * @param[in] pecb Pointer to event control block corresponding to the event. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a task from event wait list,and - * then insert it into the READY list. - ******************************************************************************* - */ -void EventTaskToRdy(P_ECB pecb) -{ - P_OSTCB ptcb; -#if CFG_QUEUE_EN >0 - P_QCB pqcb; -#endif - ptcb = pecb->eventTCBList; - if(ptcb == NULL) - return; - - pecb->eventTCBList = ptcb->waitNext;/* Get first task in event waiting list*/ - if(pecb->eventTCBList != NULL) /* Is no item in event waiting list? */ - { - pecb->eventTCBList->waitPrev = NULL; /* No,clear link for first item */ - } - - ptcb->waitNext = NULL; /* Clear event waiting link for task*/ - ptcb->eventID = INVALID_ID; /* Sign that not to use. */ - - if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */ - { - RemoveDelayList(ptcb); /* Yes,remove task from DELAY list */ - } - if(pecb->eventType == EVENT_TYPE_MBOX)/* Is it a mailbox event? */ - { - ptcb->pmail = pecb->eventPtr; /* Yes,send mail to task */ - pecb->eventPtr = NULL; /* Clear event sign */ - pecb->eventCounter--; - } -#if CFG_QUEUE_EN >0 - else if(pecb->eventType == EVENT_TYPE_QUEUE) /* Is it a queue event? */ - { - pqcb = (P_QCB)pecb->eventPtr; /* Yes,get queue pointer */ - ptcb->pmail = *(pqcb->qStart + pqcb->head); /* Send mail to task */ - pqcb->head++; /* Clear event sign */ - pqcb->qSize--; - if(pqcb->head == pqcb->qMaxSize) - { - pqcb->head = 0; - } - } -#endif - -#if CFG_MAILBOX_EN >0 - else if(pecb->eventType == EVENT_TYPE_SEM)/* Is it a semaphore event? */ - { - pecb->eventCounter--; /* Yes,clear event sign */ - ptcb->pmail = (void*)0xffffffff; /* Indicate task woke by event */ - } -#endif - if(ptcb == TCBRunning) - { - ptcb->state = TASK_RUNNING; - } - else - { - InsertToTCBRdyList(ptcb); /* Insert task into ready list */ - } -} - - - -/** - ******************************************************************************* - * @brief Move a task from event wait list to the ready list - * @param[in] pecb Pointer to event control block corresponding to the event. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a task from event wait list,and - * then insert it to the ready list. - ******************************************************************************* - */ -void RemoveEventWaittingList(P_OSTCB ptcb) -{ - P_ECB pecb; - pecb = &EventTbl[ptcb->eventID]; /* Get event control block */ - - /* Is there only one item in event waiting list? */ - if((ptcb->waitNext == NULL) && (ptcb->waitPrev == NULL)) - { - pecb->eventTCBList = NULL; /* Yes,set event waiting list as NULL */ - } - else if(ptcb->waitPrev == NULL)/* Is the first item in event waiting list?*/ - { - /* Yes,remove task from list,and reset event waiting list */ - ptcb->waitNext->waitPrev = NULL; - pecb->eventTCBList = ptcb->waitNext; - ptcb->waitNext = NULL; - } - else if(ptcb->waitNext == NULL)/* Is the last item in event waiting list? */ - { - ptcb->waitPrev->waitNext = NULL; /* Yes,remove task form list */ - ptcb->waitPrev = NULL; - } - else /* No, remove task from list */ - { - ptcb->waitPrev->waitNext = ptcb->waitNext; - ptcb->waitNext->waitPrev = ptcb->waitPrev; - ptcb->waitPrev = NULL; - ptcb->waitNext = NULL; - } - ptcb->eventID = INVALID_ID; /* Sign that not to use. */ -} - -#endif //CFG_EVENT_EN - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsEvent.h b/GD32F1/libraries/MapleCoOS/utility/OsEvent.h deleted file mode 100644 index bdb5e1d..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsEvent.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - ******************************************************************************* - * @file event.h - * @version V1.12 - * @date 2010.03.01 - * @brief Event management header file - * @details This file including some defines and declares related to event - * (semaphore,mailbox,queque) management. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _EVENT_H -#define _EVENT_H - -#define EVENT_TYPE_SEM (U8)0x01 /*!< Event type:Semaphore. */ -#define EVENT_TYPE_MBOX (U8)0x02 /*!< Event type:Mailbox. */ -#define EVENT_TYPE_QUEUE (U8)0x03 /*!< Event type:Queue. */ -#define EVENT_TYPE_INVALID (U8)0x04 /*!< Invalid event type. */ - - -/** - * @struct EventCtrBlk event.h - * @brief Event control block - * @details This struct is use to manage event, - * e.g. semaphore,mailbox,queue. - */ -typedef struct EventCtrBlk -{ - void* eventPtr; /*!< Point to mailbox or queue struct */ - U8 id; /*!< ECB id */ - U8 eventType:4; /*!< Type of event */ - U8 eventSortType:4; /*!< 0:FIFO 1: Preemptive by prio */ - U16 eventCounter; /*!< Counter of semaphore. */ - U16 initialEventCounter; /*!< Initial counter of semaphore. */ - P_OSTCB eventTCBList; /*!< Task waitting list. */ -}ECB,*P_ECB; - -/*---------------------------- Variable declare ------------------------------*/ -extern ECB EventTbl[CFG_MAX_EVENT]; /*!< Table use to save TCB. */ - -/*---------------------------- Function declare ------------------------------*/ -/*!< Create a event */ -extern P_ECB CreatEvent(U8 eventType,U8 eventSortType,void* eventPtr); - -/*!< Remove a task from wait list */ -extern void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb); -extern StatusType DeleteEvent(P_ECB pecb,U8 opt); /*!< Delete a event. */ -extern void EventTaskToRdy(P_ECB pecb); /*!< Insert a task to ready list*/ -extern void CreateEventList(void); /*!< Create a event list. */ -extern void RemoveEventWaittingList(P_OSTCB ptcb); -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsFlag.c b/GD32F1/libraries/MapleCoOS/utility/OsFlag.c deleted file mode 100644 index 0d42cd4..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsFlag.c +++ /dev/null @@ -1,712 +0,0 @@ -/** - ******************************************************************************* - * @file flag.c - * @version V1.12 - * @date 2010.03.01 - * @brief Flag management implementation code of coocox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if CFG_FLAG_EN > 0 -/*---------------------------- Variable Define -------------------------------*/ -#define FLAG_MAX_NUM 32 /*!< Define max flag number. */ -FCB FlagCrl = {0}; /*!< Flags list struct */ - - -/*---------------------------- Function Declare ------------------------------*/ -static void FlagBlock(P_FLAG_NODE pnode,U32 flags,U8 waitType); -static P_FLAG_NODE RemoveFromLink(P_FLAG_NODE pnode); - -/** - ******************************************************************************* - * @brief Create a flag - * @param[in] bAutoReset Reset mode,TRUE(Auto Reset) FLASE(Manual Reset). - * @param[in] bInitialState Initial state. - * @param[out] None - * @retval E_CREATE_FAIL Create flag fail. - * @retval others Create flag successful. - * - * @par Description - * @details This function use to create a event flag. - * @note - ******************************************************************************* - */ -OS_FlagID CoCreateFlag(BOOL bAutoReset,BOOL bInitialState) -{ - U8 i; - OsSchedLock(); - - for(i=0;i 0) /* If be called from ISR */ - { - return E_CALL; - } -#if CFG_PAR_CHECKOUT_EN >0 - if((pfcb->flagActive&(1<headNode; - - while(pnode != NULL) /* Ready all tasks waiting for flags */ - { - if((pnode->waitFlags&(1<waitType == OPT_WAIT_ALL) - { - /* If the flag is only required by NODE */ - if( pnode->waitFlags == (1<waitFlags &= ~(1<nextNode; - } - - /* Remove the flag from the flags list */ - pfcb->flagActive &= ~(1<flagRdy &= ~(1<resetOpt &= ~(1<0 - if(id >= FLAG_MAX_NUM) - { - return E_INVALID_ID; /* Invalid 'id',return error */ - } - if((pfcb->flagActive&(1<flagRdy&(1<flagRdy &= ~((FlagCrl.resetOpt)&(1<0 - if((flags&pfcb->flagActive) != flags ) /* Judge flag is active or not? */ - { - *perr = E_INVALID_PARAMETER; /* Invalid flags */ - return 0; - } -#endif - - springFlag = flags & pfcb->flagRdy; - - OsSchedLock(); - /* If any required flags are set */ - if( (springFlag != 0) && (waitType == OPT_WAIT_ANY) ) - { - - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt); /* Clear the flags */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - - /* If all required flags are set */ - if((springFlag == flags) && (waitType == OPT_WAIT_ALL)) - { - pfcb->flagRdy &= ~(springFlag&pfcb->resetOpt); /* Clear the flags */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - OsSchedUnlock(); - *perr = E_FLAG_NOT_READY; - return 0; -} - - - - -/** - ******************************************************************************* - * @brief WaitForSingleFlag - * @param[in] id Flag ID. - * @param[in] timeout The longest time for writting flag. - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_INVALID_ID Invalid event ID. - * @retval E_TIMEOUT Flag wasn't received within 'timeout' time. - * @retval E_OK The call was successful and your task owns the Flag, - * or the event you are waiting for occurred. - * - * @par Description - * @details This function is called to wait for only one flag, - * (1) if parameter "timeout" == 0,waiting until flag be set; - * (2) when "timeout" != 0,if flag was set or wasn't set but timeout - * occured,the task will exit the waiting list,convert to READY - * or RUNNING state. - * @note - ******************************************************************************* - */ -StatusType CoWaitForSingleFlag(OS_FlagID id,U32 timeout) -{ - FLAG_NODE flagNode; - P_FCB pfcb; - P_OSTCB curTCB; - - if(OSIntNesting > 0) /* See if the caller is ISR */ - { - return E_CALL; - } - if(OSSchedLock != 0) /* Schedule is lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= FLAG_MAX_NUM) /* Judge id is valid or not? */ - { - return E_INVALID_ID; /* Invalid 'id' */ - } - if((FlagCrl.flagActive&(1<flagRdy&(1<flagRdy &= ~((pfcb->resetOpt&(1<state = TASK_WAITING; - TaskSchedReq = TRUE; - OsSchedUnlock(); - - /* The required flag is set and the task is in running state */ - curTCB->pnode = NULL; - OsSchedLock(); - - /* Clear the required flag or not */ - pfcb->flagRdy &= ~((1<resetOpt)); - OsSchedUnlock(); - } - else /* If time-out is configured */ - { - /* Block task until the required flag is set or time-out occurs */ - FlagBlock(&flagNode,(1<pnode == NULL) /* If time-out occurred */ - { - return E_TIMEOUT; - } - else /* If flag is set */ - { - curTCB->pnode = NULL; - OsSchedLock(); - - /* Clear the required flag or not */ - pfcb->flagRdy &= ~((1<resetOpt)); - OsSchedUnlock(); - } - } - } - return E_OK; -} - - -/** - ******************************************************************************* - * @brief WaitForMultipleFlags - * @param[in] flags Flags that waiting to active task. - * @param[in] waitType Flags wait type. - * @param[in] timeout The longest time for writting flag. - * @param[out] perr A pointer to error code. - * @retval 0 - * @retval springFlag - * - * @par Description - * @details This function is called to pend a task for waitting multiple flag. - * @note - ******************************************************************************* - */ -U32 CoWaitForMultipleFlags(U32 flags,U8 waitType,U32 timeout,StatusType *perr) -{ - U32 springFlag; - P_FCB pfcb; - FLAG_NODE flagNode; - P_OSTCB curTCB; - - - if(OSIntNesting > 0) /* If the caller is ISR */ - { - *perr = E_CALL; - return 0; - } - if(OSSchedLock != 0) /* Schedule is lock? */ - { - *perr = E_OS_IN_LOCK; - return 0; /* Yes,error return */ - } -#if CFG_PAR_CHECKOUT_EN >0 - if( (flags&FlagCrl.flagActive) != flags ) - { - *perr = E_INVALID_PARAMETER; /* Invalid 'flags' */ - return 0; - } -#endif - OsSchedLock(); - pfcb = &FlagCrl; - springFlag = flags & pfcb->flagRdy; - - /* If any required flags are set */ - if((springFlag != 0) && (waitType == OPT_WAIT_ANY)) - { - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt); /* Clear the flag */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - - /* If all required flags are set */ - if( (springFlag == flags) && (waitType == OPT_WAIT_ALL) ) - { - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt); /* Clear the flags */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - - curTCB = TCBRunning; - if(timeout == 0) /* If time-out is not configured */ - { - /* Block task until the required flag are set */ - FlagBlock(&flagNode,flags,waitType); - curTCB->state = TASK_WAITING; - TaskSchedReq = TRUE; - OsSchedUnlock(); - - curTCB->pnode = NULL; - OsSchedLock(); - springFlag = flags & pfcb->flagRdy; - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt);/* Clear the flags */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - else /* If time-out is configured */ - { - /* Block task until the required flag are set or time-out occurred */ - FlagBlock(&flagNode,flags,waitType); - InsertDelayList(curTCB,timeout); - - OsSchedUnlock(); - if(curTCB->pnode == NULL) /* If time-out occurred */ - { - *perr = E_TIMEOUT; - return 0; - } - else /* If the required flags are set */ - { - curTCB->pnode = NULL; - OsSchedLock(); - springFlag = flags & FlagCrl.flagRdy; - - /* Clear the required ready flags or not */ - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt); - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - } -} - - -/** - ******************************************************************************* - * @brief Clear a Flag - * @param[in] id Flag ID. - * @param[out] None - * @retval E_OK Event deleted successful. - * @retval E_INVALID_ID Invalid event ID. - * - * @par Description - * @details This function is called to clear a flag. - * - * @note - ******************************************************************************* - */ -StatusType CoClearFlag(OS_FlagID id) -{ - P_FCB pfcb; - pfcb = &FlagCrl; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= FLAG_MAX_NUM) - { - return E_INVALID_ID; /* Invalid id */ - } - if((pfcb->flagActive&(1<flagRdy &= ~(1<0 - if(id >= FLAG_MAX_NUM) /* Flag is valid or not */ - { - return E_INVALID_ID; /* Invalid flag id */ - } - if((pfcb->flagActive&(1<flagRdy&(1<flagRdy |= (1<headNode; - while(pnode != NULL) - { - if(pnode->waitType == OPT_WAIT_ALL) /* Extract all the bits we want */ - { - if((pnode->waitFlags&pfcb->flagRdy) == pnode->waitFlags) - { - /* Remove the flag node from the wait list */ - pnode = RemoveFromLink(pnode); - if((pfcb->resetOpt&(1<waitFlags & pfcb->flagRdy) != 0) - { - /* Remove the flag node from the wait list */ - pnode = RemoveFromLink(pnode); - if((pfcb->resetOpt&(1<nextNode; - } - OsSchedUnlock(); - return E_OK; -} - - - -/** - ******************************************************************************* - * @brief Set a flag in ISR - * @param[in] id Flag ID. - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_OK Event deleted successful. - * - * @par Description - * @details This function is called in ISR to set a flag. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -StatusType isr_SetFlag(OS_FlagID id) -{ - if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ - { - /* Insert the request into service request queue */ - if(InsertInSRQ(FLAG_REQ,id,NULL) == FALSE) - { - return E_SEV_REQ_FULL; /* The service requst queue is full */ - } - else - { - return E_OK; - } - } - else - { - return(CoSetFlag(id)); /* The caller is not ISR, set the flag*/ - } -} -#endif - -/** - ******************************************************************************* - * @brief Block a task to wait a flag event - * @param[in] pnode A node that will link into flag waiting list. - * @param[in] flags Flag(s) that the node waiting for. - * @param[in] waitType Waiting type of the node. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to block a task to wait a flag event. - * @note - ******************************************************************************* - */ -static void FlagBlock(P_FLAG_NODE pnode,U32 flags,U8 waitType) -{ - P_FCB pfcb; - pfcb = &FlagCrl; - - TCBRunning->pnode = pnode; - pnode->waitTask = TCBRunning; - pnode->waitFlags = flags; /* Save the flags that we need to wait for*/ - pnode->waitType = waitType; /* Save the type of wait */ - - if(pfcb->tailNode == NULL) /* If this is the first NODE to insert? */ - { - pnode->nextNode = NULL; - pnode->prevNode = NULL; - pfcb->headNode = pnode; /* Insert the NODE to the head */ - } - else /* If it is not the first NODE to insert? */ - { - pfcb->tailNode->nextNode = pnode; /* Insert the NODE to the tail */ - pnode->prevNode = pfcb->tailNode; - pnode->nextNode = NULL; - } - pfcb->tailNode = pnode; -} - - -/** - ******************************************************************************* - * @brief Remove a flag node from list - * @param[in] pnode A node that will remove from flag waiting list. - * @param[out] None - * @retval pnode Next node of the node that have removed out. - * - * @par Description - * @details This function is called to remove a flag node from the wait list. - * @note - ******************************************************************************* - */ -static P_FLAG_NODE RemoveFromLink(P_FLAG_NODE pnode) -{ - P_OSTCB ptcb; - - RemoveLinkNode(pnode); /* Remove the flag node from wait list. */ - ptcb = pnode->waitTask; - - /* The task in the delay list */ - if(ptcb->delayTick != INVALID_VALUE)/* If the task is in tick delay list */ - { - RemoveDelayList(ptcb); /* Remove the task from tick delay list */ - } - - ptcb->pnode = (void*)0xffffffff; - - if(ptcb == TCBRunning) - { - ptcb->state = TASK_RUNNING; - } - else - { - InsertToTCBRdyList(ptcb); /* Insert the task to ready list */ - } - return (pnode->nextNode); -} - -/** - ******************************************************************************* - * @brief Remove a flag node from list - * @param[in] pnode A node that will remove from flag waiting list. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a flag node from the wait list. - * @note - ******************************************************************************* - */ -void RemoveLinkNode(P_FLAG_NODE pnode) -{ - /* If only one NODE in the list*/ - if((pnode->nextNode == NULL) && (pnode->prevNode == NULL)) - { - FlagCrl.headNode = NULL; - FlagCrl.tailNode = NULL; - } - else if(pnode->nextNode == NULL) /* If the NODE is tail */ - { - FlagCrl.tailNode = pnode->prevNode; - pnode->prevNode->nextNode = NULL; - } - else if(pnode->prevNode == NULL) /* If the NODE is head */ - { - FlagCrl.headNode = pnode->nextNode; - pnode->nextNode->prevNode = NULL; - } - else /* The NODE is in the middle */ - { - pnode->nextNode->prevNode = pnode->prevNode; - pnode->prevNode->nextNode = pnode->nextNode; - } - pnode->waitTask->pnode = NULL; -} - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsFlag.h b/GD32F1/libraries/MapleCoOS/utility/OsFlag.h deleted file mode 100644 index b990715..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsFlag.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - ******************************************************************************* - * @file flag.h - * @version V1.12 - * @date 2010.03.01 - * @brief Evnet flag management header file - * @details This file including some defines and declares about flag management. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _FLAG_H -#define _FLAG_H - -/** - * @struct FlagNode flag.h - * @brief Flag node struct - * @details - */ -typedef struct FlagNode -{ - struct FlagNode* nextNode; /*!< A pointer to next flag node */ - struct FlagNode* prevNode; /*!< A pointer to prev flag node */ - U32 waitFlags; /*!< Flag value */ - P_OSTCB waitTask; /*!< A pointer to task waitting flag */ - U8 waitType; /*!< Wait type */ -}FLAG_NODE,*P_FLAG_NODE; - - -/** - * @struct Flag flag.h - * @brief Flag control block - * @details This struct use to mange event flag. - */ -typedef struct Flag -{ - U32 flagRdy; /*!< Ready flag */ - U32 resetOpt; /*!< Reset option */ - U32 flagActive; /*!< Active flag */ - P_FLAG_NODE headNode; /*!< Head node */ - P_FLAG_NODE tailNode; /*!< Tail node */ -}FCB,*P_FCB; - - -/*---------------------------- Variable declare ------------------------------*/ -extern FCB FlagCrl; - -/*---------------------------- Function declare ------------------------------*/ -extern void RemoveLinkNode(P_FLAG_NODE pnode); -#endif - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsHook.c b/GD32F1/libraries/MapleCoOS/utility/OsHook.c deleted file mode 100644 index 032c75d..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsHook.c +++ /dev/null @@ -1,65 +0,0 @@ -/** - ******************************************************************************* - * @file hook.c - * @version V1.12 - * @date 2010.03.01 - * @brief hook management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Inlcude --------------------------------------*/ -#include - -/** - ******************************************************************************* - * @brief IDLE task of OS - * @param[in] pdata The parameter passed to IDLE task. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is system IDLE task code. - ******************************************************************************* - */ -void CoIdleTask(void* pdata) -{ - /* Add your codes here */ - for(; ;) - { - /* Add your codes here */ - } -} - - -/** - ******************************************************************************* - * @brief Hook for stack overflow - * @param[in] taskID Piont to the task which lead to stack overflow. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is a hook for stack overflow. - ******************************************************************************* - */ -void CoStkOverflowHook(OS_TID taskID) -{ - /* Process stack overflow here */ - for(; ;) - { - - } -} - - - - - - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsKernelHeap.c b/GD32F1/libraries/MapleCoOS/utility/OsKernelHeap.c deleted file mode 100644 index 4138f35..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsKernelHeap.c +++ /dev/null @@ -1,409 +0,0 @@ -/** - ******************************************************************************* - * @file kernelHeap.c - * @version V1.12 - * @date 2010.03.01 - * @brief kernel heap management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - - -#if CFG_KHEAP_EN >0 -/*---------------------------- Variable Define -------------------------------*/ -U32 KernelHeap[KHEAP_SIZE] = {0}; /*!< Kernel heap */ -P_FMB FMBlist = NULL; /*!< Free memory block list */ -KHeap Kheap = {0}; /*!< Kernel heap control */ - - -/*---------------------------- Function Declare ------------------------------*/ -static P_FMB GetPreFMB(P_UMB usedMB); -/** - ******************************************************************************* - * @brief Create kernel heap - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to create kernel heap. - ******************************************************************************* - */ -void CoCreateKheap(void) -{ - Kheap.startAddr = (U32)(KernelHeap); /* Initialize kernel heap control */ - Kheap.endAddr = (U32)(KernelHeap) + KHEAP_SIZE*4; - FMBlist = (P_FMB)KernelHeap; /* Initialize free memory block list*/ - FMBlist->nextFMB = NULL; - FMBlist->nextUMB = NULL; - FMBlist->preUMB = NULL; -} - - -/** - ******************************************************************************* - * @brief Allocation size bytes of memory block from kernel heap. - * @param[in] size Length of menory block. - * @param[out] None - * @retval NULL Allocate fail. - * @retval others Pointer to memory block. - * - * @par Description - * @details This function is called to allocation size bytes of memory block. - ******************************************************************************* - */ -void* CoKmalloc(U32 size) -{ - P_FMB freeMB,newFMB,preFMB; - P_UMB usedMB,tmpUMB; - U8* memAddr; - U32 freeSize; - U32 kheapAddr; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if( size == 0 ) - { - return NULL; - } -#endif - - /* Word alignment,and add used memory head size */ - size = (((size+3)>>2)<<2) + 8; - kheapAddr = Kheap.endAddr; /* Get the end address of kernel heap */ - OsSchedLock(); /* Lock schedule */ - freeMB = FMBlist; /* Get first item of free memory list */ - preFMB = NULL; - while(freeMB != NULL ) /* Is out of free memory list? */ - { /* No */ - if(freeMB->nextUMB == NULL) /* Is last item of free memory list? */ - { /* Yes,get size for this free item */ - freeSize = kheapAddr - (U32)(freeMB); - } - else /* No,get size for this free item */ - { - freeSize = (U32)(freeMB->nextUMB) -1 - (U32)(freeMB); - } - if(freeSize >= size) /* If the size equal or greater than need */ - { /* Yes,assign in this free memory */ - usedMB=(P_UMB)freeMB;/* Get the address for used memory block head*/ - - /* Get the address for used memory block */ - memAddr = (U8*)((U32)(usedMB) + 8); - - /* Is left size of free memory smaller than 12? */ - if((freeSize-size) < 12) - { - /* Yes,malloc together(12 is the size of the header information - of free memory block ). */ - if(preFMB != NULL)/* Is first item of free memory block list? */ - { /* No,set the link for list */ - preFMB->nextFMB = freeMB->nextFMB; - } - else /* Yes,reset the first item */ - { - FMBlist = freeMB->nextFMB; - } - - if(freeMB->nextUMB != NULL) /* Is last item? */ - { /* No,set the link for list */ - tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1); - tmpUMB->preMB = (void*)((U32)usedMB|0x1); - } - - usedMB->nextMB = freeMB->nextUMB;/* Set used memory block link*/ - usedMB->preMB = freeMB->preUMB; - } - else /* No,the left size more than 12 */ - { - /* Get new free memory block address */ - newFMB = (P_FMB)((U32)(freeMB) + size); - - if(preFMB != NULL)/* Is first item of free memory block list? */ - { - preFMB->nextFMB = newFMB; /* No,set the link for list */ - } - else - { - FMBlist = newFMB; /* Yes,reset the first item */ - } - - /* Set link for new free memory block */ - newFMB->preUMB = (P_UMB)((U32)usedMB|0x1); - newFMB->nextUMB = freeMB->nextUMB; - newFMB->nextFMB = freeMB->nextFMB; - - if(freeMB->nextUMB != NULL) /* Is last item? */ - { /* No,set the link for list */ - tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1); - tmpUMB->preMB = newFMB; - } - - usedMB->nextMB = newFMB; /* Set used memory block link */ - usedMB->preMB = freeMB->preUMB; - } - - if(freeMB->preUMB != NULL) /* Is first item? */ - { /* No,set the link for list */ - tmpUMB = (P_UMB)((U32)(freeMB->preUMB)-1); - tmpUMB->nextMB = (void*)((U32)usedMB|0x1); - } - - OsSchedUnlock(); /* Unlock schedule */ - return memAddr; /* Return used memory block address */ - } - preFMB = freeMB; /* Save current free memory block as previous */ - freeMB = freeMB->nextFMB; /* Get the next item as current item*/ - } - OsSchedUnlock(); /* Unlock schedule */ - return NULL; /* Error return */ -} - - -/** - ******************************************************************************* - * @brief Release memory block to kernel heap. - * @param[in] memBuf Pointer to memory block. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to release memory block. - ******************************************************************************* - */ -void CoKfree(void* memBuf) -{ - P_FMB curFMB,nextFMB,preFMB; - P_UMB usedMB,nextUMB,preUMB; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(memBuf == NULL) - { - return; - } -#endif - - usedMB = (P_UMB)((U32)(memBuf)-8); - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if((U32)(memBuf) < Kheap.startAddr) - { - return; - } - if((U32)(memBuf) > Kheap.endAddr) - { - return; - } -#endif - - - OsSchedLock(); /* Lock schedule */ - -#if CFG_PAR_CHECKOUT_EN >0 /* Check UMB in list */ - if((U32)(usedMB) < (U32)(FMBlist)) - { - preUMB = (P_UMB)((U32)(FMBlist->preUMB)-1); - while(preUMB != usedMB) - { - if(preUMB == NULL) - { - OsSchedUnlock(); - return; - } - preUMB = (P_UMB)((U32)(preUMB->preMB)-1); - } - } - else - { - if(FMBlist == NULL) - { - nextUMB = (P_UMB)(Kheap.startAddr); - } - else - { - if(FMBlist->nextUMB != NULL) - { - nextUMB = (P_UMB)((U32)(FMBlist->nextUMB)-1); - } - else - { - nextUMB = NULL; - } - } - - while(nextUMB != usedMB) - { - if(nextUMB == NULL) - { - OsSchedUnlock(); - return; - } - if(((U32)(nextUMB->nextMB)&0x1) == 0) - { - nextFMB = (P_FMB)(nextUMB->nextMB); - nextUMB = (P_UMB)((U32)(nextFMB->nextUMB)-1); - } - else - { - nextUMB = (P_UMB)((U32)(nextUMB->nextMB)-1); - } - } - } -#endif - - - /* Is between two free memory block? */ - if( (((U32)(usedMB->nextMB)&0x1) == 0) && (((U32)(usedMB->preMB)&0x1)==0) ) - { /* Yes,is the only one item in kernel heap? */ - if((usedMB->nextMB == NULL) && (usedMB->preMB == NULL)) - { - curFMB = (P_FMB)usedMB; /* Yes,release this item */ - curFMB->nextFMB = NULL; - curFMB->nextUMB = NULL; - curFMB->preUMB = NULL; - FMBlist = curFMB; - } - else if(usedMB->preMB == NULL) /* Is the first item in kernel heap */ - { - /* Yes,release this item,and set link for list */ - curFMB = (P_FMB)usedMB; - nextFMB = (P_FMB)usedMB->nextMB; - - curFMB->nextFMB = nextFMB->nextFMB; - curFMB->nextUMB = nextFMB->nextUMB; - curFMB->preUMB = NULL; - FMBlist = curFMB; - } - else if(usedMB->nextMB == NULL) /* Is the last item in kernel heap */ - { /* Yes,release this item,and set link for list */ - curFMB = (P_FMB)(usedMB->preMB); - curFMB->nextFMB = NULL; - curFMB->nextUMB = NULL; - } - else /* All no,show this item between two normal FMB */ - { - /* release this item,and set link for list */ - nextFMB = (P_FMB)usedMB->nextMB; - curFMB = (P_FMB)(usedMB->preMB); - - curFMB->nextFMB = nextFMB->nextFMB; - curFMB->nextUMB = nextFMB->nextUMB; - } - } - else if(((U32)(usedMB->preMB)&0x1) == 0) /* Is between FMB and UMB? */ - { - if(usedMB->preMB == NULL) /* Yes,is the first item in kernel heap? */ - { - /* Yes,release this item,and set link for list */ - curFMB = (P_FMB)usedMB; - nextUMB = (P_UMB)usedMB->nextMB; - curFMB->nextUMB = nextUMB; - curFMB->preUMB = NULL; - curFMB->nextFMB = FMBlist; - FMBlist = curFMB; - } - else /* No,release this item,and set link for list */ - { - curFMB = (P_FMB)usedMB->preMB; - nextUMB = (P_UMB)usedMB->nextMB; - curFMB->nextUMB = nextUMB; - } - - } - else if(((U32)(usedMB->nextMB)&0x1) == 0) /* Is between UMB and FMB? */ - { /* Yes */ - preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */ - curFMB = (P_FMB)(usedMB); /* new FMB */ - preFMB = GetPreFMB(usedMB); /* Get previous FMB */ - if(preFMB == NULL) /* Is previous FMB==NULL? */ - { - nextFMB = FMBlist; /* Yes,get next FMB */ - FMBlist = curFMB; /* Reset new FMB as the first item of FMB list*/ - } - else - { - nextFMB = preFMB->nextFMB; /* No,get next FMB */ - preFMB->nextFMB = curFMB; /* Set link for FMB list */ - } - - if(nextFMB == NULL) /* Is new FMB as last item of FMB list? */ - { - curFMB->preUMB = preUMB; /* Yes,set link for list */ - curFMB->nextUMB = NULL; - curFMB->nextFMB = NULL; - } - else - { - curFMB->preUMB = preUMB; /* No,set link for list */ - curFMB->nextUMB = nextFMB->nextUMB; - curFMB->nextFMB = nextFMB->nextFMB; - } - } - else /* All no,show UMB between two UMB*/ - { - curFMB = (P_FMB)(usedMB); /* new FMB */ - preFMB = GetPreFMB(usedMB); /* Get previous FMB */ - preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */ - nextUMB = (P_UMB)(usedMB->nextMB); /* Get next UMB */ - - if(preFMB == NULL ) /* Is previous FMB==NULL? */ - { - nextFMB = FMBlist; /* Yes,get next FMB */ - FMBlist = curFMB; /* Reset new FMB as the first item of FMB list */ - } - else - { - nextFMB = preFMB->nextFMB; /* No,get next FMB */ - preFMB->nextFMB = curFMB; /* Set link for FMB list */ - } - - curFMB->preUMB = preUMB; /* Set current FMB link for list */ - curFMB->nextUMB = nextUMB; - curFMB->nextFMB = nextFMB; - } - - if(curFMB->preUMB != NULL)/* Is current FMB as first item in kernel heap? */ - { /* No,set link for list */ - preUMB = (P_UMB)((U32)(curFMB->preUMB)-1); - preUMB->nextMB = (void*)curFMB; - } - if(curFMB->nextUMB != NULL)/* Is current FMB as last item in kernel heap? */ - { /* No,set link for list */ - nextUMB = (P_UMB)((U32)(curFMB->nextUMB)-1); - nextUMB->preMB = (void*)curFMB; - } - OsSchedUnlock(); /* Unlock schedule */ -} - - -/** - ******************************************************************************* - * @brief Get previous free memory block pointer. - * @param[in] usedMB Current used memory block. - * @param[out] None - * @retval Previous free memory block pointer. - * - * @par Description - * @details This function is called to get previous free memory block pointer. - ******************************************************************************* - */ -static P_FMB GetPreFMB(P_UMB usedMB) -{ - P_UMB preUMB; - preUMB = usedMB; - while(((U32)(preUMB->preMB)&0x1)) /* Is previous MB as FMB? */ - { /* No,get previous MB */ - preUMB = (P_UMB)((U32)(preUMB->preMB)-1); - } - return (P_FMB)(preUMB->preMB); /* Yes,return previous MB */ -} - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsKernelHeap.h b/GD32F1/libraries/MapleCoOS/utility/OsKernelHeap.h deleted file mode 100644 index 2e70fab..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsKernelHeap.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - ******************************************************************************* - * @file kernelHeap.h - * @version V1.12 - * @date 2010.03.01 - * @brief Header file related to memory management - * @details This file including some defines and function declare related to - * kernel heap management. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _KERNELHEAP_H -#define _KERNELHEAP_H - - -typedef struct KennelHeap -{ - U32 startAddr; - U32 endAddr; -}KHeap,*P_KHeap; - - -typedef struct UsedMemBlk -{ - void* nextMB; - void* preMB; -}UMB,*P_UMB; - - -typedef struct FreeMemBlk -{ - struct FreeMemBlk* nextFMB; - struct UsedMemBlk* nextUMB; - struct UsedMemBlk* preUMB; -}FMB,*P_FMB; - -/*---------------------------- Function Declare ------------------------------*/ -extern void CoCreateKheap(void); - -#endif /* _KERNELHEAP_H */ - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsMM.h b/GD32F1/libraries/MapleCoOS/utility/OsMM.h deleted file mode 100644 index 663b682..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsMM.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - ******************************************************************************* - * @file mm.h - * @version V1.12 - * @date 2010.03.01 - * @brief Header file related to memory management - * @details This file including some defines and function declare related to - * memory management. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _MM_H -#define _MM_H - - -typedef struct Memory -{ - U8* memAddr; - U8* freeBlock; - U32 blockSize; - U32 blockNum; -}MM,*P_MM; - - -typedef struct MemoryBlock -{ - struct MemoryBlock* nextBlock; -}MemBlk,*P_MemBlk; - - -extern U32 MemoryIDVessel; - -#endif /* _MM_H */ - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsMbox.c b/GD32F1/libraries/MapleCoOS/utility/OsMbox.c deleted file mode 100644 index 22f5322..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsMbox.c +++ /dev/null @@ -1,322 +0,0 @@ -/** - ******************************************************************************* - * @file mbox.c - * @version V1.12 - * @date 2010.03.01 - * @brief Mailbox management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include - - -#if CFG_MAILBOX_EN > 0 - - -/** - ******************************************************************************* - * @brief Create a mailbox - * @param[in] sortType Mail box waiting list sort type. - * @param[out] None - * @retval E_CREATE_FAIL Create mailbox fail. - * @retval others Create mailbox successful. - * - * @par Description - * @details This function is called to create a mailbox. - * @note - ******************************************************************************* - */ -OS_EventID CoCreateMbox(U8 sortType) -{ - P_ECB pecb; - - /* Create a mailbox type event control block */ - pecb = CreatEvent(EVENT_TYPE_MBOX,sortType,NULL); - if(pecb == NULL) /* If failed to create event block */ - { - return E_CREATE_FAIL; - } - pecb->eventCounter = 0; - return (pecb->id); /* Create a mailbox successfully, return event ID */ -} - - - -/** - ******************************************************************************* - * @brief Delete a mailbox - * @param[in] id Event ID. - * @param[in] opt Delete option. - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_INVALID_PARAMETER Invalid parameter. - * @retval E_TASK_WAITTING Tasks waitting for the event,delete fail. - * @retval E_OK Event deleted successful. - * - * @par Description - * @details This function is called to delete a mailbox. - * @note - ******************************************************************************* - */ -StatusType CoDelMbox(OS_EventID id,U8 opt) -{ - P_ECB pecb; - -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) /* Judge id is valid or not? */ - { - return E_INVALID_ID; /* Id is invalid ,return error */ - } -#endif - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_MBOX)/* Validate event control block type*/ - { - return E_INVALID_ID; /* The event is not mailbox */ - } -#endif - return (DeleteEvent(pecb,opt)); /* Delete the mailbox event control block */ -} - - - -/** - ******************************************************************************* - * @brief Accept a mailbox - * @param[in] id Event ID. - * @param[out] perr A pointer to error code. - * @retval NULL - * @retval A pointer to mailbox accepted. - * - * @par Description - * @details This function is called to accept a mailbox. - * @note - ******************************************************************************* - */ -void* CoAcceptMail(OS_EventID id,StatusType* perr) -{ - P_ECB pecb; - void* pmail; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - *perr = E_INVALID_ID; /* Invalid 'id' */ - return NULL; - } -#endif - pecb = &EventTbl[id]; - -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_MBOX)/* Invalid event control block type */ - { - *perr = E_INVALID_ID; - return NULL; - } -#endif - OsSchedLock(); - if(pecb->eventCounter == 1) /* If there is already a message */ - { - *perr = E_OK; - pmail = pecb->eventPtr; /* Get the message */ - pecb->eventPtr = NULL; /* Clear the mailbox */ - pecb->eventCounter = 0; - OsSchedUnlock(); - return pmail; /* Return the message received */ - } - else /* If the mailbox is empty */ - { - OsSchedUnlock(); - *perr = E_MBOX_EMPTY; /* Mailbox is empty,return NULL */ - return NULL; - } -} - - - -/** - ******************************************************************************* - * @brief Wait for a mailbox - * @param[in] id Event ID. - * @param[in] timeout The longest time for writting mail. - * @param[out] perr A pointer to error code. - * @retval NULL - * @retval A pointer to mailbox accept. - * - * @par Description - * @details This function is called to wait a mailbox. - * @note - ******************************************************************************* - */ -void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr) -{ - P_ECB pecb; - void* pmail; - P_OSTCB curTCB; - - if(OSIntNesting > 0) /* If the caller is ISR */ - { - *perr = E_CALL; - return NULL; - } - -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - *perr = E_INVALID_ID; /* Invalid 'id',retrun error */ - return NULL; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_MBOX) - { - *perr = E_INVALID_ID; /* Invalid event type,not EVENT_TYPE_MBOX */ - return NULL; - } -#endif - - if(OSSchedLock != 0) /* Judge schedule is locked or not? */ - { - *perr = E_OS_IN_LOCK; /* Schedule is locked */ - return NULL; /* return NULL */ - } - if( pecb->eventCounter == 1) /* If there is already a message */ - { - *perr = E_OK; - pmail = pecb->eventPtr; /* Get the message */ - pecb->eventPtr = NULL; /* Clear the mailbox */ - pecb->eventCounter = 0; - return pmail; /* Return the message received */ - } - else /* If message is not available, task will pend */ - { - curTCB = TCBRunning; - if(timeout == 0) /* If time-out is not configured */ - { - EventTaskToWait(pecb,curTCB); /* Block task until event occurs */ - *perr = E_OK; - - /* Have recived a message or the mailbox have been deleted */ - pmail = curTCB->pmail; - curTCB->pmail = NULL; - return pmail; /* Return received message or NULL */ - } - else /* If time-out is configured */ - { - OsSchedLock(); - - /* Block task until event or timeout occurs */ - EventTaskToWait(pecb,curTCB); - InsertDelayList(curTCB,timeout); - OsSchedUnlock(); - if( curTCB->pmail == NULL) /* Time-out occurred */ - { - *perr = E_TIMEOUT; - return NULL; - } - else /* Have recived a message or the mailbox have been deleted*/ - { - *perr = E_OK; - pmail = curTCB->pmail; - curTCB->pmail = NULL; - return pmail; /* Return received message or NULL */ - } - } - } -} - - -/** - ******************************************************************************* - * @brief Post a mailbox - * @param[in] id Event ID. - * @param[in] pmail Pointer to mail that want to send. - * @param[out] None - * @retval E_INVALID_ID - * @retval E_OK - * - * @par Description - * @details This function is called to post a mail. - * @note - ******************************************************************************* - */ -StatusType CoPostMail(OS_EventID id,void* pmail) -{ - P_ECB pecb; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; /* Invalid id,return error */ - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_MBOX)/* Validate event control block type*/ - { - return E_INVALID_ID; /* Event is not mailbox,return error*/ - } -#endif - - if(pecb->eventCounter == 0) /* If mailbox doesn't already have a message*/ - { - OsSchedLock(); - pecb->eventPtr = pmail; /* Place message in mailbox */ - pecb->eventCounter = 1; - EventTaskToRdy(pecb); /* Check waiting list */ - OsSchedUnlock(); - return E_OK; - } - else /* If there is already a message in mailbox */ - { - return E_MBOX_FULL; /* Mailbox is full,and return "E_MBOX_FULL" */ - } -} - -/** - ******************************************************************************* - * @brief Post a mailbox in ISR - * @param[in] id Event ID. - * @param[in] pmail Pointer to mail that want to send. - * @param[out] None - * @retval E_INVALID_ID - * @retval E_OK - * - * @par Description - * @details This function is called to post a mail in ISR. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -StatusType isr_PostMail(OS_EventID id,void* pmail) -{ - if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ - { - /* Insert the request into service request queue */ - if(InsertInSRQ(MBOX_REQ,id,pmail) == FALSE) - { - return E_SEV_REQ_FULL; /* If service request queue is full */ - } - else /* Operate successfully */ - { - return E_OK; - } - } - else - { - return(CoPostMail(id,pmail)); /* Sends the message to the mailbox */ - } -} -#endif - -#endif - - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsMm.c b/GD32F1/libraries/MapleCoOS/utility/OsMm.c deleted file mode 100644 index db41097..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsMm.c +++ /dev/null @@ -1,275 +0,0 @@ -/** - ******************************************************************************* - * @file mm.c - * @version V1.12 - * @date 2010.03.01 - * @brief memory management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - - -#if CFG_MM_EN > 0 -/*---------------------------- Variable Define -------------------------------*/ -MM MemoryTbl[CFG_MAX_MM] = {{0}};/*!< Table which save memory control block. */ -U32 MemoryIDVessel = 0; /*!< Memory ID container. */ - -/** - ******************************************************************************* - * @brief Create a memory partition - * @param[in] memBuf Specify memory partition head address. - * @param[in] blockSize Specify memory block size. - * @param[in] blockNum Specify memory block number. - * @param[out] None - * @retval E_CREATE_FAIL Create memory partition fail. - * @retval others Create memory partition successful. - * - * @par Description - * @details This function is called to create a memory partition. - ******************************************************************************* - */ -OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum) -{ - U8 i,j; - U8 *memory; - P_MemBlk memBlk; - memory = memBuf; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(memBuf == NULL) - { - return E_CREATE_FAIL; - } - if(blockSize == 0) - { - return E_CREATE_FAIL; - } - if((blockSize&0x3) != 0) - { - return E_CREATE_FAIL; - } - if(blockNum<=1) - { - return E_CREATE_FAIL; - } -#endif - - OsSchedLock(); /* Lock schedule */ - for(i = 0; i < CFG_MAX_MM; i++) - { - if((MemoryIDVessel & (1 << i)) == 0) /* Is free memory ID? */ - { - MemoryIDVessel |= (1<nextBlock = (P_MemBlk)memory; - memBlk = memBlk->nextBlock; - } - memBlk->nextBlock = NULL; - return i; /* Return memory block ID */ - } - } - OsSchedUnlock(); /* Unlock schedule */ - return E_CREATE_FAIL; /* Error return */ -} - - -/** - ******************************************************************************* - * @brief Delete a memory partition - * @param[in] mmID Specify memory partition that want to delete. - * @param[out] None - * @retval E_INVALID_ID The memory partition id passed was invalid,delete fail. - * @retval E_OK Delete successful. - * - * @par Description - * @details This function is called to Delete a memory partition. - ******************************************************************************* - */ -StatusType CoDelMemoryPartition(OS_MMID mmID) -{ - P_MM memCtl; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(mmID >= CFG_MAX_MM) - { - return E_INVALID_ID; - } - if( ((1<memAddr = NULL; - memCtl->freeBlock = NULL; - memCtl->blockSize = 0; - memCtl->blockNum = 0; - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Get free block number in a memory partition - * @param[in] mmID Specify memory partition. - * - * @param[out] E_INVALID_ID Invalid ID was passed and get counter failure. - * @param[out] E_OK Get current counter successful. - * @retval fbNum The number of free block. - * - * @par Description - * @details This function is called to get free block number in a memory - * partition. - ******************************************************************************* - */ -U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr) -{ - U32 fbNum; - P_MM memCtl; - P_MemBlk memBlk; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(mmID >= CFG_MAX_MM) - { - *perr = E_INVALID_ID; - return 0; - } - if( ((1<freeBlock);/* Get the free item in memory list*/ - fbNum = 0; - while(memBlk != NULL) /* Get counter of free item */ - { - fbNum++; - memBlk = memBlk->nextBlock; /* Get next free iterm */ - } - OsSchedUnlock(); /* Unlock schedul */ - *perr = E_OK; - return fbNum; /* Return the counter of free item */ -} - - -/** - ******************************************************************************* - * @brief Get a memory buffer from memory partition - * @param[in] mmID Specify memory partition that want to assign buffer. - * @param[out] None - * @retval NULL Assign buffer fail. - * @retval others Assign buffer successful,and return the buffer pointer. - * - * @par Description - * @details This function is called to Delete a memory partition. - ******************************************************************************* - */ -void* CoGetMemoryBuffer(OS_MMID mmID) -{ - P_MM memCtl; - P_MemBlk memBlk; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(mmID >= CFG_MAX_MM) - { - return NULL; - } - if( ((1<freeBlock == NULL ) /* Is there no free item in memory list */ - { - OsSchedUnlock(); /* Unlock schedule */ - return NULL; /* Yes,error return */ - } - memBlk = (P_MemBlk)memCtl->freeBlock; /* Get free memory block */ - memCtl->freeBlock = (U8*)memBlk->nextBlock; /* Reset the first free item */ - OsSchedUnlock(); /* Unlock schedule */ - return memBlk; /* Return free memory block address */ -} - - - -/** - ******************************************************************************* - * @brief Free a memory buffer to memory partition - * @param[in] mmID Specify memory partition. - * @param[in] buf Specify memory buffer that want to free. - * @param[out] None - * @retval E_INVALID_ID The memory partition id passed was invalid. - * @retval E_INVALID_PARAMETER The parameter passed was invalid. - * @retval E_OK Free successful. - * - * @par Description - * @details This function is called to Delete a memory partition. - ******************************************************************************* - */ -StatusType CoFreeMemoryBuffer(OS_MMID mmID,void* buf) -{ - P_MM memCtl; - P_MemBlk memBlk; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(mmID >= CFG_MAX_MM) - { - return E_INVALID_ID; - } - if( ((1<0 /* Check validity of parameter */ - if((U32)buf < (U32)(memCtl->memAddr)) - { - return E_INVALID_PARAMETER; - } - if((U32)buf > (U32)(memCtl->memAddr + memCtl->blockSize*memCtl->blockNum)) - { - return E_INVALID_PARAMETER; - } - if(((U32)buf - (U32)(memCtl->memAddr))%(memCtl->blockSize) != 0) - { - return E_INVALID_PARAMETER; - } -#endif - memBlk = (P_MemBlk)buf; /* Reset the first free item */ - OsSchedLock(); - memBlk->nextBlock = (P_MemBlk)memCtl->freeBlock; - memCtl->freeBlock = buf; - OsSchedUnlock(); - return E_OK; /* Return OK */ -} - -#endif - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsMutex.c b/GD32F1/libraries/MapleCoOS/utility/OsMutex.c deleted file mode 100644 index 47aa21e..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsMutex.c +++ /dev/null @@ -1,349 +0,0 @@ -/** - ******************************************************************************* - * @file mutex.c - * @version V1.12 - * @date 2010.03.01 - * @brief Mutex management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - - -/*---------------------------- Variable Define -------------------------------*/ -#if CFG_MUTEX_EN > 0 - -OS_MutexID MutexFreeID = 0; /*!< Point to next vliad mutex ID. */ -MUTEX MutexTbl[CFG_MAX_MUTEX] = {{0}}; /*!< Mutex struct array */ - - - -/** - ******************************************************************************* - * @brief Create a mutex - * @param[in] None - * @param[out] None - * @retval E_CREATE_FAIL Create mutex fail. - * @retval others Create mutex successful. - * - * @par Description - * @details This function is called to create a mutex. - * @note - ******************************************************************************* - */ -OS_MutexID CoCreateMutex(void) -{ - OS_MutexID id; - P_MUTEX pMutex; - OsSchedLock(); - - /* Assign a free mutex control block */ - if(MutexFreeID < CFG_MAX_MUTEX ) - { - id = MutexFreeID++; - OsSchedUnlock(); - pMutex = &MutexTbl[id]; - pMutex->hipriTaskID = INVALID_ID; - pMutex->originalPrio = 0xff; - pMutex->mutexFlag = MUTEX_FREE; /* Mutex is free,not was occupied */ - pMutex->taskID = INVALID_ID; - pMutex->waittingList = NULL; - return id; /* Return mutex ID */ - } - - OsSchedUnlock(); - return E_CREATE_FAIL; /* No free mutex control block */ -} - - - -/** - ******************************************************************************* - * @brief Enter a critical area - * @param[in] mutexID Specify mutex. - * @param[out] None - * @retval E_INVALID_ID Invalid mutex id. - * @retval E_CALL Error call in ISR. - * @retval E_OK Enter critical area successful. - * - * @par Description - * @details This function is called when entering a critical area. - * @note - ******************************************************************************* - */ -StatusType CoEnterMutexSection(OS_MutexID mutexID) -{ - P_OSTCB ptcb,pCurTcb; - P_MUTEX pMutex; - -#if CFG_EVENT_EN >0 - P_ECB pecb; -#endif - - if(OSIntNesting > 0) /* If the caller is ISR */ - { - return E_CALL; - } - if(OSSchedLock != 0) /* Is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - -#if CFG_PAR_CHECKOUT_EN >0 - if(mutexID >= MutexFreeID) /* Invalid 'mutexID' */ - { - return E_INVALID_ID; - } -#endif - - OsSchedLock(); - pCurTcb = TCBRunning; - pMutex = &MutexTbl[mutexID]; - - pCurTcb->mutexID = mutexID; - if(pMutex->mutexFlag == MUTEX_FREE) /* If mutex is available */ - { - pMutex->originalPrio = pCurTcb->prio; /* Save priority of owning task */ - pMutex->taskID = pCurTcb->taskID; /* Acquire the resource */ - pMutex->hipriTaskID = pCurTcb->taskID; - pMutex->mutexFlag = MUTEX_OCCUPY; /* Occupy the mutex resource*/ - } - /* If the mutex resource had been occupied */ - else if(pMutex->mutexFlag == MUTEX_OCCUPY) - { - ptcb = &TCBTbl[pMutex->taskID]; - if(ptcb->prio > pCurTcb->prio) /* Need to promote priority of owner? */ - { -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - DeleteTaskPri(ptcb->prio); - ActiveTaskPri(pCurTcb->prio); -#endif - ptcb->prio = pCurTcb->prio; /* Promote prio of owner */ - - /* Upgarde the highest priority about the mutex */ - pMutex->hipriTaskID = pCurTcb->taskID; - if(ptcb->state == TASK_READY) /* If the task is ready to run */ - { - RemoveFromTCBRdyList(ptcb); /* Remove the task from READY list*/ - InsertToTCBRdyList(ptcb); /* Insert the task into READY list*/ - } -#if CFG_EVENT_EN >0 - /* If the task is waiting on a event */ - else if(ptcb->eventID != INVALID_ID) - { - pecb = &EventTbl[ptcb->eventID]; - - /* If the event waiting type is preemptive Priority */ - if(pecb->eventSortType == EVENT_SORT_TYPE_PRIO) - { - /* Remove the task from event waiting list */ - RemoveEventWaittingList(ptcb); - - /* Insert the task into event waiting list */ - EventTaskToWait(pecb,ptcb); - } - } -#endif - } - - pCurTcb->state = TASK_WAITING; /* Block current task */ - TaskSchedReq = TRUE; - pCurTcb->TCBnext = NULL; - pCurTcb->TCBprev = NULL; - - ptcb = pMutex->waittingList; - if(ptcb == NULL) /* If the event waiting list is empty */ - { - pMutex->waittingList = pCurTcb; /* Insert the task to head */ - } - else /* If the event waiting list is not empty */ - { - while(ptcb->TCBnext != NULL) /* Insert the task to tail */ - { - ptcb = ptcb->TCBnext; - } - ptcb->TCBnext = pCurTcb; - pCurTcb->TCBprev = ptcb; - pCurTcb->TCBnext = NULL; - } - } - OsSchedUnlock(); - return E_OK; -} - - -/** - ******************************************************************************* - * @brief Leave from a critical area - * @param[in] mutexID Specify mutex id. - * @param[out] None - * @retval E_INVALID_ID Invalid mutex id. - * @retval E_CALL Error call in ISR. - * @retval E_OK Exit a critical area successful. - * - * @par Description - * @details This function must be called when exiting from a critical area. - * @note - ******************************************************************************* - */ -StatusType CoLeaveMutexSection(OS_MutexID mutexID) -{ - P_OSTCB ptcb; - P_MUTEX pMutex; - U8 prio; - U8 taskID; - - if(OSIntNesting > 0) /* If the caller is ISR */ - { - return E_CALL; - } - -#if CFG_PAR_CHECKOUT_EN >0 - if(mutexID >= MutexFreeID) - { - return E_INVALID_ID; /* Invalid mutex id, return error */ - } -#endif - OsSchedLock(); - pMutex = &MutexTbl[mutexID]; /* Obtain point of mutex control block*/ - ptcb = &TCBTbl[pMutex->taskID]; - ptcb->mutexID = INVALID_ID; - if(pMutex->waittingList == NULL) /* If the mutex waiting list is empty */ - { - pMutex->mutexFlag = MUTEX_FREE; /* The mutex resource is available */ - pMutex->taskID = INVALID_ID; - OsSchedUnlock(); - } - else /* If there is at least one task waitting for the mutex */ - { - taskID = pMutex->taskID; /* Get task ID of mutex owner */ - - /* we havn't promoted current task's priority */ - if(pMutex->hipriTaskID == taskID) - { - ptcb = pMutex->waittingList;/* Point to mutex first waiting task */ - prio = ptcb->prio; - while(ptcb != NULL) /* Find the highest priority task */ - { - if(ptcb->prio < prio) - { - prio = ptcb->prio; - pMutex->hipriTaskID = ptcb->taskID; - } - ptcb = ptcb->TCBnext; - } - } - else /* we have promoted current task's priority */ - { - prio = TCBTbl[taskID].prio; - } - - /* Reset the task priority */ - pMutex->taskID = INVALID_ID; - CoSetPriority(taskID,pMutex->originalPrio); - - /* Find first task in waiting list ready to run */ - ptcb = pMutex->waittingList; - pMutex->waittingList = ptcb->TCBnext; - pMutex->originalPrio = ptcb->prio; - pMutex->taskID = ptcb->taskID; - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(prio != ptcb->prio) - { - DeleteTaskPri(ptcb->prio); - ActiveTaskPri(prio); - } -#endif - - ptcb->prio = prio; /* Raise the task's priority */ - - /* Insert the task which acquire the mutex into ready list. */ - ptcb->TCBnext = NULL; - ptcb->TCBprev = NULL; - - InsertToTCBRdyList(ptcb); /* Insert the task into the READY list */ - OsSchedUnlock(); - } - return E_OK; -} - -/** - ******************************************************************************* - * @brief Remove a task from mutex waiting list - * @param[in] ptcb TCB which will remove out. - * @param[out] None - * @retval None - * - * @par Description - * @details This function be called when delete a task. - * @note - ******************************************************************************* - */ -void RemoveMutexList(P_OSTCB ptcb) -{ - U8 prio; - OS_TID taskID; - P_MUTEX pMutex; - pMutex = &MutexTbl[ptcb->mutexID]; - - /* If only one task waiting on mutex */ - if((ptcb->TCBnext ==NULL) && (ptcb->TCBprev == NULL)) - { - pMutex->waittingList = NULL; /* Waiting list is empty */ - } - else if(ptcb->TCBnext == NULL) /* If the task is the last of waiting list*/ - { - /* Remove task from mutex waiting list */ - ptcb->TCBprev->TCBnext = NULL; - ptcb->TCBprev = NULL; - } - else if(ptcb->TCBprev == NULL)/* If the task is the first of waiting list*/ - { - /* Remove task from waiting list */ - ptcb->TCBnext->TCBprev = NULL; - ptcb->TCBnext = NULL; - } - else /* If the task is in the middle of waiting list */ - { - /* Remove task from wait list */ - ptcb->TCBnext->TCBprev = ptcb->TCBprev; - ptcb->TCBprev->TCBnext = ptcb->TCBnext; - ptcb->TCBprev = NULL; - ptcb->TCBnext = NULL; - } - - ptcb->mutexID = INVALID_ID; - - /* If the task have highest priority in mutex waiting list */ - if(pMutex->hipriTaskID == ptcb->taskID) - { - ptcb = pMutex->waittingList; - prio = pMutex->originalPrio; - pMutex->hipriTaskID = pMutex->taskID; - while(ptcb != NULL) /* Find task ID of highest priority task*/ - { - if(ptcb->prio < prio) - { - prio = ptcb->prio; - pMutex->hipriTaskID = ptcb->taskID; - } - ptcb = ptcb->TCBnext; - } - taskID = pMutex->taskID; - pMutex->taskID = INVALID_ID; - CoSetPriority(taskID,prio); /* Reset the mutex ower priority */ - pMutex->taskID = taskID; - } -} - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsMutex.h b/GD32F1/libraries/MapleCoOS/utility/OsMutex.h deleted file mode 100644 index a819adf..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsMutex.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - ******************************************************************************* - * @file mutex.h - * @version V1.12 - * @date 2010.03.01 - * @brief Mutex management header file - * @details This file including some defines and declare related to mutex - * management. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _MUTEX_H -#define _MUTEX_H - -#include - -#if CFG_MUTEX_EN > 0 - -/*---------------------------- Resource status -------------------------------*/ -#define MUTEX_FREE 0 /*!< Mutex is free */ -#define MUTEX_OCCUPY 1 /*!< Mutex is occupy */ -#define WAITING_MUTEX 0x80 - -/** - * @struct Mutex mutex.h - * @brief Mutex control block - * @details This struct is use to mutex management. - */ -typedef struct Mutex -{ - U8 originalPrio; /*!< Mutex priority. */ - U8 mutexFlag; /*!< Mutex flag. */ - OS_TID taskID; /*!< Task ID. */ - OS_TID hipriTaskID; /*!< Mutex ID. */ - P_OSTCB waittingList; /*!< waitting the Mutex. */ -}MUTEX,*P_MUTEX; - - -/*---------------------------- Variable declare ------------------------------*/ -/*!< Table use to save mutex control block. */ -extern MUTEX MutexTbl[CFG_MAX_MUTEX]; -extern OS_MutexID MutexFreeID; /*!< A pointer to next vliad resource ID. */ - - -/*---------------------------- Function declare ------------------------------*/ -extern void RemoveMutexList(P_OSTCB ptcb); - -#endif /* CFG_MUTEX_EN */ - -#endif /* _MUTEX_H */ diff --git a/GD32F1/libraries/MapleCoOS/utility/OsPort.c b/GD32F1/libraries/MapleCoOS/utility/OsPort.c deleted file mode 100644 index 1549022..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsPort.c +++ /dev/null @@ -1,251 +0,0 @@ -/** - ******************************************************************************* - * @file prot.c - * @version V1.12 - * @date 2010.03.01 - * @brief Compiler adapter for CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2010 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include - - -//****************************************************************************** -// EQUATES -//****************************************************************************** -U32 NVIC_INT_CTRL = 0xE000ED04; // Interrupt control state register -U32 NVIC_PENDSVSET = 0x10000000; // Value to trigger PendSV exception -U32 INT_EXIT = 0xFFFFFFFC; - -//****************************************************************************** -// PUBLIC FUNCTIONS -//****************************************************************************** -extern U8 Inc8(U8 *data) ; -extern U8 Dec8(U8 *data) ; -extern void SetEnvironment(OS_STK *pstk) __attribute__ ((naked)); -extern void SwitchContext(void) __attribute__ ((naked)); -extern void PendSVC(void) __attribute__ ((naked)); - - -/** - ****************************************************************************** - * @brief Plus a byte integers and Saved into memory cell - * @param[in] data byte integers. - * @param[out] None - * @retval Returns Original value. - * - * @par Description - * @details This function is called to Plus a byte integers - * and Saved into memory cell. - ****************************************************************************** - */ -U8 Inc8 (U8 *data) -{ - register U8 result = 0; - - __asm volatile - ( - " PUSH {R1} \n" - " CPSID I \n" - " LDRB R1,[%1] \n" - " ADD R1,#1 \n" - " STRB R1,[%1] \n" - " CPSIE I \n" - " SUB R1,#0x1 \n" - " MOVS %0,R1 \n" - " POP {R1} \n" - :"=r"(result) - :"r"(data) - ); - return (result); - -} - - -/** - ****************************************************************************** - * @brief Decrease a byte integers and Saved into memory cell - * @param[in] data byte integers. - * @param[out] None - * @retval Returns Original value. - * - * @par Description - * @details This function is called to Decrease a byte integers - * and Saved into memory cell. - ****************************************************************************** - */ -U8 Dec8 (U8 *data) -{ - register U8 result = 0; - __asm volatile - ( - " PUSH {R1} \n" - " CPSID I \n" - " LDRB R1,[%1] \n" - " SUB R1,#1 \n" - " STRB R1,[%1] \n" - " CPSIE I \n" - " MOVS %0,R1 \n" - " POP {R1} \n" - :"=r"(result) - :"r"(data) - ); - return (result); -} - - -/** - ****************************************************************************** - * @brief Set environment for Coocox OS running - * @param[in] pstk stack pointer - * @param[out] None - * @retval None. - * - * @par Description - * @details This function is called to Set environment - * for Coocox OS running. - ****************************************************************************** - */ -void SetEnvironment (OS_STK *pstk) -{ - __asm volatile - ( - " SUB R0,#28 \n" - " MSR PSP,R0 \n" - " BX LR \n" - ); -} - - -/** - ****************************************************************************** - * @brief Do ready work to Switch Context for task change - * @param[in] None - * @param[out] None - * @retval None. - * - * @par Description - * @details This function is called to Do ready work to - * Switch Context for task change - ****************************************************************************** - */ -void SwitchContext(void) -{ - __asm volatile - ( - " LDR R3,=NVIC_INT_CTRL \n" - " LDR R3,[R3] \n" - " LDR R2,=NVIC_PENDSVSET \n" - " LDR R1,[R2] \n" - " STR R1, [R3] \n" - " BX LR \n" - ); -} - - - -/** - ****************************************************************************** - * @brief Switch Context for task change - * @param[in] None - * @param[out] None - * @retval None. - * - * @par Description - * @details This function is called to Switch Context for task change. - ****************************************************************************** - */ -#if CFG_CHIP_TYPE == 2 -void PendSVC(void) -{ - __asm volatile - ( - " LDR R3,=TCBRunning \n" - " LDR R1,[R3] \n" // R1 == running tcb - " LDR R2,=TCBNext \n" - " LDR R2,[R2] \n" // R2 == next tcb - - " CMP R1,R2 \n" - " BEQ exitPendSV \n" - " MRS R0, PSP \n" // Get PSP point (can not use PUSH,in ISR,SP is MSP ) - - " SUB R0,R0,#32 \n" - " STR R0,[R1] \n" // Save orig PSP - // Store r4-r11,r0 -= regCnt * 4,r0 is new stack - // top point (addr h->l r11,r10,...,r5,r4) - " STMIA R0!,{R4-R7} \n" // Save old context (R4-R7) - " MOV R4,R8 \n" - " MOV R5,R9 \n" - " MOV R6,R10 \n" - " MOV R7,R11 \n" - " STMIA R0!,{R4-R7} \n" // Save old context (R8-R11) - - " popStk: \n" - " STR R2, [R3] \n" // TCBRunning = TCBNext; - " LDR R0, [R2] \n" // Get SP of task that be switch into. - - " ADD R0,R0,#16 \n" - " LDMIA R0!,{R4-R7} \n" // Restore new Context (R8-R11) - " MOV R8,R4 \n" - " MOV R9,R5 \n" - " MOV R10,R6 \n" - " MOV R11,R7 \n" - " SUB R0,R0,#32 \n" - " LDMIA R0!,{R4-R7} \n" // Restore new Context (R4-R7) - " ADD R0,R0,#16 \n" - " MSR PSP, R0 \n" // Mov new stack point to PSP - - " exitPendSV: \n" - " LDR R3,=OSSchedLock \n" - " MOV R0, #0x0 \n" - " STRB R0, [R3] \n" - - " LDR R3,=INT_EXIT \n" - " LDR R0, [R3] \n" - " BX R0 \n" // Exit interrupt - ); -} -#endif - -#if CFG_CHIP_TYPE == 1 -void __exc_pendsv(void) -{ -////////debug block ///////////////////////// - __asm volatile - ( - " LDR R3,=TCBRunning \n" - " LDR R1,[R3] \n" // R1 == running tcb - " LDR R2,=TCBNext \n" - " LDR R2,[R2] \n" // R2 == next tcb - - " CMP R1,R2 \n" - " BEQ exitPendSV \n" - - " MRS R0, PSP \n" // Get PSP point (can not use PUSH,in ISR,SP is MSP ) - " STMDB R0!,{R4-R11} \n" // Store r4-r11,r0 -= regCnt * 4,r0 is new stack - // top point (addr h->l r11,r10,...,r5,r4) - " STR R0,[R1] \n" // Save orig PSP - - " STR R2, [R3] \n" // TCBRunning = TCBNext; - " LDR R0, [R2] \n" // Get SP of task that be switch into. - " LDMIA R0!,{R4-R11} \n" // POP {R4-R11},R0 += regCnt * 4 - " MSR PSP, R0 \n" // Mov new stack point to PSP - - - " exitPendSV: \n" - " LDR R3,=OSSchedLock\n" - " MOVS R0, #0x0 \n" - " STRB R0, [R3] \n" - " ORR LR,LR,#0x04 \n" // Ensure exception return uses process stack - " BX LR \n" // Exit interrupt - ); -} -#endif - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsQueue.c b/GD32F1/libraries/MapleCoOS/utility/OsQueue.c deleted file mode 100644 index 7a702af..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsQueue.c +++ /dev/null @@ -1,391 +0,0 @@ -/** - ******************************************************************************* - * @file queue.c - * @version V1.12 - * @date 2010.03.01 - * @brief Queue management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include - - -#if CFG_QUEUE_EN > 0 -/*---------------------------- Variable Define -------------------------------*/ -QCB QueueTbl[CFG_MAX_QUEUE] = {{0}}; /*!< Queue control block table */ -U32 QueueIDVessel = 0; /*!< Queue list mask */ - - - -/** - ******************************************************************************* - * @brief Create a queue - * @param[in] qStart Pointer to mail pointer buffer. - * @param[in] size The length of queue. - * @param[in] sortType Mail queue waiting list sort type. - * @param[out] None - * @retval E_CREATE_FAIL Create queue fail. - * @retval others Create queue successful. - * - * @par Description - * @details This function is called to create a queue. - * @note - ******************************************************************************* - */ -OS_EventID CoCreateQueue(void **qStart, U16 size ,U8 sortType) -{ - U8 i; - P_ECB pecb; - -#if CFG_PAR_CHECKOUT_EN >0 - if((qStart == NULL) || (size == 0)) - { - return E_CREATE_FAIL; - } -#endif - - OsSchedLock(); - for(i = 0; i < CFG_MAX_QUEUE; i++) - { - /* Assign a free QUEUE control block */ - if((QueueIDVessel & (1 << i)) == 0) - { - QueueIDVessel |= (1<id); - } - } - - OsSchedUnlock(); - return E_CREATE_FAIL; /* There is no free QUEUE control block */ -} - - -/** - ******************************************************************************* - * @brief Delete a queue - * @param[in] id Event ID. - * @param[in] opt Delete option. - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_INVALID_PARAMETER Invalid parameter. - * @retval E_TASK_WAITTING Tasks waitting for the event,delete fail. - * @retval E_OK Event deleted successful. - * - * @par Description - * @details This function is called to delete a queue. - * @note - ******************************************************************************* - */ -StatusType CoDelQueue(OS_EventID id,U8 opt) -{ - P_ECB pecb; - P_QCB pqcb; - StatusType err; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; /* Invalid id,return error */ - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if( pecb->eventType != EVENT_TYPE_QUEUE) - { - return E_INVALID_ID; /* The event is not queue,return error*/ - } -#endif - pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */ - err = DeleteEvent(pecb,opt); /* Delete the event control block */ - if(err == E_OK) /* If the event block have been deleted */ - { - QueueIDVessel &= ~((U32)(1<<(pqcb->id))); /* Update free queue list */ - pqcb->qStart = NULL; - pqcb->id = 0; - pqcb->head = 0; - pqcb->tail = 0; - pqcb->qMaxSize = 0; - pqcb->qSize = 0; - } - return err; -} - - - -/** - ******************************************************************************* - * @brief Accept a mail from queue - * @param[in] id Event ID. - * @param[out] perr A pointer to error code. - * @retval NULL - * @retval A pointer to mail accepted. - * - * @par Description - * @details This function is called to accept a mail from queue. - * @note - ******************************************************************************* - */ -void* CoAcceptQueueMail(OS_EventID id,StatusType* perr) -{ - P_ECB pecb; - P_QCB pqcb; - void* pmail; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - *perr = E_INVALID_ID; /* Invalid id,return error */ - return NULL; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_QUEUE)/* Invalid event control block type*/ - { - *perr = E_INVALID_ID; - return NULL; - } -#endif - pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */ - OsSchedLock(); - if(pqcb->qSize != 0) /* If there are any messages in the queue */ - { - /* Extract oldest message from the queue */ - pmail = *(pqcb->qStart + pqcb->head); - pqcb->head++; /* Update the queue head */ - pqcb->qSize--; /* Update the number of messages in the queue */ - if(pqcb->head == pqcb->qMaxSize) - { - pqcb->head = 0; - } - OsSchedUnlock(); - *perr = E_OK; - return pmail; /* Return message received */ - } - else /* If there is no message in the queue*/ - { - OsSchedUnlock(); - *perr = E_QUEUE_EMPTY; - return NULL; /* Return NULL */ - } -} - - - -/** - ******************************************************************************* - * @brief Pend for a mail - * @param[in] id Event ID. - * @param[in] timeout The longest time for writting mail. - * @param[out] perr A pointer to error code. - * @retval NULL - * @retval A pointer to mail accept. - * - * @par Description - * @details This function is called to wait for a mail. - * @note - ******************************************************************************* - */ -void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr) -{ - P_ECB pecb; - P_QCB pqcb; - P_OSTCB curTCB; - void* pmail; - if(OSIntNesting > 0) /* If the caller is ISR */ - { - *perr = E_CALL; - return NULL; - } -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - *perr = E_INVALID_ID; /* Invalid event id,return error */ - return NULL; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_QUEUE) /* The event type is not queue */ - { - *perr = E_INVALID_ID; - return NULL; - } -#endif - if(OSSchedLock != 0) /* Judge schedule is locked or not? */ - { - *perr = E_OS_IN_LOCK; /* Schedule is locked,return error */ - return NULL; - } - pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */ - - if(pqcb->qSize != 0) /* If there are any messages in the queue */ - { - /* Extract oldest message from the queue */ - pmail = *(pqcb->qStart + pqcb->head); - pqcb->head++; /* Update the queue head */ - pqcb->qSize--; /* Update the number of messages in the queue */ - if(pqcb->head == pqcb->qMaxSize)/* Check queue head */ - { - pqcb->head = 0; - } - *perr = E_OK; - return pmail; /* Return message received */ - } - else /* If there is no message in the queue*/ - { - curTCB = TCBRunning; - if(timeout == 0) /* If time-out is not configured */ - { - /* Block current task until the event occur */ - EventTaskToWait(pecb,curTCB); - - /* Have recived message or the queue have been deleted */ - pmail = curTCB->pmail; - curTCB->pmail = NULL; - *perr = E_OK; - return pmail; /* Return message received or NULL */ - } - else /* If time-out is configured */ - { - OsSchedLock(); - - /* Block current task until event or timeout occurs */ - EventTaskToWait(pecb,curTCB); - InsertDelayList(curTCB,timeout); - OsSchedUnlock(); - if(curTCB->pmail == NULL) /* If time-out occurred */ - { - *perr = E_TIMEOUT; - return NULL; - } - else /* If event occured */ - { - pmail = curTCB->pmail; - curTCB->pmail = NULL; - *perr = E_OK; - return pmail; /* Return message received or NULL */ - } - } - } -} - - - -/** - ******************************************************************************* - * @brief Post a mail to queue - * @param[in] id Event ID. - * @param[in] pmail Pointer to mail that want to send. - * @param[out] None - * @retval E_OK - * @retval E_INVALID_ID - * @retval E_QUEUE_FULL - * - * @par Description - * @details This function is called to post a mail to queue. - * @note - ******************************************************************************* - */ -StatusType CoPostQueueMail(OS_EventID id,void* pmail) -{ - P_ECB pecb; - P_QCB pqcb; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_QUEUE) - { - return E_INVALID_ID; /* The event type isn't queue,return */ - } -#endif - pqcb = (P_QCB)pecb->eventPtr; - if(pqcb->qSize == pqcb->qMaxSize) /* If queue is full */ - { - return E_QUEUE_FULL; - } - else /* If queue is not full */ - { - OsSchedLock(); - *(pqcb->qStart + pqcb->tail) = pmail; /* Insert message into queue */ - pqcb->tail++; /* Update queue tail */ - pqcb->qSize++; /* Update the number of messages in the queue */ - if(pqcb->tail == pqcb->qMaxSize) /* Check queue tail */ - { - pqcb->tail = 0; - } - EventTaskToRdy(pecb); /* Check the event waiting list */ - OsSchedUnlock(); - return E_OK; - } -} - - -/** - ******************************************************************************* - * @brief Post a mail to queue in ISR - * @param[in] id Event ID. - * @param[in] pmail Pointer to mail that want to send. - * @param[out] None - * @retval E_OK - * @retval E_INVALID_ID - * @retval E_QUEUE_FULL - * - * @par Description - * @details This function is called in ISR to post a mail to queue. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -StatusType isr_PostQueueMail(OS_EventID id,void* pmail) -{ - if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ - { - /* Insert the request into service request queue */ - if(InsertInSRQ(QUEUE_REQ,id,pmail) == FALSE) - { - return E_SEV_REQ_FULL; /* If service request queue is full */ - } - else /* If the request have been inserted into service request queue */ - { - return E_OK; - } - } - else /* The scheduler is unlocked */ - { - return(CoPostQueueMail(id,pmail)); /* Send the message to the queue*/ - } -} -#endif - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsQueue.h b/GD32F1/libraries/MapleCoOS/utility/OsQueue.h deleted file mode 100644 index 268b9d4..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsQueue.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - ******************************************************************************* - * @file queue.h - * @version V1.12 - * @date 2010.03.01 - * @brief Queue management header file - * @details This file including some defines and declares about queue management. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _QUEUE_H -#define _QUEUE_H - - -/** - * @struct Queue queue.h - * @brief Queue struct - * @details This struct use to manage queue. - * - */ -typedef struct Queue -{ - void **qStart; /*!< */ - U8 id; /*!< */ - U16 head; /*!< The header of queue */ - U16 tail; /*!< The end of queue */ - U16 qMaxSize; /*!< The max size of queue */ - U16 qSize; /*!< Current size of queue */ -}QCB,*P_QCB; - - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsSem.c b/GD32F1/libraries/MapleCoOS/utility/OsSem.c deleted file mode 100644 index 5ac99bd..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsSem.c +++ /dev/null @@ -1,319 +0,0 @@ -/** - ******************************************************************************* - * @file sem.c - * @version V1.12 - * @date 2010.03.01 - * @brief Semaphore management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if CFG_SEM_EN >0 - -/** - ******************************************************************************* - * @brief Create a semaphore - * @param[in] initCnt Semaphore valid counter. - * @param[in] maxCnt Semaphore max initialize counter. - * @param[in] sortType Semaphore sort type. - * @param[out] None - * @retval E_CREATE_FAIL Create semaphore fail. - * @retval others Create semaphore successful. - * - * @par Description - * @details This function is called to create a semaphore. - ******************************************************************************* - */ -OS_EventID CoCreateSem(U16 initCnt,U16 maxCnt,U8 sortType) -{ - P_ECB pecb; -#if CFG_PAR_CHECKOUT_EN >0 - if(initCnt > maxCnt) - { - return E_CREATE_FAIL; /* Invalid 'initCnt' or 'maxCnt' */ - } - - if ((sortType != EVENT_SORT_TYPE_FIFO) && (sortType != EVENT_SORT_TYPE_PRIO)) - { - return E_CREATE_FAIL; /* Illegal sort type,return error */ - } -#endif - - /* Create a semaphore type event control block */ - pecb = CreatEvent(EVENT_TYPE_SEM,sortType,NULL); - if(pecb == NULL) /* If failed to create event block */ - { - return E_CREATE_FAIL; - } - pecb->eventCounter = initCnt;/* Initialize event block */ - pecb->initialEventCounter = maxCnt; - return (pecb->id); /* Return event id */ -} - - -/** - ******************************************************************************* - * @brief Delete a semaphore - * @param[in] id Event ID which to be deleted. - * @param[in] opt Delete option. - * @arg == OPT_DEL_ANYWAY Delete semaphore always - * @arg == OPT_DEL_NO_PEND Delete semaphore only when no task pending on. - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_INVALID_PARAMETER Invalid parameter. - * @retval E_TASK_WAITTING Tasks waitting for the event,delete fail. - * @retval E_OK Event deleted successful. - * - * @par Description - * @details This function is called to delete a semaphore. - * - * @note - ******************************************************************************* - */ -StatusType CoDelSem(OS_EventID id,U8 opt) -{ - P_ECB pecb; - -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; - -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_SEM) - { - return E_INVALID_ID; /* The event type is not semaphore */ - } -#endif - - return (DeleteEvent(pecb,opt));/* Delete the semaphore event control block*/ -} - - -/** - ******************************************************************************* - * @brief Accept a semaphore without waitting - * @param[in] id Event ID - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_SEM_EMPTY No semaphore exist. - * @retval E_OK Get semaphore successful. - * - * @par Description - * @details This function is called accept a semaphore without waitting. - ******************************************************************************* - */ -StatusType CoAcceptSem(OS_EventID id) -{ - P_ECB pecb; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if( pecb->eventType != EVENT_TYPE_SEM) - { - return E_INVALID_ID; - } -#endif - OsSchedLock(); - if(pecb->eventCounter > 0) /* If semaphore is positive,resource available */ - { - OsSchedUnlock(); - pecb->eventCounter--; /* Decrement semaphore only if positive */ - return E_OK; - } - else /* Resource is not available */ - { - OsSchedUnlock(); - return E_SEM_EMPTY; - } -} - - -/** - ******************************************************************************* - * @brief wait for a semaphore - * @param[in] id Event ID. - * @param[in] timeout The longest time for writting semaphore. - * @para 0 - * @para 0x1~0xff - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_INVALID_ID Invalid event ID. - * @retval E_TIMEOUT Semaphore was not received within the specified - * 'timeout' time. - * @retval E_OK The call was successful and your task owns the - * resource,or the event you are waiting for occurred. - * - * @par Description - * @details This function is called to waits for a semaphore. - * @note IF this function is called in ISR,nothing to do and return immediately. - ******************************************************************************* - */ -StatusType CoPendSem(OS_EventID id,U32 timeout) -{ - P_ECB pecb; - P_OSTCB curTCB; - if(OSIntNesting > 0) /* If the caller is ISR */ - { - return E_CALL; - } -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_SEM) - { - return E_INVALID_ID; - } -#endif - if(OSSchedLock != 0) /* Schdule is locked? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - if(pecb->eventCounter > 0) /* If semaphore is positive,resource available */ - { - pecb->eventCounter--; /* Decrement semaphore only if positive */ - return E_OK; - } - else /* Resource is not available */ - { - curTCB = TCBRunning; - if(timeout == 0) /* If time-out is not configured */ - { - EventTaskToWait(pecb,curTCB); /* Block task until event occurs */ - curTCB->pmail = NULL; - return E_OK; - } - else /* If time-out is configured */ - { - OsSchedLock(); - - /* Block task until event or timeout occurs */ - EventTaskToWait(pecb,curTCB); - InsertDelayList(curTCB,timeout); - - OsSchedUnlock(); - if (curTCB->pmail == NULL) /* If pmail is NULL, time-out occurred*/ - { - return E_TIMEOUT; - } - else /* Event occurred or event have been deleted*/ - { - curTCB->pmail = NULL; - return E_OK; - } - } - } -} - - -/** - ******************************************************************************* - * @brief Post a semaphore - * @param[in] id id of event control block associated with the desired semaphore. - * @param[out] None - * @retval E_INVALID_ID Parameter id passed was invalid event ID. - * @retval E_SEM_FULL Semaphore full. - * @retval E_OK Semaphore had post successful. - * - * @par Description - * @details This function is called to post a semaphore to corresponding event. - * - * @note - ******************************************************************************* - */ -StatusType CoPostSem(OS_EventID id) -{ - P_ECB pecb; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_SEM) /* Invalid event control block type */ - { - return E_INVALID_ID; - } -#endif - - /* Make sure semaphore will not overflow */ - if(pecb->eventCounter == pecb->initialEventCounter) - { - return E_SEM_FULL; /* The counter of Semaphore reach the max number*/ - } - OsSchedLock(); - pecb->eventCounter++; /* Increment semaphore count to register event */ - EventTaskToRdy(pecb); /* Check semaphore event waiting list */ - OsSchedUnlock(); - return E_OK; - -} - - -/** - ******************************************************************************* - * @brief Post a semaphore in ISR - * @param[in] id identifier of event control block associated with the - * desired semaphore. - * @param[out] None - * @retval E_INVALID_ID Parameter id passed was invalid event ID. - * @retval E_NO_TASK_WAITTING There are one more tasks waitting for the event. - * @retval E_OK Semaphore had signaled successful. - * - * @par Description - * @details This function is called in ISR to post a semaphore to corresponding - * event. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -StatusType isr_PostSem(OS_EventID id) -{ - if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ - { - /* Initiate a post service handling request */ - if(InsertInSRQ(SEM_REQ,id,NULL) == FALSE) - { - return E_SEV_REQ_FULL; /* If service request queue is full */ - } - else /* Operate successfully */ - { - return E_OK; - } - } - else - { - return(CoPostSem(id)); /* Post semaphore */ - } -} -#endif - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsServiceReq.c b/GD32F1/libraries/MapleCoOS/utility/OsServiceReq.c deleted file mode 100644 index c9b8856..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsServiceReq.c +++ /dev/null @@ -1,147 +0,0 @@ -/** - ******************************************************************************* - * @file serviceReq.c - * @version V1.12 - * @date 2010.03.01 - * @brief servive request management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if (CFG_TASK_WAITTING_EN > 0) || (CFG_TMR_EN >0) - -#if CFG_MAX_SERVICE_REQUEST > 0 -/*---------------------------- Variable Define -------------------------------*/ -SRQ ServiceReq = {0}; /*!< ISR server request queue */ -#endif -BOOL IsrReq = FALSE; -#if (CFG_TASK_WAITTING_EN > 0) -BOOL TimeReq = FALSE; /*!< Time delay dispose request */ -#endif - -#if CFG_TMR_EN > 0 -BOOL TimerReq = FALSE; /*!< Timer dispose request */ -#endif - -/** - ******************************************************************************* - * @brief Insert into service requst queue - * @param[in] type Service request type. - * @param[in] id Service request event id,event id/flag id. - * @param[in] arg Service request argument. - * @param[out] None - * - * @retval FALSE Successfully insert into service request queue. - * @retval TRUE Failure to insert into service request queue. - * - * @par Description - * @details This function be called to insert a requst into service request - * queue. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -BOOL InsertInSRQ(U8 type,U8 id,void* arg) -{ - U16 cnt; - P_SQC pcell; - cnt = Inc8(&ServiceReq.cnt); /* Service request counter decrease */ - if(cnt >= CFG_MAX_SERVICE_REQUEST) /* If counter exceed max */ - { - return FALSE; /* Error return */ - } - IsrReq = TRUE; - pcell = &ServiceReq.cell[cnt]; /* Save service request type and parameter */ - pcell->type = type; - pcell->id = id; - pcell->arg = arg; - return TRUE; /* Return OK */ -} -#endif - - -/** - ******************************************************************************* - * @brief Respond the request in the service request queue. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function be called to respond the request in the service - * request queue. - * @note - ******************************************************************************* - */ -void RespondSRQ(void) -{ -#if CFG_MAX_SERVICE_REQUEST > 0 - U16 i; - P_SQC pcell; -#endif - -#if (CFG_TASK_WAITTING_EN > 0) - if(TimeReq == TRUE) /* Time delay request? */ - { - TimeDispose(); /* Yes,call handler */ - TimeReq = FALSE; /* Reset time delay request false */ - } -#endif -#if CFG_TMR_EN > 0 - if(TimerReq == TRUE) /* Timer request? */ - { - TmrDispose(); /* Yes,call handler */ - TimerReq = FALSE; /* Reset timer request false */ - } -#endif - -#if CFG_MAX_SERVICE_REQUEST > 0 - pcell = &ServiceReq.cell[0]; /* Get the head item of service request list*/ - for(i=0;itype) /* Judge service request type */ - { -#if CFG_SEM_EN > 0 - case SEM_REQ: /* Semaphore post request,call handler*/ - CoPostSem(pcell->id); - break; -#endif -#if CFG_MAILBOX_EN > 0 - case MBOX_REQ: /* Mailbox post request,call handler */ - CoPostMail(pcell->id,pcell->arg); - break; -#endif -#if CFG_FLAG_EN > 0 - case FLAG_REQ: /* Flag set request,call handler */ - CoSetFlag(pcell->id); - break; -#endif -#if CFG_QUEUE_EN > 0 - case QUEUE_REQ: /* Queue post request,call handler */ - CoPostQueueMail(pcell->id,pcell->arg); - break; -#endif - default: /* Others,break */ - break; - } - pcell->type = 0; /* Initialize the service request cell*/ - pcell->id = 0; - pcell->arg = 0; - } - ServiceReq.cnt = 0; /* Initialize the service request queue */ -#endif - IsrReq = FALSE; -} - -#endif - diff --git a/GD32F1/libraries/MapleCoOS/utility/OsServiceReq.h b/GD32F1/libraries/MapleCoOS/utility/OsServiceReq.h deleted file mode 100644 index dc78696..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsServiceReq.h +++ /dev/null @@ -1,51 +0,0 @@ - -/** - ******************************************************************************* - * @file serviceReq.h - * @version V1.12 - * @date 2010.03.01 - * @brief Header file related to service request - * @details This file including some defines and function declare related to - * service request. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _SERVICEREQ_H -#define _SERVICEREQ_H - -#if CFG_MAX_SERVICE_REQUEST > 0 -#define SEM_REQ (U8)0x1 -#define MBOX_REQ (U8)0x2 -#define FLAG_REQ (U8)0x3 -#define QUEUE_REQ (U8)0x4 - -typedef struct ServiceReqCell -{ - U8 type; - U8 id; - void* arg; -}SQC,*P_SQC; - -typedef struct ServiceReqQueue -{ - U8 cnt; - SQC cell[CFG_MAX_SERVICE_REQUEST]; -}SRQ,*P_SRQ; - - -extern SRQ ServiceReq; -extern BOOL InsertInSRQ(U8 type,U8 id,void* arg); -#endif - -extern void RespondSRQ(void); -extern BOOL TimeReq; -extern BOOL TimerReq; -extern BOOL IsrReq; -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsTask.c b/GD32F1/libraries/MapleCoOS/utility/OsTask.c deleted file mode 100644 index 73bd9b9..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsTask.c +++ /dev/null @@ -1,1260 +0,0 @@ -/** - ******************************************************************************* - * @file task.c - * @version V1.12 - * @date 2010.03.01 - * @brief task management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - -/*---------------------------- Variable Define -------------------------------*/ - -/*!< Table use to save TCB pointer. */ -OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {{0}}; - -/*!< The stack of IDLE task. */ -OS_STK idle_stk[CFG_IDLE_STACK_SIZE] = {0}; - -P_OSTCB FreeTCB = NULL; /*!< pointer to free TCB */ -P_OSTCB TCBRdy = NULL; /*!< Pointer to the READY list. */ -P_OSTCB TCBNext = NULL; /*!< Poniter to task that next scheduled by OS */ -P_OSTCB TCBRunning = NULL; /*!< Pointer to TCB that current running task. */ -U64 OSCheckTime = 0; /*!< The counter of system tick. */ - -#if CFG_ORDER_LIST_SCHEDULE_EN == 0 -OS_TID PriNum; -U8 ActivePri[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; -U8 TaskNumPerPri[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; -OS_TID RdyTaskPri[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {0}; -U32 RdyTaskPriInfo[(CFG_MAX_USER_TASKS+SYS_TASK_NUM+31)/32]; -#endif - - -/** - ******************************************************************************* - * @brief Create a TCB list. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called by CoOSInit() to initial the empty list - * of OS_TCBS,supply a pointer to free TCB. - ******************************************************************************* - */ -void CreateTCBList(void) -{ - U8 i; - P_OSTCB ptcb1,ptcb2; - -#if CFG_ORDER_LIST_SCHEDULE_EN == 0 - PriNum = 0; -#endif - - ptcb1 = &TCBTbl[0]; /* Build the free TCB list */ - ptcb2 = &TCBTbl[1]; - for(i=0;i< (CFG_MAX_USER_TASKS+SYS_TASK_NUM-1);i++ ) - { - ptcb1->taskID = i; - ptcb1->state = TASK_DORMANT; - ptcb1->TCBnext = ptcb2; -#if CFG_ORDER_LIST_SCHEDULE_EN == 0 - RdyTaskPri[i] = INVALID_ID; - ActivePri[i] = INVALID_ID; -#endif - ptcb1++; - ptcb2++; - } -#if CFG_ORDER_LIST_SCHEDULE_EN == 0 - ActivePri[i] = INVALID_ID; -#endif - - ptcb1->taskID = i; - ptcb1->TCBnext = NULL; - FreeTCB = &TCBTbl[0]; /* Initialize FreeTCB as head item of list */ -} - - - -#if CFG_ORDER_LIST_SCHEDULE_EN == 0 - -/** - ******************************************************************************* - * @brief Get sequence number for Assign priority - * @param[in] pri Assign priority - * @param[out] SequenceNum priority number - * @retval TRUE Assign priority in priority queue. - * FALSE Assign priority not in priority queue. - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to get sequence number for Assign priority. - ******************************************************************************* - */ -static BOOL GetPriSeqNum(U8 pri,OS_TID* SequenceNum) -{ - OS_TID seqNum; - OS_TID num,tmpNum; - num = 0; - seqNum = PriNum; - while(num != seqNum) - { - tmpNum = num; - num = (num+seqNum)/2; - if(pri == ActivePri[num]) - { - *SequenceNum = num; - return TRUE; - } - else if (pri < ActivePri[num]) - { - seqNum = num; - num = tmpNum; - } - else - { - num++; - } - } - *SequenceNum = num; - return FALSE; -} - - -/** - ******************************************************************************* - * @brief Get the nearest ready priority sequence number for Assign number - * @param[in] seqNum Assign sequence number - * @param[out] None - * @retval INVALID_ID Cannot find higher ready priority. - * Others Nearest ready priority sequence number - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to get the nearest ready priority sequence number. - ******************************************************************************* - */ -static U8 GetRdyPriSeqNum(U8 seqNum) -{ - U32 tmp; - U8 i,j,num; - S8 cnt; - i = seqNum/32; - j = seqNum%32; - - do - { - tmp = RdyTaskPriInfo[i]; - if(tmp != 0) - { - num = j/8; - do - { - if((tmp&(0xff<<(num*8))) !=0 ) - { - if((tmp&(0xf0<<(num*8))) !=0) - { - for(cnt=j; cnt >=(num*8+4); cnt--) - { - if( (tmp&(1<=num*8; cnt--) - { - if( (tmp&(1<seqNum;num--) - { - ActivePri[num] = ActivePri[num-1]; - TaskNumPerPri[num] = TaskNumPerPri[num-1]; - RdyTaskPri[num] = RdyTaskPri[num-1]; - } - ActivePri[seqNum] = pri; - TaskNumPerPri[seqNum] = 1; - RdyTaskPri[seqNum] = INVALID_ID; - PriNum++; - PrioRemap(seqNum); - } - else - { - TaskNumPerPri[seqNum]++; - } -} - - - -/** - ******************************************************************************* - * @brief Delete priority in queue - * @param[in] pri Task priority - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to decrease the task num for this priority, if the num goto 0, - * remove the priority for queue. - ******************************************************************************* - */ -static void DeleteTaskPri(U8 pri) -{ - OS_TID seqNum,num; - - GetPriSeqNum(pri,&seqNum); - TaskNumPerPri[seqNum]--; - if(TaskNumPerPri[seqNum]==0) - { - for(num=seqNum; num<(PriNum-1); num++) - { - ActivePri[num] = ActivePri[num+1]; - TaskNumPerPri[num] = TaskNumPerPri[num+1]; - RdyTaskPri[num] = RdyTaskPri[num+1]; - } - PriNum--; - PrioRemap(seqNum); - } -} - -#endif - - -/** - ******************************************************************************* - * @brief Insert a task to the ready list - * @param[in] tcbInsert A pointer to task will be inserted. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to insert a task to the READY list. - ******************************************************************************* - */ -void InsertToTCBRdyList(P_OSTCB tcbInsert) -{ - P_OSTCB ptcbNext,ptcb; - U8 prio; -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - U8 seqNum; - U8 RdyTaskSeqNum; -#endif - - prio = tcbInsert->prio; /* Get PRI of inserted task */ - tcbInsert->state = TASK_READY; /* Set task as TASK_READY */ - -#if CFG_ROBIN_EN >0 - ptcb = TCBRunning; - /* Set schedule time for the same PRI task as TCBRunning. */ - if(prio == ptcb->prio) /* Is PRI of inserted task equal to running task? */ - { - if(ptcb != tcbInsert) /* Yes,is inserted task equal to running task? */ - { - if(ptcb != NULL) /* No,TCBRunning == NULL? */ - { /* N0,OSCheckTime < OSTickCnt? */ - if(OSCheckTime < OSTickCnt) - { /* Yes,set OSCheckTime for task robin */ - OSCheckTime = OSTickCnt + ptcb->timeSlice; - } - } - } - } -#endif - - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - GetPriSeqNum(prio,&seqNum); - if(GetPrioSeqNumStatus(seqNum) == TRUE) - { - ptcb = &TCBTbl[RdyTaskPri[seqNum]]; - RdyTaskPri[seqNum] = tcbInsert->taskID; - } - else - { - RdyTaskPri[seqNum] = tcbInsert->taskID; - RdyTaskSeqNum = GetRdyPriSeqNum(seqNum); - SetPrioSeqNumStatus(seqNum, 1); - if(RdyTaskSeqNum == INVALID_ID) - { - ptcb = TCBRdy; - TaskSchedReq = TRUE; - if(ptcb == NULL) - { - TCBRdy = tcbInsert; - } - else - { - tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */ - ptcb->TCBprev = tcbInsert; - TCBRdy = tcbInsert; - } - return; - } - else - { - ptcb = &TCBTbl[RdyTaskPri[RdyTaskSeqNum]]; - } - } - - ptcbNext = ptcb->TCBnext; - tcbInsert->TCBnext = ptcbNext; /* Set link for list */ - ptcb->TCBnext = tcbInsert; - tcbInsert->TCBprev = ptcb; - if(ptcbNext != NULL) - { - ptcbNext->TCBprev = tcbInsert; - } - - -#else - ptcb = TCBRdy; - if (ptcb == NULL) /* Is ready list NULL? */ - { - TaskSchedReq = TRUE; - TCBRdy = tcbInsert; /* Yse,set tcbInsert as head item of list */ - } - else if (prio < ptcb->prio)/* Is PRI of inserted task higher than TCBRdy? */ - { - TaskSchedReq = TRUE; - tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */ - ptcb->TCBprev = tcbInsert; - TCBRdy = tcbInsert; - } - else /* No,find correct place */ - { - ptcbNext = ptcb->TCBnext; /* Get next item */ - while(ptcbNext != NULL) /* Is last item in ready list? */ - { /* No,find correct place */ - if(prio < ptcbNext->prio) /* Is correct place? */ - break; /* Yes,break circulation */ - ptcb = ptcbNext; /* Save current item */ - ptcbNext = ptcbNext->TCBnext; /* Get next item */ - } - tcbInsert->TCBnext = ptcbNext; /* Set link for list */ - ptcb->TCBnext = tcbInsert; - tcbInsert->TCBprev = ptcb; - if(ptcbNext != NULL) - { - ptcbNext->TCBprev = tcbInsert; - } - } -#endif -} - - - -/** - ******************************************************************************* - * @brief Remove a task from the READY list - * @param[in] ptcb A pointer to task which be removed. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a task from the READY list. - ******************************************************************************* - */ -void RemoveFromTCBRdyList(P_OSTCB ptcb) -{ - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - U8 prio; - U8 seqNum; - BOOL isChange; - isChange = FALSE; - prio = ptcb->prio; - GetPriSeqNum(prio,&seqNum); -#endif - - /* Is there only one item in READY list? */ - if((ptcb->TCBnext == NULL) && (ptcb->TCBprev == NULL) ) - { - TCBRdy = NULL; /* Yes,set READY list as NULL */ -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - isChange = TRUE; -#endif - } - else if(ptcb->TCBprev == NULL) /* Is the first item in READY list? */ - { - /* Yes,remove task from the list,and reset the head of READY list */ - TCBRdy = ptcb->TCBnext; - ptcb->TCBnext = NULL; - TCBRdy->TCBprev = NULL; -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(TCBRdy->prio != prio) - isChange = TRUE; - -#endif - } - else if( ptcb->TCBnext == NULL) /* Is the last item in READY list? */ - { /* Yes,remove task from list */ -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(ptcb->TCBprev->prio != prio) - isChange = TRUE; - else - RdyTaskPri[seqNum] = ptcb->TCBprev->taskID; -#endif - ptcb->TCBprev->TCBnext = NULL; - ptcb->TCBprev = NULL; - } - else /* No, remove task from list */ - { -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if((ptcb->TCBprev->prio != prio) && (ptcb->TCBnext->prio != prio)) - isChange = TRUE; - else if((ptcb->TCBprev->prio == prio) && (ptcb->TCBnext->prio != prio)) - RdyTaskPri[seqNum] = ptcb->TCBprev->taskID; -#endif - ptcb->TCBprev->TCBnext = ptcb->TCBnext; - ptcb->TCBnext->TCBprev = ptcb->TCBprev; - ptcb->TCBnext = NULL; - ptcb->TCBprev = NULL; - } -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(isChange == TRUE) - { - RdyTaskPri[seqNum] = INVALID_ID; - SetPrioSeqNumStatus(seqNum, 0); - } -#endif -} - - -#if CFG_MUTEX_EN > 0 -#define CFG_PRIORITY_SET_EN (1) -#endif -#if CFG_PRIORITY_SET_EN >0 -/** - ******************************************************************************* - * @brief Change task priority - * @param[in] taskID Specify task id. - * @param[in] priority New priority. - * @param[out] None - * @retval E_OK Change priority successful. - * @retval E_INVALID_ID Invalid id,change priority fail. - * @retval E_PROTECTED_TASK Can't change idle task priority. - * - * @par Description - * @details This function is called to change priority for a specify task. - ******************************************************************************* - */ -StatusType CoSetPriority(OS_TID taskID,U8 priority) -{ - P_OSTCB ptcb; -#if CFG_MUTEX_EN >0 - U8 prio; - P_MUTEX pMutex; -#endif -#if CFG_EVENT_EN >0 - P_ECB pecb; -#endif - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; /* Get TCB of task ID */ -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } - if(priority > CFG_LOWEST_PRIO) - { - return E_INVALID_ID; - } -#endif - - if(ptcb->prio != priority) /* Is PRI equal to original PRI? */ - { /* No */ -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) - { - pMutex = &MutexTbl[ptcb->mutexID]; - if(pMutex->taskID == ptcb->taskID) /* Task hold mutex? */ - { - pMutex->originalPrio= priority;/* Yes,change original PRI in mutex*/ - if(ptcb->prio < priority) /* Is task priority higher than set?*/ - { - return E_OK; /* Yes,do nothing,return OK */ - } - } - } - -#endif - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - DeleteTaskPri(ptcb->prio); - ActiveTaskPri(priority); -#endif - - ptcb->prio = priority; /* Change task PRI */ - if(ptcb->state == TASK_READY) /* Is task in READY list? */ - { - OsSchedLock(); /* Yes,reorder task in READY list */ - RemoveFromTCBRdyList(ptcb); - InsertToTCBRdyList(ptcb); - OsSchedUnlock(); - } - else if(ptcb->state == TASK_RUNNING)/* Is task running? */ - { - if(ptcb->prio > TCBRdy->prio) /* Yes,Is PRI higher than TCBRdy? */ - { - OsSchedLock(); /* Yes,reorder task in READY list */ - TaskSchedReq = TRUE; - OsSchedUnlock(); - } - } - else - { /* No,task in WAITING list */ -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex WAITING list? */ - { - /* Yes,reset the highest PRI in the list */ - OsSchedLock(); - pMutex = &MutexTbl[ptcb->mutexID]; - ptcb = pMutex->waittingList; - prio = pMutex->originalPrio; - pMutex->hipriTaskID = pMutex->taskID; - while(ptcb != NULL) - { - if(ptcb->prio < prio) - { - prio = ptcb->prio; - pMutex->hipriTaskID = ptcb->taskID; - } - ptcb = ptcb->TCBnext; - } - OsSchedUnlock(); - if(pMutex->originalPrio != prio) - { - CoSetPriority(pMutex->taskID,prio); - } - } -#endif - -#if CFG_EVENT_EN >0 - ptcb = &TCBTbl[taskID]; - if(ptcb->eventID != INVALID_ID) /* Is task in event WAITING list? */ - { - pecb = &EventTbl[ptcb->eventID]; - - /* Yes,is event sort type as preemptive PRI? */ - if(pecb->eventSortType == EVENT_SORT_TYPE_PRIO) - { - /* Yes,reorder task in the list */ - RemoveEventWaittingList(ptcb); - EventTaskToWait(pecb,ptcb); - } - } -#endif - } - } - return E_OK; -} -#endif - -/** - ******************************************************************************* - * @brief Schedule function - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called by every where need to switch context, - * It is schedule function of OS kernel. - ******************************************************************************* - */ -void Schedule(void) -{ - U8 RunPrio,RdyPrio; - P_OSTCB pRdyTcb,pCurTcb; - - - pCurTcb = TCBRunning; - pRdyTcb = TCBRdy; - - if((pRdyTcb==NULL) || (pCurTcb != TCBNext) || (OSSchedLock >1) || (OSIntNesting >0)) - { - return; - } - - TaskSchedReq = FALSE; - RunPrio = pCurTcb->prio; - RdyPrio = pRdyTcb->prio; - - /* Is Running task status was changed? */ - if(pCurTcb->state != TASK_RUNNING) - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - pRdyTcb->state = TASK_RUNNING; - RemoveFromTCBRdyList(pRdyTcb); - } - - else if(RdyPrio < RunPrio ) /* Is higher PRI task coming in? */ - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - InsertToTCBRdyList(pCurTcb); - RemoveFromTCBRdyList(pRdyTcb); - pRdyTcb->state = TASK_RUNNING; - } - -#if CFG_ROBIN_EN >0 /* Is time for robinning */ - else if((RunPrio == RdyPrio) && (OSCheckTime == OSTickCnt)) - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - InsertToTCBRdyList(pCurTcb); - RemoveFromTCBRdyList(pRdyTcb); - pRdyTcb->state = TASK_RUNNING; - } -#endif - else - { - return; - } - -#if CFG_ROBIN_EN >0 - if(TCBNext->prio == TCBRdy->prio) /* Reset OSCheckTime for task robinnig */ - OSCheckTime = OSTickCnt + TCBNext->timeSlice; -#endif - - -#if CFG_STK_CHECKOUT_EN > 0 /* Is stack overflow? */ - if((pCurTcb->stkPtr < pCurTcb->stack)||(*(U32*)(pCurTcb->stack) != MAGIC_WORD)) - { - CoStkOverflowHook(pCurTcb->taskID); /* Yes,call handler */ - } -#endif - - SwitchContext(); /* Call task context switch */ -} - - -/** - ******************************************************************************* - * @brief Assign a TCB to task being created - * @param[in] None - * @param[out] None - * - * @retval XXXX - * - * @par Description - * @details This function is called to assign a task control block for task - * being created. - ******************************************************************************* - */ -static P_OSTCB AssignTCB(void) -{ - P_OSTCB ptcb; - - OsSchedLock(); /* Lock schedule */ - if(FreeTCB == NULL) /* Is there no free TCB */ - { - OsSchedUnlock(); /* Yes,unlock schedule */ - return NULL; /* Error return */ - } - ptcb = FreeTCB; /* Yes,assgin free TCB for this task */ - /* Set next item as the head of free TCB list */ - FreeTCB = FreeTCB->TCBnext; - OsSchedUnlock(); - return ptcb; -} - - -/** - ******************************************************************************* - * @brief Create a task - * @param[in] task Task code entry. - * @param[in] argv The parameter passed to task. - * @param[in] parameter Task priority + stack size + time slice + isWaitting. - * @param[in] stk Pointer to stack top of task. - * @param[out] None - * @retval E_CREATE_FAIL Fail to create a task . - * @retval others Valid task id. - * - * @par Description - * @details This function is called by application to create a task,return a id - * to mark this task. - ******************************************************************************* - */ -OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk) -{ - OS_STK* stkTopPtr; - P_OSTCB ptcb; - U8 prio; -#if CFG_ROBIN_EN >0 - U16 timeSlice; -#endif - -#if CFG_STK_CHECKOUT_EN >0 /* Check validity of parameter */ - U16 sktSz; - sktSz = (parameter&0xfff00)>>8; -#endif - prio = parameter&0xff; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(task == NULL) - { - return E_CREATE_FAIL; - } - if(stk == NULL) - { - return E_CREATE_FAIL; - } - if(prio > CFG_LOWEST_PRIO) - { - return E_CREATE_FAIL; - } -#if CFG_STK_CHECKOUT_EN >0 - if(sktSz < 20) - { - return E_CREATE_FAIL; - } -#endif // CFG_STK_CHECKOUT_EN -#endif // CFG_PAR_CHECKOUT_EN - -#if CFG_TASK_SCHEDULE_EN == 0 - if(TCBRunning != NULL) - return E_CREATE_FAIL; -#endif - - stkTopPtr = InitTaskContext(task,argv,stk); /* Initialize task context. */ - - ptcb = AssignTCB(); /* Get free TCB to use */ - - if(ptcb == NULL) /* Is free TCB equal to NULL? */ - { - return E_CREATE_FAIL; /* Yes,error return */ - } - - ptcb->stkPtr = stkTopPtr; /* Initialize TCB as user set */ - ptcb->prio = prio; -#if CFG_STK_CHECKOUT_EN >0 - ptcb->stack = stk+1 - sktSz; /* Set bottom stack for stack overflow check */ - *(U32*)(ptcb->stack) = MAGIC_WORD; -#endif - -#if CFG_TASK_WAITTING_EN >0 - ptcb->delayTick = INVALID_VALUE; -#endif - -#if CFG_TASK_SCHEDULE_EN == 0 - ptcb->taskFuc = task; - ptcb->taskStk = stk; -#endif - ptcb->TCBnext = NULL; /* Initialize TCB link in READY list */ - ptcb->TCBprev = NULL; - -#if CFG_ROBIN_EN >0 /* Set task time slice for task robin */ - timeSlice = (parameter&0x7fff0000)>>20; - if(timeSlice == 0) - { - timeSlice = CFG_TIME_SLICE; - } - ptcb->timeSlice = timeSlice; -#endif - -#if CFG_FLAG_EN > 0 - ptcb->pnode = NULL; /* Initialize task as no flag waiting */ -#endif - -#if CFG_EVENT_EN > 0 - ptcb->eventID = INVALID_ID; /* Initialize task as no event waiting*/ - ptcb->pmail = NULL; - ptcb->waitNext = NULL; - ptcb->waitPrev = NULL; -#endif - -#if CFG_MUTEX_EN > 0 - /* Initialize task as no mutex holding or waiting */ - ptcb->mutexID = INVALID_ID; -#endif - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - ActiveTaskPri(prio); -#endif - - if((parameter>>31) == 0) /* Is task in waitting state? */ - { /* No,set it into ready list */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert into the READY list */ - OsSchedUnlock(); /* Unlock schedule */ - } - else - { /* Yes,Set task status as TASK_WAITING*/ - ptcb->state = TASK_WAITING; - } - return ptcb->taskID; /* Return task ID */ -} - - -/** - ******************************************************************************* - * @brief Delete Task - * @param[in] taskID Task ID - * @param[out] None - * @retval E_INVALID_ID Invalid task ID. - * @retval E_PROTECTED_TASK Protected task in OS. - * @retval E_OK Delete successful. - * - * @par Description - * @details This function is called to delete assign task. - ******************************************************************************* - */ -StatusType CoDelTask(OS_TID taskID) -{ - P_OSTCB ptcb; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } - - if(ptcb->state == TASK_RUNNING) /* Is task running? */ - { - if(OSSchedLock != 0) /* Yes,is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - } - -#if CFG_MUTEX_EN >0 /* Do task hold mutex? */ - if(ptcb->mutexID != INVALID_ID) - { - if(MutexTbl[ptcb->mutexID].taskID == ptcb->taskID) - { /* Yes,leave the mutex */ - CoLeaveMutexSection(ptcb->mutexID); - } - } - -#endif - - OsSchedLock(); /* Lock schedule */ - - if(ptcb->state == TASK_READY) /* Is task in READY list? */ - { - RemoveFromTCBRdyList(ptcb); /* Yes,remove task from the READY list*/ - } - -#if CFG_TASK_WAITTING_EN > 0 - else if(ptcb->state == TASK_WAITING)/* Is task in the WAITING list? */ - { - /* Yes,Is task in delay list? */ - if(ptcb->delayTick != INVALID_VALUE) - { - RemoveDelayList(ptcb); /* Yes,remove task from READY list */ - } - -#if CFG_EVENT_EN > 0 - if(ptcb->eventID != INVALID_ID) /* Is task in event waiting list? */ - { - /* Yes,remove task from event waiting list */ - RemoveEventWaittingList(ptcb); - } -#endif - -#if CFG_FLAG_EN > 0 - if(ptcb->pnode != NULL) /* Is task in flag waiting list? */ - { - /* Yes,remove task from flag waiting list */ - RemoveLinkNode(ptcb->pnode); - } -#endif - -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex waiting list? */ - { - RemoveMutexList(ptcb); /* Yes,remove task from mutex waiting list*/ - } -#endif - } -#endif - ptcb->state = TASK_DORMANT; /* Release TCB */ - TaskSchedReq = TRUE; - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - DeleteTaskPri(ptcb->prio); -#endif - -#if CFG_TASK_SCHEDULE_EN >0 - ptcb->TCBnext = FreeTCB; - FreeTCB = ptcb; -#endif - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; /* return OK */ -} - - -/** - ******************************************************************************* - * @brief Exit Task - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to exit current task. - ******************************************************************************* - */ -void CoExitTask(void) -{ - CoDelTask(TCBRunning->taskID); /* Call task delete function */ -} - - -#if CFG_TASK_SCHEDULE_EN ==0 -/** - ******************************************************************************* - * @brief Activate Task - * @param[in] taskID Task ID - * @param[in] argv Task argv - * @param[out] None - * @retval E_INVALID_ID Invalid task ID. - * @retval E_OK Activate task successful. - * - * @par Description - * @details This function is called to activate current task. - ******************************************************************************* - */ -StatusType CoActivateTask(OS_TID taskID,void *argv) -{ - P_OSTCB ptcb; - OS_STK* stkTopPtr; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->stkPtr == NULL) - return E_INVALID_ID; -#endif - if(ptcb->state != TASK_DORMANT) - return E_OK; - - - /* Initialize task context. */ - stkTopPtr = InitTaskContext(ptcb->taskFuc,argv,ptcb->taskStk); - - ptcb->stkPtr = stkTopPtr; /* Initialize TCB as user set */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert into the READY list */ - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; -} -#endif - - -/** - ******************************************************************************* - * @brief Get current task id - * @param[in] None - * @param[out] None - * @retval ID of the current task. - * - * @par Description - * @details This function is called to get current task id. - ******************************************************************************* - */ -OS_TID CoGetCurTaskID(void) -{ - return (TCBRunning->taskID); /* Return running task ID */ -} - -#if CFG_TASK_SUSPEND_EN >0 -/** - ******************************************************************************* - * @brief Suspend Task - * @param[in] taskID ID of task that want to suspend. - * @param[out] None - * @retval E_OK Task suspend successful. - * @retval E_INVALID_ID Invalid event ID. - * @retval E_PROTECTED_TASK Can't suspend idle task. - * @retval E_ALREADY_IN_WAITING Task now in waiting state. - - * - * @par Description - * @details This function is called to exit current task. - ******************************************************************************* - */ -StatusType CoSuspendTask(OS_TID taskID) -{ - P_OSTCB ptcb; - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - if(OSSchedLock != 0) - { - return E_OS_IN_LOCK; - } - if(ptcb->state == TASK_WAITING) /* Is task in WAITING list? */ - { - return E_ALREADY_IN_WAITING; /* Yes,error return */ - } - - OsSchedLock(); - if(ptcb != TCBRunning) /* Is runing task? */ - { - RemoveFromTCBRdyList(ptcb); /* No,Remove task from READY list */ - } - else - { - TaskSchedReq = TRUE; - } - - ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */ - OsSchedUnlock(); /* Call task schedule */ - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Awake Task - * @param[in] taskID ID of task that will been awaked. - * @param[out] None - * @retval E_OK Task awake successful. - * @retval E_INVALID_ID Invalid task ID. - * @retval E_TASK_NOT_WAITING Task now not in waiting state. - * @retval E_TASK_WAIT_OTHER Task now waiting other awake event. - * @retval E_PROTECTED_TASK Idle task mustn't be awaked. - * - * @par Description - * @details This function is called to awake current task. - ******************************************************************************* - */ -StatusType CoAwakeTask(OS_TID taskID) -{ - P_OSTCB ptcb; - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - - if(ptcb->state != TASK_WAITING) /* Is task in WAITING list */ - { - return E_TASK_NOT_WAITING; /* No,error return */ - } - -#if CFG_TASK_WAITTING_EN > 0 - if(ptcb->delayTick != INVALID_VALUE)/* Is task in READY list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } - -#if CFG_FLAG_EN > 0 - if(ptcb->pnode != NULL) /* Is task in flag waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#if CFG_EVENT_EN>0 - if(ptcb->eventID != INVALID_ID) /* Is task in event waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#if CFG_MUTEX_EN > 0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#endif //CFG_TASK_WAITTING_EN - - /* All no,so WAITING state was set by CoSuspendTask() */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert the task into the READY list*/ - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; /* return OK */ -} -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsTask.h b/GD32F1/libraries/MapleCoOS/utility/OsTask.h deleted file mode 100644 index 14e77ad..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsTask.h +++ /dev/null @@ -1,112 +0,0 @@ -/** - ******************************************************************************* - * @file task.h - * @version V1.12 - * @date 2010.03.01 - * @brief Header file related to task. - * @details This file including some defines and function declare related to task. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - -#ifndef _TASK_H -#define _TASK_H - -#define SYS_TASK_NUM (1) /*!< System task number. */ - -/*---------------------------- Task Status -----------------------------------*/ -#define TASK_READY 0 /*!< Ready status of task. */ -#define TASK_RUNNING 1 /*!< Running status of task. */ -#define TASK_WAITING 2 /*!< Waitting status of task. */ -#define TASK_DORMANT 3 /*!< Dormant status of task. */ - - -#define INVALID_ID (U8)0xff -#define INVALID_VALUE (U32)0xffffffff -#define MAGIC_WORD (U32)0x5a5aa5a5 - - -/** - * @struct TCB task.h - * @brief Task control blcok. - * @details This struct use to manage task. - */ -typedef struct TCB -{ - OS_STK *stkPtr; /*!< The current point of task. */ - U8 prio; /*!< Task priority. */ - U8 state; /*!< TaSk status. */ - OS_TID taskID; /*!< Task ID. */ - -#if CFG_MUTEX_EN > 0 - OS_MutexID mutexID; /*!< Mutex ID. */ -#endif - -#if CFG_EVENT_EN > 0 - OS_EventID eventID; /*!< Event ID. */ -#endif - -#if CFG_ROBIN_EN >0 - U16 timeSlice; /*!< Task time slice */ -#endif - -#if CFG_STK_CHECKOUT_EN >0 - OS_STK *stack; /*!< The top point of task. */ -#endif - -#if CFG_EVENT_EN > 0 - void* pmail; /*!< Mail to task. */ - struct TCB *waitNext; /*!< Point to next TCB in the Event waitting list.*/ - struct TCB *waitPrev; /*!< Point to prev TCB in the Event waitting list.*/ -#endif - -#if CFG_TASK_SCHEDULE_EN == 0 - FUNCPtr taskFuc; - OS_STK *taskStk; -#endif - - -#if CFG_FLAG_EN > 0 - void* pnode; /*!< Pointer to node of event flag. */ -#endif - -#if CFG_TASK_WAITTING_EN >0 - U32 delayTick; /*!< The number of ticks which delay. */ -#endif - struct TCB *TCBnext; /*!< The pointer to next TCB. */ - struct TCB *TCBprev; /*!< The pointer to prev TCB. */ - -}OSTCB,*P_OSTCB; - - -/*---------------------------- Variable declare ------------------------------*/ -// save tcb ptr that created -extern P_OSTCB FreeTCB; /*!< A pointer to free TCB. */ -extern OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; -extern P_OSTCB TCBRdy; /*!< A pointer to TCB that is ready status */ -extern P_OSTCB TCBNext; /*!< A pointer to TCB next be scheduled. */ -extern P_OSTCB TCBRunning; /*!< A pointer to TCB that is running. */ - -extern U64 OSCheckTime; -extern U8 OSIntNesting; /*!< Use to indicate interrupt nesting level. */ -extern U8 OSSchedLock; /*!< Schedule is lock(LOCK) or unlock(UN_LOCK). */ -extern BOOL TaskSchedReq; -extern OS_STK idle_stk[CFG_IDLE_STACK_SIZE]; - - -void Schedule(void); /*!< Schedule function */ -void IdleTask(void* pdata); /*!< IDLE task code */ -void InsertToTCBRdyList (P_OSTCB tcbInser); -void RemoveFromTCBRdyList(P_OSTCB ptcb); -void CreateTCBList(void); -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 -void ActiveTaskPri(U8 pri); -void DeleteTaskPri(U8 pri); -#endif - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsTime.c b/GD32F1/libraries/MapleCoOS/utility/OsTime.c deleted file mode 100644 index 4a431a0..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsTime.c +++ /dev/null @@ -1,376 +0,0 @@ -/** - ******************************************************************************* - * @file time.c - * @version V1.12 - * @date 2010.03.01 - * @brief time management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if CFG_TASK_WAITTING_EN > 0 - -/*---------------------------- Variable Define -------------------------------*/ -P_OSTCB DlyList = NULL; /*!< Header pointer to the DELAY list.*/ - - -/** - ******************************************************************************* - * @brief Insert into DELAY list - * - * @param[in] ptcb Task that want to insert into DELAY list. - * @param[in] ticks Delay system ticks. - * @param[out] None - * @retval None. - * - * @par Description - * @details This function is called to insert task into DELAY list. - ******************************************************************************* - */ -void InsertDelayList(P_OSTCB ptcb,U32 ticks) -{ - S32 deltaTicks; - P_OSTCB dlyNext; - - if(ticks == 0) /* Is delay tick == 0? */ - return; /* Yes,do nothing,return */ - if(DlyList == NULL) /* Is no item in DELAY list? */ - { - ptcb->delayTick = ticks; /* Yes,set this as first item */ - DlyList = ptcb; - } - else - { - /* No,find correct place ,and insert the task */ - dlyNext = DlyList; - deltaTicks = ticks; /* Get task delay ticks */ - - /* Find correct place */ - while(dlyNext != NULL) - { - /* Get delta ticks with previous item */ - deltaTicks -= dlyNext->delayTick; - if(deltaTicks < 0) /* Is delta ticks<0? */ - { - /* Yes,get correct place */ - if(dlyNext->TCBprev != NULL) /* Is head item of DELAY list? */ - { - dlyNext->TCBprev->TCBnext = ptcb; /* No,insert into */ - ptcb->TCBprev = dlyNext->TCBprev; - ptcb->TCBnext = dlyNext; - dlyNext->TCBprev = ptcb; - } - else /* Yes,set task as first item */ - { - ptcb->TCBnext = DlyList; - DlyList->TCBprev = ptcb; - DlyList = ptcb; - } - ptcb->delayTick = ptcb->TCBnext->delayTick+deltaTicks; - ptcb->TCBnext->delayTick -= ptcb->delayTick; - break; - } - /* Is last item in DELAY list? */ - else if((deltaTicks >= 0) && (dlyNext->TCBnext == NULL) ) - { - ptcb->TCBprev = dlyNext; /* Yes,insert into */ - dlyNext->TCBnext = ptcb; - ptcb->delayTick = deltaTicks; - break; - } - dlyNext = dlyNext->TCBnext; /* Get the next item in DELAY list */ - } - } - - ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */ - TaskSchedReq = TRUE; -} - - -/** - ******************************************************************************* - * @brief Remove from the DELAY list - * @param[in] ptcb Task that want to remove from the DELAY list. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove task from the DELAY list. - ******************************************************************************* - */ -void RemoveDelayList(P_OSTCB ptcb) -{ - - /* Is there only one item in the DELAY list? */ - if((ptcb->TCBprev == NULL) && ( ptcb->TCBnext == NULL)) - { - DlyList = NULL; /* Yes,set DELAY list as NULL */ - } - else if(ptcb->TCBprev == NULL) /* Is the first item in DELAY list? */ - { - /* Yes,remove task from the DELAY list,and reset the list */ - DlyList = ptcb->TCBnext; - ptcb->TCBnext->delayTick += ptcb->delayTick; - ptcb->TCBnext->TCBprev = NULL; - ptcb->TCBnext = NULL; - - } - else if(ptcb->TCBnext == NULL) /* Is the last item in DELAY list? */ - { - ptcb->TCBprev->TCBnext = NULL; /* Yes,remove task form DELAY list */ - ptcb->TCBprev = NULL; - } - else /* No, remove task from DELAY list */ - { - ptcb->TCBprev->TCBnext = ptcb->TCBnext; - ptcb->TCBnext->TCBprev = ptcb->TCBprev; - ptcb->TCBnext->delayTick += ptcb->delayTick; - ptcb->TCBnext = NULL; - ptcb->TCBprev = NULL; - } - ptcb->delayTick = INVALID_VALUE; /* Set task delay tick value as invalid */ -} - -/** - ******************************************************************************* - * @brief Get current ticks - * @param[in] None - * @param[out] None - * @retval Return current system tick counter. - * - * @par Description - * @details This function is called to obtain current system tick counter. - ******************************************************************************* - */ -U64 CoGetOSTime(void) -{ - return OSTickCnt; /* Get system time(tick) */ -} - - -/** - ******************************************************************************* - * @brief Delay current task for specify ticks number - * @param[in] ticks Specify system tick number which will delay. - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_OK The current task was insert to DELAY list successful,it - * will delay specify time. - * @par Description - * @details This function delay specify ticks for current task. - * - * @note This function be called in ISR,do nothing and return immediately. - ******************************************************************************* - */ -StatusType CoTickDelay(U32 ticks) -{ - if(OSIntNesting >0) /* Is call in ISR? */ - { - return E_CALL; /* Yes,error return */ - } - - if(ticks == INVALID_VALUE) /* Is tick==INVALID_VALUE? */ - { - return E_INVALID_PARAMETER; /* Yes,error return */ - } - if(ticks == 0) /* Is tick==0? */ - { - return E_OK; /* Yes,do nothing ,return OK */ - } - if(OSSchedLock != 0) /* Is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - OsSchedLock(); /* Lock schedule */ - InsertDelayList(TCBRunning,ticks); /* Insert task in DELAY list */ - OsSchedUnlock(); /* Unlock schedule,and call task schedule */ - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Reset task delay ticks - * @param[in] ptcb Task that want to insert into DELAY list. - * @param[in] ticks Specify system tick number which will delay . - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_INVALID_ID Invalid task id. - * @retval E_NOT_IN_DELAY_LIST Task not in delay list. - * @retval E_OK The current task was inserted to DELAY list - * successful,it will delay for specify time. - * @par Description - * @details This function delay specify ticks for current task. - ******************************************************************************* - */ -StatusType CoResetTaskDelayTick(OS_TID taskID,U32 ticks) -{ - P_OSTCB ptcb; - - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->stkPtr == NULL) - { - return E_INVALID_ID; - } -#endif - - if(ptcb->delayTick == INVALID_VALUE) /* Is tick==INVALID_VALUE? */ - { - return E_NOT_IN_DELAY_LIST; /* Yes,error return */ - } - OsSchedLock(); /* Lock schedule */ - RemoveDelayList(ptcb); /* Remove task from the DELAY list */ - - if(ticks == 0) /* Is delay tick==0? */ - { - InsertToTCBRdyList(ptcb); /* Insert task into the DELAY list */ - } - else - { - InsertDelayList(ptcb,ticks); /* No,insert task into DELAY list */ - } - OsSchedUnlock(); /* Unlock schedule,and call task schedule */ - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Delay current task for detail time - * @param[in] hour Specify the number of hours. - * @param[in] minute Specify the number of minutes. - * @param[in] sec Specify the number of seconds. - * @param[in] millsec Specify the number of millseconds. - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_INVALID_PARAMETER Parameter passed was invalid,delay fail. - * @retval E_OK The current task was inserted to DELAY list - * successful,it will delay for specify time. - * @par Description - * @details This function delay specify time for current task. - * - * @note If this function called in ISR,do nothing and return immediately. - ******************************************************************************* - */ -#if CFG_TIME_DELAY_EN >0 -StatusType CoTimeDelay(U8 hour,U8 minute,U8 sec,U16 millsec) -{ - U32 ticks; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(OSIntNesting > 0) - { - return E_CALL; - } - if((minute > 59)||(sec > 59)||(millsec > 999)) - return E_INVALID_PARAMETER; -#endif - if(OSSchedLock != 0) /* Is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - - /* Get tick counter from time */ - ticks = ((hour*3600) + (minute*60) + (sec)) * (CFG_SYSTICK_FREQ)\ - + (millsec*CFG_SYSTICK_FREQ + 500)/1000; - - CoTickDelay(ticks); /* Call tick delay */ - return E_OK; /* Return OK */ -} -#endif - - - - -/** - ******************************************************************************* - * @brief Dispose time delay - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to dispose time delay of all task. - ******************************************************************************* - */ -void TimeDispose(void) -{ - P_OSTCB dlyList; - - dlyList = DlyList; /* Get first item of DELAY list */ - while((dlyList != NULL) && (dlyList->delayTick == 0) ) - { - -#if CFG_EVENT_EN > 0 - if(dlyList->eventID != INVALID_ID) /* Is task in event waiting list? */ - { - RemoveEventWaittingList(dlyList); /* Yes,remove task from list */ - } -#endif - -#if CFG_FLAG_EN > 0 - if(dlyList->pnode != NULL) /* Is task in flag waiting list? */ - { - RemoveLinkNode(dlyList->pnode); /* Yes,remove task from list */ - } -#endif - dlyList->delayTick = INVALID_VALUE; /* Set delay tick value as invalid*/ - DlyList = dlyList->TCBnext; /* Get next item as the head of DELAY list*/ - dlyList->TCBnext = NULL; - - InsertToTCBRdyList(dlyList); /* Insert task into READY list */ - - dlyList = DlyList; /* Get the first item of DELAY list */ - if(dlyList != NULL) /* Is DELAY list as NULL? */ - { - dlyList->TCBprev = NULL; /* No,initialize the first item */ - } - } -} - - -/** - ******************************************************************************* - * @brief Dispose time delay in ISR - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in systick interrupt to dispose time delay - * of all task. - ******************************************************************************* - */ -void isr_TimeDispose(void) -{ - if(OSSchedLock > 1) /* Is schedule lock? */ - { - IsrReq = TRUE; - TimeReq = TRUE; /* Yes,set time request true */ - } - else - { - TimeDispose(); /* No,call handler */ - } -} - - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsTime.h b/GD32F1/libraries/MapleCoOS/utility/OsTime.h deleted file mode 100644 index 43624e8..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsTime.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - ******************************************************************************* - * @file task.c - * @version V1.12 - * @date 2010.03.01 - * @brief Header file related to time management - * @details Thie file including some data declare related to time managment. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - -#ifndef _TIME_H -#define _TIME_H - -/*---------------------------- Variable declare ------------------------------*/ -extern P_OSTCB DlyList; /*!< A pointer to ther delay list. */ - -/*---------------------------- Function declare ------------------------------*/ -extern void TimeDispose(void); /*!< Time dispose function. */ -extern void isr_TimeDispose(void); -extern void RemoveDelayList(P_OSTCB ptcb); -extern void InsertDelayList(P_OSTCB ptcb,U32 ticks); -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsTimer.c b/GD32F1/libraries/MapleCoOS/utility/OsTimer.c deleted file mode 100644 index 836313d..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsTimer.c +++ /dev/null @@ -1,447 +0,0 @@ -/** - ******************************************************************************* - * @file timer.c - * @version V1.12 - * @date 2010.03.01 - * @brief timer management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - -/*---------------------------- Variable Define -------------------------------*/ -#if CFG_TMR_EN > 0 - -TmrCtrl TmrTbl[CFG_MAX_TMR]= {{0}};/*!< Table which save timer control block.*/ -P_TmrCtrl TmrList = NULL; /*!< The header of the TmrCtrl list. */ -U32 TmrIDVessel = 0; /*!< Timer ID container. */ - - -/** - ******************************************************************************* - * @brief Insert a timer into the timer list - * @param[in] tmrID Specify timer ID which insertted. - * @param[out] None - * @retval E_INVALID_ID Timer ID passed was invalid,insert fail. - * @retval E_OK Insert successful. - * - * @par Description - * @details This function is called to insert a timer into the timer list. - ******************************************************************************* - */ -static void InsertTmrList(OS_TCID tmrID) -{ - P_TmrCtrl pTmr; - S32 deltaTicks; - U32 tmrCnt; - tmrCnt = TmrTbl[tmrID].tmrCnt; /* Get timer time */ - - if(tmrCnt == 0) /* Is timer time==0? */ - { - return; /* Do nothing,return */ - } - - OsSchedLock(); /* Lock schedule */ - if(TmrList == NULL) /* Is no item in timer list? */ - { - TmrList = &TmrTbl[tmrID]; /* Yes,set this as first item */ - } - else /* No,find correct place ,and insert inserted timer */ - { - pTmr = TmrList; - deltaTicks = tmrCnt; /* Get timer tick */ - - /* find correct place */ - while(pTmr != NULL) - { - deltaTicks -= pTmr->tmrCnt; /* Get ticks with previous item */ - if(deltaTicks < 0) /* Is delta ticks<0? */ - { - /* Yes,get correct place */ - if(pTmr->tmrPrev!= NULL)/* Is head item of timer list? */ - { - /* No,insert into */ - pTmr->tmrPrev->tmrNext = &TmrTbl[tmrID]; - TmrTbl[tmrID].tmrPrev = pTmr->tmrPrev; - TmrTbl[tmrID].tmrNext = pTmr; - pTmr->tmrPrev = &TmrTbl[tmrID]; - } - else /* Yes,set task as first item */ - { - TmrTbl[tmrID].tmrNext = TmrList; - TmrList->tmrPrev = &TmrTbl[tmrID]; - TmrList = &TmrTbl[tmrID]; - } - TmrTbl[tmrID].tmrCnt = TmrTbl[tmrID].tmrNext->tmrCnt+deltaTicks; - TmrTbl[tmrID].tmrNext->tmrCnt -= TmrTbl[tmrID].tmrCnt; - break; - } - /* Is last item in list? */ - else if((deltaTicks >= 0) && (pTmr->tmrNext == NULL)) - { - /* Yes,insert into */ - TmrTbl[tmrID].tmrPrev = pTmr; - pTmr->tmrNext = &TmrTbl[tmrID]; - TmrTbl[tmrID].tmrCnt = deltaTicks; - break; - } - pTmr = pTmr->tmrNext; /* Get the next item in timer list */ - } - } - OsSchedUnlock(); /* Unlock schedule */ -} - - -/** - ******************************************************************************* - * @brief Remove a timer from the timer list - * @param[in] tmrID Specify ID for a timer which removed form timer list. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a timer from the timer list. - ******************************************************************************* - */ -static void RemoveTmrList(OS_TCID tmrID) -{ - P_TmrCtrl pTmr; - - pTmr = &TmrTbl[tmrID]; - - OsSchedLock(); /* Lock schedule */ - - /* Is there only one item in timer list? */ - if((pTmr->tmrPrev == NULL) && (pTmr->tmrNext == NULL)) - { - TmrList = NULL; /* Yes,set timer list as NULL */ - } - else if(pTmr->tmrPrev == NULL) /* Is the first item in timer list? */ - { /* Yes,remove timer from list,and reset timer list */ - TmrList = pTmr->tmrNext; - TmrList->tmrPrev = NULL; - pTmr->tmrNext->tmrCnt += pTmr->tmrCnt; - pTmr->tmrNext = NULL; - } - else if(pTmr->tmrNext == NULL) /* Is the last item in timer list? */ - { - /* Yes,remove timer form list */ - pTmr->tmrPrev->tmrNext = NULL; - pTmr->tmrPrev = NULL; - } - else /* No, remove timer from list */ - { - pTmr->tmrPrev->tmrNext = pTmr->tmrNext; - pTmr->tmrNext->tmrPrev = pTmr->tmrPrev; - pTmr->tmrNext->tmrCnt += pTmr->tmrCnt; - pTmr->tmrNext = NULL; - pTmr->tmrPrev = NULL; - } - OsSchedUnlock(); /* Unlock schedule */ -} - - -/** - ******************************************************************************* - * @brief Create a timer - * @param[in] tmrType Specify timer's type. - * @param[in] tmrCnt Specify timer initial counter value. - * @param[in] tmrReload Specify timer reload value. - * @param[in] func Specify timer callback function entry. - * @param[out] None - * @retval E_CREATE_FAIL Create timer fail. - * @retval others Create timer successful. - * - * @par Description - * @details This function is called to create a timer. - ******************************************************************************* - */ -OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func) -{ - U8 i; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if((tmrType != TMR_TYPE_ONE_SHOT) && (tmrType != TMR_TYPE_PERIODIC)) - { - return E_CREATE_FAIL; - } - if(func == NULL) - { - return E_CREATE_FAIL; - } -#endif - OsSchedLock(); /* Lock schedule */ - for(i = 0; i < CFG_MAX_TMR; i++) - { - if((TmrIDVessel & (1 << i)) == 0) /* Is free timer ID? */ - { - TmrIDVessel |= (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - return E_INVALID_ID; - } - if( (TmrIDVessel & (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - return E_INVALID_ID; - } - if((TmrIDVessel & (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - return E_INVALID_ID; - } - if( (TmrIDVessel & (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - *perr = E_INVALID_ID; - return 0; - } - if((TmrIDVessel & (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - return E_INVALID_ID; - } - if( (TmrIDVessel & (1<tmrCnt == 0) ) - { - if(pTmr->tmrType == TMR_TYPE_ONE_SHOT) /* Is a One-shot timer? */ - { - /* Yes,remove this timer from timer list */ - RemoveTmrList(pTmr->tmrID); - - /* Set timer status as TMR_STATE_STOPPED */ - pTmr->tmrState = TMR_STATE_STOPPED; - (pTmr->tmrCallBack)(); /* Call timer callback function */ - } - else if(pTmr->tmrType == TMR_TYPE_PERIODIC) /* Is a periodic timer? */ - { - /* Yes,remove this timer from timer list */ - RemoveTmrList(pTmr->tmrID); - pTmr->tmrCnt = pTmr->tmrReload; /* Reset timer tick */ - InsertTmrList(pTmr->tmrID); /* Insert timer into timer list */ - (pTmr->tmrCallBack)(); /* Call timer callback function */ - } - pTmr = TmrList; /* Get first item of timer list */ - } -} - - -/** - ******************************************************************************* - * @brief Timer counter dispose in ISR - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to dispose timer counter. - ******************************************************************************* - */ -void isr_TmrDispose(void) -{ - if(OSSchedLock > 1) /* Is schedule lock? */ - { - IsrReq = TRUE; - TimerReq = TRUE; /* Yes,set timer request true */ - } - else - { - TmrDispose(); /* No,call handler */ - } -} - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsTimer.h b/GD32F1/libraries/MapleCoOS/utility/OsTimer.h deleted file mode 100644 index 202e8aa..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsTimer.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - ******************************************************************************* - * @file timer.h - * @version V1.12 - * @date 2010.03.01 - * @brief Timer manage header file - * @details This file including some declares and defines related to timer - * management. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - -#ifndef _TIMER_H -#define _TIMER_H - -#define TMR_STATE_RUNNING 0 /*!< Timer State: Running */ -#define TMR_STATE_STOPPED 1 /*!< Timer State: Stopped */ - -/** - * @struct tmrCtrl timer.h - * @brief Timer control block - * @details This struct is use to manage user timer. - * - */ -typedef struct tmrCtrl /* Timer Control Block Define. */ -{ - OS_TCID tmrID; /*!< Timer ID. */ - U8 tmrType; /*!< Timer Type. */ - U8 tmrState; /*!< Timer State. */ - U32 tmrCnt; /*!< Timer Counter. */ - U32 tmrReload; /*!< Timer Reload Counter Value. */ - vFUNCPtr tmrCallBack; /*!< Call-back Function When Timer overrun. */ - struct tmrCtrl* tmrNext; /*!< Point to Next Timer Control Block. */ - struct tmrCtrl* tmrPrev; /*!< Point to Previous Timer Control Block*/ - -}TmrCtrl,*P_TmrCtrl; - -/*---------------------------- Variable declare ------------------------------*/ -extern P_TmrCtrl TmrList; /*!< A pointer to the timer list. */ -extern U32 TmrIDVessel; -/*---------------------------- Function declare ------------------------------*/ -extern void TmrDispose(void); /*!< Timer counter function. */ -extern void isr_TmrDispose(void); -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/OsUtility.c b/GD32F1/libraries/MapleCoOS/utility/OsUtility.c deleted file mode 100644 index 5aeb7c4..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsUtility.c +++ /dev/null @@ -1,86 +0,0 @@ -/** - ******************************************************************************* - * @file utility.c - * @version V1.12 - * @date 2010.03.01 - * @brief Utility management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if CFG_UTILITY_EN > 0 - - -/** - ******************************************************************************* - * @brief Convert tick number to time - * @param[in] ticks Specifies the systerm tick numbers that will be converted. - * @param[out] hour Hours which converted. - * @param[out] minute minutes which converted. - * @param[out] sec seconds which converted. - * @param[out] millsec millseconds which converted. - * @retval None - * - * @par Description - * @details This function is called to convert specify ticks to time format. - ******************************************************************************* - */ -#if CFG_TICK_TO_TIME_EN > 0 -void CoTickToTime(U32 ticks,U8* hour,U8* minute,U8* sec,U16* millsec) -{ - U32 totalTime; - - /* Convert ticks to time*/ - totalTime = ticks * (1000/CFG_SYSTICK_FREQ); - *millsec = totalTime%1000; - totalTime = totalTime/1000; - *sec = totalTime%60; - totalTime = totalTime/60; - *minute = totalTime%60; - totalTime = totalTime/60; - *hour = totalTime; -} -#endif /* CFG_TICK_TO_TIME_EN */ - - -/** - ******************************************************************************* - * @brief Convert time to tick - * @param[in] hour Specifies the number of hours. - * @param[in] minute Specifies the number of minutes. - * @param[in] sec Specifies the number of seconds. - * @param[in] millsec Specifies the number of millseconds. - * @param[out] ticks Tick numbers that converted. - * @retval E_INVALID_PARAMETER Invalid parameter be passed and convert fail. - * @retval E_OK Convert successful. - * - * @par Description - * @details This function is called to convert specify time to tick number. - ******************************************************************************* - */ -#if CFG_TIME_TO_TICK_EN > 0 -StatusType CoTimeToTick(U8 hour,U8 minute,U8 sec,U16 millsec,U32* ticks) -{ -#if CFG_PAR_CHECKOUT_EN >0 - /* Validate arguments to be within range */ - if((minute > 59)||(sec > 59)||(millsec > 999)) - return E_INVALID_PARAMETER; -#endif - - /* Convert time to ticks */ - *ticks = ((hour*3600) + (minute*60) + (sec)) * (CFG_SYSTICK_FREQ)\ - + (millsec*CFG_SYSTICK_FREQ + 500)/1000; - return E_OK; -} -#endif /* CFG_TIME_TO_TICK_EN */ - -#endif /* CFG_UTILITY_EN */ diff --git a/GD32F1/libraries/MapleCoOS/utility/OsUtility.h b/GD32F1/libraries/MapleCoOS/utility/OsUtility.h deleted file mode 100644 index 8406898..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/OsUtility.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - ******************************************************************************* - * @file utility.h - * @version V1.00 Initial version - * @date 2009.06.26 - * @brief Utility function header file - * @details This file including some defines and declares related to utility - * function. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _UTILITY_H -#define _UTILITY_H - - -/** - * @struct Time struct utility.h - * @brief Time struct - * @details This struct use to manage time - */ -typedef struct SysTime -{ - U8 sec; /*!< Second */ - U8 min; /*!< Minute */ - U8 hour; /*!< Hour */ - U8 date; /*!< Date */ - U8 month; /*!< Month */ - U16 year; /*!< Year */ -}TIME; - -#endif diff --git a/GD32F1/libraries/MapleCoOS/utility/coocox.h b/GD32F1/libraries/MapleCoOS/utility/coocox.h deleted file mode 100644 index 9db6cd4..0000000 --- a/GD32F1/libraries/MapleCoOS/utility/coocox.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - ******************************************************************************* - * @file coocox.h - * @version V1.12 - * @date 2010.03.01 - * @brief Gather for all header file of CooCox CoOS. - ******************************************************************************* - * @copy - * - * INTERNAL FILE,DON'T PUBLIC. - * - *

© COPYRIGHT 2009 CooCox

- ******************************************************************************* - */ - - -#ifndef _COOCOX_H -#define _COOCOX_H - -#define OS_VERSION (U16)0x0112 /*!< OS version.(format: Vx.xx), - e.g. value 0x0111 is version V1.12*/ -/*---------------------------- Include ---------------------------------------*/ -#include "CoOS.h" -#include "OsArch.h" -#include "OsCore.h" -#include "OsTask.h" -#include "OsServiceReq.h" -#include "OsError.h" -#include "OsTime.h" - - -#if CFG_TMR_EN > 0 - #include "OsTimer.h" -#endif - -#if CFG_KHEAP_EN > 0 - #include "OsKernelHeap.h" -#endif - -#if CFG_MM_EN >0 - #include "OsMM.h" -#endif - -#if CFG_EVENT_EN > 0 - #include "OsEvent.h" -#endif - -#if CFG_MUTEX_EN > 0 - #include "OsMutex.h" -#endif - -#if CFG_QUEUE_EN > 0 - #include "OsQueue.h" -#endif - -#if CFG_FLAG_EN > 0 - #include "OsFlag.h" -#endif - -#endif /* _COOCOX_H */ diff --git a/GD32F1/libraries/MapleCoOS116/MapleCoOS116.h b/GD32F1/libraries/MapleCoOS116/MapleCoOS116.h deleted file mode 100644 index 701f9f8..0000000 --- a/GD32F1/libraries/MapleCoOS116/MapleCoOS116.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _COOS_H_ -#define _COOS_H_ - -#include "WProgram.h" -extern "C" { - #include "utility/CoOS.h" -} - -#define TASK_STK_SIZE 128 /*!< Define stack size. */ - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/SPICoOS.cpp b/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/SPICoOS.cpp deleted file mode 100644 index 352ec08..0000000 --- a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/SPICoOS.cpp +++ /dev/null @@ -1,631 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @author Marti Bolivar - * @brief Wirish SPI implementation. - */ - -#include "SPICoOS.h" - -//#define SPI_DEBUG - -#include -#include -#include -#include - -#include "wirish.h" -#include "boards.h" - -//#include "HardwareSerial.h" - -#if CYCLES_PER_MICROSECOND != 72 -/* TODO [0.2.0?] something smarter than this */ -#warning "Unexpected clock speed; SPI frequency calculation will be incorrect" -#endif - -struct spi_pins { - uint8 nss; - uint8 sck; - uint8 miso; - uint8 mosi; -}; - -static const spi_pins* dev_to_spi_pins(spi_dev *dev); - -static void configure_gpios(spi_dev *dev, bool as_master); - -static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq); - -#if (BOARD_NR_SPI >= 3) && !defined(STM32_HIGH_DENSITY) -#error "The SPI library is misconfigured: 3 SPI ports only available on high density STM32 devices" -#endif - -static const spi_pins board_spi_pins[] __FLASH__ = { -#if BOARD_NR_SPI >= 1 - {BOARD_SPI1_NSS_PIN, - BOARD_SPI1_SCK_PIN, - BOARD_SPI1_MISO_PIN, - BOARD_SPI1_MOSI_PIN}, -#endif -#if BOARD_NR_SPI >= 2 - {BOARD_SPI2_NSS_PIN, - BOARD_SPI2_SCK_PIN, - BOARD_SPI2_MISO_PIN, - BOARD_SPI2_MOSI_PIN}, -#endif -#if BOARD_NR_SPI >= 3 - {BOARD_SPI3_NSS_PIN, - BOARD_SPI3_SCK_PIN, - BOARD_SPI3_MISO_PIN, - BOARD_SPI3_MOSI_PIN}, -#endif -}; - - -/* - * Constructor - */ - -SPIClass::SPIClass(uint32 spi_num) { - switch (spi_num) { -#if BOARD_NR_SPI >= 1 - case 1: - this->spi_d = SPI1; - break; -#endif -#if BOARD_NR_SPI >= 2 - case 2: - this->spi_d = SPI2; - break; -#endif -#if BOARD_NR_SPI >= 3 - case 3: - this->spi_d = SPI3; - break; -#endif - default: - ASSERT(0); - } - - //pinMode(BOARD_SPI_DEFAULT_SS,OUTPUT); -} - -/* - * Set up/tear down - */ - -void SPIClass::begin(void) { - if (dataMode >= 4) { - ASSERT(0); - return; - } - uint32 flags = ((bitOrder == MSBFIRST ? SPI_FRAME_MSB : SPI_FRAME_LSB) | SPI_DFF_8_BIT | SPI_SW_SLAVE | SPI_SOFT_SS); - spi_init(spi_d); - configure_gpios(spi_d, 1); - #ifdef SPI_DEBUG - Serial.print("spi_master_enable("); Serial.print(clockDivider); Serial.print(","); Serial.print(dataMode); Serial.print(","); Serial.print(flags); Serial.println(")"); - #endif - spi_master_enable(spi_d, (spi_baud_rate)clockDivider, (spi_mode)dataMode, flags); - sem_dma1free = CoCreateSem (1, 1, EVENT_SORT_TYPE_FIFO); // Create semaphore for CoOS multitasking. -} - -void SPIClass::beginSlave(void) { - if (dataMode >= 4) { - ASSERT(0); - return; - } - uint32 flags = ((bitOrder == MSBFIRST ? SPI_FRAME_MSB : SPI_FRAME_LSB) | SPI_DFF_8_BIT | SPI_SW_SLAVE); - spi_init(spi_d); - configure_gpios(spi_d, 0); - #ifdef SPI_DEBUG - Serial.print("spi_slave_enable("); Serial.print(dataMode); Serial.print(","); Serial.print(flags); Serial.println(")"); - #endif - spi_slave_enable(spi_d, (spi_mode)dataMode, flags); -} - -void SPIClass::end(void) { - if (!spi_is_enabled(this->spi_d)) { - return; - } - - // Follows RM0008's sequence for disabling a SPI in master/slave - // full duplex mode. - while (spi_is_rx_nonempty(this->spi_d)) { - // FIXME [0.1.0] remove this once you have an interrupt based driver - volatile uint16 rx __attribute__((unused)) = spi_rx_reg(this->spi_d); - } - while (!spi_is_tx_empty(this->spi_d)) - ; - while (spi_is_busy(this->spi_d)) - ; - spi_peripheral_disable(this->spi_d); -} - -/* Roger Clark added 3 functions */ -void SPIClass::setClockDivider(uint32_t clockDivider) -{ - #ifdef SPI_DEBUG - Serial.print("Clock divider set to "); Serial.println(clockDivider); - #endif - this->clockDivider = clockDivider; - this->begin(); -} - -void SPIClass::setBitOrder(BitOrder bitOrder) -{ - #ifdef SPI_DEBUG - Serial.print("Bit order set to "); Serial.println(bitOrder); - #endif - this->bitOrder = bitOrder; - this->begin(); -} - -/* Victor Perez. Added to test changing datasize from 8 to 16 bit modes on the fly. -* Input parameter should be SPI_CR1_DFF set to 0 or 1 on a 32bit word. -* Requires an added function spi_data_size on STM32F1 / cores / maple / libmaple / spi.c -*/ -void SPIClass::setDataSize(uint32 datasize) { -// spi_data_size(this->spi_d, ds); - uint32 cr1 = this->spi_d->regs->CR1; - datasize &= SPI_CR1_DFF; - cr1 &= ~(SPI_CR1_DFF); - cr1 |= datasize; - this->spi_d->regs->CR1 = cr1; -} - -void SPIClass::setDataMode(uint8_t dataMode) -{ -/* Notes. As far as I can tell, the AVR numbers for dataMode appear to match the numbers required by the STM32 - -From the AVR doc http://www.atmel.com/images/doc2585.pdf section 2.4 - -SPI Mode CPOL CPHA Shift SCK-edge Capture SCK-edge -0 0 0 Falling Rising -1 0 1 Rising Falling -2 1 0 Rising Falling -3 1 1 Falling Rising - - -On the STM32 it appears to be - -bit 1 - CPOL : Clock polarity - - (This bit should not be changed when communication is ongoing) - 0 : CLK to 0 when idle - 1 : CLK to 1 when idle - -bit 0 - CPHA : Clock phase - - (This bit should not be changed when communication is ongoing) - 0 : The first clock transition is the first data capture edge - 1 : The second clock transition is the first data capture edge - -If someone finds this is not the case or sees a logic error with this let me know ;-) - */ - #ifdef SPI_DEBUG - Serial.print("Data mode set to "); Serial.println(dataMode); - #endif - this->dataMode = dataMode; - this->begin(); -} - - -void SPIClass::beginTransaction(uint8_t pin, SPISettings settings) -{ - #ifdef SPI_DEBUG - Serial.println("SPIClass::beginTransaction"); - #endif - //_SSPin=pin; - //pinMode(_SSPin,OUTPUT); - //digitalWrite(_SSPin,LOW); - setBitOrder(settings.bitOrder); - setDataMode(settings.dataMode); - setClockDivider(determine_baud_rate(spi_d, settings.clock)); - begin(); -#if 0 -// code from SAM core - uint8_t mode = interruptMode; - if (mode > 0) { - if (mode < 16) { - if (mode & 1) PIOA->PIO_IDR = interruptMask[0]; - if (mode & 2) PIOB->PIO_IDR = interruptMask[1]; - if (mode & 4) PIOC->PIO_IDR = interruptMask[2]; - if (mode & 8) PIOD->PIO_IDR = interruptMask[3]; - } else { - interruptSave = interruptsStatus(); - noInterrupts(); - } - } - uint32_t ch = BOARD_PIN_TO_SPI_CHANNEL(pin); - bitOrder[ch] = settings.border; - SPI_ConfigureNPCS(spi, ch, settings.config); - //setBitOrder(pin, settings.border); - //setDataMode(pin, settings.datamode); - //setClockDivider(pin, settings.clockdiv); -#endif -} - -void SPIClass::endTransaction(void) -{ - #ifdef SPI_DEBUG - Serial.println("SPIClass::endTransaction"); - #endif - //digitalWrite(_SSPin,HIGH); -#if false -// code from SAM core - uint8_t mode = interruptMode; - if (mode > 0) { - if (mode < 16) { - if (mode & 1) PIOA->PIO_IER = interruptMask[0]; - if (mode & 2) PIOB->PIO_IER = interruptMask[1]; - if (mode & 4) PIOC->PIO_IER = interruptMask[2]; - if (mode & 8) PIOD->PIO_IER = interruptMask[3]; - } else { - if (interruptSave) interrupts(); - } - } -#endif -} - - -/* - * I/O - */ - -uint8 SPIClass::read(void) { - uint8 buf[1]; - this->read(buf, 1); - return buf[0]; -} - -void SPIClass::read(uint8 *buf, uint32 len) { - uint32 rxed = 0; - while (rxed < len) { - while (!spi_is_rx_nonempty(this->spi_d)) - ; - buf[rxed++] = (uint8)spi_rx_reg(this->spi_d); - } -} - -void SPIClass::write(uint16 data) { - // this->write(&data, 1); - - /* Added for 16bit data Victor Perez. Roger Clark - * Improved speed by just directly writing the single byte to the SPI data reg and wait for completion, * by taking the Tx code from transfer(byte) - * The original method, of calling write(*data, length) . - * This almost doubles the speed of this function. - */ - - spi_tx_reg(this->spi_d, data); // "2. Write the first data item to be transmitted into the SPI_DR register (this clears the TXE flag)." - while (spi_is_tx_empty(this->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(this->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." -} - -void SPIClass::write(uint8 byte) { - // this->write(&byte, 1); - - /* Roger Clark - * Improved speed by just directly writing the single byte to the SPI data reg and wait for completion, * by taking the Tx code from transfer(byte) - * The original method, of calling write(*data, length) . - * This almost doubles the speed of this function. - */ - - spi_tx_reg(this->spi_d, byte); // "2. Write the first data item to be transmitted into the SPI_DR register (this clears the TXE flag)." - while (spi_is_tx_empty(this->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(this->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." -} - -void SPIClass::write(const uint8 *data, uint32 length) { - uint32 txed = 0; - while (txed < length) { - txed += spi_tx(this->spi_d, data + txed, length - txed); - } - while (spi_is_tx_empty(this->spi_d) == 0); // "4. After writing the last data item into the SPI_DR register, wait until TXE=1 ..." - while (spi_is_busy(this->spi_d) != 0); // "... then wait until BSY=0, this indicates that the transmission of the last data is complete." -} - -uint8 SPIClass::transfer(uint8 byte) { - uint8 b; - spi_tx_reg(this->spi_d, byte); // "2. Write the first data item to be transmitted into the SPI_DR register (this clears the TXE flag)." - while (spi_is_rx_nonempty(this->spi_d) == 0); // "4. Wait until RXNE=1 ..." - b = spi_rx_reg(this->spi_d); // "... and read the last received data." - while (spi_is_tx_empty(this->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(this->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." - return b; -} -/* Roger Clark and Victor Perez, 2015 -* Performs a DMA SPI transfer with at least a receive buffer. -* If a TX buffer is not provided, FF is sent over and over for the lenght of the transfer. -* On exit TX buffer is not modified, and RX buffer cotains the received data. -* Still in progress. -*/ -uint8 SPIClass::dmaTransfer(uint8 *transmitBuf, uint8 *receiveBuf, uint16 length) { - if (length == 0) return 0; - uint8 b; - if (spi_is_rx_nonempty(this->spi_d) == 1) b = spi_rx_reg(this->spi_d); //Clear the RX buffer in case a byte is waiting on it. - dma1_ch3_Active=true; - dma_init(DMA1); - dma_attach_interrupt(DMA1, DMA_CH3, &SPIClass::DMA1_CH3_Event); - - // RX - spi_rx_dma_enable(SPI1); - dma_setup_transfer(DMA1, DMA_CH2, &SPI1->regs->DR, DMA_SIZE_8BITS, - receiveBuf, DMA_SIZE_8BITS, (DMA_MINC_MODE | DMA_TRNS_CMPLT));// receive buffer DMA - dma_set_num_transfers(DMA1, DMA_CH2, length); - - // TX - spi_tx_dma_enable(SPI1); - if (!transmitBuf) { - static uint8_t ff = 0XFF; - transmitBuf = &ff; - dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS, - transmitBuf, DMA_SIZE_8BITS, (DMA_FROM_MEM | DMA_TRNS_CMPLT));// Transmit FF repeatedly - } - else { - dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS, - transmitBuf, DMA_SIZE_8BITS, (DMA_MINC_MODE | DMA_FROM_MEM | DMA_TRNS_CMPLT));// Transmit buffer DMA - } - dma_set_num_transfers(DMA1, DMA_CH3, length); - - CoPendSem (sem_dma1free, 0); - dma_enable(DMA1, DMA_CH2);// enable receive - dma_enable(DMA1, DMA_CH3);// enable transmit - -// while (dma1_ch3_Active); -// if (receiveBuf) { - CoPendSem (sem_dma1free, 100); - CoPostSem (sem_dma1free); - /* - uint32_t m = millis(); - while (dma1_ch3_Active) { - if ((millis() - m) > 100) { - dma1_ch3_Active = 0; - b = 2; - break; - } - } - */ - -// } - while (spi_is_tx_empty(this->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(this->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." - dma_disable(DMA1, DMA_CH3); - dma_disable(DMA1, DMA_CH2); - spi_rx_dma_disable(SPI1); - spi_tx_dma_disable(SPI1); - return b; -} - -/* Roger Clark and Victor Perez, 2015 -* Performs a DMA SPI send using a TX buffer. -* On exit TX buffer is not modified. -* Still in progress. -*/ -uint8 SPIClass::dmaSend(uint8 *transmitBuf, uint16 length, bool minc = 1) { - if (length == 0) return 0; - uint32 flags = ((DMA_MINC_MODE * minc) | DMA_FROM_MEM | DMA_TRNS_CMPLT); - uint8 b; - dma1_ch3_Active=true; - dma_init(DMA1); - dma_attach_interrupt(DMA1, DMA_CH3, &SPIClass::DMA1_CH3_Event); - - // TX - spi_tx_dma_enable(SPI1); - dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS, - transmitBuf, DMA_SIZE_8BITS, flags);// Transmit buffer DMA - dma_set_num_transfers(DMA1, DMA_CH3, length); - - if (length > 32) { - CoPendSem (sem_dma1free, 0); - dma_enable(DMA1, DMA_CH3);// enable transmit - CoPendSem (sem_dma1free, 10); //Check if the semaphore was release by the DMA ISR - CoPostSem (sem_dma1free); - } - else { - dma_enable(DMA1, DMA_CH3);// enable transmit - while (dma1_ch3_Active); - } - - while (spi_is_rx_nonempty(this->spi_d) == 0); // "4. Wait until RXNE=1 ..." - b = spi_rx_reg(this->spi_d); // "... and read the last received data." - while (spi_is_tx_empty(this->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(this->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." - dma_disable(DMA1, DMA_CH3); - spi_tx_dma_disable(SPI1); - return b; -} - -uint8 SPIClass::dmaSend(uint16 *transmitBuf, uint16 length, bool minc = 1) { - if (length == 0) return 0; - uint32 flags = ((DMA_MINC_MODE * minc) | DMA_FROM_MEM | DMA_TRNS_CMPLT); - uint8 b; - dma1_ch3_Active=true; - dma_init(DMA1); - dma_attach_interrupt(DMA1, DMA_CH3, &SPIClass::DMA1_CH3_Event); - - // TX - spi_tx_dma_enable(SPI1); - dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_16BITS, - transmitBuf, DMA_SIZE_16BITS, flags);// Transmit buffer DMA - dma_set_num_transfers(DMA1, DMA_CH3, length); - - if (length > 32) { - CoPendSem (sem_dma1free, 0); - dma_enable(DMA1, DMA_CH3);// enable transmit - CoPendSem (sem_dma1free, 10); //Check if the semaphore was release by the DMA ISR - CoPostSem (sem_dma1free); - } - else { - dma_enable(DMA1, DMA_CH3);// enable transmit - while (dma1_ch3_Active); - } - - while (spi_is_rx_nonempty(this->spi_d) == 0); // "4. Wait until RXNE=1 ..." - b = spi_rx_reg(this->spi_d); // "... and read the last received data." - while (spi_is_tx_empty(this->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(this->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." - dma_disable(DMA1, DMA_CH3); - spi_tx_dma_disable(SPI1); - return b; -} - - -void SPIClass::attachInterrupt(void) { - // Should be enableInterrupt() -} - -void SPIClass::detachInterrupt(void) { - // Should be disableInterrupt() -} - -/* - * Pin accessors - */ - -uint8 SPIClass::misoPin(void) { - return dev_to_spi_pins(this->spi_d)->miso; -} - -uint8 SPIClass::mosiPin(void) { - return dev_to_spi_pins(this->spi_d)->mosi; -} - -uint8 SPIClass::sckPin(void) { - return dev_to_spi_pins(this->spi_d)->sck; -} - -uint8 SPIClass::nssPin(void) { - return dev_to_spi_pins(this->spi_d)->nss; -} - -/* - * Deprecated functions - */ - -uint8 SPIClass::send(uint8 data) { - uint8 buf[] = {data}; - return this->send(buf, 1); -} - -uint8 SPIClass::send(uint8 *buf, uint32 len) { - uint32 txed = 0; - uint8 ret = 0; - while (txed < len) { - this->write(buf[txed++]); - ret = this->read(); - } - return ret; -} - -uint8 SPIClass::recv(void) { - return this->read(); -} - - -/* - * Auxiliary functions - */ - -static const spi_pins* dev_to_spi_pins(spi_dev *dev) { - switch (dev->clk_id) { -#if BOARD_NR_SPI >= 1 - case RCC_SPI1: return board_spi_pins; -#endif -#if BOARD_NR_SPI >= 2 - case RCC_SPI2: return board_spi_pins + 1; -#endif -#if BOARD_NR_SPI >= 3 - case RCC_SPI3: return board_spi_pins + 2; -#endif - default: return NULL; - } -} - -static void disable_pwm(const stm32_pin_info *i) { - if (i->timer_device) { - timer_set_mode(i->timer_device, i->timer_channel, TIMER_DISABLED); - } -} - -static void configure_gpios(spi_dev *dev, bool as_master) { - const spi_pins *pins = dev_to_spi_pins(dev); - - if (!pins) { - return; - } - - const stm32_pin_info *nssi = &PIN_MAP[pins->nss]; - const stm32_pin_info *scki = &PIN_MAP[pins->sck]; - const stm32_pin_info *misoi = &PIN_MAP[pins->miso]; - const stm32_pin_info *mosii = &PIN_MAP[pins->mosi]; - - disable_pwm(nssi); - disable_pwm(scki); - disable_pwm(misoi); - disable_pwm(mosii); - - spi_config_gpios(dev, as_master, nssi->gpio_device, nssi->gpio_bit, - scki->gpio_device, scki->gpio_bit, misoi->gpio_bit, - mosii->gpio_bit); -} - -static const spi_baud_rate baud_rates[8] __FLASH__ = { - SPI_BAUD_PCLK_DIV_2, - SPI_BAUD_PCLK_DIV_4, - SPI_BAUD_PCLK_DIV_8, - SPI_BAUD_PCLK_DIV_16, - SPI_BAUD_PCLK_DIV_32, - SPI_BAUD_PCLK_DIV_64, - SPI_BAUD_PCLK_DIV_128, - SPI_BAUD_PCLK_DIV_256, -}; - -/* - * Note: This assumes you're on a LeafLabs-style board - * (CYCLES_PER_MICROSECOND == 72, APB2 at 72MHz, APB1 at 36MHz). - */ -static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq) { - uint32_t clock = 0, i; - #ifdef SPI_DEBUG - Serial.print("determine_baud_rate("); Serial.print(freq); Serial.println(")"); - #endif - switch (rcc_dev_clk(dev->clk_id)) - { - case RCC_APB2: clock = STM32_PCLK2; break; // 72 Mhz - case RCC_APB1: clock = STM32_PCLK1; break; // 36 Mhz - } - clock /= 2; - i = 0; - while (i < 7 && freq < clock) { - clock /= 2; - i++; - } - return baud_rates[i]; -} - -SPIClass SPI(1); diff --git a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/SPICoOS.h b/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/SPICoOS.h deleted file mode 100644 index fc5a626..0000000 --- a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/SPICoOS.h +++ /dev/null @@ -1,368 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/HardwareSPI.h - * @brief High-level SPI interface - * - * This is a "bare essentials" polling driver for now. - */ - -/* TODO [0.1.0] Remove deprecated methods. */ - - - -#ifndef _SPI_H_INCLUDED -#define _SPI_H_INCLUDED - -#include -#include -#include -#include - -#include -#include -#include - -// SPI_HAS_TRANSACTION means SPI has -// - beginTransaction() -// - endTransaction() -// - usingInterrupt() -// - SPISetting(clock, bitOrder, dataMode) -//#define SPI_HAS_TRANSACTION - -#define SPI_CLOCK_DIV2 SPI_BAUD_PCLK_DIV_2 -#define SPI_CLOCK_DIV4 SPI_BAUD_PCLK_DIV_4 -#define SPI_CLOCK_DIV8 SPI_BAUD_PCLK_DIV_8 -#define SPI_CLOCK_DIV16 SPI_BAUD_PCLK_DIV_16 -#define SPI_CLOCK_DIV32 SPI_BAUD_PCLK_DIV_32 -#define SPI_CLOCK_DIV64 SPI_BAUD_PCLK_DIV_64 -#define SPI_CLOCK_DIV128 SPI_BAUD_PCLK_DIV_128 -#define SPI_CLOCK_DIV256 SPI_BAUD_PCLK_DIV_256 - -/* - * Roger Clark. 20150106 - * Commented out redundant AVR defined - * -#define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR -#define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR -#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR - -// define SPI_AVR_EIMSK for AVR boards with external interrupt pins -#if defined(EIMSK) - #define SPI_AVR_EIMSK EIMSK -#elif defined(GICR) - #define SPI_AVR_EIMSK GICR -#elif defined(GIMSK) - #define SPI_AVR_EIMSK GIMSK -#endif -*/ - -#ifndef STM32_LSBFIRST -#define STM32_LSBFIRST 0 -#endif -#ifndef STM32_MSBFIRST -#define STM32_MSBFIRST 1 -#endif - -// PC13 or PA4 -//#define BOARD_SPI_DEFAULT_SS PA4 -#define BOARD_SPI_DEFAULT_SS PC13 - -#define SPI_MODE0 SPI_MODE_0 -#define SPI_MODE1 SPI_MODE_1 -#define SPI_MODE2 SPI_MODE_2 -#define SPI_MODE3 SPI_MODE_3 - -class SPISettings { -public: - SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) { - if (__builtin_constant_p(clock)) { - init_AlwaysInline(clock, bitOrder, dataMode); - } else { - init_MightInline(clock, bitOrder, dataMode); - } - } - SPISettings() { init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0); } -private: - void init_MightInline(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) { - init_AlwaysInline(clock, bitOrder, dataMode); - } - void init_AlwaysInline(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) __attribute__((__always_inline__)) { - this->clock = clock; - this->bitOrder = bitOrder; - this->dataMode = dataMode; - } - uint32_t clock; - BitOrder bitOrder; - uint8_t dataMode; - friend class SPIClass; -}; - - -volatile static bool dma1_ch3_Active; -volatile static OS_EventID sem_dma1free; - -/** - * @brief Wirish SPI interface. - * - * This implementation uses software slave management, so the caller - * is responsible for controlling the slave select line. - */ -class SPIClass { -public: - - - - /** - * @param spiPortNumber Number of the SPI port to manage. - */ - SPIClass(uint32 spiPortNumber); - - /* - * Set up/tear down - */ - - - - /** - * @brief Equivalent to begin(SPI_1_125MHZ, MSBFIRST, 0). - */ - void begin(void); - - /** - * @brief Turn on a SPI port and set its GPIO pin modes for use as a slave. - * - * SPI port is enabled in full duplex mode, with software slave management. - * - * @param bitOrder Either LSBFIRST (little-endian) or MSBFIRST(big-endian) - * @param mode SPI mode to use - */ - void beginSlave(uint32 bitOrder, uint32 mode); - - /** - * @brief Equivalent to beginSlave(MSBFIRST, 0). - */ - void beginSlave(void); - - /** - * @brief Disables the SPI port, but leaves its GPIO pin modes unchanged. - */ - void end(void); - - void beginTransaction(SPISettings settings) { beginTransaction(BOARD_SPI_DEFAULT_SS, settings); } - void beginTransaction(uint8_t pin, SPISettings settings); - void endTransaction(void); - - void setClockDivider(uint32_t clockDivider); - void setBitOrder(BitOrder bitOrder); - void setDataMode(uint8_t dataMode); - - // SPI Configuration methods - void attachInterrupt(void); - void detachInterrupt(void); - - /* Victor Perez. Added to test changing datasize from 8 to 16 bit modes on the fly. - * Input parameter should be SPI_CR1_DFF set to 0 or 1 on a 32bit word. - * Requires an added function spi_data_size on STM32F1 / cores / maple / libmaple / spi.c - */ - void setDataSize(uint32 ds); - - - /* - * I/O - */ - - /** - * @brief Return the next unread byte. - * - * If there is no unread byte waiting, this function will block - * until one is received. - */ - uint8 read(void); - - /** - * @brief Read length bytes, storing them into buffer. - * @param buffer Buffer to store received bytes into. - * @param length Number of bytes to store in buffer. This - * function will block until the desired number of - * bytes have been read. - */ - void read(uint8 *buffer, uint32 length); - - /** - * @brief Transmit a byte. - * @param data Byte to transmit. - */ - void write(uint8 data); - - /** - * @brief Transmit a half word. - * @param data to transmit. - */ - void write(uint16 data); - - /** - * @brief Transmit multiple bytes. - * @param buffer Bytes to transmit. - * @param length Number of bytes in buffer to transmit. - */ - void write(const uint8 *buffer, uint32 length); - - /** - * @brief Transmit a byte, then return the next unread byte. - * - * This function transmits before receiving. - * - * @param data Byte to transmit. - * @return Next unread byte. - */ - uint8 transfer(uint8 data); - - /** - * @brief Sets up a DMA Transfer for "length" bytes. - * - * This function transmits and receives to buffers. - * - * @param transmitBuf buffer Bytes to transmit. If passed as 0, it sends FF repeatedly for "length" bytes - * @param receiveBuf buffer Bytes to save received data. - * @param length Number of bytes in buffer to transmit. - */ - uint8 dmaTransfer(uint8 *transmitBuf, uint8 *receiveBuf, uint16 length); - - /** - * @brief Sets up a DMA Transmit for bytes. - * - * This function transmits and does not care about the RX fifo. - * - * @param transmitBuf buffer Bytes to transmit, - * @param length Number of bytes in buffer to transmit. - * @param minc Set to use Memory Increment mode, clear to use Circular mode. - */ - uint8 dmaSend(uint8 *transmitBuf, uint16 length, bool minc); - - /** - * @brief Sets up a DMA Transmit for half words. - * SPI PERFIPHERAL MUST BE SET TO 16 BIT MODE BEFORE - * - * This function transmits and does not care about the RX fifo. - * - * @param data buffer half words to transmit, - * @param length Number of bytes in buffer to transmit. - * @param minc Set to use Memory Increment mode (default if blank), clear to use Circular mode. - */ - uint8 dmaSend(uint16 *transmitBuf, uint16 length, bool minc); - - /* - * Pin accessors - */ - - /** - * @brief Return the number of the MISO (master in, slave out) pin - */ - uint8 misoPin(void); - - /** - * @brief Return the number of the MOSI (master out, slave in) pin - */ - uint8 mosiPin(void); - - /** - * @brief Return the number of the SCK (serial clock) pin - */ - uint8 sckPin(void); - - /** - * @brief Return the number of the NSS (slave select) pin - */ - uint8 nssPin(void); - - /* Escape hatch */ - - /** - * @brief Get a pointer to the underlying libmaple spi_dev for - * this HardwareSPI instance. - */ - spi_dev* c_dev(void) { return this->spi_d; } - - /* -- The following methods are deprecated --------------------------- */ - - /** - * @brief Deprecated. - * - * Use HardwareSPI::transfer() instead. - * - * @see HardwareSPI::transfer() - */ - uint8 send(uint8 data); - - /** - * @brief Deprecated. - * - * Use HardwareSPI::write() in combination with - * HardwareSPI::read() (or HardwareSPI::transfer()) instead. - * - * @see HardwareSPI::write() - * @see HardwareSPI::read() - * @see HardwareSPI::transfer() - */ - uint8 send(uint8 *data, uint32 length); - - /** - * @brief Deprecated. - * - * Use HardwareSPI::read() instead. - * - * @see HardwareSPI::read() - */ - uint8 recv(void); - - spi_dev *dev(){ return spi_d;} - - - -private: - - static inline void DMA1_CH3_Event() { - CoEnterISR (); // Enter ISR - isr_PostSem (sem_dma1free); - dma1_ch3_Active = 0; -// dma_disable(DMA1, DMA_CH3); -// dma_disable(DMA1, DMA_CH2); - - // To Do. Need to wait for - CoExitISR (); // Exit ISR - } - spi_dev *spi_d; - uint8_t _SSPin; - uint32_t clockDivider; - uint8_t dataMode; - BitOrder bitOrder; -}; - - -extern SPIClass SPI;//(1);// dummy params -#endif diff --git a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/TFT_ILI9163C.cpp b/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/TFT_ILI9163C.cpp deleted file mode 100644 index f8a808b..0000000 --- a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/TFT_ILI9163C.cpp +++ /dev/null @@ -1,1357 +0,0 @@ -#include "TFT_ILI9163C.h" -#include -#include "pins_arduino.h" -#include "wiring_private.h" -#include ".\SPICoOS.h" - -//constructors -TFT_ILI9163C::TFT_ILI9163C(uint8_t cspin,uint8_t dcpin,uint8_t rstpin) : Adafruit_GFX(_TFTWIDTH,_TFTHEIGHT){ - _cs = cspin; - _rs = dcpin; - _rst = rstpin; - #if defined(__MK20DX128__) || defined(__MK20DX256__) - #else - _sid = _sclk = 0; - #endif -} - - -TFT_ILI9163C::TFT_ILI9163C(uint8_t CS, uint8_t DC) : Adafruit_GFX(_TFTWIDTH, _TFTHEIGHT) { - _cs = CS; - _rs = DC; - _rst = 0; - #if defined(__MK20DX128__) || defined(__MK20DX256__) - #else - _sid = _sclk = 0; - #endif -} - -//Arduino Uno, Leonardo, Mega, Teensy 2.0, etc -#ifdef __AVR__ - -inline void TFT_ILI9163C::spiwrite(uint8_t c){ - SPDR = c; - while(!(SPSR & _BV(SPIF))); -} - -void TFT_ILI9163C::writecommand(uint8_t c){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport &= ~rspinmask;//low - *csport &= ~cspinmask;//low - spiwrite(c); - *csport |= cspinmask;//hi - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::writedata(uint8_t c){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport |= rspinmask; - *csport &= ~cspinmask; - spiwrite(c); - *csport |= cspinmask; - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::writedata16(uint16_t d){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport |= rspinmask; - *csport &= ~cspinmask; - spiwrite(d >> 8); - spiwrite(d); - *csport |= cspinmask; - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::setBitrate(uint32_t n){ - #if !defined (SPI_HAS_TRANSACTION) - if (n >= 8000000) { - SPI.setClockDivider(SPI_CLOCK_DIV2); - } else if (n >= 4000000) { - SPI.setClockDivider(SPI_CLOCK_DIV4); - } else if (n >= 2000000) { - SPI.setClockDivider(SPI_CLOCK_DIV8); - } else { - SPI.setClockDivider(SPI_CLOCK_DIV16); - } - #endif -} -#elif defined(__SAM3X8E__) -// Arduino Due - -inline void TFT_ILI9163C::spiwrite(uint8_t c){ - SPI.transfer(c); -} - -void TFT_ILI9163C::writecommand(uint8_t c){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - rsport->PIO_CODR |= rspinmask;//LO - csport->PIO_CODR |= cspinmask;//LO - spiwrite(c); - csport->PIO_SODR |= cspinmask;//HI - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::writedata(uint8_t c){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - rsport->PIO_SODR |= rspinmask;//HI - csport->PIO_CODR |= cspinmask;//LO - spiwrite(c); - csport->PIO_SODR |= cspinmask;//HI - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::writedata16(uint16_t d){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - rsport->PIO_SODR |= rspinmask;//HI - csport->PIO_CODR |= cspinmask;//LO - spiwrite(d >> 8); - spiwrite(d); - csport->PIO_SODR |= cspinmask;//HI - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - - -void TFT_ILI9163C::setBitrate(uint32_t n){ - #if !defined (SPI_HAS_TRANSACTION) - uint32_t divider=1; - while (divider < 255) { - if (n >= 84000000 / divider) break; - divider = divider - 1; - } - SPI.setClockDivider(divider); - #endif -} - -#elif defined(__STM32F1__) -// Maple & Maple mini - -inline void TFT_ILI9163C::spiwrite(uint8_t c){ - SPI.write(c); -} - -void TFT_ILI9163C::writecommand(uint8_t c){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport &= ~rspinmask;//low - *csport &= ~cspinmask;//low - spiwrite(c); - *csport |= cspinmask;//hi - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::writedata(uint8_t c){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport |= rspinmask; - *csport &= ~cspinmask; -#if defined SPI_16BIT - SPI.setDataSize (0); -#endif - spiwrite(c); -#if defined SPI_16BIT - SPI.setDataSize (SPI_CR1_DFF); -#endif - *csport |= cspinmask; - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::writedata16(uint16_t d){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport |= rspinmask; - *csport &= ~cspinmask; -#if defined SPI_16BIT - SPI.write(d); -#else - spiwrite(d >> 8); - spiwrite(d); -#endif - *csport |= cspinmask; - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::setBitrate(uint32_t n){ - #if !defined (SPI_HAS_TRANSACTION) - if (n >= 8000000) { - SPI.setClockDivider(SPI_CLOCK_DIV2); - } else if (n >= 4000000) { - SPI.setClockDivider(SPI_CLOCK_DIV4); - } else if (n >= 2000000) { - SPI.setClockDivider(SPI_CLOCK_DIV8); - } else { - SPI.setClockDivider(SPI_CLOCK_DIV16); - } - #endif -} - -/////////////// -#elif defined(__MK20DX128__) || defined(__MK20DX256__) -//Teensy 3.0 & 3.1 - -void TFT_ILI9163C::setBitrate(uint32_t n){ - //nop -} - -#endif //#if defined(TEENSY3.x) - - -void TFT_ILI9163C::begin(void) { - sleep = 0; -#if defined (__AVR__) || (__STM32F1__) - pinMode(_rs, OUTPUT); - pinMode(_cs, OUTPUT); - csport = portOutputRegister(digitalPinToPort(_cs)); - rsport = portOutputRegister(digitalPinToPort(_rs)); - cspinmask = digitalPinToBitMask(_cs); - rspinmask = digitalPinToBitMask(_rs); - SPI.begin(); - #if defined SPI_16BIT - SPI.setDataSize (SPI_CR1_DFF); - #endif - #if !defined (SPI_HAS_TRANSACTION) - SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - #endif - // toggle RST low to reset; CS low so it'll listen to us - *csport &= ~cspinmask; -#elif defined(__SAM3X8E__) - pinMode(_rs, OUTPUT); - pinMode(_cs, OUTPUT); - csport = digitalPinToPort(_cs); - rsport = digitalPinToPort(_rs); - cspinmask = digitalPinToBitMask(_cs); - rspinmask = digitalPinToBitMask(_rs); - SPI.begin(); - #if !defined (SPI_HAS_TRANSACTION) - SPI.setClockDivider(11); // 8 MHz - SPI.setBitOrder(MSBFIRST); - SPI.setDataMode(SPI_MODE0); - #endif - // toggle RST low to reset; CS low so it'll listen to us - csport ->PIO_CODR |= cspinmask; // Set control bits to LOW (idle) -#elif defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.begin(); - if (SPI.pinIsChipSelect(_cs, _rs)) { - pcs_data = SPI.setCS(_cs); - pcs_command = pcs_data | SPI.setCS(_rs); - } else { - pcs_data = 0; - pcs_command = 0; - return; - } -#endif - if (_rst != 0) { - pinMode(_rst, OUTPUT); - digitalWrite(_rst, HIGH); - delay(500); - digitalWrite(_rst, LOW); - delay(500); - digitalWrite(_rst, HIGH); - delay(500); - } - -/* -7) MY: 1(bottom to top), 0(top to bottom) Row Address Order -6) MX: 1(R to L), 0(L to R) Column Address Order -5) MV: 1(Exchanged), 0(normal) Row/Column exchange -4) ML: 1(bottom to top), 0(top to bottom) Vertical Refresh Order -3) RGB: 1(BGR), 0(RGB) Color Space -2) MH: 1(R to L), 0(L to R) Horizontal Refresh Order -1) -0) - - MY, MX, MV, ML,RGB, MH, D1, D0 - 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 //normal - 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 //Y-Mirror - 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 //X-Mirror - 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 //X-Y-Mirror - 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 //X-Y Exchange - 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 //X-Y Exchange, Y-Mirror - 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 //XY exchange - 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 -*/ - _Mactrl_Data = 0b00000000; - _colorspaceData = __COLORSPC;//start with default data; - chipInit(); -} - - - -void TFT_ILI9163C::chipInit() { - uint8_t i; - #if defined(__GAMMASET1) - const uint8_t pGammaSet[15]= {0x36,0x29,0x12,0x22,0x1C,0x15,0x42,0xB7,0x2F,0x13,0x12,0x0A,0x11,0x0B,0x06}; - const uint8_t nGammaSet[15]= {0x09,0x16,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x34,0x39}; - #elif defined(__GAMMASET2) - const uint8_t pGammaSet[15]= {0x3F,0x21,0x12,0x22,0x1C,0x15,0x42,0xB7,0x2F,0x13,0x02,0x0A,0x01,0x00,0x00}; - const uint8_t nGammaSet[15]= {0x09,0x18,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x24,0x29}; - #elif defined(__GAMMASET3) - const uint8_t pGammaSet[15]= {0x3F,0x26,0x23,0x30,0x28,0x10,0x55,0xB7,0x40,0x19,0x10,0x1E,0x02,0x01,0x00}; - //&const uint8_t nGammaSet[15]= {0x00,0x19,0x1C,0x0F,0x14,0x0F,0x2A,0x48,0x3F,0x06,0x1D,0x21,0x3D,0x3F,0x3F}; - const uint8_t nGammaSet[15]= {0x09,0x18,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x24,0x29}; - #else - const uint8_t pGammaSet[15]= {0x3F,0x25,0x1C,0x1E,0x20,0x12,0x2A,0x90,0x24,0x11,0x00,0x00,0x00,0x00,0x00}; - const uint8_t nGammaSet[15]= {0x20,0x20,0x20,0x20,0x05,0x15,0x00,0xA7,0x3D,0x18,0x25,0x2A,0x2B,0x2B,0x3A}; - #endif - - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_cont(CMD_SWRESET);//software reset - delay(500); - writecommand_cont(CMD_SLPOUT);//exit sleep - delay(5); - writecommand_cont(CMD_PIXFMT);//Set Color Format 16bit - writedata8_cont(0x05); - delay(5); - writecommand_cont(CMD_GAMMASET);//default gamma curve 3 - writedata8_cont(0x08);//0x04 - delay(1); - writecommand_cont(CMD_GAMRSEL);//Enable Gamma adj - writedata8_cont(0x01); - delay(1); - writecommand_cont(CMD_NORML); - - - writecommand_cont(CMD_DFUNCTR); - writedata8_cont(0b11111111);// - writedata8_cont(0b00000110);// - - writecommand_cont(CMD_PGAMMAC);//Positive Gamma Correction Setting - for (i=0;i<15;i++){ - writedata8_cont(pGammaSet[i]); - } - writecommand_cont(CMD_NGAMMAC);//Negative Gamma Correction Setting - for (i=0;i<15;i++){ - writedata8_cont(nGammaSet[i]); - } - - writecommand_cont(CMD_FRMCTR1);//Frame Rate Control (In normal mode/Full colors) - writedata8_cont(0x08);//0x0C//0x08 - writedata8_cont(0x02);//0x14//0x08 - delay(1); - - writecommand_cont(CMD_DINVCTR);//display inversion - writedata8_cont(0x07); - delay(1); - - writecommand_cont(CMD_PWCTR1);//Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD - writedata8_cont(0x0A);//4.30 - 0x0A - writedata8_cont(0x02);//0x05 - delay(1); - - writecommand_cont(CMD_PWCTR2);//Set BT[2:0] for AVDD & VCL & VGH & VGL - writedata8_cont(0x02); - delay(1); - - writecommand_cont(CMD_VCOMCTR1);//Set VMH[6:0] & VML[6:0] for VOMH & VCOML - writedata8_cont(0x50);//0x50 - writedata8_cont(99);//0x5b - delay(1); - - writecommand_cont(CMD_VCOMOFFS); - writedata8_cont(0);//0x40 - delay(1); - - writecommand_cont(CMD_CLMADRS);//Set Column Address - writedata16_cont(0x00); - writedata16_cont(_GRAMWIDTH); - - writecommand_cont(CMD_PGEADRS);//Set Page Address - writedata16_cont(0x00); - writedata16_cont(_GRAMHEIGH); - // set scroll area (thanks Masuda) - writecommand_cont(CMD_VSCLLDEF); - writedata16_cont(__OFFSET); - writedata16_cont(_GRAMHEIGH - __OFFSET); - writedata16_last(0); - - endProc(); - colorSpace(_colorspaceData); - setRotation(0); - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_cont(CMD_DISPON);//display ON - delay(1); - writecommand_last(CMD_RAMWR);//Memory Write - SPI.endTransaction(); - delay(1); - - #else - writecommand(CMD_SWRESET);//software reset - delay(500); - writecommand(CMD_SLPOUT);//exit sleep - delay(5); - writecommand(CMD_PIXFMT);//Set Color Format 16bit - writedata(0x05); - delay(5); - writecommand(CMD_GAMMASET);//default gamma curve 3 - writedata(0x04);//0x04 - delay(1); - writecommand(CMD_GAMRSEL);//Enable Gamma adj - writedata(0x01); - delay(1); - writecommand(CMD_NORML); - - writecommand(CMD_DFUNCTR); - writedata(0b11111111);// - writedata(0b00000110);// - - writecommand(CMD_PGAMMAC);//Positive Gamma Correction Setting - for (i=0;i<15;i++){ - writedata(pGammaSet[i]); - } - writecommand(CMD_NGAMMAC);//Negative Gamma Correction Setting - for (i=0;i<15;i++){ - writedata(nGammaSet[i]); - } - - writecommand(CMD_FRMCTR1);//Frame Rate Control (In normal mode/Full colors) - writedata(0x08);//0x0C//0x08 - writedata(0x02);//0x14//0x08 - delay(1); - writecommand(CMD_DINVCTR);//display inversion - writedata(0x07); - delay(1); - writecommand(CMD_PWCTR1);//Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD - writedata(0x0A);//4.30 - 0x0A - writedata(0x02);//0x05 - delay(1); - writecommand(CMD_PWCTR2);//Set BT[2:0] for AVDD & VCL & VGH & VGL - writedata(0x02); - delay(1); - writecommand(CMD_VCOMCTR1);//Set VMH[6:0] & VML[6:0] for VOMH & VCOML - writedata(0x50);//0x50 - writedata(99);//0x5b - delay(1); - writecommand(CMD_VCOMOFFS); - writedata(0);//0x40 - delay(1); - - writecommand(CMD_CLMADRS);//Set Column Address - writedata16(0x00); - writedata16(_GRAMWIDTH); - - writecommand(CMD_PGEADRS);//Set Page Address - writedata16(0X00); - writedata16(_GRAMHEIGH); - // set scroll area (thanks Masuda) - writecommand(CMD_VSCLLDEF); - writedata16(__OFFSET); - writedata16(_GRAMHEIGH - __OFFSET); - writedata16(0); - colorSpace(_colorspaceData); - setRotation(0); - writecommand(CMD_DISPON);//display ON - delay(1); - writecommand(CMD_RAMWR);//Memory Write - - delay(1); - #endif - fillScreen(BLACK); -} - -/* -Colorspace selection: -0: RGB -1: GBR -*/ -void TFT_ILI9163C::colorSpace(uint8_t cspace) { - if (cspace < 1){ - bitClear(_Mactrl_Data,3); - } else { - bitSet(_Mactrl_Data,3); - } -} - -void TFT_ILI9163C::invertDisplay(boolean i) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_last(i ? CMD_DINVON : CMD_DINVOF); - SPI.endTransaction(); - #else - writecommand(i ? CMD_DINVON : CMD_DINVOF); - #endif -} - -void TFT_ILI9163C::display(boolean onOff) { - if (onOff){ - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_last(CMD_DISPON); - endProc(); - #else - writecommand(CMD_DISPON); - #endif - } else { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_last(CMD_DISPOFF); - endProc(); - #else - writecommand(CMD_DISPOFF); - #endif - } -} - -void TFT_ILI9163C::idleMode(boolean onOff) { - if (onOff){ - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_last(CMD_IDLEON); - endProc(); - #else - writecommand(CMD_IDLEON); - #endif - } else { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_last(CMD_IDLEOF); - endProc(); - #else - writecommand(CMD_IDLEOF); - #endif - } -} - -void TFT_ILI9163C::sleepMode(boolean mode) { - if (mode){ - if (sleep == 1) return;//already sleeping - sleep = 1; - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_last(CMD_SLPIN); - endProc(); - #else - writecommand(CMD_SLPIN); - #endif - delay(5);//needed - } else { - if (sleep == 0) return; //Already awake - sleep = 0; - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_last(CMD_SLPOUT); - endProc(); - #else - writecommand(CMD_SLPOUT); - #endif - delay(120);//needed - } -} - -void TFT_ILI9163C::defineScrollArea(uint16_t tfa, uint16_t bfa){ - tfa += __OFFSET; - int16_t vsa = _GRAMHEIGH - tfa - bfa; - if (vsa >= 0) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_cont(CMD_VSCLLDEF); - writedata16_cont(tfa); - writedata16_cont(vsa); - writedata16_last(bfa); - endProc(); - #else - writecommand(CMD_VSCLLDEF); - writedata16(tfa); - writedata16(vsa); - writedata16(bfa); - #endif - } -} - -void TFT_ILI9163C::scroll(uint16_t adrs) { - if (adrs <= _GRAMHEIGH) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_cont(CMD_VSSTADRS); - writedata16_last(adrs + __OFFSET); - endProc(); - #else - writecommand(CMD_VSSTADRS); - writedata16(adrs + __OFFSET); - #endif - } -} - - -//corrected! v3 -void TFT_ILI9163C::clearScreen(uint16_t color) { - int px; - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - //writecommand_cont(CMD_RAMWR); - _setAddrWindow(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH); - for (px = 0;px < _GRAMSIZE; px++){ - writedata16_cont(color); - } - writecommand_last(CMD_NOP); - endProc(); - #elif defined(SPI_MODE_DMA) - fillScanline(color, _GRAMHEIGH); - setAddr(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH);//go home - *rsport |= rspinmask; - *csport &= ~cspinmask; - for (px = 0; px < _GRAMWIDTH; px++){ - writeScanline(_GRAMHEIGH); - } - *csport |= cspinmask; - - #else - //writecommand(CMD_RAMWR); - setAddr(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH);//go home - for (px = 0;px < _GRAMSIZE; px++){ - writedata16(color); - } - #endif -} - -void TFT_ILI9163C::startPushData(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - setAddr(x0,y0,x1,y1); -} - -void TFT_ILI9163C::pushData(uint16_t color) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - writedata16_cont(color); - #else - writedata16(color); - #endif -} - - -void TFT_ILI9163C::endPushData() { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - writecommand_last(CMD_NOP); - endProc(); - #endif -} - - -void TFT_ILI9163C::pushColor(uint16_t color) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writedata16_last(color); - endProc(); - #else - writedata16(color); - #endif -} - -void TFT_ILI9163C::writeScreen24(const uint32_t *bitmap,uint16_t size) { - uint16_t color; - int px; - #if defined(__MK20DX128__) || defined(__MK20DX256__) - writecommand_cont(CMD_RAMWR); - for (px = 0;px < size; px++){//16384 - color = Color24To565(bitmap[px]); - writedata16_cont(color); - } - _setAddrWindow(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH);//home - endProc(); - #else - - writecommand(CMD_RAMWR); - for (px = 0;px < size; px++){ - color = Color24To565(bitmap[px]); - writedata16(color); - } - homeAddress(); - #endif -} - -void TFT_ILI9163C::homeAddress() { - setAddrWindow(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH); -} - - - -void TFT_ILI9163C::setCursor(int16_t x, int16_t y) { - if (boundaryCheck(x,y)) return; - setAddrWindow(0x00,0x00,x,y); - cursor_x = x; - cursor_y = y; -} - - - -void TFT_ILI9163C::drawPixel(int16_t x, int16_t y, uint16_t color) { - if (boundaryCheck(x,y)) return; - if ((x < 0) || (y < 0)) return; - setAddr(x,y,x+1,y+1); - #if defined(__MK20DX128__) || defined(__MK20DX256__) - writedata16_last(color); - endProc(); - #else - writedata16(color); - #endif -} - - - -void TFT_ILI9163C::endProc(void){ - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.endTransaction(); - #endif -} - - -void TFT_ILI9163C::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) { - // Rudimentary clipping - if (boundaryCheck(x,y)) return; - if (((y + h) - 1) >= _height) h = _height-y; - if (h < 2 ) { - drawPixel(x, y, color); - return; - } - setAddr(x,y,x,(y+h)-1); - #if !defined SPI_MODE_DMA - while (h-- > 1) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - if (h == 0){ - writedata16_last(color); - } else { - writedata16_cont(color); - } - #else - writedata16(color); - #endif - } - - endProc(); - #else //SPI_MODE_DMA - fillScanline(color, h); - *rsport |= rspinmask; - *csport &= ~cspinmask; - writeScanline(h); - *csport |= cspinmask; - #endif -} - -bool TFT_ILI9163C::boundaryCheck(int16_t x,int16_t y){ - if ((x >= _width) || (y >= _height)) return true; - return false; -} - -void TFT_ILI9163C::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) { - // Rudimentary clipping - if (boundaryCheck(x,y)) return; - if (((x+w) - 1) >= _width) w = _width-x; - if (w < 2 ) { - drawPixel(x, y, color); - return; - } - setAddr(x,y,(x+w)-1,y); - #if !defined SPI_MODE_DMA - while (w-- > 1) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - if (w == 0){ - writedata16_last(color); - } else { - writedata16_cont(color); - } - #else - writedata16(color); - #endif - } - endProc(); - #else //SPI_MODE_DMA - fillScanline(color, w); - *rsport |= rspinmask; - *csport &= ~cspinmask; - writeScanline(w); - *csport |= cspinmask; - #endif -} - -inline void TFT_ILI9163C::fillScreen(uint16_t color) { - clearScreen(color); -} - -// fill a rectangle -void TFT_ILI9163C::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if (boundaryCheck(x,y)) return; - if (((x + w) - 1) >= _width) w = _width - x; - if (((y + h) - 1) >= _height) h = _height - y; - if (w == 1 && h == 1) { - drawPixel(x, y, color); - return; - } - #if !defined SPI_MODE_DMA - setAddr(x,y,(x+w)-1,(y+h)-1); - for (y = h;y > 0;y--) { - for (x = w;x > 0;x--) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - writedata16_cont(color); - #else - writedata16(color); - #endif - } - #if defined(__MK20DX128__) || defined(__MK20DX256__) - writedata16_last(color); - #endif - } - endProc(); - #else //SPI_MODE_DMA - setAddr(x,y,(x+w)-1,(y+h)-1); - if (w < h) swap(w, h); - fillScanline(color, w); - *rsport |= rspinmask; - *csport &= ~cspinmask; - for (y = h;y > 0;y--) { - writeScanline(w); - } - *csport |= cspinmask; - #endif -} - -#if defined(__MK20DX128__) || defined(__MK20DX256__) -void TFT_ILI9163C::drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color){ - if (y0 == y1) { - if (x1 > x0) { - drawFastHLine(x0, y0, x1 - x0 + 1, color); - } else if (x1 < x0) { - drawFastHLine(x1, y0, x0 - x1 + 1, color); - } else { - drawPixel(x0, y0, color); - } - return; - } else if (x0 == x1) { - if (y1 > y0) { - drawFastVLine(x0, y0, y1 - y0 + 1, color); - } else { - drawFastVLine(x0, y1, y0 - y1 + 1, color); - } - return; - } - - bool steep = abs(y1 - y0) > abs(x1 - x0); - if (steep) { - swap(x0, y0); - swap(x1, y1); - } - if (x0 > x1) { - swap(x0, x1); - swap(y0, y1); - } - - int16_t dx, dy; - dx = x1 - x0; - dy = abs(y1 - y0); - - int16_t err = dx / 2; - int16_t ystep; - - if (y0 < y1) { - ystep = 1; - } else { - ystep = -1; - } - - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - int16_t xbegin = x0; - if (steep) { - for (; x0<=x1; x0++) { - err -= dy; - if (err < 0) { - int16_t len = x0 - xbegin; - if (len) { - VLine(y0, xbegin, len + 1, color); - } else { - Pixel(y0, x0, color); - } - xbegin = x0 + 1; - y0 += ystep; - err += dx; - } - } - if (x0 > xbegin + 1) { - VLine(y0, xbegin, x0 - xbegin, color); - } - - } else { - for (; x0<=x1; x0++) { - err -= dy; - if (err < 0) { - int16_t len = x0 - xbegin; - if (len) { - HLine(xbegin, y0, len + 1, color); - } else { - Pixel(x0, y0, color); - } - xbegin = x0 + 1; - y0 += ystep; - err += dx; - } - } - if (x0 > xbegin + 1) { - HLine(xbegin, y0, x0 - xbegin, color); - } - } - writecommand_last(CMD_NOP); - SPI.endTransaction(); -} - -void TFT_ILI9163C::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){ - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - HLine(x, y, w, color); - HLine(x, y+h-1, w, color); - VLine(x, y, h, color); - VLine(x+w-1, y, h, color); - writecommand_last(CMD_NOP); - SPI.endTransaction(); -} - - -#endif - -void TFT_ILI9163C::setAddr(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1){ - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - _setAddrWindow(x0,y0,x1,y1); - #else - setAddrWindow(x0,y0,x1,y1); - #endif -} - -void TFT_ILI9163C::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - _setAddrWindow(x0,y0,x1,y1); - SPI.endTransaction(); - #else - writecommand(CMD_CLMADRS); // Column - if (rotation == 0 || rotation > 1){ - writedata16(x0); - writedata16(x1); - } else { - writedata16(x0 + __OFFSET); - writedata16(x1 + __OFFSET); - } - - writecommand(CMD_PGEADRS); // Page - if (rotation == 0){ - writedata16(y0 + __OFFSET); - writedata16(y1 + __OFFSET); - } else { - writedata16(y0); - writedata16(y1); - } - writecommand(CMD_RAMWR); //Into RAM - #endif -} - -#if defined(__MK20DX128__) || defined(__MK20DX256__) -void TFT_ILI9163C::_setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - writecommand_cont(CMD_CLMADRS); // Column - if (rotation == 0 || rotation > 1){ - writedata16_cont(x0); - writedata16_cont(x1); - } else { - writedata16_cont(x0 + __OFFSET); - writedata16_cont(x1 + __OFFSET); - } - writecommand_cont(CMD_PGEADRS); // Page - if (rotation == 0){ - writedata16_cont(y0 + __OFFSET); - writedata16_cont(y1 + __OFFSET); - } else { - writedata16_cont(y0); - writedata16_cont(y1); - } - writecommand_cont(CMD_RAMWR); //Into RAM -} -#endif - -void TFT_ILI9163C::setRotation(uint8_t m) { - rotation = m % 4; // can't be higher than 3 - switch (rotation) { - case 0: - _Mactrl_Data = 0b00001000; - _width = _TFTWIDTH; - _height = _TFTHEIGHT;//-__OFFSET; - break; - case 1: - _Mactrl_Data = 0b01101000; - _width = _TFTHEIGHT;//-__OFFSET; - _height = _TFTWIDTH; - break; - case 2: - _Mactrl_Data = 0b11001000; - _width = _TFTWIDTH; - _height = _TFTHEIGHT;//-__OFFSET; - break; - case 3: - _Mactrl_Data = 0b10101000; - _width = _TFTWIDTH; - _height = _TFTHEIGHT;//-__OFFSET; - break; - } - colorSpace(_colorspaceData); - #if defined(__MK20DX128__) || defined(__MK20DX256__) - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - writecommand_cont(CMD_MADCTL); - writedata8_last(_Mactrl_Data); - endProc(); - #else - writecommand(CMD_MADCTL); - writedata(_Mactrl_Data); - #endif -} - -#if SPI_MODE_DMA -void TFT_ILI9163C::drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color) -{ - if (y0 == y1) { - if (x1 > x0) { - drawFastHLine(x0, y0, x1 - x0 + 1, color); - } - else if (x1 < x0) { - drawFastHLine(x1, y0, x0 - x1 + 1, color); - } - else { - drawPixel(x0, y0, color); - } - return; - } - else if (x0 == x1) { - if (y1 > y0) { - drawFastVLine(x0, y0, y1 - y0 + 1, color); - } - else { - drawFastVLine(x0, y1, y0 - y1 + 1, color); - } - return; - } - - bool steep = abs(y1 - y0) > abs(x1 - x0); - if (steep) { - swap(x0, y0); - swap(x1, y1); - } - if (x0 > x1) { - swap(x0, x1); - swap(y0, y1); - } - - int16_t dx, dy; - dx = x1 - x0; - dy = abs(y1 - y0); - - int16_t err = dx / 2; - int16_t ystep; - - if (y0 < y1) { - ystep = 1; - } - else { - ystep = -1; - } - - int16_t xbegin = x0; - fillScanline(color, _GRAMHEIGH); - *csport &= ~cspinmask; - if (steep) { - for (; x0 <= x1; x0++) { - err -= dy; - if (err < 0) { - int16_t len = x0 - xbegin; - if (len) { - //drawFastVLine (y0, xbegin, len + 1, color); - writeVLine_cont_noCS_noFill(y0, xbegin, len + 1); - } - else { - //drawPixel(x0, y0, color); - writePixel_cont_noCS(y0, x0, color); - } - xbegin = x0 + 1; - y0 += ystep; - err += dx; - } - } - if (x0 > xbegin + 1) { - writeVLine_cont_noCS_noFill(y0, xbegin, x0 - xbegin); - } - - } - else { - for (; x0 <= x1; x0++) { - err -= dy; - if (err < 0) { - int16_t len = x0 - xbegin; - if (len) { - //drawFastVLine(xbegin, y0, len + 1, color); - writeHLine_cont_noCS_noFill(xbegin, y0, len + 1); - } - else { - //drawPixel(x0, y0, color); - writePixel_cont_noCS(x0, y0, color); - } - xbegin = x0 + 1; - y0 += ystep; - err += dx; - } - } - if (x0 > xbegin + 1) { - writeHLine_cont_noCS_noFill(xbegin, y0, x0 - xbegin); - } - } - *csport |= cspinmask; -} - -void TFT_ILI9163C::writePixel_cont_noCS(int16_t x, int16_t y, uint16_t color) -{ - if (boundaryCheck(x,y)) return; - if ((x < 0) || (y < 0)) return; - setAddrWindow_cont(x,y,x+1,y+1); - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport |= rspinmask; - #if defined SPI_16BIT - SPI.write(color); - #else - spiwrite(color >> 8); - spiwrite(color); - #endif - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::writeVLine_cont_noCS_noFill(int16_t x, int16_t y, int16_t h) -{ - // Rudimentary clipping - if (boundaryCheck(x,y)) return; - if ((x < 0) || (y < 0)) return; - if (((y + h) - 1) >= _height) h = _height-y; - setAddrWindow_cont(x,y,x,(y+h)-1); - *rsport |= rspinmask; - writeScanline(h); // send 2 bytes per pixel -} - -void TFT_ILI9163C::writeHLine_cont_noCS_noFill(int16_t x, int16_t y, int16_t w) -{ - // Rudimentary clipping - if (boundaryCheck(x,y)) return; - if ((x < 0) || (y < 0)) return; - if (((x+w) - 1) >= _width) w = _width-x; - setAddrWindow_cont(x,y,(x+w)-1,y); - *rsport |= rspinmask; - writeScanline(w); -} - -void TFT_ILI9163C::setAddrWindow_cont(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - writecommand_cont(CMD_CLMADRS); // Column - if (rotation == 0 || rotation > 1){ - writedata16_cont(x0); - writedata16_cont(x1); - } else { - writedata16_cont(x0 + __OFFSET); - writedata16_cont(x1 + __OFFSET); - } - writecommand_cont(CMD_PGEADRS); // Page - if (rotation == 0){ - writedata16_cont(y0 + __OFFSET); - writedata16_cont(y1 + __OFFSET); - } else { - writedata16_cont(y0); - writedata16_cont(y1); - } - writecommand_cont(CMD_RAMWR); //Into RAM -} - -void TFT_ILI9163C::writedata16_cont(uint16_t d){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport |= rspinmask; -#if defined SPI_16BIT - SPI.write(d); -#else - spiwrite(d >> 8); - spiwrite(d); -#endif - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::writecommand_cont(uint8_t c){ - #ifdef SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); - #endif - *rsport &= ~rspinmask;//low - spiwrite(c); - #ifdef SPI_HAS_TRANSACTION - SPI.endTransaction(); - #endif -} - -void TFT_ILI9163C::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){ - fillScanline(color, _GRAMHEIGH); - *csport &= ~cspinmask; - writeHLine_cont_noCS_noFill(x, y, w); - writeHLine_cont_noCS_noFill(x, y+h-1, w); - writeVLine_cont_noCS_noFill(x, y, h); - writeVLine_cont_noCS_noFill(x+w-1, y, h); - *csport |= cspinmask; -} - -void TFT_ILI9163C::drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color) -{ - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - *csport &= ~cspinmask; - writePixel_cont_noCS(x0, y0 + r, color); - writePixel_cont_noCS(x0, y0 - r, color); - writePixel_cont_noCS(x0 + r, y0, color); - writePixel_cont_noCS(x0 - r, y0, color); - #if SPEED_UP - if (r<6){ - #endif - while (x < y) { - if (f >= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - writePixel_cont_noCS(x0 + x, y0 + y, color); - writePixel_cont_noCS(x0 - x, y0 + y, color); - writePixel_cont_noCS(x0 + x, y0 - y, color); - writePixel_cont_noCS(x0 - x, y0 - y, color); - writePixel_cont_noCS(x0 + y, y0 + x, color); - writePixel_cont_noCS(x0 - y, y0 + x, color); - writePixel_cont_noCS(x0 + y, y0 - x, color); - writePixel_cont_noCS(x0 - y, y0 - x, color); - } - #if SPEED_UP - } - else { - fillScanline(color, _GRAMHEIGH); - int16_t xi = x; - int16_t yi = y; - int16_t w = 0; - while (x < y) { - if (f >= 0) { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - if (y < yi){ - w = x - xi; - if (w > 0){ - writeHLine_cont_noCS_noFill(x0 + xi, y0 + yi, w); - writeHLine_cont_noCS_noFill(x0 - x + 1, y0 + yi, w); - writeHLine_cont_noCS_noFill(x0 + xi, y0 - yi, w); - writeHLine_cont_noCS_noFill(x0 - x + 1, y0 - yi, w); - writeVLine_cont_noCS_noFill(x0 + yi, y0 + xi, w); - writeVLine_cont_noCS_noFill(x0 - yi, y0 + xi, w); - writeVLine_cont_noCS_noFill(x0 + yi, y0 - x + 1, w); - writeVLine_cont_noCS_noFill(x0 - yi, y0 - x + 1, w); - } - else { - writePixel_cont_noCS(x0 + x, y0 + y, color); - writePixel_cont_noCS(x0 - x, y0 + y, color); - writePixel_cont_noCS(x0 + x, y0 - y, color); - writePixel_cont_noCS(x0 - x, y0 - y, color); - writePixel_cont_noCS(x0 + y, y0 + x, color); - writePixel_cont_noCS(x0 - y, y0 + x, color); - writePixel_cont_noCS(x0 + y, y0 - x, color); - writePixel_cont_noCS(x0 - y, y0 - x, color); - } - yi = y; - xi = x; - } - } - writePixel_cont_noCS(x0 + x, y0 + y, color); - writePixel_cont_noCS(x0 - x, y0 + y, color); - writePixel_cont_noCS(x0 + x, y0 - y, color); - writePixel_cont_noCS(x0 - x, y0 - y, color); - writePixel_cont_noCS(x0 + y, y0 + x, color); - writePixel_cont_noCS(x0 - y, y0 + x, color); - writePixel_cont_noCS(x0 + y, y0 - x, color); - writePixel_cont_noCS(x0 - y, y0 - x, color); - } - #endif - *csport |= cspinmask; -} - -// Sets first n pixels in scanline buffer to the specified color -// __attribute__((always_inline)) -void TFT_ILI9163C::fillScanline(uint16_t color, size_t n) { -#if defined SPI_16BIT - //color = (color << 8) | (color >> 8); -// for (uint16_t i = 0; i < n; i ++) -// { - _scanlineBuffer16[0] = color; -// } -#else - _hiByte = highByte(color); - _loByte = lowByte(color); - for (uint16_t i = 0; i < (n << 1); i += 2) - { - _scanlineBuffer8[i] = _hiByte; - _scanlineBuffer8[i + 1] = _loByte; - } -#endif -} - -// Enables CS, sets DC and writes n-bytes from the scanline buffer via DMA -// Does not disable CS -// inline __attribute__((always_inline)) -void TFT_ILI9163C::writeScanline(size_t n) { - if (n == 0) return; -#if defined SPI_16BIT - SPI.dmaSend(_scanlineBuffer16, n, 0); // each pixel is one halfword. circular mode -#else - SPI.dmaSend(_scanlineBuffer8, n << 1); // each pixel is 2 bytes -#endif -} - - -#endif - - - diff --git a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/TFT_ILI9163C.h b/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/TFT_ILI9163C.h deleted file mode 100644 index d5014d1..0000000 --- a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/TFT_ILI9163C.h +++ /dev/null @@ -1,512 +0,0 @@ -/* Modified 04/2015 by Victor G. Perez to add support for Maple and Maple mini, STM32F103 processors -* It can use SPI DMA transfers. To not use DMA, comment out the next define. -* Requires function dmaSend in SPI library. Result with 16bit SPI and DMA modes enabled in Maple Mini. -*/ -#define SPI_16BIT -#define SPI_MODE_DMA 1 -#define SPEED_UP 1 // Enables extra calculations in the circles routine to use fastVLine and fastHLine, only in DMA mode. - - -/* - ILI9163C - A fast SPI driver for TFT that use Ilitek ILI9163C. - - Features: - - Very FAST!, expecially with Teensy 3.x where uses hyper optimized SPI. - - It uses just 4 or 5 wires. - - Compatible at command level with Adafruit display series so it's easy to adapt existing code. - - It uses the standard Adafruit_GFX Library (you need to install). - - Background: - I got one of those displays from a chinese ebay seller but unfortunatly I cannot get - any working library so I decided to hack it. ILI9163C looks pretty similar to other - display driver but it uses it's own commands so it's tricky to work with it unlsess you - carefully fight with his gigantic and not so clever datasheet. - My display it's a 1.44"", 128x128 that suppose to substitute Nokia 5110 LCD and here's the - first confusion! Many sellers claim that it's compatible with Nokia 5110 (that use a philips - controller) but the only similarity it's the pin names since that this one it's color and - have totally different controller that's not compatible. - http://www.ebay.com/itm/Replace-Nokia-5110-LCD-1-44-Red-Serial-128X128-SPI-Color-TFT-LCD-Display-Module-/141196897388 - http://www.elecrow.com/144-128x-128-tft-lcd-with-spi-interface-p-855.html - Pay attention that can drive different resolutions and your display can be - 160*128 or whatever, also there's a strain of this display with a black PCB that a friend of mine - got some weeks ago and need some small changes in library to get working. - If you look at TFT_ILI9163C.h file you can add your modifications and let me know so I - can include for future versions. - - Code Optimizations: - The purpose of this library it's SPEED. I have tried to use hardware optimized calls - where was possible and results are quite good for most applications, actually nly filled circles - are still a bit slow. Many SPI call has been optimized by reduce un-needed triggers to RS and CS - lines. Of course it can be improved so feel free to add suggestions. - ------------------------------------------------------------------------------- - Copyright (c) 2014, .S.U.M.O.T.O.Y., coded by Max MC Costa. - - TFT_ILI9163C Library is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - TFT_ILI9163C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Foobar. If not, see . - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - This file needs the following Libraries: - - Adafruit_GFX by Adafruit: - https://github.com/adafruit/Adafruit-GFX-Library - Remember to update GFX library often to have more features with this library! - From this version I'm using my version of Adafruit_GFX library: - https://github.com/sumotoy/Adafruit-GFX-Library - It has faster char rendering and some small little optimizations but you can - choose one of the two freely since are both fully compatible. - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Special Thanks: - Thanks Adafruit for his Adafruit_GFX! - Thanks to Paul Stoffregen for his beautiful Teensy3 and DMA SPI. - - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - Version: - 0.1a1: First release, compile correctly. Altrough not fully working! - 0.1a3: Better but still some addressing problems. - 0.1b1: Beta! Addressing solved, now rotation works and boundaries ok. - 0.2b1: Cleaned up. - 0.2b3: Added 2.2" Red PCB parameters - 0.2b4: Bug fixes, added colorSpace (for future send image) - 0.2b5: Cleaning - 0.3b1: Complete rework on Teensy SPI based on Paul Stoffregen work - SPI transaction,added BLACK TAG 2.2 display - 0.3b2: Minor fix, load 24bit image, Added conversion utility - 0.4: some improvement, new ballistic gauge example! - 0.5: Added scroll and more commands, optimizations - 0.6: Small fix, added SD example and subroutines - 0.6b1: Fix clearscreen, missed a parameter. - 0.6b2: Scroll completed. (thanks Masuda) - 0.6b3: Clear Screen fix v2. Added Idle mode. - 0.7: Init correction.Clear Screen fix v3 (last time?) - 0.75: SPI transactions for arduino's (beta) - 0.8: Compatiblke with IDE 1.0.6 (teensyduino 1.20) and IDE 1.6.x (teensyduino 1.21b) - +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - BugList of the current version: - - Please report any! - - -Here's the speed test between 0.2b5 and 0.3b1 on Teensy3.1 (major SPI changes) ------------------------------------------------------------------------- -Lines 17024 16115 BETTER -Horiz/Vert Lines 5360 5080 BETTER -Rectangles (outline) 4384 4217 BETTER -Rectangles (filled) 96315 91265 BETTER -Circles (filled) 16053 15829 LITTLE BETTER -Circles (outline) 11540 20320 WORST! -Triangles (outline) 5359 5143 BETTER -Triangles (filled) 19088 18741 BETTER -Rounded rects (outline) 8681 12498 LITTLE WORST -Rounded rects (filled) 105453 100213 BETTER -Done! - - -*/ - - -/* -Benchmark Time (microseconds) -Screen fill 40676 -Text 11756 -Lines 42841 -Horiz/Vert Lines 4033 -Rectangles (outline) 3724 -Rectangles (filled) 65417 -Circles (filled) 28576 -Circles (outline) 22532 -Triangles (outline) 14877 -Triangles (filled) 34927 -Rounded rects (outline) 18777 -Rounded rects (filled) 77142 -Done! - - -*/ - -#ifndef _TFT_ILI9163CLIB_H_ -#define _TFT_ILI9163CLIB_H_ - - -#include "Arduino.h" -#include "Print.h" -#include - - - -//DID YOU HAVE A RED PCB, BLACk PCB or WHAT DISPLAY TYPE???????????? ---> SELECT HERE <---- -//#define __144_RED_PCB__//128x128 -#define __144_BLACK_PCB__//128x128 -//#define __22_RED_PCB__//240x320 -//--------------------------------------- - -#if defined(__SAM3X8E__) - #include - #define PROGMEM - #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) - #define pgm_read_word(addr) (*(const unsigned short *)(addr)) - typedef unsigned char prog_uchar; - #define SPICLOCK 8000000 -#endif -#ifdef __AVR__ - #include - #define SPICLOCK 8000000 -#endif -#if defined(__MK20DX128__) || defined(__MK20DX256__) - #define SPICLOCK 30000000 -#endif - - -#if defined(__144_RED_PCB__) -/* -This display: -http://www.ebay.com/itm/Replace-Nokia-5110-LCD-1-44-Red-Serial-128X128-SPI-Color-TFT-LCD-Display-Module-/271422122271 -This particular display has a design error! The controller has 3 pins to configure to constrain -the memory and resolution to a fixed dimension (in that case 128x128) but they leaved those pins -configured for 128x160 so there was several pixel memory addressing problems. -I solved by setup several parameters that dinamically fix the resolution as needed so below -the parameters for this diplay. If you have a strain or a correct display (can happen with chinese) -you can copy those parameters and create setup for different displays. -*/ - #define _TFTWIDTH 128//the REAL W resolution of the TFT - #define _TFTHEIGHT 128//the REAL H resolution of the TFT - #define _GRAMWIDTH 128 - #define _GRAMHEIGH 160//160 - #define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH//*see note 1 - #define __COLORSPC 1// 1:GBR - 0:RGB - #define __GAMMASET3 //uncomment for another gamma - #define __OFFSET 32//*see note 2 - //Tested! -#elif defined (__144_BLACK_PCB__) - #define _TFTWIDTH 128//the REAL W resolution of the TFT - #define _TFTHEIGHT 128//the REAL H resolution of the TFT - #define _GRAMWIDTH 128 - #define _GRAMHEIGH 128 - #define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH//*see note 1 - #define __COLORSPC 1// 1:GBR - 0:RGB - #define __GAMMASET1 //uncomment for another gamma - #define __OFFSET 0 - //not tested -#elif defined (__22_RED_PCB__) -/* -Like this one: -http://www.ebay.it/itm/2-2-Serial-SPI-TFT-LCD-Display-Module-240x320-Chip-ILI9340C-PCB-Adapter-SD-Card-/281304733556 -Not tested! -*/ - #define _TFTWIDTH 240//the REAL W resolution of the TFT - #define _TFTHEIGHT 320//the REAL H resolution of the TFT - #define _GRAMWIDTH 240 - #define _GRAMHEIGH 320 - #define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH - #define __COLORSPC 1// 1:GBR - 0:RGB - #define __GAMMASET1 //uncomment for another gamma - #define __OFFSET 0 -#else - #define _TFTWIDTH 128//128 - #define _TFTHEIGHT 160//160 - #define _GRAMWIDTH 128 - #define _GRAMHEIGH 160 - #define _GRAMSIZE _GRAMWIDTH * _GRAMHEIGH - #define __COLORSPC 1// 1:GBR - 0:RGB - #define __GAMMASET1 - #define __OFFSET 0 -#endif -/* - Note 1: The __144_RED_PCB__ display has hardware addressing of 128 x 160 - but the tft resolution it's 128 x 128 so the dram should be set correctly - - Note 2: This is the offset between image in RAM and TFT. In that case 160 - 128 = 32; -*/ - -//--------- Color definitions ------------- - -#define BLACK 0x0000 -#define BLUE 0x001F -#define RED 0xF800 -#define GREEN 0x07E0 -#define CYAN 0x07FF -#define MAGENTA 0xF81F -#define YELLOW 0xFFE0 -#define WHITE 0xFFFF -#define TRANSPARENT -1 - -//--------- Used for STM32 DMA ------------ -#define SCANLINE_BUFFER_SIZE _GRAMHEIGH - -//ILI9163C registers----------------------- -#define CMD_NOP 0x00//Non operation -#define CMD_SWRESET 0x01//Soft Reset -#define CMD_SLPIN 0x10//Sleep ON -#define CMD_SLPOUT 0x11//Sleep OFF -#define CMD_PTLON 0x12//Partial Mode ON -#define CMD_NORML 0x13//Normal Display ON -#define CMD_DINVOF 0x20//Display Inversion OFF -#define CMD_DINVON 0x21//Display Inversion ON -#define CMD_GAMMASET 0x26//Gamma Set (0x01[1],0x02[2],0x04[3],0x08[4]) -#define CMD_DISPOFF 0x28//Display OFF -#define CMD_DISPON 0x29//Display ON -#define CMD_IDLEON 0x39//Idle Mode ON -#define CMD_IDLEOF 0x38//Idle Mode OFF -#define CMD_CLMADRS 0x2A//Column Address Set -#define CMD_PGEADRS 0x2B//Page Address Set - -#define CMD_RAMWR 0x2C//Memory Write -#define CMD_RAMRD 0x2E//Memory Read -#define CMD_CLRSPACE 0x2D//Color Space : 4K/65K/262K -#define CMD_PARTAREA 0x30//Partial Area -#define CMD_VSCLLDEF 0x33//Vertical Scroll Definition -#define CMD_TEFXLON 0x35//Tearing Effect Line ON -#define CMD_TEFXLOF 0x34//Tearing Effect Line OFF -#define CMD_MADCTL 0x36//Memory Access Control -#define CMD_VSSTADRS 0x37//Vertical Scrolling Start address -#define CMD_PIXFMT 0x3A//Interface Pixel Format -#define CMD_FRMCTR1 0xB1//Frame Rate Control (In normal mode/Full colors) -#define CMD_FRMCTR2 0xB2//Frame Rate Control(In Idle mode/8-colors) -#define CMD_FRMCTR3 0xB3//Frame Rate Control(In Partial mode/full colors) -#define CMD_DINVCTR 0xB4//Display Inversion Control -#define CMD_RGBBLK 0xB5//RGB Interface Blanking Porch setting -#define CMD_DFUNCTR 0xB6//Display Fuction set 5 -#define CMD_SDRVDIR 0xB7//Source Driver Direction Control -#define CMD_GDRVDIR 0xB8//Gate Driver Direction Control - -#define CMD_PWCTR1 0xC0//Power_Control1 -#define CMD_PWCTR2 0xC1//Power_Control2 -#define CMD_PWCTR3 0xC2//Power_Control3 -#define CMD_PWCTR4 0xC3//Power_Control4 -#define CMD_PWCTR5 0xC4//Power_Control5 -#define CMD_VCOMCTR1 0xC5//VCOM_Control 1 -#define CMD_VCOMCTR2 0xC6//VCOM_Control 2 -#define CMD_VCOMOFFS 0xC7//VCOM Offset Control -#define CMD_PGAMMAC 0xE0//Positive Gamma Correction Setting -#define CMD_NGAMMAC 0xE1//Negative Gamma Correction Setting -#define CMD_GAMRSEL 0xF2//GAM_R_SEL - - -class TFT_ILI9163C : public Adafruit_GFX { - - public: - - TFT_ILI9163C(uint8_t cspin,uint8_t dcpin,uint8_t rstpin); - TFT_ILI9163C(uint8_t CS, uint8_t DC);//connect rst pin to VDD - - void begin(void), - setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1),//graphic Addressing - setCursor(int16_t x,int16_t y),//char addressing - pushColor(uint16_t color), - fillScreen(uint16_t color=0x0000), - clearScreen(uint16_t color=0x0000),//same as fillScreen - drawPixel(int16_t x, int16_t y, uint16_t color), - drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), - drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), - #if defined(__MK20DX128__) || defined(__MK20DX256__)//workaround to get more speed from Teensy - drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color), - drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), - #endif - fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color), - setRotation(uint8_t r), - invertDisplay(boolean i); - void idleMode(boolean onOff); - void display(boolean onOff); - void sleepMode(boolean mode); - void defineScrollArea(uint16_t tfa, uint16_t bfa); - void scroll(uint16_t adrs); - void startPushData(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); - void pushData(uint16_t color); - void endPushData(); - void writeScreen24(const uint32_t *bitmap,uint16_t size=_TFTWIDTH*_TFTHEIGHT); - inline uint16_t Color565(uint8_t r, uint8_t g, uint8_t b) {return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);}; - //convert 24bit color into packet 16 bit one (credits for this are all mine) - inline uint16_t Color24To565(int32_t color_) { return ((((color_ >> 16) & 0xFF) / 8) << 11) | ((((color_ >> 8) & 0xFF) / 4) << 5) | (((color_) & 0xFF) / 8);} - void setBitrate(uint32_t n); - #if defined SPI_MODE_DMA - uint16_t _scanlineBuffer16[SCANLINE_BUFFER_SIZE]; - uint8_t* _scanlineBuffer8 = reinterpret_cast(_scanlineBuffer16); - uint8_t _hiByte, _loByte; - void fillScanline(uint16_t color, size_t n), - writeScanline(size_t n), - drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color), - writePixel_cont_noCS(int16_t x, int16_t y, uint16_t color), - writeVLine_cont_noCS_noFill(int16_t x, int16_t y, int16_t h), - writeHLine_cont_noCS_noFill(int16_t x, int16_t y, int16_t w), - setAddrWindow_cont(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1), - writecommand_cont(uint8_t c), - writedata16_cont(uint16_t d), - drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), - drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); - #endif //SPI_MODE_DMA - - private: - uint8_t _Mactrl_Data;//container for the memory access control data - uint8_t _colorspaceData; - void colorSpace(uint8_t cspace); - void setAddr(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); - void endProc(void); - uint8_t sleep; - - - #if defined(__MK20DX128__) || defined(__MK20DX256__) - // - #else - void writecommand(uint8_t c); - void writedata(uint8_t d); - void writedata16(uint16_t d); - #endif - void chipInit(); - bool boundaryCheck(int16_t x,int16_t y); - void homeAddress(); - #if defined (__AVR__) - void spiwrite(uint8_t); - volatile uint8_t *dataport, *clkport, *csport, *rsport; - uint8_t _cs,_rs,_sid,_sclk,_rst; - uint8_t datapinmask, clkpinmask, cspinmask, rspinmask; - #endif // #ifdef __AVR__ - - #if defined (__STM32F1__) - void spiwrite(uint8_t); - volatile uint32_t *dataport, *clkport, *csport, *rsport; - uint8_t _cs,_rs,_sid,_sclk,_rst; - uint32_t datapinmask, clkpinmask, cspinmask, rspinmask; - #endif // #ifdef __STM32F1__ - - #if defined(__SAM3X8E__) - void spiwrite(uint8_t); - Pio *dataport, *clkport, *csport, *rsport; - uint8_t _cs,_rs,_sid,_sclk,_rst; - uint32_t datapinmask, clkpinmask, cspinmask, rspinmask; - #endif // #if defined(__SAM3X8E__) - - #if defined(__MK20DX128__) || defined(__MK20DX256__) - //Here's Paul Stoffregen magic in action... - uint8_t _cs, _rs, _rst; - uint8_t pcs_data, pcs_command; - - void _setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);//graphic Addressing for Teensy - - void waitFifoNotFull(void) { - uint32_t sr; - uint32_t tmp __attribute__((unused)); - do { - #if ARDUINO >= 160 - sr = KINETISK_SPI0.SR; - #else - sr = SPI0.SR; - #endif - if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO - } while ((sr & (15 << 12)) > (3 << 12)); - } - - void waitFifoEmpty(void) { - uint32_t sr; - uint32_t tmp __attribute__((unused)); - do { - #if ARDUINO >= 160 - sr = KINETISK_SPI0.SR; - #else - sr = SPI0.SR; - #endif - if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO - } while ((sr & 0xF0F0) > 0); // wait both RX & TX empty - } - - void waitTransmitComplete(void) __attribute__((always_inline)) { - uint32_t tmp __attribute__((unused)); - #if ARDUINO >= 160 - while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done - #else - while (!(SPI0.SR & SPI_SR_TCF)) ; // wait until final output done - #endif - tmp = SPI0_POPR; // drain the final RX FIFO word - } - - void writecommand_cont(uint8_t c) __attribute__((always_inline)) { - #if ARDUINO >= 160 - KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT; - #else - SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT; - #endif - waitFifoNotFull(); - } - - void writedata8_cont(uint8_t c) __attribute__((always_inline)) { - #if ARDUINO >= 160 - KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT; - #else - SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT; - #endif - waitFifoNotFull(); - } - - void writedata16_cont(uint16_t d) __attribute__((always_inline)) { - #if ARDUINO >= 160 - KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT; - #else - SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT; - #endif - waitFifoNotFull(); - } - - void writecommand_last(uint8_t c) __attribute__((always_inline)) { - waitFifoEmpty(); - #if ARDUINO >= 160 - KINETISK_SPI0.SR = SPI_SR_TCF; - KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0); - #else - SPI0.SR = SPI_SR_TCF; - SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0); - #endif - waitTransmitComplete(); - } - - void writedata8_last(uint8_t c) __attribute__((always_inline)) { - waitFifoEmpty(); - #if ARDUINO >= 160 - KINETISK_SPI0.SR = SPI_SR_TCF; - KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0); - #else - SPI0.SR = SPI_SR_TCF; - SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0); - #endif - waitTransmitComplete(); - } - - void writedata16_last(uint16_t d) __attribute__((always_inline)) { - waitFifoEmpty(); - #if ARDUINO >= 160 - KINETISK_SPI0.SR = SPI_SR_TCF; - KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1); - #else - SPI0.SR = SPI_SR_TCF; - SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1); - #endif - waitTransmitComplete(); - } - - void HLine(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline)) { - _setAddrWindow(x, y, x+w-1, y); - //writecommand_cont(CMD_RAMWR);//not needed - do { writedata16_cont(color); } while (--w > 0); - } - - void Pixel(int16_t x, int16_t y, uint16_t color) __attribute__((always_inline)) { - _setAddrWindow(x, y, x, y); - //writecommand_cont(CMD_RAMWR);//not needed - writedata16_cont(color); - } - - void VLine(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline)) { - _setAddrWindow(x, y, x, y+h-1); - //writecommand_cont(CMD_RAMWR);//not needed - do { writedata16_cont(color); } while (--h > 0); - } - #endif - -}; -#endif \ No newline at end of file diff --git a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/coos_display_blink.ino b/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/coos_display_blink.ino deleted file mode 100644 index d78f4f9..0000000 --- a/GD32F1/libraries/MapleCoOS116/examples/coos_display_blink/coos_display_blink.ino +++ /dev/null @@ -1,220 +0,0 @@ -/* -* Multitasking Example with Maple CoOS. Victor Perez 2015 -* -*/ - -#include -#include ".\SPICoOS.h" -#include ".\TFT_ILI9163C.h" -#include - -#define __CS 8 -#define __RST 9 -#define __DC 10 - -TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST); - -OS_MutexID xDisplayFree; - -OS_STK vCube1LoopStk[TASK_STK_SIZE]; -OS_STK vCube2LoopStk[TASK_STK_SIZE]; -OS_STK vLEDFlashStk[TASK_STK_SIZE]; -OS_STK vSqrtStk[TASK_STK_SIZE]; - - -const float sin_d[] = { - 0, 0.17, 0.34, 0.5, 0.64, 0.77, 0.87, 0.94, 0.98, 1, 0.98, 0.94, - 0.87, 0.77, 0.64, 0.5, 0.34, 0.17, 0, -0.17, -0.34, -0.5, -0.64, - -0.77, -0.87, -0.94, -0.98, -1, -0.98, -0.94, -0.87, -0.77, - -0.64, -0.5, -0.34, -0.17 -}; -const float cos_d[] = { - 1, 0.98, 0.94, 0.87, 0.77, 0.64, 0.5, 0.34, 0.17, 0, -0.17, -0.34, - -0.5, -0.64, -0.77, -0.87, -0.94, -0.98, -1, -0.98, -0.94, -0.87, - -0.77, -0.64, -0.5, -0.34, -0.17, 0, 0.17, 0.34, 0.5, 0.64, 0.77, - 0.87, 0.94, 0.98 -}; -const float d = 5; -float cube1_px[] = { - -d, d, d, -d, -d, d, d, -d -}; -float cube1_py[] = { - -d, -d, d, d, -d, -d, d, d -}; -float cube1_pz[] = { - -d, -d, -d, -d, d, d, d, d -}; - -float cube1_p2x[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; -float cube1_p2y[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int cube1_r[] = { - 0, 0, 0 -}; -const float d2 = 10; -float cube2_px[] = { - -d2, d2, d2, -d2, -d2, d2, d2, -d2 -}; -float cube2_py[] = { - -d2, -d2, d2, d2, -d2, -d2, d2, d2 -}; -float cube2_pz[] = { - -d2, -d2, -d2, -d2, d2, d2, d2, d2 -}; - -float cube2_p2x[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; -float cube2_p2y[] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int cube2_r[] = { - 0, 0, 0 -}; - -uint16 cube1_x, cube1_y, cube2_x, cube2_y, cube1_color, cube2_color; - -static void vLEDFlashTask(void *pdata) { - for (;;) { - CoTickDelay(950); - digitalWrite(BOARD_LED_PIN, HIGH); - CoTickDelay(50); - digitalWrite(BOARD_LED_PIN, LOW); - } -} - -static void vCube1LoopTask(void *pdata) { - while (1) { - CoEnterMutexSection (xDisplayFree); - cube(cube1_px, cube1_py, cube1_pz, cube1_p2x, cube1_p2y, cube1_r, &cube1_x, &cube1_y, &cube1_color); - CoLeaveMutexSection( xDisplayFree ); - CoTickDelay(15); - } -} - -static void vCube2LoopTask(void *pdata) { - while (1) { - CoEnterMutexSection (xDisplayFree); - cube(cube2_px, cube2_py, cube2_pz, cube2_p2x, cube2_p2y, cube2_r, &cube2_x, &cube2_y, &cube2_color); - CoLeaveMutexSection( xDisplayFree ); - CoTickDelay(40); - } -} - - -void cube(float *px, float *py, float *pz, float *p2x, float *p2y, int *r, uint16 *x, uint16 *y, uint16 *color) { - - for (int i = 0; i < 3; i++) { - tft.drawLine(p2x[i], p2y[i], p2x[i + 1], p2y[i + 1], WHITE); - tft.drawLine(p2x[i + 4], p2y[i + 4], p2x[i + 5], p2y[i + 5], WHITE); - tft.drawLine(p2x[i], p2y[i], p2x[i + 4], p2y[i + 4], WHITE); - } - tft.drawLine(p2x[3], p2y[3], p2x[0], p2y[0], WHITE); - tft.drawLine(p2x[7], p2y[7], p2x[4], p2y[4], WHITE); - tft.drawLine(p2x[3], p2y[3], p2x[7], p2y[7], WHITE); - - r[0] = r[0] + 1; - r[1] = r[1] + 1; - if (r[0] == 36) r[0] = 0; - if (r[1] == 36) r[1] = 0; - if (r[2] == 36) r[2] = 0; - for (int i = 0; i < 8; i++) - { - float px2 = px[i]; - float py2 = cos_d[r[0]] * py[i] - sin_d[r[0]] * pz[i]; - float pz2 = sin_d[r[0]] * py[i] + cos_d[r[0]] * pz[i]; - - float px3 = cos_d[r[1]] * px2 + sin_d[r[1]] * pz2; - float py3 = py2; - float pz3 = -sin_d[r[1]] * px2 + cos_d[r[1]] * pz2; - - float ax = cos_d[r[2]] * px3 - sin_d[r[2]] * py3; - float ay = sin_d[r[2]] * px3 + cos_d[r[2]] * py3; - float az = pz3 - 190; - - p2x[i] = *x + ax * 500 / az; - p2y[i] = *y + ay * 500 / az; - } - - for (int i = 0; i < 3; i++) { - tft.drawLine(p2x[i], p2y[i], p2x[i + 1], p2y[i + 1], *color); - tft.drawLine(p2x[i + 4], p2y[i + 4], p2x[i + 5], p2y[i + 5], *color); - tft.drawLine(p2x[i], p2y[i], p2x[i + 4], p2y[i + 4], *color); - } - tft.drawLine(p2x[3], p2y[3], p2x[0], p2y[0], *color); - tft.drawLine(p2x[7], p2y[7], p2x[4], p2y[4], *color); - tft.drawLine(p2x[3], p2y[3], p2x[7], p2y[7], *color); -} - -static void vSqrtTask(void *pdata) { - while (1) { - Serial.println ("Starting Sqrt calculations..."); - uint16 x = 0; - uint16 ixx[1001]; - // Library Sqrt - uint32_t t0 = millis(); - for (uint32_t n = 247583650 ; n > 247400000 ; n--) { - x = sqrt (n); - } - uint32_t t1 = millis() - t0; - Serial.print ("Sqrt calculations took (ms): "); - Serial.println (t1); - CoTickDelay (5000); - } -} - -void setup() { - // initialize the digital pin as an output: - Serial.begin(9600); - delay (5000); - Serial.println ("Running..."); - pinMode(BOARD_LED_PIN, OUTPUT); - tft.begin(); - tft.fillScreen(WHITE); - cube1_x = ((tft.width()) / 4); - cube1_y = ((tft.height()) / 4); - cube2_x = ((tft.width()) / 2); - cube2_y = ((tft.height()) / 2); - cube1_color = BLACK; - cube2_color = RED; - CoInitOS(); - xDisplayFree = CoCreateMutex(); - CoCreateTask(vLEDFlashTask, - (void *)0 , - 2, - &vLEDFlashStk[TASK_STK_SIZE - 1], - TASK_STK_SIZE - ); - - CoCreateTask(vCube1LoopTask, - (void *)0 , - 3, - &vCube1LoopStk[TASK_STK_SIZE - 1], - TASK_STK_SIZE - ); - CoCreateTask(vCube2LoopTask, - (void *)0 , - 3, - &vCube2LoopStk[TASK_STK_SIZE - 1], - TASK_STK_SIZE - ); - CoCreateTask(vSqrtTask, - (void *)0 , - 6, - &vSqrtStk[TASK_STK_SIZE - 1], - TASK_STK_SIZE - ); - - CoStartOS(); -} - -void loop() { - // Do not write any code here, it would not execute. -} - - diff --git a/GD32F1/libraries/MapleCoOS116/keywords.txt b/GD32F1/libraries/MapleCoOS116/keywords.txt deleted file mode 100644 index 04e603d..0000000 --- a/GD32F1/libraries/MapleCoOS116/keywords.txt +++ /dev/null @@ -1,25 +0,0 @@ -####################################### -# Syntax Coloring Map For CoOS -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### -OS_STK KEYWORD1 -OS_MutexID KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -CoInitOS KEYWORD2 -CoCreateTask KEYWORD2 -CoStartOS KEYWORD2 -CoTickDelay KEYWORD2 -CoLeaveMutexSection KEYWORD2 -CoEnterMutexSection KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### -TASK_STK_SIZE LITERAL1 diff --git a/GD32F1/libraries/MapleCoOS116/utility/CoOS.h b/GD32F1/libraries/MapleCoOS116/utility/CoOS.h deleted file mode 100644 index 7271b19..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/CoOS.h +++ /dev/null @@ -1,246 +0,0 @@ -/** - ******************************************************************************* - * @file CoOS.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief API header file of CooCox CoOS. - * @details This file including all API functions's declare of CooCox CoOS. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -#ifndef _CCRTOS_H -#define _CCRTOS_H -#include "OsConfig.h" -/*---------------------------- Type Define ----------------------------------*/ -typedef signed char S8; -typedef unsigned char U8; -typedef short S16; -typedef unsigned short U16; -typedef int S32; -typedef unsigned int U32; -typedef long long S64; -typedef unsigned long long U64; -typedef unsigned char BIT; -typedef unsigned char BOOL; -typedef unsigned int OS_STK; -typedef U8 OS_TID; -typedef U8 OS_TCID; -typedef U8 OS_MutexID; -typedef U8 OS_EventID; -typedef U8 OS_FlagID; -typedef U8 OS_MMID; -typedef U8 StatusType; -typedef U16 OS_VER; -typedef void (*FUNCPtr)(void*); -typedef void (*vFUNCPtr)(void); - - -/*---------------------------- Constant Define -------------------------------*/ -#ifndef Co_NULL -#define Co_NULL ((void *)0) -#endif - -#ifndef Co_FALSE -#define Co_FALSE (0) -#endif - -#ifndef Co_TRUE -#define Co_TRUE (1) -#endif - - -/*---------------------------- Error Codes ---------------------------------*/ -#define E_CREATE_FAIL (StatusType)-1 -#define E_OK (StatusType)0 -#define E_INVALID_ID (StatusType)1 -#define E_INVALID_PARAMETER (StatusType)2 -#define E_CALL (StatusType)3 -#define E_TASK_WAITING (StatusType)4 -#define E_TIMEOUT (StatusType)5 -#define E_SEM_FULL (StatusType)6 -#define E_MBOX_FULL (StatusType)7 -#define E_QUEUE_FULL (StatusType)8 -#define E_SEM_EMPTY (StatusType)9 -#define E_MBOX_EMPTY (StatusType)10 -#define E_QUEUE_EMPTY (StatusType)11 -#define E_FLAG_NOT_READY (StatusType)12 -#define E_ALREADY_IN_WAITING (StatusType)13 -#define E_TASK_NOT_WAITING (StatusType)14 -#define E_TASK_WAIT_OTHER (StatusType)15 -#define E_EXCEED_MAX_NUM (StatusType)16 -#define E_NOT_IN_DELAY_LIST (StatusType)17 -#define E_SEV_REQ_FULL (StatusType)18 -#define E_NOT_FREE_ALL (StatusType)19 -#define E_PROTECTED_TASK (StatusType)20 -#define E_OS_IN_LOCK (StatusType)21 - - -/*---------------------------- Wait Opreation type --------------------------*/ -#define OPT_WAIT_ALL 0 /*!< Wait for all flags. */ -#define OPT_WAIT_ANY 1 /*!< Wait for any one of flags. */ -#define OPT_WAIT_ONE 2 /*!< Waot for one flag. */ - - -/*---------------------------- Delete Opreation type ------------------------*/ -#define OPT_DEL_NO_PEND 0 /*!< Delete when no task waitting for */ -#define OPT_DEL_ANYWAY 1 /*!< Delete always. */ - - -/*---------------------------- Timer Types ----------------------------------*/ -#if CFG_TMR_EN >0 -#define TMR_TYPE_ONE_SHOT 0 /*!< Timer counter type: One-shot */ -#define TMR_TYPE_PERIODIC 1 /*!< Timer counter type: Periodic */ -#endif - - -/*---------------------------- Event Control ---------------------------------*/ -#if CFG_EVENT_EN >0 -#define EVENT_SORT_TYPE_FIFO (U8)0x01 /*!< Insert a event by FIFO */ -#define EVENT_SORT_TYPE_PRIO (U8)0x02 /*!< Insert a event by prio */ -#endif - - -/*---------------------------- Function declare-------------------------------*/ - -/* Implement in file "core.c" */ -extern void CoInitOS(void); /*!< Initialize OS */ -extern void CoStartOS(void); /*!< Start multitask */ -extern void CoEnterISR(void); /*!< Enter a ISR */ -extern void CoExitISR(void); /*!< Exit a ISR */ -extern void CoSchedLock(void); -extern void CoSchedUnlock(void); -extern OS_VER CoGetOSVersion(void); /*!< Get OS version value */ - - -/* Implement in file "task.c" */ -#define CoCreateTask(task,argv,prio,stk,stkSz) \ - CreateTask(task,argv,(prio)|(((stkSz)<<8) &0x000FFF00 ),stk) - - -#define CoCreateTaskEx(task,argv,prio,stk,stkSz,timeSlice,isWaitting) \ - CreateTask(task,argv,(prio)|(((stkSz)<<8)&0x000FFF00)|(((timeSlice)<<20)&0x7FF00000)|((isWaitting<<31)&0x80000000),stk) - -extern void CoExitTask(void); -extern OS_TID CoGetCurTaskID(void); -extern StatusType CoDelTask(OS_TID taskID); -extern StatusType CoActivateTask(OS_TID taskID,void *argv); -extern StatusType CoAwakeTask(OS_TID taskID); -extern StatusType CoSuspendTask(OS_TID taskID); -extern StatusType CoSetPriority(OS_TID taskID,U8 priority); -extern OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk); -extern void CoYield(void); - -/* Implement in file "time.c" */ -extern U64 CoGetOSTime(void); -extern StatusType CoTickDelay(U32 ticks); -extern StatusType CoResetTaskDelayTick(OS_TID taskID,U32 ticks); -extern StatusType CoTimeDelay(U8 hour,U8 minute,U8 sec,U16 millsec); - - -/* Implement in file "timer.c" */ -extern StatusType CoDelTmr(OS_TCID tmrID); -extern StatusType CoStopTmr(OS_TCID tmrID); -extern StatusType CoStartTmr(OS_TCID tmrID); -extern U32 CoGetCurTmrCnt(OS_TCID tmrID,StatusType* perr); -extern StatusType CoSetTmrCnt(OS_TCID tmrID,U32 tmrCnt,U32 tmrReload); -extern OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func); - - -/* Implement in file "kernelHeap.c"*/ -extern void* CoKmalloc(U32 size); -extern void CoKfree(void* memBuf); - - -/* Implement in file "mm.c" */ -extern void* CoGetMemoryBuffer(OS_MMID mmID); -extern StatusType CoDelMemoryPartition(OS_MMID mmID); -extern StatusType CoFreeMemoryBuffer(OS_MMID mmID,void* buf); -extern U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr); -extern OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum); - -/* Implement in file "mutex.c" */ -extern OS_MutexID CoCreateMutex(void); -extern StatusType CoEnterMutexSection(OS_MutexID mutexID); -extern StatusType CoLeaveMutexSection(OS_MutexID mutexID); - - -/* Implement in file "sem.c" */ -extern StatusType CoPostSem(OS_EventID id); -extern StatusType CoAcceptSem(OS_EventID id); -extern StatusType isr_PostSem(OS_EventID id); -extern StatusType CoDelSem(OS_EventID id,U8 opt); -extern StatusType CoPendSem(OS_EventID id,U32 timeout); -extern OS_EventID CoCreateSem(U16 initCnt,U16 maxCnt,U8 sortType); - - -/* Implement in file "mbox.c" */ -extern OS_EventID CoCreateMbox(U8 sortType); -extern StatusType CoDelMbox(OS_EventID id,U8 opt); -extern StatusType CoPostMail(OS_EventID id,void* pmail); -extern StatusType isr_PostMail(OS_EventID id,void* pmail); -extern void* CoAcceptMail(OS_EventID id,StatusType* perr); -extern void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr); - - -/* Implement in file "queue.c" */ -extern StatusType CoDelQueue(OS_EventID id,U8 opt); -extern StatusType CoPostQueueMail(OS_EventID id,void* pmail); -extern StatusType isr_PostQueueMail(OS_EventID id,void* pmail); -extern void* CoAcceptQueueMail(OS_EventID id,StatusType* perr); -extern OS_EventID CoCreateQueue(void **qStart, U16 size ,U8 sortType); -extern void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr); - - - -/* Implement in file "flag.c" */ -extern StatusType CoSetFlag (OS_FlagID id); -extern StatusType CoClearFlag (OS_FlagID id); -extern StatusType isr_SetFlag (OS_FlagID id); -extern StatusType CoDelFlag (OS_FlagID id,U8 opt); -extern StatusType CoAcceptSingleFlag (OS_FlagID id); -extern StatusType CoWaitForSingleFlag (OS_FlagID id,U32 timeout); -extern OS_FlagID CoCreateFlag (BOOL bAutoReset,BOOL bInitialState); -extern U32 CoAcceptMultipleFlags (U32 flags,U8 waitType,StatusType *perr); -extern U32 CoWaitForMultipleFlags (U32 flags,U8 waitType,U32 timeout,StatusType *perr); - - -/* Implement in file "utility.c" */ -extern StatusType CoTimeToTick(U8 hour,U8 minute,U8 sec,U16 millsec,U32* ticks); -extern void CoTickToTime(U32 ticks,U8* hour,U8* minute,U8* sec,U16* millsec); - - -/* Implement in file "hook.c" */ -extern void CoIdleTask(void* pdata); -extern void CoStkOverflowHook(OS_TID taskID); - - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsArch.h b/GD32F1/libraries/MapleCoOS116/utility/OsArch.h deleted file mode 100644 index 51ee324..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsArch.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - ******************************************************************************* - * @file OsArch.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Implement function declare related to Cortex-M3(ARM-v7) - * @details This header file including functions or defines related to - * Cortex-M3(ARM-v7). - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _CPU_H -#define _CPU_H - - -#define NVIC_ST_CTRL (*((volatile U32 *)0xE000E010)) -#define NVIC_ST_RELOAD (*((volatile U32 *)0xE000E014)) -#define RELOAD_VAL ((U32)(( (U32)CFG_CPU_FREQ) / (U32)CFG_SYSTICK_FREQ) -1) - -/*!< Initial System tick. */ -// Maple -#define InitSysTick() systick_attach_callback(&CoSysTick_Handler) -/* Maple -#define InitSysTick() NVIC_ST_RELOAD = RELOAD_VAL; \ - NVIC_ST_CTRL = 0x0007 -*/ - -#define NVIC_SYS_PRI2 (*((volatile U32 *)0xE000ED1C)) -#define NVIC_SYS_PRI3 (*((volatile U32 *)0xE000ED20)) - -/*!< Initialize PendSV,SVC and SysTick interrupt priority to lowest. */ - -#define InitInt() NVIC_SYS_PRI2 |= 0xFF000000;\ - NVIC_SYS_PRI3 |= 0xFFFF0000 - - -/*---------------------------- Variable declare ------------------------------*/ -extern U64 OSTickCnt; /*!< Counter for current system ticks. */ - -/*!< Initial context of task being created */ -extern OS_STK *InitTaskContext(FUNCPtr task,void *param,OS_STK *pstk); -extern void SwitchContext(void); /*!< Switch context */ -extern void SetEnvironment(OS_STK *pstk);/*!< Set environment for run */ -extern U8 Inc8 (volatile U8 *data); -extern U8 Dec8 (volatile U8 *data); -extern void IRQ_ENABLE_RESTORE(void); -extern void IRQ_DISABLE_SAVE(void); -extern void CoSysTick_Handler(void); - - -#endif /* _CPU_H */ diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsConfig.h b/GD32F1/libraries/MapleCoOS116/utility/OsConfig.h deleted file mode 100644 index a651664..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsConfig.h +++ /dev/null @@ -1,304 +0,0 @@ -/** - ******************************************************************************* - * @file OsConfig.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief This file use by user to configuration CooCox CoOS. - * @note Ensure you have knew every item before modify this file. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _CONFIG_H -#define _CONFIG_H - - -/*!< -Defines chip type,cortex-m3(1),cortex-m0(2) -cortex-m4 without FPU(1), cortex-m4 with FPU(3) -*/ -#define CFG_CHIP_TYPE (1) - -/*!< -Defines the lowest priority that be assigned. -*/ -#define CFG_LOWEST_PRIO (64) - -/*!< -Max number of tasks that can be running. -*/ -#define CFG_MAX_USER_TASKS (5) - -/*!< -Idle task stack size(word). -*/ -#if CFG_CHIP_TYPE == 3 -#define CFG_IDLE_STACK_SIZE (58) -#else -#define CFG_IDLE_STACK_SIZE (25) -#endif - -/*!< -System frequency (Hz). -*/ -#define CFG_CPU_FREQ (F_CPU) - -/*!< -systick frequency (Hz). -*/ -#define CFG_SYSTICK_FREQ (1000) - -/*!< -max systerm api call num in ISR. -*/ -#define CFG_MAX_SERVICE_REQUEST (5) - -/*!< -Enable(1) or disable(0) order list schedule. -If disable(0),CoOS use Binary-Scheduling Algorithm. -*/ -#if (CFG_MAX_USER_TASKS) <15 -#define CFG_ORDER_LIST_SCHEDULE_EN (1) -#else -#define CFG_ORDER_LIST_SCHEDULE_EN (0) -#endif - - -/*!< -Enable(1) or disable(0) Round-Robin Task switching. -*/ -#define CFG_ROBIN_EN (1) - -/*!< -Default slice of task. -*/ -#if CFG_ROBIN_EN > 0 -#define CFG_TIME_SLICE (10) -#endif - - -/*----------------------- Schedule model Config -----------------------------*/ -/*!< -Enable(1) or disable(0) all waiting function. -Include sem,mailbox,queue,flag,mutex,delay modules. -If CFG_TASK_WAITTING_EN=0,all these modules are disable. -*/ -#define CFG_TASK_WAITTING_EN (1) - -/*!< -Dynamic task scheduling(1) or Static Task Scheduling(0) model. -If in Static Task Scheduling model(0),cannot creat task and change task priority -after coocox os start running. In Dynamic Task Scheduling model(1), all these can. -When task terminated, if in Static Task Scheduling model(0), -CoOS do not recovered task resources, and you can activate it again. -But in Dynamic Task Scheduling model(1),task resources will be recovered. -If in Static Task Scheduling model(0),mutex module can not be used, as this model don't -support to change task priority while CoOS running. -*/ -#define CFG_TASK_SCHEDULE_EN (1) - - -/*---------------------- Task Management Config -----------------------------*/ -/*!< -Enable(1) or disable(0) CoSetPriority() API. -*/ -#if CFG_TASK_SCHEDULE_EN >0 -#define CFG_PRIORITY_SET_EN (1) -#endif - -/*!< -Enable(1) or disable(0) CoAwakeTask() and CoSuspendTask() API. -*/ -#define CFG_TASK_SUSPEND_EN (1) - - -/*---------------------- Debug Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) parameter checkout . -*/ -#define CFG_PAR_CHECKOUT_EN (1) - -/*!< -Enable(1) or disable(0) stack overflow checkout . -*/ -#define CFG_STK_CHECKOUT_EN (1) - - - -/*---------------------- Memory Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) memory management. -*/ -#define CFG_MM_EN (1) - -/*!< -Max number of memory.(must be less than 32). -*/ -#if CFG_MM_EN >0 -#define CFG_MAX_MM (2) -#endif - - - -/*-------------------- Kernel heap Management Config -------------------------*/ -/*!< -Enable(1) or disable(0) kernel heap management. -*/ -#define CFG_KHEAP_EN (1) - -/*!< -Kernel heap size(word). -*/ -#if CFG_KHEAP_EN >0 -#define KHEAP_SIZE (50) -#endif - - - -/*---------------------- Time Management Config -----------------------------*/ -/*!< -Enable(1) or disable(0) TimeDelay() API. -*/ -#if CFG_TASK_WAITTING_EN >0 -#define CFG_TIME_DELAY_EN (1) -#endif - - -/*---------------------- Timer Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) timer management. -*/ -#define CFG_TMR_EN (1) - -/*!< -Specify max number timer.(must be less than 32) -*/ -#if CFG_TMR_EN >0 -#define CFG_MAX_TMR (2) -#endif - - -/*---------------------- Event Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) events management, -events including semaphore,mailbox,queue. -*/ -#if CFG_TASK_WAITTING_EN > 0 -#define CFG_EVENT_EN (1) -#endif - -#if CFG_EVENT_EN > 0 -/*!< -Event sort type.(1)FIFO (2)PRI (3)FIFO+PRI -*/ -#define CFG_EVENT_SORT (3) - -/*!< -Max number of event.(must be less than 255) -Event = semaphore + mailbox + queue; -*/ -#define CFG_MAX_EVENT (20) - -/*!< -Enable(1) or disable(0) semaphore management. -*/ -#define CFG_SEM_EN (1) - -/*!< -Enable(1) or disable(0) mailbox management. -*/ -#define CFG_MAILBOX_EN (1) - -/*!< -Enable(1) or disable(0) queue management. -*/ -#define CFG_QUEUE_EN (1) - -/*!< -Max number of queue.(less than CFG_MAX_EVENT). -*/ -#if CFG_QUEUE_EN >0 -#define CFG_MAX_QUEUE (2) -#endif // CFG_QUEUE_EN - -#endif // CFG_EVENT_EN - - - -/*----------------------- Flag Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) flag management. -Max number of flag is 32. -*/ -#if CFG_TASK_WAITTING_EN > 0 -#define CFG_FLAG_EN (1) -#endif - - -/*---------------------- Mutex Management Config ----------------------------*/ -/*!< -Enable(1) or disable(0) mutex management. -*/ -#if CFG_TASK_WAITTING_EN > 0 -#if CFG_TASK_SCHEDULE_EN > 0 -#define CFG_MUTEX_EN (1) -#endif -#endif - - -/*!< -Max number of mutex.(must be less than 255). -*/ -#if CFG_MUTEX_EN >0 -#define CFG_MAX_MUTEX (10) -#endif - -/*---------------------- Utility Management Config --------------------------*/ -/*!< -Enable(1) or disable(0) utility management. -*/ -#define CFG_UTILITY_EN (1) - -#if CFG_UTILITY_EN >0 - -/*!< -Enable(1) or disable(0) TickToTime() utility -*/ -#define CFG_TICK_TO_TIME_EN (1) -/*!< -Enable(1) or disable(0) TimeToTick() utility -*/ -#define CFG_TIME_TO_TICK_EN (1) -#endif - - -#endif // _CONFIG_H diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsCore.h b/GD32F1/libraries/MapleCoOS116/utility/OsCore.h deleted file mode 100644 index 98395db..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsCore.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - ******************************************************************************* - * @file OsCore.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Header file related to kernel - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _CORE_H -#define _CORE_H - -#include - - -#define OsSchedLock() OSSchedLock++; /*!< Lock schedule */ -extern void OsSchedUnlock(void); - -#endif - diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsError.h b/GD32F1/libraries/MapleCoOS116/utility/OsError.h deleted file mode 100644 index b09ec27..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsError.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - ******************************************************************************* - * @file OsError.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief rror dispose header file - * @details This file use to dispose error which from error configure for OS. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _ERROR_H -#define _ERROR_H - -#if (CFG_SYSTICK_FREQ > 1000) ||(CFG_SYSTICK_FREQ < 1) - #error " OsConfig.h System Tick time must between 1ms and 1s!" -#endif - -#if CFG_MAX_USER_TASKS > 253 - #error " OsConfig.h, CFG_MAX_USER_TASKS must be <= 253! " -#endif - -#if CFG_LOWEST_PRIO > 254 - #error " OsConfig.h, CFG_LOWEST_PRIO must be <= 254! " -#endif - -#if CFG_IDLE_STACK_SIZE <25 - #error " OsConfig.h, CFG_IDLE_STACK_SIZE must be >= 25! " -#endif - - -#if CFG_ROBIN_EN > 0 - #if CFG_TIME_SLICE > 4095 - #error " OsConfig.h, CFG_TIME_SLICE must be <= 4095! " - #endif -#endif - -#if CFG_TMR_EN > 0 - #if CFG_MAX_TMR > 32 - #error " OsConfig.h, CFG_MAX_TMR must be <= 32! " - #endif -#endif - - -#if CFG_MM_EN > 0 - #if CFG_MAX_MM > 32 - #error " config.h, CFG_MAX_MM must be <= 32! " - #endif -#endif - - -#if CFG_KHEAP_EN > 0 - #if KHEAP_SIZE < 0x20 - #error " config.h, CFG_MAX_MM must be >= 0x20! " - #endif -#endif - -#if CFG_MUTEX_EN > 0 - #if CFG_MAX_MUTEX > 254 - #error " config.h, CFG_MAX_MUTEX must be <= 254! " - #endif -#endif - - -#if CFG_EVENT_EN > 0 - #if (CFG_MAX_EVENT > 254 || CFG_MAX_EVENT <= 0) - #error " config.h, CFG_MAX_EVENT must be <= 254 && > 0! " - #endif - - - #if CFG_QUEUE_EN > 0 - #if CFG_MAX_QUEUE > CFG_MAX_EVENT - #error " config.h, CFG_MAX_QUEUE must be <= CFG_MAX_EVENT! " - #endif - #endif -#endif /* CFG_EVENT_EN */ - -#endif /* _ERROR_H */ diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsEvent.h b/GD32F1/libraries/MapleCoOS116/utility/OsEvent.h deleted file mode 100644 index e0f8ab8..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsEvent.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - ******************************************************************************* - * @file OsEvent.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Event management header file - * @details This file including some defines and declares related to event - * (semaphore,mailbox,queque) management. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _EVENT_H -#define _EVENT_H - -#define EVENT_TYPE_SEM (U8)0x01 /*!< Event type:Semaphore. */ -#define EVENT_TYPE_MBOX (U8)0x02 /*!< Event type:Mailbox. */ -#define EVENT_TYPE_QUEUE (U8)0x03 /*!< Event type:Queue. */ -#define EVENT_TYPE_INVALID (U8)0x04 /*!< Invalid event type. */ - - -/** - * @struct EventCtrBlk event.h - * @brief Event control block - * @details This struct is use to manage event, - * e.g. semaphore,mailbox,queue. - */ -typedef struct EventCtrBlk -{ - void* eventPtr; /*!< Point to mailbox or queue struct */ - U8 id; /*!< ECB id */ - U8 eventType:4; /*!< Type of event */ - U8 eventSortType:4; /*!< 0:FIFO 1: Preemptive by prio */ - U16 eventCounter; /*!< Counter of semaphore. */ - U16 initialEventCounter; /*!< Initial counter of semaphore. */ - P_OSTCB eventTCBList; /*!< Task waitting list. */ -}ECB,*P_ECB; - -/*---------------------------- Variable declare ------------------------------*/ -extern ECB EventTbl[CFG_MAX_EVENT]; /*!< Table use to save TCB. */ - -/*---------------------------- Function declare ------------------------------*/ -/*!< Create a event */ -extern P_ECB CreatEvent(U8 eventType,U8 eventSortType,void* eventPtr); - -/*!< Remove a task from wait list */ -extern void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb); -extern StatusType DeleteEvent(P_ECB pecb,U8 opt); /*!< Delete a event. */ -extern void EventTaskToRdy(P_ECB pecb); /*!< Insert a task to ready list*/ -extern void CreateEventList(void); /*!< Create a event list. */ -extern void RemoveEventWaittingList(P_OSTCB ptcb); -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsFlag.h b/GD32F1/libraries/MapleCoOS116/utility/OsFlag.h deleted file mode 100644 index 3f318af..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsFlag.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - ******************************************************************************* - * @file OsFlag.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Evnet flag management header file - * @details This file including some defines and declares about flag management. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _FLAG_H -#define _FLAG_H - -/** - * @struct FlagNode flag.h - * @brief Flag node struct - * @details - */ -typedef struct FlagNode -{ - struct FlagNode* nextNode; /*!< A pointer to next flag node */ - struct FlagNode* prevNode; /*!< A pointer to prev flag node */ - U32 waitFlags; /*!< Flag value */ - P_OSTCB waitTask; /*!< A pointer to task waitting flag */ - U8 waitType; /*!< Wait type */ -}FLAG_NODE,*P_FLAG_NODE; - - -/** - * @struct Flag flag.h - * @brief Flag control block - * @details This struct use to mange event flag. - */ -typedef struct Flag -{ - U32 flagRdy; /*!< Ready flag */ - U32 resetOpt; /*!< Reset option */ - U32 flagActive; /*!< Active flag */ - P_FLAG_NODE headNode; /*!< Head node */ - P_FLAG_NODE tailNode; /*!< Tail node */ -}FCB,*P_FCB; - - -/*---------------------------- Variable declare ------------------------------*/ -extern FCB FlagCrl; - -/*---------------------------- Function declare ------------------------------*/ -extern void RemoveLinkNode(P_FLAG_NODE pnode); -#endif - diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsKernelHeap.h b/GD32F1/libraries/MapleCoOS116/utility/OsKernelHeap.h deleted file mode 100644 index be6be41..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsKernelHeap.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - ******************************************************************************* - * @file OsKernelHeap.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Header file related to memory management - * @details This file including some defines and function declare related to - * kernel heap management. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _KERNELHEAP_H -#define _KERNELHEAP_H - - -typedef struct KennelHeap -{ - U32 startAddr; - U32 endAddr; -}KHeap,*P_KHeap; - - -typedef struct UsedMemBlk -{ - void* nextMB; - void* preMB; -}UMB,*P_UMB; - - -typedef struct FreeMemBlk -{ - struct FreeMemBlk* nextFMB; - struct UsedMemBlk* nextUMB; - struct UsedMemBlk* preUMB; -}FMB,*P_FMB; - -/*---------------------------- Function Declare ------------------------------*/ -extern void CoCreateKheap(void); - -#endif /* _KERNELHEAP_H */ - diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsMM.h b/GD32F1/libraries/MapleCoOS116/utility/OsMM.h deleted file mode 100644 index 4332600..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsMM.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - ******************************************************************************* - * @file OsMm.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Header file related to memory management - * @details This file including some defines and function declare related to - * memory management. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _MM_H -#define _MM_H - - -typedef struct Memory -{ - U8* memAddr; - U8* freeBlock; - U32 blockSize; - U32 blockNum; -}MM,*P_MM; - - -typedef struct MemoryBlock -{ - struct MemoryBlock* nextBlock; -}MemBlk,*P_MemBlk; - - -extern U32 MemoryIDVessel; - -#endif /* _MM_H */ - diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsMutex.h b/GD32F1/libraries/MapleCoOS116/utility/OsMutex.h deleted file mode 100644 index 7691547..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsMutex.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - ******************************************************************************* - * @file OsMutex.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Mutex management header file - * @details This file including some defines and declare related to mutex - * management. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _MUTEX_H -#define _MUTEX_H - -#include - -#if CFG_MUTEX_EN > 0 - -/*---------------------------- Resource status -------------------------------*/ -#define MUTEX_FREE 0 /*!< Mutex is free */ -#define MUTEX_OCCUPY 1 /*!< Mutex is occupy */ -#define WAITING_MUTEX 0x80 - -/** - * @struct Mutex mutex.h - * @brief Mutex control block - * @details This struct is use to mutex management. - */ -typedef struct Mutex -{ - U8 originalPrio; /*!< Mutex priority. */ - U8 mutexFlag; /*!< Mutex flag. */ - OS_TID taskID; /*!< Task ID. */ - OS_TID hipriTaskID; /*!< Mutex ID. */ - P_OSTCB waittingList; /*!< waitting the Mutex. */ -}MUTEX,*P_MUTEX; - - -/*---------------------------- Variable declare ------------------------------*/ -/*!< Table use to save mutex control block. */ -extern MUTEX MutexTbl[CFG_MAX_MUTEX]; -extern OS_MutexID MutexFreeID; /*!< A pointer to next vliad resource ID. */ - - -/*---------------------------- Function declare ------------------------------*/ -extern void RemoveMutexList(P_OSTCB ptcb); - -#endif /* CFG_MUTEX_EN */ - -#endif /* _MUTEX_H */ diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsQueue.h b/GD32F1/libraries/MapleCoOS116/utility/OsQueue.h deleted file mode 100644 index 4a8c3ab..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsQueue.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - ******************************************************************************* - * @file OsQueue.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Queue management header file - * @details This file including some defines and declares about queue management. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _QUEUE_H -#define _QUEUE_H - - -/** - * @struct Queue queue.h - * @brief Queue struct - * @details This struct use to manage queue. - * - */ -typedef struct Queue -{ - void **qStart; /*!< */ - U8 id; /*!< */ - U16 head; /*!< The header of queue */ - U16 tail; /*!< The end of queue */ - U16 qMaxSize; /*!< The max size of queue */ - U16 qSize; /*!< Current size of queue */ -}QCB,*P_QCB; - - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsServiceReq.h b/GD32F1/libraries/MapleCoOS116/utility/OsServiceReq.h deleted file mode 100644 index af5d581..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsServiceReq.h +++ /dev/null @@ -1,76 +0,0 @@ - -/** - ******************************************************************************* - * @file OsServiceReq.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Header file related to service request - * @details This file including some defines and function declare related to - * service request. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _SERVICEREQ_H -#define _SERVICEREQ_H - -#if CFG_MAX_SERVICE_REQUEST > 0 -#define SEM_REQ (U8)0x1 -#define MBOX_REQ (U8)0x2 -#define FLAG_REQ (U8)0x3 -#define QUEUE_REQ (U8)0x4 - - -typedef struct ServiceReqCell -{ - U8 type; - U8 id; - void* arg; -}SQC,*P_SQC; - -typedef struct ServiceReqQueue -{ - U8 cnt; - U8 head; - SQC cell[CFG_MAX_SERVICE_REQUEST]; -}SRQ,*P_SRQ; - - -extern SRQ ServiceReq; -extern BOOL InsertInSRQ(U8 type,U8 id,void* arg); -#endif - -extern void RespondSRQ(void); -extern BOOL TimeReq; -extern BOOL TimerReq; -extern BOOL IsrReq; -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsTask.h b/GD32F1/libraries/MapleCoOS116/utility/OsTask.h deleted file mode 100644 index e25bde9..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsTask.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - ******************************************************************************* - * @file OsTask.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Header file related to task. - * @details This file including some defines and function declare related to task. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -#ifndef _TASK_H -#define _TASK_H - -#define SYS_TASK_NUM (1) /*!< System task number. */ - -/*---------------------------- Task Status -----------------------------------*/ -#define TASK_READY 0 /*!< Ready status of task. */ -#define TASK_RUNNING 1 /*!< Running status of task. */ -#define TASK_WAITING 2 /*!< Waitting status of task. */ -#define TASK_DORMANT 3 /*!< Dormant status of task. */ - - -#define INVALID_ID (U8)0xff -#define INVALID_VALUE (U32)0xffffffff -#define MAGIC_WORD (U32)0x5a5aa5a5 - - -/** - * @struct TCB task.h - * @brief Task control blcok. - * @details This struct use to manage task. - */ -typedef struct TCB -{ - OS_STK *stkPtr; /*!< The current point of task. */ - U8 prio; /*!< Task priority. */ - U8 state; /*!< TaSk status. */ - OS_TID taskID; /*!< Task ID. */ - -#if CFG_MUTEX_EN > 0 - OS_MutexID mutexID; /*!< Mutex ID. */ -#endif - -#if CFG_EVENT_EN > 0 - OS_EventID eventID; /*!< Event ID. */ -#endif - -#if CFG_ROBIN_EN >0 - U16 timeSlice; /*!< Task time slice */ -#endif - -#if CFG_STK_CHECKOUT_EN >0 - OS_STK *stack; /*!< The top point of task. */ -#endif - -#if CFG_EVENT_EN > 0 - void* pmail; /*!< Mail to task. */ - struct TCB *waitNext; /*!< Point to next TCB in the Event waitting list.*/ - struct TCB *waitPrev; /*!< Point to prev TCB in the Event waitting list.*/ -#endif - -#if CFG_TASK_SCHEDULE_EN == 0 - FUNCPtr taskFuc; - OS_STK *taskStk; -#endif - - -#if CFG_FLAG_EN > 0 - void* pnode; /*!< Pointer to node of event flag. */ -#endif - -#if CFG_TASK_WAITTING_EN >0 - U32 delayTick; /*!< The number of ticks which delay. */ -#endif - struct TCB *TCBnext; /*!< The pointer to next TCB. */ - struct TCB *TCBprev; /*!< The pointer to prev TCB. */ - -}OSTCB,*P_OSTCB; - - -/*---------------------------- Variable declare ------------------------------*/ -// save tcb ptr that created -extern P_OSTCB FreeTCB; /*!< A pointer to free TCB. */ -extern OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; -extern P_OSTCB TCBRdy; /*!< A pointer to TCB that is ready status */ -extern P_OSTCB TCBNext; /*!< A pointer to TCB next be scheduled. */ -extern P_OSTCB TCBRunning; /*!< A pointer to TCB that is running. */ - -extern U64 OSCheckTime; -extern volatile U8 OSIntNesting; /*!< Use to indicate interrupt nesting level.*/ -extern volatile U8 OSSchedLock; /*!< Schedule is lock(LOCK) or unlock(UN_LOCK).*/ -extern volatile BOOL TaskSchedReq; -extern OS_STK idle_stk[CFG_IDLE_STACK_SIZE]; - - -void Schedule(void); /*!< Schedule function */ -void IdleTask(void* pdata); /*!< IDLE task code */ -void InsertToTCBRdyList (P_OSTCB tcbInser); -void RemoveFromTCBRdyList(P_OSTCB ptcb); -void CreateTCBList(void); -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 -void ActiveTaskPri(U8 pri); -void DeleteTaskPri(U8 pri); -#endif - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsTime.h b/GD32F1/libraries/MapleCoOS116/utility/OsTime.h deleted file mode 100644 index 34bbc8e..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsTime.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - ******************************************************************************* - * @file OsTime.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Header file related to time management - * @details Thie file including some data declare related to time managment. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -#ifndef _TIME_H -#define _TIME_H - -/*---------------------------- Variable declare ------------------------------*/ -extern P_OSTCB DlyList; /*!< A pointer to ther delay list. */ - -/*---------------------------- Function declare ------------------------------*/ -extern void TimeDispose(void); /*!< Time dispose function. */ -extern void isr_TimeDispose(void); -extern void RemoveDelayList(P_OSTCB ptcb); -extern void InsertDelayList(P_OSTCB ptcb,U32 ticks); -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/OsTimer.h b/GD32F1/libraries/MapleCoOS116/utility/OsTimer.h deleted file mode 100644 index 8e9d4da..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/OsTimer.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - ******************************************************************************* - * @file OsTimer.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Timer manage header file - * @details This file including some declares and defines related to timer - * management. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -#ifndef _TIMER_H -#define _TIMER_H - -#define TMR_STATE_RUNNING 0 /*!< Timer State: Running */ -#define TMR_STATE_STOPPED 1 /*!< Timer State: Stopped */ - -/** - * @struct tmrCtrl timer.h - * @brief Timer control block - * @details This struct is use to manage user timer. - * - */ -typedef struct tmrCtrl /* Timer Control Block Define. */ -{ - OS_TCID tmrID; /*!< Timer ID. */ - U8 tmrType; /*!< Timer Type. */ - U8 tmrState; /*!< Timer State. */ - U32 tmrCnt; /*!< Timer Counter. */ - U32 tmrReload; /*!< Timer Reload Counter Value. */ - vFUNCPtr tmrCallBack; /*!< Call-back Function When Timer overrun. */ - struct tmrCtrl* tmrNext; /*!< Point to Next Timer Control Block. */ - struct tmrCtrl* tmrPrev; /*!< Point to Previous Timer Control Block*/ - -}TmrCtrl,*P_TmrCtrl; - -/*---------------------------- Variable declare ------------------------------*/ -extern P_TmrCtrl TmrList; /*!< A pointer to the timer list. */ -extern U32 TmrIDVessel; -/*---------------------------- Function declare ------------------------------*/ -extern void TmrDispose(void); /*!< Timer counter function. */ -extern void isr_TmrDispose(void); -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/arch.c b/GD32F1/libraries/MapleCoOS116/utility/arch.c deleted file mode 100644 index 46029df..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/arch.c +++ /dev/null @@ -1,126 +0,0 @@ -/** - ******************************************************************************* - * @file arch.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief This file provides InitTaskContext() and SysTick_Handler(). - ******************************************************************************* - * @copy - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include -U64 OSTickCnt = 0; /*!< Current system tick counter */ - -/** - ****************************************************************************** - * @brief Initial task context - * @param[in] task Entry point of task. - * @param[in] param The parameter pass to task. - * @param[in] pstk The pointer to stack top. - * @param[out] None - * @retval Returns location of new stack top. - * - * @par Description - * @details This function is called to initialize the stack frame of the - * task being created. - ****************************************************************************** - */ -OS_STK *InitTaskContext(FUNCPtr task,void *param,OS_STK *pstk) -{ - OS_STK *context; - context = pstk; -#if CFG_CHIP_TYPE == 3 - context = context - 18; -#endif - *(context--) = (U32)0x01000000L; /* xPSR */ - *(context--) = (U32)task; /* Entry point of task. */ - *(context) = (U32)0xFFFFFFFEL; - context = context - 5; - *(context) = (U32)param; /* R0: argument */ - context = context - 8; -#if CFG_CHIP_TYPE == 3 - context = context - 16; -#endif -// *(--context) = 0xfffffffd; /* LR */ - - return (context); /* Returns location of new stack top. */ -} - - - -/** - ******************************************************************************* - * @brief System tick interrupt handler. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This is system tick interrupt headler. - * @note CoOS may schedule when exiting this ISR. - ******************************************************************************* - */ -void CoSysTick_Handler(void) -{ - OSSchedLock++; /* Lock scheduler. */ - OSTickCnt++; /* Increment systerm time. */ -#if CFG_TASK_WAITTING_EN >0 - if(DlyList != Co_NULL) /* Have task in delay list? */ - { - if(DlyList->delayTick > 1) /* Delay time > 1? */ - { - DlyList->delayTick--; /* Decrease delay time of the list head. */ - } - else - { - DlyList->delayTick = 0; - isr_TimeDispose(); /* Call hander for delay time list */ - } - } -#endif - -#if CFG_TMR_EN > 0 - if(TmrList != Co_NULL) /* Have timer in working? */ - { - if(TmrList->tmrCnt > 1) /* Timer time > 1? */ - { - TmrList->tmrCnt--; /* Decrease timer time of the list head. */ - } - else - { - TmrList->tmrCnt = 0; - isr_TmrDispose(); /* Call hander for timer list */ - } - } -#endif - TaskSchedReq = Co_TRUE; - OsSchedUnlock(); -} diff --git a/GD32F1/libraries/MapleCoOS116/utility/coocox.h b/GD32F1/libraries/MapleCoOS116/utility/coocox.h deleted file mode 100644 index 3a60b8c..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/coocox.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - ******************************************************************************* - * @file coocox.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Gather for all header file of CooCox CoOS. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _COOCOX_H -#define _COOCOX_H - -#define OS_VERSION (U16)0x0114 /*!< OS version.(format: Vx.xx), - e.g. value 0x0114 is version V1.14*/ -/*---------------------------- Include ---------------------------------------*/ -#include "CoOS.h" -#include "OsArch.h" -#include "OsCore.h" -#include "OsTask.h" -#include "OsServiceReq.h" -#include "OsError.h" -#include "OsTime.h" - - -#if CFG_TMR_EN > 0 - #include "OsTimer.h" -#endif - -#if CFG_KHEAP_EN > 0 - #include "OsKernelHeap.h" -#endif - -#if CFG_MM_EN >0 - #include "OsMM.h" -#endif - -#if CFG_EVENT_EN > 0 - #include "OsEvent.h" -#endif - -#if CFG_MUTEX_EN > 0 - #include "OsMutex.h" -#endif - -#if CFG_QUEUE_EN > 0 - #include "OsQueue.h" -#endif - -#if CFG_FLAG_EN > 0 - #include "OsFlag.h" -#endif - -#endif /* _COOCOX_H */ diff --git a/GD32F1/libraries/MapleCoOS116/utility/core.c b/GD32F1/libraries/MapleCoOS116/utility/core.c deleted file mode 100644 index 64cec87..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/core.c +++ /dev/null @@ -1,262 +0,0 @@ - /** - ******************************************************************************* - * @file core.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Core implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include - - -/*---------------------------- Variable Define -------------------------------*/ -volatile U8 OSIntNesting = 0; /*!< Use to indicate interrupt nesting level*/ -volatile U8 OSSchedLock = 0; /*!< Task Switch lock. */ -volatile BOOL TaskSchedReq = Co_FALSE; - - -/** - ******************************************************************************* - * @brief Enter a ISR. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to notify OS when enter to an ISR. - * - * @note When you call API in ISR,you must call CoEnterISR() before your - * interrupt handler code,and call CoExitISR() after your handler - * code and before exiting from ISR. - ******************************************************************************* - */ -void CoEnterISR(void) -{ - Inc8(&OSIntNesting); /* OSIntNesting increment */ -} - - -/** - ******************************************************************************* - * @brief Exit a ISR. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called when exit from a ISR. - * - * @note - ******************************************************************************* - */ -void CoExitISR(void) -{ - Dec8(&OSIntNesting); /* OSIntNesting decrease */ - if( OSIntNesting == 0) /* Is OSIntNesting == 0? */ - { - if(TaskSchedReq == Co_TRUE) - { - OSSchedLock++; - Schedule(); /* Call task schedule */ - OSSchedLock--; - } - } -} - - - -/** - ******************************************************************************* - * @brief Unlock schedule - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to unlock schedule(i.e.enable schedule again) - * - * @note - ******************************************************************************* - */ -void OsSchedUnlock(void) -{ - if(OSSchedLock == 1) /* Is OSSchedLock == 0? */ - { -#if CFG_TASK_WAITTING_EN > 0 - if(IsrReq == Co_TRUE) - { - RespondSRQ(); /* Respond service request */ - } -#endif - /* Judge task state change or higher PRI task coming in */ - if(TaskSchedReq == Co_TRUE) - { - Schedule(); /* Call task schedule */ - } - OSSchedLock = 0; - } - else - { - OSSchedLock--; - } -} - - -/** - ******************************************************************************* - * @brief Lock schedule - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in application code to lock schedule. - * - * @note - ******************************************************************************* - */ -void CoSchedLock(void) -{ - OsSchedLock(); /* Lock schedule */ -} - - -/** - ******************************************************************************* - * @brief Unlock schedule - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in APP to unlock schedule. - * - * @note - ******************************************************************************* - */ -void CoSchedUnlock(void) -{ - OsSchedUnlock(); /* Unlock schedule */ -} - - -/** - ******************************************************************************* - * @brief Initialize OS - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to initialize OS. - * - * @note You must call this function first,before any other OS API function - * - * @code There is a example for useage of this function,as follows: - * e.g. - * ... // Your target initial code. - * - * OsInit(); // Initial OS. - * CreateTask(...); // Create tasks. - * ... - * OsStart(); // Start multitask. - * @endcode - ******************************************************************************* - */ -void CoInitOS(void) -{ - InitSysTick(); /* Initialize system tick. */ - InitInt(); /* Initialize PendSV,SVC,SysTick interrupt */ - CreateTCBList(); /* Create TCB list. */ -#if CFG_EVENT_EN > 0 - CreateEventList(); /* Create event control list. */ -#endif -#if CFG_KHEAP_EN > 0 - CoCreateKheap(); /* Create kernel heap within user define */ -#endif - OsSchedLock(); /* Lock Schedule */ - /* Create first task -- IDLE task. */ - CoCreateTask( CoIdleTask, - Co_NULL, - CFG_LOWEST_PRIO, - &idle_stk[CFG_IDLE_STACK_SIZE-1], - CFG_IDLE_STACK_SIZE - ); - /* Set PSP for CoIdleTask coming in */ - SetEnvironment(&idle_stk[CFG_IDLE_STACK_SIZE-1]); -} - - -/** - ******************************************************************************* - * @brief Start multitask - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to start multitask.After it is called, - * OS start schedule task by priority or/and time slice. - * @note This function must be called to start OS when you use CoOS,and must - * call after CoOsInit(). - ******************************************************************************* - */ -void CoStartOS(void) -{ - TCBRunning = &TCBTbl[0]; /* Get running task */ - TCBNext = TCBRunning; /* Set next scheduled task as running task */ - TCBRunning->state = TASK_RUNNING; /* Set running task status to RUNNING */ - RemoveFromTCBRdyList(TCBRunning); /* Remove running task from READY list */ - OsSchedUnlock(); /* Enable Schedule,call task schedule */ -} - - -/** - ******************************************************************************* - * @brief Get OS version - * @param[in] None - * @param[out] None - * @retval The value is version of OS mutipled by 100. - * - * @par Description - * @details This function is used to return the version number of CooCox OS. - * the return value corresponds to CooCox's version number multiplied - * by 100. In other words, version 1.02 would be returned as 102. - ******************************************************************************* - */ -OS_VER CoGetOSVersion(void) -{ - return OS_VERSION; /* Get CooCox CoOS version */ -} - diff --git a/GD32F1/libraries/MapleCoOS116/utility/event.c b/GD32F1/libraries/MapleCoOS116/utility/event.c deleted file mode 100644 index eabee44..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/event.c +++ /dev/null @@ -1,435 +0,0 @@ -/** - ******************************************************************************* - * @file event.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief event management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - - -/*---------------------------- Variable Define -------------------------------*/ -#if CFG_EVENT_EN > 0 - -ECB EventTbl[CFG_MAX_EVENT]= {{0}};/*!< Table which save event control block.*/ -P_ECB FreeEventList = Co_NULL; /*!< Pointer to free event control block. */ - - -/** - ******************************************************************************* - * @brief Create a empty list of event control block - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called by OSInit() API to create a ECB list,supply - * a pointer to next event control block that not used. - ******************************************************************************* - */ -void CreateEventList(void) -{ - U8 i; - P_ECB pecb1; -#if CFG_MAX_EVENT > 1 - P_ECB pecb2; -#endif - i=0; - pecb1 = &EventTbl[0]; /* Get first item */ -#if CFG_MAX_EVENT == 1 /* Build event list for only one item */ - pecb1->eventPtr = Co_NULL; - pecb1->id = i; /* Assign ID. */ - pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */ -#endif - -#if CFG_MAX_EVENT > 1 /* Build event list for more than one item */ - pecb2 = &EventTbl[1]; - for(;i< (CFG_MAX_EVENT-1);i++ ) - { - pecb1->eventPtr = (void*)pecb2; /* Set link for list */ - pecb1->id = i; /* Assign ID. */ - pecb1->eventType = EVENT_TYPE_INVALID;/* Sign that not to use. */ - pecb1++; /* Get next item */ - pecb2++; - } - pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */ - pecb1->eventPtr = Co_NULL; /* Set link for last item */ - pecb1->id = i; -#endif - - FreeEventList = &EventTbl[0]; /* Set free event item */ -} - - - -/** - ******************************************************************************* - * @brief Release a ECB - * @param[in] pecb A pointer to event control block which be released. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to release a event control block when a - * event be deleted. - ******************************************************************************* - */ -static void ReleaseECB(P_ECB pecb) -{ - pecb->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */ - OsSchedLock(); /* Lock schedule */ - pecb->eventPtr = FreeEventList; /* Release ECB that event hold */ - FreeEventList = pecb; /* Reset free event item */ - OsSchedUnlock(); /* Unlock schedule */ -} - - - -/** - ******************************************************************************* - * @brief Create a event - * @param[in] eventType The type of event which being created. - * @param[in] eventSortType Event sort type. - * @param[in] eventCounter Event counter,ONLY for EVENT_TYPE_SEM. - * @param[in] eventPtr Event struct pointer,ONLY for Queue.Co_NULL for other - * event type. - * @param[out] None - * @retval Co_NULL Invalid pointer,create event fail. - * @retval others Pointer to event control block which had assigned right now. - * - * @par Description - * @details This function is called by CreateSem(),... - * to get a event control block and initial the event content. - * - * @note This is a internal function of CooCox CoOS,User can't call. - ******************************************************************************* - */ -P_ECB CreatEvent(U8 eventType,U8 eventSortType,void* eventPtr) -{ - P_ECB pecb; - - OsSchedLock(); /* Lock schedule */ - if(FreeEventList == Co_NULL) /* Is there no free evnet item */ - { - OsSchedUnlock(); /* Yes,unlock schedule */ - return Co_NULL; /* Return error */ - } - pecb = FreeEventList;/* Assign the free event item to this event */ - FreeEventList = FreeEventList->eventPtr; /* Reset free event item */ - OsSchedUnlock(); /* Unlock schedul */ - - pecb->eventType = eventType; /* Initialize event item as user set */ - pecb->eventSortType = eventSortType; - pecb->eventPtr = eventPtr; - pecb->eventTCBList = Co_NULL; - return pecb; /* Return event item pointer */ -} - - -/** - ******************************************************************************* - * @brief Delete a event - * @param[in] pecb Pointer to event control block which will be deleted. - * @param[in] opt Delete option. - * @arg == OPT_DEL_ANYWAY Delete event always - * @arg == OPT_DEL_NO_PEND Delete event only when no task pending on. - * @param[out] None - * @retval E_INVALID_PARAMETER Parameter passed is invalid,deleted fail. - * @retval E_TASK_WAITTING These are one more tasks waitting event. - * @retval E_OK Delete event control block successful. - * - * @par Description - * @details This function is called to delete a event from the event wait list - * use specify option. - * - * @note This is a internal function of Coocox CoOS,user can't call. - ******************************************************************************* - */ -StatusType DeleteEvent(P_ECB pecb,U8 opt) -{ - P_OSTCB ptcb; - if(opt == OPT_DEL_NO_PEND) /* Do delete event when no task pend? */ - { - if(pecb->eventTCBList != Co_NULL) /* Yes,is there task pend this event? */ - { - return E_TASK_WAITING; /* Yes,error return */ - } - else - { - ReleaseECB(pecb); /* No,release resource that event hold*/ - } - } - else if(opt == OPT_DEL_ANYWAY) /* Do delete event anyway? */ - { - OsSchedLock(); /* Lock schedule */ - while(pecb->eventTCBList != Co_NULL) /* Is there task pend this event? */ - { /* Yes,remove it */ - ptcb = pecb->eventTCBList;/* Get first task in event waiting list */ - if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */ - { - RemoveDelayList(ptcb); /* Yes,remove task from delay list */ - } - - /* Set next item as event waiting list head */ - pecb->eventTCBList = ptcb->waitNext; - ptcb->waitNext = Co_NULL; /* Clear link for event waiting list */ - ptcb->eventID = INVALID_ID; /* Sign that not to use. */ - - InsertToTCBRdyList(ptcb); /* Insert task into ready list */ - } - OsSchedUnlock(); /* Unlock schedule */ - ReleaseECB(pecb); /* Release resource that event hold */ - } - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Insert a task to event wait list - * @param[in] pecb Pointer to event control block corresponding to the event. - * @param[in] ptcb Pointer to task that will be insert to event wait list. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to insert a task by fllowing manner: - * opt == EVENT_SORT_TYPE_FIFO By FIFO. - * opt == EVENT_SORT_TYPE_PRIO By priority order,hghest priority - * as head,lowest priority as end. - * (Highest-->...-->Lowest-->Co_NULL) - ******************************************************************************* - */ -void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb) -{ - P_OSTCB ptcb1; -#if (CFG_EVENT_SORT == 2) || (CFG_EVENT_SORT == 3) - P_OSTCB ptcb2; -#endif - - OsSchedLock(); /* Lock schedule */ - ptcb1 = pecb->eventTCBList; /* Get first task in event waiting list */ - ptcb->eventID = pecb->id; /* Set event ID for task */ - -#if CFG_EVENT_SORT == 3 /* Does event waiting list sort as FIFO? */ - - if(pecb->eventSortType == EVENT_SORT_TYPE_FIFO) -#endif - -#if (CFG_EVENT_SORT == 1) || (CFG_EVENT_SORT == 3) - { - if(ptcb1 == Co_NULL) /* Is no item in event waiting list?*/ - { - pecb->eventTCBList = ptcb; /* Yes,set task as first item */ - } - else - { - while(ptcb1->waitNext != Co_NULL)/* No,insert task in last */ - { - ptcb1 = ptcb1->waitNext; - } - ptcb1->waitNext = ptcb; /* Set link for list */ - ptcb->waitPrev = ptcb1; - } - } -#endif - -#if CFG_EVENT_SORT ==3 /* Does event waiting list sort as preemptive priority?*/ - else if(pecb->eventSortType == EVENT_SORT_TYPE_PRIO) -#endif -#if (CFG_EVENT_SORT == 2) || (CFG_EVENT_SORT == 3) - { - if(ptcb1 == Co_NULL) /* Is no item in event waiting list? */ - { - pecb->eventTCBList = ptcb; /* Yes,set task as first item */ - } - /* Is PRI of task higher than list first item? */ - else if(ptcb1->prio > ptcb->prio) - { - pecb->eventTCBList = ptcb; /* Reset task as first item */ - ptcb->waitNext = ptcb1; /* Set link for list */ - ptcb1->waitPrev = ptcb; - } - else /* No,find correct place to insert */ - { - ptcb2 = ptcb1->waitNext; - while(ptcb2 != Co_NULL) /* Is last item? */ - { - if(ptcb2->prio > ptcb->prio) /* No,is correct place? */ - { - break; /* Yes,break Circulation */ - } - ptcb1 = ptcb2; /* Save current item */ - ptcb2 = ptcb2->waitNext; /* Get next item */ - } - ptcb1->waitNext = ptcb; /* Set link for list */ - ptcb->waitPrev = ptcb1; - ptcb->waitNext = ptcb2; - if(ptcb2 != Co_NULL) - { - ptcb2->waitPrev = ptcb; - } - } - } -#endif - ptcb->state = TASK_WAITING; /* Set task status to TASK_WAITING state */ - TaskSchedReq = Co_TRUE; - OsSchedUnlock(); /* Unlock schedule,and call task schedule */ -} - - -/** - ******************************************************************************* - * @brief Move a task from event WAITING list to the DELAY list - * @param[in] pecb Pointer to event control block corresponding to the event. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a task from event wait list,and - * then insert it into the READY list. - ******************************************************************************* - */ -void EventTaskToRdy(P_ECB pecb) -{ - P_OSTCB ptcb; -#if CFG_QUEUE_EN >0 - P_QCB pqcb; -#endif - ptcb = pecb->eventTCBList; - if(ptcb == Co_NULL) - return; - - pecb->eventTCBList = ptcb->waitNext;/* Get first task in event waiting list*/ - if(pecb->eventTCBList != Co_NULL) /* Is no item in event waiting list? */ - { - pecb->eventTCBList->waitPrev = Co_NULL; /* No,clear link for first item */ - } - - ptcb->waitNext = Co_NULL; /* Clear event waiting link for task*/ - ptcb->eventID = INVALID_ID; /* Sign that not to use. */ - - if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */ - { - RemoveDelayList(ptcb); /* Yes,remove task from DELAY list */ - } -#if CFG_MAILBOX_EN >0 - if(pecb->eventType == EVENT_TYPE_MBOX)/* Is it a mailbox event? */ - { - ptcb->pmail = pecb->eventPtr; /* Yes,send mail to task */ - pecb->eventPtr = Co_NULL; /* Clear event sign */ - //pecb->eventCounter--; - } -#endif -#if CFG_QUEUE_EN >0 - else if(pecb->eventType == EVENT_TYPE_QUEUE) /* Is it a queue event? */ - { - pqcb = (P_QCB)pecb->eventPtr; /* Yes,get queue pointer */ - ptcb->pmail = *(pqcb->qStart + pqcb->head); /* Send mail to task */ - //pqcb->head++; /* Clear event sign */ - //pqcb->qSize--; - //if(pqcb->head == pqcb->qMaxSize) - //{ - // pqcb->head = 0; - //} - } -#endif - -#if CFG_SEM_EN >0 - else if(pecb->eventType == EVENT_TYPE_SEM)/* Is it a semaphore event? */ - { - //pecb->eventCounter--; /* Yes,clear event sign */ - ptcb->pmail = (void*)0xffffffff; /* Indicate task woke by event */ - } -#endif - if(ptcb == TCBRunning) - { - ptcb->state = TASK_RUNNING; - } - else - { - InsertToTCBRdyList(ptcb); /* Insert task into ready list */ - } -} - - - -/** - ******************************************************************************* - * @brief Move a task from event wait list to the ready list - * @param[in] pecb Pointer to event control block corresponding to the event. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a task from event wait list,and - * then insert it to the ready list. - ******************************************************************************* - */ -void RemoveEventWaittingList(P_OSTCB ptcb) -{ - P_ECB pecb; - pecb = &EventTbl[ptcb->eventID]; /* Get event control block */ - - /* Is there only one item in event waiting list? */ - if((ptcb->waitNext == Co_NULL) && (ptcb->waitPrev == Co_NULL)) - { - pecb->eventTCBList = Co_NULL; /* Yes,set event waiting list as Co_NULL */ - } - else if(ptcb->waitPrev == Co_NULL)/* Is the first item in event waiting list?*/ - { - /* Yes,remove task from list,and reset event waiting list */ - ptcb->waitNext->waitPrev = Co_NULL; - pecb->eventTCBList = ptcb->waitNext; - ptcb->waitNext = Co_NULL; - } - else if(ptcb->waitNext == Co_NULL)/* Is the last item in event waiting list? */ - { - ptcb->waitPrev->waitNext = Co_NULL; /* Yes,remove task form list */ - ptcb->waitPrev = Co_NULL; - } - else /* No, remove task from list */ - { - ptcb->waitPrev->waitNext = ptcb->waitNext; - ptcb->waitNext->waitPrev = ptcb->waitPrev; - ptcb->waitPrev = Co_NULL; - ptcb->waitNext = Co_NULL; - } - ptcb->eventID = INVALID_ID; /* Sign that not to use. */ -} - -#endif //CFG_EVENT_EN - diff --git a/GD32F1/libraries/MapleCoOS116/utility/flag.c b/GD32F1/libraries/MapleCoOS116/utility/flag.c deleted file mode 100644 index 75fc58a..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/flag.c +++ /dev/null @@ -1,735 +0,0 @@ -/** - ******************************************************************************* - * @file flag.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Flag management implementation code of coocox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if CFG_FLAG_EN > 0 -/*---------------------------- Variable Define -------------------------------*/ -#define FLAG_MAX_NUM 32 /*!< Define max flag number. */ -FCB FlagCrl = {0}; /*!< Flags list struct */ - - -/*---------------------------- Function Declare ------------------------------*/ -static void FlagBlock(P_FLAG_NODE pnode,U32 flags,U8 waitType); -static P_FLAG_NODE RemoveFromLink(P_FLAG_NODE pnode); - -/** - ******************************************************************************* - * @brief Create a flag - * @param[in] bAutoReset Reset mode,Co_TRUE(Auto Reset) FLASE(Manual Reset). - * @param[in] bInitialState Initial state. - * @param[out] None - * @retval E_CREATE_FAIL Create flag fail. - * @retval others Create flag successful. - * - * @par Description - * @details This function use to create a event flag. - * @note - ******************************************************************************* - */ -OS_FlagID CoCreateFlag(BOOL bAutoReset,BOOL bInitialState) -{ - U8 i; - OsSchedLock(); - - for(i=0;i 0) /* If be called from ISR */ - { - return E_CALL; - } -#if CFG_PAR_CHECKOUT_EN >0 - if((pfcb->flagActive&(1<headNode; - - while(pnode != Co_NULL) /* Ready all tasks waiting for flags */ - { - if((pnode->waitFlags&(1<waitType == OPT_WAIT_ALL) - { - /* If the flag is only required by NODE */ - if( pnode->waitFlags == (1<waitFlags &= ~(1<nextNode; - } - - /* Remove the flag from the flags list */ - pfcb->flagActive &= ~(1<flagRdy &= ~(1<resetOpt &= ~(1<0 - if(id >= FLAG_MAX_NUM) - { - return E_INVALID_ID; /* Invalid 'id',return error */ - } - if((pfcb->flagActive&(1<flagRdy&(1<flagRdy &= ~((FlagCrl.resetOpt)&(1<0 - if((flags&pfcb->flagActive) != flags ) /* Judge flag is active or not? */ - { - *perr = E_INVALID_PARAMETER; /* Invalid flags */ - return 0; - } -#endif - - springFlag = flags & pfcb->flagRdy; - - OsSchedLock(); - /* If any required flags are set */ - if( (springFlag != 0) && (waitType == OPT_WAIT_ANY) ) - { - - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt); /* Clear the flags */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - - /* If all required flags are set */ - if((springFlag == flags) && (waitType == OPT_WAIT_ALL)) - { - pfcb->flagRdy &= ~(springFlag&pfcb->resetOpt); /* Clear the flags */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - OsSchedUnlock(); - *perr = E_FLAG_NOT_READY; - return 0; -} - - - - -/** - ******************************************************************************* - * @brief WaitForSingleFlag - * @param[in] id Flag ID. - * @param[in] timeout The longest time for writting flag. - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_INVALID_ID Invalid event ID. - * @retval E_TIMEOUT Flag wasn't received within 'timeout' time. - * @retval E_OK The call was successful and your task owns the Flag, - * or the event you are waiting for occurred. - * - * @par Description - * @details This function is called to wait for only one flag, - * (1) if parameter "timeout" == 0,waiting until flag be set; - * (2) when "timeout" != 0,if flag was set or wasn't set but timeout - * occured,the task will exit the waiting list,convert to READY - * or RUNNING state. - * @note - ******************************************************************************* - */ -StatusType CoWaitForSingleFlag(OS_FlagID id,U32 timeout) -{ - FLAG_NODE flagNode; - P_FCB pfcb; - P_OSTCB curTCB; - - if(OSIntNesting > 0) /* See if the caller is ISR */ - { - return E_CALL; - } - if(OSSchedLock != 0) /* Schedule is lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= FLAG_MAX_NUM) /* Judge id is valid or not? */ - { - return E_INVALID_ID; /* Invalid 'id' */ - } - if((FlagCrl.flagActive&(1<flagRdy&(1<flagRdy &= ~((pfcb->resetOpt&(1<state = TASK_WAITING; - TaskSchedReq = Co_TRUE; - OsSchedUnlock(); - - /* The required flag is set and the task is in running state */ - curTCB->pnode = Co_NULL; - OsSchedLock(); - - /* Clear the required flag or not */ - pfcb->flagRdy &= ~((1<resetOpt)); - OsSchedUnlock(); - } - else /* If time-out is configured */ - { - /* Block task until the required flag is set or time-out occurs */ - FlagBlock(&flagNode,(1<pnode == Co_NULL) /* If time-out occurred */ - { - return E_TIMEOUT; - } - else /* If flag is set */ - { - curTCB->pnode = Co_NULL; - OsSchedLock(); - - /* Clear the required flag or not */ - pfcb->flagRdy &= ~((1<resetOpt)); - OsSchedUnlock(); - } - } - } - return E_OK; -} - - -/** - ******************************************************************************* - * @brief WaitForMultipleFlags - * @param[in] flags Flags that waiting to active task. - * @param[in] waitType Flags wait type. - * @param[in] timeout The longest time for writting flag. - * @param[out] perr A pointer to error code. - * @retval 0 - * @retval springFlag - * - * @par Description - * @details This function is called to pend a task for waitting multiple flag. - * @note - ******************************************************************************* - */ -U32 CoWaitForMultipleFlags(U32 flags,U8 waitType,U32 timeout,StatusType *perr) -{ - U32 springFlag; - P_FCB pfcb; - FLAG_NODE flagNode; - P_OSTCB curTCB; - - - if(OSIntNesting > 0) /* If the caller is ISR */ - { - *perr = E_CALL; - return 0; - } - if(OSSchedLock != 0) /* Schedule is lock? */ - { - *perr = E_OS_IN_LOCK; - return 0; /* Yes,error return */ - } -#if CFG_PAR_CHECKOUT_EN >0 - if( (flags&FlagCrl.flagActive) != flags ) - { - *perr = E_INVALID_PARAMETER; /* Invalid 'flags' */ - return 0; - } -#endif - OsSchedLock(); - pfcb = &FlagCrl; - springFlag = flags & pfcb->flagRdy; - - /* If any required flags are set */ - if((springFlag != 0) && (waitType == OPT_WAIT_ANY)) - { - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt); /* Clear the flag */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - - /* If all required flags are set */ - if( (springFlag == flags) && (waitType == OPT_WAIT_ALL) ) - { - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt); /* Clear the flags */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - - curTCB = TCBRunning; - if(timeout == 0) /* If time-out is not configured */ - { - /* Block task until the required flag are set */ - FlagBlock(&flagNode,flags,waitType); - curTCB->state = TASK_WAITING; - TaskSchedReq = Co_TRUE; - OsSchedUnlock(); - - curTCB->pnode = Co_NULL; - OsSchedLock(); - springFlag = flags & pfcb->flagRdy; - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt);/* Clear the flags */ - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - else /* If time-out is configured */ - { - /* Block task until the required flag are set or time-out occurred */ - FlagBlock(&flagNode,flags,waitType); - InsertDelayList(curTCB,timeout); - - OsSchedUnlock(); - if(curTCB->pnode == Co_NULL) /* If time-out occurred */ - { - *perr = E_TIMEOUT; - return 0; - } - else /* If the required flags are set */ - { - curTCB->pnode = Co_NULL; - OsSchedLock(); - springFlag = flags & FlagCrl.flagRdy; - - /* Clear the required ready flags or not */ - pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt); - OsSchedUnlock(); - *perr = E_OK; - return springFlag; - } - } -} - - -/** - ******************************************************************************* - * @brief Clear a Flag - * @param[in] id Flag ID. - * @param[out] None - * @retval E_OK Event deleted successful. - * @retval E_INVALID_ID Invalid event ID. - * - * @par Description - * @details This function is called to clear a flag. - * - * @note - ******************************************************************************* - */ -StatusType CoClearFlag(OS_FlagID id) -{ - P_FCB pfcb; - pfcb = &FlagCrl; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= FLAG_MAX_NUM) - { - return E_INVALID_ID; /* Invalid id */ - } - if((pfcb->flagActive&(1<flagRdy &= ~(1<0 - if(id >= FLAG_MAX_NUM) /* Flag is valid or not */ - { - return E_INVALID_ID; /* Invalid flag id */ - } - if((pfcb->flagActive&(1<flagRdy&(1<flagRdy |= (1<headNode; - while(pnode != Co_NULL) - { - if(pnode->waitType == OPT_WAIT_ALL) /* Extract all the bits we want */ - { - if((pnode->waitFlags&pfcb->flagRdy) == pnode->waitFlags) - { - /* Remove the flag node from the wait list */ - pnode = RemoveFromLink(pnode); - if((pfcb->resetOpt&(1<waitFlags & pfcb->flagRdy) != 0) - { - /* Remove the flag node from the wait list */ - pnode = RemoveFromLink(pnode); - if((pfcb->resetOpt&(1<nextNode; - } - OsSchedUnlock(); - return E_OK; -} - - - -/** - ******************************************************************************* - * @brief Set a flag in ISR - * @param[in] id Flag ID. - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_OK Event deleted successful. - * - * @par Description - * @details This function is called in ISR to set a flag. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -StatusType isr_SetFlag(OS_FlagID id) -{ - if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ - { - /* Insert the request into service request queue */ - if(InsertInSRQ(FLAG_REQ,id,Co_NULL) == Co_FALSE) - { - return E_SEV_REQ_FULL; /* The service requst queue is full */ - } - else - { - return E_OK; - } - } - else - { - return(CoSetFlag(id)); /* The caller is not ISR, set the flag*/ - } -} -#endif - -/** - ******************************************************************************* - * @brief Block a task to wait a flag event - * @param[in] pnode A node that will link into flag waiting list. - * @param[in] flags Flag(s) that the node waiting for. - * @param[in] waitType Waiting type of the node. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to block a task to wait a flag event. - * @note - ******************************************************************************* - */ -static void FlagBlock(P_FLAG_NODE pnode,U32 flags,U8 waitType) -{ - P_FCB pfcb; - pfcb = &FlagCrl; - - TCBRunning->pnode = pnode; - pnode->waitTask = TCBRunning; - pnode->waitFlags = flags; /* Save the flags that we need to wait for*/ - pnode->waitType = waitType; /* Save the type of wait */ - - if(pfcb->tailNode == Co_NULL) /* If this is the first NODE to insert? */ - { - pnode->nextNode = Co_NULL; - pnode->prevNode = Co_NULL; - pfcb->headNode = pnode; /* Insert the NODE to the head */ - } - else /* If it is not the first NODE to insert? */ - { - pfcb->tailNode->nextNode = pnode; /* Insert the NODE to the tail */ - pnode->prevNode = pfcb->tailNode; - pnode->nextNode = Co_NULL; - } - pfcb->tailNode = pnode; -} - - -/** - ******************************************************************************* - * @brief Remove a flag node from list - * @param[in] pnode A node that will remove from flag waiting list. - * @param[out] None - * @retval pnode Next node of the node that have removed out. - * - * @par Description - * @details This function is called to remove a flag node from the wait list. - * @note - ******************************************************************************* - */ -static P_FLAG_NODE RemoveFromLink(P_FLAG_NODE pnode) -{ - P_OSTCB ptcb; - - RemoveLinkNode(pnode); /* Remove the flag node from wait list. */ - ptcb = pnode->waitTask; - - /* The task in the delay list */ - if(ptcb->delayTick != INVALID_VALUE)/* If the task is in tick delay list */ - { - RemoveDelayList(ptcb); /* Remove the task from tick delay list */ - } - - ptcb->pnode = (void*)0xffffffff; - - if(ptcb == TCBRunning) - { - ptcb->state = TASK_RUNNING; - } - else - { - InsertToTCBRdyList(ptcb); /* Insert the task to ready list */ - } - return (pnode->nextNode); -} - -/** - ******************************************************************************* - * @brief Remove a flag node from list - * @param[in] pnode A node that will remove from flag waiting list. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a flag node from the wait list. - * @note - ******************************************************************************* - */ -void RemoveLinkNode(P_FLAG_NODE pnode) -{ - /* If only one NODE in the list*/ - if((pnode->nextNode == Co_NULL) && (pnode->prevNode == Co_NULL)) - { - FlagCrl.headNode = Co_NULL; - FlagCrl.tailNode = Co_NULL; - } - else if(pnode->nextNode == Co_NULL) /* If the NODE is tail */ - { - FlagCrl.tailNode = pnode->prevNode; - pnode->prevNode->nextNode = Co_NULL; - } - else if(pnode->prevNode == Co_NULL) /* If the NODE is head */ - { - FlagCrl.headNode = pnode->nextNode; - pnode->nextNode->prevNode = Co_NULL; - } - else /* The NODE is in the middle */ - { - pnode->nextNode->prevNode = pnode->prevNode; - pnode->prevNode->nextNode = pnode->nextNode; - } - pnode->waitTask->pnode = Co_NULL; -} - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/hook.c b/GD32F1/libraries/MapleCoOS116/utility/hook.c deleted file mode 100644 index 09853b9..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/hook.c +++ /dev/null @@ -1,88 +0,0 @@ -/** - ******************************************************************************* - * @file hook.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief hook management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Inlcude --------------------------------------*/ -#include - -/** - ******************************************************************************* - * @brief IDLE task of OS - * @param[in] pdata The parameter passed to IDLE task. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is system IDLE task code. - ******************************************************************************* - */ -void CoIdleTask(void* pdata) -{ - /* Add your codes here */ - for(; ;) - { - /* Add your codes here */ - } -} - - -/** - ******************************************************************************* - * @brief Hook for stack overflow - * @param[in] taskID Piont to the task which lead to stack overflow. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is a hook for stack overflow. - ******************************************************************************* - */ -void CoStkOverflowHook(OS_TID taskID) -{ - /* Process stack overflow here */ - for(; ;) - { - - } -} - - - - - - diff --git a/GD32F1/libraries/MapleCoOS116/utility/kernelHeap.c b/GD32F1/libraries/MapleCoOS116/utility/kernelHeap.c deleted file mode 100644 index 0950962..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/kernelHeap.c +++ /dev/null @@ -1,432 +0,0 @@ -/** - ******************************************************************************* - * @file kernelHeap.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief kernel heap management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - - -#if CFG_KHEAP_EN >0 -/*---------------------------- Variable Define -------------------------------*/ -U32 KernelHeap[KHEAP_SIZE] = {0}; /*!< Kernel heap */ -P_FMB FMBlist = Co_NULL; /*!< Free memory block list */ -KHeap Kheap = {0}; /*!< Kernel heap control */ - - -/*---------------------------- Function Declare ------------------------------*/ -static P_FMB GetPreFMB(P_UMB usedMB); -/** - ******************************************************************************* - * @brief Create kernel heap - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to create kernel heap. - ******************************************************************************* - */ -void CoCreateKheap(void) -{ - Kheap.startAddr = (U32)(KernelHeap); /* Initialize kernel heap control */ - Kheap.endAddr = (U32)(KernelHeap) + KHEAP_SIZE*4; - FMBlist = (P_FMB)KernelHeap; /* Initialize free memory block list*/ - FMBlist->nextFMB = Co_NULL; - FMBlist->nextUMB = Co_NULL; - FMBlist->preUMB = Co_NULL; -} - - -/** - ******************************************************************************* - * @brief Allocation size bytes of memory block from kernel heap. - * @param[in] size Length of menory block. - * @param[out] None - * @retval Co_NULL Allocate fail. - * @retval others Pointer to memory block. - * - * @par Description - * @details This function is called to allocation size bytes of memory block. - ******************************************************************************* - */ -void* CoKmalloc(U32 size) -{ - P_FMB freeMB,newFMB,preFMB; - P_UMB usedMB,tmpUMB; - U8* memAddr; - U32 freeSize; - U32 kheapAddr; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if( size == 0 ) - { - return Co_NULL; - } -#endif - - /* Word alignment,and add used memory head size */ - size = (((size+3)>>2)<<2) + 8; - kheapAddr = Kheap.endAddr; /* Get the end address of kernel heap */ - OsSchedLock(); /* Lock schedule */ - freeMB = FMBlist; /* Get first item of free memory list */ - preFMB = Co_NULL; - while(freeMB != Co_NULL ) /* Is out of free memory list? */ - { /* No */ - if(freeMB->nextUMB == Co_NULL) /* Is last item of free memory list? */ - { /* Yes,get size for this free item */ - freeSize = kheapAddr - (U32)(freeMB); - } - else /* No,get size for this free item */ - { - freeSize = (U32)(freeMB->nextUMB) -1 - (U32)(freeMB); - } - if(freeSize >= size) /* If the size equal or greater than need */ - { /* Yes,assign in this free memory */ - usedMB=(P_UMB)freeMB;/* Get the address for used memory block head*/ - - /* Get the address for used memory block */ - memAddr = (U8*)((U32)(usedMB) + 8); - - /* Is left size of free memory smaller than 12? */ - if((freeSize-size) < 12) - { - /* Yes,malloc together(12 is the size of the header information - of free memory block ). */ - if(preFMB != Co_NULL)/* Is first item of free memory block list? */ - { /* No,set the link for list */ - preFMB->nextFMB = freeMB->nextFMB; - } - else /* Yes,reset the first item */ - { - FMBlist = freeMB->nextFMB; - } - - if(freeMB->nextUMB != Co_NULL) /* Is last item? */ - { /* No,set the link for list */ - tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1); - tmpUMB->preMB = (void*)((U32)usedMB|0x1); - } - - usedMB->nextMB = freeMB->nextUMB;/* Set used memory block link*/ - usedMB->preMB = freeMB->preUMB; - } - else /* No,the left size more than 12 */ - { - /* Get new free memory block address */ - newFMB = (P_FMB)((U32)(freeMB) + size); - - if(preFMB != Co_NULL)/* Is first item of free memory block list? */ - { - preFMB->nextFMB = newFMB; /* No,set the link for list */ - } - else - { - FMBlist = newFMB; /* Yes,reset the first item */ - } - - /* Set link for new free memory block */ - newFMB->preUMB = (P_UMB)((U32)usedMB|0x1); - newFMB->nextUMB = freeMB->nextUMB; - newFMB->nextFMB = freeMB->nextFMB; - - if(freeMB->nextUMB != Co_NULL) /* Is last item? */ - { /* No,set the link for list */ - tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1); - tmpUMB->preMB = newFMB; - } - - usedMB->nextMB = newFMB; /* Set used memory block link */ - usedMB->preMB = freeMB->preUMB; - } - - if(freeMB->preUMB != Co_NULL) /* Is first item? */ - { /* No,set the link for list */ - tmpUMB = (P_UMB)((U32)(freeMB->preUMB)-1); - tmpUMB->nextMB = (void*)((U32)usedMB|0x1); - } - - OsSchedUnlock(); /* Unlock schedule */ - return memAddr; /* Return used memory block address */ - } - preFMB = freeMB; /* Save current free memory block as previous */ - freeMB = freeMB->nextFMB; /* Get the next item as current item*/ - } - OsSchedUnlock(); /* Unlock schedule */ - return Co_NULL; /* Error return */ -} - - -/** - ******************************************************************************* - * @brief Release memory block to kernel heap. - * @param[in] memBuf Pointer to memory block. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to release memory block. - ******************************************************************************* - */ -void CoKfree(void* memBuf) -{ - P_FMB curFMB,nextFMB,preFMB; - P_UMB usedMB,nextUMB,preUMB; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(memBuf == Co_NULL) - { - return; - } -#endif - - usedMB = (P_UMB)((U32)(memBuf)-8); - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if((U32)(memBuf) < Kheap.startAddr) - { - return; - } - if((U32)(memBuf) > Kheap.endAddr) - { - return; - } -#endif - - - OsSchedLock(); /* Lock schedule */ - -#if CFG_PAR_CHECKOUT_EN >0 /* Check UMB in list */ - if((U32)(usedMB) < (U32)(FMBlist)) - { - preUMB = (P_UMB)((U32)(FMBlist->preUMB)-1); - while(preUMB != usedMB) - { - if(preUMB == Co_NULL) - { - OsSchedUnlock(); - return; - } - preUMB = (P_UMB)((U32)(preUMB->preMB)-1); - } - } - else - { - if(FMBlist == Co_NULL) - { - nextUMB = (P_UMB)(Kheap.startAddr); - } - else - { - if(FMBlist->nextUMB != Co_NULL) - { - nextUMB = (P_UMB)((U32)(FMBlist->nextUMB)-1); - } - else - { - nextUMB = Co_NULL; - } - } - - while(nextUMB != usedMB) - { - if(nextUMB == Co_NULL) - { - OsSchedUnlock(); - return; - } - if(((U32)(nextUMB->nextMB)&0x1) == 0) - { - nextFMB = (P_FMB)(nextUMB->nextMB); - nextUMB = (P_UMB)((U32)(nextFMB->nextUMB)-1); - } - else - { - nextUMB = (P_UMB)((U32)(nextUMB->nextMB)-1); - } - } - } -#endif - - - /* Is between two free memory block? */ - if( (((U32)(usedMB->nextMB)&0x1) == 0) && (((U32)(usedMB->preMB)&0x1)==0) ) - { /* Yes,is the only one item in kernel heap? */ - if((usedMB->nextMB == Co_NULL) && (usedMB->preMB == Co_NULL)) - { - curFMB = (P_FMB)usedMB; /* Yes,release this item */ - curFMB->nextFMB = Co_NULL; - curFMB->nextUMB = Co_NULL; - curFMB->preUMB = Co_NULL; - FMBlist = curFMB; - } - else if(usedMB->preMB == Co_NULL) /* Is the first item in kernel heap */ - { - /* Yes,release this item,and set link for list */ - curFMB = (P_FMB)usedMB; - nextFMB = (P_FMB)usedMB->nextMB; - - curFMB->nextFMB = nextFMB->nextFMB; - curFMB->nextUMB = nextFMB->nextUMB; - curFMB->preUMB = Co_NULL; - FMBlist = curFMB; - } - else if(usedMB->nextMB == Co_NULL) /* Is the last item in kernel heap */ - { /* Yes,release this item,and set link for list */ - curFMB = (P_FMB)(usedMB->preMB); - curFMB->nextFMB = Co_NULL; - curFMB->nextUMB = Co_NULL; - } - else /* All no,show this item between two normal FMB */ - { - /* release this item,and set link for list */ - nextFMB = (P_FMB)usedMB->nextMB; - curFMB = (P_FMB)(usedMB->preMB); - - curFMB->nextFMB = nextFMB->nextFMB; - curFMB->nextUMB = nextFMB->nextUMB; - } - } - else if(((U32)(usedMB->preMB)&0x1) == 0) /* Is between FMB and UMB? */ - { - if(usedMB->preMB == Co_NULL) /* Yes,is the first item in kernel heap? */ - { - /* Yes,release this item,and set link for list */ - curFMB = (P_FMB)usedMB; - nextUMB = (P_UMB)usedMB->nextMB; - curFMB->nextUMB = nextUMB; - curFMB->preUMB = Co_NULL; - curFMB->nextFMB = FMBlist; - FMBlist = curFMB; - } - else /* No,release this item,and set link for list */ - { - curFMB = (P_FMB)usedMB->preMB; - nextUMB = (P_UMB)usedMB->nextMB; - curFMB->nextUMB = nextUMB; - } - - } - else if(((U32)(usedMB->nextMB)&0x1) == 0) /* Is between UMB and FMB? */ - { /* Yes */ - preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */ - curFMB = (P_FMB)(usedMB); /* new FMB */ - preFMB = GetPreFMB(usedMB); /* Get previous FMB */ - if(preFMB == Co_NULL) /* Is previous FMB==Co_NULL? */ - { - nextFMB = FMBlist; /* Yes,get next FMB */ - FMBlist = curFMB; /* Reset new FMB as the first item of FMB list*/ - } - else - { - nextFMB = preFMB->nextFMB; /* No,get next FMB */ - preFMB->nextFMB = curFMB; /* Set link for FMB list */ - } - - if(nextFMB == Co_NULL) /* Is new FMB as last item of FMB list? */ - { - curFMB->preUMB = preUMB; /* Yes,set link for list */ - curFMB->nextUMB = Co_NULL; - curFMB->nextFMB = Co_NULL; - } - else - { - curFMB->preUMB = preUMB; /* No,set link for list */ - curFMB->nextUMB = nextFMB->nextUMB; - curFMB->nextFMB = nextFMB->nextFMB; - } - } - else /* All no,show UMB between two UMB*/ - { - curFMB = (P_FMB)(usedMB); /* new FMB */ - preFMB = GetPreFMB(usedMB); /* Get previous FMB */ - preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */ - nextUMB = (P_UMB)(usedMB->nextMB); /* Get next UMB */ - - if(preFMB == Co_NULL ) /* Is previous FMB==Co_NULL? */ - { - nextFMB = FMBlist; /* Yes,get next FMB */ - FMBlist = curFMB; /* Reset new FMB as the first item of FMB list */ - } - else - { - nextFMB = preFMB->nextFMB; /* No,get next FMB */ - preFMB->nextFMB = curFMB; /* Set link for FMB list */ - } - - curFMB->preUMB = preUMB; /* Set current FMB link for list */ - curFMB->nextUMB = nextUMB; - curFMB->nextFMB = nextFMB; - } - - if(curFMB->preUMB != Co_NULL)/* Is current FMB as first item in kernel heap? */ - { /* No,set link for list */ - preUMB = (P_UMB)((U32)(curFMB->preUMB)-1); - preUMB->nextMB = (void*)curFMB; - } - if(curFMB->nextUMB != Co_NULL)/* Is current FMB as last item in kernel heap? */ - { /* No,set link for list */ - nextUMB = (P_UMB)((U32)(curFMB->nextUMB)-1); - nextUMB->preMB = (void*)curFMB; - } - OsSchedUnlock(); /* Unlock schedule */ -} - - -/** - ******************************************************************************* - * @brief Get previous free memory block pointer. - * @param[in] usedMB Current used memory block. - * @param[out] None - * @retval Previous free memory block pointer. - * - * @par Description - * @details This function is called to get previous free memory block pointer. - ******************************************************************************* - */ -static P_FMB GetPreFMB(P_UMB usedMB) -{ - P_UMB preUMB; - preUMB = usedMB; - while(((U32)(preUMB->preMB)&0x1)) /* Is previous MB as FMB? */ - { /* No,get previous MB */ - preUMB = (P_UMB)((U32)(preUMB->preMB)-1); - } - return (P_FMB)(preUMB->preMB); /* Yes,return previous MB */ -} - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/mbox.c b/GD32F1/libraries/MapleCoOS116/utility/mbox.c deleted file mode 100644 index 1e2e587..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/mbox.c +++ /dev/null @@ -1,356 +0,0 @@ -/** - ******************************************************************************* - * @file mbox.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Mailbox management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include - - -#if CFG_MAILBOX_EN > 0 - - -/** - ******************************************************************************* - * @brief Create a mailbox - * @param[in] sortType Mail box waiting list sort type. - * @param[out] None - * @retval E_CREATE_FAIL Create mailbox fail. - * @retval others Create mailbox successful. - * - * @par Description - * @details This function is called to create a mailbox. - * @note - ******************************************************************************* - */ -OS_EventID CoCreateMbox(U8 sortType) -{ - P_ECB pecb; - - /* Create a mailbox type event control block */ - pecb = CreatEvent(EVENT_TYPE_MBOX,sortType,Co_NULL); - if(pecb == Co_NULL) /* If failed to create event block */ - { - return E_CREATE_FAIL; - } - pecb->eventCounter = 0; - return (pecb->id); /* Create a mailbox successfully, return event ID */ -} - - - -/** - ******************************************************************************* - * @brief Delete a mailbox - * @param[in] id Event ID. - * @param[in] opt Delete option. - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_INVALID_PARAMETER Invalid parameter. - * @retval E_TASK_WAITTING Tasks waitting for the event,delete fail. - * @retval E_OK Event deleted successful. - * - * @par Description - * @details This function is called to delete a mailbox. - * @note - ******************************************************************************* - */ -StatusType CoDelMbox(OS_EventID id,U8 opt) -{ - P_ECB pecb; - -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) /* Judge id is valid or not? */ - { - return E_INVALID_ID; /* Id is invalid ,return error */ - } -#endif - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_MBOX)/* Validate event control block type*/ - { - return E_INVALID_ID; /* The event is not mailbox */ - } -#endif - return (DeleteEvent(pecb,opt)); /* Delete the mailbox event control block */ -} - - - -/** - ******************************************************************************* - * @brief Accept a mailbox - * @param[in] id Event ID. - * @param[out] perr A pointer to error code. - * @retval Co_NULL - * @retval A pointer to mailbox accepted. - * - * @par Description - * @details This function is called to accept a mailbox. - * @note - ******************************************************************************* - */ -void* CoAcceptMail(OS_EventID id,StatusType* perr) -{ - P_ECB pecb; - void* pmail; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - *perr = E_INVALID_ID; /* Invalid 'id' */ - return Co_NULL; - } -#endif - pecb = &EventTbl[id]; - -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_MBOX)/* Invalid event control block type */ - { - *perr = E_INVALID_ID; - return Co_NULL; - } -#endif - OsSchedLock(); - if(pecb->eventCounter == 1) /* If there is already a message */ - { - *perr = E_OK; - pmail = pecb->eventPtr; /* Get the message */ - pecb->eventPtr = Co_NULL; /* Clear the mailbox */ - pecb->eventCounter = 0; - OsSchedUnlock(); - return pmail; /* Return the message received */ - } - else /* If the mailbox is empty */ - { - OsSchedUnlock(); - *perr = E_MBOX_EMPTY; /* Mailbox is empty,return Co_NULL */ - return Co_NULL; - } -} - - - -/** - ******************************************************************************* - * @brief Wait for a mailbox - * @param[in] id Event ID. - * @param[in] timeout The longest time for writting mail. - * @param[out] perr A pointer to error code. - * @retval Co_NULL - * @retval A pointer to mailbox accept. - * - * @par Description - * @details This function is called to wait a mailbox. - * @note - ******************************************************************************* - */ -void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr) -{ - P_ECB pecb; - void* pmail; - P_OSTCB curTCB; - - if(OSIntNesting > 0) /* If the caller is ISR */ - { - *perr = E_CALL; - return Co_NULL; - } - -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - *perr = E_INVALID_ID; /* Invalid 'id',retrun error */ - return Co_NULL; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_MBOX) - { - *perr = E_INVALID_ID; /* Invalid event type,not EVENT_TYPE_MBOX */ - return Co_NULL; - } -#endif - - if(OSSchedLock != 0) /* Judge schedule is locked or not? */ - { - *perr = E_OS_IN_LOCK; /* Schedule is locked */ - return Co_NULL; /* return Co_NULL */ - } - OsSchedLock(); - if( pecb->eventCounter == 1) /* If there is already a message */ - { - *perr = E_OK; - pmail = pecb->eventPtr; /* Get the message */ - pecb->eventPtr = Co_NULL; /* Clear the mailbox */ - pecb->eventCounter = 0; - OsSchedUnlock(); - return pmail; /* Return the message received */ - } - else /* If message is not available, task will pend */ - { - OsSchedUnlock(); - curTCB = TCBRunning; - if(timeout == 0) /* If time-out is not configured */ - { - EventTaskToWait(pecb,curTCB); /* Block task until event occurs */ - *perr = E_OK; - - /* Have recived a message or the mailbox have been deleted */ - OsSchedLock(); - pmail = curTCB->pmail; - pecb->eventCounter = 0; - curTCB->pmail = Co_NULL; - OsSchedUnlock(); - return pmail; /* Return received message or Co_NULL */ - } - else /* If time-out is configured */ - { - OsSchedLock(); - - /* Block task until event or timeout occurs */ - EventTaskToWait(pecb,curTCB); - InsertDelayList(curTCB,timeout); - OsSchedUnlock(); - if( curTCB->pmail == Co_NULL) /* Time-out occurred */ - { - *perr = E_TIMEOUT; - return Co_NULL; - } - else /* Have recived a message or the mailbox have been deleted*/ - { - *perr = E_OK; - - OsSchedLock(); - pmail = curTCB->pmail; - pecb->eventCounter = 0; - curTCB->pmail = Co_NULL; - OsSchedUnlock(); - - return pmail; /* Return received message or Co_NULL */ - } - } - } -} - - -/** - ******************************************************************************* - * @brief Post a mailbox - * @param[in] id Event ID. - * @param[in] pmail Pointer to mail that want to send. - * @param[out] None - * @retval E_INVALID_ID - * @retval E_OK - * - * @par Description - * @details This function is called to post a mail. - * @note - ******************************************************************************* - */ -StatusType CoPostMail(OS_EventID id,void* pmail) -{ - P_ECB pecb; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; /* Invalid id,return error */ - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_MBOX)/* Validate event control block type*/ - { - return E_INVALID_ID; /* Event is not mailbox,return error*/ - } -#endif - - if(pecb->eventCounter == 0) /* If mailbox doesn't already have a message*/ - { - OsSchedLock(); - pecb->eventPtr = pmail; /* Place message in mailbox */ - pecb->eventCounter = 1; - EventTaskToRdy(pecb); /* Check waiting list */ - OsSchedUnlock(); - return E_OK; - } - else /* If there is already a message in mailbox */ - { - return E_MBOX_FULL; /* Mailbox is full,and return "E_MBOX_FULL" */ - } -} - -/** - ******************************************************************************* - * @brief Post a mailbox in ISR - * @param[in] id Event ID. - * @param[in] pmail Pointer to mail that want to send. - * @param[out] None - * @retval E_INVALID_ID - * @retval E_OK - * - * @par Description - * @details This function is called to post a mail in ISR. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -StatusType isr_PostMail(OS_EventID id,void* pmail) -{ - if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ - { - /* Insert the request into service request queue */ - if(InsertInSRQ(MBOX_REQ,id,pmail) == Co_FALSE) - { - return E_SEV_REQ_FULL; /* If service request queue is full */ - } - else /* Operate successfully */ - { - return E_OK; - } - } - else - { - return(CoPostMail(id,pmail)); /* Sends the message to the mailbox */ - } -} -#endif - -#endif - - diff --git a/GD32F1/libraries/MapleCoOS116/utility/mm.c b/GD32F1/libraries/MapleCoOS116/utility/mm.c deleted file mode 100644 index 8654ba0..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/mm.c +++ /dev/null @@ -1,298 +0,0 @@ -/** - ******************************************************************************* - * @file mm.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief memory management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - - -#if CFG_MM_EN > 0 -/*---------------------------- Variable Define -------------------------------*/ -MM MemoryTbl[CFG_MAX_MM] = {{0}};/*!< Table which save memory control block. */ -U32 MemoryIDVessel = 0; /*!< Memory ID container. */ - -/** - ******************************************************************************* - * @brief Create a memory partition - * @param[in] memBuf Specify memory partition head address. - * @param[in] blockSize Specify memory block size. - * @param[in] blockNum Specify memory block number. - * @param[out] None - * @retval E_CREATE_FAIL Create memory partition fail. - * @retval others Create memory partition successful. - * - * @par Description - * @details This function is called to create a memory partition. - ******************************************************************************* - */ -OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum) -{ - U8 i,j; - U8 *memory; - P_MemBlk memBlk; - memory = memBuf; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(memBuf == Co_NULL) - { - return E_CREATE_FAIL; - } - if(blockSize == 0) - { - return E_CREATE_FAIL; - } - if((blockSize&0x3) != 0) - { - return E_CREATE_FAIL; - } - if(blockNum<=1) - { - return E_CREATE_FAIL; - } -#endif - - OsSchedLock(); /* Lock schedule */ - for(i = 0; i < CFG_MAX_MM; i++) - { - if((MemoryIDVessel & (1 << i)) == 0) /* Is free memory ID? */ - { - MemoryIDVessel |= (1<nextBlock = (P_MemBlk)memory; - memBlk = memBlk->nextBlock; - } - memBlk->nextBlock = Co_NULL; - return i; /* Return memory block ID */ - } - } - OsSchedUnlock(); /* Unlock schedule */ - return E_CREATE_FAIL; /* Error return */ -} - - -/** - ******************************************************************************* - * @brief Delete a memory partition - * @param[in] mmID Specify memory partition that want to delete. - * @param[out] None - * @retval E_INVALID_ID The memory partition id passed was invalid,delete fail. - * @retval E_OK Delete successful. - * - * @par Description - * @details This function is called to Delete a memory partition. - ******************************************************************************* - */ -StatusType CoDelMemoryPartition(OS_MMID mmID) -{ - P_MM memCtl; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(mmID >= CFG_MAX_MM) - { - return E_INVALID_ID; - } - if( ((1<memAddr = Co_NULL; - memCtl->freeBlock = Co_NULL; - memCtl->blockSize = 0; - memCtl->blockNum = 0; - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Get free block number in a memory partition - * @param[in] mmID Specify memory partition. - * - * @param[out] E_INVALID_ID Invalid ID was passed and get counter failure. - * @param[out] E_OK Get current counter successful. - * @retval fbNum The number of free block. - * - * @par Description - * @details This function is called to get free block number in a memory - * partition. - ******************************************************************************* - */ -U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr) -{ - U32 fbNum; - P_MM memCtl; - P_MemBlk memBlk; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(mmID >= CFG_MAX_MM) - { - *perr = E_INVALID_ID; - return 0; - } - if( ((1<freeBlock);/* Get the free item in memory list*/ - fbNum = 0; - while(memBlk != Co_NULL) /* Get counter of free item */ - { - fbNum++; - memBlk = memBlk->nextBlock; /* Get next free iterm */ - } - OsSchedUnlock(); /* Unlock schedul */ - *perr = E_OK; - return fbNum; /* Return the counter of free item */ -} - - -/** - ******************************************************************************* - * @brief Get a memory buffer from memory partition - * @param[in] mmID Specify memory partition that want to assign buffer. - * @param[out] None - * @retval Co_NULL Assign buffer fail. - * @retval others Assign buffer successful,and return the buffer pointer. - * - * @par Description - * @details This function is called to Delete a memory partition. - ******************************************************************************* - */ -void* CoGetMemoryBuffer(OS_MMID mmID) -{ - P_MM memCtl; - P_MemBlk memBlk; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(mmID >= CFG_MAX_MM) - { - return Co_NULL; - } - if( ((1<freeBlock == Co_NULL ) /* Is there no free item in memory list */ - { - OsSchedUnlock(); /* Unlock schedule */ - return Co_NULL; /* Yes,error return */ - } - memBlk = (P_MemBlk)memCtl->freeBlock; /* Get free memory block */ - memCtl->freeBlock = (U8*)memBlk->nextBlock; /* Reset the first free item */ - OsSchedUnlock(); /* Unlock schedule */ - return memBlk; /* Return free memory block address */ -} - - - -/** - ******************************************************************************* - * @brief Free a memory buffer to memory partition - * @param[in] mmID Specify memory partition. - * @param[in] buf Specify memory buffer that want to free. - * @param[out] None - * @retval E_INVALID_ID The memory partition id passed was invalid. - * @retval E_INVALID_PARAMETER The parameter passed was invalid. - * @retval E_OK Free successful. - * - * @par Description - * @details This function is called to Delete a memory partition. - ******************************************************************************* - */ -StatusType CoFreeMemoryBuffer(OS_MMID mmID,void* buf) -{ - P_MM memCtl; - P_MemBlk memBlk; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(mmID >= CFG_MAX_MM) - { - return E_INVALID_ID; - } - if( ((1<0 /* Check validity of parameter */ - if((U32)buf < (U32)(memCtl->memAddr)) - { - return E_INVALID_PARAMETER; - } - if((U32)buf > (U32)(memCtl->memAddr + memCtl->blockSize*memCtl->blockNum)) - { - return E_INVALID_PARAMETER; - } - if(((U32)buf - (U32)(memCtl->memAddr))%(memCtl->blockSize) != 0) - { - return E_INVALID_PARAMETER; - } -#endif - memBlk = (P_MemBlk)buf; /* Reset the first free item */ - OsSchedLock(); - memBlk->nextBlock = (P_MemBlk)memCtl->freeBlock; - memCtl->freeBlock = buf; - OsSchedUnlock(); - return E_OK; /* Return OK */ -} - -#endif - diff --git a/GD32F1/libraries/MapleCoOS116/utility/mutex.c b/GD32F1/libraries/MapleCoOS116/utility/mutex.c deleted file mode 100644 index 4906fde..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/mutex.c +++ /dev/null @@ -1,372 +0,0 @@ -/** - ******************************************************************************* - * @file mutex.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Mutex management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - - -/*---------------------------- Variable Define -------------------------------*/ -#if CFG_MUTEX_EN > 0 - -OS_MutexID MutexFreeID = 0; /*!< Point to next vliad mutex ID. */ -MUTEX MutexTbl[CFG_MAX_MUTEX] = {{0}}; /*!< Mutex struct array */ - - - -/** - ******************************************************************************* - * @brief Create a mutex - * @param[in] None - * @param[out] None - * @retval E_CREATE_FAIL Create mutex fail. - * @retval others Create mutex successful. - * - * @par Description - * @details This function is called to create a mutex. - * @note - ******************************************************************************* - */ -OS_MutexID CoCreateMutex(void) -{ - OS_MutexID id; - P_MUTEX pMutex; - OsSchedLock(); - - /* Assign a free mutex control block */ - if(MutexFreeID < CFG_MAX_MUTEX ) - { - id = MutexFreeID++; - OsSchedUnlock(); - pMutex = &MutexTbl[id]; - pMutex->hipriTaskID = INVALID_ID; - pMutex->originalPrio = 0xff; - pMutex->mutexFlag = MUTEX_FREE; /* Mutex is free,not was occupied */ - pMutex->taskID = INVALID_ID; - pMutex->waittingList = Co_NULL; - return id; /* Return mutex ID */ - } - - OsSchedUnlock(); - return E_CREATE_FAIL; /* No free mutex control block */ -} - - - -/** - ******************************************************************************* - * @brief Enter a critical area - * @param[in] mutexID Specify mutex. - * @param[out] None - * @retval E_INVALID_ID Invalid mutex id. - * @retval E_CALL Error call in ISR. - * @retval E_OK Enter critical area successful. - * - * @par Description - * @details This function is called when entering a critical area. - * @note - ******************************************************************************* - */ -StatusType CoEnterMutexSection(OS_MutexID mutexID) -{ - P_OSTCB ptcb,pCurTcb; - P_MUTEX pMutex; - -#if CFG_EVENT_EN >0 - P_ECB pecb; -#endif - - if(OSIntNesting > 0) /* If the caller is ISR */ - { - return E_CALL; - } - if(OSSchedLock != 0) /* Is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - -#if CFG_PAR_CHECKOUT_EN >0 - if(mutexID >= MutexFreeID) /* Invalid 'mutexID' */ - { - return E_INVALID_ID; - } -#endif - - OsSchedLock(); - pCurTcb = TCBRunning; - pMutex = &MutexTbl[mutexID]; - - pCurTcb->mutexID = mutexID; - if(pMutex->mutexFlag == MUTEX_FREE) /* If mutex is available */ - { - pMutex->originalPrio = pCurTcb->prio; /* Save priority of owning task */ - pMutex->taskID = pCurTcb->taskID; /* Acquire the resource */ - pMutex->hipriTaskID = pCurTcb->taskID; - pMutex->mutexFlag = MUTEX_OCCUPY; /* Occupy the mutex resource*/ - } - /* If the mutex resource had been occupied */ - else if(pMutex->mutexFlag == MUTEX_OCCUPY) - { - ptcb = &TCBTbl[pMutex->taskID]; - if(ptcb->prio > pCurTcb->prio) /* Need to promote priority of owner? */ - { -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - DeleteTaskPri(ptcb->prio); - ActiveTaskPri(pCurTcb->prio); -#endif - ptcb->prio = pCurTcb->prio; /* Promote prio of owner */ - - /* Upgarde the highest priority about the mutex */ - pMutex->hipriTaskID = pCurTcb->taskID; - if(ptcb->state == TASK_READY) /* If the task is ready to run */ - { - RemoveFromTCBRdyList(ptcb); /* Remove the task from READY list*/ - InsertToTCBRdyList(ptcb); /* Insert the task into READY list*/ - } -#if CFG_EVENT_EN >0 - /* If the task is waiting on a event */ - else if(ptcb->eventID != INVALID_ID) - { - pecb = &EventTbl[ptcb->eventID]; - - /* If the event waiting type is preemptive Priority */ - if(pecb->eventSortType == EVENT_SORT_TYPE_PRIO) - { - /* Remove the task from event waiting list */ - RemoveEventWaittingList(ptcb); - - /* Insert the task into event waiting list */ - EventTaskToWait(pecb,ptcb); - } - } -#endif - } - - pCurTcb->state = TASK_WAITING; /* Block current task */ - TaskSchedReq = Co_TRUE; - pCurTcb->TCBnext = Co_NULL; - pCurTcb->TCBprev = Co_NULL; - - ptcb = pMutex->waittingList; - if(ptcb == Co_NULL) /* If the event waiting list is empty */ - { - pMutex->waittingList = pCurTcb; /* Insert the task to head */ - } - else /* If the event waiting list is not empty */ - { - while(ptcb->TCBnext != Co_NULL) /* Insert the task to tail */ - { - ptcb = ptcb->TCBnext; - } - ptcb->TCBnext = pCurTcb; - pCurTcb->TCBprev = ptcb; - pCurTcb->TCBnext = Co_NULL; - } - } - OsSchedUnlock(); - return E_OK; -} - - -/** - ******************************************************************************* - * @brief Leave from a critical area - * @param[in] mutexID Specify mutex id. - * @param[out] None - * @retval E_INVALID_ID Invalid mutex id. - * @retval E_CALL Error call in ISR. - * @retval E_OK Exit a critical area successful. - * - * @par Description - * @details This function must be called when exiting from a critical area. - * @note - ******************************************************************************* - */ -StatusType CoLeaveMutexSection(OS_MutexID mutexID) -{ - P_OSTCB ptcb; - P_MUTEX pMutex; - U8 prio; - U8 taskID; - - if(OSIntNesting > 0) /* If the caller is ISR */ - { - return E_CALL; - } - -#if CFG_PAR_CHECKOUT_EN >0 - if(mutexID >= MutexFreeID) - { - return E_INVALID_ID; /* Invalid mutex id, return error */ - } -#endif - OsSchedLock(); - pMutex = &MutexTbl[mutexID]; /* Obtain point of mutex control block*/ - ptcb = &TCBTbl[pMutex->taskID]; - ptcb->mutexID = INVALID_ID; - if(pMutex->waittingList == Co_NULL) /* If the mutex waiting list is empty */ - { - pMutex->mutexFlag = MUTEX_FREE; /* The mutex resource is available */ - pMutex->taskID = INVALID_ID; - OsSchedUnlock(); - } - else /* If there is at least one task waitting for the mutex */ - { - taskID = pMutex->taskID; /* Get task ID of mutex owner */ - - /* we havn't promoted current task's priority */ - if(pMutex->hipriTaskID == taskID) - { - ptcb = pMutex->waittingList;/* Point to mutex first waiting task */ - prio = ptcb->prio; - while(ptcb != Co_NULL) /* Find the highest priority task */ - { - if(ptcb->prio < prio) - { - prio = ptcb->prio; - pMutex->hipriTaskID = ptcb->taskID; - } - ptcb = ptcb->TCBnext; - } - } - else /* we have promoted current task's priority */ - { - prio = TCBTbl[taskID].prio; - } - - /* Reset the task priority */ - pMutex->taskID = INVALID_ID; - CoSetPriority(taskID,pMutex->originalPrio); - - /* Find first task in waiting list ready to run */ - ptcb = pMutex->waittingList; - pMutex->waittingList = ptcb->TCBnext; - pMutex->originalPrio = ptcb->prio; - pMutex->taskID = ptcb->taskID; - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(prio != ptcb->prio) - { - DeleteTaskPri(ptcb->prio); - ActiveTaskPri(prio); - } -#endif - - ptcb->prio = prio; /* Raise the task's priority */ - - /* Insert the task which acquire the mutex into ready list. */ - ptcb->TCBnext = Co_NULL; - ptcb->TCBprev = Co_NULL; - - InsertToTCBRdyList(ptcb); /* Insert the task into the READY list */ - OsSchedUnlock(); - } - return E_OK; -} - -/** - ******************************************************************************* - * @brief Remove a task from mutex waiting list - * @param[in] ptcb TCB which will remove out. - * @param[out] None - * @retval None - * - * @par Description - * @details This function be called when delete a task. - * @note - ******************************************************************************* - */ -void RemoveMutexList(P_OSTCB ptcb) -{ - U8 prio; - OS_TID taskID; - P_MUTEX pMutex; - pMutex = &MutexTbl[ptcb->mutexID]; - - /* If only one task waiting on mutex */ - if((ptcb->TCBnext ==Co_NULL) && (ptcb->TCBprev == Co_NULL)) - { - pMutex->waittingList = Co_NULL; /* Waiting list is empty */ - } - else if(ptcb->TCBnext == Co_NULL) /* If the task is the last of waiting list*/ - { - /* Remove task from mutex waiting list */ - ptcb->TCBprev->TCBnext = Co_NULL; - ptcb->TCBprev = Co_NULL; - } - else if(ptcb->TCBprev == Co_NULL)/* If the task is the first of waiting list*/ - { - /* Remove task from waiting list */ - ptcb->TCBnext->TCBprev = Co_NULL; - ptcb->TCBnext = Co_NULL; - } - else /* If the task is in the middle of waiting list */ - { - /* Remove task from wait list */ - ptcb->TCBnext->TCBprev = ptcb->TCBprev; - ptcb->TCBprev->TCBnext = ptcb->TCBnext; - ptcb->TCBprev = Co_NULL; - ptcb->TCBnext = Co_NULL; - } - - ptcb->mutexID = INVALID_ID; - - /* If the task have highest priority in mutex waiting list */ - if(pMutex->hipriTaskID == ptcb->taskID) - { - ptcb = pMutex->waittingList; - prio = pMutex->originalPrio; - pMutex->hipriTaskID = pMutex->taskID; - while(ptcb != Co_NULL) /* Find task ID of highest priority task*/ - { - if(ptcb->prio < prio) - { - prio = ptcb->prio; - pMutex->hipriTaskID = ptcb->taskID; - } - ptcb = ptcb->TCBnext; - } - taskID = pMutex->taskID; - pMutex->taskID = INVALID_ID; - CoSetPriority(taskID,prio); /* Reset the mutex ower priority */ - pMutex->taskID = taskID; - } -} - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/port.c b/GD32F1/libraries/MapleCoOS116/utility/port.c deleted file mode 100644 index acf2926..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/port.c +++ /dev/null @@ -1,334 +0,0 @@ -/** - ******************************************************************************* - * @file prot.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Compiler adapter for CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include "coocox.h" - - -//****************************************************************************** -// EQUATES -//****************************************************************************** -U32 NVIC_INT_CTRL = 0xE000ED04; // Interrupt control state register -U32 NVIC_PENDSVSET = 0x10000000; // Value to trigger PendSV exception -U32 INT_EXIT = 0xFFFFFFFC; - -//****************************************************************************** -// PUBLIC FUNCTIONS -//****************************************************************************** -extern U8 Inc8(volatile U8 *data) ; -extern U8 Dec8(volatile U8 *data) ; -extern void IRQ_ENABLE_RESTORE(void); -extern void IRQ_DISABLE_SAVE(void); -extern void SetEnvironment(OS_STK *pstk) __attribute__ ((naked)); -extern void SwitchContext(void) __attribute__ ((naked)); -extern void PendSV_Handler(void) __attribute__ ((naked)); - - -/** - ****************************************************************************** - * @brief Plus a byte integers and Saved into memory cell - * @param[in] data byte integers. - * @param[out] None - * @retval Returns Original value. - * - * @par Description - * @details This function is called to Plus a byte integers - * and Saved into memory cell. - ****************************************************************************** - */ -U8 Inc8 (volatile U8 *data) -{ - register U8 result = 0; - - __asm volatile - ( - " PUSH {R1} \n" - " CPSID I \n" - " LDRB R1,[%1] \n" - " ADD R1,#1 \n" - " STRB R1,[%1] \n" - " CPSIE I \n" - " SUB R1,#0x1 \n" - " MOVS %0,R1 \n" - " POP {R1} \n" - :"=r"(result) - :"r"(data) - ); - return (result); - -} - - -/** - ****************************************************************************** - * @brief Decrease a byte integers and Saved into memory cell - * @param[in] data byte integers. - * @param[out] None - * @retval Returns Original value. - * - * @par Description - * @details This function is called to Decrease a byte integers - * and Saved into memory cell. - ****************************************************************************** - */ -U8 Dec8 (volatile U8 *data) -{ - register U8 result = 0; - __asm volatile - ( - " PUSH {R1} \n" - " CPSID I \n" - " LDRB R1,[%1] \n" - " SUB R1,#1 \n" - " STRB R1,[%1] \n" - " CPSIE I \n" - " MOVS %0,R1 \n" - " POP {R1} \n" - :"=r"(result) - :"r"(data) - ); - return (result); -} - -/** - ****************************************************************************** - * @brief ENABLE Interrupt - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to ENABLE Interrupt. - ****************************************************************************** - */ -void IRQ_ENABLE_RESTORE(void) -{ - __asm volatile - ( - " CPSIE I \n" - ); - return; -} - -/** - ****************************************************************************** - * @brief Close Interrupt - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to close Interrupt. - ****************************************************************************** - */ -void IRQ_DISABLE_SAVE(void) -{ - __asm volatile - ( - " CPSID I \n" - ); - return; -} - - -/** - ****************************************************************************** - * @brief Set environment for Coocox OS running - * @param[in] pstk stack pointer - * @param[out] None - * @retval None. - * - * @par Description - * @details This function is called to Set environment - * for Coocox OS running. - ****************************************************************************** - */ -void SetEnvironment (OS_STK *pstk) -{ - __asm volatile - ( -#if CFG_CHIP_TYPE == 3 - " SUB R0,#100 \n" -#else - " SUB R0,#28 \n" -#endif - " MSR PSP,R0 \n" - " BX LR \n" - ); - -} - - -/** - ****************************************************************************** - * @brief Do ready work to Switch Context for task change - * @param[in] None - * @param[out] None - * @retval None. - * - * @par Description - * @details This function is called to Do ready work to - * Switch Context for task change - ****************************************************************************** - */ -void SwitchContext(void) -{ - __asm volatile - ( - " LDR R3,=NVIC_INT_CTRL \n" - " LDR R3,[R3] \n" - " LDR R2,=NVIC_PENDSVSET \n" - " LDR R1,[R2] \n" - " STR R1, [R3] \n" - " BX LR \n" - ); - -} - - - -/** - ****************************************************************************** - * @brief Switch Context for task change - * @param[in] None - * @param[out] None - * @retval None. - * - * @par Description - * @details This function is called to Switch Context for task change. - ****************************************************************************** - */ -#if CFG_CHIP_TYPE == 2 -// Maple -void __exc_pendsv(void) -{ - __asm volatile - ( - " LDR R3,=TCBRunning \n" - " LDR R1,[R3] \n" // R1 == running tcb - " LDR R2,=TCBNext \n" - " LDR R2,[R2] \n" // R2 == next tcb - - " CMP R1,R2 \n" - " BEQ exitPendSV \n" - " MRS R0, PSP \n" // Get PSP point (can not use PUSH,in ISR,SP is MSP ) - - " SUB R0,R0,#32 \n" - " STR R0,[R1] \n" // Save orig PSP - // Store r4-r11,r0 -= regCnt * 4,r0 is new stack - // top point (addr h->l r11,r10,...,r5,r4) - " STMIA R0!,{R4-R7} \n" // Save old context (R4-R7) - " MOV R4,R8 \n" - " MOV R5,R9 \n" - " MOV R6,R10 \n" - " MOV R7,R11 \n" - " STMIA R0!,{R4-R7} \n" // Save old context (R8-R11) - - " popStk: \n" - " STR R2, [R3] \n" // TCBRunning = TCBNext; - " LDR R0, [R2] \n" // Get SP of task that be switch into. - - " ADD R0,R0,#16 \n" - " LDMIA R0!,{R4-R7} \n" // Restore new Context (R8-R11) - " MOV R8,R4 \n" - " MOV R9,R5 \n" - " MOV R10,R6 \n" - " MOV R11,R7 \n" - " SUB R0,R0,#32 \n" - " LDMIA R0!,{R4-R7} \n" // Restore new Context (R4-R7) - " ADD R0,R0,#16 \n" - " MSR PSP, R0 \n" // Mov new stack point to PSP - - " exitPendSV: \n" - " LDR R3,=OSSchedLock \n" - " MOV R0, #0x0 \n" - " STRB R0, [R3] \n" - - " LDR R3,=INT_EXIT \n" - " LDR R0, [R3] \n" - " BX R0 \n" // Exit interrupt - ); -} -#endif - -#if CFG_CHIP_TYPE == 1 || 3 == CFG_CHIP_TYPE -// Maple -void __exc_pendsv(void) -{ -////////debug block ///////////////////////// - __asm volatile - ( - " LDR R3,=TCBRunning \n" - " LDR R1,[R3] \n" // R1 == running tcb - " LDR R2,=TCBNext \n" - " LDR R2,[R2] \n" // R2 == next tcb - - " CMP R1,R2 \n" - " BEQ exitPendSV \n" - - " MRS R0, PSP \n" // Get PSP point (can not use PUSH,in ISR,SP is MSP ) - " STMDB R0!,{R4-R11} \n" // Store r4-r11,r0 -= regCnt * 4,r0 is new stack - // top point (addr h->l r11,r10,...,r5,r4) -#if CFG_CHIP_TYPE == 3 - " VSTMDB R0!, {S16-S31} \n" // store remaining FPU registers -#endif // CFG_FPU_ENABLE - - " STR R0,[R1] \n" // Save orig PSP - - " STR R2, [R3] \n" // TCBRunning = TCBNext; - " LDR R0, [R2] \n" // Get SP of task that be switch into. - -#if CFG_CHIP_TYPE == 3 - " VLDMIA R0!, {S16-S31} \n" // load remaining FPU registers -#endif // CFG_FPU_ENABLE - - " LDMIA R0!,{R4-R11} \n" // POP {R4-R11},R0 += regCnt * 4 - " MSR PSP, R0 \n" // Mov new stack point to PSP - - " exitPendSV: \n" - " LDR R3,=OSSchedLock\n" - " MOVS R0, #0x0 \n" - " STRB R0, [R3] \n" - " ORR LR,LR,#0x04 \n" // Ensure exception return uses process stack -#if CFG_CHIP_TYPE == 3 - " LDR LR,=0xFFFFFFED \n" -#endif - " BX LR \n" // Exit interrupt - ); -} -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/queue.c b/GD32F1/libraries/MapleCoOS116/utility/queue.c deleted file mode 100644 index b8663be..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/queue.c +++ /dev/null @@ -1,432 +0,0 @@ -/** - ******************************************************************************* - * @file queue.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Queue management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - -/*---------------------------- Include ---------------------------------------*/ -#include - - -#if CFG_QUEUE_EN > 0 -/*---------------------------- Variable Define -------------------------------*/ -QCB QueueTbl[CFG_MAX_QUEUE] = {{0}}; /*!< Queue control block table */ -U32 QueueIDVessel = 0; /*!< Queue list mask */ - - - -/** - ******************************************************************************* - * @brief Create a queue - * @param[in] qStart Pointer to mail pointer buffer. - * @param[in] size The length of queue. - * @param[in] sortType Mail queue waiting list sort type. - * @param[out] None - * @retval E_CREATE_FAIL Create queue fail. - * @retval others Create queue successful. - * - * @par Description - * @details This function is called to create a queue. - * @note - ******************************************************************************* - */ -OS_EventID CoCreateQueue(void **qStart, U16 size ,U8 sortType) -{ - U8 i; - P_ECB pecb; - -#if CFG_PAR_CHECKOUT_EN >0 - if((qStart == Co_NULL) || (size == 0)) - { - return E_CREATE_FAIL; - } -#endif - - OsSchedLock(); - for(i = 0; i < CFG_MAX_QUEUE; i++) - { - /* Assign a free QUEUE control block */ - if((QueueIDVessel & (1 << i)) == 0) - { - QueueIDVessel |= (1<id); - } - } - - OsSchedUnlock(); - return E_CREATE_FAIL; /* There is no free QUEUE control block */ -} - - -/** - ******************************************************************************* - * @brief Delete a queue - * @param[in] id Event ID. - * @param[in] opt Delete option. - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_INVALID_PARAMETER Invalid parameter. - * @retval E_TASK_WAITTING Tasks waitting for the event,delete fail. - * @retval E_OK Event deleted successful. - * - * @par Description - * @details This function is called to delete a queue. - * @note - ******************************************************************************* - */ -StatusType CoDelQueue(OS_EventID id,U8 opt) -{ - P_ECB pecb; - P_QCB pqcb; - StatusType err; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; /* Invalid id,return error */ - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if( pecb->eventType != EVENT_TYPE_QUEUE) - { - return E_INVALID_ID; /* The event is not queue,return error*/ - } -#endif - pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */ - err = DeleteEvent(pecb,opt); /* Delete the event control block */ - if(err == E_OK) /* If the event block have been deleted */ - { - QueueIDVessel &= ~((U32)(1<<(pqcb->id))); /* Update free queue list */ - pqcb->qStart = Co_NULL; - pqcb->id = 0; - pqcb->head = 0; - pqcb->tail = 0; - pqcb->qMaxSize = 0; - pqcb->qSize = 0; - } - return err; -} - - - -/** - ******************************************************************************* - * @brief Accept a mail from queue - * @param[in] id Event ID. - * @param[out] perr A pointer to error code. - * @retval Co_NULL - * @retval A pointer to mail accepted. - * - * @par Description - * @details This function is called to accept a mail from queue. - * @note - ******************************************************************************* - */ -void* CoAcceptQueueMail(OS_EventID id,StatusType* perr) -{ - P_ECB pecb; - P_QCB pqcb; - void* pmail; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - *perr = E_INVALID_ID; /* Invalid id,return error */ - return Co_NULL; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_QUEUE)/* Invalid event control block type*/ - { - *perr = E_INVALID_ID; - return Co_NULL; - } -#endif - pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */ - OsSchedLock(); - if(pqcb->qSize != 0) /* If there are any messages in the queue */ - { - /* Extract oldest message from the queue */ - pmail = *(pqcb->qStart + pqcb->head); - pqcb->head++; /* Update the queue head */ - pqcb->qSize--; /* Update the number of messages in the queue */ - if(pqcb->head == pqcb->qMaxSize) - { - pqcb->head = 0; - } - OsSchedUnlock(); - *perr = E_OK; - return pmail; /* Return message received */ - } - else /* If there is no message in the queue*/ - { - OsSchedUnlock(); - *perr = E_QUEUE_EMPTY; - return Co_NULL; /* Return Co_NULL */ - } -} - - - -/** - ******************************************************************************* - * @brief Pend for a mail - * @param[in] id Event ID. - * @param[in] timeout The longest time for writting mail. - * @param[out] perr A pointer to error code. - * @retval Co_NULL - * @retval A pointer to mail accept. - * - * @par Description - * @details This function is called to wait for a mail. - * @note - ******************************************************************************* - */ -void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr) -{ - P_ECB pecb; - P_QCB pqcb; - P_OSTCB curTCB; - void* pmail; - if(OSIntNesting > 0) /* If the caller is ISR */ - { - *perr = E_CALL; - return Co_NULL; - } -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - *perr = E_INVALID_ID; /* Invalid event id,return error */ - return Co_NULL; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_QUEUE) /* The event type is not queue */ - { - *perr = E_INVALID_ID; - return Co_NULL; - } -#endif - if(OSSchedLock != 0) /* Judge schedule is locked or not? */ - { - *perr = E_OS_IN_LOCK; /* Schedule is locked,return error */ - return Co_NULL; - } - pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */ - OsSchedLock(); - if(pqcb->qSize != 0) /* If there are any messages in the queue */ - { - /* Extract oldest message from the queue */ - pmail = *(pqcb->qStart + pqcb->head); - pqcb->head++; /* Update the queue head */ - pqcb->qSize--; /* Update the number of messages in the queue */ - if(pqcb->head == pqcb->qMaxSize)/* Check queue head */ - { - pqcb->head = 0; - } - OsSchedUnlock(); - *perr = E_OK; - return pmail; /* Return message received */ - } - else /* If there is no message in the queue*/ - { - OsSchedUnlock(); - curTCB = TCBRunning; - if(timeout == 0) /* If time-out is not configured */ - { - /* Block current task until the event occur */ - EventTaskToWait(pecb,curTCB); - - /* Have recived message or the queue have been deleted */ - OsSchedLock(); - pmail = curTCB->pmail; - curTCB->pmail = Co_NULL; - pqcb->head++; /* Clear event sign */ - pqcb->qSize--; - if(pqcb->head == pqcb->qMaxSize) - { - pqcb->head = 0; - } - OsSchedUnlock(); - *perr = E_OK; - return pmail; /* Return message received or Co_NULL */ - } - else /* If time-out is configured */ - { - OsSchedLock(); - - /* Block current task until event or timeout occurs */ - EventTaskToWait(pecb,curTCB); - InsertDelayList(curTCB,timeout); - OsSchedUnlock(); - if(curTCB->pmail == Co_NULL) /* If time-out occurred */ - { - *perr = E_TIMEOUT; - return Co_NULL; - } - else /* If event occured */ - { - OsSchedLock(); - pmail = curTCB->pmail; - curTCB->pmail = Co_NULL; - pqcb->head++; /* Clear event sign */ - pqcb->qSize--; - if(pqcb->head == pqcb->qMaxSize) - { - pqcb->head = 0; - } - OsSchedUnlock(); - *perr = E_OK; - return pmail; /* Return message received or Co_NULL */ - } - } - } -} - - - -/** - ******************************************************************************* - * @brief Post a mail to queue - * @param[in] id Event ID. - * @param[in] pmail Pointer to mail that want to send. - * @param[out] None - * @retval E_OK - * @retval E_INVALID_ID - * @retval E_QUEUE_FULL - * - * @par Description - * @details This function is called to post a mail to queue. - * @note - ******************************************************************************* - */ -StatusType CoPostQueueMail(OS_EventID id,void* pmail) -{ - P_ECB pecb; - P_QCB pqcb; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_QUEUE) - { - return E_INVALID_ID; /* The event type isn't queue,return */ - } -#endif - pqcb = (P_QCB)pecb->eventPtr; - if(pqcb->qSize == pqcb->qMaxSize) /* If queue is full */ - { - return E_QUEUE_FULL; - } - else /* If queue is not full */ - { - OsSchedLock(); - *(pqcb->qStart + pqcb->tail) = pmail; /* Insert message into queue */ - pqcb->tail++; /* Update queue tail */ - pqcb->qSize++; /* Update the number of messages in the queue */ - if(pqcb->tail == pqcb->qMaxSize) /* Check queue tail */ - { - pqcb->tail = 0; - } - EventTaskToRdy(pecb); /* Check the event waiting list */ - OsSchedUnlock(); - return E_OK; - } -} - - -/** - ******************************************************************************* - * @brief Post a mail to queue in ISR - * @param[in] id Event ID. - * @param[in] pmail Pointer to mail that want to send. - * @param[out] None - * @retval E_OK - * @retval E_INVALID_ID - * @retval E_QUEUE_FULL - * - * @par Description - * @details This function is called in ISR to post a mail to queue. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -StatusType isr_PostQueueMail(OS_EventID id,void* pmail) -{ - if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ - { - /* Insert the request into service request queue */ - if(InsertInSRQ(QUEUE_REQ,id,pmail) == Co_FALSE) - { - return E_SEV_REQ_FULL; /* If service request queue is full */ - } - else /* If the request have been inserted into service request queue */ - { - return E_OK; - } - } - else /* The scheduler is unlocked */ - { - return(CoPostQueueMail(id,pmail)); /* Send the message to the queue*/ - } -} -#endif - -#endif \ No newline at end of file diff --git a/GD32F1/libraries/MapleCoOS116/utility/sem.c b/GD32F1/libraries/MapleCoOS116/utility/sem.c deleted file mode 100644 index d8893f8..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/sem.c +++ /dev/null @@ -1,347 +0,0 @@ -/** - ******************************************************************************* - * @file sem.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Semaphore management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if CFG_SEM_EN >0 - -/** - ******************************************************************************* - * @brief Create a semaphore - * @param[in] initCnt Semaphore valid counter. - * @param[in] maxCnt Semaphore max initialize counter. - * @param[in] sortType Semaphore sort type. - * @param[out] None - * @retval E_CREATE_FAIL Create semaphore fail. - * @retval others Create semaphore successful. - * - * @par Description - * @details This function is called to create a semaphore. - ******************************************************************************* - */ -OS_EventID CoCreateSem(U16 initCnt,U16 maxCnt,U8 sortType) -{ - P_ECB pecb; -#if CFG_PAR_CHECKOUT_EN >0 - if(initCnt > maxCnt) - { - return E_CREATE_FAIL; /* Invalid 'initCnt' or 'maxCnt' */ - } - - if ((sortType != EVENT_SORT_TYPE_FIFO) && (sortType != EVENT_SORT_TYPE_PRIO)) - { - return E_CREATE_FAIL; /* Illegal sort type,return error */ - } -#endif - - /* Create a semaphore type event control block */ - pecb = CreatEvent(EVENT_TYPE_SEM,sortType,Co_NULL); - if(pecb == Co_NULL) /* If failed to create event block */ - { - return E_CREATE_FAIL; - } - pecb->eventCounter = initCnt;/* Initialize event block */ - pecb->initialEventCounter = maxCnt; - return (pecb->id); /* Return event id */ -} - - -/** - ******************************************************************************* - * @brief Delete a semaphore - * @param[in] id Event ID which to be deleted. - * @param[in] opt Delete option. - * @arg == OPT_DEL_ANYWAY Delete semaphore always - * @arg == OPT_DEL_NO_PEND Delete semaphore only when no task pending on. - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_INVALID_PARAMETER Invalid parameter. - * @retval E_TASK_WAITTING Tasks waitting for the event,delete fail. - * @retval E_OK Event deleted successful. - * - * @par Description - * @details This function is called to delete a semaphore. - * - * @note - ******************************************************************************* - */ -StatusType CoDelSem(OS_EventID id,U8 opt) -{ - P_ECB pecb; - -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; - -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_SEM) - { - return E_INVALID_ID; /* The event type is not semaphore */ - } -#endif - - return (DeleteEvent(pecb,opt));/* Delete the semaphore event control block*/ -} - - -/** - ******************************************************************************* - * @brief Accept a semaphore without waitting - * @param[in] id Event ID - * @param[out] None - * @retval E_INVALID_ID Invalid event ID. - * @retval E_SEM_EMPTY No semaphore exist. - * @retval E_OK Get semaphore successful. - * - * @par Description - * @details This function is called accept a semaphore without waitting. - ******************************************************************************* - */ -StatusType CoAcceptSem(OS_EventID id) -{ - P_ECB pecb; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if( pecb->eventType != EVENT_TYPE_SEM) - { - return E_INVALID_ID; - } -#endif - OsSchedLock(); - if(pecb->eventCounter > 0) /* If semaphore is positive,resource available */ - { - pecb->eventCounter--; /* Decrement semaphore only if positive */ - OsSchedUnlock(); - return E_OK; - } - else /* Resource is not available */ - { - OsSchedUnlock(); - return E_SEM_EMPTY; - } -} - - -/** - ******************************************************************************* - * @brief wait for a semaphore - * @param[in] id Event ID. - * @param[in] timeout The longest time for writting semaphore. - * @para 0 - * @para 0x1~0xff - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_INVALID_ID Invalid event ID. - * @retval E_TIMEOUT Semaphore was not received within the specified - * 'timeout' time. - * @retval E_OK The call was successful and your task owns the - * resource,or the event you are waiting for occurred. - * - * @par Description - * @details This function is called to waits for a semaphore. - * @note IF this function is called in ISR,nothing to do and return immediately. - ******************************************************************************* - */ -StatusType CoPendSem(OS_EventID id,U32 timeout) -{ - P_ECB pecb; - P_OSTCB curTCB; - if(OSIntNesting > 0) /* If the caller is ISR */ - { - return E_CALL; - } -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_SEM) - { - return E_INVALID_ID; - } -#endif - if(OSSchedLock != 0) /* Schdule is locked? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - OsSchedLock(); - if(pecb->eventCounter > 0) /* If semaphore is positive,resource available */ - { - pecb->eventCounter--; /* Decrement semaphore only if positive */ - OsSchedUnlock(); - return E_OK; - } - else /* Resource is not available */ - { - curTCB = TCBRunning; - if(timeout == 0) /* If time-out is not configured */ - { - EventTaskToWait(pecb,curTCB); /* Block task until event occurs */ - pecb->eventCounter--; - curTCB->pmail = Co_NULL; - OsSchedUnlock(); - return E_OK; - } - else /* If time-out is configured */ - { - /* Block task until event or timeout occurs */ - EventTaskToWait(pecb,curTCB); - InsertDelayList(curTCB,timeout); - - OsSchedUnlock(); - if (curTCB->pmail == Co_NULL) /* If pmail is Co_NULL, time-out occurred*/ - { - return E_TIMEOUT; - } - else /* Event occurred or event have been deleted*/ - { - OsSchedLock(); - curTCB->pmail = Co_NULL; - pecb->eventCounter--; - OsSchedUnlock(); - return E_OK; - } - } - } -} - - -/** - ******************************************************************************* - * @brief Post a semaphore - * @param[in] id id of event control block associated with the desired semaphore. - * @param[out] None - * @retval E_INVALID_ID Parameter id passed was invalid event ID. - * @retval E_SEM_FULL Semaphore full. - * @retval E_OK Semaphore had post successful. - * - * @par Description - * @details This function is called to post a semaphore to corresponding event. - * - * @note - ******************************************************************************* - */ -StatusType CoPostSem(OS_EventID id) -{ - P_ECB pecb; -#if CFG_PAR_CHECKOUT_EN >0 - if(id >= CFG_MAX_EVENT) - { - return E_INVALID_ID; - } -#endif - - pecb = &EventTbl[id]; -#if CFG_PAR_CHECKOUT_EN >0 - if(pecb->eventType != EVENT_TYPE_SEM) /* Invalid event control block type */ - { - return E_INVALID_ID; - } -#endif - - /* Make sure semaphore will not overflow */ - if(pecb->eventCounter == pecb->initialEventCounter) - { - return E_SEM_FULL; /* The counter of Semaphore reach the max number*/ - } - OsSchedLock(); - pecb->eventCounter++; /* Increment semaphore count to register event */ - EventTaskToRdy(pecb); /* Check semaphore event waiting list */ - OsSchedUnlock(); - return E_OK; - -} - - -/** - ******************************************************************************* - * @brief Post a semaphore in ISR - * @param[in] id identifier of event control block associated with the - * desired semaphore. - * @param[out] None - * @retval E_INVALID_ID Parameter id passed was invalid event ID. - * @retval E_NO_TASK_WAITTING There are one more tasks waitting for the event. - * @retval E_OK Semaphore had signaled successful. - * - * @par Description - * @details This function is called in ISR to post a semaphore to corresponding - * event. - * @note - ******************************************************************************* - */ -#if CFG_MAX_SERVICE_REQUEST > 0 -StatusType isr_PostSem(OS_EventID id) -{ - if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ - { - /* Initiate a post service handling request */ - if(InsertInSRQ(SEM_REQ,id,Co_NULL) == Co_FALSE) - { - return E_SEV_REQ_FULL; /* If service request queue is full */ - } - else /* Operate successfully */ - { - return E_OK; - } - } - else - { - return(CoPostSem(id)); /* Post semaphore */ - } -} -#endif - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/serviceReq.c b/GD32F1/libraries/MapleCoOS116/utility/serviceReq.c deleted file mode 100644 index 2a4cc5c..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/serviceReq.c +++ /dev/null @@ -1,188 +0,0 @@ -/** - ******************************************************************************* - * @file serviceReq.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief servive request management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if (CFG_TASK_WAITTING_EN > 0) || (CFG_TMR_EN >0) - -#if CFG_MAX_SERVICE_REQUEST > 0 -/*---------------------------- Variable Define -------------------------------*/ -SRQ ServiceReq = {0,0}; /*!< ISR server request queue */ -#endif -BOOL IsrReq = Co_FALSE; -#if (CFG_TASK_WAITTING_EN > 0) -BOOL TimeReq = Co_FALSE; /*!< Time delay dispose request */ -#endif - -#if CFG_TMR_EN > 0 -BOOL TimerReq = Co_FALSE; /*!< Timer dispose request */ -#endif - -/** - ******************************************************************************* - * @brief Insert into service requst queue - * @param[in] type Service request type. - * @param[in] id Service request event id,event id/flag id. - * @param[in] arg Service request argument. - * @param[out] None - * - * @retval Co_FALSE Successfully insert into service request queue. - * @retval Co_TRUE Failure to insert into service request queue. - * - * @par Description - * @details This function be called to insert a requst into service request - * queue. - * @note - ******************************************************************************* - */ -#if (CFG_MAX_SERVICE_REQUEST > 0) -BOOL InsertInSRQ(U8 type,U8 id,void* arg) -{ - P_SQC pcell; - U8 cnt; - U8 heed; - IRQ_DISABLE_SAVE(); - if (ServiceReq.cnt >= CFG_MAX_SERVICE_REQUEST) - { - IRQ_ENABLE_RESTORE (); - - return Co_FALSE; /* Error return */ - } - cnt = Inc8(&ServiceReq.cnt); - heed = ServiceReq.head; - IsrReq = Co_TRUE; - pcell = &ServiceReq.cell[((cnt+heed)%CFG_MAX_SERVICE_REQUEST)];/*the tail */ - pcell->type = type; /* Save service request type, */ - pcell->id = id; /* event id */ - pcell->arg = arg; /* and parameter */ - IRQ_ENABLE_RESTORE (); - - return Co_TRUE; /* Return OK */ -} -#endif - - - -/** - ******************************************************************************* - * @brief Respond the request in the service request queue. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function be called to respond the request in the service - * request queue. - * @note - ******************************************************************************* - */ -void RespondSRQ(void) -{ - -#if CFG_MAX_SERVICE_REQUEST > 0 - SQC cell; - -#endif - -#if (CFG_TASK_WAITTING_EN > 0) - if(TimeReq == Co_TRUE) /* Time delay request? */ - { - TimeDispose(); /* Yes,call handler */ - TimeReq = Co_FALSE; /* Reset time delay request Co_FALSE */ - } -#endif -#if CFG_TMR_EN > 0 - if(TimerReq == Co_TRUE) /* Timer request? */ - { - TmrDispose(); /* Yes,call handler */ - TimerReq = Co_FALSE; /* Reset timer request Co_FALSE */ - } -#endif - -#if CFG_MAX_SERVICE_REQUEST > 0 - - while (ServiceReq.cnt != 0) - { - IRQ_DISABLE_SAVE (); /* need to protect the following */ - cell = ServiceReq.cell[ServiceReq.head]; /* extract one cell */ - ServiceReq.head = (ServiceReq.head + 1) % /* move head (pop) */ - CFG_MAX_SERVICE_REQUEST; - ServiceReq.cnt--; - IRQ_ENABLE_RESTORE (); /* now use the cell copy */ - - switch(cell.type) /* Judge service request type */ - { -#if CFG_SEM_EN > 0 - case SEM_REQ: /* Semaphore post request,call handler*/ - CoPostSem(cell.id); - break; -#endif -#if CFG_MAILBOX_EN > 0 - case MBOX_REQ: /* Mailbox post request,call handler */ - CoPostMail(cell.id, cell.arg); - break; -#endif -#if CFG_FLAG_EN > 0 - case FLAG_REQ: /* Flag set request,call handler */ - CoSetFlag(cell.id); - break; -#endif -#if CFG_QUEUE_EN > 0 - case QUEUE_REQ: /* Queue post request,call handler */ - CoPostQueueMail(cell.id, cell.arg); - break; -#endif - default: /* Others,break */ - break; - } - } -#endif - IRQ_DISABLE_SAVE (); /* need to protect the following */ - - if (ServiceReq.cnt == 0) /* another item in the queue already? */ - { - IsrReq = Co_FALSE; /* queue still empty here */ - } - IRQ_ENABLE_RESTORE (); /* now it is done and return */ -} - -#endif - diff --git a/GD32F1/libraries/MapleCoOS116/utility/task.c b/GD32F1/libraries/MapleCoOS116/utility/task.c deleted file mode 100644 index c8db6e7..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/task.c +++ /dev/null @@ -1,1299 +0,0 @@ -/** - ******************************************************************************* - * @file task.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief task management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - -/*---------------------------- Variable Define -------------------------------*/ - -/*!< Table use to save TCB pointer. */ -OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {{0}}; - -/*!< The stack of IDLE task. */ -OS_STK idle_stk[CFG_IDLE_STACK_SIZE] = {0}; - -P_OSTCB FreeTCB = Co_NULL; /*!< pointer to free TCB */ -P_OSTCB TCBRdy = Co_NULL; /*!< Pointer to the READY list. */ -P_OSTCB TCBNext = Co_NULL; /*!< Poniter to task that next scheduled by OS */ -P_OSTCB TCBRunning = Co_NULL; /*!< Pointer to TCB that current running task. */ -U64 OSCheckTime = 0; /*!< The counter of system tick. */ - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 -OS_TID PriNum; -U8 ActivePri[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; -U8 TaskNumPerPri[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; -OS_TID RdyTaskPri[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {0}; -U32 RdyTaskPriInfo[(CFG_MAX_USER_TASKS+SYS_TASK_NUM+31)/32]; -#endif - - -/** - ******************************************************************************* - * @brief Create a TCB list. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called by CoOSInit() to initial the empty list - * of OS_TCBS,supply a pointer to free TCB. - ******************************************************************************* - */ -void CreateTCBList(void) -{ - U8 i; - P_OSTCB ptcb1,ptcb2; - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - PriNum = 0; -#endif - - ptcb1 = &TCBTbl[0]; /* Build the free TCB list */ - ptcb2 = &TCBTbl[1]; - for(i=0;i< (CFG_MAX_USER_TASKS+SYS_TASK_NUM-1);i++ ) - { - ptcb1->taskID = i; - ptcb1->state = TASK_DORMANT; - ptcb1->TCBnext = ptcb2; -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - RdyTaskPri[i] = INVALID_ID; - ActivePri[i] = INVALID_ID; -#endif - ptcb1++; - ptcb2++; - } -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - ActivePri[i] = INVALID_ID; -#endif - - ptcb1->taskID = i; - ptcb1->TCBnext = Co_NULL; - FreeTCB = &TCBTbl[0]; /* Initialize FreeTCB as head item of list */ -} - - - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - -/** - ******************************************************************************* - * @brief Get sequence number for Assign priority - * @param[in] pri Assign priority - * @param[out] SequenceNum priority number - * @retval Co_TRUE Assign priority in priority queue. - * Co_FALSE Assign priority not in priority queue. - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to get sequence number for Assign priority. - ******************************************************************************* - */ -static BOOL GetPriSeqNum(U8 pri,OS_TID* SequenceNum) -{ - OS_TID seqNum; - OS_TID num,tmpNum; - num = 0; - seqNum = PriNum; - while(num != seqNum) - { - tmpNum = num; - num = (num+seqNum)/2; - if(pri == ActivePri[num]) - { - *SequenceNum = num; - return Co_TRUE; - } - else if (pri < ActivePri[num]) - { - seqNum = num; - num = tmpNum; - } - else - { - num++; - } - } - *SequenceNum = num; - return Co_FALSE; -} - - -/** - ******************************************************************************* - * @brief Get the nearest ready priority sequence number for Assign number - * @param[in] seqNum Assign sequence number - * @param[out] None - * @retval INVALID_ID Cannot find higher ready priority. - * Others Nearest ready priority sequence number - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to get the nearest ready priority sequence number. - ******************************************************************************* - */ -static U8 GetRdyPriSeqNum(U8 seqNum) -{ - U32 tmp; - U8 i,j,num; - S8 cnt; - i = seqNum/32; - j = seqNum%32; - - do - { - tmp = RdyTaskPriInfo[i]; - if(tmp != 0) - { - num = j/8; - do - { - if((tmp&(0xff<<(num*8))) !=0 ) - { - if((tmp&(0xf0<<(num*8))) !=0) - { - for(cnt=j; cnt >=(num*8+4); cnt--) - { - if( (tmp&(1<=num*8; cnt--) - { - if( (tmp&(1<seqNum;num--) - { - ActivePri[num] = ActivePri[num-1]; - TaskNumPerPri[num] = TaskNumPerPri[num-1]; - RdyTaskPri[num] = RdyTaskPri[num-1]; - } - ActivePri[seqNum] = pri; - TaskNumPerPri[seqNum] = 1; - RdyTaskPri[seqNum] = INVALID_ID; - PriNum++; - PrioRemap(seqNum); - } - else - { - TaskNumPerPri[seqNum]++; - } -} - - - -/** - ******************************************************************************* - * @brief Delete priority in queue - * @param[in] pri Task priority - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to decrease the task num for this priority, if the num goto 0, - * remove the priority for queue. - ******************************************************************************* - */ -void DeleteTaskPri(U8 pri) -{ - OS_TID seqNum,num; - - GetPriSeqNum(pri,&seqNum); - TaskNumPerPri[seqNum]--; - if(TaskNumPerPri[seqNum]==0) - { - for(num=seqNum; num<(PriNum-1); num++) - { - ActivePri[num] = ActivePri[num+1]; - TaskNumPerPri[num] = TaskNumPerPri[num+1]; - RdyTaskPri[num] = RdyTaskPri[num+1]; - } - PriNum--; - PrioRemap(seqNum); - } -} - -#endif - - -/** - ******************************************************************************* - * @brief Insert a task to the ready list - * @param[in] tcbInsert A pointer to task will be inserted. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to insert a task to the READY list. - ******************************************************************************* - */ -void InsertToTCBRdyList(P_OSTCB tcbInsert) -{ - P_OSTCB ptcbNext,ptcb; - U8 prio; -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - U8 seqNum; - U8 RdyTaskSeqNum; -#endif - - prio = tcbInsert->prio; /* Get PRI of inserted task */ - tcbInsert->state = TASK_READY; /* Set task as TASK_READY */ - -#if CFG_ROBIN_EN >0 - ptcb = TCBRunning; - /* Set schedule time for the same PRI task as TCBRunning. */ - if(prio == ptcb->prio) /* Is PRI of inserted task equal to running task? */ - { - if(ptcb != tcbInsert) /* Yes,is inserted task equal to running task? */ - { - if(ptcb != Co_NULL) /* No,TCBRunning == Co_NULL? */ - { /* N0,OSCheckTime < OSTickCnt? */ - if(OSCheckTime < OSTickCnt) - { /* Yes,set OSCheckTime for task robin */ - OSCheckTime = OSTickCnt + ptcb->timeSlice; - } - } - } - } -#endif - - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - GetPriSeqNum(prio,&seqNum); - if(GetPrioSeqNumStatus(seqNum) == Co_TRUE) - { - ptcb = &TCBTbl[RdyTaskPri[seqNum]]; - RdyTaskPri[seqNum] = tcbInsert->taskID; - } - else - { - RdyTaskPri[seqNum] = tcbInsert->taskID; - RdyTaskSeqNum = GetRdyPriSeqNum(seqNum); - SetPrioSeqNumStatus(seqNum, 1); - if(RdyTaskSeqNum == INVALID_ID) - { - ptcb = TCBRdy; - TaskSchedReq = Co_TRUE; - if(ptcb == Co_NULL) - { - TCBRdy = tcbInsert; - } - else - { - tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */ - ptcb->TCBprev = tcbInsert; - TCBRdy = tcbInsert; - } - return; - } - else - { - ptcb = &TCBTbl[RdyTaskPri[RdyTaskSeqNum]]; - } - } - - ptcbNext = ptcb->TCBnext; - tcbInsert->TCBnext = ptcbNext; /* Set link for list */ - ptcb->TCBnext = tcbInsert; - tcbInsert->TCBprev = ptcb; - if(ptcbNext != Co_NULL) - { - ptcbNext->TCBprev = tcbInsert; - } - - -#else - ptcb = TCBRdy; - if (ptcb == Co_NULL) /* Is ready list Co_NULL? */ - { - TaskSchedReq = Co_TRUE; - TCBRdy = tcbInsert; /* Yse,set tcbInsert as head item of list */ - } - else if (prio < ptcb->prio)/* Is PRI of inserted task higher than TCBRdy? */ - { - TaskSchedReq = Co_TRUE; - tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */ - ptcb->TCBprev = tcbInsert; - TCBRdy = tcbInsert; - } - else /* No,find correct place */ - { - ptcbNext = ptcb->TCBnext; /* Get next item */ - while(ptcbNext != Co_NULL) /* Is last item in ready list? */ - { /* No,find correct place */ - if(prio < ptcbNext->prio) /* Is correct place? */ - break; /* Yes,break circulation */ - ptcb = ptcbNext; /* Save current item */ - ptcbNext = ptcbNext->TCBnext; /* Get next item */ - } - tcbInsert->TCBnext = ptcbNext; /* Set link for list */ - ptcb->TCBnext = tcbInsert; - tcbInsert->TCBprev = ptcb; - if(ptcbNext != Co_NULL) - { - ptcbNext->TCBprev = tcbInsert; - } - } -#endif -} - - - -/** - ******************************************************************************* - * @brief Remove a task from the READY list - * @param[in] ptcb A pointer to task which be removed. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a task from the READY list. - ******************************************************************************* - */ -void RemoveFromTCBRdyList(P_OSTCB ptcb) -{ - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - U8 prio; - U8 seqNum; - BOOL isChange; - isChange = Co_FALSE; - prio = ptcb->prio; - GetPriSeqNum(prio,&seqNum); -#endif - - /* Is there only one item in READY list? */ - if((ptcb->TCBnext == Co_NULL) && (ptcb->TCBprev == Co_NULL) ) - { - TCBRdy = Co_NULL; /* Yes,set READY list as Co_NULL */ -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - isChange = Co_TRUE; -#endif - } - else if(ptcb->TCBprev == Co_NULL) /* Is the first item in READY list? */ - { - /* Yes,remove task from the list,and reset the head of READY list */ - TCBRdy = ptcb->TCBnext; - ptcb->TCBnext = Co_NULL; - TCBRdy->TCBprev = Co_NULL; -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(TCBRdy->prio != prio) - isChange = Co_TRUE; - -#endif - } - else if( ptcb->TCBnext == Co_NULL) /* Is the last item in READY list? */ - { /* Yes,remove task from list */ -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(ptcb->TCBprev->prio != prio) - isChange = Co_TRUE; - else - RdyTaskPri[seqNum] = ptcb->TCBprev->taskID; -#endif - ptcb->TCBprev->TCBnext = Co_NULL; - ptcb->TCBprev = Co_NULL; - } - else /* No, remove task from list */ - { -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if((ptcb->TCBprev->prio != prio) && (ptcb->TCBnext->prio != prio)) - isChange = Co_TRUE; - else if((ptcb->TCBprev->prio == prio) && (ptcb->TCBnext->prio != prio)) - RdyTaskPri[seqNum] = ptcb->TCBprev->taskID; -#endif - ptcb->TCBprev->TCBnext = ptcb->TCBnext; - ptcb->TCBnext->TCBprev = ptcb->TCBprev; - ptcb->TCBnext = Co_NULL; - ptcb->TCBprev = Co_NULL; - } -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(isChange == Co_TRUE) - { - RdyTaskPri[seqNum] = INVALID_ID; - SetPrioSeqNumStatus(seqNum, 0); - } -#endif -} - - -#if CFG_MUTEX_EN > 0 -#define CFG_PRIORITY_SET_EN (1) -#endif -#if CFG_PRIORITY_SET_EN >0 -/** - ******************************************************************************* - * @brief Change task priority - * @param[in] taskID Specify task id. - * @param[in] priority New priority. - * @param[out] None - * @retval E_OK Change priority successful. - * @retval E_INVALID_ID Invalid id,change priority fail. - * @retval E_PROTECTED_TASK Can't change idle task priority. - * - * @par Description - * @details This function is called to change priority for a specify task. - ******************************************************************************* - */ -StatusType CoSetPriority(OS_TID taskID,U8 priority) -{ - P_OSTCB ptcb; -#if CFG_MUTEX_EN >0 - U8 prio; - P_MUTEX pMutex; -#endif -#if CFG_EVENT_EN >0 - P_ECB pecb; -#endif - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; /* Get TCB of task ID */ -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } - if(priority > CFG_LOWEST_PRIO) - { - return E_INVALID_ID; - } -#endif - - if(ptcb->prio != priority) /* Is PRI equal to original PRI? */ - { /* No */ -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) - { - pMutex = &MutexTbl[ptcb->mutexID]; - if(pMutex->taskID == ptcb->taskID) /* Task hold mutex? */ - { - pMutex->originalPrio= priority;/* Yes,change original PRI in mutex*/ - if(ptcb->prio < priority) /* Is task priority higher than set?*/ - { - return E_OK; /* Yes,do nothing,return OK */ - } - } - } - -#endif - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - DeleteTaskPri(ptcb->prio); - ActiveTaskPri(priority); -#endif - - ptcb->prio = priority; /* Change task PRI */ - if(ptcb->state == TASK_READY) /* Is task in READY list? */ - { - OsSchedLock(); /* Yes,reorder task in READY list */ - RemoveFromTCBRdyList(ptcb); - InsertToTCBRdyList(ptcb); - OsSchedUnlock(); - } - else if(ptcb->state == TASK_RUNNING)/* Is task running? */ - { - if(ptcb->prio > TCBRdy->prio) /* Yes,Is PRI higher than TCBRdy? */ - { - OsSchedLock(); /* Yes,reorder task in READY list */ - TaskSchedReq = Co_TRUE; - OsSchedUnlock(); - } - } - else - { /* No,task in WAITING list */ -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex WAITING list? */ - { - /* Yes,reset the highest PRI in the list */ - OsSchedLock(); - pMutex = &MutexTbl[ptcb->mutexID]; - ptcb = pMutex->waittingList; - prio = pMutex->originalPrio; - pMutex->hipriTaskID = pMutex->taskID; - while(ptcb != Co_NULL) - { - if(ptcb->prio < prio) - { - prio = ptcb->prio; - pMutex->hipriTaskID = ptcb->taskID; - } - ptcb = ptcb->TCBnext; - } - OsSchedUnlock(); - if(pMutex->originalPrio != prio) - { - CoSetPriority(pMutex->taskID,prio); - } - } -#endif - -#if CFG_EVENT_EN >0 - ptcb = &TCBTbl[taskID]; - if(ptcb->eventID != INVALID_ID) /* Is task in event WAITING list? */ - { - pecb = &EventTbl[ptcb->eventID]; - - /* Yes,is event sort type as preemptive PRI? */ - if(pecb->eventSortType == EVENT_SORT_TYPE_PRIO) - { - /* Yes,reorder task in the list */ - RemoveEventWaittingList(ptcb); - EventTaskToWait(pecb,ptcb); - } - } -#endif - } - } - return E_OK; -} -#endif - -/** - ******************************************************************************* - * @brief Schedule function - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called by every where need to switch context, - * It is schedule function of OS kernel. - * Modified as per Marlo to add yield. - ******************************************************************************* - */ -static inline void _schedule(BOOL yield) -{ - U8 RunPrio,RdyPrio; - P_OSTCB pRdyTcb,pCurTcb; - - - pCurTcb = TCBRunning; - pRdyTcb = TCBRdy; - - if((pRdyTcb==Co_NULL) || (pCurTcb != TCBNext) || (OSSchedLock >1) || (OSIntNesting >0)) - { - return; - } - - TaskSchedReq = Co_FALSE; - RunPrio = pCurTcb->prio; - RdyPrio = pRdyTcb->prio; - - /* Is Running task status was changed? */ - if(pCurTcb->state != TASK_RUNNING) - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - pRdyTcb->state = TASK_RUNNING; - RemoveFromTCBRdyList(pRdyTcb); - } - - else if(RdyPrio < RunPrio ) /* Is higher PRI task coming in? */ - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - InsertToTCBRdyList(pCurTcb); - RemoveFromTCBRdyList(pRdyTcb); - pRdyTcb->state = TASK_RUNNING; - } - -#if CFG_ROBIN_EN >0 /* Is time for robinning */ - else if ((RunPrio == RdyPrio) && (yield || (OSCheckTime == OSTickCnt))) -#else /* simple yield */ - else if ((RunPrio == RdyPrio) && yield) -#endif - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - InsertToTCBRdyList(pCurTcb); - RemoveFromTCBRdyList(pRdyTcb); - pRdyTcb->state = TASK_RUNNING; - } - else - { - return; - } - -#if CFG_ROBIN_EN >0 - if(TCBNext->prio == TCBRdy->prio) /* Reset OSCheckTime for task robinnig */ - OSCheckTime = OSTickCnt + TCBNext->timeSlice; -#endif - - -#if CFG_STK_CHECKOUT_EN > 0 /* Is stack overflow? */ - if((pCurTcb->stkPtr < pCurTcb->stack)||(*(U32*)(pCurTcb->stack) != MAGIC_WORD)) - { - CoStkOverflowHook(pCurTcb->taskID); /* Yes,call handler */ - } -#endif - - SwitchContext(); /* Call task context switch */ -} - -void Schedule(void) -{ - _schedule(Co_FALSE); -} - - -/** - ******************************************************************************* - * @brief Assign a TCB to task being created - * @param[in] None - * @param[out] None - * - * @retval XXXX - * - * @par Description - * @details This function is called to assign a task control block for task - * being created. - ******************************************************************************* - */ -static P_OSTCB AssignTCB(void) -{ - P_OSTCB ptcb; - - OsSchedLock(); /* Lock schedule */ - if(FreeTCB == Co_NULL) /* Is there no free TCB */ - { - OsSchedUnlock(); /* Yes,unlock schedule */ - return Co_NULL; /* Error return */ - } - ptcb = FreeTCB; /* Yes,assgin free TCB for this task */ - /* Set next item as the head of free TCB list */ - FreeTCB = FreeTCB->TCBnext; - OsSchedUnlock(); - return ptcb; -} - - -/** - ******************************************************************************* - * @brief Create a task - * @param[in] task Task code entry. - * @param[in] argv The parameter passed to task. - * @param[in] parameter Task priority + stack size + time slice + isWaitting. - * @param[in] stk Pointer to stack top of task. - * @param[out] None - * @retval E_CREATE_FAIL Fail to create a task . - * @retval others Valid task id. - * - * @par Description - * @details This function is called by application to create a task,return a id - * to mark this task. - ******************************************************************************* - */ -OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk) -{ - OS_STK* stkTopPtr; - P_OSTCB ptcb; - U8 prio; -#if CFG_ROBIN_EN >0 - U16 timeSlice; -#endif - -#if CFG_STK_CHECKOUT_EN >0 /* Check validity of parameter */ - U16 sktSz; - sktSz = (parameter&0xfff00)>>8; -#endif - prio = parameter&0xff; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(task == Co_NULL) - { - return E_CREATE_FAIL; - } - if(stk == Co_NULL) - { - return E_CREATE_FAIL; - } - if(prio > CFG_LOWEST_PRIO) - { - return E_CREATE_FAIL; - } -#if CFG_STK_CHECKOUT_EN >0 - if(sktSz < 20) - { - return E_CREATE_FAIL; - } -#endif // CFG_STK_CHECKOUT_EN -#endif // CFG_PAR_CHECKOUT_EN - -#if CFG_TASK_SCHEDULE_EN == 0 - if(TCBRunning != Co_NULL) - return E_CREATE_FAIL; -#endif - - stkTopPtr = InitTaskContext(task,argv,stk); /* Initialize task context. */ - - ptcb = AssignTCB(); /* Get free TCB to use */ - - if(ptcb == Co_NULL) /* Is free TCB equal to Co_NULL? */ - { - return E_CREATE_FAIL; /* Yes,error return */ - } - - ptcb->stkPtr = stkTopPtr; /* Initialize TCB as user set */ - ptcb->prio = prio; -#if CFG_STK_CHECKOUT_EN >0 - ptcb->stack = stk+1 - sktSz; /* Set bottom stack for stack overflow check */ - *(U32*)(ptcb->stack) = MAGIC_WORD; -#endif - -#if CFG_TASK_WAITTING_EN >0 - ptcb->delayTick = INVALID_VALUE; -#endif - -#if CFG_TASK_SCHEDULE_EN == 0 - ptcb->taskFuc = task; - ptcb->taskStk = stk; -#endif - ptcb->TCBnext = Co_NULL; /* Initialize TCB link in READY list */ - ptcb->TCBprev = Co_NULL; - -#if CFG_ROBIN_EN >0 /* Set task time slice for task robin */ - timeSlice = (parameter&0x7fff0000)>>20; - if(timeSlice == 0) - { - timeSlice = CFG_TIME_SLICE; - } - ptcb->timeSlice = timeSlice; -#endif - -#if CFG_FLAG_EN > 0 - ptcb->pnode = Co_NULL; /* Initialize task as no flag waiting */ -#endif - -#if CFG_EVENT_EN > 0 - ptcb->eventID = INVALID_ID; /* Initialize task as no event waiting*/ - ptcb->pmail = Co_NULL; - ptcb->waitNext = Co_NULL; - ptcb->waitPrev = Co_NULL; -#endif - -#if CFG_MUTEX_EN > 0 - /* Initialize task as no mutex holding or waiting */ - ptcb->mutexID = INVALID_ID; -#endif - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - ActiveTaskPri(prio); -#endif - - if((parameter>>31) == 0) /* Is task in waitting state? */ - { /* No,set it into ready list */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert into the READY list */ - OsSchedUnlock(); /* Unlock schedule */ - } - else - { /* Yes,Set task status as TASK_WAITING*/ - ptcb->state = TASK_WAITING; - } - return ptcb->taskID; /* Return task ID */ -} - - -/** - ******************************************************************************* - * @brief Delete Task - * @param[in] taskID Task ID - * @param[out] None - * @retval E_INVALID_ID Invalid task ID. - * @retval E_PROTECTED_TASK Protected task in OS. - * @retval E_OK Delete successful. - * - * @par Description - * @details This function is called to delete assign task. - ******************************************************************************* - */ -StatusType CoDelTask(OS_TID taskID) -{ - P_OSTCB ptcb; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } - - if(ptcb->state == TASK_RUNNING) /* Is task running? */ - { - if(OSSchedLock != 0) /* Yes,is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - } - -#if CFG_MUTEX_EN >0 /* Do task hold mutex? */ - if(ptcb->mutexID != INVALID_ID) - { - if(MutexTbl[ptcb->mutexID].taskID == ptcb->taskID) - { /* Yes,leave the mutex */ - CoLeaveMutexSection(ptcb->mutexID); - } - } - -#endif - - OsSchedLock(); /* Lock schedule */ - - if(ptcb->state == TASK_READY) /* Is task in READY list? */ - { - RemoveFromTCBRdyList(ptcb); /* Yes,remove task from the READY list*/ - } - -#if CFG_TASK_WAITTING_EN > 0 - else if(ptcb->state == TASK_WAITING)/* Is task in the WAITING list? */ - { - /* Yes,Is task in delay list? */ - if(ptcb->delayTick != INVALID_VALUE) - { - RemoveDelayList(ptcb); /* Yes,remove task from READY list */ - } - -#if CFG_EVENT_EN > 0 - if(ptcb->eventID != INVALID_ID) /* Is task in event waiting list? */ - { - /* Yes,remove task from event waiting list */ - RemoveEventWaittingList(ptcb); - } -#endif - -#if CFG_FLAG_EN > 0 - if(ptcb->pnode != Co_NULL) /* Is task in flag waiting list? */ - { - /* Yes,remove task from flag waiting list */ - RemoveLinkNode(ptcb->pnode); - } -#endif - -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex waiting list? */ - { - RemoveMutexList(ptcb); /* Yes,remove task from mutex waiting list*/ - } -#endif - } -#endif - ptcb->state = TASK_DORMANT; /* Release TCB */ - TaskSchedReq = Co_TRUE; - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - DeleteTaskPri(ptcb->prio); -#endif - -#if CFG_TASK_SCHEDULE_EN >0 - ptcb->TCBnext = FreeTCB; - FreeTCB = ptcb; -#endif - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; /* return OK */ -} - - -/** - ******************************************************************************* - * @brief Exit Task - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to exit current task. - ******************************************************************************* - */ -void CoExitTask(void) -{ - CoDelTask(TCBRunning->taskID); /* Call task delete function */ -} - - -#if CFG_TASK_SCHEDULE_EN ==0 -/** - ******************************************************************************* - * @brief Activate Task - * @param[in] taskID Task ID - * @param[in] argv Task argv - * @param[out] None - * @retval E_INVALID_ID Invalid task ID. - * @retval E_OK Activate task successful. - * - * @par Description - * @details This function is called to activate current task. - ******************************************************************************* - */ -StatusType CoActivateTask(OS_TID taskID,void *argv) -{ - P_OSTCB ptcb; - OS_STK* stkTopPtr; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->stkPtr == Co_NULL) - return E_INVALID_ID; -#endif - if(ptcb->state != TASK_DORMANT) - return E_OK; - - - /* Initialize task context. */ - stkTopPtr = InitTaskContext(ptcb->taskFuc,argv,ptcb->taskStk); - - ptcb->stkPtr = stkTopPtr; /* Initialize TCB as user set */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert into the READY list */ - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; -} -#endif - - -/** - ******************************************************************************* - * @brief Get current task id - * @param[in] None - * @param[out] None - * @retval ID of the current task. - * - * @par Description - * @details This function is called to get current task id. - ******************************************************************************* - */ -OS_TID CoGetCurTaskID(void) -{ - return (TCBRunning->taskID); /* Return running task ID */ -} - -#if CFG_TASK_SUSPEND_EN >0 -/** - ******************************************************************************* - * @brief Suspend Task - * @param[in] taskID ID of task that want to suspend. - * @param[out] None - * @retval E_OK Task suspend successful. - * @retval E_INVALID_ID Invalid event ID. - * @retval E_PROTECTED_TASK Can't suspend idle task. - * @retval E_ALREADY_IN_WAITING Task now in waiting state. - - * - * @par Description - * @details This function is called to exit current task. - ******************************************************************************* - */ -StatusType CoSuspendTask(OS_TID taskID) -{ - P_OSTCB ptcb; - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - if(OSSchedLock != 0) - { - return E_OS_IN_LOCK; - } - if(ptcb->state == TASK_WAITING) /* Is task in WAITING list? */ - { - return E_ALREADY_IN_WAITING; /* Yes,error return */ - } - - OsSchedLock(); - if(ptcb != TCBRunning) /* Is runing task? */ - { - RemoveFromTCBRdyList(ptcb); /* No,Remove task from READY list */ - } - else - { - TaskSchedReq = Co_TRUE; - } - - ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */ - OsSchedUnlock(); /* Call task schedule */ - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Awake Task - * @param[in] taskID ID of task that will been awaked. - * @param[out] None - * @retval E_OK Task awake successful. - * @retval E_INVALID_ID Invalid task ID. - * @retval E_TASK_NOT_WAITING Task now not in waiting state. - * @retval E_TASK_WAIT_OTHER Task now waiting other awake event. - * @retval E_PROTECTED_TASK Idle task mustn't be awaked. - * - * @par Description - * @details This function is called to awake current task. - ******************************************************************************* - */ -StatusType CoAwakeTask(OS_TID taskID) -{ - P_OSTCB ptcb; - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - - if(ptcb->state != TASK_WAITING) /* Is task in WAITING list */ - { - return E_TASK_NOT_WAITING; /* No,error return */ - } - -#if CFG_TASK_WAITTING_EN > 0 - if(ptcb->delayTick != INVALID_VALUE)/* Is task in READY list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } - -#if CFG_FLAG_EN > 0 - if(ptcb->pnode != Co_NULL) /* Is task in flag waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#if CFG_EVENT_EN>0 - if(ptcb->eventID != INVALID_ID) /* Is task in event waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#if CFG_MUTEX_EN > 0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#endif //CFG_TASK_WAITTING_EN - - /* All no,so WAITING state was set by CoSuspendTask() */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert the task into the READY list*/ - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; /* return OK */ -} -#endif -/* -* Added to add yielf function -*/ - -void CoYield(void) -{ - _schedule(Co_TRUE); -} diff --git a/GD32F1/libraries/MapleCoOS116/utility/task.c.original b/GD32F1/libraries/MapleCoOS116/utility/task.c.original deleted file mode 100644 index a1b3655..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/task.c.original +++ /dev/null @@ -1,1283 +0,0 @@ -/** - ******************************************************************************* - * @file task.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief task management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - -/*---------------------------- Variable Define -------------------------------*/ - -/*!< Table use to save TCB pointer. */ -OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {{0}}; - -/*!< The stack of IDLE task. */ -OS_STK idle_stk[CFG_IDLE_STACK_SIZE] = {0}; - -P_OSTCB FreeTCB = Co_NULL; /*!< pointer to free TCB */ -P_OSTCB TCBRdy = Co_NULL; /*!< Pointer to the READY list. */ -P_OSTCB TCBNext = Co_NULL; /*!< Poniter to task that next scheduled by OS */ -P_OSTCB TCBRunning = Co_NULL; /*!< Pointer to TCB that current running task. */ -U64 OSCheckTime = 0; /*!< The counter of system tick. */ - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 -OS_TID PriNum; -U8 ActivePri[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; -U8 TaskNumPerPri[CFG_MAX_USER_TASKS+SYS_TASK_NUM]; -OS_TID RdyTaskPri[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {0}; -U32 RdyTaskPriInfo[(CFG_MAX_USER_TASKS+SYS_TASK_NUM+31)/32]; -#endif - - -/** - ******************************************************************************* - * @brief Create a TCB list. - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called by CoOSInit() to initial the empty list - * of OS_TCBS,supply a pointer to free TCB. - ******************************************************************************* - */ -void CreateTCBList(void) -{ - U8 i; - P_OSTCB ptcb1,ptcb2; - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - PriNum = 0; -#endif - - ptcb1 = &TCBTbl[0]; /* Build the free TCB list */ - ptcb2 = &TCBTbl[1]; - for(i=0;i< (CFG_MAX_USER_TASKS+SYS_TASK_NUM-1);i++ ) - { - ptcb1->taskID = i; - ptcb1->state = TASK_DORMANT; - ptcb1->TCBnext = ptcb2; -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - RdyTaskPri[i] = INVALID_ID; - ActivePri[i] = INVALID_ID; -#endif - ptcb1++; - ptcb2++; - } -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - ActivePri[i] = INVALID_ID; -#endif - - ptcb1->taskID = i; - ptcb1->TCBnext = Co_NULL; - FreeTCB = &TCBTbl[0]; /* Initialize FreeTCB as head item of list */ -} - - - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - -/** - ******************************************************************************* - * @brief Get sequence number for Assign priority - * @param[in] pri Assign priority - * @param[out] SequenceNum priority number - * @retval Co_TRUE Assign priority in priority queue. - * Co_FALSE Assign priority not in priority queue. - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to get sequence number for Assign priority. - ******************************************************************************* - */ -static BOOL GetPriSeqNum(U8 pri,OS_TID* SequenceNum) -{ - OS_TID seqNum; - OS_TID num,tmpNum; - num = 0; - seqNum = PriNum; - while(num != seqNum) - { - tmpNum = num; - num = (num+seqNum)/2; - if(pri == ActivePri[num]) - { - *SequenceNum = num; - return Co_TRUE; - } - else if (pri < ActivePri[num]) - { - seqNum = num; - num = tmpNum; - } - else - { - num++; - } - } - *SequenceNum = num; - return Co_FALSE; -} - - -/** - ******************************************************************************* - * @brief Get the nearest ready priority sequence number for Assign number - * @param[in] seqNum Assign sequence number - * @param[out] None - * @retval INVALID_ID Cannot find higher ready priority. - * Others Nearest ready priority sequence number - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to get the nearest ready priority sequence number. - ******************************************************************************* - */ -static U8 GetRdyPriSeqNum(U8 seqNum) -{ - U32 tmp; - U8 i,j,num; - S8 cnt; - i = seqNum/32; - j = seqNum%32; - - do - { - tmp = RdyTaskPriInfo[i]; - if(tmp != 0) - { - num = j/8; - do - { - if((tmp&(0xff<<(num*8))) !=0 ) - { - if((tmp&(0xf0<<(num*8))) !=0) - { - for(cnt=j; cnt >=(num*8+4); cnt--) - { - if( (tmp&(1<=num*8; cnt--) - { - if( (tmp&(1<seqNum;num--) - { - ActivePri[num] = ActivePri[num-1]; - TaskNumPerPri[num] = TaskNumPerPri[num-1]; - RdyTaskPri[num] = RdyTaskPri[num-1]; - } - ActivePri[seqNum] = pri; - TaskNumPerPri[seqNum] = 1; - RdyTaskPri[seqNum] = INVALID_ID; - PriNum++; - PrioRemap(seqNum); - } - else - { - TaskNumPerPri[seqNum]++; - } -} - - - -/** - ******************************************************************************* - * @brief Delete priority in queue - * @param[in] pri Task priority - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in Binary-Scheduling Algorithm - * to decrease the task num for this priority, if the num goto 0, - * remove the priority for queue. - ******************************************************************************* - */ -void DeleteTaskPri(U8 pri) -{ - OS_TID seqNum,num; - - GetPriSeqNum(pri,&seqNum); - TaskNumPerPri[seqNum]--; - if(TaskNumPerPri[seqNum]==0) - { - for(num=seqNum; num<(PriNum-1); num++) - { - ActivePri[num] = ActivePri[num+1]; - TaskNumPerPri[num] = TaskNumPerPri[num+1]; - RdyTaskPri[num] = RdyTaskPri[num+1]; - } - PriNum--; - PrioRemap(seqNum); - } -} - -#endif - - -/** - ******************************************************************************* - * @brief Insert a task to the ready list - * @param[in] tcbInsert A pointer to task will be inserted. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to insert a task to the READY list. - ******************************************************************************* - */ -void InsertToTCBRdyList(P_OSTCB tcbInsert) -{ - P_OSTCB ptcbNext,ptcb; - U8 prio; -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - U8 seqNum; - U8 RdyTaskSeqNum; -#endif - - prio = tcbInsert->prio; /* Get PRI of inserted task */ - tcbInsert->state = TASK_READY; /* Set task as TASK_READY */ - -#if CFG_ROBIN_EN >0 - ptcb = TCBRunning; - /* Set schedule time for the same PRI task as TCBRunning. */ - if(prio == ptcb->prio) /* Is PRI of inserted task equal to running task? */ - { - if(ptcb != tcbInsert) /* Yes,is inserted task equal to running task? */ - { - if(ptcb != Co_NULL) /* No,TCBRunning == Co_NULL? */ - { /* N0,OSCheckTime < OSTickCnt? */ - if(OSCheckTime < OSTickCnt) - { /* Yes,set OSCheckTime for task robin */ - OSCheckTime = OSTickCnt + ptcb->timeSlice; - } - } - } - } -#endif - - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - GetPriSeqNum(prio,&seqNum); - if(GetPrioSeqNumStatus(seqNum) == Co_TRUE) - { - ptcb = &TCBTbl[RdyTaskPri[seqNum]]; - RdyTaskPri[seqNum] = tcbInsert->taskID; - } - else - { - RdyTaskPri[seqNum] = tcbInsert->taskID; - RdyTaskSeqNum = GetRdyPriSeqNum(seqNum); - SetPrioSeqNumStatus(seqNum, 1); - if(RdyTaskSeqNum == INVALID_ID) - { - ptcb = TCBRdy; - TaskSchedReq = Co_TRUE; - if(ptcb == Co_NULL) - { - TCBRdy = tcbInsert; - } - else - { - tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */ - ptcb->TCBprev = tcbInsert; - TCBRdy = tcbInsert; - } - return; - } - else - { - ptcb = &TCBTbl[RdyTaskPri[RdyTaskSeqNum]]; - } - } - - ptcbNext = ptcb->TCBnext; - tcbInsert->TCBnext = ptcbNext; /* Set link for list */ - ptcb->TCBnext = tcbInsert; - tcbInsert->TCBprev = ptcb; - if(ptcbNext != Co_NULL) - { - ptcbNext->TCBprev = tcbInsert; - } - - -#else - ptcb = TCBRdy; - if (ptcb == Co_NULL) /* Is ready list Co_NULL? */ - { - TaskSchedReq = Co_TRUE; - TCBRdy = tcbInsert; /* Yse,set tcbInsert as head item of list */ - } - else if (prio < ptcb->prio)/* Is PRI of inserted task higher than TCBRdy? */ - { - TaskSchedReq = Co_TRUE; - tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */ - ptcb->TCBprev = tcbInsert; - TCBRdy = tcbInsert; - } - else /* No,find correct place */ - { - ptcbNext = ptcb->TCBnext; /* Get next item */ - while(ptcbNext != Co_NULL) /* Is last item in ready list? */ - { /* No,find correct place */ - if(prio < ptcbNext->prio) /* Is correct place? */ - break; /* Yes,break circulation */ - ptcb = ptcbNext; /* Save current item */ - ptcbNext = ptcbNext->TCBnext; /* Get next item */ - } - tcbInsert->TCBnext = ptcbNext; /* Set link for list */ - ptcb->TCBnext = tcbInsert; - tcbInsert->TCBprev = ptcb; - if(ptcbNext != Co_NULL) - { - ptcbNext->TCBprev = tcbInsert; - } - } -#endif -} - - - -/** - ******************************************************************************* - * @brief Remove a task from the READY list - * @param[in] ptcb A pointer to task which be removed. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a task from the READY list. - ******************************************************************************* - */ -void RemoveFromTCBRdyList(P_OSTCB ptcb) -{ - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - U8 prio; - U8 seqNum; - BOOL isChange; - isChange = Co_FALSE; - prio = ptcb->prio; - GetPriSeqNum(prio,&seqNum); -#endif - - /* Is there only one item in READY list? */ - if((ptcb->TCBnext == Co_NULL) && (ptcb->TCBprev == Co_NULL) ) - { - TCBRdy = Co_NULL; /* Yes,set READY list as Co_NULL */ -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - isChange = Co_TRUE; -#endif - } - else if(ptcb->TCBprev == Co_NULL) /* Is the first item in READY list? */ - { - /* Yes,remove task from the list,and reset the head of READY list */ - TCBRdy = ptcb->TCBnext; - ptcb->TCBnext = Co_NULL; - TCBRdy->TCBprev = Co_NULL; -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(TCBRdy->prio != prio) - isChange = Co_TRUE; - -#endif - } - else if( ptcb->TCBnext == Co_NULL) /* Is the last item in READY list? */ - { /* Yes,remove task from list */ -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(ptcb->TCBprev->prio != prio) - isChange = Co_TRUE; - else - RdyTaskPri[seqNum] = ptcb->TCBprev->taskID; -#endif - ptcb->TCBprev->TCBnext = Co_NULL; - ptcb->TCBprev = Co_NULL; - } - else /* No, remove task from list */ - { -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if((ptcb->TCBprev->prio != prio) && (ptcb->TCBnext->prio != prio)) - isChange = Co_TRUE; - else if((ptcb->TCBprev->prio == prio) && (ptcb->TCBnext->prio != prio)) - RdyTaskPri[seqNum] = ptcb->TCBprev->taskID; -#endif - ptcb->TCBprev->TCBnext = ptcb->TCBnext; - ptcb->TCBnext->TCBprev = ptcb->TCBprev; - ptcb->TCBnext = Co_NULL; - ptcb->TCBprev = Co_NULL; - } -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - if(isChange == Co_TRUE) - { - RdyTaskPri[seqNum] = INVALID_ID; - SetPrioSeqNumStatus(seqNum, 0); - } -#endif -} - - -#if CFG_MUTEX_EN > 0 -#define CFG_PRIORITY_SET_EN (1) -#endif -#if CFG_PRIORITY_SET_EN >0 -/** - ******************************************************************************* - * @brief Change task priority - * @param[in] taskID Specify task id. - * @param[in] priority New priority. - * @param[out] None - * @retval E_OK Change priority successful. - * @retval E_INVALID_ID Invalid id,change priority fail. - * @retval E_PROTECTED_TASK Can't change idle task priority. - * - * @par Description - * @details This function is called to change priority for a specify task. - ******************************************************************************* - */ -StatusType CoSetPriority(OS_TID taskID,U8 priority) -{ - P_OSTCB ptcb; -#if CFG_MUTEX_EN >0 - U8 prio; - P_MUTEX pMutex; -#endif -#if CFG_EVENT_EN >0 - P_ECB pecb; -#endif - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; /* Get TCB of task ID */ -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } - if(priority > CFG_LOWEST_PRIO) - { - return E_INVALID_ID; - } -#endif - - if(ptcb->prio != priority) /* Is PRI equal to original PRI? */ - { /* No */ -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) - { - pMutex = &MutexTbl[ptcb->mutexID]; - if(pMutex->taskID == ptcb->taskID) /* Task hold mutex? */ - { - pMutex->originalPrio= priority;/* Yes,change original PRI in mutex*/ - if(ptcb->prio < priority) /* Is task priority higher than set?*/ - { - return E_OK; /* Yes,do nothing,return OK */ - } - } - } - -#endif - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - DeleteTaskPri(ptcb->prio); - ActiveTaskPri(priority); -#endif - - ptcb->prio = priority; /* Change task PRI */ - if(ptcb->state == TASK_READY) /* Is task in READY list? */ - { - OsSchedLock(); /* Yes,reorder task in READY list */ - RemoveFromTCBRdyList(ptcb); - InsertToTCBRdyList(ptcb); - OsSchedUnlock(); - } - else if(ptcb->state == TASK_RUNNING)/* Is task running? */ - { - if(ptcb->prio > TCBRdy->prio) /* Yes,Is PRI higher than TCBRdy? */ - { - OsSchedLock(); /* Yes,reorder task in READY list */ - TaskSchedReq = Co_TRUE; - OsSchedUnlock(); - } - } - else - { /* No,task in WAITING list */ -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex WAITING list? */ - { - /* Yes,reset the highest PRI in the list */ - OsSchedLock(); - pMutex = &MutexTbl[ptcb->mutexID]; - ptcb = pMutex->waittingList; - prio = pMutex->originalPrio; - pMutex->hipriTaskID = pMutex->taskID; - while(ptcb != Co_NULL) - { - if(ptcb->prio < prio) - { - prio = ptcb->prio; - pMutex->hipriTaskID = ptcb->taskID; - } - ptcb = ptcb->TCBnext; - } - OsSchedUnlock(); - if(pMutex->originalPrio != prio) - { - CoSetPriority(pMutex->taskID,prio); - } - } -#endif - -#if CFG_EVENT_EN >0 - ptcb = &TCBTbl[taskID]; - if(ptcb->eventID != INVALID_ID) /* Is task in event WAITING list? */ - { - pecb = &EventTbl[ptcb->eventID]; - - /* Yes,is event sort type as preemptive PRI? */ - if(pecb->eventSortType == EVENT_SORT_TYPE_PRIO) - { - /* Yes,reorder task in the list */ - RemoveEventWaittingList(ptcb); - EventTaskToWait(pecb,ptcb); - } - } -#endif - } - } - return E_OK; -} -#endif - -/** - ******************************************************************************* - * @brief Schedule function - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called by every where need to switch context, - * It is schedule function of OS kernel. - ******************************************************************************* - */ -void Schedule(void) -{ - U8 RunPrio,RdyPrio; - P_OSTCB pRdyTcb,pCurTcb; - - - pCurTcb = TCBRunning; - pRdyTcb = TCBRdy; - - if((pRdyTcb==Co_NULL) || (pCurTcb != TCBNext) || (OSSchedLock >1) || (OSIntNesting >0)) - { - return; - } - - TaskSchedReq = Co_FALSE; - RunPrio = pCurTcb->prio; - RdyPrio = pRdyTcb->prio; - - /* Is Running task status was changed? */ - if(pCurTcb->state != TASK_RUNNING) - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - pRdyTcb->state = TASK_RUNNING; - RemoveFromTCBRdyList(pRdyTcb); - } - - else if(RdyPrio < RunPrio ) /* Is higher PRI task coming in? */ - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - InsertToTCBRdyList(pCurTcb); - RemoveFromTCBRdyList(pRdyTcb); - pRdyTcb->state = TASK_RUNNING; - } - -#if CFG_ROBIN_EN >0 /* Is time for robinning */ - else if((RunPrio == RdyPrio) && (OSCheckTime == OSTickCnt)) - { - TCBNext = pRdyTcb; /* Yes,set TCBNext and reorder READY list */ - InsertToTCBRdyList(pCurTcb); - RemoveFromTCBRdyList(pRdyTcb); - pRdyTcb->state = TASK_RUNNING; - } -#endif - else - { - return; - } - -#if CFG_ROBIN_EN >0 - if(TCBNext->prio == TCBRdy->prio) /* Reset OSCheckTime for task robinnig */ - OSCheckTime = OSTickCnt + TCBNext->timeSlice; -#endif - - -#if CFG_STK_CHECKOUT_EN > 0 /* Is stack overflow? */ - if((pCurTcb->stkPtr < pCurTcb->stack)||(*(U32*)(pCurTcb->stack) != MAGIC_WORD)) - { - CoStkOverflowHook(pCurTcb->taskID); /* Yes,call handler */ - } -#endif - - SwitchContext(); /* Call task context switch */ -} - - -/** - ******************************************************************************* - * @brief Assign a TCB to task being created - * @param[in] None - * @param[out] None - * - * @retval XXXX - * - * @par Description - * @details This function is called to assign a task control block for task - * being created. - ******************************************************************************* - */ -static P_OSTCB AssignTCB(void) -{ - P_OSTCB ptcb; - - OsSchedLock(); /* Lock schedule */ - if(FreeTCB == Co_NULL) /* Is there no free TCB */ - { - OsSchedUnlock(); /* Yes,unlock schedule */ - return Co_NULL; /* Error return */ - } - ptcb = FreeTCB; /* Yes,assgin free TCB for this task */ - /* Set next item as the head of free TCB list */ - FreeTCB = FreeTCB->TCBnext; - OsSchedUnlock(); - return ptcb; -} - - -/** - ******************************************************************************* - * @brief Create a task - * @param[in] task Task code entry. - * @param[in] argv The parameter passed to task. - * @param[in] parameter Task priority + stack size + time slice + isWaitting. - * @param[in] stk Pointer to stack top of task. - * @param[out] None - * @retval E_CREATE_FAIL Fail to create a task . - * @retval others Valid task id. - * - * @par Description - * @details This function is called by application to create a task,return a id - * to mark this task. - ******************************************************************************* - */ -OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk) -{ - OS_STK* stkTopPtr; - P_OSTCB ptcb; - U8 prio; -#if CFG_ROBIN_EN >0 - U16 timeSlice; -#endif - -#if CFG_STK_CHECKOUT_EN >0 /* Check validity of parameter */ - U16 sktSz; - sktSz = (parameter&0xfff00)>>8; -#endif - prio = parameter&0xff; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(task == Co_NULL) - { - return E_CREATE_FAIL; - } - if(stk == Co_NULL) - { - return E_CREATE_FAIL; - } - if(prio > CFG_LOWEST_PRIO) - { - return E_CREATE_FAIL; - } -#if CFG_STK_CHECKOUT_EN >0 - if(sktSz < 20) - { - return E_CREATE_FAIL; - } -#endif // CFG_STK_CHECKOUT_EN -#endif // CFG_PAR_CHECKOUT_EN - -#if CFG_TASK_SCHEDULE_EN == 0 - if(TCBRunning != Co_NULL) - return E_CREATE_FAIL; -#endif - - stkTopPtr = InitTaskContext(task,argv,stk); /* Initialize task context. */ - - ptcb = AssignTCB(); /* Get free TCB to use */ - - if(ptcb == Co_NULL) /* Is free TCB equal to Co_NULL? */ - { - return E_CREATE_FAIL; /* Yes,error return */ - } - - ptcb->stkPtr = stkTopPtr; /* Initialize TCB as user set */ - ptcb->prio = prio; -#if CFG_STK_CHECKOUT_EN >0 - ptcb->stack = stk+1 - sktSz; /* Set bottom stack for stack overflow check */ - *(U32*)(ptcb->stack) = MAGIC_WORD; -#endif - -#if CFG_TASK_WAITTING_EN >0 - ptcb->delayTick = INVALID_VALUE; -#endif - -#if CFG_TASK_SCHEDULE_EN == 0 - ptcb->taskFuc = task; - ptcb->taskStk = stk; -#endif - ptcb->TCBnext = Co_NULL; /* Initialize TCB link in READY list */ - ptcb->TCBprev = Co_NULL; - -#if CFG_ROBIN_EN >0 /* Set task time slice for task robin */ - timeSlice = (parameter&0x7fff0000)>>20; - if(timeSlice == 0) - { - timeSlice = CFG_TIME_SLICE; - } - ptcb->timeSlice = timeSlice; -#endif - -#if CFG_FLAG_EN > 0 - ptcb->pnode = Co_NULL; /* Initialize task as no flag waiting */ -#endif - -#if CFG_EVENT_EN > 0 - ptcb->eventID = INVALID_ID; /* Initialize task as no event waiting*/ - ptcb->pmail = Co_NULL; - ptcb->waitNext = Co_NULL; - ptcb->waitPrev = Co_NULL; -#endif - -#if CFG_MUTEX_EN > 0 - /* Initialize task as no mutex holding or waiting */ - ptcb->mutexID = INVALID_ID; -#endif - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - ActiveTaskPri(prio); -#endif - - if((parameter>>31) == 0) /* Is task in waitting state? */ - { /* No,set it into ready list */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert into the READY list */ - OsSchedUnlock(); /* Unlock schedule */ - } - else - { /* Yes,Set task status as TASK_WAITING*/ - ptcb->state = TASK_WAITING; - } - return ptcb->taskID; /* Return task ID */ -} - - -/** - ******************************************************************************* - * @brief Delete Task - * @param[in] taskID Task ID - * @param[out] None - * @retval E_INVALID_ID Invalid task ID. - * @retval E_PROTECTED_TASK Protected task in OS. - * @retval E_OK Delete successful. - * - * @par Description - * @details This function is called to delete assign task. - ******************************************************************************* - */ -StatusType CoDelTask(OS_TID taskID) -{ - P_OSTCB ptcb; - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } - - if(ptcb->state == TASK_RUNNING) /* Is task running? */ - { - if(OSSchedLock != 0) /* Yes,is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - } - -#if CFG_MUTEX_EN >0 /* Do task hold mutex? */ - if(ptcb->mutexID != INVALID_ID) - { - if(MutexTbl[ptcb->mutexID].taskID == ptcb->taskID) - { /* Yes,leave the mutex */ - CoLeaveMutexSection(ptcb->mutexID); - } - } - -#endif - - OsSchedLock(); /* Lock schedule */ - - if(ptcb->state == TASK_READY) /* Is task in READY list? */ - { - RemoveFromTCBRdyList(ptcb); /* Yes,remove task from the READY list*/ - } - -#if CFG_TASK_WAITTING_EN > 0 - else if(ptcb->state == TASK_WAITING)/* Is task in the WAITING list? */ - { - /* Yes,Is task in delay list? */ - if(ptcb->delayTick != INVALID_VALUE) - { - RemoveDelayList(ptcb); /* Yes,remove task from READY list */ - } - -#if CFG_EVENT_EN > 0 - if(ptcb->eventID != INVALID_ID) /* Is task in event waiting list? */ - { - /* Yes,remove task from event waiting list */ - RemoveEventWaittingList(ptcb); - } -#endif - -#if CFG_FLAG_EN > 0 - if(ptcb->pnode != Co_NULL) /* Is task in flag waiting list? */ - { - /* Yes,remove task from flag waiting list */ - RemoveLinkNode(ptcb->pnode); - } -#endif - -#if CFG_MUTEX_EN >0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex waiting list? */ - { - RemoveMutexList(ptcb); /* Yes,remove task from mutex waiting list*/ - } -#endif - } -#endif - ptcb->state = TASK_DORMANT; /* Release TCB */ - TaskSchedReq = Co_TRUE; - -#if CFG_ORDER_LIST_SCHEDULE_EN ==0 - DeleteTaskPri(ptcb->prio); -#endif - -#if CFG_TASK_SCHEDULE_EN >0 - ptcb->TCBnext = FreeTCB; - FreeTCB = ptcb; -#endif - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; /* return OK */ -} - - -/** - ******************************************************************************* - * @brief Exit Task - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to exit current task. - ******************************************************************************* - */ -void CoExitTask(void) -{ - CoDelTask(TCBRunning->taskID); /* Call task delete function */ -} - - -#if CFG_TASK_SCHEDULE_EN ==0 -/** - ******************************************************************************* - * @brief Activate Task - * @param[in] taskID Task ID - * @param[in] argv Task argv - * @param[out] None - * @retval E_INVALID_ID Invalid task ID. - * @retval E_OK Activate task successful. - * - * @par Description - * @details This function is called to activate current task. - ******************************************************************************* - */ -StatusType CoActivateTask(OS_TID taskID,void *argv) -{ - P_OSTCB ptcb; - OS_STK* stkTopPtr; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->stkPtr == Co_NULL) - return E_INVALID_ID; -#endif - if(ptcb->state != TASK_DORMANT) - return E_OK; - - - /* Initialize task context. */ - stkTopPtr = InitTaskContext(ptcb->taskFuc,argv,ptcb->taskStk); - - ptcb->stkPtr = stkTopPtr; /* Initialize TCB as user set */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert into the READY list */ - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; -} -#endif - - -/** - ******************************************************************************* - * @brief Get current task id - * @param[in] None - * @param[out] None - * @retval ID of the current task. - * - * @par Description - * @details This function is called to get current task id. - ******************************************************************************* - */ -OS_TID CoGetCurTaskID(void) -{ - return (TCBRunning->taskID); /* Return running task ID */ -} - -#if CFG_TASK_SUSPEND_EN >0 -/** - ******************************************************************************* - * @brief Suspend Task - * @param[in] taskID ID of task that want to suspend. - * @param[out] None - * @retval E_OK Task suspend successful. - * @retval E_INVALID_ID Invalid event ID. - * @retval E_PROTECTED_TASK Can't suspend idle task. - * @retval E_ALREADY_IN_WAITING Task now in waiting state. - - * - * @par Description - * @details This function is called to exit current task. - ******************************************************************************* - */ -StatusType CoSuspendTask(OS_TID taskID) -{ - P_OSTCB ptcb; - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - if(OSSchedLock != 0) - { - return E_OS_IN_LOCK; - } - if(ptcb->state == TASK_WAITING) /* Is task in WAITING list? */ - { - return E_ALREADY_IN_WAITING; /* Yes,error return */ - } - - OsSchedLock(); - if(ptcb != TCBRunning) /* Is runing task? */ - { - RemoveFromTCBRdyList(ptcb); /* No,Remove task from READY list */ - } - else - { - TaskSchedReq = Co_TRUE; - } - - ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */ - OsSchedUnlock(); /* Call task schedule */ - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Awake Task - * @param[in] taskID ID of task that will been awaked. - * @param[out] None - * @retval E_OK Task awake successful. - * @retval E_INVALID_ID Invalid task ID. - * @retval E_TASK_NOT_WAITING Task now not in waiting state. - * @retval E_TASK_WAIT_OTHER Task now waiting other awake event. - * @retval E_PROTECTED_TASK Idle task mustn't be awaked. - * - * @par Description - * @details This function is called to awake current task. - ******************************************************************************* - */ -StatusType CoAwakeTask(OS_TID taskID) -{ - P_OSTCB ptcb; - - if(taskID == 0) /* Is idle task? */ - { - return E_PROTECTED_TASK; /* Yes,error return */ - } -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->state == TASK_DORMANT) - { - return E_INVALID_ID; - } -#endif - - if(ptcb->state != TASK_WAITING) /* Is task in WAITING list */ - { - return E_TASK_NOT_WAITING; /* No,error return */ - } - -#if CFG_TASK_WAITTING_EN > 0 - if(ptcb->delayTick != INVALID_VALUE)/* Is task in READY list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } - -#if CFG_FLAG_EN > 0 - if(ptcb->pnode != Co_NULL) /* Is task in flag waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#if CFG_EVENT_EN>0 - if(ptcb->eventID != INVALID_ID) /* Is task in event waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#if CFG_MUTEX_EN > 0 - if(ptcb->mutexID != INVALID_ID) /* Is task in mutex waiting list */ - { - return E_TASK_WAIT_OTHER; /* Yes,error return */ - } -#endif - -#endif //CFG_TASK_WAITTING_EN - - /* All no,so WAITING state was set by CoSuspendTask() */ - OsSchedLock(); /* Lock schedule */ - InsertToTCBRdyList(ptcb); /* Insert the task into the READY list*/ - OsSchedUnlock(); /* Unlock schedule */ - return E_OK; /* return OK */ -} -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/time.c b/GD32F1/libraries/MapleCoOS116/utility/time.c deleted file mode 100644 index 9b609c2..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/time.c +++ /dev/null @@ -1,399 +0,0 @@ -/** - ******************************************************************************* - * @file time.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief time management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if CFG_TASK_WAITTING_EN > 0 - -/*---------------------------- Variable Define -------------------------------*/ -P_OSTCB DlyList = Co_NULL; /*!< Header pointer to the DELAY list.*/ - - -/** - ******************************************************************************* - * @brief Insert into DELAY list - * - * @param[in] ptcb Task that want to insert into DELAY list. - * @param[in] ticks Delay system ticks. - * @param[out] None - * @retval None. - * - * @par Description - * @details This function is called to insert task into DELAY list. - ******************************************************************************* - */ -void InsertDelayList(P_OSTCB ptcb,U32 ticks) -{ - S32 deltaTicks; - P_OSTCB dlyNext; - - if(ticks == 0) /* Is delay tick == 0? */ - return; /* Yes,do nothing,return */ - if(DlyList == Co_NULL) /* Is no item in DELAY list? */ - { - ptcb->delayTick = ticks; /* Yes,set this as first item */ - DlyList = ptcb; - } - else - { - /* No,find correct place ,and insert the task */ - dlyNext = DlyList; - deltaTicks = ticks; /* Get task delay ticks */ - - /* Find correct place */ - while(dlyNext != Co_NULL) - { - /* Get delta ticks with previous item */ - deltaTicks -= dlyNext->delayTick; - if(deltaTicks < 0) /* Is delta ticks<0? */ - { - /* Yes,get correct place */ - if(dlyNext->TCBprev != Co_NULL) /* Is head item of DELAY list? */ - { - dlyNext->TCBprev->TCBnext = ptcb; /* No,insert into */ - ptcb->TCBprev = dlyNext->TCBprev; - ptcb->TCBnext = dlyNext; - dlyNext->TCBprev = ptcb; - } - else /* Yes,set task as first item */ - { - ptcb->TCBnext = DlyList; - DlyList->TCBprev = ptcb; - DlyList = ptcb; - } - ptcb->delayTick = ptcb->TCBnext->delayTick+deltaTicks; - ptcb->TCBnext->delayTick -= ptcb->delayTick; - break; - } - /* Is last item in DELAY list? */ - else if((deltaTicks >= 0) && (dlyNext->TCBnext == Co_NULL) ) - { - ptcb->TCBprev = dlyNext; /* Yes,insert into */ - dlyNext->TCBnext = ptcb; - ptcb->delayTick = deltaTicks; - break; - } - dlyNext = dlyNext->TCBnext; /* Get the next item in DELAY list */ - } - } - - ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */ - TaskSchedReq = Co_TRUE; -} - - -/** - ******************************************************************************* - * @brief Remove from the DELAY list - * @param[in] ptcb Task that want to remove from the DELAY list. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove task from the DELAY list. - ******************************************************************************* - */ -void RemoveDelayList(P_OSTCB ptcb) -{ - - /* Is there only one item in the DELAY list? */ - if((ptcb->TCBprev == Co_NULL) && ( ptcb->TCBnext == Co_NULL)) - { - DlyList = Co_NULL; /* Yes,set DELAY list as Co_NULL */ - } - else if(ptcb->TCBprev == Co_NULL) /* Is the first item in DELAY list? */ - { - /* Yes,remove task from the DELAY list,and reset the list */ - DlyList = ptcb->TCBnext; - ptcb->TCBnext->delayTick += ptcb->delayTick; - ptcb->TCBnext->TCBprev = Co_NULL; - ptcb->TCBnext = Co_NULL; - - } - else if(ptcb->TCBnext == Co_NULL) /* Is the last item in DELAY list? */ - { - ptcb->TCBprev->TCBnext = Co_NULL; /* Yes,remove task form DELAY list */ - ptcb->TCBprev = Co_NULL; - } - else /* No, remove task from DELAY list */ - { - ptcb->TCBprev->TCBnext = ptcb->TCBnext; - ptcb->TCBnext->TCBprev = ptcb->TCBprev; - ptcb->TCBnext->delayTick += ptcb->delayTick; - ptcb->TCBnext = Co_NULL; - ptcb->TCBprev = Co_NULL; - } - ptcb->delayTick = INVALID_VALUE; /* Set task delay tick value as invalid */ -} - -/** - ******************************************************************************* - * @brief Get current ticks - * @param[in] None - * @param[out] None - * @retval Return current system tick counter. - * - * @par Description - * @details This function is called to obtain current system tick counter. - ******************************************************************************* - */ -U64 CoGetOSTime(void) -{ - return OSTickCnt; /* Get system time(tick) */ -} - - -/** - ******************************************************************************* - * @brief Delay current task for specify ticks number - * @param[in] ticks Specify system tick number which will delay. - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_OK The current task was insert to DELAY list successful,it - * will delay specify time. - * @par Description - * @details This function delay specify ticks for current task. - * - * @note This function be called in ISR,do nothing and return immediately. - ******************************************************************************* - */ -StatusType CoTickDelay(U32 ticks) -{ - if(OSIntNesting >0) /* Is call in ISR? */ - { - return E_CALL; /* Yes,error return */ - } - - if(ticks == INVALID_VALUE) /* Is tick==INVALID_VALUE? */ - { - return E_INVALID_PARAMETER; /* Yes,error return */ - } - if(ticks == 0) /* Is tick==0? */ - { - return E_OK; /* Yes,do nothing ,return OK */ - } - if(OSSchedLock != 0) /* Is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - OsSchedLock(); /* Lock schedule */ - InsertDelayList(TCBRunning,ticks); /* Insert task in DELAY list */ - OsSchedUnlock(); /* Unlock schedule,and call task schedule */ - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Reset task delay ticks - * @param[in] ptcb Task that want to insert into DELAY list. - * @param[in] ticks Specify system tick number which will delay . - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_INVALID_ID Invalid task id. - * @retval E_NOT_IN_DELAY_LIST Task not in delay list. - * @retval E_OK The current task was inserted to DELAY list - * successful,it will delay for specify time. - * @par Description - * @details This function delay specify ticks for current task. - ******************************************************************************* - */ -StatusType CoResetTaskDelayTick(OS_TID taskID,U32 ticks) -{ - P_OSTCB ptcb; - - -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) - { - return E_INVALID_ID; - } -#endif - - ptcb = &TCBTbl[taskID]; -#if CFG_PAR_CHECKOUT_EN >0 - if(ptcb->stkPtr == Co_NULL) - { - return E_INVALID_ID; - } -#endif - - if(ptcb->delayTick == INVALID_VALUE) /* Is tick==INVALID_VALUE? */ - { - return E_NOT_IN_DELAY_LIST; /* Yes,error return */ - } - OsSchedLock(); /* Lock schedule */ - RemoveDelayList(ptcb); /* Remove task from the DELAY list */ - - if(ticks == 0) /* Is delay tick==0? */ - { - InsertToTCBRdyList(ptcb); /* Insert task into the DELAY list */ - } - else - { - InsertDelayList(ptcb,ticks); /* No,insert task into DELAY list */ - } - OsSchedUnlock(); /* Unlock schedule,and call task schedule */ - return E_OK; /* Return OK */ -} - - -/** - ******************************************************************************* - * @brief Delay current task for detail time - * @param[in] hour Specify the number of hours. - * @param[in] minute Specify the number of minutes. - * @param[in] sec Specify the number of seconds. - * @param[in] millsec Specify the number of millseconds. - * @param[out] None - * @retval E_CALL Error call in ISR. - * @retval E_INVALID_PARAMETER Parameter passed was invalid,delay fail. - * @retval E_OK The current task was inserted to DELAY list - * successful,it will delay for specify time. - * @par Description - * @details This function delay specify time for current task. - * - * @note If this function called in ISR,do nothing and return immediately. - ******************************************************************************* - */ -#if CFG_TIME_DELAY_EN >0 -StatusType CoTimeDelay(U8 hour,U8 minute,U8 sec,U16 millsec) -{ - U32 ticks; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if(OSIntNesting > 0) - { - return E_CALL; - } - if((minute > 59)||(sec > 59)||(millsec > 999)) - return E_INVALID_PARAMETER; -#endif - if(OSSchedLock != 0) /* Is OS lock? */ - { - return E_OS_IN_LOCK; /* Yes,error return */ - } - - /* Get tick counter from time */ - ticks = ((hour*3600) + (minute*60) + (sec)) * (CFG_SYSTICK_FREQ)\ - + (millsec*CFG_SYSTICK_FREQ + 500)/1000; - - CoTickDelay(ticks); /* Call tick delay */ - return E_OK; /* Return OK */ -} -#endif - - - - -/** - ******************************************************************************* - * @brief Dispose time delay - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to dispose time delay of all task. - ******************************************************************************* - */ -void TimeDispose(void) -{ - P_OSTCB dlyList; - - dlyList = DlyList; /* Get first item of DELAY list */ - while((dlyList != Co_NULL) && (dlyList->delayTick == 0) ) - { - -#if CFG_EVENT_EN > 0 - if(dlyList->eventID != INVALID_ID) /* Is task in event waiting list? */ - { - RemoveEventWaittingList(dlyList); /* Yes,remove task from list */ - } -#endif - -#if CFG_FLAG_EN > 0 - if(dlyList->pnode != Co_NULL) /* Is task in flag waiting list? */ - { - RemoveLinkNode(dlyList->pnode); /* Yes,remove task from list */ - } -#endif - dlyList->delayTick = INVALID_VALUE; /* Set delay tick value as invalid*/ - DlyList = dlyList->TCBnext; /* Get next item as the head of DELAY list*/ - dlyList->TCBnext = Co_NULL; - - InsertToTCBRdyList(dlyList); /* Insert task into READY list */ - - dlyList = DlyList; /* Get the first item of DELAY list */ - if(dlyList != Co_NULL) /* Is DELAY list as Co_NULL? */ - { - dlyList->TCBprev = Co_NULL; /* No,initialize the first item */ - } - } -} - - -/** - ******************************************************************************* - * @brief Dispose time delay in ISR - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called in systick interrupt to dispose time delay - * of all task. - ******************************************************************************* - */ -void isr_TimeDispose(void) -{ - if(OSSchedLock > 1) /* Is schedule lock? */ - { - IsrReq = Co_TRUE; - TimeReq = Co_TRUE; /* Yes,set time request Co_TRUE */ - } - else - { - TimeDispose(); /* No,call handler */ - } -} - - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/timer.c b/GD32F1/libraries/MapleCoOS116/utility/timer.c deleted file mode 100644 index acd868e..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/timer.c +++ /dev/null @@ -1,470 +0,0 @@ -/** - ******************************************************************************* - * @file timer.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief timer management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - - -/*---------------------------- Include ---------------------------------------*/ -#include - -/*---------------------------- Variable Define -------------------------------*/ -#if CFG_TMR_EN > 0 - -TmrCtrl TmrTbl[CFG_MAX_TMR]= {{0}};/*!< Table which save timer control block.*/ -P_TmrCtrl TmrList = Co_NULL; /*!< The header of the TmrCtrl list. */ -U32 TmrIDVessel = 0; /*!< Timer ID container. */ - - -/** - ******************************************************************************* - * @brief Insert a timer into the timer list - * @param[in] tmrID Specify timer ID which insertted. - * @param[out] None - * @retval E_INVALID_ID Timer ID passed was invalid,insert fail. - * @retval E_OK Insert successful. - * - * @par Description - * @details This function is called to insert a timer into the timer list. - ******************************************************************************* - */ -static void InsertTmrList(OS_TCID tmrID) -{ - P_TmrCtrl pTmr; - S32 deltaTicks; - U32 tmrCnt; - tmrCnt = TmrTbl[tmrID].tmrCnt; /* Get timer time */ - - if(tmrCnt == 0) /* Is timer time==0? */ - { - return; /* Do nothing,return */ - } - - OsSchedLock(); /* Lock schedule */ - if(TmrList == Co_NULL) /* Is no item in timer list? */ - { - TmrList = &TmrTbl[tmrID]; /* Yes,set this as first item */ - } - else /* No,find correct place ,and insert inserted timer */ - { - pTmr = TmrList; - deltaTicks = tmrCnt; /* Get timer tick */ - - /* find correct place */ - while(pTmr != Co_NULL) - { - deltaTicks -= pTmr->tmrCnt; /* Get ticks with previous item */ - if(deltaTicks < 0) /* Is delta ticks<0? */ - { - /* Yes,get correct place */ - if(pTmr->tmrPrev!= Co_NULL)/* Is head item of timer list? */ - { - /* No,insert into */ - pTmr->tmrPrev->tmrNext = &TmrTbl[tmrID]; - TmrTbl[tmrID].tmrPrev = pTmr->tmrPrev; - TmrTbl[tmrID].tmrNext = pTmr; - pTmr->tmrPrev = &TmrTbl[tmrID]; - } - else /* Yes,set task as first item */ - { - TmrTbl[tmrID].tmrNext = TmrList; - TmrList->tmrPrev = &TmrTbl[tmrID]; - TmrList = &TmrTbl[tmrID]; - } - TmrTbl[tmrID].tmrCnt = TmrTbl[tmrID].tmrNext->tmrCnt+deltaTicks; - TmrTbl[tmrID].tmrNext->tmrCnt -= TmrTbl[tmrID].tmrCnt; - break; - } - /* Is last item in list? */ - else if((deltaTicks >= 0) && (pTmr->tmrNext == Co_NULL)) - { - /* Yes,insert into */ - TmrTbl[tmrID].tmrPrev = pTmr; - pTmr->tmrNext = &TmrTbl[tmrID]; - TmrTbl[tmrID].tmrCnt = deltaTicks; - break; - } - pTmr = pTmr->tmrNext; /* Get the next item in timer list */ - } - } - OsSchedUnlock(); /* Unlock schedule */ -} - - -/** - ******************************************************************************* - * @brief Remove a timer from the timer list - * @param[in] tmrID Specify ID for a timer which removed form timer list. - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to remove a timer from the timer list. - ******************************************************************************* - */ -static void RemoveTmrList(OS_TCID tmrID) -{ - P_TmrCtrl pTmr; - - pTmr = &TmrTbl[tmrID]; - - OsSchedLock(); /* Lock schedule */ - - /* Is there only one item in timer list? */ - if((pTmr->tmrPrev == Co_NULL) && (pTmr->tmrNext == Co_NULL)) - { - TmrList = Co_NULL; /* Yes,set timer list as Co_NULL */ - } - else if(pTmr->tmrPrev == Co_NULL) /* Is the first item in timer list? */ - { /* Yes,remove timer from list,and reset timer list */ - TmrList = pTmr->tmrNext; - TmrList->tmrPrev = Co_NULL; - pTmr->tmrNext->tmrCnt += pTmr->tmrCnt; - pTmr->tmrNext = Co_NULL; - } - else if(pTmr->tmrNext == Co_NULL) /* Is the last item in timer list? */ - { - /* Yes,remove timer form list */ - pTmr->tmrPrev->tmrNext = Co_NULL; - pTmr->tmrPrev = Co_NULL; - } - else /* No, remove timer from list */ - { - pTmr->tmrPrev->tmrNext = pTmr->tmrNext; - pTmr->tmrNext->tmrPrev = pTmr->tmrPrev; - pTmr->tmrNext->tmrCnt += pTmr->tmrCnt; - pTmr->tmrNext = Co_NULL; - pTmr->tmrPrev = Co_NULL; - } - OsSchedUnlock(); /* Unlock schedule */ -} - - -/** - ******************************************************************************* - * @brief Create a timer - * @param[in] tmrType Specify timer's type. - * @param[in] tmrCnt Specify timer initial counter value. - * @param[in] tmrReload Specify timer reload value. - * @param[in] func Specify timer callback function entry. - * @param[out] None - * @retval E_CREATE_FAIL Create timer fail. - * @retval others Create timer successful. - * - * @par Description - * @details This function is called to create a timer. - ******************************************************************************* - */ -OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func) -{ - U8 i; -#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ - if((tmrType != TMR_TYPE_ONE_SHOT) && (tmrType != TMR_TYPE_PERIODIC)) - { - return E_CREATE_FAIL; - } - if(func == Co_NULL) - { - return E_CREATE_FAIL; - } -#endif - OsSchedLock(); /* Lock schedule */ - for(i = 0; i < CFG_MAX_TMR; i++) - { - if((TmrIDVessel & (1 << i)) == 0) /* Is free timer ID? */ - { - TmrIDVessel |= (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - return E_INVALID_ID; - } - if( (TmrIDVessel & (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - return E_INVALID_ID; - } - if((TmrIDVessel & (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - return E_INVALID_ID; - } - if( (TmrIDVessel & (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - *perr = E_INVALID_ID; - return 0; - } - if((TmrIDVessel & (1<0 /* Check validity of parameter */ - if(tmrID >= CFG_MAX_TMR) - { - return E_INVALID_ID; - } - if( (TmrIDVessel & (1<tmrCnt == 0) ) - { - if(pTmr->tmrType == TMR_TYPE_ONE_SHOT) /* Is a One-shot timer? */ - { - /* Yes,remove this timer from timer list */ - RemoveTmrList(pTmr->tmrID); - - /* Set timer status as TMR_STATE_STOPPED */ - pTmr->tmrState = TMR_STATE_STOPPED; - (pTmr->tmrCallBack)(); /* Call timer callback function */ - } - else if(pTmr->tmrType == TMR_TYPE_PERIODIC) /* Is a periodic timer? */ - { - /* Yes,remove this timer from timer list */ - RemoveTmrList(pTmr->tmrID); - pTmr->tmrCnt = pTmr->tmrReload; /* Reset timer tick */ - InsertTmrList(pTmr->tmrID); /* Insert timer into timer list */ - (pTmr->tmrCallBack)(); /* Call timer callback function */ - } - pTmr = TmrList; /* Get first item of timer list */ - } -} - - -/** - ******************************************************************************* - * @brief Timer counter dispose in ISR - * @param[in] None - * @param[out] None - * @retval None - * - * @par Description - * @details This function is called to dispose timer counter. - ******************************************************************************* - */ -void isr_TmrDispose(void) -{ - if(OSSchedLock > 1) /* Is schedule lock? */ - { - IsrReq = Co_TRUE; - TimerReq = Co_TRUE; /* Yes,set timer request true */ - } - else - { - TmrDispose(); /* No,call handler */ - } -} - -#endif diff --git a/GD32F1/libraries/MapleCoOS116/utility/utility.c b/GD32F1/libraries/MapleCoOS116/utility/utility.c deleted file mode 100644 index 520319c..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/utility.c +++ /dev/null @@ -1,109 +0,0 @@ -/** - ******************************************************************************* - * @file utility.c - * @version V1.1.6 - * @date 2014.05.23 - * @brief Utility management implementation code of CooCox CoOS kernel. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -/*---------------------------- Include ---------------------------------------*/ -#include - -#if CFG_UTILITY_EN > 0 - - -/** - ******************************************************************************* - * @brief Convert tick number to time - * @param[in] ticks Specifies the systerm tick numbers that will be converted. - * @param[out] hour Hours which converted. - * @param[out] minute minutes which converted. - * @param[out] sec seconds which converted. - * @param[out] millsec millseconds which converted. - * @retval None - * - * @par Description - * @details This function is called to convert specify ticks to time format. - ******************************************************************************* - */ -#if CFG_TICK_TO_TIME_EN > 0 -void CoTickToTime(U32 ticks,U8* hour,U8* minute,U8* sec,U16* millsec) -{ - U32 totalTime; - - /* Convert ticks to time*/ - totalTime = ticks * (1000/CFG_SYSTICK_FREQ); - *millsec = totalTime%1000; - totalTime = totalTime/1000; - *sec = totalTime%60; - totalTime = totalTime/60; - *minute = totalTime%60; - totalTime = totalTime/60; - *hour = totalTime; -} -#endif /* CFG_TICK_TO_TIME_EN */ - - -/** - ******************************************************************************* - * @brief Convert time to tick - * @param[in] hour Specifies the number of hours. - * @param[in] minute Specifies the number of minutes. - * @param[in] sec Specifies the number of seconds. - * @param[in] millsec Specifies the number of millseconds. - * @param[out] ticks Tick numbers that converted. - * @retval E_INVALID_PARAMETER Invalid parameter be passed and convert fail. - * @retval E_OK Convert successful. - * - * @par Description - * @details This function is called to convert specify time to tick number. - ******************************************************************************* - */ -#if CFG_TIME_TO_TICK_EN > 0 -StatusType CoTimeToTick(U8 hour,U8 minute,U8 sec,U16 millsec,U32* ticks) -{ -#if CFG_PAR_CHECKOUT_EN >0 - /* Validate arguments to be within range */ - if((minute > 59)||(sec > 59)||(millsec > 999)) - return E_INVALID_PARAMETER; -#endif - - /* Convert time to ticks */ - *ticks = ((hour*3600) + (minute*60) + (sec)) * (CFG_SYSTICK_FREQ)\ - + (millsec*CFG_SYSTICK_FREQ + 500)/1000; - return E_OK; -} -#endif /* CFG_TIME_TO_TICK_EN */ - -#endif /* CFG_UTILITY_EN */ diff --git a/GD32F1/libraries/MapleCoOS116/utility/utility.h b/GD32F1/libraries/MapleCoOS116/utility/utility.h deleted file mode 100644 index b35cfd8..0000000 --- a/GD32F1/libraries/MapleCoOS116/utility/utility.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - ******************************************************************************* - * @file utility.h - * @version V1.1.6 - * @date 2014.05.23 - * @brief Utility function header file - * @details This file including some defines and declares related to utility - * function. - ******************************************************************************* - * @copy - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - *

© COPYRIGHT 2014 CooCox

- ******************************************************************************* - */ - - -#ifndef _UTILITY_H -#define _UTILITY_H - - -/** - * @struct Time struct utility.h - * @brief Time struct - * @details This struct use to manage time - */ -typedef struct SysTime -{ - U8 sec; /*!< Second */ - U8 min; /*!< Minute */ - U8 hour; /*!< Hour */ - U8 date; /*!< Date */ - U8 month; /*!< Month */ - U16 year; /*!< Year */ -}TIME; - -#endif - diff --git a/GD32F1/libraries/OLED_I2C/DefaultFonts.c b/GD32F1/libraries/OLED_I2C/DefaultFonts.c deleted file mode 100644 index 8d6881f..0000000 --- a/GD32F1/libraries/OLED_I2C/DefaultFonts.c +++ /dev/null @@ -1,168 +0,0 @@ -#if defined(__AVR__) - #include - #define fontdatatype const uint8_t -#elif defined(__PIC32MX__) - #define PROGMEM - #define fontdatatype const unsigned char -#elif defined(__arm__) - #define PROGMEM - #define fontdatatype const unsigned char -#endif - -fontdatatype SmallFont[] PROGMEM = -{ -0x06, 0x08, 0x20, 0x5f, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sp -0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // ! -0x00, 0x00, 0x07, 0x00, 0x07, 0x00, // " -0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14, // # -0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12, // $ -0x00, 0x23, 0x13, 0x08, 0x64, 0x62, // % -0x00, 0x36, 0x49, 0x55, 0x22, 0x50, // & -0x00, 0x00, 0x05, 0x03, 0x00, 0x00, // ' -0x00, 0x00, 0x1c, 0x22, 0x41, 0x00, // ( -0x00, 0x00, 0x41, 0x22, 0x1c, 0x00, // ) -0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, // * -0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, // + -0x00, 0x00, 0x00, 0xA0, 0x60, 0x00, // , -0x00, 0x08, 0x08, 0x08, 0x08, 0x08, // - -0x00, 0x00, 0x60, 0x60, 0x00, 0x00, // . -0x00, 0x20, 0x10, 0x08, 0x04, 0x02, // / - -0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0 -0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, // 1 -0x00, 0x42, 0x61, 0x51, 0x49, 0x46, // 2 -0x00, 0x21, 0x41, 0x45, 0x4B, 0x31, // 3 -0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, // 4 -0x00, 0x27, 0x45, 0x45, 0x45, 0x39, // 5 -0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, // 6 -0x00, 0x01, 0x71, 0x09, 0x05, 0x03, // 7 -0x00, 0x36, 0x49, 0x49, 0x49, 0x36, // 8 -0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, // 9 -0x00, 0x00, 0x36, 0x36, 0x00, 0x00, // : -0x00, 0x00, 0x56, 0x36, 0x00, 0x00, // ; -0x00, 0x08, 0x14, 0x22, 0x41, 0x00, // < -0x00, 0x14, 0x14, 0x14, 0x14, 0x14, // = -0x00, 0x00, 0x41, 0x22, 0x14, 0x08, // > -0x00, 0x02, 0x01, 0x51, 0x09, 0x06, // ? - -0x00, 0x32, 0x49, 0x59, 0x51, 0x3E, // @ -0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, // A -0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, // B -0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, // C -0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C, // D -0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, // E -0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, // F -0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A, // G -0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, // H -0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, // I -0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, // J -0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, // K -0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, // L -0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F, // M -0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, // N -0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, // O - -0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, // P -0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, // Q -0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, // R -0x00, 0x46, 0x49, 0x49, 0x49, 0x31, // S -0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, // T -0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, // U -0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, // V -0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, // W -0x00, 0x63, 0x14, 0x08, 0x14, 0x63, // X -0x00, 0x07, 0x08, 0x70, 0x08, 0x07, // Y -0x00, 0x61, 0x51, 0x49, 0x45, 0x43, // Z -0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // [ -0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, // Backslash (Checker pattern) -0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, // ] -0x00, 0x04, 0x02, 0x01, 0x02, 0x04, // ^ -0x00, 0x40, 0x40, 0x40, 0x40, 0x40, // _ - -0x00, 0x00, 0x03, 0x05, 0x00, 0x00, // ` -0x00, 0x20, 0x54, 0x54, 0x54, 0x78, // a -0x00, 0x7F, 0x48, 0x44, 0x44, 0x38, // b -0x00, 0x38, 0x44, 0x44, 0x44, 0x20, // c -0x00, 0x38, 0x44, 0x44, 0x48, 0x7F, // d -0x00, 0x38, 0x54, 0x54, 0x54, 0x18, // e -0x00, 0x08, 0x7E, 0x09, 0x01, 0x02, // f -0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, // g -0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, // h -0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, // i -0x00, 0x40, 0x80, 0x84, 0x7D, 0x00, // j -0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, // k -0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, // l -0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, // m -0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, // n -0x00, 0x38, 0x44, 0x44, 0x44, 0x38, // o - -0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, // p -0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, // q -0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, // r -0x00, 0x48, 0x54, 0x54, 0x54, 0x20, // s -0x00, 0x04, 0x3F, 0x44, 0x40, 0x20, // t -0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, // u -0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, // v -0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, // w -0x00, 0x44, 0x28, 0x10, 0x28, 0x44, // x -0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, // y -0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, // z -0x00, 0x00, 0x10, 0x7C, 0x82, 0x00, // { -0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, // | -0x00, 0x00, 0x82, 0x7C, 0x10, 0x00, // } -0x00, 0x00, 0x06, 0x09, 0x09, 0x06 // ~ (Degrees) -}; - -fontdatatype MediumNumbers[] PROGMEM = -{ -0x0c, 0x10, 0x2d, 0x0d, -0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, // - -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, // . -0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x81, 0x00, 0x00, // / -0x00, 0xfc, 0x7a, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xbc, 0x7e, 0x00, // 0 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0x00, // 1 -0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x81, 0x00, 0x00, // 2 -0x00, 0x00, 0x02, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 3 -0x00, 0xfc, 0x78, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x78, 0xfc, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3d, 0x7e, 0x00, // 4 -0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 5 -0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x02, 0x00, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 6 -0x00, 0x00, 0x02, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7e, 0x00, // 7 -0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x7e, 0xbd, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 8 -0x00, 0xfc, 0x7a, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x7a, 0xfc, 0x00, 0x00, 0x00, 0x81, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xbd, 0x7e, 0x00, // 9 -}; - -fontdatatype BigNumbers[] PROGMEM = -{ -0x0e, 0x18, 0x2d, 0x0d, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xe0, 0xe0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, // . -0x00, 0x00, 0x02, 0x06, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0x80, 0x00, 0x00, // / -0x00, 0xfc, 0xfa, 0xf6, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0xf6, 0xfa, 0xfc, 0x00, 0x00, 0xef, 0xc7, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0xc7, 0xef, 0x00, 0x00, 0x7f, 0xbf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, 0xbf, 0x7f, 0x00, // 0 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0xc7, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x3f, 0x7f, 0x00, // 1 -0x00, 0x00, 0x02, 0x06, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0xf6, 0xfa, 0xfc, 0x00, 0x00, 0xe0, 0xd0, 0xb8, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x3b, 0x17, 0x0f, 0x00, 0x00, 0x7f, 0xbf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0x80, 0x00, 0x00, // 2 -0x00, 0x00, 0x02, 0x06, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0xf6, 0xfa, 0xfc, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0xbb, 0xd7, 0xef, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, 0xbf, 0x7f, 0x00, // 3 -0x00, 0xfc, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8, 0xfc, 0x00, 0x00, 0x0f, 0x17, 0x3b, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0xbb, 0xd7, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x3f, 0x7f, 0x00, // 4 -0x00, 0xfc, 0xfa, 0xf6, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x17, 0x3b, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0xb8, 0xd0, 0xe0, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, 0xbf, 0x7f, 0x00, // 5 -0x00, 0xfc, 0xfa, 0xf6, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0xef, 0xd7, 0xbb, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0xb8, 0xd0, 0xe0, 0x00, 0x00, 0x7f, 0xbf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, 0xbf, 0x7f, 0x00, // 6 -0x00, 0x00, 0x02, 0x06, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0xf6, 0xfa, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0xc7, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x3f, 0x7f, 0x00, // 7 -0x00, 0xfc, 0xfa, 0xf6, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0xf6, 0xfa, 0xfc, 0x00, 0x00, 0xef, 0xd7, 0xbb, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0xbb, 0xd7, 0xef, 0x00, 0x00, 0x7f, 0xbf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, 0xbf, 0x7f, 0x00, // 8 -0x00, 0xfc, 0xfa, 0xf6, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0xf6, 0xfa, 0xfc, 0x00, 0x00, 0x0f, 0x17, 0x3b, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0xbb, 0xd7, 0xef, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, 0xbf, 0x7f, 0x00, // 9 -}; - -fontdatatype TinyFont[] PROGMEM = -{ -0x04, 0x06, 0x20, 0x5f, -0x00, 0x00, 0x00, 0x03, 0xa0, 0x00, 0xc0, 0x0c, 0x00, 0xf9, 0x4f, 0x80, 0x6b, 0xeb, 0x00, 0x98, 0x8c, 0x80, 0x52, 0xa5, 0x80, 0x03, 0x00, 0x00, // Space, !"#$%&' -0x01, 0xc8, 0x80, 0x89, 0xc0, 0x00, 0x50, 0x85, 0x00, 0x21, 0xc2, 0x00, 0x08, 0x40, 0x00, 0x20, 0x82, 0x00, 0x00, 0x20, 0x00, 0x18, 0x8c, 0x00, // ()*+,-./ -0xfa, 0x2f, 0x80, 0x4b, 0xe0, 0x80, 0x5a, 0x66, 0x80, 0x8a, 0xa5, 0x00, 0xe0, 0x8f, 0x80, 0xea, 0xab, 0x00, 0x72, 0xa9, 0x00, 0x9a, 0x8c, 0x00, // 01234567 -0xfa, 0xaf, 0x80, 0x4a, 0xa7, 0x00, 0x01, 0x40, 0x00, 0x09, 0x40, 0x00, 0x21, 0x48, 0x80, 0x51, 0x45, 0x00, 0x89, 0x42, 0x00, 0x42, 0x66, 0x00, // 89:;<=>? -0x72, 0xa6, 0x80, 0x7a, 0x87, 0x80, 0xfa, 0xa5, 0x00, 0x72, 0x25, 0x00, 0xfa, 0x27, 0x00, 0xfa, 0xa8, 0x80, 0xfa, 0x88, 0x00, 0x72, 0x2b, 0x00, // @ABCDEFG -0xf8, 0x8f, 0x80, 0x8b, 0xe8, 0x80, 0x8b, 0xe8, 0x00, 0xf8, 0x8d, 0x80, 0xf8, 0x20, 0x80, 0xf9, 0x0f, 0x80, 0xf9, 0xcf, 0x80, 0x72, 0x27, 0x00, // HIJKLMNO -0xfa, 0x84, 0x00, 0x72, 0x27, 0x40, 0xfa, 0x85, 0x80, 0x4a, 0xa9, 0x00, 0x83, 0xe8, 0x00, 0xf0, 0x2f, 0x00, 0xe0, 0x6e, 0x00, 0xf0, 0xef, 0x00, // PQRSTUVW -0xd8, 0x8d, 0x80, 0xc0, 0xec, 0x00, 0x9a, 0xac, 0x80, 0x03, 0xe8, 0x80, 0xc0, 0x81, 0x80, 0x8b, 0xe0, 0x00, 0x42, 0x04, 0x00, 0x08, 0x20, 0x80, // XYZ[\]^_ -0x02, 0x04, 0x00, 0x31, 0x23, 0x80, 0xf9, 0x23, 0x00, 0x31, 0x24, 0x80, 0x31, 0x2f, 0x80, 0x31, 0x62, 0x80, 0x23, 0xea, 0x00, 0x25, 0x53, 0x80, // `abcdefg -0xf9, 0x03, 0x80, 0x02, 0xe0, 0x00, 0x06, 0xe0, 0x00, 0xf8, 0x42, 0x80, 0x03, 0xe0, 0x00, 0x79, 0x87, 0x80, 0x39, 0x03, 0x80, 0x31, 0x23, 0x00, // hijklmno -0x7d, 0x23, 0x00, 0x31, 0x27, 0xc0, 0x78, 0x84, 0x00, 0x29, 0x40, 0x00, 0x43, 0xe4, 0x00, 0x70, 0x27, 0x00, 0x60, 0x66, 0x00, 0x70, 0x67, 0x00, // pqrstuvw -0x48, 0xc4, 0x80, 0x74, 0x57, 0x80, 0x59, 0xe6, 0x80, 0x23, 0xe8, 0x80, 0x03, 0x60, 0x00, 0x8b, 0xe2, 0x00, 0x61, 0x0c, 0x00 // zyx{|}~ -}; diff --git a/GD32F1/libraries/OLED_I2C/Documentation/OLED_I2C.pdf b/GD32F1/libraries/OLED_I2C/Documentation/OLED_I2C.pdf deleted file mode 100644 index 9076e6b..0000000 Binary files a/GD32F1/libraries/OLED_I2C/Documentation/OLED_I2C.pdf and /dev/null differ diff --git a/GD32F1/libraries/OLED_I2C/Documentation/version.txt b/GD32F1/libraries/OLED_I2C/Documentation/version.txt deleted file mode 100644 index c53f10b..0000000 --- a/GD32F1/libraries/OLED_I2C/Documentation/version.txt +++ /dev/null @@ -1,3 +0,0 @@ -Version: - 1.0 01 Mar 2015 - initial release - 1.01 07 Mar 2015 - fixed a bug in the OLED_I2C_3D_Cube example diff --git a/GD32F1/libraries/OLED_I2C/License/License - CC BY-NC-SA 3.0 - Legal.pdf b/GD32F1/libraries/OLED_I2C/License/License - CC BY-NC-SA 3.0 - Legal.pdf deleted file mode 100644 index ed326c9..0000000 Binary files a/GD32F1/libraries/OLED_I2C/License/License - CC BY-NC-SA 3.0 - Legal.pdf and /dev/null differ diff --git a/GD32F1/libraries/OLED_I2C/License/License - CC BY-NC-SA 3.0 - Summary.pdf b/GD32F1/libraries/OLED_I2C/License/License - CC BY-NC-SA 3.0 - Summary.pdf deleted file mode 100644 index b35e677..0000000 Binary files a/GD32F1/libraries/OLED_I2C/License/License - CC BY-NC-SA 3.0 - Summary.pdf and /dev/null differ diff --git a/GD32F1/libraries/OLED_I2C/OLED_I2C.cpp b/GD32F1/libraries/OLED_I2C/OLED_I2C.cpp deleted file mode 100644 index 8b59f9d..0000000 --- a/GD32F1/libraries/OLED_I2C/OLED_I2C.cpp +++ /dev/null @@ -1,862 +0,0 @@ -/* - OLED_I2C.cpp - Arduino/chipKit library support for 128x64 pixel SSD1306 OLEDs - Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved - - This library has been made to make it easy to use 128x64 pixel OLED displays - based on the SSD1306 controller chip with an Arduino or a chipKit. - - You can always find the latest version of the library at - http://www.RinkyDinkElectronics.com/ - - This library is free software; you can redistribute it and/or - modify it under the terms of the CC BY-NC-SA 3.0 license. - Please see the included documents for further information. - - Commercial use of this library requires you to buy a license that - will allow commercial use. This includes using the library, - modified or not, as a tool to sell products. - - The license applies to all part of the library including the - examples and tools supplied with the library. -*/ - -#include "OLED_I2C.h" -#if defined(__AVR__) - #include - #include "hardware/avr/HW_AVR.h" -#elif defined(__PIC32MX__) - #pragma message("Compiling for PIC32 Architecture...") - #include "hardware/pic32/HW_PIC32.h" -/* -#elif defined(__arm__) - #pragma message("Compiling for ARM Architecture...") - #include "hardware/arm/HW_ARM.h" - */ -#elif defined (__STM32F1__) - #pragma message("Compiling for STM32F1 Architecture...") -#include "hardware/arm/HW_STM32.h" -#endif - -OLED::OLED(uint8_t data_pin, uint8_t sclk_pin, uint8_t rst_pin) -{ - _sda_pin = data_pin; - _scl_pin = sclk_pin; - _rst_pin = rst_pin; -} - -OLED::OLED(uint8_t data_pin, uint8_t sclk_pin) -{ - _sda_pin = data_pin; - _scl_pin = sclk_pin; - _rst_pin = RST_NOT_IN_USE; -} - -void OLED::begin() -{ - if (_rst_pin != RST_NOT_IN_USE) - { - pinMode(_rst_pin, OUTPUT); - digitalWrite(_rst_pin, HIGH); - delay(1); - digitalWrite(_rst_pin, LOW); - delay(10); - digitalWrite(_rst_pin, HIGH); - } - -#if defined(SDA1) & defined(SCL1) - if (((_sda_pin == SDA) and (_scl_pin == SCL)) or ((_sda_pin == SDA1) and (_scl_pin == SCL1))) -#else - if ((_sda_pin == SDA) and (_scl_pin == SCL)) -#endif - { - _use_hw = true; - #pragma message("I2C HW mode enabled") - _initTWI(); - } - else - { - _use_hw = false; - pinMode(_scl_pin, OUTPUT); - #pragma message("SCL pinmode OUTPUT") - } - - _sendTWIcommand(SSD1306_DISPLAY_OFF); - _sendTWIcommand(SSD1306_SET_DISPLAY_CLOCK_DIV_RATIO); - _sendTWIcommand(0x80); - _sendTWIcommand(SSD1306_SET_MULTIPLEX_RATIO); - _sendTWIcommand(0x3F); - _sendTWIcommand(SSD1306_SET_DISPLAY_OFFSET); - _sendTWIcommand(0x0); - _sendTWIcommand(SSD1306_SET_START_LINE | 0x0); - _sendTWIcommand(SSD1306_CHARGE_PUMP); - _sendTWIcommand(0x14); - _sendTWIcommand(SSD1306_MEMORY_ADDR_MODE); - _sendTWIcommand(0x00); - _sendTWIcommand(SSD1306_SET_SEGMENT_REMAP | 0x1); - _sendTWIcommand(SSD1306_COM_SCAN_DIR_DEC); - _sendTWIcommand(SSD1306_SET_COM_PINS); - _sendTWIcommand(0x12); - _sendTWIcommand(SSD1306_SET_CONTRAST_CONTROL); - _sendTWIcommand(0xCF); - _sendTWIcommand(SSD1306_SET_PRECHARGE_PERIOD); - _sendTWIcommand(0xF1); - _sendTWIcommand(SSD1306_SET_VCOM_DESELECT); - _sendTWIcommand(0x40); - _sendTWIcommand(SSD1306_DISPLAY_ALL_ON_RESUME); - _sendTWIcommand(SSD1306_NORMAL_DISPLAY); - _sendTWIcommand(SSD1306_DISPLAY_ON); - - clrScr(); - update(); - cfont.font=0; -} - -void OLED::clrScr() -{ - memset(scrbuf, 0, 1024); -} - -void OLED::fillScr() -{ - memset(scrbuf, 255, 1024); -} - -void OLED::setBrightness(uint8_t value) -{ - _sendTWIcommand(SSD1306_SET_CONTRAST_CONTROL); - _sendTWIcommand(value); -} - -void OLED::invert(bool mode) -{ - if (mode==true) - _sendTWIcommand(SSD1306_INVERT_DISPLAY); - else - _sendTWIcommand(SSD1306_NORMAL_DISPLAY); -} - -void OLED::setPixel(uint16_t x, uint16_t y) -{ - int by, bi; - - if ((x>=0) and (x<128) and (y>=0) and (y<64)) - { - by=((y/8)*128)+x; - bi=y % 8; - - scrbuf[by]=scrbuf[by] | (1<=0) and (x<128) and (y>=0) and (y<64)) - { - by=((y/8)*128)+x; - bi=y % 8; - - scrbuf[by]=scrbuf[by] & ~(1<=0) and (x<128) and (y>=0) and (y<64)) - { - by=((y/8)*128)+x; - bi=y % 8; - - if ((scrbuf[by] & (1<0) - { - buf[c]=48+(num % 10); - c++; - num=(num-(num % 10))/10; - } - buf[c]=0; - - if (neg) - { - st[0]=45; - } - - if (length>(c+neg)) - { - for (int i=0; i<(length-c-neg); i++) - { - st[i+neg]=filler; - f++; - } - } - - for (int i=0; i=0) and (x<128) and (y>=0) and (y<64)) - { - for (int cx=0; cx=0) and (x<128) and (y>=0) and (y<64)) - { - for (int cx=0; cx=0) and (x<128) and (y>=0) and (y<64)) - { - for (int cy=0; cy=0) and (x<128) and (y>=0) and (y<64)) - { - for (int cy=0; cyx2) - { - tmp=x1; - x1=x2; - x2=tmp; - } - drawHLine(x1, y1, x2-x1); - } - else if (x1==x2) - { - if (y1>y2) - { - tmp=y1; - y1=y2; - y2=tmp; - } - drawVLine(x1, y1, y2-y1); - } - else if (abs(x2-x1)>abs(y2-y1)) - { - delta=(double(y2-y1)/double(x2-x1)); - ty=double(y1); - if (x1>x2) - { - for (int i=x1; i>=x2; i--) - { - setPixel(i, int(ty+0.5)); - ty=ty-delta; - } - } - else - { - for (int i=x1; i<=x2; i++) - { - setPixel(i, int(ty+0.5)); - ty=ty+delta; - } - } - } - else - { - delta=(float(x2-x1)/float(y2-y1)); - tx=float(x1); - if (y1>y2) - { - for (int i=y2+1; i>y1; i--) - { - setPixel(int(tx+0.5), i); - tx=tx+delta; - } - } - else - { - for (int i=y1; ix2) - { - tmp=x1; - x1=x2; - x2=tmp; - } - clrHLine(x1, y1, x2-x1); - } - else if (x1==x2) - { - if (y1>y2) - { - tmp=y1; - y1=y2; - y2=tmp; - } - clrVLine(x1, y1, y2-y1); - } - else if (abs(x2-x1)>abs(y2-y1)) - { - delta=(double(y2-y1)/double(x2-x1)); - ty=double(y1); - if (x1>x2) - { - for (int i=x1; i>=x2; i--) - { - clrPixel(i, int(ty+0.5)); - ty=ty-delta; - } - } - else - { - for (int i=x1; i<=x2; i++) - { - clrPixel(i, int(ty+0.5)); - ty=ty+delta; - } - } - } - else - { - delta=(float(x2-x1)/float(y2-y1)); - tx=float(x1); - if (y1>y2) - { - for (int i=y2+1; i>y1; i--) - { - clrPixel(int(tx+0.5), i); - tx=tx+delta; - } - } - else - { - for (int i=y1; ix2) - { - tmp=x1; - x1=x2; - x2=tmp; - } - if (y1>y2) - { - tmp=y1; - y1=y2; - y2=tmp; - } - - drawHLine(x1, y1, x2-x1); - drawHLine(x1, y2, x2-x1); - drawVLine(x1, y1, y2-y1); - drawVLine(x2, y1, y2-y1+1); -} - -void OLED::clrRect(int x1, int y1, int x2, int y2) -{ - int tmp; - - if (x1>x2) - { - tmp=x1; - x1=x2; - x2=tmp; - } - if (y1>y2) - { - tmp=y1; - y1=y2; - y2=tmp; - } - - clrHLine(x1, y1, x2-x1); - clrHLine(x1, y2, x2-x1); - clrVLine(x1, y1, y2-y1); - clrVLine(x2, y1, y2-y1+1); -} - -void OLED::drawRoundRect(int x1, int y1, int x2, int y2) -{ - int tmp; - - if (x1>x2) - { - tmp=x1; - x1=x2; - x2=tmp; - } - if (y1>y2) - { - tmp=y1; - y1=y2; - y2=tmp; - } - if ((x2-x1)>4 && (y2-y1)>4) - { - setPixel(x1+1,y1+1); - setPixel(x2-1,y1+1); - setPixel(x1+1,y2-1); - setPixel(x2-1,y2-1); - drawHLine(x1+2, y1, x2-x1-3); - drawHLine(x1+2, y2, x2-x1-3); - drawVLine(x1, y1+2, y2-y1-3); - drawVLine(x2, y1+2, y2-y1-3); - } -} - -void OLED::clrRoundRect(int x1, int y1, int x2, int y2) -{ - int tmp; - - if (x1>x2) - { - tmp=x1; - x1=x2; - x2=tmp; - } - if (y1>y2) - { - tmp=y1; - y1=y2; - y2=tmp; - } - if ((x2-x1)>4 && (y2-y1)>4) - { - clrPixel(x1+1,y1+1); - clrPixel(x2-1,y1+1); - clrPixel(x1+1,y2-1); - clrPixel(x2-1,y2-1); - clrHLine(x1+2, y1, x2-x1-3); - clrHLine(x1+2, y2, x2-x1-3); - clrVLine(x1, y1+2, y2-y1-3); - clrVLine(x2, y1+2, y2-y1-3); - } -} - -void OLED::drawCircle(int x, int y, int radius) -{ - int f = 1 - radius; - int ddF_x = 1; - int ddF_y = -2 * radius; - int x1 = 0; - int y1 = radius; - char ch, cl; - - setPixel(x, y + radius); - setPixel(x, y - radius); - setPixel(x + radius, y); - setPixel(x - radius, y); - - while(x1 < y1) - { - if(f >= 0) - { - y1--; - ddF_y += 2; - f += ddF_y; - } - x1++; - ddF_x += 2; - f += ddF_x; - setPixel(x + x1, y + y1); - setPixel(x - x1, y + y1); - setPixel(x + x1, y - y1); - setPixel(x - x1, y - y1); - setPixel(x + y1, y + x1); - setPixel(x - y1, y + x1); - setPixel(x + y1, y - x1); - setPixel(x - y1, y - x1); - } -} - -void OLED::clrCircle(int x, int y, int radius) -{ - int f = 1 - radius; - int ddF_x = 1; - int ddF_y = -2 * radius; - int x1 = 0; - int y1 = radius; - char ch, cl; - - clrPixel(x, y + radius); - clrPixel(x, y - radius); - clrPixel(x + radius, y); - clrPixel(x - radius, y); - - while(x1 < y1) - { - if(f >= 0) - { - y1--; - ddF_y += 2; - f += ddF_y; - } - x1++; - ddF_x += 2; - f += ddF_x; - clrPixel(x + x1, y + y1); - clrPixel(x - x1, y + y1); - clrPixel(x + x1, y - y1); - clrPixel(x - x1, y - y1); - clrPixel(x + y1, y + x1); - clrPixel(x - y1, y + x1); - clrPixel(x + y1, y - x1); - clrPixel(x - y1, y - x1); - } -} - -void OLED::drawBitmap(int x, int y, uint8_t* bitmap, int sx, int sy) -{ - int bit; - byte data; - - for (int cy=0; cy0) - setPixel(x+cx, y+cy); - else - clrPixel(x+cx, y+cy); - } - } -} - -// Private - -void OLED::_sendStart(byte addr) -{ - pinMode(_sda_pin, OUTPUT); - digitalWrite(_sda_pin, HIGH); - digitalWrite(_scl_pin, HIGH); - digitalWrite(_sda_pin, LOW); - digitalWrite(_scl_pin, LOW); - shiftOut(_sda_pin, _scl_pin, MSBFIRST, addr); -} - -void OLED::_sendStop() -{ - pinMode(_sda_pin, OUTPUT); - digitalWrite(_sda_pin, LOW); - digitalWrite(_scl_pin, HIGH); - digitalWrite(_sda_pin, HIGH); - pinMode(_sda_pin, INPUT); -} - -void OLED::_sendNack() -{ - pinMode(_sda_pin, OUTPUT); - digitalWrite(_scl_pin, LOW); - digitalWrite(_sda_pin, HIGH); - digitalWrite(_scl_pin, HIGH); - digitalWrite(_scl_pin, LOW); - pinMode(_sda_pin, INPUT); -} - -void OLED::_sendAck() -{ - pinMode(_sda_pin, OUTPUT); - digitalWrite(_scl_pin, LOW); - digitalWrite(_sda_pin, LOW); - digitalWrite(_scl_pin, HIGH); - digitalWrite(_scl_pin, LOW); - pinMode(_sda_pin, INPUT); -} - -void OLED::_waitForAck() -{ - pinMode(_sda_pin, INPUT); - digitalWrite(_scl_pin, HIGH); - while (digitalRead(_sda_pin)==HIGH) {} - digitalWrite(_scl_pin, LOW); -} - -void OLED::_writeByte(uint8_t value) -{ - pinMode(_sda_pin, OUTPUT); - shiftOut(_sda_pin, _scl_pin, MSBFIRST, value); -} - diff --git a/GD32F1/libraries/OLED_I2C/OLED_I2C.h b/GD32F1/libraries/OLED_I2C/OLED_I2C.h deleted file mode 100644 index 4bde83f..0000000 --- a/GD32F1/libraries/OLED_I2C/OLED_I2C.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - OLED_I2C.h - Arduino/chipKit library support for 128x64 pixel SSD1306 OLEDs - Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved - - This library has been made to make it easy to use 128x64 pixel OLED displays - based on the SSD1306 controller chip with an Arduino or a chipKit. - - You can always find the latest version of the library at - http://www.RinkyDinkElectronics.com/ - - This library is free software; you can redistribute it and/or - modify it under the terms of the CC BY-NC-SA 3.0 license. - Please see the included documents for further information. - - Commercial use of this library requires you to buy a license that - will allow commercial use. This includes using the library, - modified or not, as a tool to sell products. - - The license applies to all part of the library including the - examples and tools supplied with the library. -*/ - -#ifndef OLED_I2C_h -#define OLED_I2C_h - -#define SSD1306_ADDR 0x3C - -#define LEFT 0 -#define RIGHT 9999 -#define CENTER 9998 - -#define SSD1306_COMMAND 0x00 -#define SSD1306_DATA 0xC0 -#define SSD1306_DATA_CONTINUE 0x40 - -#define RST_NOT_IN_USE 255 - -// SSD1306 Commandset -// ------------------ -// Fundamental Commands -#define SSD1306_SET_CONTRAST_CONTROL 0x81 -#define SSD1306_DISPLAY_ALL_ON_RESUME 0xA4 -#define SSD1306_DISPLAY_ALL_ON 0xA5 -#define SSD1306_NORMAL_DISPLAY 0xA6 -#define SSD1306_INVERT_DISPLAY 0xA7 -#define SSD1306_DISPLAY_OFF 0xAE -#define SSD1306_DISPLAY_ON 0xAF -#define SSD1306_NOP 0xE3 -// Scrolling Commands -#define SSD1306_HORIZONTAL_SCROLL_RIGHT 0x26 -#define SSD1306_HORIZONTAL_SCROLL_LEFT 0x27 -#define SSD1306_HORIZONTAL_SCROLL_VERTICAL_AND_RIGHT 0x29 -#define SSD1306_HORIZONTAL_SCROLL_VERTICAL_AND_LEFT 0x2A -#define SSD1306_DEACTIVATE_SCROLL 0x2E -#define SSD1306_ACTIVATE_SCROLL 0x2F -#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 -// Addressing Setting Commands -#define SSD1306_SET_LOWER_COLUMN 0x00 -#define SSD1306_SET_HIGHER_COLUMN 0x10 -#define SSD1306_MEMORY_ADDR_MODE 0x20 -#define SSD1306_SET_COLUMN_ADDR 0x21 -#define SSD1306_SET_PAGE_ADDR 0x22 -// Hardware Configuration Commands -#define SSD1306_SET_START_LINE 0x40 -#define SSD1306_SET_SEGMENT_REMAP 0xA0 -#define SSD1306_SET_MULTIPLEX_RATIO 0xA8 -#define SSD1306_COM_SCAN_DIR_INC 0xC0 -#define SSD1306_COM_SCAN_DIR_DEC 0xC8 -#define SSD1306_SET_DISPLAY_OFFSET 0xD3 -#define SSD1306_SET_COM_PINS 0xDA -#define SSD1306_CHARGE_PUMP 0x8D -// Timing & Driving Scheme Setting Commands -#define SSD1306_SET_DISPLAY_CLOCK_DIV_RATIO 0xD5 -#define SSD1306_SET_PRECHARGE_PERIOD 0xD9 -#define SSD1306_SET_VCOM_DESELECT 0xDB - -#if defined(__AVR__) - #include "Arduino.h" - #include "hardware/avr/HW_AVR_defines.h" -#elif defined(__PIC32MX__) - #include "WProgram.h" - #include "hardware/pic32/HW_PIC32_defines.h" -/* -#elif defined(__arm__) - #include "Arduino.h" - #include "hardware/arm/HW_ARM_defines.h" - */ -#elif defined (__STM32F1__) -#include "Arduino.h" -//#include -#include "hardware/arm/HW_STM32_defines.h" -#endif - -struct _current_font -{ - uint8_t* font; - uint8_t x_size; - uint8_t y_size; - uint8_t offset; - uint8_t numchars; - uint8_t inverted; -}; - -class OLED -{ - public: - OLED(uint8_t data_pin, uint8_t sclk_pin, uint8_t rst_pin); - OLED(uint8_t data_pin, uint8_t sclk_pin); - void begin(); - void update(); - void setBrightness(uint8_t value); - void clrScr(); - void fillScr(); - void invert(bool mode); - void setPixel(uint16_t x, uint16_t y); - void clrPixel(uint16_t x, uint16_t y); - void invPixel(uint16_t x, uint16_t y); - void invertText(bool mode); - void print(char *st, int x, int y); - void print(String st, int x, int y); - void printNumI(long num, int x, int y, int length=0, char filler=' '); - void printNumF(double num, byte dec, int x, int y, char divider='.', int length=0, char filler=' '); - void setFont(uint8_t* font); - void drawBitmap(int x, int y, uint8_t* bitmap, int sx, int sy); - void drawLine(int x1, int y1, int x2, int y2); - void clrLine(int x1, int y1, int x2, int y2); - void drawRect(int x1, int y1, int x2, int y2); - void clrRect(int x1, int y1, int x2, int y2); - void drawRoundRect(int x1, int y1, int x2, int y2); - void clrRoundRect(int x1, int y1, int x2, int y2); - void drawCircle(int x, int y, int radius); - void clrCircle(int x, int y, int radius); - - protected: - uint8_t _scl_pin, _sda_pin, _rst_pin; - boolean _use_hw; - _current_font cfont; - uint8_t scrbuf[1024]; - - void _print_char(unsigned char c, int x, int row); - void _convert_float(char *buf, double num, int width, byte prec); - void drawHLine(int x, int y, int l); - void clrHLine(int x, int y, int l); - void drawVLine(int x, int y, int l); - void clrVLine(int x, int y, int l); - - void _initTWI(); - void _sendTWIstart(); - void _sendTWIstop(); - void _sendTWIcommand(uint8_t value); - void _sendStart(byte addr); - void _sendStop(); - void _sendAck(); - void _sendNack(); - void _waitForAck(); - void _writeByte(uint8_t value); -#if defined(__arm__) - // Twi *twi; -#endif -}; - -#endif \ No newline at end of file diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_3D_Cube/OLED_I2C_3D_Cube.ino b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_3D_Cube/OLED_I2C_3D_Cube.ino deleted file mode 100644 index 6b123d4..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_3D_Cube/OLED_I2C_3D_Cube.ino +++ /dev/null @@ -1,158 +0,0 @@ -// OLED_I2C_3D_Cube -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library to rotate a 3D cube. -// The average FPS (Frames Per Second) will be displayed on the screen. -// -// NOTE: The FPS counter will overflow if left for an extended amount of time. -// -// To use the hardware I2C (TWI) interface of the Arduino you must connect -// the pins as follows: -// -// Arduino Uno/2009: -// ---------------------- -// Display: SDA pin -> Arduino Analog 4 or the dedicated SDA pin -// SCL pin -> Arduino Analog 5 or the dedicated SCL pin -// -// Arduino Leonardo: -// ---------------------- -// Display: SDA pin -> Arduino Digital 2 or the dedicated SDA pin -// SCL pin -> Arduino Digital 3 or the dedicated SCL pin -// -// Arduino Mega: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin -// -// Arduino Due: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin -// -// The internal pull-up resistors will be activated when using the -// hardware I2C interfaces. -// -// You can connect the OLED display to any available pin but if you use -// any other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used, and you will also have to use appropriate, external -// pull-up resistors on the data and clock signals. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; - -double vectors[8][3] = {{20, 20, 20},{-20, 20, 20},{-20, -20, 20},{20, -20, 20},{20, 20, -20},{-20, 20, -20},{-20, -20, -20},{20, -20, -20}}; - -double perspective = 100.0f; -int deltaX, deltaY, deltaZ, iter = 0; -long stime, fps = 0, frames = 0; - -void setup() -{ - randomSeed(analogRead(0)); - - myOLED.begin(); - myOLED.setFont(SmallFont); - stime = micros(); -} - -void loop() -{ - myOLED.clrScr(); - drawVectors(); - if (iter == 0) - { - deltaX = random(7) - 3; - deltaY = random(7) - 3; - deltaZ = random(7) - 3; - iter = random(250) + 5; - } - rotateX(deltaX); - rotateY(deltaY); - rotateZ(deltaZ); - iter--; - fps += 1000000 / (micros() - stime); - stime = micros(); - frames++; - myOLED.printNumI(fps / frames, 0, 0, 3); // Print average FPS on screen - myOLED.update(); -} - -int translateX(double x, double z) -{ - return (int)((x + 64) + (z * (x / perspective))); -} - -int translateY(double y, double z) -{ - return (int)((y + 32) + (z * (y / perspective))); -} - -void rotateX(int angle) -{ - double rad, cosa, sina, Yn, Zn; - - rad = angle * PI / 180; - cosa = cos(rad); - sina = sin(rad); - for (int i = 0; i < 8; i++) - { - Yn = (vectors[i][1] * cosa) - (vectors[i][2] * sina); - Zn = (vectors[i][1] * sina) + (vectors[i][2] * cosa); - vectors[i][1] = Yn; - vectors[i][2] = Zn; - } -} - -void rotateY(int angle) -{ - double rad, cosa, sina, Xn, Zn; - - rad = angle * PI / 180; - cosa = cos(rad); - sina = sin(rad); - for (int i = 0; i < 8; i++) - { - Xn = (vectors[i][0] * cosa) - (vectors[i][2] * sina); - Zn = (vectors[i][0] * sina) + (vectors[i][2] * cosa); - vectors[i][0] = Xn; - vectors[i][2] = Zn; - } -} - -void rotateZ(int angle) -{ - double rad, cosa, sina, Xn, Yn; - - rad = angle * PI / 180; - cosa = cos(rad); - sina = sin(rad); - for (int i = 0; i < 8; i++) - { - Xn = (vectors[i][0] * cosa) - (vectors[i][1] * sina); - Yn = (vectors[i][0] * sina) + (vectors[i][1] * cosa); - vectors[i][0] = Xn; - vectors[i][1] = Yn; - } -} - -void drawVectors() -{ - myOLED.drawLine(translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2]), translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2])); - myOLED.drawLine(translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2]), translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2])); - myOLED.drawLine(translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2]), translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2])); - myOLED.drawLine(translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2]), translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2])); - myOLED.drawLine(translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2]), translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2])); - myOLED.drawLine(translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2]), translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2])); - myOLED.drawLine(translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2]), translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2])); - myOLED.drawLine(translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2]), translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2])); - myOLED.drawLine(translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2]), translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2])); - myOLED.drawLine(translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2]), translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2])); - myOLED.drawLine(translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2]), translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2])); - myOLED.drawLine(translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2]), translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2])); -} diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Bitmap/OLED_I2C_Bitmap.ino b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Bitmap/OLED_I2C_Bitmap.ino deleted file mode 100644 index cd4b945..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Bitmap/OLED_I2C_Bitmap.ino +++ /dev/null @@ -1,81 +0,0 @@ -// OLED_I2C_Bitmap -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the Arduino you must connect -// the pins as follows: -// -// Arduino Uno/2009: -// ---------------------- -// Display: SDA pin -> Arduino Analog 4 or the dedicated SDA pin -// SCL pin -> Arduino Analog 5 or the dedicated SCL pin -// -// Arduino Leonardo: -// ---------------------- -// Display: SDA pin -> Arduino Digital 2 or the dedicated SDA pin -// SCL pin -> Arduino Digital 3 or the dedicated SCL pin -// -// Arduino Mega: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin -// -// Arduino Due: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin -// -// The internal pull-up resistors will be activated when using the -// hardware I2C interfaces. -// -// You can connect the OLED display to any available pin but if you use -// any other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used, and you will also have to use appropriate, external -// pull-up resistors on the data and clock signals. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t logo[]; -extern uint8_t mice[]; - -void setup() -{ - myOLED.begin(); -} - -void loop() -{ - myOLED.clrScr(); - myOLED.drawBitmap(0, 16, logo, 128, 36); - myOLED.update(); - delay(4000); - for (int i=0; i<2; i++) - { - myOLED.invert(true); - delay(500); - myOLED.invert(false); - delay(500); - } - delay(4000); - - myOLED.clrScr(); - myOLED.drawBitmap(0, 0, mice, 128, 64); - myOLED.update(); - delay(4000); - for (int i=0; i<2; i++) - { - myOLED.invert(true); - delay(500); - myOLED.invert(false); - delay(500); - } - delay(4000); -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Bitmap/graphics.c b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Bitmap/graphics.c deleted file mode 100644 index 7cc2fdf..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Bitmap/graphics.c +++ /dev/null @@ -1,112 +0,0 @@ -#include - -const uint8_t logo[] PROGMEM={ -0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08, 0x08, // 0x0010 (16) pixels -0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x1F, 0xFF, 0xFE, 0x83, // 0x0020 (32) pixels -0x83, 0xC2, 0xC6, 0x7E, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x20, 0xE7, 0xE7, 0x00, 0x00, 0x00, 0x00, // 0x0030 (48) pixels -0x20, 0x70, 0xE0, 0xC0, 0x20, 0x30, 0x30, 0xE0, 0xC0, 0x00, 0x00, 0x03, 0x03, 0xFE, 0xFE, 0x00, // 0x0040 (64) pixels -0x20, 0xE0, 0x60, 0x20, 0x20, 0x00, 0x00, 0x40, 0xE0, 0xE0, 0x40, 0x00, 0x40, 0xE0, 0x60, 0x00, // 0x0050 (80) pixels -0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFF, 0xFF, 0xEF, 0x03, 0x02, 0x02, 0x02, 0x06, 0xFC, 0xF8, // 0x0060 (96) pixels -0xE0, 0x00, 0x00, 0x00, 0x20, 0xE7, 0xE7, 0x00, 0x00, 0x00, 0x20, 0x70, 0xE0, 0xC0, 0x20, 0x30, // 0x0070 (112) pixels -0x30, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x03, 0xFE, 0xFE, 0x00, 0x20, 0xE0, 0x60, 0x20, 0x20, // 0x0080 (128) pixels -0x00, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, // 0x0090 (144) pixels -0x90, 0x7F, 0x90, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3C, 0x3F, 0x3F, 0x20, // 0x00A0 (160) pixels -0x00, 0x00, 0x07, 0x3F, 0x3C, 0x30, 0x30, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x30, 0x00, 0x00, 0x00, // 0x00B0 (176) pixels -0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x20, 0x20, 0x3F, 0x3F, 0x22, // 0x00C0 (192) pixels -0x27, 0x2F, 0x38, 0x30, 0x20, 0x00, 0x00, 0x00, 0x01, 0x0F, 0xBC, 0x60, 0x1E, 0x01, 0x00, 0x01, // 0x00D0 (208) pixels -0x01, 0x01, 0x01, 0x01, 0x20, 0x20, 0x3F, 0x3F, 0x3F, 0x20, 0x20, 0x20, 0x20, 0x30, 0x1F, 0x0F, // 0x00E0 (224) pixels -0x03, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x30, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, // 0x00F0 (240) pixels -0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x3F, 0x22, 0x27, 0x2F, 0x38, 0x30, 0x20, // 0x0100 (256) pixels -0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, // 0x0110 (272) pixels -0x01, 0x00, 0x01, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, // 0x0120 (288) pixels -0xE0, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x00, 0x00, 0x40, 0xC0, 0xC0, 0x00, 0x00, 0x00, // 0x0130 (304) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0140 (320) pixels -0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x03, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0150 (336) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0160 (352) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0170 (368) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0180 (384) pixels -0x00, 0x00, 0x0F, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, // 0x0190 (400) pixels -0x01, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // 0x01A0 (416) pixels -0xFF, 0x9F, 0x18, 0x18, 0x3E, 0x00, 0x00, 0x87, 0xC0, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 0x01B0 (432) pixels -0x60, 0xF8, 0xFC, 0x46, 0x26, 0x2E, 0x3C, 0xB8, 0x00, 0xE0, 0xF8, 0x08, 0x0C, 0x0C, 0x7C, 0x38, // 0x01C0 (448) pixels -0x00, 0x06, 0x06, 0xFF, 0x0E, 0x06, 0x84, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x08, 0x0C, 0x0C, 0x08, // 0x01D0 (464) pixels -0x00, 0xF0, 0xF8, 0x1C, 0x06, 0x02, 0x04, 0xFC, 0xF8, 0xF0, 0x00, 0x04, 0xEE, 0xFC, 0x18, 0x04, // 0x01E0 (480) pixels -0x06, 0x06, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x08, // 0x01F0 (496) pixels -0x0C, 0x0C, 0x7C, 0x38, 0x00, 0x00, 0x7C, 0x7C, 0x64, 0xC4, 0xDC, 0xCC, 0x80, 0x00, 0x00, 0x00, // 0x0200 (512) pixels -0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xFF, 0xF1, 0xF1, 0xF1, 0xF1, // 0x0210 (528) pixels -0xF1, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF4, 0xF4, 0xF7, // 0x0220 (544) pixels -0xF7, 0xF7, 0xF4, 0xF4, 0xF4, 0xF6, 0xF6, 0xF7, 0xF3, 0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, // 0x0230 (560) pixels -0xF0, 0xF3, 0xF7, 0xF4, 0xF4, 0xF4, 0xF6, 0xF1, 0xF0, 0xF1, 0xF7, 0xF6, 0xFC, 0xFC, 0xF4, 0xF7, // 0x0240 (576) pixels -0xF0, 0xF0, 0xF0, 0xF7, 0xFE, 0xF4, 0xF7, 0xF0, 0xF0, 0xF6, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, 0xF0, // 0x0250 (592) pixels -0xF0, 0xF0, 0xF3, 0xF6, 0xF4, 0xF4, 0xF4, 0xF7, 0xF3, 0xF0, 0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, // 0x0260 (608) pixels -0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, 0xF4, 0xF7, 0xF7, 0xF6, 0xF0, 0xF0, 0xF1, 0xF7, 0xF6, // 0x0270 (624) pixels -0xFC, 0xFC, 0xF4, 0xF7, 0xF0, 0xF0, 0xFF, 0xF6, 0xF4, 0xF8, 0xF8, 0xF7, 0xF1, 0xF0, 0xF0, 0xF0, // 0x0280 (640) pixels -}; - -const uint8_t mice[] PROGMEM={ -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0010 (16) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, // 0x0020 (32) pixels -0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0030 (48) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0040 (64) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0050 (80) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0xCF, 0xCF, 0xEF, 0xCF, 0x9F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, // 0x0060 (96) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x9F, 0x9F, 0xDF, 0xCF, 0xCF, 0xCF, // 0x0070 (112) pixels -0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0080 (128) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0090 (144) pixels -0xFF, 0xFF, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00A0 (160) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x00B0 (176) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x00C0 (192) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x00D0 (208) pixels -0xFF, 0xFF, 0xFF, 0x07, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xE1, 0x07, 0x3F, // 0x00E0 (224) pixels -0xFF, 0xFF, 0x7F, 0x1F, 0x47, 0x33, 0x98, 0xCC, 0xE6, 0xF3, 0xF9, 0xFE, 0xFF, 0xFF, 0x3F, 0x07, // 0x00F0 (240) pixels -0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0100 (256) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0110 (272) pixels -0xFF, 0xFF, 0xFC, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0120 (288) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0130 (304) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0140 (320) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x07, 0x03, 0x01, 0x01, 0x00, // 0x0150 (336) pixels -0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xF7, 0xE6, 0x00, // 0x0160 (352) pixels -0x33, 0xF9, 0xF0, 0x04, 0x0E, 0xCF, 0xEF, 0xE7, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x00, 0x03, // 0x0170 (368) pixels -0x03, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0180 (384) pixels -0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1F, // 0x0190 (400) pixels -0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1E, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x01A0 (416) pixels -0x00, 0x00, 0x00, 0x00, 0xF0, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xF9, 0xF1, 0xC3, // 0x01B0 (432) pixels -0x87, 0xCF, 0x9F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x01C0 (448) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x01D0 (464) pixels -0x00, 0x00, 0x3F, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0xDF, 0xCF, 0xEF, 0xE7, 0xB7, 0x33, 0x11, 0x30, // 0x01E0 (480) pixels -0xC6, 0xC7, 0xE3, 0x10, 0x32, 0x17, 0x67, 0xAF, 0xCF, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F, 0x00, 0x00, // 0x01F0 (496) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0200 (512) pixels -0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0210 (528) pixels -0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0220 (544) pixels -0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x01, 0xC1, 0xF1, // 0x0230 (560) pixels -0x07, 0x3F, 0x0F, 0x87, 0x0C, 0x01, 0x0F, 0x7F, 0x1F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x0F, 0xFF, // 0x0240 (576) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF8, 0xF0, // 0x0250 (592) pixels -0x30, 0x08, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, 0x3E, 0x3C, // 0x0260 (608) pixels -0x03, 0x8F, 0x01, 0x3C, 0x3E, 0x00, 0x83, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x70, // 0x0270 (624) pixels -0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0280 (640) pixels -0xFF, 0xF8, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0290 (656) pixels -0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0xE0, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0x7E, 0x7C, // 0x02A0 (672) pixels -0x3C, 0x3C, 0x3C, 0x78, 0x78, 0xF1, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF3, 0xE7, // 0x02B0 (688) pixels -0xF0, 0xF8, 0xF0, 0xF3, 0xF8, 0xF8, 0xFC, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xFF, // 0x02C0 (704) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x02D0 (720) pixels -0x80, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0x63, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x08, 0x00, // 0x02E0 (736) pixels -0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0xFF, 0x3F, 0x39, 0x78, 0xF8, 0xF8, 0x60, 0x00, // 0x02F0 (752) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0300 (768) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, // 0x0310 (784) pixels -0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xE7, 0xCF, 0x9F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, // 0x0320 (800) pixels -0xF8, 0xE3, 0xCF, 0xBF, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0330 (816) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x9F, 0xCF, 0xE3, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, // 0x0340 (832) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0350 (848) pixels -0xFF, 0xFC, 0xF9, 0xF3, 0xE7, 0xCE, 0xDE, 0x9C, 0xB9, 0x33, 0x67, 0x87, 0x0F, 0x4F, 0x8F, 0x8F, // 0x0360 (864) pixels -0x8E, 0x8E, 0x8E, 0x8E, 0x07, 0x87, 0xF3, 0x79, 0x7D, 0x3E, 0x9F, 0xCF, 0xE7, 0xF3, 0xF8, 0xFE, // 0x0370 (880) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0380 (896) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0390 (912) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, // 0x03A0 (928) pixels -0xFE, 0xFC, 0xFC, 0xFC, 0xFD, 0xF8, 0xFA, 0xF8, 0xF8, 0xF9, 0xF9, 0xFD, 0xF9, 0xF9, 0xF9, 0xF9, // 0x03B0 (944) pixels -0xF9, 0xFD, 0xFD, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x03C0 (960) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x03D0 (976) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF9, 0xF8, 0xF0, 0xF1, // 0x03E0 (992) pixels -0xF1, 0xF1, 0xF1, 0xF8, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x03F0 (1008) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0400 (1024) pixels -}; - diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Brightness/OLED_I2C_Brightness.ino b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Brightness/OLED_I2C_Brightness.ino deleted file mode 100644 index bda13e4..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Brightness/OLED_I2C_Brightness.ino +++ /dev/null @@ -1,64 +0,0 @@ -// OLED_I2C_Brightness -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the Arduino you must connect -// the pins as follows: -// -// Arduino Uno/2009: -// ---------------------- -// Display: SDA pin -> Arduino Analog 4 or the dedicated SDA pin -// SCL pin -> Arduino Analog 5 or the dedicated SCL pin -// -// Arduino Leonardo: -// ---------------------- -// Display: SDA pin -> Arduino Digital 2 or the dedicated SDA pin -// SCL pin -> Arduino Digital 3 or the dedicated SCL pin -// -// Arduino Mega: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin -// -// Arduino Due: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin -// -// The internal pull-up resistors will be activated when using the -// hardware I2C interfaces. -// -// You can connect the OLED display to any available pin but if you use -// any other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used, and you will also have to use appropriate, external -// pull-up resistors on the data and clock signals. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -void setup() -{ - myOLED.begin(); - myOLED.invert(true); -} - -void loop() -{ - for (int i=0; i<256; i++) - { - myOLED.setBrightness(i); - delay(5); - } - for (int i=255; i>=0; i--) - { - myOLED.setBrightness(i); - delay(5); - } -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Graph_Demo/OLED_I2C_Graph_Demo.ino b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Graph_Demo/OLED_I2C_Graph_Demo.ino deleted file mode 100644 index 1c7f619..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Graph_Demo/OLED_I2C_Graph_Demo.ino +++ /dev/null @@ -1,195 +0,0 @@ -// OLED_I2C_Graph_Demo -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the Arduino you must connect -// the pins as follows: -// -// Arduino Uno/2009: -// ---------------------- -// Display: SDA pin -> Arduino Analog 4 or the dedicated SDA pin -// SCL pin -> Arduino Analog 5 or the dedicated SCL pin -// -// Arduino Leonardo: -// ---------------------- -// Display: SDA pin -> Arduino Digital 2 or the dedicated SDA pin -// SCL pin -> Arduino Digital 3 or the dedicated SCL pin -// -// Arduino Mega: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin -// -// Arduino Due: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin -// -// The internal pull-up resistors will be activated when using the -// hardware I2C interfaces. -// -// You can connect the OLED display to any available pin but if you use -// any other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used, and you will also have to use appropriate, external -// pull-up resistors on the data and clock signals. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; -extern uint8_t logo[]; -extern uint8_t The_End[]; -extern uint8_t pacman1[]; -extern uint8_t pacman2[]; -extern uint8_t pacman3[]; -extern uint8_t pill[]; - -float y; -uint8_t* bm; -int pacy; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(SmallFont); - randomSeed(analogRead(7)); -} - -void loop() -{ - myOLED.clrScr(); - myOLED.drawBitmap(0, 16, logo, 128, 36); - myOLED.update(); - - delay(3000); - - myOLED.clrScr(); - myOLED.print("OLED_I2C", CENTER, 0); - myOLED.print("DEMO", CENTER, 28); - myOLED.drawRect(50, 26, 78, 36); - for (int i=0; i<6; i++) - { - myOLED.drawLine(79, 26+(i*2), 105-(i*3), 26+(i*2)); - myOLED.drawLine(22+(i*3), 36-(i*2), 50, 36-(i*2)); - } - myOLED.print("(C)2015 by", CENTER, 48); - myOLED.print("Henning Karlsen", CENTER, 56); - myOLED.update(); - - delay(5000); - - myOLED.clrScr(); - for (int i=0; i<64; i+=2) - { - myOLED.drawLine(0, i, 127, 63-i); - myOLED.update(); - } - for (int i=127; i>=0; i-=2) - { - myOLED.drawLine(i, 0, 127-i, 63); - myOLED.update(); - } - - delay(2000); - - myOLED.clrScr(); - myOLED.drawRect(0, 0, 127, 63); - for (int i=0; i<64; i+=4) - { - myOLED.drawLine(0, i, i*2, 63); - myOLED.update(); - } - for (int i=0; i<64; i+=4) - { - myOLED.drawLine(127, 63-i, 127-(i*2), 0); - myOLED.update(); - } - - delay(2000); - - myOLED.clrScr(); - for (int i=0; i<10; i++) - { - myOLED.drawRoundRect(i*3, i*3, 127-(i*3), 63-(i*3)); - myOLED.update(); - } - - delay(2000); - - myOLED.clrScr(); - for (int i=0; i<25; i++) - { - myOLED.drawCircle(64, 32, i*3); - myOLED.update(); - } - - delay(2000); - - myOLED.clrScr(); - myOLED.drawRect(0, 0, 127, 63); - myOLED.drawLine(0, 31, 127, 31); - myOLED.drawLine(63, 0, 63, 63); - for (int c=0; c<4; c++) - { - for (int i=0; i<128; i++) - { - y=i*0.04974188368183839294232518690191; - myOLED.invPixel(i, (sin(y)*28)+31); - myOLED.update(); - delay(10); - } - } - - delay(2000); - - for (int pc=0; pc<3; pc++) - { - pacy=random(0, 44); - - for (int i=-20; i<132; i++) - { - myOLED.clrScr(); - for (int p=6; p>((i+20)/20); p--) - myOLED.drawBitmap(p*20-8, pacy+7, pill, 5, 5); - switch(((i+20)/3) % 4) - { - case 0: bm=pacman1; - break; - case 1: bm=pacman2; - break; - case 2: bm=pacman3; - break; - case 3: bm=pacman2; - break; - } - myOLED.drawBitmap(i, pacy, bm, 20, 20); - myOLED.update(); - delay(10); - } - } - - for (int i=0; i<41; i++) - { - myOLED.clrScr(); - myOLED.drawBitmap(22, i-24, The_End, 84, 24); - myOLED.update(); - delay(50); - } - myOLED.print("Runtime (ms):", CENTER, 48); - myOLED.printNumI(millis(), CENTER, 56); - myOLED.update(); - for (int i=0; i<5; i++) - { - myOLED.invert(true); - delay(1000); - myOLED.invert(false); - delay(1000); - } -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Graph_Demo/graphics.c b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Graph_Demo/graphics.c deleted file mode 100644 index ece23be..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Graph_Demo/graphics.c +++ /dev/null @@ -1,89 +0,0 @@ -#include - -const uint8_t logo[] PROGMEM={ -0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08, 0x08, // 0x0010 (16) pixels -0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x1F, 0xFF, 0xFE, 0x83, // 0x0020 (32) pixels -0x83, 0xC2, 0xC6, 0x7E, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x20, 0xE7, 0xE7, 0x00, 0x00, 0x00, 0x00, // 0x0030 (48) pixels -0x20, 0x70, 0xE0, 0xC0, 0x20, 0x30, 0x30, 0xE0, 0xC0, 0x00, 0x00, 0x03, 0x03, 0xFE, 0xFE, 0x00, // 0x0040 (64) pixels -0x20, 0xE0, 0x60, 0x20, 0x20, 0x00, 0x00, 0x40, 0xE0, 0xE0, 0x40, 0x00, 0x40, 0xE0, 0x60, 0x00, // 0x0050 (80) pixels -0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFF, 0xFF, 0xEF, 0x03, 0x02, 0x02, 0x02, 0x06, 0xFC, 0xF8, // 0x0060 (96) pixels -0xE0, 0x00, 0x00, 0x00, 0x20, 0xE7, 0xE7, 0x00, 0x00, 0x00, 0x20, 0x70, 0xE0, 0xC0, 0x20, 0x30, // 0x0070 (112) pixels -0x30, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x03, 0xFE, 0xFE, 0x00, 0x20, 0xE0, 0x60, 0x20, 0x20, // 0x0080 (128) pixels -0x00, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, // 0x0090 (144) pixels -0x90, 0x7F, 0x90, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3C, 0x3F, 0x3F, 0x20, // 0x00A0 (160) pixels -0x00, 0x00, 0x07, 0x3F, 0x3C, 0x30, 0x30, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x30, 0x00, 0x00, 0x00, // 0x00B0 (176) pixels -0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x20, 0x20, 0x3F, 0x3F, 0x22, // 0x00C0 (192) pixels -0x27, 0x2F, 0x38, 0x30, 0x20, 0x00, 0x00, 0x00, 0x01, 0x0F, 0xBC, 0x60, 0x1E, 0x01, 0x00, 0x01, // 0x00D0 (208) pixels -0x01, 0x01, 0x01, 0x01, 0x20, 0x20, 0x3F, 0x3F, 0x3F, 0x20, 0x20, 0x20, 0x20, 0x30, 0x1F, 0x0F, // 0x00E0 (224) pixels -0x03, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x30, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, // 0x00F0 (240) pixels -0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x3F, 0x22, 0x27, 0x2F, 0x38, 0x30, 0x20, // 0x0100 (256) pixels -0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, // 0x0110 (272) pixels -0x01, 0x00, 0x01, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, // 0x0120 (288) pixels -0xE0, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x00, 0x00, 0x40, 0xC0, 0xC0, 0x00, 0x00, 0x00, // 0x0130 (304) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0140 (320) pixels -0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x03, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0150 (336) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0160 (352) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0170 (368) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0180 (384) pixels -0x00, 0x00, 0x0F, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, // 0x0190 (400) pixels -0x01, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // 0x01A0 (416) pixels -0xFF, 0x9F, 0x18, 0x18, 0x3E, 0x00, 0x00, 0x87, 0xC0, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 0x01B0 (432) pixels -0x60, 0xF8, 0xFC, 0x46, 0x26, 0x2E, 0x3C, 0xB8, 0x00, 0xE0, 0xF8, 0x08, 0x0C, 0x0C, 0x7C, 0x38, // 0x01C0 (448) pixels -0x00, 0x06, 0x06, 0xFF, 0x0E, 0x06, 0x84, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x08, 0x0C, 0x0C, 0x08, // 0x01D0 (464) pixels -0x00, 0xF0, 0xF8, 0x1C, 0x06, 0x02, 0x04, 0xFC, 0xF8, 0xF0, 0x00, 0x04, 0xEE, 0xFC, 0x18, 0x04, // 0x01E0 (480) pixels -0x06, 0x06, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x08, // 0x01F0 (496) pixels -0x0C, 0x0C, 0x7C, 0x38, 0x00, 0x00, 0x7C, 0x7C, 0x64, 0xC4, 0xDC, 0xCC, 0x80, 0x00, 0x00, 0x00, // 0x0200 (512) pixels -0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xFF, 0xF1, 0xF1, 0xF1, 0xF1, // 0x0210 (528) pixels -0xF1, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF4, 0xF4, 0xF7, // 0x0220 (544) pixels -0xF7, 0xF7, 0xF4, 0xF4, 0xF4, 0xF6, 0xF6, 0xF7, 0xF3, 0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, // 0x0230 (560) pixels -0xF0, 0xF3, 0xF7, 0xF4, 0xF4, 0xF4, 0xF6, 0xF1, 0xF0, 0xF1, 0xF7, 0xF6, 0xFC, 0xFC, 0xF4, 0xF7, // 0x0240 (576) pixels -0xF0, 0xF0, 0xF0, 0xF7, 0xFE, 0xF4, 0xF7, 0xF0, 0xF0, 0xF6, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, 0xF0, // 0x0250 (592) pixels -0xF0, 0xF0, 0xF3, 0xF6, 0xF4, 0xF4, 0xF4, 0xF7, 0xF3, 0xF0, 0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, // 0x0260 (608) pixels -0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, 0xF4, 0xF7, 0xF7, 0xF6, 0xF0, 0xF0, 0xF1, 0xF7, 0xF6, // 0x0270 (624) pixels -0xFC, 0xFC, 0xF4, 0xF7, 0xF0, 0xF0, 0xFF, 0xF6, 0xF4, 0xF8, 0xF8, 0xF7, 0xF1, 0xF0, 0xF0, 0xF0, // 0x0280 (640) pixels -}; - -const uint8_t The_End[] PROGMEM={ -0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0x60, 0x00, 0x00, // 0x0010 (16) pixels -0x80, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, // 0x0020 (32) pixels -0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, // 0x0030 (48) pixels -0xE0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0x00, 0x00, // 0x0040 (64) pixels -0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF0, 0x60, 0x40, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, // 0x0050 (80) pixels -0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x81, 0xFC, 0xFF, 0x0F, 0x03, 0x00, 0x00, 0x00, // 0x0060 (96) pixels -0xEE, 0x6F, 0x67, 0xFF, 0xFF, 0x7F, 0x71, 0x30, 0xF0, 0xFF, 0x3F, 0x39, 0x38, 0x18, 0x00, 0x01, // 0x0070 (112) pixels -0x00, 0xF8, 0xFF, 0x1F, 0x0F, 0x0C, 0x0D, 0x8D, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // 0x0080 (128) pixels -0x00, 0xC0, 0xFF, 0x7F, 0x0F, 0x0C, 0x0D, 0x0D, 0x84, 0x80, 0x80, 0x07, 0x07, 0x83, 0xFF, 0xFF, // 0x0090 (144) pixels -0x1F, 0x3F, 0xFE, 0xF8, 0xF8, 0xFE, 0xDF, 0x03, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x1F, 0x00, // 0x00A0 (160) pixels -0x00, 0x80, 0x81, 0xC3, 0xE7, 0x7F, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, 0x07, 0x03, 0x00, // 0x00B0 (176) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x0F, 0x0F, 0x07, 0x00, // 0x00C0 (192) pixels -0x00, 0x06, 0x06, 0x3F, 0x1F, 0x0F, 0x0F, 0x0E, 0x06, 0x06, 0x06, 0x07, 0x07, 0x03, 0x00, 0x00, // 0x00D0 (208) pixels -0x00, 0x00, 0x06, 0x1F, 0x3F, 0x1F, 0x0F, 0x0E, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x03, 0x00, // 0x00E0 (224) pixels -0x06, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x18, 0x1C, 0x1F, // 0x00F0 (240) pixels -0x0F, 0x07, 0x06, 0x07, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, -}; - -const uint8_t pacman1[] PROGMEM={ -0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3E, 0x1C, // 0x0010 (16) pixels -0x0C, 0x00, 0x00, 0x00, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, // 0x0020 (32) pixels -0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels -0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00, -}; - -const uint8_t pacman2[] PROGMEM={ -0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x7C, // 0x0010 (16) pixels -0x7C, 0x38, 0x20, 0x00, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, // 0x0020 (32) pixels -0xF9, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels -0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, -}; - -const uint8_t pacman3[] PROGMEM={ -0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, // 0x0010 (16) pixels -0xF8, 0xF0, 0xE0, 0x80, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0020 (32) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xF9, 0x79, 0x19, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels -0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, -}; - -const uint8_t pill[] PROGMEM={ -0x0E, 0x1F, 0x1F, 0x1F, 0x0E, -}; - diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_NumberFonts/OLED_I2C_NumberFonts.ino b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_NumberFonts/OLED_I2C_NumberFonts.ino deleted file mode 100644 index 94b32e3..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_NumberFonts/OLED_I2C_NumberFonts.ino +++ /dev/null @@ -1,79 +0,0 @@ -// OLED_I2C_NumberFonts -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the Arduino you must connect -// the pins as follows: -// -// Arduino Uno/2009: -// ---------------------- -// Display: SDA pin -> Arduino Analog 4 or the dedicated SDA pin -// SCL pin -> Arduino Analog 5 or the dedicated SCL pin -// -// Arduino Leonardo: -// ---------------------- -// Display: SDA pin -> Arduino Digital 2 or the dedicated SDA pin -// SCL pin -> Arduino Digital 3 or the dedicated SCL pin -// -// Arduino Mega: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin -// -// Arduino Due: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin -// -// The internal pull-up resistors will be activated when using the -// hardware I2C interfaces. -// -// You can connect the OLED display to any available pin but if you use -// any other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used, and you will also have to use appropriate, external -// pull-up resistors on the data and clock signals. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; -extern uint8_t MediumNumbers[]; -extern uint8_t BigNumbers[]; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(SmallFont); -} - -void loop() -{ - for (int i=0; i<=10000; i++) - { - myOLED.setFont(MediumNumbers); - myOLED.printNumF(float(i)/3, 2, RIGHT, 0); - myOLED.setFont(BigNumbers); - myOLED.printNumI(i, RIGHT, 40); - myOLED.update(); - } - - myOLED.setFont(SmallFont); - myOLED.print("|", LEFT, 24); - myOLED.print("|", RIGHT, 24); - myOLED.update(); - delay(500); - for (int i=0; i<19; i++) - { - myOLED.print("\\", 7+(i*6), 24); - myOLED.update(); - delay(250); - } - myOLED.clrScr(); -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Scrolling_Text/OLED_I2C_Scrolling_Text.ino b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Scrolling_Text/OLED_I2C_Scrolling_Text.ino deleted file mode 100644 index e5e803d..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_Scrolling_Text/OLED_I2C_Scrolling_Text.ino +++ /dev/null @@ -1,64 +0,0 @@ -// OLED_I2C_Scrolling_Text -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the Arduino you must connect -// the pins as follows: -// -// Arduino Uno/2009: -// ---------------------- -// Display: SDA pin -> Arduino Analog 4 or the dedicated SDA pin -// SCL pin -> Arduino Analog 5 or the dedicated SCL pin -// -// Arduino Leonardo: -// ---------------------- -// Display: SDA pin -> Arduino Digital 2 or the dedicated SDA pin -// SCL pin -> Arduino Digital 3 or the dedicated SCL pin -// -// Arduino Mega: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin -// -// Arduino Due: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin -// -// The internal pull-up resistors will be activated when using the -// hardware I2C interfaces. -// -// You can connect the OLED display to any available pin but if you use -// any other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used, and you will also have to use appropriate, external -// pull-up resistors on the data and clock signals. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(SmallFont); - randomSeed(analogRead(0)); -} - -void loop() -{ - int y = random(0, 56); - for (int i=128; i>=-(34*6); i--) - { - myOLED.print("OLED_I2C Scrolling Text Demo ", i, y); - myOLED.update(); - delay(50); - } -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_TinyFont_View/OLED_I2C_TinyFont_View.ino b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_TinyFont_View/OLED_I2C_TinyFont_View.ino deleted file mode 100644 index 87bc261..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_TinyFont_View/OLED_I2C_TinyFont_View.ino +++ /dev/null @@ -1,65 +0,0 @@ -// OLED_I2C_TinyFont_View -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the Arduino you must connect -// the pins as follows: -// -// Arduino Uno/2009: -// ---------------------- -// Display: SDA pin -> Arduino Analog 4 or the dedicated SDA pin -// SCL pin -> Arduino Analog 5 or the dedicated SCL pin -// -// Arduino Leonardo: -// ---------------------- -// Display: SDA pin -> Arduino Digital 2 or the dedicated SDA pin -// SCL pin -> Arduino Digital 3 or the dedicated SCL pin -// -// Arduino Mega: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin -// -// Arduino Due: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin -// -// The internal pull-up resistors will be activated when using the -// hardware I2C interfaces. -// -// You can connect the OLED display to any available pin but if you use -// any other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used, and you will also have to use appropriate, external -// pull-up resistors on the data and clock signals. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t TinyFont[]; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(TinyFont); -} - -void loop() -{ - myOLED.print(" !\"#$%&'()*+,-./", CENTER, 16); - myOLED.print("0123456789:;<=>?", CENTER, 22); - myOLED.print("@ABCDEFGHIJKLMNO", CENTER, 28); - myOLED.print("PQRSTUVWXYZ[\\]^_", CENTER, 34); - myOLED.print("`abcdefghijklmno", CENTER, 40); - myOLED.print("pqrstuvwxyz{|}~ ", CENTER, 46); - myOLED.update(); - - while (1); -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_ViewFont/OLED_I2C_ViewFont.ino b/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_ViewFont/OLED_I2C_ViewFont.ino deleted file mode 100644 index 01b4be9..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/Arduino/OLED_I2C_ViewFont/OLED_I2C_ViewFont.ino +++ /dev/null @@ -1,83 +0,0 @@ -// OLED_I2C_ViewFont -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the Arduino you must connect -// the pins as follows: -// -// Arduino Uno/2009: -// ---------------------- -// Display: SDA pin -> Arduino Analog 4 or the dedicated SDA pin -// SCL pin -> Arduino Analog 5 or the dedicated SCL pin -// -// Arduino Leonardo: -// ---------------------- -// Display: SDA pin -> Arduino Digital 2 or the dedicated SDA pin -// SCL pin -> Arduino Digital 3 or the dedicated SCL pin -// -// Arduino Mega: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin -// -// Arduino Due: -// ---------------------- -// Display: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin -// SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin -// -// The internal pull-up resistors will be activated when using the -// hardware I2C interfaces. -// -// You can connect the OLED display to any available pin but if you use -// any other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used, and you will also have to use appropriate, external -// pull-up resistors on the data and clock signals. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(SmallFont); -} - -void loop() -{ - myOLED.clrScr(); - myOLED.print("Upper case:", LEFT, 0); - myOLED.print("ABCDEFGHIJKLM", CENTER, 16); - myOLED.print("NOPQRSTUVWXYZ", CENTER, 24); - myOLED.update(); - delay (5000); - - myOLED.clrScr(); - myOLED.print("Lower case:", LEFT, 0); - myOLED.print("abcdefghijklm", CENTER, 16); - myOLED.print("nopqrstuvwxyz", CENTER, 24); - myOLED.update(); - delay (5000); - - myOLED.clrScr(); - myOLED.print("Numbers:", LEFT, 0); - myOLED.print("0123456789", CENTER, 16); - myOLED.update(); - delay (5000); - - myOLED.clrScr(); - myOLED.print("Special:", LEFT, 0); - myOLED.print("!\"#$%&'()*+,-.", CENTER, 16); - myOLED.print("/:;<=>?@[\\]^_`", CENTER, 24); - myOLED.print("{|}~", CENTER, 32); - myOLED.update(); - delay (5000); -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_3D_Cube/OLED_I2C_3D_Cube.pde b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_3D_Cube/OLED_I2C_3D_Cube.pde deleted file mode 100644 index c1fa541..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_3D_Cube/OLED_I2C_3D_Cube.pde +++ /dev/null @@ -1,148 +0,0 @@ -// OLED_I2C_3D_Cube -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library to rotate a 3D cube. -// The average FPS (Frames Per Second) will be displayed on the screen. -// -// NOTE: The FPS counter will overflow if left for an extended amount of time. -// -// To use the hardware I2C (TWI) interface of the chipKit you must connect -// the pins as follows: -// -// chipKit Uno32/uC32: -// ---------------------- -// Display: SDA pin -> Analog 4 -// SCL pin -> Analog 5 -// *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins) -// -// chipKit Max32: -// ---------------------- -// Display: SDA pin -> Digital 20 (the pin labeled SDA) -// SCL pin -> Digital 21 (the pin labeled SCL) -// -// The chipKit boards does not have pull-up resistors on the hardware I2C interface -// so external pull-up resistors on the data and clock signals are required. -// -// You can connect the OLED display to any available pin but if you use any -// other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; - -double vectors[8][3] = {{20, 20, 20},{-20, 20, 20},{-20, -20, 20},{20, -20, 20},{20, 20, -20},{-20, 20, -20},{-20, -20, -20},{20, -20, -20}}; - -double perspective = 100.0f; -int deltaX, deltaY, deltaZ, iter = 0; -long stime, fps = 0, frames = 0; - -void setup() -{ - randomSeed(analogRead(0)); - - myOLED.begin(); - myOLED.setFont(SmallFont); - stime = micros(); -} - -void loop() -{ - myOLED.clrScr(); - drawVectors(); - if (iter == 0) - { - deltaX = random(7) - 3; - deltaY = random(7) - 3; - deltaZ = random(7) - 3; - iter = random(250) + 5; - } - rotateX(deltaX); - rotateY(deltaY); - rotateZ(deltaZ); - iter--; - fps += 1000000 / (micros() - stime); - stime = micros(); - frames++; - myOLED.printNumI(fps / frames, 0, 0, 3); // Print average FPS on screen - myOLED.update(); -} - -int translateX(double x, double z) -{ - return (int)((x + 64) + (z * (x / perspective))); -} - -int translateY(double y, double z) -{ - return (int)((y + 32) + (z * (y / perspective))); -} - -void rotateX(int angle) -{ - double rad, cosa, sina, Yn, Zn; - - rad = angle * PI / 180; - cosa = cos(rad); - sina = sin(rad); - for (int i = 0; i < 8; i++) - { - Yn = (vectors[i][1] * cosa) - (vectors[i][2] * sina); - Zn = (vectors[i][1] * sina) + (vectors[i][2] * cosa); - vectors[i][1] = Yn; - vectors[i][2] = Zn; - } -} - -void rotateY(int angle) -{ - double rad, cosa, sina, Xn, Zn; - - rad = angle * PI / 180; - cosa = cos(rad); - sina = sin(rad); - for (int i = 0; i < 8; i++) - { - Xn = (vectors[i][0] * cosa) - (vectors[i][2] * sina); - Zn = (vectors[i][0] * sina) + (vectors[i][2] * cosa); - vectors[i][0] = Xn; - vectors[i][2] = Zn; - } -} - -void rotateZ(int angle) -{ - double rad, cosa, sina, Xn, Yn; - - rad = angle * PI / 180; - cosa = cos(rad); - sina = sin(rad); - for (int i = 0; i < 8; i++) - { - Xn = (vectors[i][0] * cosa) - (vectors[i][1] * sina); - Yn = (vectors[i][0] * sina) + (vectors[i][1] * cosa); - vectors[i][0] = Xn; - vectors[i][1] = Yn; - } -} - -void drawVectors() -{ - myOLED.drawLine(translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2]), translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2])); - myOLED.drawLine(translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2]), translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2])); - myOLED.drawLine(translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2]), translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2])); - myOLED.drawLine(translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2]), translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2])); - myOLED.drawLine(translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2]), translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2])); - myOLED.drawLine(translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2]), translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2])); - myOLED.drawLine(translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2]), translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2])); - myOLED.drawLine(translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2]), translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2])); - myOLED.drawLine(translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2]), translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2])); - myOLED.drawLine(translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2]), translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2])); - myOLED.drawLine(translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2]), translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2])); - myOLED.drawLine(translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2]), translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2])); -} diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Bitmap/OLED_I2C_Bitmap.ino b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Bitmap/OLED_I2C_Bitmap.ino deleted file mode 100644 index 946e563..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Bitmap/OLED_I2C_Bitmap.ino +++ /dev/null @@ -1,71 +0,0 @@ -// OLED_I2C_Bitmap -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the chipKit you must connect -// the pins as follows: -// -// chipKit Uno32/uC32: -// ---------------------- -// Display: SDA pin -> Analog 4 -// SCL pin -> Analog 5 -// *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins) -// -// chipKit Max32: -// ---------------------- -// Display: SDA pin -> Digital 20 (the pin labeled SDA) -// SCL pin -> Digital 21 (the pin labeled SCL) -// -// The chipKit boards does not have pull-up resistors on the hardware I2C interface -// so external pull-up resistors on the data and clock signals are required. -// -// You can connect the OLED display to any available pin but if you use any -// other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t logo[]; -extern uint8_t mice[]; - -void setup() -{ - myOLED.begin(); -} - -void loop() -{ - myOLED.clrScr(); - myOLED.drawBitmap(0, 16, logo, 128, 36); - myOLED.update(); - delay(4000); - for (int i=0; i<2; i++) - { - myOLED.invert(true); - delay(500); - myOLED.invert(false); - delay(500); - } - delay(4000); - - myOLED.clrScr(); - myOLED.drawBitmap(0, 0, mice, 128, 64); - myOLED.update(); - delay(4000); - for (int i=0; i<2; i++) - { - myOLED.invert(true); - delay(500); - myOLED.invert(false); - delay(500); - } - delay(4000); -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Bitmap/graphics.c b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Bitmap/graphics.c deleted file mode 100644 index 14b5f85..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Bitmap/graphics.c +++ /dev/null @@ -1,110 +0,0 @@ -const unsigned char logo[] ={ -0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08, 0x08, // 0x0010 (16) pixels -0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x1F, 0xFF, 0xFE, 0x83, // 0x0020 (32) pixels -0x83, 0xC2, 0xC6, 0x7E, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x20, 0xE7, 0xE7, 0x00, 0x00, 0x00, 0x00, // 0x0030 (48) pixels -0x20, 0x70, 0xE0, 0xC0, 0x20, 0x30, 0x30, 0xE0, 0xC0, 0x00, 0x00, 0x03, 0x03, 0xFE, 0xFE, 0x00, // 0x0040 (64) pixels -0x20, 0xE0, 0x60, 0x20, 0x20, 0x00, 0x00, 0x40, 0xE0, 0xE0, 0x40, 0x00, 0x40, 0xE0, 0x60, 0x00, // 0x0050 (80) pixels -0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFF, 0xFF, 0xEF, 0x03, 0x02, 0x02, 0x02, 0x06, 0xFC, 0xF8, // 0x0060 (96) pixels -0xE0, 0x00, 0x00, 0x00, 0x20, 0xE7, 0xE7, 0x00, 0x00, 0x00, 0x20, 0x70, 0xE0, 0xC0, 0x20, 0x30, // 0x0070 (112) pixels -0x30, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x03, 0xFE, 0xFE, 0x00, 0x20, 0xE0, 0x60, 0x20, 0x20, // 0x0080 (128) pixels -0x00, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, // 0x0090 (144) pixels -0x90, 0x7F, 0x90, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3C, 0x3F, 0x3F, 0x20, // 0x00A0 (160) pixels -0x00, 0x00, 0x07, 0x3F, 0x3C, 0x30, 0x30, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x30, 0x00, 0x00, 0x00, // 0x00B0 (176) pixels -0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x20, 0x20, 0x3F, 0x3F, 0x22, // 0x00C0 (192) pixels -0x27, 0x2F, 0x38, 0x30, 0x20, 0x00, 0x00, 0x00, 0x01, 0x0F, 0xBC, 0x60, 0x1E, 0x01, 0x00, 0x01, // 0x00D0 (208) pixels -0x01, 0x01, 0x01, 0x01, 0x20, 0x20, 0x3F, 0x3F, 0x3F, 0x20, 0x20, 0x20, 0x20, 0x30, 0x1F, 0x0F, // 0x00E0 (224) pixels -0x03, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x30, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, // 0x00F0 (240) pixels -0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x3F, 0x22, 0x27, 0x2F, 0x38, 0x30, 0x20, // 0x0100 (256) pixels -0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, // 0x0110 (272) pixels -0x01, 0x00, 0x01, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, // 0x0120 (288) pixels -0xE0, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x00, 0x00, 0x40, 0xC0, 0xC0, 0x00, 0x00, 0x00, // 0x0130 (304) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0140 (320) pixels -0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x03, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0150 (336) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0160 (352) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0170 (368) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0180 (384) pixels -0x00, 0x00, 0x0F, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, // 0x0190 (400) pixels -0x01, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // 0x01A0 (416) pixels -0xFF, 0x9F, 0x18, 0x18, 0x3E, 0x00, 0x00, 0x87, 0xC0, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 0x01B0 (432) pixels -0x60, 0xF8, 0xFC, 0x46, 0x26, 0x2E, 0x3C, 0xB8, 0x00, 0xE0, 0xF8, 0x08, 0x0C, 0x0C, 0x7C, 0x38, // 0x01C0 (448) pixels -0x00, 0x06, 0x06, 0xFF, 0x0E, 0x06, 0x84, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x08, 0x0C, 0x0C, 0x08, // 0x01D0 (464) pixels -0x00, 0xF0, 0xF8, 0x1C, 0x06, 0x02, 0x04, 0xFC, 0xF8, 0xF0, 0x00, 0x04, 0xEE, 0xFC, 0x18, 0x04, // 0x01E0 (480) pixels -0x06, 0x06, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x08, // 0x01F0 (496) pixels -0x0C, 0x0C, 0x7C, 0x38, 0x00, 0x00, 0x7C, 0x7C, 0x64, 0xC4, 0xDC, 0xCC, 0x80, 0x00, 0x00, 0x00, // 0x0200 (512) pixels -0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xFF, 0xF1, 0xF1, 0xF1, 0xF1, // 0x0210 (528) pixels -0xF1, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF4, 0xF4, 0xF7, // 0x0220 (544) pixels -0xF7, 0xF7, 0xF4, 0xF4, 0xF4, 0xF6, 0xF6, 0xF7, 0xF3, 0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, // 0x0230 (560) pixels -0xF0, 0xF3, 0xF7, 0xF4, 0xF4, 0xF4, 0xF6, 0xF1, 0xF0, 0xF1, 0xF7, 0xF6, 0xFC, 0xFC, 0xF4, 0xF7, // 0x0240 (576) pixels -0xF0, 0xF0, 0xF0, 0xF7, 0xFE, 0xF4, 0xF7, 0xF0, 0xF0, 0xF6, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, 0xF0, // 0x0250 (592) pixels -0xF0, 0xF0, 0xF3, 0xF6, 0xF4, 0xF4, 0xF4, 0xF7, 0xF3, 0xF0, 0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, // 0x0260 (608) pixels -0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, 0xF4, 0xF7, 0xF7, 0xF6, 0xF0, 0xF0, 0xF1, 0xF7, 0xF6, // 0x0270 (624) pixels -0xFC, 0xFC, 0xF4, 0xF7, 0xF0, 0xF0, 0xFF, 0xF6, 0xF4, 0xF8, 0xF8, 0xF7, 0xF1, 0xF0, 0xF0, 0xF0, // 0x0280 (640) pixels -}; - -const unsigned char mice[] ={ -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0010 (16) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, // 0x0020 (32) pixels -0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0030 (48) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0040 (64) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0050 (80) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0xCF, 0xCF, 0xEF, 0xCF, 0x9F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, // 0x0060 (96) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x9F, 0x9F, 0xDF, 0xCF, 0xCF, 0xCF, // 0x0070 (112) pixels -0x1F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0080 (128) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0090 (144) pixels -0xFF, 0xFF, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00A0 (160) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x00B0 (176) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x00C0 (192) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x00D0 (208) pixels -0xFF, 0xFF, 0xFF, 0x07, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xE1, 0x07, 0x3F, // 0x00E0 (224) pixels -0xFF, 0xFF, 0x7F, 0x1F, 0x47, 0x33, 0x98, 0xCC, 0xE6, 0xF3, 0xF9, 0xFE, 0xFF, 0xFF, 0x3F, 0x07, // 0x00F0 (240) pixels -0xC0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0100 (256) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0110 (272) pixels -0xFF, 0xFF, 0xFC, 0xF0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0120 (288) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0130 (304) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0140 (320) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x07, 0x03, 0x01, 0x01, 0x00, // 0x0150 (336) pixels -0x00, 0x00, 0xC0, 0xF0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0xF7, 0xE6, 0x00, // 0x0160 (352) pixels -0x33, 0xF9, 0xF0, 0x04, 0x0E, 0xCF, 0xEF, 0xE7, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x00, 0x03, // 0x0170 (368) pixels -0x03, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0180 (384) pixels -0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0F, 0x1F, // 0x0190 (400) pixels -0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1E, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x01A0 (416) pixels -0x00, 0x00, 0x00, 0x00, 0xF0, 0xFC, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFC, 0xF9, 0xF1, 0xC3, // 0x01B0 (432) pixels -0x87, 0xCF, 0x9F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x01C0 (448) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x01D0 (464) pixels -0x00, 0x00, 0x3F, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0xDF, 0xCF, 0xEF, 0xE7, 0xB7, 0x33, 0x11, 0x30, // 0x01E0 (480) pixels -0xC6, 0xC7, 0xE3, 0x10, 0x32, 0x17, 0x67, 0xAF, 0xCF, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F, 0x00, 0x00, // 0x01F0 (496) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0200 (512) pixels -0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0210 (528) pixels -0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0220 (544) pixels -0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x01, 0xC1, 0xF1, // 0x0230 (560) pixels -0x07, 0x3F, 0x0F, 0x87, 0x0C, 0x01, 0x0F, 0x7F, 0x1F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x0F, 0xFF, // 0x0240 (576) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF8, 0xF0, // 0x0250 (592) pixels -0x30, 0x08, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC1, 0x00, 0x3E, 0x3C, // 0x0260 (608) pixels -0x03, 0x8F, 0x01, 0x3C, 0x3E, 0x00, 0x83, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x70, // 0x0270 (624) pixels -0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0280 (640) pixels -0xFF, 0xF8, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0290 (656) pixels -0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0xE0, 0xF8, 0xF8, 0xFC, 0xFC, 0xFC, 0x7E, 0x7C, // 0x02A0 (672) pixels -0x3C, 0x3C, 0x3C, 0x78, 0x78, 0xF1, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF3, 0xE7, // 0x02B0 (688) pixels -0xF0, 0xF8, 0xF0, 0xF3, 0xF8, 0xF8, 0xFC, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xFF, // 0x02C0 (704) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x02D0 (720) pixels -0x80, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0x63, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x08, 0x00, // 0x02E0 (736) pixels -0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xFF, 0xFF, 0x3F, 0x39, 0x78, 0xF8, 0xF8, 0x60, 0x00, // 0x02F0 (752) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0300 (768) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFC, // 0x0310 (784) pixels -0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xE7, 0xCF, 0x9F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, // 0x0320 (800) pixels -0xF8, 0xE3, 0xCF, 0xBF, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0330 (816) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x9F, 0xCF, 0xE3, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, // 0x0340 (832) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0350 (848) pixels -0xFF, 0xFC, 0xF9, 0xF3, 0xE7, 0xCE, 0xDE, 0x9C, 0xB9, 0x33, 0x67, 0x87, 0x0F, 0x4F, 0x8F, 0x8F, // 0x0360 (864) pixels -0x8E, 0x8E, 0x8E, 0x8E, 0x07, 0x87, 0xF3, 0x79, 0x7D, 0x3E, 0x9F, 0xCF, 0xE7, 0xF3, 0xF8, 0xFE, // 0x0370 (880) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0380 (896) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0390 (912) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, // 0x03A0 (928) pixels -0xFE, 0xFC, 0xFC, 0xFC, 0xFD, 0xF8, 0xFA, 0xF8, 0xF8, 0xF9, 0xF9, 0xFD, 0xF9, 0xF9, 0xF9, 0xF9, // 0x03B0 (944) pixels -0xF9, 0xFD, 0xFD, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x03C0 (960) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x03D0 (976) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF9, 0xF8, 0xF0, 0xF1, // 0x03E0 (992) pixels -0xF1, 0xF1, 0xF1, 0xF8, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x03F0 (1008) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0400 (1024) pixels -}; - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Brightness/OLED_I2C_Brightness.ino b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Brightness/OLED_I2C_Brightness.ino deleted file mode 100644 index 7ee96ef..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Brightness/OLED_I2C_Brightness.ino +++ /dev/null @@ -1,54 +0,0 @@ -// OLED_I2C_Brightness -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the chipKit you must connect -// the pins as follows: -// -// chipKit Uno32/uC32: -// ---------------------- -// Display: SDA pin -> Analog 4 -// SCL pin -> Analog 5 -// *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins) -// -// chipKit Max32: -// ---------------------- -// Display: SDA pin -> Digital 20 (the pin labeled SDA) -// SCL pin -> Digital 21 (the pin labeled SCL) -// -// The chipKit boards does not have pull-up resistors on the hardware I2C interface -// so external pull-up resistors on the data and clock signals are required. -// -// You can connect the OLED display to any available pin but if you use any -// other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -void setup() -{ - myOLED.begin(); - myOLED.invert(true); -} - -void loop() -{ - for (int i=0; i<256; i++) - { - myOLED.setBrightness(i); - delay(5); - } - for (int i=255; i>=0; i--) - { - myOLED.setBrightness(i); - delay(5); - } -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Graph_Demo/OLED_I2C_Graph_Demo.ino b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Graph_Demo/OLED_I2C_Graph_Demo.ino deleted file mode 100644 index 2455068..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Graph_Demo/OLED_I2C_Graph_Demo.ino +++ /dev/null @@ -1,185 +0,0 @@ -// OLED_I2C_Graph_Demo -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the chipKit you must connect -// the pins as follows: -// -// chipKit Uno32/uC32: -// ---------------------- -// Display: SDA pin -> Analog 4 -// SCL pin -> Analog 5 -// *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins) -// -// chipKit Max32: -// ---------------------- -// Display: SDA pin -> Digital 20 (the pin labeled SDA) -// SCL pin -> Digital 21 (the pin labeled SCL) -// -// The chipKit boards does not have pull-up resistors on the hardware I2C interface -// so external pull-up resistors on the data and clock signals are required. -// -// You can connect the OLED display to any available pin but if you use any -// other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; -extern uint8_t logo[]; -extern uint8_t The_End[]; -extern uint8_t pacman1[]; -extern uint8_t pacman2[]; -extern uint8_t pacman3[]; -extern uint8_t pill[]; - -float y; -uint8_t* bm; -int pacy; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(SmallFont); - randomSeed(analogRead(7)); -} - -void loop() -{ - myOLED.clrScr(); - myOLED.drawBitmap(0, 16, logo, 128, 36); - myOLED.update(); - - delay(3000); - - myOLED.clrScr(); - myOLED.print("OLED_I2C", CENTER, 0); - myOLED.print("DEMO", CENTER, 28); - myOLED.drawRect(50, 26, 78, 36); - for (int i=0; i<6; i++) - { - myOLED.drawLine(79, 26+(i*2), 105-(i*3), 26+(i*2)); - myOLED.drawLine(22+(i*3), 36-(i*2), 50, 36-(i*2)); - } - myOLED.print("(C)2015 by", CENTER, 48); - myOLED.print("Henning Karlsen", CENTER, 56); - myOLED.update(); - - delay(5000); - - myOLED.clrScr(); - for (int i=0; i<64; i+=2) - { - myOLED.drawLine(0, i, 127, 63-i); - myOLED.update(); - } - for (int i=127; i>=0; i-=2) - { - myOLED.drawLine(i, 0, 127-i, 63); - myOLED.update(); - } - - delay(2000); - - myOLED.clrScr(); - myOLED.drawRect(0, 0, 127, 63); - for (int i=0; i<64; i+=4) - { - myOLED.drawLine(0, i, i*2, 63); - myOLED.update(); - } - for (int i=0; i<64; i+=4) - { - myOLED.drawLine(127, 63-i, 127-(i*2), 0); - myOLED.update(); - } - - delay(2000); - - myOLED.clrScr(); - for (int i=0; i<10; i++) - { - myOLED.drawRoundRect(i*3, i*3, 127-(i*3), 63-(i*3)); - myOLED.update(); - } - - delay(2000); - - myOLED.clrScr(); - for (int i=0; i<25; i++) - { - myOLED.drawCircle(64, 32, i*3); - myOLED.update(); - } - - delay(2000); - - myOLED.clrScr(); - myOLED.drawRect(0, 0, 127, 63); - myOLED.drawLine(0, 31, 127, 31); - myOLED.drawLine(63, 0, 63, 63); - for (int c=0; c<4; c++) - { - for (int i=0; i<128; i++) - { - y=i*0.04974188368183839294232518690191; - myOLED.invPixel(i, (sin(y)*28)+31); - myOLED.update(); - delay(10); - } - } - - delay(2000); - - for (int pc=0; pc<3; pc++) - { - pacy=random(0, 44); - - for (int i=-20; i<132; i++) - { - myOLED.clrScr(); - for (int p=6; p>((i+20)/20); p--) - myOLED.drawBitmap(p*20-8, pacy+7, pill, 5, 5); - switch(((i+20)/3) % 4) - { - case 0: bm=pacman1; - break; - case 1: bm=pacman2; - break; - case 2: bm=pacman3; - break; - case 3: bm=pacman2; - break; - } - myOLED.drawBitmap(i, pacy, bm, 20, 20); - myOLED.update(); - delay(10); - } - } - - for (int i=0; i<41; i++) - { - myOLED.clrScr(); - myOLED.drawBitmap(22, i-24, The_End, 84, 24); - myOLED.update(); - delay(50); - } - myOLED.print("Runtime (ms):", CENTER, 48); - myOLED.printNumI(millis(), CENTER, 56); - myOLED.update(); - for (int i=0; i<5; i++) - { - myOLED.invert(true); - delay(1000); - myOLED.invert(false); - delay(1000); - } -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Graph_Demo/graphics.c b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Graph_Demo/graphics.c deleted file mode 100644 index 5f16986..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Graph_Demo/graphics.c +++ /dev/null @@ -1,87 +0,0 @@ -const unsigned char logo[] ={ -0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08, 0x08, // 0x0010 (16) pixels -0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x1F, 0xFF, 0xFE, 0x83, // 0x0020 (32) pixels -0x83, 0xC2, 0xC6, 0x7E, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x20, 0xE7, 0xE7, 0x00, 0x00, 0x00, 0x00, // 0x0030 (48) pixels -0x20, 0x70, 0xE0, 0xC0, 0x20, 0x30, 0x30, 0xE0, 0xC0, 0x00, 0x00, 0x03, 0x03, 0xFE, 0xFE, 0x00, // 0x0040 (64) pixels -0x20, 0xE0, 0x60, 0x20, 0x20, 0x00, 0x00, 0x40, 0xE0, 0xE0, 0x40, 0x00, 0x40, 0xE0, 0x60, 0x00, // 0x0050 (80) pixels -0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFF, 0xFF, 0xEF, 0x03, 0x02, 0x02, 0x02, 0x06, 0xFC, 0xF8, // 0x0060 (96) pixels -0xE0, 0x00, 0x00, 0x00, 0x20, 0xE7, 0xE7, 0x00, 0x00, 0x00, 0x20, 0x70, 0xE0, 0xC0, 0x20, 0x30, // 0x0070 (112) pixels -0x30, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x03, 0xFE, 0xFE, 0x00, 0x20, 0xE0, 0x60, 0x20, 0x20, // 0x0080 (128) pixels -0x00, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, // 0x0090 (144) pixels -0x90, 0x7F, 0x90, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3C, 0x3F, 0x3F, 0x20, // 0x00A0 (160) pixels -0x00, 0x00, 0x07, 0x3F, 0x3C, 0x30, 0x30, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x30, 0x00, 0x00, 0x00, // 0x00B0 (176) pixels -0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x20, 0x20, 0x3F, 0x3F, 0x22, // 0x00C0 (192) pixels -0x27, 0x2F, 0x38, 0x30, 0x20, 0x00, 0x00, 0x00, 0x01, 0x0F, 0xBC, 0x60, 0x1E, 0x01, 0x00, 0x01, // 0x00D0 (208) pixels -0x01, 0x01, 0x01, 0x01, 0x20, 0x20, 0x3F, 0x3F, 0x3F, 0x20, 0x20, 0x20, 0x20, 0x30, 0x1F, 0x0F, // 0x00E0 (224) pixels -0x03, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x30, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, // 0x00F0 (240) pixels -0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x3F, 0x22, 0x27, 0x2F, 0x38, 0x30, 0x20, // 0x0100 (256) pixels -0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, // 0x0110 (272) pixels -0x01, 0x00, 0x01, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, // 0x0120 (288) pixels -0xE0, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x00, 0x00, 0x40, 0xC0, 0xC0, 0x00, 0x00, 0x00, // 0x0130 (304) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0140 (320) pixels -0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x03, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0150 (336) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0160 (352) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0170 (368) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0180 (384) pixels -0x00, 0x00, 0x0F, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, // 0x0190 (400) pixels -0x01, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // 0x01A0 (416) pixels -0xFF, 0x9F, 0x18, 0x18, 0x3E, 0x00, 0x00, 0x87, 0xC0, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 0x01B0 (432) pixels -0x60, 0xF8, 0xFC, 0x46, 0x26, 0x2E, 0x3C, 0xB8, 0x00, 0xE0, 0xF8, 0x08, 0x0C, 0x0C, 0x7C, 0x38, // 0x01C0 (448) pixels -0x00, 0x06, 0x06, 0xFF, 0x0E, 0x06, 0x84, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x08, 0x0C, 0x0C, 0x08, // 0x01D0 (464) pixels -0x00, 0xF0, 0xF8, 0x1C, 0x06, 0x02, 0x04, 0xFC, 0xF8, 0xF0, 0x00, 0x04, 0xEE, 0xFC, 0x18, 0x04, // 0x01E0 (480) pixels -0x06, 0x06, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x08, // 0x01F0 (496) pixels -0x0C, 0x0C, 0x7C, 0x38, 0x00, 0x00, 0x7C, 0x7C, 0x64, 0xC4, 0xDC, 0xCC, 0x80, 0x00, 0x00, 0x00, // 0x0200 (512) pixels -0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xFF, 0xF1, 0xF1, 0xF1, 0xF1, // 0x0210 (528) pixels -0xF1, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF4, 0xF4, 0xF7, // 0x0220 (544) pixels -0xF7, 0xF7, 0xF4, 0xF4, 0xF4, 0xF6, 0xF6, 0xF7, 0xF3, 0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, // 0x0230 (560) pixels -0xF0, 0xF3, 0xF7, 0xF4, 0xF4, 0xF4, 0xF6, 0xF1, 0xF0, 0xF1, 0xF7, 0xF6, 0xFC, 0xFC, 0xF4, 0xF7, // 0x0240 (576) pixels -0xF0, 0xF0, 0xF0, 0xF7, 0xFE, 0xF4, 0xF7, 0xF0, 0xF0, 0xF6, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, 0xF0, // 0x0250 (592) pixels -0xF0, 0xF0, 0xF3, 0xF6, 0xF4, 0xF4, 0xF4, 0xF7, 0xF3, 0xF0, 0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, // 0x0260 (608) pixels -0xF0, 0xF4, 0xF7, 0xF7, 0xF4, 0xF0, 0xF0, 0xF4, 0xF7, 0xF7, 0xF6, 0xF0, 0xF0, 0xF1, 0xF7, 0xF6, // 0x0270 (624) pixels -0xFC, 0xFC, 0xF4, 0xF7, 0xF0, 0xF0, 0xFF, 0xF6, 0xF4, 0xF8, 0xF8, 0xF7, 0xF1, 0xF0, 0xF0, 0xF0, // 0x0280 (640) pixels -}; - -const unsigned char The_End[] ={ -0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0x60, 0x00, 0x00, // 0x0010 (16) pixels -0x80, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, // 0x0020 (32) pixels -0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, // 0x0030 (48) pixels -0xE0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0x00, 0x00, // 0x0040 (64) pixels -0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF0, 0x60, 0x40, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, // 0x0050 (80) pixels -0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x81, 0xFC, 0xFF, 0x0F, 0x03, 0x00, 0x00, 0x00, // 0x0060 (96) pixels -0xEE, 0x6F, 0x67, 0xFF, 0xFF, 0x7F, 0x71, 0x30, 0xF0, 0xFF, 0x3F, 0x39, 0x38, 0x18, 0x00, 0x01, // 0x0070 (112) pixels -0x00, 0xF8, 0xFF, 0x1F, 0x0F, 0x0C, 0x0D, 0x8D, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // 0x0080 (128) pixels -0x00, 0xC0, 0xFF, 0x7F, 0x0F, 0x0C, 0x0D, 0x0D, 0x84, 0x80, 0x80, 0x07, 0x07, 0x83, 0xFF, 0xFF, // 0x0090 (144) pixels -0x1F, 0x3F, 0xFE, 0xF8, 0xF8, 0xFE, 0xDF, 0x03, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x1F, 0x00, // 0x00A0 (160) pixels -0x00, 0x80, 0x81, 0xC3, 0xE7, 0x7F, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, 0x07, 0x03, 0x00, // 0x00B0 (176) pixels -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x0F, 0x0F, 0x07, 0x00, // 0x00C0 (192) pixels -0x00, 0x06, 0x06, 0x3F, 0x1F, 0x0F, 0x0F, 0x0E, 0x06, 0x06, 0x06, 0x07, 0x07, 0x03, 0x00, 0x00, // 0x00D0 (208) pixels -0x00, 0x00, 0x06, 0x1F, 0x3F, 0x1F, 0x0F, 0x0E, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x03, 0x00, // 0x00E0 (224) pixels -0x06, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x18, 0x1C, 0x1F, // 0x00F0 (240) pixels -0x0F, 0x07, 0x06, 0x07, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, -}; - -const unsigned char pacman1[] ={ -0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3E, 0x1C, // 0x0010 (16) pixels -0x0C, 0x00, 0x00, 0x00, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, // 0x0020 (32) pixels -0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels -0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00, -}; - -const unsigned char pacman2[] ={ -0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x7C, // 0x0010 (16) pixels -0x7C, 0x38, 0x20, 0x00, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, // 0x0020 (32) pixels -0xF9, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels -0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, -}; - -const unsigned char pacman3[] ={ -0x80, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, // 0x0010 (16) pixels -0xF8, 0xF0, 0xE0, 0x80, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x0020 (32) pixels -0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xF9, 0x79, 0x19, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, // 0x0030 (48) pixels -0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, -}; - -const unsigned char pill[] ={ -0x0E, 0x1F, 0x1F, 0x1F, 0x0E, -}; - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_NumberFonts/OLED_I2C_NumberFonts.ino b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_NumberFonts/OLED_I2C_NumberFonts.ino deleted file mode 100644 index 836e944..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_NumberFonts/OLED_I2C_NumberFonts.ino +++ /dev/null @@ -1,69 +0,0 @@ -// OLED_I2C_NumberFonts -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the chipKit you must connect -// the pins as follows: -// -// chipKit Uno32/uC32: -// ---------------------- -// Display: SDA pin -> Analog 4 -// SCL pin -> Analog 5 -// *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins) -// -// chipKit Max32: -// ---------------------- -// Display: SDA pin -> Digital 20 (the pin labeled SDA) -// SCL pin -> Digital 21 (the pin labeled SCL) -// -// The chipKit boards does not have pull-up resistors on the hardware I2C interface -// so external pull-up resistors on the data and clock signals are required. -// -// You can connect the OLED display to any available pin but if you use any -// other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; -extern uint8_t MediumNumbers[]; -extern uint8_t BigNumbers[]; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(SmallFont); -} - -void loop() -{ - for (int i=0; i<=10000; i++) - { - myOLED.setFont(MediumNumbers); - myOLED.printNumF(float(i)/3, 2, RIGHT, 0); - myOLED.setFont(BigNumbers); - myOLED.printNumI(i, RIGHT, 40); - myOLED.update(); - } - - myOLED.setFont(SmallFont); - myOLED.print("|", LEFT, 24); - myOLED.print("|", RIGHT, 24); - myOLED.update(); - delay(500); - for (int i=0; i<19; i++) - { - myOLED.print("\\", 7+(i*6), 24); - myOLED.update(); - delay(250); - } - myOLED.clrScr(); -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Scrolling_Text/OLED_I2C_Scrolling_Text.ino b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Scrolling_Text/OLED_I2C_Scrolling_Text.ino deleted file mode 100644 index cfc13f2..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_Scrolling_Text/OLED_I2C_Scrolling_Text.ino +++ /dev/null @@ -1,54 +0,0 @@ -// OLED_I2C_Scrolling_Text -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the chipKit you must connect -// the pins as follows: -// -// chipKit Uno32/uC32: -// ---------------------- -// Display: SDA pin -> Analog 4 -// SCL pin -> Analog 5 -// *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins) -// -// chipKit Max32: -// ---------------------- -// Display: SDA pin -> Digital 20 (the pin labeled SDA) -// SCL pin -> Digital 21 (the pin labeled SCL) -// -// The chipKit boards does not have pull-up resistors on the hardware I2C interface -// so external pull-up resistors on the data and clock signals are required. -// -// You can connect the OLED display to any available pin but if you use any -// other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(SmallFont); - randomSeed(analogRead(0)); -} - -void loop() -{ - int y = random(0, 56); - for (int i=128; i>=-(34*6); i--) - { - myOLED.print("OLED_I2C Scrolling Text Demo ", i, y); - myOLED.update(); - delay(50); - } -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_TinyFont_View/OLED_I2C_TinyFont_View.ino b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_TinyFont_View/OLED_I2C_TinyFont_View.ino deleted file mode 100644 index 2eaf34d..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_TinyFont_View/OLED_I2C_TinyFont_View.ino +++ /dev/null @@ -1,55 +0,0 @@ -// OLED_I2C_TinyFont_View -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the chipKit you must connect -// the pins as follows: -// -// chipKit Uno32/uC32: -// ---------------------- -// Display: SDA pin -> Analog 4 -// SCL pin -> Analog 5 -// *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins) -// -// chipKit Max32: -// ---------------------- -// Display: SDA pin -> Digital 20 (the pin labeled SDA) -// SCL pin -> Digital 21 (the pin labeled SCL) -// -// The chipKit boards does not have pull-up resistors on the hardware I2C interface -// so external pull-up resistors on the data and clock signals are required. -// -// You can connect the OLED display to any available pin but if you use any -// other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t TinyFont[]; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(TinyFont); -} - -void loop() -{ - myOLED.print(" !\"#$%&'()*+,-./", CENTER, 16); - myOLED.print("0123456789:;<=>?", CENTER, 22); - myOLED.print("@ABCDEFGHIJKLMNO", CENTER, 28); - myOLED.print("PQRSTUVWXYZ[\\]^_", CENTER, 34); - myOLED.print("`abcdefghijklmno", CENTER, 40); - myOLED.print("pqrstuvwxyz{|}~ ", CENTER, 46); - myOLED.update(); - - while (1); -} - - diff --git a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_ViewFont/OLED_I2C_ViewFont.ino b/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_ViewFont/OLED_I2C_ViewFont.ino deleted file mode 100644 index 679a0c9..0000000 --- a/GD32F1/libraries/OLED_I2C/examples/chipKit/OLED_I2C_ViewFont/OLED_I2C_ViewFont.ino +++ /dev/null @@ -1,73 +0,0 @@ -// OLED_I2C_ViewFont -// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved -// web: http://www.RinkyDinkElectronics.com/ -// -// A quick demo of how to use my OLED_I2C library. -// -// To use the hardware I2C (TWI) interface of the chipKit you must connect -// the pins as follows: -// -// chipKit Uno32/uC32: -// ---------------------- -// Display: SDA pin -> Analog 4 -// SCL pin -> Analog 5 -// *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins) -// -// chipKit Max32: -// ---------------------- -// Display: SDA pin -> Digital 20 (the pin labeled SDA) -// SCL pin -> Digital 21 (the pin labeled SCL) -// -// The chipKit boards does not have pull-up resistors on the hardware I2C interface -// so external pull-up resistors on the data and clock signals are required. -// -// You can connect the OLED display to any available pin but if you use any -// other than what is described above the library will fall back to -// a software-based, TWI-like protocol which will require exclusive access -// to the pins used. -// - -#include - -OLED myOLED(SDA, SCL, 8); - -extern uint8_t SmallFont[]; - -void setup() -{ - myOLED.begin(); - myOLED.setFont(SmallFont); -} - -void loop() -{ - myOLED.clrScr(); - myOLED.print("Upper case:", LEFT, 0); - myOLED.print("ABCDEFGHIJKLM", CENTER, 16); - myOLED.print("NOPQRSTUVWXYZ", CENTER, 24); - myOLED.update(); - delay (5000); - - myOLED.clrScr(); - myOLED.print("Lower case:", LEFT, 0); - myOLED.print("abcdefghijklm", CENTER, 16); - myOLED.print("nopqrstuvwxyz", CENTER, 24); - myOLED.update(); - delay (5000); - - myOLED.clrScr(); - myOLED.print("Numbers:", LEFT, 0); - myOLED.print("0123456789", CENTER, 16); - myOLED.update(); - delay (5000); - - myOLED.clrScr(); - myOLED.print("Special:", LEFT, 0); - myOLED.print("!\"#$%&'()*+,-.", CENTER, 16); - myOLED.print("/:;<=>?@[\\]^_`", CENTER, 24); - myOLED.print("{|}~", CENTER, 32); - myOLED.update(); - delay (5000); -} - - diff --git a/GD32F1/libraries/OLED_I2C/hardware/arm/HW_ARM.h b/GD32F1/libraries/OLED_I2C/hardware/arm/HW_ARM.h deleted file mode 100644 index 49c0a5b..0000000 --- a/GD32F1/libraries/OLED_I2C/hardware/arm/HW_ARM.h +++ /dev/null @@ -1,127 +0,0 @@ -void OLED::_convert_float(char *buf, double num, int width, byte prec) -{ - char format[10]; - - sprintf(format, "%%%i.%if", width, prec); - sprintf(buf, format, num); -} - - -void OLED::_initTWI() -{ - if ((_sda_pin == SDA) and (_scl_pin == SCL)) - { - twi = TWI1; - pmc_enable_periph_clk(WIRE_INTERFACE_ID); - PIO_Configure(g_APinDescription[PIN_WIRE_SDA].pPort, g_APinDescription[PIN_WIRE_SDA].ulPinType, g_APinDescription[PIN_WIRE_SDA].ulPin, g_APinDescription[PIN_WIRE_SDA].ulPinConfiguration); - PIO_Configure(g_APinDescription[PIN_WIRE_SCL].pPort, g_APinDescription[PIN_WIRE_SCL].ulPinType, g_APinDescription[PIN_WIRE_SCL].ulPin, g_APinDescription[PIN_WIRE_SCL].ulPinConfiguration); - NVIC_DisableIRQ(TWI1_IRQn); - NVIC_ClearPendingIRQ(TWI1_IRQn); - NVIC_SetPriority(TWI1_IRQn, 0); - NVIC_EnableIRQ(TWI1_IRQn); - - } - else if ((_sda_pin == SDA1) and (_scl_pin == SCL1)) - { - twi = TWI0; - pmc_enable_periph_clk(WIRE1_INTERFACE_ID); - PIO_Configure(g_APinDescription[PIN_WIRE1_SDA].pPort, g_APinDescription[PIN_WIRE1_SDA].ulPinType, g_APinDescription[PIN_WIRE1_SDA].ulPin, g_APinDescription[PIN_WIRE1_SDA].ulPinConfiguration); - PIO_Configure(g_APinDescription[PIN_WIRE1_SCL].pPort, g_APinDescription[PIN_WIRE1_SCL].ulPinType, g_APinDescription[PIN_WIRE1_SCL].ulPin, g_APinDescription[PIN_WIRE1_SCL].ulPinConfiguration); - NVIC_DisableIRQ(TWI0_IRQn); - NVIC_ClearPendingIRQ(TWI0_IRQn); - NVIC_SetPriority(TWI0_IRQn, 0); - NVIC_EnableIRQ(TWI0_IRQn); - } - - // activate internal pullups for twi. - digitalWrite(SDA, 1); - digitalWrite(SCL, 1); - - // Reset the TWI - twi->TWI_CR = TWI_CR_SWRST; - // TWI Slave Mode Disabled, TWI Master Mode Disabled. - twi->TWI_CR = TWI_CR_SVDIS; - twi->TWI_CR = TWI_CR_MSDIS; - // Set TWI Speed - twi->TWI_CWGR = (TWI_DIV << 16) | (TWI_SPEED << 8) | TWI_SPEED; - // Set master mode - twi->TWI_CR = TWI_CR_MSEN; -} - -void OLED::update() -{ - noInterrupts(); - _sendTWIcommand(SSD1306_SET_COLUMN_ADDR); - _sendTWIcommand(0); - _sendTWIcommand(127); - - _sendTWIcommand(SSD1306_SET_PAGE_ADDR); - _sendTWIcommand(0); - _sendTWIcommand(7); - - if (_use_hw) // Send TWI Start - { - // Set slave address and number of internal address bytes. - twi->TWI_MMR = (1 << 8) | (SSD1306_ADDR << 16); - // Set internal address bytes - twi->TWI_IADR = SSD1306_DATA_CONTINUE; - // Send start address - } - else - { - _sendStart(SSD1306_ADDR<<1); - _waitForAck(); - _writeByte(SSD1306_DATA_CONTINUE); - _waitForAck(); - } - - for (int b=0; b<1024; b++) // Send data - if (_use_hw) - { - twi->TWI_THR = scrbuf[b]; - while ((twi->TWI_SR & TWI_SR_TXRDY) != TWI_SR_TXRDY) {}; - } - else - { - _writeByte(scrbuf[b]); - _waitForAck(); - } - - if (_use_hw) // Send TWI Stop - { - // Send STOP condition - twi->TWI_CR = TWI_CR_STOP; - while ((twi->TWI_SR & TWI_SR_TXCOMP) != TWI_SR_TXCOMP) {}; - } - else - _sendStop(); - interrupts(); -} - -void OLED::_sendTWIcommand(uint8_t value) -{ - if (_use_hw) - { - // Set slave address and number of internal address bytes. - twi->TWI_MMR = (1 << 8) | (SSD1306_ADDR << 16); - // Set internal address bytes - twi->TWI_IADR = SSD1306_COMMAND; - - twi->TWI_THR = value; - while ((twi->TWI_SR & TWI_SR_TXRDY) != TWI_SR_TXRDY) {}; - - // Send STOP condition - twi->TWI_CR = TWI_CR_STOP; - while ((twi->TWI_SR & TWI_SR_TXCOMP) != TWI_SR_TXCOMP) {}; - } - else - { - _sendStart(SSD1306_ADDR<<1); - _waitForAck(); - _writeByte(SSD1306_COMMAND); - _waitForAck(); - _writeByte(value); - _waitForAck(); - _sendStop(); - } -} diff --git a/GD32F1/libraries/OLED_I2C/hardware/arm/HW_ARM_defines.h b/GD32F1/libraries/OLED_I2C/hardware/arm/HW_ARM_defines.h deleted file mode 100644 index 3182890..0000000 --- a/GD32F1/libraries/OLED_I2C/hardware/arm/HW_ARM_defines.h +++ /dev/null @@ -1,22 +0,0 @@ -// *** Hardwarespecific defines *** -#define cbi(reg, bitmask) *reg &= ~bitmask -#define sbi(reg, bitmask) *reg |= bitmask -#define pulseClock cbi(P_SCK, B_SCK); asm ("nop"); sbi(P_SCK, B_SCK) - -#define fontbyte(x) cfont.font[x] -#define bitmapbyte(x) bitmap[x] - -#define bitmapdatatype unsigned char* - -#define SDA 20 -#define SCL 21 -#define SDA1 70 -#define SCL1 71 - -#define TWI_SPEED TWI_SPEED_400k // Set default TWI Speed -#define TWI_SPEED_100k 208 -#define TWI_SPEED_400k 101 - -#define TWI_DIV TWI_DIV_400k // Set divider for TWI Speed (must match TWI_SPEED setting) -#define TWI_DIV_100k 1 -#define TWI_DIV_400k 0 diff --git a/GD32F1/libraries/OLED_I2C/hardware/arm/HW_STM32.h b/GD32F1/libraries/OLED_I2C/hardware/arm/HW_STM32.h deleted file mode 100644 index 7060b44..0000000 --- a/GD32F1/libraries/OLED_I2C/hardware/arm/HW_STM32.h +++ /dev/null @@ -1,168 +0,0 @@ -#include "HardWire.h" -#define WIRE_WRITE HWIRE.write - - HardWire HWIRE(2,I2C_FAST_MODE); // stupid compiler - -void OLED::_convert_float(char *buf, double num, int width, byte prec) -{ - char format[10]; - - sprintf(format, "%%%i.%if", width, prec); - sprintf(buf, format, num); -} - - -void OLED::_initTWI() -{ - if ((_sda_pin == SDA) and (_scl_pin == SCL)) - { - - // HardWire HWIRE(1,I2C_FAST_MODE); // I2c1 - - HWIRE.begin(); - /* - twi = TWI1; - - pmc_enable_periph_clk(WIRE_INTERFACE_ID); - PIO_Configure(g_APinDescription[PIN_WIRE_SDA].pPort, g_APinDescription[PIN_WIRE_SDA].ulPinType, g_APinDescription[PIN_WIRE_SDA].ulPin, g_APinDescription[PIN_WIRE_SDA].ulPinConfiguration); - PIO_Configure(g_APinDescription[PIN_WIRE_SCL].pPort, g_APinDescription[PIN_WIRE_SCL].ulPinType, g_APinDescription[PIN_WIRE_SCL].ulPin, g_APinDescription[PIN_WIRE_SCL].ulPinConfiguration); - NVIC_DisableIRQ(TWI1_IRQn); - NVIC_ClearPendingIRQ(TWI1_IRQn); - NVIC_SetPriority(TWI1_IRQn, 0); - NVIC_EnableIRQ(TWI1_IRQn); - */ - - } - else if ((_sda_pin == SDA1) and (_scl_pin == SCL1)) - { - HWIRE.begin(); - // I2c2 - // HardWire HWIRE(2,I2C_FAST_MODE); - // HWIRE.begin(); - - /* - twi = TWI0; - - pmc_enable_periph_clk(WIRE1_INTERFACE_ID); - PIO_Configure(g_APinDescription[PIN_WIRE1_SDA].pPort, g_APinDescription[PIN_WIRE1_SDA].ulPinType, g_APinDescription[PIN_WIRE1_SDA].ulPin, g_APinDescription[PIN_WIRE1_SDA].ulPinConfiguration); - PIO_Configure(g_APinDescription[PIN_WIRE1_SCL].pPort, g_APinDescription[PIN_WIRE1_SCL].ulPinType, g_APinDescription[PIN_WIRE1_SCL].ulPin, g_APinDescription[PIN_WIRE1_SCL].ulPinConfiguration); - NVIC_DisableIRQ(TWI0_IRQn); - NVIC_ClearPendingIRQ(TWI0_IRQn); - NVIC_SetPriority(TWI0_IRQn, 0); - NVIC_EnableIRQ(TWI0_IRQn); - */ - } - - // activate internal pullups for twi. -// digitalWrite(SDA, 1); - //digitalWrite(SCL, 1); -/* - // Reset the TWI - twi->TWI_CR = TWI_CR_SWRST; - // TWI Slave Mode Disabled, TWI Master Mode Disabled. - twi->TWI_CR = TWI_CR_SVDIS; - twi->TWI_CR = TWI_CR_MSDIS; - // Set TWI Speed - twi->TWI_CWGR = (TWI_DIV << 16) | (TWI_SPEED << 8) | TWI_SPEED; - // Set master mode - twi->TWI_CR = TWI_CR_MSEN; - */ -} - -void OLED::update() -{ - //noInterrupts(); - _sendTWIcommand(SSD1306_SET_COLUMN_ADDR); - _sendTWIcommand(0); - _sendTWIcommand(127); - - _sendTWIcommand(SSD1306_SET_PAGE_ADDR); - _sendTWIcommand(0); - _sendTWIcommand(7); - - if (_use_hw) // Send TWI Start - { - HWIRE.beginTransmission(SSD1306_ADDR); - WIRE_WRITE(SSD1306_DATA_CONTINUE); - /* - // Set slave address and number of internal address bytes. - twi->TWI_MMR = (1 << 8) | (SSD1306_ADDR << 16); - // Set internal address bytes - twi->TWI_IADR = SSD1306_DATA_CONTINUE; - // Send start address - */ - - - } - else - { - _sendStart(SSD1306_ADDR<<1); - _waitForAck(); - _writeByte(SSD1306_DATA_CONTINUE); - _waitForAck(); - } - - for (int b=0; b<1024; b++) // Send data - if (_use_hw) - { - /* - twi->TWI_THR = scrbuf[b]; - while ((twi->TWI_SR & TWI_SR_TXRDY) != TWI_SR_TXRDY) {}; - */ - static byte aa=scrbuf[b]; - WIRE_WRITE(aa); - - } - else - { - _writeByte(scrbuf[b]); - _waitForAck(); - } - - if (_use_hw) // Send TWI Stop - { - HWIRE.endTransmission(); - /* - // Send STOP condition - twi->TWI_CR = TWI_CR_STOP; - while ((twi->TWI_SR & TWI_SR_TXCOMP) != TWI_SR_TXCOMP) {}; - */ - } - else - _sendStop(); - //interrupts(); -} - -void OLED::_sendTWIcommand(uint8_t value) -{ - if (_use_hw) - { - HWIRE.beginTransmission(SSD1306_ADDR); - WIRE_WRITE(SSD1306_COMMAND); - WIRE_WRITE(value); - HWIRE.endTransmission(); - /* - // Set slave address and number of internal address bytes. - twi->TWI_MMR = (1 << 8) | (SSD1306_ADDR << 16); - // Set internal address bytes - twi->TWI_IADR = SSD1306_COMMAND; - - twi->TWI_THR = value; - while ((twi->TWI_SR & TWI_SR_TXRDY) != TWI_SR_TXRDY) {}; - - // Send STOP condition - twi->TWI_CR = TWI_CR_STOP; - while ((twi->TWI_SR & TWI_SR_TXCOMP) != TWI_SR_TXCOMP) {}; - */ - } - else - { - _sendStart(SSD1306_ADDR<<1); - _waitForAck(); - _writeByte(SSD1306_COMMAND); - _waitForAck(); - _writeByte(value); - _waitForAck(); - _sendStop(); - } -} diff --git a/GD32F1/libraries/OLED_I2C/hardware/arm/HW_STM32_defines.h b/GD32F1/libraries/OLED_I2C/hardware/arm/HW_STM32_defines.h deleted file mode 100644 index c79a070..0000000 --- a/GD32F1/libraries/OLED_I2C/hardware/arm/HW_STM32_defines.h +++ /dev/null @@ -1,22 +0,0 @@ -// *** Hardwarespecific defines *** -#define cbi(reg, bitmask) *reg &= ~bitmask -#define sbi(reg, bitmask) *reg |= bitmask -#define pulseClock cbi(P_SCK, B_SCK); asm ("nop"); sbi(P_SCK, B_SCK) - -#define fontbyte(x) cfont.font[x] -#define bitmapbyte(x) bitmap[x] - -#define bitmapdatatype unsigned char* - -#define SDA1 0 -#define SCL1 1 -#define SDA 15 -#define SCL 16 - -#define TWI_SPEED TWI_SPEED_400k // Set default TWI Speed -#define TWI_SPEED_100k 208 -#define TWI_SPEED_400k 101 - -#define TWI_DIV TWI_DIV_400k // Set divider for TWI Speed (must match TWI_SPEED setting) -#define TWI_DIV_100k 1 -#define TWI_DIV_400k 0 diff --git a/GD32F1/libraries/OLED_I2C/hardware/avr/HW_AVR.h b/GD32F1/libraries/OLED_I2C/hardware/avr/HW_AVR.h deleted file mode 100644 index 9ded737..0000000 --- a/GD32F1/libraries/OLED_I2C/hardware/avr/HW_AVR.h +++ /dev/null @@ -1,103 +0,0 @@ -void OLED::_convert_float(char *buf, double num, int width, byte prec) -{ - dtostrf(num, width, prec, buf); -} - -void OLED::_initTWI() -{ - // activate internal pullups for twi. - digitalWrite(SDA, HIGH); - digitalWrite(SCL, HIGH); - //delay(1); // Workaround for a linker bug - - // initialize twi prescaler and bit rate - __cbi2(TWSR, TWPS0); - __cbi2(TWSR, TWPS1); - TWBR = ((F_CPU / TWI_FREQ) - 16) / 2; - - // enable twi module, acks, and twi interrupt - TWCR = _BV(TWEN) | _BV(TWIE)/* | _BV(TWEA)*/; -} - -void OLED::update() -{ - noInterrupts(); - _sendTWIcommand(SSD1306_SET_COLUMN_ADDR); - _sendTWIcommand(0); - _sendTWIcommand(127); - - _sendTWIcommand(SSD1306_SET_PAGE_ADDR); - _sendTWIcommand(0); - _sendTWIcommand(7); - - if (_use_hw) // Send TWI Start - { - // Send start address - TWCR = _BV(TWEN) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA); - while ((TWCR & _BV(TWINT)) == 0) {}; - TWDR = SSD1306_ADDR<<1; - TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWEA); - while ((TWCR & _BV(TWINT)) == 0) {}; - TWDR = SSD1306_DATA_CONTINUE; - TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWEA); - while ((TWCR & _BV(TWINT)) == 0) {}; - } - else - { - _sendStart(SSD1306_ADDR<<1); - _waitForAck(); - _writeByte(SSD1306_DATA_CONTINUE); - _waitForAck(); - } - - for (int b=0; b<1024; b++) // Send data - if (_use_hw) - { - TWDR = scrbuf[b]; - TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWEA); // Clear TWINT to proceed - while ((TWCR & _BV(TWINT)) == 0) {}; // Wait for TWI to be ready - } - else - { - _writeByte(scrbuf[b]); - _waitForAck(); - } - - if (_use_hw) // Send TWI Stop - TWCR = _BV(TWEN)| _BV(TWINT) | _BV(TWSTO); // Send STOP - else - _sendStop(); - interrupts(); -} - -void OLED::_sendTWIcommand(uint8_t value) -{ - if (_use_hw) - { - // Send start address - TWCR = _BV(TWEN) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA); // Send START - while ((TWCR & _BV(TWINT)) == 0) {}; // Wait for TWI to be ready - TWDR = SSD1306_ADDR<<1; - TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWEA); // Clear TWINT to proceed - while ((TWCR & _BV(TWINT)) == 0) {}; // Wait for TWI to be ready - - TWDR = SSD1306_COMMAND; - TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWEA); // Clear TWINT to proceed - while ((TWCR & _BV(TWINT)) == 0) {}; // Wait for TWI to be ready - TWDR = value; - TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWEA); // Clear TWINT to proceed - while ((TWCR & _BV(TWINT)) == 0) {}; // Wait for TWI to be ready - - TWCR = _BV(TWEN)| _BV(TWINT) | _BV(TWSTO); // Send STOP - } - else - { - _sendStart(SSD1306_ADDR<<1); - _waitForAck(); - _writeByte(SSD1306_COMMAND); - _waitForAck(); - _writeByte(value); - _waitForAck(); - _sendStop(); - } -} diff --git a/GD32F1/libraries/OLED_I2C/hardware/avr/HW_AVR_defines.h b/GD32F1/libraries/OLED_I2C/hardware/avr/HW_AVR_defines.h deleted file mode 100644 index 92a4afa..0000000 --- a/GD32F1/libraries/OLED_I2C/hardware/avr/HW_AVR_defines.h +++ /dev/null @@ -1,14 +0,0 @@ -// *** Hardwarespecific defines *** -#define __cbi(reg, bitmask) *reg &= ~bitmask -#define __cbi2(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) -#define __sbi(reg, bitmask) *reg |= bitmask -#define pulseClock __cbi(P_SCK, B_SCK); asm ("nop"); __sbi(P_SCK, B_SCK) - -#define fontbyte(x) pgm_read_byte(&cfont.font[x]) -#define bitmapbyte(x) pgm_read_byte(&bitmap[x]) - -#define bitmapdatatype uint8_t* - -#ifndef TWI_FREQ - #define TWI_FREQ 400000L -#endif diff --git a/GD32F1/libraries/OLED_I2C/hardware/pic32/HW_PIC32.h b/GD32F1/libraries/OLED_I2C/hardware/pic32/HW_PIC32.h deleted file mode 100644 index df53aa0..0000000 --- a/GD32F1/libraries/OLED_I2C/hardware/pic32/HW_PIC32.h +++ /dev/null @@ -1,121 +0,0 @@ -void OLED::_convert_float(char *buf, double num, int width, byte prec) -{ - char format[10]; - - sprintf(format, "%%%i.%if", width, prec); - sprintf(buf, format, num); -} - -inline void _waitForIdleBus() { while (I2C1CON & 0x1f) {} } - -void OLED::_initTWI() -{ - uint32_t tpgd; - - pinMode(SDA, OUTPUT); - digitalWrite(SDA, HIGH); - IFS0CLR = 0xE0000000; // Clear Interrupt Flag - IEC0CLR = 0xE0000000; // Disable Interrupt - I2C1CONCLR = (1 << _I2CCON_ON); // Disable I2C interface - tpgd = ((F_CPU / 8) * 104) / 125000000; - I2C1BRG = (F_CPU / (2 * TWI_FREQ) - tpgd) - 2; // Set I2C Speed - I2C1ADD = SSD1306_ADDR; // Set I2C device address - I2C1CONSET = (1 << _I2CCON_ON) | (1 << _I2CCON_STREN); // Enable I2C Interface -} - -void OLED::update() -{ - noInterrupts(); - _sendTWIcommand(SSD1306_SET_COLUMN_ADDR); - _sendTWIcommand(0); - _sendTWIcommand(127); - - _sendTWIcommand(SSD1306_SET_PAGE_ADDR); - _sendTWIcommand(0); - _sendTWIcommand(7); - - if (_use_hw) // Send TWI Start - { - _waitForIdleBus(); // Wait for I2C bus to be Idle before starting - I2C1CONSET = (1 << _I2CCON_SEN); // Send start condition - if (I2C1STAT & (1 << _I2CSTAT_BCL)) { return; } // Check if there is a bus collision - while (I2C1CON & (1 << _I2CCON_SEN)) {} // Wait for start condition to finish - I2C1TRN = (SSD1306_ADDR<<1); // Send device Write address - while (I2C1STAT & (1 << _I2CSTAT_IWCOL)) // Check if there is a Write collision - { - I2C1STATCLR = (1 << _I2CSTAT_IWCOL); // Clear Write collision flag - I2C1TRN = (SSD1306_ADDR<<1); // Retry send device Write address - } - while (I2C1STAT & (1 << _I2CSTAT_TRSTAT)) {} // Wait for transmit to finish - while (I2C1STAT & (1 << _I2CSTAT_ACKSTAT)) {} // Wait for ACK - I2C1TRN = SSD1306_DATA_CONTINUE; // Send the command for continous data - while (I2C1STAT & (1 << _I2CSTAT_TRSTAT)) {} // Wait for transmit to finish - while (I2C1STAT & (1 << _I2CSTAT_ACKSTAT)) {} // Wait for ACK - } - else - { - _sendStart(SSD1306_ADDR<<1); - _waitForAck(); - _writeByte(SSD1306_DATA_CONTINUE); - _waitForAck(); - } - - for (int b=0; b<1024; b++) // Send data - if (_use_hw) - { - I2C1TRN = scrbuf[b]; - while (I2C1STAT & (1 << _I2CSTAT_TRSTAT)) {} - while (I2C1STAT & (1 << _I2CSTAT_ACKSTAT)) {} - } - else - { - _writeByte(scrbuf[b]); - _waitForAck(); - } - - if (_use_hw) // Send TWI Stop - { - I2C1CONSET = (1 << _I2CCON_PEN); // Send stop condition - while (I2C1CON & (1 << _I2CCON_PEN)) {} // Wait for stop condition to finish - } - else - _sendStop(); - interrupts(); -} - -void OLED::_sendTWIcommand(uint8_t value) -{ - if (_use_hw) - { - _waitForIdleBus(); // Wait for I2C bus to be Idle before starting - I2C1CONSET = (1 << _I2CCON_SEN); // Send start condition - if (I2C1STAT & (1 << _I2CSTAT_BCL)) { return; } // Check if there is a bus collision - while (I2C1CON & (1 << _I2CCON_SEN)) {} // Wait for start condition to finish - I2C1TRN = (SSD1306_ADDR<<1); // Send device Write address - while (I2C1STAT & (1 << _I2CSTAT_IWCOL)) // Check if there is a Write collision - { - I2C1STATCLR = (1 << _I2CSTAT_IWCOL); // Clear Write collision flag - I2C1TRN = (SSD1306_ADDR<<1); // Retry send device Write address - } - while (I2C1STAT & (1 << _I2CSTAT_TRSTAT)) {} // Wait for transmit to finish - while (I2C1STAT & (1 << _I2CSTAT_ACKSTAT)) {} // Wait for ACK - I2C1TRN = SSD1306_COMMAND; // Send the 1st data byte - while (I2C1STAT & (1 << _I2CSTAT_TRSTAT)) {} // Wait for transmit to finish - while (I2C1STAT & (1 << _I2CSTAT_ACKSTAT)) {} // Wait for ACK - I2C1TRN = value; // Send the 2nd data byte - while (I2C1STAT & (1 << _I2CSTAT_TRSTAT)) {} // Wait for transmit to finish - while (I2C1STAT & (1 << _I2CSTAT_ACKSTAT)) {} // Wait for ACK - I2C1CONSET = (1 << _I2CCON_PEN); // Send stop condition - while (I2C1CON & (1 << _I2CCON_PEN)) {} // Wait for stop condition to finish - } - else - { - _sendStart(SSD1306_ADDR<<1); - _waitForAck(); - _writeByte(SSD1306_COMMAND); - _waitForAck(); - _writeByte(value); - _waitForAck(); - _sendStop(); - } -} diff --git a/GD32F1/libraries/OLED_I2C/hardware/pic32/HW_PIC32_defines.h b/GD32F1/libraries/OLED_I2C/hardware/pic32/HW_PIC32_defines.h deleted file mode 100644 index a14c1f9..0000000 --- a/GD32F1/libraries/OLED_I2C/hardware/pic32/HW_PIC32_defines.h +++ /dev/null @@ -1,30 +0,0 @@ -// *** Hardwarespecific defines *** -#define __cbi(reg, bitmask) (*(reg + 1)) = bitmask -#define __sbi(reg, bitmask) (*(reg + 2)) = bitmask -#define pulseClock digitalWrite(SCK_Pin, LOW); digitalWrite(SCK_Pin, HIGH) - -#define fontbyte(x) cfont.font[x] -#define bitmapbyte(x) bitmap[x] - -#define PROGMEM -#define bitmapdatatype unsigned char* - -#if !defined(_UP_MCU_) - #if defined(__32MX320F128H__) - #define SDA 18 // A4 (Remeber to set the jumper correctly) - #define SCL 19 // A5 (Remeber to set the jumper correctly) - #elif defined(__32MX340F512H__) - #define SDA 18 // A4 (Remeber to set the jumper correctly) - #define SCL 19 // A5 (Remeber to set the jumper correctly) - #elif defined(__32MX795F512L__) - #define SDA 20 // Digital 20 - #define SCL 21 // Digital 21 - #else - #error "Unsupported PIC32 MCU!" - #endif -#endif - -#ifndef TWI_FREQ - #define TWI_FREQ 400000L -#endif - diff --git a/GD32F1/libraries/OLED_I2C/keywords.txt b/GD32F1/libraries/OLED_I2C/keywords.txt deleted file mode 100644 index 4f144ca..0000000 --- a/GD32F1/libraries/OLED_I2C/keywords.txt +++ /dev/null @@ -1,31 +0,0 @@ -OLED KEYWORD1 - -begin KEYWORD2 -setBrightness KEYWORD2 -update KEYWORD2 -clrScr KEYWORD2 -fillScr KEYWORD2 -invert KEYWORD2 -setPixel KEYWORD2 -clrPixel KEYWORD2 -invPixel KEYWORD2 -invertText KEYWORD2 -print KEYWORD2 -printNumI KEYWORD2 -printNumF KEYWORD2 -setFont KEYWORD2 -drawBitmap KEYWORD2 -drawLine KEYWORD2 -clrLine KEYWORD2 -drawRect KEYWORD2 -clrRect KEYWORD2 -drawRoundRect KEYWORD2 -clrRoundRect KEYWORD2 -drawCircle KEYWORD2 -clrCircle KEYWORD2 - -LEFT LITERAL1 -RIGHT LITERAL1 -CENTER LITERAL1 - -RST_NOT_IN_USE LITERAL1 diff --git a/GD32F1/libraries/OneWireSTM/examples/DS18x20_Temperature/DS18x20_Temperature.ino b/GD32F1/libraries/OneWireSTM/examples/DS18x20_Temperature/DS18x20_Temperature.ino deleted file mode 100644 index f8c4b74..0000000 --- a/GD32F1/libraries/OneWireSTM/examples/DS18x20_Temperature/DS18x20_Temperature.ino +++ /dev/null @@ -1,112 +0,0 @@ -#include - -// OneWire DS18S20, DS18B20, DS1822 Temperature Example -// -// Based on version by PJRC -// -// The DallasTemperature library can do all this work for you! -// http://milesburton.com/Dallas_Temperature_Control_Library - -OneWire ds(10); // on pin 10 (a 4.7K resistor is necessary) - -void setup(void) { - Serial.begin(9600); -} - -void loop(void) { - byte i; - byte present = 0; - byte type_s; - byte data[12]; - byte addr[8]; - float celsius, fahrenheit; - - if ( !ds.search(addr)) { - Serial.println("No more addresses."); - Serial.println(); - ds.reset_search(); - delay(250); - return; - } - - Serial.print("ROM ="); - for( i = 0; i < 8; i++) { - Serial.write(' '); - Serial.print(addr[i], HEX); - } - - if (OneWire::crc8(addr, 7) != addr[7]) { - Serial.println("CRC is not valid!"); - return; - } - Serial.println(); - - // the first ROM byte indicates which chip - switch (addr[0]) { - case 0x10: - Serial.println(" Chip = DS18S20"); // or old DS1820 - type_s = 1; - break; - case 0x28: - Serial.println(" Chip = DS18B20"); - type_s = 0; - break; - case 0x22: - Serial.println(" Chip = DS1822"); - type_s = 0; - break; - default: - Serial.println("Device is not a DS18x20 family device."); - return; - } - - ds.reset(); - ds.select(addr); - ds.write(0x44, 1); // start conversion, with parasite power on at the end - - delay(1000); // maybe 750ms is enough, maybe not - // we might do a ds.depower() here, but the reset will take care of it. - - present = ds.reset(); - ds.select(addr); - ds.write(0xBE); // Read Scratchpad - - Serial.print(" Data = "); - Serial.print(present, HEX); - Serial.print(" "); - for ( i = 0; i < 9; i++) { // we need 9 bytes - data[i] = ds.read(); - Serial.print(data[i], HEX); - Serial.print(" "); - } - Serial.print(" CRC="); - Serial.print(OneWire::crc8(data, 8), HEX); - Serial.println(); - - // Convert the data to actual temperature - // because the result is a 16 bit signed integer, it should - // be stored to an "int16_t" type, which is always 16 bits - // even when compiled on a 32 bit processor. - int16_t raw = (data[1] << 8) | data[0]; - if (type_s) { - raw = raw << 3; // 9 bit resolution default - if (data[7] == 0x10) { - // "count remain" gives full 12 bit resolution - raw = (raw & 0xFFF0) + 12 - data[6]; - } - } else { - byte cfg = (data[4] & 0x60); - // at lower res, the low bits are undefined, so let's zero them - if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms - else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms - else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms - //// default is 12 bit resolution, 750 ms conversion time - } - celsius = (float)raw / 16.0; - fahrenheit = celsius * 1.8 + 32.0; - Serial.print(" Temperature = "); - Serial.print(celsius); - Serial.print(" Celsius, "); - Serial.print(fahrenheit); - Serial.println(" Fahrenheit"); -} diff --git a/GD32F1/libraries/OneWireSTM/examples/DS2408_Switch/DS2408_Switch.ino b/GD32F1/libraries/OneWireSTM/examples/DS2408_Switch/DS2408_Switch.ino deleted file mode 100644 index 7386fb6..0000000 --- a/GD32F1/libraries/OneWireSTM/examples/DS2408_Switch/DS2408_Switch.ino +++ /dev/null @@ -1,77 +0,0 @@ -#include - -/* - * DS2408 8-Channel Addressable Switch - * - * Writte by Glenn Trewitt, glenn at trewitt dot org - * - * Some notes about the DS2408: - * - Unlike most input/output ports, the DS2408 doesn't have mode bits to - * set whether the pins are input or output. If you issue a read command, - * they're inputs. If you write to them, they're outputs. - * - For reading from a switch, you should use 10K pull-up resisters. - */ - -void PrintBytes(uint8_t* addr, uint8_t count, bool newline=0) { - for (uint8_t i = 0; i < count; i++) { - Serial.print(addr[i]>>4, HEX); - Serial.print(addr[i]&0x0f, HEX); - } - if (newline) - Serial.println(); -} - -void ReadAndReport(OneWire* net, uint8_t* addr) { - Serial.print(" Reading DS2408 "); - PrintBytes(addr, 8); - Serial.println(); - - uint8_t buf[13]; // Put everything in the buffer so we can compute CRC easily. - buf[0] = 0xF0; // Read PIO Registers - buf[1] = 0x88; // LSB address - buf[2] = 0x00; // MSB address - net->write_bytes(buf, 3); - net->read_bytes(buf+3, 10); // 3 cmd bytes, 6 data bytes, 2 0xFF, 2 CRC16 - net->reset(); - - if (!OneWire::check_crc16(buf, 11, &buf[11])) { - Serial.print("CRC failure in DS2408 at "); - PrintBytes(addr, 8, true); - return; - } - Serial.print(" DS2408 data = "); - // First 3 bytes contain command, register address. - Serial.println(buf[3], BIN); -} - -OneWire net(10); // on pin 10 - -void setup(void) { - Serial.begin(9600); -} - -void loop(void) { - byte i; - byte present = 0; - byte addr[8]; - - if (!net.search(addr)) { - Serial.print("No more addresses.\n"); - net.reset_search(); - delay(1000); - return; - } - - if (OneWire::crc8(addr, 7) != addr[7]) { - Serial.print("CRC is not valid!\n"); - return; - } - - if (addr[0] != 0x29) { - PrintBytes(addr, 8); - Serial.print(" is not a DS2408.\n"); - return; - } - - ReadAndReport(&net, addr); -} diff --git a/GD32F1/libraries/OneWireSTM/examples/DS250x_PROM/DS250x_PROM.ino b/GD32F1/libraries/OneWireSTM/examples/DS250x_PROM/DS250x_PROM.ino deleted file mode 100644 index 8aed5cb..0000000 --- a/GD32F1/libraries/OneWireSTM/examples/DS250x_PROM/DS250x_PROM.ino +++ /dev/null @@ -1,90 +0,0 @@ -/* -DS250x add-only programmable memory reader w/SKIP ROM. - - The DS250x is a 512/1024bit add-only PROM(you can add data but cannot change the old one) that's used mainly for device identification purposes - like serial number, mfgr data, unique identifiers, etc. It uses the Maxim 1-wire bus. - - This sketch will use the SKIP ROM function that skips the 1-Wire search phase since we only have one device connected in the bus on digital pin 6. - If more than one device is connected to the bus, it will fail. - Sketch will not verify if device connected is from the DS250x family since the skip rom function effectively skips the family-id byte readout. - thus it is possible to run this sketch with any Maxim OneWire device in which case the command CRC will most likely fail. - Sketch will only read the first page of memory(32bits) starting from the lower address(0000h), if more than 1 device is present, then use the sketch with search functions. - Remember to put a 4.7K pullup resistor between pin 6 and +Vcc - - To change the range or ammount of data to read, simply change the data array size, LSB/MSB addresses and for loop iterations - - This example code is in the public domain and is provided AS-IS. - - Based on the version by PJRC - - created by Guillermo Lovato - march/2011 - - */ - -#include -OneWire ds(6); // OneWire bus on digital pin 6 -void setup() { - Serial.begin (9600); -} - -void loop() { - byte i; // This is for the for loops - boolean present; // device present var - byte data[32]; // container for the data from device - byte leemem[3] = { // array with the commands to initiate a read, DS250x devices expect 3 bytes to start a read: command,LSB&MSB adresses - 0xF0 , 0x00 , 0x00 }; // 0xF0 is the Read Data command, followed by 00h 00h as starting address(the beginning, 0000h) - byte ccrc; // Variable to store the command CRC - byte ccrc_calc; - - present = ds.reset(); // OneWire bus reset, always needed to start operation on the bus, returns a 1/TRUE if there's a device present. - ds.skip(); // Skip ROM search - - if (present == TRUE){ // We only try to read the data if there's a device present - Serial.println("DS250x device present"); - ds.write(leemem[0],1); // Read data command, leave ghost power on - ds.write(leemem[1],1); // LSB starting address, leave ghost power on - ds.write(leemem[2],1); // MSB starting address, leave ghost power on - - ccrc = ds.read(); // DS250x generates a CRC for the command we sent, we assign a read slot and store it's value - ccrc_calc = OneWire::crc8(leemem, 3); // We calculate the CRC of the commands we sent using the library function and store it - - if ( ccrc_calc != ccrc) { // Then we compare it to the value the ds250x calculated, if it fails, we print debug messages and abort - Serial.println("Invalid command CRC!"); - Serial.print("Calculated CRC:"); - Serial.println(ccrc_calc,HEX); // HEX makes it easier to observe and compare - Serial.print("DS250x readback CRC:"); - Serial.println(ccrc,HEX); - return; // Since CRC failed, we abort the rest of the loop and start over - } - Serial.println("Data is: "); // For the printout of the data - for ( i = 0; i < 32; i++) { // Now it's time to read the PROM data itself, each page is 32 bytes so we need 32 read commands - data[i] = ds.read(); // we store each read byte to a different position in the data array - Serial.print(data[i]); // printout in ASCII - Serial.print(" "); // blank space - } - Serial.println(); - delay(5000); // Delay so we don't saturate the serial output - } - else { // Nothing is connected in the bus - Serial.println("Nothing connected"); - delay(3000); - } -} - - - - - - - - - - - - - - - - - diff --git a/GD32F1/libraries/OneWireSTM/keywords.txt b/GD32F1/libraries/OneWireSTM/keywords.txt deleted file mode 100644 index e17f554..0000000 --- a/GD32F1/libraries/OneWireSTM/keywords.txt +++ /dev/null @@ -1,38 +0,0 @@ -####################################### -# Syntax Coloring Map For OneWire -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -OneWireSTM KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -reset KEYWORD2 -write_bit KEYWORD2 -read_bit KEYWORD2 -write KEYWORD2 -write_bytes KEYWORD2 -read KEYWORD2 -read_bytes KEYWORD2 -select KEYWORD2 -skip KEYWORD2 -depower KEYWORD2 -reset_search KEYWORD2 -search KEYWORD2 -crc8 KEYWORD2 -crc16 KEYWORD2 -check_crc16 KEYWORD2 - -####################################### -# Instances (KEYWORD2) -####################################### - - -####################################### -# Constants (LITERAL1) -####################################### diff --git a/GD32F1/libraries/OneWireSTM/library.properties b/GD32F1/libraries/OneWireSTM/library.properties deleted file mode 100644 index e2e76d4..0000000 --- a/GD32F1/libraries/OneWireSTM/library.properties +++ /dev/null @@ -1,8 +0,0 @@ -name=OneWireSTM -version=1.0 -author=Various - updated for STM by Roger Clark -email= -sentence=Dallas One Wire for STM -paragraph=OneWire for STM32F1 -url= -architectures=STM32F1 diff --git a/GD32F1/libraries/OneWireSTM/src/OneWireSTM.cpp b/GD32F1/libraries/OneWireSTM/src/OneWireSTM.cpp deleted file mode 100644 index 3b43c13..0000000 --- a/GD32F1/libraries/OneWireSTM/src/OneWireSTM.cpp +++ /dev/null @@ -1,558 +0,0 @@ -/* -Copyright (c) 2007, Jim Studt (original old version - many contributors since) - -The latest version of this library may be found at: - http://www.pjrc.com/teensy/td_libs_OneWire.html - -OneWire has been maintained by Paul Stoffregen (paul@pjrc.com) since -January 2010. At the time, it was in need of many bug fixes, but had -been abandoned the original author (Jim Studt). None of the known -contributors were interested in maintaining OneWire. Paul typically -works on OneWire every 6 to 12 months. Patches usually wait that -long. If anyone is interested in more actively maintaining OneWire, -please contact Paul. - -Version 2.2: - Teensy 3.0 compatibility, Paul Stoffregen, paul@pjrc.com - Arduino Due compatibility, http://arduino.cc/forum/index.php?topic=141030 - Fix DS18B20 example negative temperature - Fix DS18B20 example's low res modes, Ken Butcher - Improve reset timing, Mark Tillotson - Add const qualifiers, Bertrik Sikken - Add initial value input to crc16, Bertrik Sikken - Add target_search() function, Scott Roberts - -Version 2.1: - Arduino 1.0 compatibility, Paul Stoffregen - Improve temperature example, Paul Stoffregen - DS250x_PROM example, Guillermo Lovato - PIC32 (chipKit) compatibility, Jason Dangel, dangel.jason AT gmail.com - Improvements from Glenn Trewitt: - - crc16() now works - - check_crc16() does all of calculation/checking work. - - Added read_bytes() and write_bytes(), to reduce tedious loops. - - Added ds2408 example. - Delete very old, out-of-date readme file (info is here) - -Version 2.0: Modifications by Paul Stoffregen, January 2010: -http://www.pjrc.com/teensy/td_libs_OneWire.html - Search fix from Robin James - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 - Use direct optimized I/O in all cases - Disable interrupts during timing critical sections - (this solves many random communication errors) - Disable interrupts during read-modify-write I/O - Reduce RAM consumption by eliminating unnecessary - variables and trimming many to 8 bits - Optimize both crc8 - table version moved to flash - -Modified to work with larger numbers of devices - avoids loop. -Tested in Arduino 11 alpha with 12 sensors. -26 Sept 2008 -- Robin James -http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 - -Updated to work with arduino-0008 and to include skip() as of -2007/07/06. --RJL20 - -Modified to calculate the 8-bit CRC directly, avoiding the need for -the 256-byte lookup table to be loaded in RAM. Tested in arduino-0010 --- Tom Pollard, Jan 23, 2008 - -Jim Studt's original library was modified by Josh Larios. - -Tom Pollard, pollard@alum.mit.edu, contributed around May 20, 2008 - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Much of the code was inspired by Derek Yerger's code, though I don't -think much of that remains. In any event that was.. - (copyleft) 2006 by Derek Yerger - Free to distribute freely. - -The CRC code was excerpted and inspired by the Dallas Semiconductor -sample code bearing this copyright. -//--------------------------------------------------------------------------- -// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES -// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// -// Except as contained in this notice, the name of Dallas Semiconductor -// shall not be used except as stated in the Dallas Semiconductor -// Branding Policy. -//-------------------------------------------------------------------------- -*/ - -#include "OneWireSTM.h" - - -OneWire::OneWire(uint8_t pin) -{ - //pinMode(pin, INPUT); - bitmask = PIN_TO_BITMASK(pin); - baseReg = PIN_TO_BASEREG(pin); -#if ONEWIRE_SEARCH - reset_search(); -#endif -} - - -// Perform the onewire reset function. We will wait up to 250uS for -// the bus to come high, if it doesn't then it is broken or shorted -// and we return a 0; -// -// Returns 1 if a device asserted a presence pulse, 0 otherwise. -// -uint8_t OneWire::reset(void) -{ - IO_REG_TYPE mask = bitmask; - volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; - uint8_t r; - uint8_t retries = 125; - - noInterrupts(); - DIRECT_MODE_INPUT(reg, mask); - interrupts(); - // wait until the wire is high... just in case - do { - if (--retries == 0) return 0; - delayMicroseconds(2); - } while ( !DIRECT_READ(reg, mask)); - - noInterrupts(); - DIRECT_WRITE_LOW(reg, mask); - DIRECT_MODE_OUTPUT(reg, mask); // drive output low - interrupts(); - delayMicroseconds(480); - noInterrupts(); - DIRECT_MODE_INPUT(reg, mask); // allow it to float - delayMicroseconds(70); - r = !DIRECT_READ(reg, mask); - interrupts(); - delayMicroseconds(410); - return r; -} - -// -// Write a bit. Port and bit is used to cut lookup time and provide -// more certain timing. -// -void OneWire::write_bit(uint8_t v) -{ - IO_REG_TYPE mask=bitmask; - volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; - - if (v & 1) { - noInterrupts(); - DIRECT_WRITE_LOW(reg, mask); - DIRECT_MODE_OUTPUT(reg, mask); // drive output low - delayMicroseconds(10); - DIRECT_WRITE_HIGH(reg, mask); // drive output high - interrupts(); - delayMicroseconds(55); - } else { - noInterrupts(); - DIRECT_WRITE_LOW(reg, mask); - DIRECT_MODE_OUTPUT(reg, mask); // drive output low - delayMicroseconds(65); - DIRECT_WRITE_HIGH(reg, mask); // drive output high - interrupts(); - delayMicroseconds(5); - } -} - -// -// Read a bit. Port and bit is used to cut lookup time and provide -// more certain timing. -// -uint8_t OneWire::read_bit(void) -{ - IO_REG_TYPE mask=bitmask; - volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; - uint8_t r; - - noInterrupts(); - DIRECT_MODE_OUTPUT(reg, mask); - DIRECT_WRITE_LOW(reg, mask); - delayMicroseconds(3); - DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise - delayMicroseconds(10); - r = DIRECT_READ(reg, mask); - interrupts(); - delayMicroseconds(53); - return r; -} - -// -// Write a byte. The writing code uses the active drivers to raise the -// pin high, if you need power after the write (e.g. DS18S20 in -// parasite power mode) then set 'power' to 1, otherwise the pin will -// go tri-state at the end of the write to avoid heating in a short or -// other mishap. -// -void OneWire::write(uint8_t v, uint8_t power /* = 0 */) { - uint8_t bitMask; - - for (bitMask = 0x01; bitMask; bitMask <<= 1) { - OneWire::write_bit( (bitMask & v)?1:0); - } - if ( !power) { - noInterrupts(); - DIRECT_MODE_INPUT(baseReg, bitmask); - DIRECT_WRITE_LOW(baseReg, bitmask); - interrupts(); - } -} - -void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) { - for (uint16_t i = 0 ; i < count ; i++) - write(buf[i]); - if (!power) { - noInterrupts(); - DIRECT_MODE_INPUT(baseReg, bitmask); - DIRECT_WRITE_LOW(baseReg, bitmask); - interrupts(); - } -} - -// -// Read a byte -// -uint8_t OneWire::read() { - uint8_t bitMask; - uint8_t r = 0; - - for (bitMask = 0x01; bitMask; bitMask <<= 1) { - if ( OneWire::read_bit()) r |= bitMask; - } - return r; -} - -void OneWire::read_bytes(uint8_t *buf, uint16_t count) { - for (uint16_t i = 0 ; i < count ; i++) - buf[i] = read(); -} - -// -// Do a ROM select -// -void OneWire::select(const uint8_t rom[8]) -{ - uint8_t i; - - write(0x55); // Choose ROM - - for (i = 0; i < 8; i++) write(rom[i]); -} - -// -// Do a ROM skip -// -void OneWire::skip() -{ - write(0xCC); // Skip ROM -} - -void OneWire::depower() -{ - noInterrupts(); - DIRECT_MODE_INPUT(baseReg, bitmask); - interrupts(); -} - -#if ONEWIRE_SEARCH - -// -// You need to use this function to start a search again from the beginning. -// You do not need to do it for the first search, though you could. -// -void OneWire::reset_search() -{ - // reset the search state - LastDiscrepancy = 0; - LastDeviceFlag = FALSE; - LastFamilyDiscrepancy = 0; - for(int i = 7; ; i--) { - ROM_NO[i] = 0; - if ( i == 0) break; - } -} - -// Setup the search to find the device type 'family_code' on the next call -// to search(*newAddr) if it is present. -// -void OneWire::target_search(uint8_t family_code) -{ - // set the search state to find SearchFamily type devices - ROM_NO[0] = family_code; - for (uint8_t i = 1; i < 8; i++) - ROM_NO[i] = 0; - LastDiscrepancy = 64; - LastFamilyDiscrepancy = 0; - LastDeviceFlag = FALSE; -} - -// -// Perform a search. If this function returns a '1' then it has -// enumerated the next device and you may retrieve the ROM from the -// OneWire::address variable. If there are no devices, no further -// devices, or something horrible happens in the middle of the -// enumeration then a 0 is returned. If a new device is found then -// its address is copied to newAddr. Use OneWire::reset_search() to -// start over. -// -// --- Replaced by the one from the Dallas Semiconductor web site --- -//-------------------------------------------------------------------------- -// Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing -// search state. -// Return TRUE : device found, ROM number in ROM_NO buffer -// FALSE : device not found, end of search -// -uint8_t OneWire::search(uint8_t *newAddr) -{ - uint8_t id_bit_number; - uint8_t last_zero, rom_byte_number, search_result; - uint8_t id_bit, cmp_id_bit; - - unsigned char rom_byte_mask, search_direction; - - pinMode(bitmask, INPUT); - // initialize for search - id_bit_number = 1; - last_zero = 0; - rom_byte_number = 0; - rom_byte_mask = 1; - search_result = 0; - - // if the last call was not the last one - if (!LastDeviceFlag) - { - // 1-Wire reset - if (!reset()) - { - // reset the search - LastDiscrepancy = 0; - LastDeviceFlag = FALSE; - LastFamilyDiscrepancy = 0; - return FALSE; - } - - // issue the search command - write(0xF0); - - // loop to do the search - do - { - // read a bit and its complement - id_bit = read_bit(); - cmp_id_bit = read_bit(); - - // check for no devices on 1-wire - if ((id_bit == 1) && (cmp_id_bit == 1)) - break; - else - { - // all devices coupled have 0 or 1 - if (id_bit != cmp_id_bit) - search_direction = id_bit; // bit write value for search - else - { - // if this discrepancy if before the Last Discrepancy - // on a previous next then pick the same as last time - if (id_bit_number < LastDiscrepancy) - search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0); - else - // if equal to last pick 1, if not then pick 0 - search_direction = (id_bit_number == LastDiscrepancy); - - // if 0 was picked then record its position in LastZero - if (search_direction == 0) - { - last_zero = id_bit_number; - - // check for Last discrepancy in family - if (last_zero < 9) - LastFamilyDiscrepancy = last_zero; - } - } - - // set or clear the bit in the ROM byte rom_byte_number - // with mask rom_byte_mask - if (search_direction == 1) - ROM_NO[rom_byte_number] |= rom_byte_mask; - else - ROM_NO[rom_byte_number] &= ~rom_byte_mask; - - // serial number search direction write bit - write_bit(search_direction); - - // increment the byte counter id_bit_number - // and shift the mask rom_byte_mask - id_bit_number++; - rom_byte_mask <<= 1; - - // if the mask is 0 then go to new SerialNum byte rom_byte_number and reset mask - if (rom_byte_mask == 0) - { - rom_byte_number++; - rom_byte_mask = 1; - } - } - } - while(rom_byte_number < 8); // loop until through all ROM bytes 0-7 - - // if the search was successful then - if (!(id_bit_number < 65)) - { - // search successful so set LastDiscrepancy,LastDeviceFlag,search_result - LastDiscrepancy = last_zero; - - // check for last device - if (LastDiscrepancy == 0) - LastDeviceFlag = TRUE; - - search_result = TRUE; - } - } - - // if no device found then reset counters so next 'search' will be like a first - if (!search_result || !ROM_NO[0]) - { - LastDiscrepancy = 0; - LastDeviceFlag = FALSE; - LastFamilyDiscrepancy = 0; - search_result = FALSE; - } - for (int i = 0; i < 8; i++) newAddr[i] = ROM_NO[i]; - return search_result; - } - -#endif - -#if ONEWIRE_CRC -// The 1-Wire CRC scheme is described in Maxim Application Note 27: -// "Understanding and Using Cyclic Redundancy Checks with Maxim iButton Products" -// - -#if ONEWIRE_CRC8_TABLE -// This table comes from Dallas sample code where it is freely reusable, -// though Copyright (C) 2000 Dallas Semiconductor Corporation -static const uint8_t PROGMEM dscrc_table[] = { - 0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65, - 157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220, - 35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98, - 190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255, - 70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7, - 219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154, - 101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36, - 248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185, - 140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205, - 17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80, - 175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238, - 50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115, - 202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139, - 87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22, - 233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168, - 116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53}; - -// -// Compute a Dallas Semiconductor 8 bit CRC. These show up in the ROM -// and the registers. (note: this might better be done without to -// table, it would probably be smaller and certainly fast enough -// compared to all those delayMicrosecond() calls. But I got -// confused, so I use this table from the examples.) -// -uint8_t OneWire::crc8(const uint8_t *addr, uint8_t len) -{ - uint8_t crc = 0; - - while (len--) { - crc = pgm_read_byte(dscrc_table + (crc ^ *addr++)); - } - return crc; -} -#else -// -// Compute a Dallas Semiconductor 8 bit CRC directly. -// this is much slower, but much smaller, than the lookup table. -// -uint8_t OneWire::crc8(const uint8_t *addr, uint8_t len) -{ - uint8_t crc = 0; - - while (len--) { - uint8_t inbyte = *addr++; - for (uint8_t i = 8; i; i--) { - uint8_t mix = (crc ^ inbyte) & 0x01; - crc >>= 1; - if (mix) crc ^= 0x8C; - inbyte >>= 1; - } - } - return crc; -} -#endif - -#if ONEWIRE_CRC16 -bool OneWire::check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc) -{ - crc = ~crc16(input, len, crc); - return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1]; -} - -uint16_t OneWire::crc16(const uint8_t* input, uint16_t len, uint16_t crc) -{ - static const uint8_t oddparity[16] = - { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; - - for (uint16_t i = 0 ; i < len ; i++) { - // Even though we're just copying a byte from the input, - // we'll be doing 16-bit computation with it. - uint16_t cdata = input[i]; - cdata = (cdata ^ crc) & 0xff; - crc >>= 8; - - if (oddparity[cdata & 0x0F] ^ oddparity[cdata >> 4]) - crc ^= 0xC001; - - cdata <<= 6; - crc ^= cdata; - cdata <<= 1; - crc ^= cdata; - } - return crc; -} -#endif - -#endif diff --git a/GD32F1/libraries/OneWireSTM/src/OneWireSTM.h b/GD32F1/libraries/OneWireSTM/src/OneWireSTM.h deleted file mode 100644 index befac14..0000000 --- a/GD32F1/libraries/OneWireSTM/src/OneWireSTM.h +++ /dev/null @@ -1,254 +0,0 @@ -#ifndef OneWire_h -#define OneWire_h - -#include - -#if ARDUINO >= 100 -#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc -#else -#include "WProgram.h" // for delayMicroseconds -#include "pins_arduino.h" // for digitalPinToBitMask, etc -#endif - -// You can exclude certain features from OneWire. In theory, this -// might save some space. In practice, the compiler automatically -// removes unused code (technically, the linker, using -fdata-sections -// and -ffunction-sections when compiling, and Wl,--gc-sections -// when linking), so most of these will not result in any code size -// reduction. Well, unless you try to use the missing features -// and redesign your program to not need them! ONEWIRE_CRC8_TABLE -// is the exception, because it selects a fast but large algorithm -// or a small but slow algorithm. - -// you can exclude onewire_search by defining that to 0 -#ifndef ONEWIRE_SEARCH -#define ONEWIRE_SEARCH 1 -#endif - -// You can exclude CRC checks altogether by defining this to 0 -#ifndef ONEWIRE_CRC -#define ONEWIRE_CRC 1 -#endif - -// Select the table-lookup method of computing the 8-bit CRC -// by setting this to 1. The lookup table enlarges code size by -// about 250 bytes. It does NOT consume RAM (but did in very -// old versions of OneWire). If you disable this, a slower -// but very compact algorithm is used. -#ifndef ONEWIRE_CRC8_TABLE -#define ONEWIRE_CRC8_TABLE 1 -#endif - -// You can allow 16-bit CRC checks by defining this to 1 -// (Note that ONEWIRE_CRC must also be 1.) -#ifndef ONEWIRE_CRC16 -#define ONEWIRE_CRC16 1 -#endif - -#define FALSE 0 -#define TRUE 1 - -// Platform specific I/O definitions - -#if defined(__AVR__) -#define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define IO_REG_TYPE uint8_t -#define IO_REG_ASM asm("r30") -#define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) -#define DIRECT_MODE_INPUT(base, mask) ((*((base)+1)) &= ~(mask)) -#define DIRECT_MODE_OUTPUT(base, mask) ((*((base)+1)) |= (mask)) -#define DIRECT_WRITE_LOW(base, mask) ((*((base)+2)) &= ~(mask)) -#define DIRECT_WRITE_HIGH(base, mask) ((*((base)+2)) |= (mask)) - -#elif defined(__MK20DX128__) || defined(__MK20DX256__) -#define PIN_TO_BASEREG(pin) (portOutputRegister(pin)) -#define PIN_TO_BITMASK(pin) (1) -#define IO_REG_TYPE uint8_t -#define IO_REG_ASM -#define DIRECT_READ(base, mask) (*((base)+512)) -#define DIRECT_MODE_INPUT(base, mask) (*((base)+640) = 0) -#define DIRECT_MODE_OUTPUT(base, mask) (*((base)+640) = 1) -#define DIRECT_WRITE_LOW(base, mask) (*((base)+256) = 1) -#define DIRECT_WRITE_HIGH(base, mask) (*((base)+128) = 1) - -#elif defined(__SAM3X8E__) -// Arduino 1.5.1 may have a bug in delayMicroseconds() on Arduino Due. -// http://arduino.cc/forum/index.php/topic,141030.msg1076268.html#msg1076268 -// If you have trouble with OneWire on Arduino Due, please check the -// status of delayMicroseconds() before reporting a bug in OneWire! -#define PIN_TO_BASEREG(pin) (&(digitalPinToPort(pin)->PIO_PER)) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define IO_REG_TYPE uint32_t -#define IO_REG_ASM -#define DIRECT_READ(base, mask) (((*((base)+15)) & (mask)) ? 1 : 0) -#define DIRECT_MODE_INPUT(base, mask) ((*((base)+5)) = (mask)) -#define DIRECT_MODE_OUTPUT(base, mask) ((*((base)+4)) = (mask)) -#define DIRECT_WRITE_LOW(base, mask) ((*((base)+13)) = (mask)) -#define DIRECT_WRITE_HIGH(base, mask) ((*((base)+12)) = (mask)) -#ifndef PROGMEM -#define PROGMEM -#endif -#ifndef pgm_read_byte -#define pgm_read_byte(addr) (*(const uint8_t *)(addr)) -#endif - -#elif defined(__PIC32MX__) -#define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define IO_REG_TYPE uint32_t -#define IO_REG_ASM -#define DIRECT_READ(base, mask) (((*(base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10 -#define DIRECT_MODE_INPUT(base, mask) ((*(base+2)) = (mask)) //TRISXSET + 0x08 -#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) = (mask)) //TRISXCLR + 0x04 -#define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24 -#define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28 - -#else - -/* - Fallback to Arduino GPIO API calls for all other architectures. - - Operation can't be guaranteed using API calls, as the bus timings may be incorrect on some slower architectures. - - Notes. - BASEREG is not used, and hence the result of the macro is 0 (zero) - - IO_REG_TYPE has been set to a generic data type of unsigned int , which should be available on most architectures - - IO_REG_ASM is not used - - PIN_TO_BITMASK returns the pin number, hence the bitmask private variable will be used to store the pin number rather than the bit mask, - This is a minor hack as the variable will not contain the item advertised by its name. -*/ -#define PIN_TO_BASEREG(pin) (0) -#define PIN_TO_BITMASK(pin) ( pin ) -#define IO_REG_TYPE unsigned int -#define IO_REG_ASM -#define DIRECT_READ(base, pin) digitalRead(pin) -#define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW) -#define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH) -#define DIRECT_MODE_INPUT(base, pin) pinMode(pin,INPUT) -#define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin,OUTPUT) -#warning "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture." -#endif - - -class OneWire -{ - private: - IO_REG_TYPE bitmask; - volatile IO_REG_TYPE *baseReg; - -#if ONEWIRE_SEARCH - // global search state - unsigned char ROM_NO[8]; - uint8_t LastDiscrepancy; - uint8_t LastFamilyDiscrepancy; - uint8_t LastDeviceFlag; -#endif - - public: - OneWire( uint8_t pin); - - // Perform a 1-Wire reset cycle. Returns 1 if a device responds - // with a presence pulse. Returns 0 if there is no device or the - // bus is shorted or otherwise held low for more than 250uS - uint8_t reset(void); - - // Issue a 1-Wire rom select command, you do the reset first. - void select(const uint8_t rom[8]); - - // Issue a 1-Wire rom skip command, to address all on bus. - void skip(void); - - // Write a byte. If 'power' is one then the wire is held high at - // the end for parasitically powered devices. You are responsible - // for eventually depowering it by calling depower() or doing - // another read or write. - void write(uint8_t v, uint8_t power = 0); - - void write_bytes(const uint8_t *buf, uint16_t count, bool power = 0); - - // Read a byte. - uint8_t read(void); - - void read_bytes(uint8_t *buf, uint16_t count); - - // Write a bit. The bus is always left powered at the end, see - // note in write() about that. - void write_bit(uint8_t v); - - // Read a bit. - uint8_t read_bit(void); - - // Stop forcing power onto the bus. You only need to do this if - // you used the 'power' flag to write() or used a write_bit() call - // and aren't about to do another read or write. You would rather - // not leave this powered if you don't have to, just in case - // someone shorts your bus. - void depower(void); - -#if ONEWIRE_SEARCH - // Clear the search state so that if will start from the beginning again. - void reset_search(); - - // Setup the search to find the device type 'family_code' on the next call - // to search(*newAddr) if it is present. - void target_search(uint8_t family_code); - - // Look for the next device. Returns 1 if a new address has been - // returned. A zero might mean that the bus is shorted, there are - // no devices, or you have already retrieved all of them. It - // might be a good idea to check the CRC to make sure you didn't - // get garbage. The order is deterministic. You will always get - // the same devices in the same order. - uint8_t search(uint8_t *newAddr); -#endif - -#if ONEWIRE_CRC - // Compute a Dallas Semiconductor 8 bit CRC, these are used in the - // ROM and scratchpad registers. - static uint8_t crc8(const uint8_t *addr, uint8_t len); - -#if ONEWIRE_CRC16 - // Compute the 1-Wire CRC16 and compare it against the received CRC. - // Example usage (reading a DS2408): - // // Put everything in a buffer so we can compute the CRC easily. - // uint8_t buf[13]; - // buf[0] = 0xF0; // Read PIO Registers - // buf[1] = 0x88; // LSB address - // buf[2] = 0x00; // MSB address - // WriteBytes(net, buf, 3); // Write 3 cmd bytes - // ReadBytes(net, buf+3, 10); // Read 6 data bytes, 2 0xFF, 2 CRC16 - // if (!CheckCRC16(buf, 11, &buf[11])) { - // // Handle error. - // } - // - // @param input - Array of bytes to checksum. - // @param len - How many bytes to use. - // @param inverted_crc - The two CRC16 bytes in the received data. - // This should just point into the received data, - // *not* at a 16-bit integer. - // @param crc - The crc starting value (optional) - // @return True, iff the CRC matches. - static bool check_crc16(const uint8_t* input, uint16_t len, const uint8_t* inverted_crc, uint16_t crc = 0); - - // Compute a Dallas Semiconductor 16 bit CRC. This is required to check - // the integrity of data received from many 1-Wire devices. Note that the - // CRC computed here is *not* what you'll get from the 1-Wire network, - // for two reasons: - // 1) The CRC is transmitted bitwise inverted. - // 2) Depending on the endian-ness of your processor, the binary - // representation of the two-byte return value may have a different - // byte order than the two bytes you get from 1-Wire. - // @param input - Array of bytes to checksum. - // @param len - How many bytes to use. - // @param crc - The crc starting value (optional) - // @return The CRC16, as defined by Dallas Semiconductor. - static uint16_t crc16(const uint8_t* input, uint16_t len, uint16_t crc = 0); -#endif -#endif -}; - -#endif diff --git a/GD32F1/libraries/RTClock/examples/Gilchrist_RTC/Gilchrist_RTC.ino b/GD32F1/libraries/RTClock/examples/Gilchrist_RTC/Gilchrist_RTC.ino deleted file mode 100644 index 35d9553..0000000 --- a/GD32F1/libraries/RTClock/examples/Gilchrist_RTC/Gilchrist_RTC.ino +++ /dev/null @@ -1,93 +0,0 @@ -/* - * test-rtc.c - * - * Example program that sets up the Real Time Clock and then blinks the - * LED in patterns for seconds and alarm interrupts. - * - * Created by Rod Gilchrist on 11-12-24. - Ray Burnette: 20150521: - Edited: \Documents\Arduino\hardware\STM32\STM32F1\system\libmaple\stm32f1\include\series\rcc.h to include: - #include - #define RCC_BDCR_RTCSEL_LSI (0x2 << 8) - static inline void rcc_start_lsi(void) - static inline void rcc_start_lse(void) - static inline void rcc_start_hse(void) - - Arduino GUI 1.7.3 from Arduino.org - Sketch uses 20,268 bytes (18%) of program storage space. Maximum is 110,592 bytes. - Global variables use 4,552 bytes of dynamic memory. - */ - -#include "RTClock.h" - -#define BOARD_LED_PIN PB1 - -int globAlmCnt = 0; -int globOvCnt = 0; -int globSecCnt = 0; -int specAlmCnt = 0; -int lastGlobAlmCnt = -1; -int lastSpecAlmCnt = -1; - -void rtc_sec_intr() { if (rtc_is_second()) globSecCnt++; } -void rtc_ovf_intr() { if (rtc_is_overflow()) globOvCnt++; } -void rtc_glob_alm_intr() { if (rtc_is_alarm()) globAlmCnt++; } -void rtc_spec_alm_intr() { if (rtc_is_alarm()) specAlmCnt++; } - -void setup() { - // http://forums.leaflabs.com/topic.php?id=1437 - // slow! div speed. NOTE! 512 is stop/hang when USB not connected! - // rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_256); - // Normal speed: - // rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1); - - pinMode(BOARD_LED_PIN, OUTPUT); - delay(5000); - Serial.println("begin RTC blink"); - delay(1000); - - rtc_init(RTCSEL_LSI); - rtc_set_prescaler_load(0x7fff); - rtc_set_count(0); - - rtc_attach_interrupt(RTC_SECONDS_INTERRUPT, rtc_sec_intr); - rtc_attach_interrupt(RTC_OVERFLOW_INTERRUPT, rtc_ovf_intr); // expected every 128000 seconds - rtc_attach_interrupt(RTC_ALARM_GLOBAL_INTERRUPT, rtc_glob_alm_intr); - rtc_attach_interrupt(RTC_ALARM_SPECIFIC_INTERRUPT, rtc_spec_alm_intr); -} - -void loop() { - int i,n; - - Serial.print("Time + interrupt counts: "); - Serial.print(rtc_get_count()); - Serial.print("."); - Serial.print(rtc_get_divider()); - Serial.print(" ("); - Serial.print(globSecCnt); - Serial.print(", "); - Serial.print(globOvCnt); - Serial.print(", "); - Serial.print(globAlmCnt); - Serial.print(", "); - Serial.print(specAlmCnt); - Serial.println(")"); - - delay(1000); - - digitalWrite(BOARD_LED_PIN, 1); - if ((lastSpecAlmCnt != specAlmCnt) || (lastGlobAlmCnt != globAlmCnt)){ - lastGlobAlmCnt = globAlmCnt; - lastSpecAlmCnt = specAlmCnt; - - Serial.println(" -- alarm -- "); - for (i=0;i<3;i++) { digitalWrite(BOARD_LED_PIN, 0); delay(100); digitalWrite(BOARD_LED_PIN, 1); delay(100);} - n = rtc_get_count() + 5; - rtc_set_alarm(n); - } - - delay(1000); - digitalWrite(BOARD_LED_PIN, 0); -} - - diff --git a/GD32F1/libraries/RTClock/examples/Test_RTClock/Test_RTClock.ino b/GD32F1/libraries/RTClock/examples/Test_RTClock/Test_RTClock.ino deleted file mode 100644 index 5010c87..0000000 --- a/GD32F1/libraries/RTClock/examples/Test_RTClock/Test_RTClock.ino +++ /dev/null @@ -1,33 +0,0 @@ -#include - -RTClock rt (RTCSEL_LSE); // initialise -uint32 tt; - -#define LED_PIN PB1 - -// This function is called in the attachSecondsInterrpt -void blink () -{ - digitalWrite(LED_PIN,!digitalRead(LED_PIN)); -} - -void setup() -{ - pinMode(LED_PIN, OUTPUT); - - rt.attachSecondsInterrupt(blink);// Call blink -} - - - -void loop() -{ - - if (rt.getTime()!=tt) - { - tt = rt.getTime(); - - Serial.print("time is: "); - Serial.println(tt); - } -} \ No newline at end of file diff --git a/GD32F1/libraries/RTClock/keywords.txt b/GD32F1/libraries/RTClock/keywords.txt deleted file mode 100644 index ddd0680..0000000 --- a/GD32F1/libraries/RTClock/keywords.txt +++ /dev/null @@ -1,23 +0,0 @@ -####################################### -# Syntax Coloring Map RTClock -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### -RTClock KEYWORD1 - - -setTime KEYWORD2 -getTime KEYWORD2 - -createAlarm KEYWORD2 -attachSecondsInterrupt KEYWORD2 -detachSecondsInterrupt KEYWORD2 -setAlarmTime KEYWORD2 - - -####################################### -# Constants (LITERAL1) -####################################### - diff --git a/GD32F1/libraries/RTClock/library.properties b/GD32F1/libraries/RTClock/library.properties deleted file mode 100644 index 6bfeb40..0000000 --- a/GD32F1/libraries/RTClock/library.properties +++ /dev/null @@ -1,8 +0,0 @@ -name=RTClock -version=1.0 -author=Various -email= -sentence=Real Time Clock -paragraph=Real Time Clock for STM32F1 -url= -architectures=STM32F1 diff --git a/GD32F1/libraries/RTClock/src/RTClock.cpp b/GD32F1/libraries/RTClock/src/RTClock.cpp deleted file mode 100644 index 869e152..0000000 --- a/GD32F1/libraries/RTClock/src/RTClock.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - - */ - -#include "RTClock.h" - - RTClock::RTClock() { - RTClock(RTCSEL_HSE, 0xf423); - } - - RTClock::RTClock(rtc_clk_src src) { - RTClock(src, 0); - - }//end RTC - - RTClock::RTClock(rtc_clk_src src, uint16 prescaler ) { - switch (src) { - - case RTCSEL_LSE : { - rtc_init(RTCSEL_LSE);//LSE should be 32768 Hz. - if (prescaler != 0) rtc_set_prescaler_load(prescaler); //according to sheet clock/(prescaler + 1) = Hz - else rtc_set_prescaler_load(0x7fff); - break; - } - case RTCSEL_LSI : { - rtc_init(RTCSEL_LSI);//LSI is around 40000 Hz (between 30000 and 60000). - if (prescaler != 0) rtc_set_prescaler_load(prescaler); //according to sheet clock/(prescaler + 1) = Hz 39999Hz = 0x9C3F - else rtc_set_prescaler_load(0x9C3F); - break; - } - case RTCSEL_HSE : { - rtc_init(RTCSEL_HSE);//HSE = 8/128MHz = 62500 Hz - if (prescaler != 0) rtc_set_prescaler_load(prescaler); //according to sheet clock/(prescaler + 1) = Hz 0xF423 = 62499 - else rtc_set_prescaler_load(0xF423); - break; - } - case RTCSEL_DEFAULT: { - //do nothing. Have a look at the clocks to see the diff between NONE and DEFAULT - break; - } - case RTCSEL_NONE: { - //do nothing. Have a look at the clocks to see the diff between NONE and DEFAULT - break; - } - - }//end switch - - - } - -/* - RTClock::~RTClock() { - //to implement - } -*/ - - void RTClock::setTime (time_t time_stamp) { - rtc_set_count(time_stamp); - } - - void RTClock::setTime (struct tm* tm_ptr) { - rtc_set_count(mktime (tm_ptr)); - } - - time_t RTClock::getTime() { - return rtc_get_count(); - } - - struct tm* RTClock::getTime(struct tm* tm_ptr) { - time_t res = rtc_get_count(); - tm_ptr = gmtime(&res); //why not gmtime? - return tm_ptr; - } - - void RTClock::createAlarm(voidFuncPtr function, time_t alarm_time_t) { - rtc_set_alarm(alarm_time_t); //must be int... for standardization sake. - rtc_attach_interrupt(RTC_ALARM_SPECIFIC_INTERRUPT, function); - } - - void RTClock::attachSecondsInterrupt(voidFuncPtr function) { - rtc_attach_interrupt(RTC_SECONDS_INTERRUPT, function); - } - void RTClock::detachSecondsInterrupt() { - rtc_detach_interrupt(RTC_SECONDS_INTERRUPT); - } - - - void RTClock::createAlarm(voidFuncPtr function, tm* alarm_tm) { - time_t alarm = mktime(alarm_tm);//convert to time_t - createAlarm(function, alarm); - } - -//change alarm time - void RTClock::setAlarmTime (tm * tm_ptr) { - time_t time = mktime(tm_ptr);//convert to time_t - rtc_set_alarm(time); //must be int... for standardization sake. - } - - void RTClock::setAlarmTime (time_t alarm_time) { - - rtc_set_alarm(alarm_time); - - } - - diff --git a/GD32F1/libraries/RTClock/src/RTClock.h b/GD32F1/libraries/RTClock/src/RTClock.h deleted file mode 100644 index 443a30b..0000000 --- a/GD32F1/libraries/RTClock/src/RTClock.h +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include - - -#ifndef _RTCLOCK_H_ -#define _RTCLOCK_H_ - - - - - -class RTClock { - public: - RTClock(); - RTClock(rtc_clk_src src ); - RTClock(rtc_clk_src src, uint16 prescaler ); - //~RTClock(); //to implement - - - void setTime (time_t time_stamp); - void setTime (struct tm * tm_ptr); - - struct tm* getTime(struct tm* tm_ptr); - time_t getTime(); - - void createAlarm(voidFuncPtr function, time_t alarm_time_t); - void createAlarm(voidFuncPtr function, struct tm* alarm_tm); - - void attachSecondsInterrupt(voidFuncPtr function); - void detachSecondsInterrupt(); - - void setAlarmTime (tm * tm_ptr); - void setAlarmTime (time_t alarm_time); - //private: - -} ; - - - -#endif // _RTCLOCK_H_ - \ No newline at end of file diff --git a/GD32F1/libraries/RTClock/src/utility/rtc_util.c b/GD32F1/libraries/RTClock/src/utility/rtc_util.c deleted file mode 100644 index 3c8b7d5..0000000 --- a/GD32F1/libraries/RTClock/src/utility/rtc_util.c +++ /dev/null @@ -1,232 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file rtc.c - * @author Rod Gilchrist - * @brief Real Time Clock interface - */ - -#include "rtc_util.h" - - -#define NR_RTC_HANDLERS 4 - -static rtc_dev rtc = { - .regs = RTC_BASE, - .handlers = { [NR_RTC_HANDLERS - 1] = 0 }, -}; - -rtc_dev *RTC = &rtc; - - -/** - * Initialize the RTC interface, and enable access to its register map and - * the backup registers. - */ -void rtc_init(rtc_clk_src src) { - - bkp_init(); // turn on peripheral clocks to PWR and BKP and reset the backup domain via RCC registers. - // (we reset the backup domain here because we must in order to change the rtc clock source). - - bkp_enable_writes(); // enable writes to the backup registers and the RTC registers via the DBP bit in the PWR control register - - RCC_BASE->BDCR &= ~RCC_BDCR_RTCSEL; - switch (src) { - case RTCSEL_NONE: - RCC_BASE->BDCR = RCC_BDCR_RTCSEL_NONE; - break; - - case RTCSEL_LSE: - rcc_start_lse(); - RCC_BASE->BDCR |= RCC_BDCR_RTCSEL_LSE; - - break; - - case RTCSEL_LSI: - case RTCSEL_DEFAULT: - rcc_start_lsi(); - RCC_BASE->BDCR |= RCC_BDCR_RTCSEL_LSI; - break; - - case RTCSEL_HSE: // This selection uses HSE/128 as the RTC source (i.e. 64 kHz with an 8 mHz xtal) - rcc_start_hse(); - RCC_BASE->BDCR |= RCC_BDCR_RTCSEL_HSE; - break; - } - bb_peri_set_bit(&RCC_BASE->BDCR, RCC_BDCR_RTCEN_BIT, 1); // Enable the RTC - - rtc_clear_sync(); - rtc_wait_sync(); - rtc_wait_finished(); -} - -/** - * @brief Attach a RTC interrupt. - * @param interrupt Interrupt number to attach to; this may be any rtc_interrupt_id. - * @param handler Handler to attach to the given interrupt. - * @see rtc_interrupt_id - */ -void rtc_attach_interrupt( uint8 interrupt, - voidFuncPtr handler) { - RTC->handlers[interrupt] = handler; - rtc_enable_irq(interrupt); - switch (interrupt) { - case RTC_SECONDS_INTERRUPT: nvic_irq_enable(NVIC_RTC); break; - case RTC_OVERFLOW_INTERRUPT: nvic_irq_enable(NVIC_RTC); break; - case RTC_ALARM_GLOBAL_INTERRUPT: nvic_irq_enable(NVIC_RTC); break; - case RTC_ALARM_SPECIFIC_INTERRUPT: nvic_irq_enable(NVIC_RTCALARM); break; // The alarm specific interrupt can wake us from deep sleep. - } -} - -/** - * @brief Detach an rtc interrupt. - * @param interrupt Interrupt number to detach. - * @see rtc_interrupt_id - */ -void rtc_detach_interrupt(uint8 interrupt) { - rtc_disable_irq(interrupt); - RTC->handlers[interrupt] = NULL; -} - -/* - * IRQ handlers - */ - -/* For dispatch routines which service multiple interrupts. */ -#define handle_irq(dier_sr, irq_mask, handlers, iid, handled_irq) do { \ - if ((dier_sr) & (irq_mask)) { \ - void (*__handler)(void) = (handlers)[iid]; \ - if (__handler) { \ - __handler(); \ - handled_irq |= (irq_mask); \ - } \ - } \ -} while (0) - -static inline void dispatch_multiple_rtc_irq() { - rtc_reg_map *regs = RTC->regs; - uint32 dsr = regs->CRH & regs->CRL; - void (**hs)(void) = RTC->handlers; - uint32 handled = 0; - - handle_irq(dsr, RTC_CRL_SECF, hs, RTC_SECONDS_INTERRUPT, handled); - handle_irq(dsr, RTC_CRL_ALRF, hs, RTC_ALARM_GLOBAL_INTERRUPT, handled); - handle_irq(dsr, RTC_CRL_OWF, hs, RTC_OVERFLOW_INTERRUPT, handled); - - regs->CRL &= ~handled; -} - -void __irq_rtc(void) { - dispatch_multiple_rtc_irq(); -} - -/* A special-case dispatch routine for single-interrupt NVIC lines. - * This function assumes that the interrupt corresponding to `RTC_ALARM_INTERRUPT' has - * in fact occurred (i.e., it doesn't check DIER & SR). */ -void __irq_rtcalarm(void) { - void (*handler)(void) = RTC->handlers[RTC_ALARM_SPECIFIC_INTERRUPT]; - if (handler) { - handler(); - *bb_perip(&EXTI_BASE->PR, EXTI_RTC_ALARM_BIT) = 1; - //asm volatile("nop"); // See comment in exti.c. Doesn't seem to be required. - //asm volatile("nop"); - } -} - -/** - * @brief Returns the rtc's counter (i.e. time/date) value. - * - * This value is likely to be inaccurate if the counter is running - * with a low prescaler. - */ -uint32 rtc_get_count() { - uint32 h, l; - rtc_clear_sync(); - rtc_wait_sync(); - rtc_wait_finished(); - h = RTC->regs->CNTH & 0xffff; - l = RTC->regs->CNTL & 0xffff; - return (h << 16) | l; -} - -/** - * @brief Sets the counter value (i.e. time/date) for the rtc. - * @param value New counter value - */ -void rtc_set_count(uint32 value) { - rtc_clear_sync(); - rtc_wait_sync(); - rtc_wait_finished(); - rtc_enter_config_mode(); - RTC->regs->CNTH = (value >> 16) & 0xffff; - RTC->regs->CNTL = value & 0xffff; - rtc_exit_config_mode(); - rtc_wait_finished(); -} - -/** - * @brief Sets the prescaler load value for the rtc. - * @param value New prescaler load value (use 0x7fff to get 1 second period with 32.768 Hz clock). - */ -void rtc_set_prescaler_load(uint32 value) { - rtc_clear_sync(); - rtc_wait_sync(); - rtc_wait_finished(); - rtc_enter_config_mode(); - RTC->regs->PRLH = (value >> 16) & 0xffff; - RTC->regs->PRLL = value & 0xffff; - rtc_exit_config_mode(); - rtc_wait_finished(); -} - -/** - * @brief Returns the rtc's prescaler divider (i.e. current divider count) value. - */ -uint32 rtc_get_divider() { - uint32 h, l; - rtc_clear_sync(); - rtc_wait_sync(); - rtc_wait_finished(); - h = RTC->regs->DIVH & 0x000f; - l = RTC->regs->DIVL & 0xffff; - return (h << 16) | l; -} - -/** - * @brief Sets the alarm value (i.e. time/date) for the rtc. - * @param value New alarm value - */ -void rtc_set_alarm(uint32 value) { - rtc_clear_sync(); - rtc_wait_sync(); - rtc_wait_finished(); - rtc_enter_config_mode(); - RTC->regs->ALRH = (value >> 16) & 0xffff; - RTC->regs->ALRL = value & 0xffff; - rtc_exit_config_mode(); - rtc_wait_finished(); -} \ No newline at end of file diff --git a/GD32F1/libraries/RTClock/src/utility/rtc_util.h b/GD32F1/libraries/RTClock/src/utility/rtc_util.h deleted file mode 100644 index 7084b0d..0000000 --- a/GD32F1/libraries/RTClock/src/utility/rtc_util.h +++ /dev/null @@ -1,261 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 Visible Assets Inc. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file rtc.h - * @author Rod Gilchrist - * @brief Real Time Clock interface. - * - */ - -#ifndef _RTC_UTIL_H -#define _RTC_UTIL_H - -#include -#include -#include -#include -#include -#include -#include - -#define EXTI_RTC_ALARM_BIT 17 // the extra exti interrupts (16,17,18,19) should be defined in exti.h (BUG) - -//#define RCC_BDCR_RTCSEL_LSI (0x2 << 8) - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rtc_reg_map { - __io uint32 CRH; /**< Control register high */ - __io uint32 CRL; /**< Control register high */ - __io uint32 PRLH; /**< Prescaler load register high */ - __io uint32 PRLL; /**< Prescaler load register low */ - __io uint32 DIVH; /**< Prescaler divider register high */ - __io uint32 DIVL; /**< Prescaler divider register low */ - __io uint32 CNTH; /**< Counter register high */ - __io uint32 CNTL; /**< Counter register low */ - __io uint32 ALRH; /**< Alarm register high */ - __io uint32 ALRL; /**< Alarm register low */ -} rtc_reg_map; - -/** RTC register map base pointer */ -#define RTC_BASE ((struct rtc_reg_map*)0x40002800) - -/** rtc device type */ -typedef struct rtc_dev { - rtc_reg_map *regs; /**< Register map */ - voidFuncPtr handlers[]; /**< User IRQ handlers */ -} rtc_dev; - -extern rtc_dev *RTC; - - -/* - * Register bit definitions - */ - -/* Control register high (CRH) */ - -#define RTC_CRH_OWIE_BIT 2 -#define RTC_CRH_ALRIE_BIT 1 -#define RTC_CRH_SECIE_BIT 0 - -#define RTC_CRH_OWIE BIT(RTC_CRH_OWIE_BIT) -#define RTC_CRH_ALRIE BIT(RTC_CRH_ALRIE_BIT) -#define RTC_CRH_SECIE BIT(RTC_CRH_SECIE_BIT) - -/* Control register low (CRL) */ - -#define RTC_CRL_RTOFF_BIT 5 -#define RTC_CRL_CNF_BIT 4 -#define RTC_CRL_RSF_BIT 3 -#define RTC_CRL_OWF_BIT 2 -#define RTC_CRL_ALRF_BIT 1 -#define RTC_CRL_SECF_BIT 0 - -#define RTC_CRL_RTOFF BIT(RTC_CRL_RTOFF_BIT) -#define RTC_CRL_CNF BIT(RTC_CRL_CNF_BIT) -#define RTC_CRL_RSF BIT(RTC_CRL_RSF_BIT) -#define RTC_CRL_OWF BIT(RTC_CRL_OWF_BIT) -#define RTC_CRL_ALRF BIT(RTC_CRL_ALRF_BIT) -#define RTC_CRL_SECF BIT(RTC_CRL_SECF_BIT) - -/** - * @brief RTC interrupt number. - * - */ -typedef enum rtc_interrupt_id { - RTC_SECONDS_INTERRUPT = 0, /**< Counter seconds interrupt */ - RTC_ALARM_GLOBAL_INTERRUPT = 1, /**< RTC alarm global interrupt (i.e. __irq_rtc()) */ - RTC_OVERFLOW_INTERRUPT = 2, /**< Counter overflow interrupt */ - RTC_ALARM_SPECIFIC_INTERRUPT = 3 /**< RTC alarm specific interrupt (i.e. __irq_rtcalarm(), wake up from halt/sleep) */ -} rtc_interrupt_id; - -void rtc_attach_interrupt( uint8 interrupt, - voidFuncPtr handler); -void rtc_detach_interrupt( uint8 interrupt); - -/** - * @brief RTC clock source. - * - */ -typedef enum rtc_clk_src { - RTCSEL_DEFAULT = 0, - RTCSEL_NONE = 0x10, - RTCSEL_LSE = 0x11, - RTCSEL_LSI = 0x12, - RTCSEL_HSE = 0x13, -} rtc_clk_src; - - -void rtc_init(rtc_clk_src src); -void rtc_attach_interrupt(uint8 interrupt, voidFuncPtr handler); -void rtc_detach_interrupt(uint8 interrupt); -uint32 rtc_get_count(); -void rtc_set_count(uint32 value); -void rtc_set_prescaler_load(uint32 value); -uint32 rtc_get_divider(); -void rtc_set_alarm(uint32 value); - - -/** - * @brief Check (wait if necessary) to see the previous write operation has completed. - */ -static inline void rtc_wait_finished() { - while (*bb_perip(&(RTC->regs)->CRL, RTC_CRL_RTOFF_BIT) == 0); -} - - /** - * @brief Clear the register synchronized flag. The flag is then set by hardware after a write to PRL/DIV or CNT. - */ -static inline void rtc_clear_sync() { - rtc_wait_finished(); - *bb_perip(&(RTC->regs)->CRL, RTC_CRL_RSF_BIT) = 0; -} - -/** - * @brief Check (wait if necessary) to see RTC registers are synchronized. - */ -static inline void rtc_wait_sync() { - while (*bb_perip(&(RTC->regs)->CRL, RTC_CRL_RSF_BIT) == 0); -} - -/** - * @brief Enter configuration mode. - */ -static inline void rtc_enter_config_mode() { - rtc_wait_finished(); - *bb_perip(&(RTC->regs)->CRL, RTC_CRL_CNF_BIT) = 1; -} - -/** - * @brief Exit configuration mode. - */ -static inline void rtc_exit_config_mode() { - rtc_wait_finished(); - *bb_perip(&(RTC->regs)->CRL, RTC_CRL_CNF_BIT) = 0; -} - -/** - * @brief Enable an RTC interrupt. - * @param interrupt Interrupt number to enable; this may be any rtc_interrupt_id. - * @see rtc_interrupt_id - */ -static inline void rtc_enable_irq(uint8 interrupt) { - rtc_wait_finished(); - if (interrupt == RTC_ALARM_SPECIFIC_INTERRUPT) { // Enabling this interrupt allows waking up from deep sleep via WFI. - *bb_perip(&EXTI_BASE->IMR, EXTI_RTC_ALARM_BIT) = 1; - *bb_perip(&EXTI_BASE->RTSR, EXTI_RTC_ALARM_BIT) = 1; - } - else *bb_perip(&(RTC->regs)->CRH, interrupt) = 1; -} - -/** - * @brief Disable an RTC interrupt. - * @param interrupt Interrupt number to disable; this may be any rtc_interrupt_id value. - * @see rtc_interrupt_id - */ -static inline void rtc_disable_irq(uint8 interrupt) { - rtc_wait_finished(); - if (interrupt == RTC_ALARM_SPECIFIC_INTERRUPT) { - *bb_perip(&EXTI_BASE->IMR, EXTI_RTC_ALARM_BIT) = 0; - *bb_perip(&EXTI_BASE->RTSR, EXTI_RTC_ALARM_BIT) = 0; - } - else *bb_perip(&(RTC->regs)->CRH, interrupt) = 0; -} - -/** - * @brief Enable an RTC alarm event. Enabling this event allows waking up from deep sleep via WFE. - * @see rtc_interrupt_id - */ -static inline void rtc_enable_alarm_event() { - *bb_perip(&EXTI_BASE->EMR, EXTI_RTC_ALARM_BIT) = 1; - *bb_perip(&EXTI_BASE->RTSR, EXTI_RTC_ALARM_BIT) = 1; -} - -/** - * @brief Disable the RTC alarm event. - * @see rtc_interrupt_id - */ -static inline void rtc_disable_alarm_event() { - *bb_perip(&EXTI_BASE->EMR, EXTI_RTC_ALARM_BIT) = 0; - *bb_perip(&EXTI_BASE->RTSR, EXTI_RTC_ALARM_BIT) = 0; -} - -/** - * @brief Test for global interrupt second type. - * @see rtc_interrupt_id - */ -static inline int rtc_is_second() { - return *bb_perip(&(RTC->regs)->CRL, RTC_CRL_SECF_BIT); -} - -/** - * @brief Test for global interrupt alarm type. - * @see rtc_interrupt_id - */ -static inline int rtc_is_alarm() { - return *bb_perip(&(RTC->regs)->CRL, RTC_CRL_ALRF_BIT); -} - -/** - * @brief Test for global interrupt overflow type. - * @see rtc_interrupt_id - */ -static inline int rtc_is_overflow() { - return *bb_perip(&(RTC->regs)->CRL, RTC_CRL_OWF_BIT); -} - - - -#ifdef __cplusplus -} -#endif - -#endif /* _RTC_H */ \ No newline at end of file diff --git a/GD32F1/libraries/SPI/examples/using_SPI_ports/using_SPI_ports.ino b/GD32F1/libraries/SPI/examples/using_SPI_ports/using_SPI_ports.ino deleted file mode 100644 index dfffc0d..0000000 --- a/GD32F1/libraries/SPI/examples/using_SPI_ports/using_SPI_ports.ino +++ /dev/null @@ -1,76 +0,0 @@ -/** - SPI_1 and SPI_2 port example code - - Description: - This sketch sends one byte with value 0x55 over the SPI_1 or SPI_2 port. - The received byte (the answer from the SPI slave device) is stored to the variable. - - The sketch as it is, works with SPI_1 port. For using the SPI_2 port, just - un-comment all the nessesary code lines marked with word. - - Created on 10 Jun 2015 by Vassilis Serasidis - email: avrsite@yahoo.gr - - Using the first SPI port (SPI_1) - SS <--> PA4 <--> BOARD_SPI1_NSS_PIN - SCK <--> PA5 <--> BOARD_SPI1_SCK_PIN - MISO <--> PA6 <--> BOARD_SPI1_MISO_PIN - MOSI <--> PA7 <--> BOARD_SPI1_MOSI_PIN - - Using the second SPI port (SPI_2) - SS <--> PB12 <--> BOARD_SPI2_NSS_PIN - SCK <--> PB13 <--> BOARD_SPI2_SCK_PIN - MISO <--> PB14 <--> BOARD_SPI2_MISO_PIN - MOSI <--> PB15 <--> BOARD_SPI2_MOSI_PIN -*/ - - -#include - -#define SPI1_NSS_PIN PA4 //SPI_1 Chip Select pin is PA4. You can change it to the STM32 pin you want. -#define SPI2_NSS_PIN PB12 //SPI_2 Chip Select pin is PB12. You can change it to the STM32 pin you want. - -SPIClass SPI_2(2); //Create an instance of the SPI Class called SPI_2 that uses the 2nd SPI Port -byte data; - -void setup() { - - // Setup SPI 1 - SPI.begin(); //Initialize the SPI_1 port. - SPI.setBitOrder(MSBFIRST); // Set the SPI_1 bit order - SPI.setDataMode(SPI_MODE0); //Set the SPI_2 data mode 0 - SPI.setClockDivider(SPI_CLOCK_DIV16); // Slow speed (72 / 16 = 4.5 MHz SPI_1 speed) - pinMode(SPI1_NSS_PIN, OUTPUT); - - // Setup SPI 2 - SPI_2.begin(); //Initialize the SPI_2 port. - SPI_2.setBitOrder(MSBFIRST); // Set the SPI_2 bit order - SPI_2.setDataMode(SPI_MODE0); //Set the SPI_2 data mode 0 - SPI_2.setClockDivider(SPI_CLOCK_DIV16); // Use a different speed to SPI 1 - pinMode(SPI2_NSS_PIN, OUTPUT); - - -} - -void loop() { - - sendSPI(); - sendSPI2(); - - delayMicroseconds(10); //Delay 10 micro seconds. -} - -void sendSPI() -{ - digitalWrite(SPI1_NSS_PIN, LOW); // manually take CSN low for SPI_1 transmission - data = SPI.transfer(0x55); //Send the HEX data 0x55 over SPI-1 port and store the received byte to the variable. - digitalWrite(SPI1_NSS_PIN, HIGH); // manually take CSN high between spi transmissions -} - - -void sendSPI2() -{ - digitalWrite(SPI2_NSS_PIN, LOW); // manually take CSN low for SPI_2 transmission - data = SPI_2.transfer(0x55); //Send the HEX data 0x55 over SPI-2 port and store the received byte to the variable. - digitalWrite(SPI2_NSS_PIN, HIGH); // manually take CSN high between spi transmissions -} \ No newline at end of file diff --git a/GD32F1/libraries/SPI/keywords.txt b/GD32F1/libraries/SPI/keywords.txt deleted file mode 100644 index 47738f9..0000000 --- a/GD32F1/libraries/SPI/keywords.txt +++ /dev/null @@ -1,31 +0,0 @@ -####################################### -# Syntax Coloring Map SPI -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -SPI KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -begin KEYWORD2 -end KEYWORD2 -transfer KEYWORD2 -#setBitOrder KEYWORD2 -setDataMode KEYWORD2 -setClockDivider KEYWORD2 - - -####################################### -# Constants (LITERAL1) -####################################### -SPI_MODE0 LITERAL1 -SPI_MODE1 LITERAL1 -SPI_MODE2 LITERAL1 -SPI_MODE3 LITERAL1 - -SPI_CONTINUE LITERAL1 -SPI_LAST LITERAL1 diff --git a/GD32F1/libraries/SPI/library.properties b/GD32F1/libraries/SPI/library.properties deleted file mode 100644 index 09d7789..0000000 --- a/GD32F1/libraries/SPI/library.properties +++ /dev/null @@ -1,8 +0,0 @@ -name=SPI -version=1.0 -author=Roger Clark -email= -sentence=Serial Peripheral Interface -paragraph=SPI for STM32F1 -url= -architectures=STM32F1 diff --git a/GD32F1/libraries/SPI/src/README.txt b/GD32F1/libraries/SPI/src/README.txt deleted file mode 100644 index e69de29..0000000 diff --git a/GD32F1/libraries/SPI/src/SPI.cpp b/GD32F1/libraries/SPI/src/SPI.cpp deleted file mode 100644 index ebb0198..0000000 --- a/GD32F1/libraries/SPI/src/SPI.cpp +++ /dev/null @@ -1,619 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @author Marti Bolivar - * @brief Wirish SPI implementation. - */ - -#include "SPI.h" - -//#define SPI_DEBUG - -#include -#include -#include - -#include "wirish.h" -#include "boards.h" - -//#include "HardwareSerial.h" - -#if CYCLES_PER_MICROSECOND != 72 -/* TODO [0.2.0?] something smarter than this */ -#warning "Unexpected clock speed; SPI frequency calculation will be incorrect" -#endif - -struct spi_pins { - uint8 nss; - uint8 sck; - uint8 miso; - uint8 mosi; -}; - -static const spi_pins* dev_to_spi_pins(spi_dev *dev); - -static void configure_gpios(spi_dev *dev, bool as_master); - -static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq); - -#if (BOARD_NR_SPI >= 3) && !defined(STM32_HIGH_DENSITY) -#error "The SPI library is misconfigured: 3 SPI ports only available on high density STM32 devices" -#endif - -static const spi_pins board_spi_pins[] __FLASH__ = { -#if BOARD_NR_SPI >= 1 - {BOARD_SPI1_NSS_PIN, - BOARD_SPI1_SCK_PIN, - BOARD_SPI1_MISO_PIN, - BOARD_SPI1_MOSI_PIN}, -#endif -#if BOARD_NR_SPI >= 2 - {BOARD_SPI2_NSS_PIN, - BOARD_SPI2_SCK_PIN, - BOARD_SPI2_MISO_PIN, - BOARD_SPI2_MOSI_PIN}, -#endif -#if BOARD_NR_SPI >= 3 - {BOARD_SPI3_NSS_PIN, - BOARD_SPI3_SCK_PIN, - BOARD_SPI3_MISO_PIN, - BOARD_SPI3_MOSI_PIN}, -#endif -}; - - -/* - * Constructor - */ - -SPIClass::SPIClass(uint32 spi_num) { - - _currentSetting=&_settings[spi_num-1];// SPI channels are called 1 2 and 3 but the array is zero indexed - - - switch (spi_num) { -#if BOARD_NR_SPI >= 1 - case 1: - _currentSetting->spi_d = SPI1; - break; -#endif -#if BOARD_NR_SPI >= 2 - case 2: - _currentSetting->spi_d = SPI2; - break; -#endif -#if BOARD_NR_SPI >= 3 - case 3: - _currentSetting->spi_d = SPI3; - break; -#endif - default: - ASSERT(0); - } - - // Init things specific to each SPI device - // clock divider setup is a bit of hack, and needs to be improved at a later date. - _settings[0].spi_d = SPI1; - _settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock); - _settings[0].spiDmaDev = DMA1; - _settings[0].spiTxDmaChannel = DMA_CH3; - _settings[0].spiRxDmaChannel = DMA_CH2; - _settings[1].spi_d = SPI2; - _settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock); - _settings[1].spiDmaDev = DMA1; - _settings[1].spiTxDmaChannel = DMA_CH5; - _settings[1].spiRxDmaChannel = DMA_CH4; -#if BOARD_NR_SPI >= 3 - _settings[2].spi_d = SPI3; - _settings[2].clockDivider = determine_baud_rate(_settings[2].spi_d, _settings[2].clock); - _settings[2].spiDmaDev = DMA2; - _settings[2].spiTxDmaChannel = DMA_CH2; - _settings[2].spiRxDmaChannel = DMA_CH1; -#endif - - //pinMode(BOARD_SPI_DEFAULT_SS,OUTPUT); -} - -/* - * Set up/tear down - */ - -void SPIClass::begin(void) { - - uint32 flags = ((_currentSetting->bitOrder == MSBFIRST ? SPI_FRAME_MSB : SPI_FRAME_LSB) | SPI_DFF_8_BIT | SPI_SW_SLAVE | SPI_SOFT_SS); - spi_init(_currentSetting->spi_d); - configure_gpios(_currentSetting->spi_d, 1); - #ifdef SPI_DEBUG - Serial.print("spi_master_enable("); Serial.print(_currentSetting->clockDivider); Serial.print(","); Serial.print(_currentSetting->dataMode); Serial.print(","); Serial.print(flags); Serial.println(")"); - #endif - spi_master_enable(_currentSetting->spi_d, (spi_baud_rate)_currentSetting->clockDivider, (spi_mode)_currentSetting->dataMode, flags); -} - -void SPIClass::beginSlave(void) { - if (_currentSetting->dataMode >= 4) { - ASSERT(0); - return; - } - uint32 flags = ((_currentSetting->bitOrder == MSBFIRST ? SPI_FRAME_MSB : SPI_FRAME_LSB) | SPI_DFF_8_BIT | SPI_SW_SLAVE); - spi_init(_currentSetting->spi_d); - configure_gpios(_currentSetting->spi_d, 0); - #ifdef SPI_DEBUG - Serial.print("spi_slave_enable("); Serial.print(_currentSetting->dataMode); Serial.print(","); Serial.print(flags); Serial.println(")"); - #endif - spi_slave_enable(_currentSetting->spi_d, (spi_mode)_currentSetting->dataMode, flags); -} - -void SPIClass::end(void) { - if (!spi_is_enabled(_currentSetting->spi_d)) { - return; - } - - // Follows RM0008's sequence for disabling a SPI in master/slave - // full duplex mode. - while (spi_is_rx_nonempty(_currentSetting->spi_d)) { - // FIXME [0.1.0] remove this once you have an interrupt based driver - volatile uint16 rx __attribute__((unused)) = spi_rx_reg(_currentSetting->spi_d); - } - while (!spi_is_tx_empty(_currentSetting->spi_d)) - ; - while (spi_is_busy(_currentSetting->spi_d)) - ; - spi_peripheral_disable(_currentSetting->spi_d); -} - -/* Roger Clark added 3 functions */ -void SPIClass::setClockDivider(uint32_t clockDivider) -{ - #ifdef SPI_DEBUG - Serial.print("Clock divider set to "); Serial.println(clockDivider); - #endif - _currentSetting->clockDivider = clockDivider; - this->begin(); -} - -void SPIClass::setBitOrder(BitOrder bitOrder) -{ - #ifdef SPI_DEBUG - Serial.print("Bit order set to "); Serial.println(bitOrder); - #endif - _currentSetting->bitOrder = bitOrder; - this->begin(); -} - -/* Victor Perez. Added to test changing datasize from 8 to 16 bit modes on the fly. -* Input parameter should be SPI_CR1_DFF set to 0 or 1 on a 32bit word. -* -*/ -void SPIClass::setDataSize(uint32 datasize) -{ - uint32 cr1 = _currentSetting->spi_d->regs->CR1; - datasize &= SPI_CR1_DFF; - cr1 &= ~(SPI_CR1_DFF); - cr1 |= datasize; - _currentSetting->spi_d->regs->CR1 = cr1; -} - -void SPIClass::setDataMode(uint8_t dataMode) -{ -/* Notes. As far as I can tell, the AVR numbers for dataMode appear to match the numbers required by the STM32 - -From the AVR doc http://www.atmel.com/images/doc2585.pdf section 2.4 - -SPI Mode CPOL CPHA Shift SCK-edge Capture SCK-edge -0 0 0 Falling Rising -1 0 1 Rising Falling -2 1 0 Rising Falling -3 1 1 Falling Rising - - -On the STM32 it appears to be - -bit 1 - CPOL : Clock polarity - - (This bit should not be changed when communication is ongoing) - 0 : CLK to 0 when idle - 1 : CLK to 1 when idle - -bit 0 - CPHA : Clock phase - - (This bit should not be changed when communication is ongoing) - 0 : The first clock transition is the first data capture edge - 1 : The second clock transition is the first data capture edge - -If someone finds this is not the case or sees a logic error with this let me know ;-) - */ - #ifdef SPI_DEBUG - Serial.print("Data mode set to "); Serial.println(dataMode); - #endif - _currentSetting->dataMode = dataMode; - this->begin(); -} - - -void SPIClass::beginTransaction(uint8_t pin, SPISettings settings) -{ - #ifdef SPI_DEBUG - Serial.println("SPIClass::beginTransaction"); - #endif - //_SSPin=pin; - //pinMode(_SSPin,OUTPUT); - //digitalWrite(_SSPin,LOW); - setBitOrder(settings.bitOrder); - setDataMode(settings.dataMode); - setClockDivider(determine_baud_rate(_currentSetting->spi_d, settings.clock)); - begin(); - -} - -void SPIClass::endTransaction(void) -{ - #ifdef SPI_DEBUG - Serial.println("SPIClass::endTransaction"); - #endif - //digitalWrite(_SSPin,HIGH); -#if false -// code from SAM core - uint8_t mode = interruptMode; - if (mode > 0) { - if (mode < 16) { - if (mode & 1) PIOA->PIO_IER = interruptMask[0]; - if (mode & 2) PIOB->PIO_IER = interruptMask[1]; - if (mode & 4) PIOC->PIO_IER = interruptMask[2]; - if (mode & 8) PIOD->PIO_IER = interruptMask[3]; - } else { - if (interruptSave) interrupts(); - } - } -#endif -} - - -/* - * I/O - */ - -uint8 SPIClass::read(void) { - uint8 buf[1]; - this->read(buf, 1); - return buf[0]; -} - -void SPIClass::read(uint8 *buf, uint32 len) { - uint32 rxed = 0; - while (rxed < len) { - while (!spi_is_rx_nonempty(_currentSetting->spi_d)) - ; - buf[rxed++] = (uint8)spi_rx_reg(_currentSetting->spi_d); - } -} - -void SPIClass::write(uint16 data) { - // this->write(&data, 1); - - /* Added for 16bit data Victor Perez. Roger Clark - * Improved speed by just directly writing the single byte to the SPI data reg and wait for completion, * by taking the Tx code from transfer(byte) - * The original method, of calling write(*data, length) . - * This almost doubles the speed of this function. - */ - - spi_tx_reg(_currentSetting->spi_d, data); // "2. Write the first data item to be transmitted into the SPI_DR register (this clears the TXE flag)." - while (spi_is_tx_empty(_currentSetting->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(_currentSetting->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." -} - -//void SPIClass::write(uint8 byte) { - // this->write(&byte, 1); - - /* Roger Clark - * Improved speed by just directly writing the single byte to the SPI data reg and wait for completion, * by taking the Tx code from transfer(byte) - * The original method, of calling write(*data, length) . - * This almost doubles the speed of this function. - */ - -// spi_tx_reg(_currentSetting->spi_d, byte); // "2. Write the first data item to be transmitted into the SPI_DR register (this clears the TXE flag)." -// while (spi_is_tx_empty(_currentSetting->spi_d) == 0); // "5. Wait until TXE=1 ..." -// while (spi_is_busy(_currentSetting->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." -//} - -void SPIClass::write(const uint8 *data, uint32 length) { - uint32 txed = 0; - while (txed < length) { - txed += spi_tx(_currentSetting->spi_d, data + txed, length - txed); - } - while (spi_is_tx_empty(_currentSetting->spi_d) == 0); // "4. After writing the last data item into the SPI_DR register, wait until TXE=1 ..." - while (spi_is_busy(_currentSetting->spi_d) != 0); // "... then wait until BSY=0, this indicates that the transmission of the last data is complete." -} - -uint8 SPIClass::transfer(uint8 byte) const { - uint8 b; - spi_tx_reg(_currentSetting->spi_d, byte); // "2. Write the first data item to be transmitted into the SPI_DR register (this clears the TXE flag)." - while (spi_is_rx_nonempty(_currentSetting->spi_d) == 0); // "4. Wait until RXNE=1 ..." - b = spi_rx_reg(_currentSetting->spi_d); // "... and read the last received data." - while (spi_is_tx_empty(_currentSetting->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(_currentSetting->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." - return b; -} -/* Roger Clark and Victor Perez, 2015 -* Performs a DMA SPI transfer with at least a receive buffer. -* If a TX buffer is not provided, FF is sent over and over for the lenght of the transfer. -* On exit TX buffer is not modified, and RX buffer cotains the received data. -* Still in progress. -*/ -uint8 SPIClass::dmaTransfer(uint8 *transmitBuf, uint8 *receiveBuf, uint16 length) { - if (length == 0) return 0; - uint8 b = 0; - if (spi_is_rx_nonempty(_currentSetting->spi_d) == 1) b = spi_rx_reg(_currentSetting->spi_d); //Clear the RX buffer in case a byte is waiting on it. -// dma1_ch3_Active=true; - dma_init(_currentSetting->spiDmaDev); -// dma_attach_interrupt(DMA1, DMA_CH3, &SPIClass::DMA1_CH3_Event); - - // RX - spi_rx_dma_enable(_currentSetting->spi_d); - dma_setup_transfer(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &_currentSetting->spi_d->regs->DR, DMA_SIZE_8BITS, - receiveBuf, DMA_SIZE_8BITS, (DMA_MINC_MODE | DMA_TRNS_CMPLT));// receive buffer DMA - dma_set_num_transfers(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, length); - - // TX - spi_tx_dma_enable(_currentSetting->spi_d); - if (!transmitBuf) { - static uint8_t ff = 0XFF; - transmitBuf = &ff; - dma_setup_transfer(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &_currentSetting->spi_d->regs->DR, DMA_SIZE_8BITS, - transmitBuf, DMA_SIZE_8BITS, (DMA_FROM_MEM | DMA_TRNS_CMPLT));// Transmit FF repeatedly - } - else { - dma_setup_transfer(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &_currentSetting->spi_d->regs->DR, DMA_SIZE_8BITS, - transmitBuf, DMA_SIZE_8BITS, (DMA_MINC_MODE | DMA_FROM_MEM | DMA_TRNS_CMPLT));// Transmit buffer DMA - } - dma_set_num_transfers(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, length); - - dma_enable(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel);// enable receive - dma_enable(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel);// enable transmit - -// while (dma1_ch3_Active); -// if (receiveBuf) { - uint32_t m = millis(); - while ((dma_get_isr_bits(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel) & 0x2)==0) {//Avoid interrupts and just loop waiting for the flag to be set. - if ((millis() - m) > 100) { -// dma1_ch3_Active = 0; - b = 2; - break; - } - } - dma_clear_isr_bits(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel); - -// } - while (spi_is_tx_empty(_currentSetting->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(_currentSetting->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." - dma_disable(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel); - dma_disable(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel); - spi_rx_dma_disable(_currentSetting->spi_d); // And disable generation of DMA request from the SPI port so other peripherals can use the channels - spi_tx_dma_disable(_currentSetting->spi_d); - if (spi_is_rx_nonempty(_currentSetting->spi_d) != 0){; // "4. Wait until RXNE=1 ..." - uint8 x = spi_rx_reg(_currentSetting->spi_d); // "... and read the last received data." - } - return b; -} - -/* Roger Clark and Victor Perez, 2015 -* Performs a DMA SPI send using a TX buffer. -* On exit TX buffer is not modified. -* Still in progress. -*/ -uint8 SPIClass::dmaSend(uint8 *transmitBuf, uint16 length, bool minc) { - if (length == 0) return 0; - uint32 flags = ((DMA_MINC_MODE * minc) | DMA_FROM_MEM | DMA_TRNS_CMPLT); - uint8 b = 0; -// dma1_ch3_Active=true; - dma_init(_currentSetting->spiDmaDev); -// dma_attach_interrupt(DMA1, DMA_CH3, &SPIClass::DMA1_CH3_Event); - - // TX - spi_tx_dma_enable(_currentSetting->spi_d); - dma_setup_transfer(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &_currentSetting->spi_d->regs->DR, DMA_SIZE_8BITS, - transmitBuf, DMA_SIZE_8BITS, flags);// Transmit buffer DMA - dma_set_num_transfers(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, length); - dma_enable(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel);// enable transmit - -// while (dma1_ch3_Active); - while ((dma_get_isr_bits(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel) & 0x2)==0); //Avoid interrupts and just loop waiting for the flag to be set. - dma_clear_isr_bits(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel); - - while (spi_is_tx_empty(_currentSetting->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(_currentSetting->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." - dma_disable(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel); - spi_tx_dma_disable(_currentSetting->spi_d); - if (spi_is_rx_nonempty(_currentSetting->spi_d) != 0){; // "4. Wait until RXNE=1 ..." - uint8 x = spi_rx_reg(_currentSetting->spi_d); // "... and read the last received data." - } - return b; -} - -uint8 SPIClass::dmaSend(uint16 *transmitBuf, uint16 length, bool minc) { - if (length == 0) return 0; - uint32 flags = ((DMA_MINC_MODE * minc) | DMA_FROM_MEM | DMA_TRNS_CMPLT); - uint8 b; - dma1_ch3_Active=true; - dma_init(_currentSetting->spiDmaDev); -// dma_attach_interrupt(DMA1, DMA_CH3, &SPIClass::DMA1_CH3_Event); - - // TX - spi_tx_dma_enable(_currentSetting->spi_d); - dma_setup_transfer(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &_currentSetting->spi_d->regs->DR, DMA_SIZE_16BITS, - transmitBuf, DMA_SIZE_16BITS, flags);// Transmit buffer DMA - dma_set_num_transfers(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, length); - dma_enable(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel);// enable transmit - -// while (dma1_ch3_Active); - while ((dma_get_isr_bits(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel) & 0x2)==0); //Avoid interrupts and just loop waiting for the flag to be set. - dma_clear_isr_bits(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel); - - while (spi_is_tx_empty(_currentSetting->spi_d) == 0); // "5. Wait until TXE=1 ..." - while (spi_is_busy(_currentSetting->spi_d) != 0); // "... and then wait until BSY=0 before disabling the SPI." - dma_disable(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel); - spi_tx_dma_disable(_currentSetting->spi_d); - if (spi_is_rx_nonempty(_currentSetting->spi_d) != 0){; // "4. Wait until RXNE=1 ..." - b = spi_rx_reg(_currentSetting->spi_d); // "... and read the last received data." - } - return b; -} - - -void SPIClass::attachInterrupt(void) { - // Should be enableInterrupt() -} - -void SPIClass::detachInterrupt(void) { - // Should be disableInterrupt() -} - -/* - * Pin accessors - */ - -uint8 SPIClass::misoPin(void) { - return dev_to_spi_pins(_currentSetting->spi_d)->miso; -} - -uint8 SPIClass::mosiPin(void) { - return dev_to_spi_pins(_currentSetting->spi_d)->mosi; -} - -uint8 SPIClass::sckPin(void) { - return dev_to_spi_pins(_currentSetting->spi_d)->sck; -} - -uint8 SPIClass::nssPin(void) { - return dev_to_spi_pins(_currentSetting->spi_d)->nss; -} - -/* - * Deprecated functions - */ - -uint8 SPIClass::send(uint8 data) { - uint8 buf[] = {data}; - return this->send(buf, 1); -} - -uint8 SPIClass::send(uint8 *buf, uint32 len) { - uint32 txed = 0; - uint8 ret = 0; - while (txed < len) { - this->write(buf[txed++]); - ret = this->read(); - } - return ret; -} - -uint8 SPIClass::recv(void) { - return this->read(); -} - - -/* - * Auxiliary functions - */ - -static const spi_pins* dev_to_spi_pins(spi_dev *dev) { - switch (dev->clk_id) { -#if BOARD_NR_SPI >= 1 - case RCC_SPI1: return board_spi_pins; -#endif -#if BOARD_NR_SPI >= 2 - case RCC_SPI2: return board_spi_pins + 1; -#endif -#if BOARD_NR_SPI >= 3 - case RCC_SPI3: return board_spi_pins + 2; -#endif - default: return NULL; - } -} - -static void disable_pwm(const stm32_pin_info *i) { - if (i->timer_device) { - timer_set_mode(i->timer_device, i->timer_channel, TIMER_DISABLED); - } -} - -static void configure_gpios(spi_dev *dev, bool as_master) { - const spi_pins *pins = dev_to_spi_pins(dev); - - if (!pins) { - return; - } - - const stm32_pin_info *nssi = &PIN_MAP[pins->nss]; - const stm32_pin_info *scki = &PIN_MAP[pins->sck]; - const stm32_pin_info *misoi = &PIN_MAP[pins->miso]; - const stm32_pin_info *mosii = &PIN_MAP[pins->mosi]; - - disable_pwm(nssi); - disable_pwm(scki); - disable_pwm(misoi); - disable_pwm(mosii); - - spi_config_gpios(dev, as_master, nssi->gpio_device, nssi->gpio_bit, - scki->gpio_device, scki->gpio_bit, misoi->gpio_bit, - mosii->gpio_bit); -} - -static const spi_baud_rate baud_rates[8] __FLASH__ = { - SPI_BAUD_PCLK_DIV_2, - SPI_BAUD_PCLK_DIV_4, - SPI_BAUD_PCLK_DIV_8, - SPI_BAUD_PCLK_DIV_16, - SPI_BAUD_PCLK_DIV_32, - SPI_BAUD_PCLK_DIV_64, - SPI_BAUD_PCLK_DIV_128, - SPI_BAUD_PCLK_DIV_256, -}; - -/* - * Note: This assumes you're on a LeafLabs-style board - * (CYCLES_PER_MICROSECOND == 72, APB2 at 72MHz, APB1 at 36MHz). - */ -static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq) { - uint32_t clock = 0, i; - #ifdef SPI_DEBUG - Serial.print("determine_baud_rate("); Serial.print(freq); Serial.println(")"); - #endif - switch (rcc_dev_clk(dev->clk_id)) - { - case RCC_APB2: clock = STM32_PCLK2; break; // 72 Mhz - case RCC_APB1: clock = STM32_PCLK1; break; // 36 Mhz - } - clock /= 2; - i = 0; - while (i < 7 && freq < clock) { - clock /= 2; - i++; - } - return baud_rates[i]; -} - -SPIClass SPI(1); diff --git a/GD32F1/libraries/SPI/src/SPI.h b/GD32F1/libraries/SPI/src/SPI.h deleted file mode 100644 index 9bfe4f4..0000000 --- a/GD32F1/libraries/SPI/src/SPI.h +++ /dev/null @@ -1,389 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/include/wirish/HardwareSPI.h - * @brief High-level SPI interface - * - * This is a "bare essentials" polling driver for now. - */ - -/* TODO [0.1.0] Remove deprecated methods. */ - - - -#ifndef _SPI_H_INCLUDED -#define _SPI_H_INCLUDED - -#include -#include -#include - -#include -#include -#include - -// SPI_HAS_TRANSACTION means SPI has -// - beginTransaction() -// - endTransaction() -// - usingInterrupt() -// - SPISetting(clock, bitOrder, dataMode) -//#define SPI_HAS_TRANSACTION - -#define SPI_CLOCK_DIV2 SPI_BAUD_PCLK_DIV_2 -#define SPI_CLOCK_DIV4 SPI_BAUD_PCLK_DIV_4 -#define SPI_CLOCK_DIV8 SPI_BAUD_PCLK_DIV_8 -#define SPI_CLOCK_DIV16 SPI_BAUD_PCLK_DIV_16 -#define SPI_CLOCK_DIV32 SPI_BAUD_PCLK_DIV_32 -#define SPI_CLOCK_DIV64 SPI_BAUD_PCLK_DIV_64 -#define SPI_CLOCK_DIV128 SPI_BAUD_PCLK_DIV_128 -#define SPI_CLOCK_DIV256 SPI_BAUD_PCLK_DIV_256 - -/* - * Roger Clark. 20150106 - * Commented out redundant AVR defined - * -#define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR -#define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR -#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR - -// define SPI_AVR_EIMSK for AVR boards with external interrupt pins -#if defined(EIMSK) - #define SPI_AVR_EIMSK EIMSK -#elif defined(GICR) - #define SPI_AVR_EIMSK GICR -#elif defined(GIMSK) - #define SPI_AVR_EIMSK GIMSK -#endif -*/ - -#ifndef STM32_LSBFIRST -#define STM32_LSBFIRST 0 -#endif -#ifndef STM32_MSBFIRST -#define STM32_MSBFIRST 1 -#endif - -// PC13 or PA4 -//#define BOARD_SPI_DEFAULT_SS PA4 -#define BOARD_SPI_DEFAULT_SS PC13 - -#define SPI_MODE0 SPI_MODE_0 -#define SPI_MODE1 SPI_MODE_1 -#define SPI_MODE2 SPI_MODE_2 -#define SPI_MODE3 SPI_MODE_3 - -class SPISettings { -public: - SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) { - if (__builtin_constant_p(clock)) { - init_AlwaysInline(clock, bitOrder, dataMode); - } else { - init_MightInline(clock, bitOrder, dataMode); - } - } - SPISettings() { init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0); } -private: - void init_MightInline(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) { - init_AlwaysInline(clock, bitOrder, dataMode); - } - void init_AlwaysInline(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) __attribute__((__always_inline__)) { - this->clock = clock; - this->bitOrder = bitOrder; - this->dataMode = dataMode; - } - uint32_t clock; - BitOrder bitOrder; - uint8_t dataMode; - - spi_dev *spi_d; - uint8_t _SSPin; - uint32_t clockDivider; - dma_channel spiRxDmaChannel, spiTxDmaChannel; - dma_dev* spiDmaDev; - - friend class SPIClass; -}; - - -volatile static bool dma1_ch3_Active; - -/** - * @brief Wirish SPI interface. - * - * This implementation uses software slave management, so the caller - * is responsible for controlling the slave select line. - */ -class SPIClass { -public: - - - - /** - * @param spiPortNumber Number of the SPI port to manage. - */ - SPIClass(uint32 spiPortNumber); - - /* - * Set up/tear down - */ - - - - /** - * @brief Equivalent to begin(SPI_1_125MHZ, MSBFIRST, 0). - */ - void begin(void); - - /** - * @brief Turn on a SPI port and set its GPIO pin modes for use as a slave. - * - * SPI port is enabled in full duplex mode, with software slave management. - * - * @param bitOrder Either LSBFIRST (little-endian) or MSBFIRST(big-endian) - * @param mode SPI mode to use - */ - void beginSlave(uint32 bitOrder, uint32 mode); - - /** - * @brief Equivalent to beginSlave(MSBFIRST, 0). - */ - void beginSlave(void); - - /** - * @brief Disables the SPI port, but leaves its GPIO pin modes unchanged. - */ - void end(void); - - void beginTransaction(SPISettings settings) { beginTransaction(BOARD_SPI_DEFAULT_SS, settings); } - void beginTransaction(uint8_t pin, SPISettings settings); - void endTransaction(void); - - void setClockDivider(uint32_t clockDivider); - void setBitOrder(BitOrder bitOrder); - void setDataMode(uint8_t dataMode); - - // SPI Configuration methods - void attachInterrupt(void); - void detachInterrupt(void); - - /* Victor Perez. Added to change datasize from 8 to 16 bit modes on the fly. - * Input parameter should be SPI_CR1_DFF set to 0 or 1 on a 32bit word. - * Requires an added function spi_data_size on STM32F1 / cores / maple / libmaple / spi.c - */ - void setDataSize(uint32 ds); - - - /* - * I/O - */ - - /** - * @brief Return the next unread byte. - * - * If there is no unread byte waiting, this function will block - * until one is received. - */ - uint8 read(void); - - /** - * @brief Read length bytes, storing them into buffer. - * @param buffer Buffer to store received bytes into. - * @param length Number of bytes to store in buffer. This - * function will block until the desired number of - * bytes have been read. - */ - void read(uint8 *buffer, uint32 length); - - /** - * @brief Transmit a byte. - * @param data Byte to transmit. - */ -// void write(uint8 data); - - /** - * @brief Transmit a half word. - * @param data to transmit. - */ - void write(uint16 data); - - /** - * @brief Transmit multiple bytes. - * @param buffer Bytes to transmit. - * @param length Number of bytes in buffer to transmit. - */ - void write(const uint8 *buffer, uint32 length); - - /** - * @brief Transmit a byte, then return the next unread byte. - * - * This function transmits before receiving. - * - * @param data Byte to transmit. - * @return Next unread byte. - */ - uint8 transfer(uint8 data) const; - - /** - * @brief Sets up a DMA Transfer for "length" bytes. - * - * This function transmits and receives to buffers. - * - * @param transmitBuf buffer Bytes to transmit. If passed as 0, it sends FF repeatedly for "length" bytes - * @param receiveBuf buffer Bytes to save received data. - * @param length Number of bytes in buffer to transmit. - */ - uint8 dmaTransfer(uint8 *transmitBuf, uint8 *receiveBuf, uint16 length); - - /** - * @brief Sets up a DMA Transmit for bytes. - * - * This function transmits and does not care about the RX fifo. - * - * @param transmitBuf buffer Bytes to transmit, - * @param length Number of bytes in buffer to transmit. - * @param minc Set to use Memory Increment mode, clear to use Circular mode. - */ - uint8 dmaSend(uint8 *transmitBuf, uint16 length, bool minc = 1); - - /** - * @brief Sets up a DMA Transmit for half words. - * SPI PERFIPHERAL MUST BE SET TO 16 BIT MODE BEFORE - * - * This function transmits and does not care about the RX fifo. - * - * @param data buffer half words to transmit, - * @param length Number of bytes in buffer to transmit. - * @param minc Set to use Memory Increment mode (default if blank), clear to use Circular mode. - */ - uint8 dmaSend(uint16 *transmitBuf, uint16 length, bool minc = 1); - - /* - * Pin accessors - */ - - /** - * @brief Return the number of the MISO (master in, slave out) pin - */ - uint8 misoPin(void); - - /** - * @brief Return the number of the MOSI (master out, slave in) pin - */ - uint8 mosiPin(void); - - /** - * @brief Return the number of the SCK (serial clock) pin - */ - uint8 sckPin(void); - - /** - * @brief Return the number of the NSS (slave select) pin - */ - uint8 nssPin(void); - - /* Escape hatch */ - - /** - * @brief Get a pointer to the underlying libmaple spi_dev for - * this HardwareSPI instance. - */ - spi_dev* c_dev(void) { return _currentSetting->spi_d; } - - - spi_dev *dev(){ return _currentSetting->spi_d;} - - /** - * @brief Sets the number of the SPI peripheral to be used by - * this HardwareSPI instance. - * - * @param spi_num Number of the SPI port. 1-2 in low density devices - * or 1-3 in high density devices. - */ - - void setModule(int spi_num) - { - _currentSetting=&_settings[spi_num-1];// SPI channels are called 1 2 and 3 but the array is zero indexed - } - - - /* -- The following methods are deprecated --------------------------- */ - - /** - * @brief Deprecated. - * - * Use HardwareSPI::transfer() instead. - * - * @see HardwareSPI::transfer() - */ - uint8 send(uint8 data); - - /** - * @brief Deprecated. - * - * Use HardwareSPI::write() in combination with - * HardwareSPI::read() (or HardwareSPI::transfer()) instead. - * - * @see HardwareSPI::write() - * @see HardwareSPI::read() - * @see HardwareSPI::transfer() - */ - uint8 send(uint8 *data, uint32 length); - - /** - * @brief Deprecated. - * - * Use HardwareSPI::read() instead. - * - * @see HardwareSPI::read() - */ - uint8 recv(void); - -private: -/* - static inline void DMA1_CH3_Event() { - dma1_ch3_Active = 0; -// dma_disable(DMA1, DMA_CH3); -// dma_disable(DMA1, DMA_CH2); - - // To Do. Need to wait for - } -*/ - SPISettings _settings[BOARD_NR_SPI]; - SPISettings *_currentSetting; - - /* - spi_dev *spi_d; - uint8_t _SSPin; - uint32_t clockDivider; - uint8_t dataMode; - BitOrder bitOrder; - */ -}; - - -extern SPIClass SPI;//(1);// dummy params -#endif diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/README.md b/GD32F1/libraries/Serasidis_EtherCard_STM/README.md deleted file mode 100644 index aa366ee..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# EtherCard - -**EtherCard** is a driver for the ENC28J60 chip, compatible with Arduino IDE 1.6.3 (or later). -Adapted and extended from code written by Guido Socher and Pascal Stang. - -License: GPL2 - -The documentation for this library is at http://jeelabs.net/pub/docs/ethercard/. - -## Physical Installation - -### PIN Connections (Using STM32F103): - -|ENC28J60|STM32F103| -|:------:|:-----:| -|Vcc|3.3V| -|SCK|PA5| -|SO|PA6| -|SI|PA7| -|CS|PA8| # Selectable with the ether.begin() function -|RST|3.3V| - -The **CS** pin is selectable with the ether.begin() function. - -e.g. If you want to use the **PA9** as **CS** pin then you can initiallize the ethernet module inside the sketch as: - -`if (ether.begin(sizeof Ethernet::buffer, mymac) == 0,`**`PA9`**`) ` - -By default the pin **PA8** is used as **CS** (you don't have to initiallize it). - - -## Credits - -The **EtherCard** library was written by [Jean-Claude Wippler][F] and ported to **STM32F103** by [Vassilis Serasidis][V] - -## Support - -That library works perfect on Arduino IDE 1.6.3 (or later) with [Arduino_STM32 project][S] installed. - -The Arduino STM32 project has a forum ([STM32duino][F]) also for getting or for providing help to people that are interested in that project . - -[F]: https://github.com/jcw -[S]: https://github.com/rogerclarkmelbourne/Arduino_STM32 -[F]: http://www.stm32duino.com -[V]: https://github.com/Serasidis diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/JeeUdp/JeeUdp.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/JeeUdp/JeeUdp.ino deleted file mode 100644 index f22c538..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/JeeUdp/JeeUdp.ino +++ /dev/null @@ -1,320 +0,0 @@ -// Collect RF12 packets and send them on as UDP collectd packets on Ethernet. -// 2010-05-20 http://opensource.org/licenses/mit-license.php - -// This sketch is derived from RF12eth.pde (and etherNode.ino): -// May 2010, Andras Tucsni, http://opensource.org/licenses/mit-license.php - -#include -#include -#include - -#define DEBUG 1 // set to 1 to display free RAM on web page -#define SERIAL 1 // set to 1 to show incoming requests on serial port - -#define CONFIG_EEPROM_ADDR ((byte*) 0x10) - -// configuration, as stored in EEPROM -struct Config { - byte band; - byte group; - byte collect; - word port; - byte valid; // keep this as last byte -} config; - -// ethernet interface mac address - must be unique on your network -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -// buffer for an outgoing data packet -static byte outBuf[RF12_MAXDATA], outDest; -static char outCount = -1; - -// this buffer will be used to construct a collectd UDP packet -static byte collBuf [200], collPos; - -#define NUM_MESSAGES 3 // Number of messages saved in history -#define MESSAGE_TRUNC 15 // Truncate message payload to reduce memory use - -static BufferFiller bfill; // used as cursor while filling the buffer - -static byte history_rcvd[NUM_MESSAGES][MESSAGE_TRUNC+1]; //history record -static byte history_len[NUM_MESSAGES]; // # of RF12 messages+header in history -static byte next_msg; // pointer to next rf12rcvd line -static word msgs_rcvd; // total number of lines received modulo 10,000 - -byte Ethernet::buffer[700]; // tcp/ip send and receive buffer - -static void loadConfig () { - for (byte i = 0; i < sizeof config; ++i) - ((byte*) &config)[i] = eeprom_read_byte(CONFIG_EEPROM_ADDR + i); - if (config.valid != 253) { - config.valid = 253; - config.band = 8; - config.group = 1; - config.collect = 1; - config.port = 25827; - } - byte freq = config.band == 4 ? RF12_433MHZ : - config.band == 8 ? RF12_868MHZ : - RF12_915MHZ; - rf12_initialize(31, freq, config.group); -} - -static void saveConfig () { - for (byte i = 0; i < sizeof config; ++i) - eeprom_write_byte(CONFIG_EEPROM_ADDR + i, ((byte*) &config)[i]); -} - -#if DEBUG -static int freeRam () { -extern int __heap_start, *__brkval; -int v; -return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); -} -#endif - -void setup (){ - Serial.begin(57600); - Serial.println("\n[JeeUdp]"); - loadConfig(); - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println( "Failed to access Ethernet controller"); - if (!ether.dhcpSetup()) - Serial.println("DHCP failed"); - ether.printIp("IP: ", ether.myip); -} - -const char okHeader[] PROGMEM = - "HTTP/1.0 200 OK\r\n" - "Content-Type: text/html\r\n" - "Pragma: no-cache\r\n" -; - -static void homePage (BufferFiller& buf) { - word mhz = config.band == 4 ? 433 : config.band == 8 ? 868 : 915; - buf.emit_p(PSTR("$F\r\n" - "RF12 JeeUdp" - "

RF12 JeeUdp @ $D - RF12 @ $D.$D

" - "Configure - Send Packet" - "

Last $D messages:

" - "
"), okHeader, config.port, mhz, config.group, NUM_MESSAGES);
-  for (byte i = 0; i < NUM_MESSAGES; ++i) {
-    byte j = (next_msg + i) % NUM_MESSAGES;
-    if (history_len[j] > 0) {
-      word n = msgs_rcvd - NUM_MESSAGES + i;
-      buf.emit_p(PSTR("\n$D$D$D$D: OK"), // hack, to show leading zero's
-                          n/1000, (n/100) % 10, (n/10) % 10, n % 10);
-      for (byte k = 0; k < history_len[j]; ++k)
-        buf.emit_p(PSTR(" $D"), history_rcvd[j][k]);
-    }
-  }
-  long t = millis() / 1000;
-  word h = t / 3600;
-  byte m = (t / 60) % 60;
-  byte s = t % 60;
-  buf.emit_p(PSTR(
-    "
" - "Uptime is $D$D:$D$D:$D$D"), h/10, h%10, m/10, m%10, s/10, s%10); -#if DEBUG - buf.emit_p(PSTR(" ($D bytes free)"), freeRam()); -#endif -} - -static int getIntArg(const char* data, const char* key, int value =-1) { - char temp[10]; - if (ether.findKeyVal(data + 7, temp, sizeof temp, key) > 0) - value = atoi(temp); - return value; -} - -static void configPage (const char* data, BufferFiller& buf) { - // pick up submitted data, if present - if (data[6] == '?') { - byte b = getIntArg(data, "b", 8); - byte g = getIntArg(data, "g", 1); - byte c = getIntArg(data, "c", 0); - word p = getIntArg(data, "p", 25827); - if (1 <= g && g <= 250 && 1024 <= p && p <= 30000) { - // store values as new settings - config.band = b; - config.group = g; - config.collect = c; - config.port = p; - saveConfig(); - // re-init RF12 driver - loadConfig(); - // clear history - memset(history_len, 0, sizeof history_len); - // redirect to the home page - buf.emit_p(PSTR( - "HTTP/1.0 302 found\r\n" - "Location: /\r\n" - "\r\n")); - return; - } - } - // else show a configuration form - buf.emit_p(PSTR("$F\r\n" - "

Server node configuration

" - "
" - "

" - "Freq band (4, 8, or 9)
" - "Net group (1..250)
" - "Collect mode: " - "(don't send ACKs)

" - "UDP Port (1024..30000)" - "

" - "" - "
"), okHeader, config.band, config.group, - config.collect ? "CHECKED" : "", - config.port); -} - -static void sendPage (const char* data, BufferFiller& buf) { - // pick up submitted data, if present - const char* p = strstr(data, "b="); - byte d = getIntArg(data, "d"); - if (data[6] == '?' && p != 0 && 0 <= d && d <= 31) { - // prepare to send data as soon as possible in loop() - outDest = d & RF12_HDR_MASK ? RF12_HDR_DST | d : 0; - outCount = 0; - // convert the input string to a number of decimal data bytes in outBuf - ++p; - while (*p != 0 && *p != '&') { - outBuf[outCount] = 0; - while ('0' <= *++p && *p <= '9') - outBuf[outCount] = 10 * outBuf[outCount] + (*p - '0'); - ++outCount; - } -#if SERIAL - Serial.print("Send to "); - Serial.print(outDest, DEC); - Serial.print(':'); - for (byte i = 0; i < outCount; ++i) { - Serial.print(' '); - Serial.print(outBuf[i], DEC); - } - Serial.println(); -#endif - // redirect to home page - buf.emit_p(PSTR( - "HTTP/1.0 302 found\r\n" - "Location: /\r\n" - "\r\n")); - return; - } - // else show a send form - buf.emit_p(PSTR("$F\r\n" - "

Send a wireless data packet

" - "
" - "

" - "Data bytes (decimal)
" - "Destination node " - "(1..31, or 0 to broadcast)
" - "

" - "" - "
"), okHeader); -} - -static void collectTypeLen (word type, word len) { - len += 4; - collBuf[collPos++] = type >> 8; - collBuf[collPos++] = (byte) type; - collBuf[collPos++] = len >> 8; - collBuf[collPos++] = (byte) len; -} - -static void collectStr (word type, const char* data) { - word len = strlen(data) + 1; - collectTypeLen(type, len); - strcpy((char*) collBuf + collPos, data); - collPos += len; -} - -static void collectPayload (word type) { - // Copy the received RF12 data into a as many values as needed. - byte num = rf12_len / 8 + 1; // this many values will be needed - collectTypeLen(type, 2 + 9 * num); - collBuf[collPos++] = 0; - collBuf[collPos++] = num; - for (byte i = 0; i < num; ++i) - collBuf[collPos++] = 0; // counter - for (char i = 0; i < 8 * num; ++i) // include -1, i.e. the length byte - collBuf[collPos++] = i <= rf12_len ? rf12_data[i-1] : 0; -} - -static void forwardToUDP () { - static byte destIp[] = { 239,192,74,66 }; // UDP multicast address - char buf[10]; - - collPos = 0; - collectStr(0x0000, "JeeUdp"); - collectStr(0x0002, "RF12"); - word mhz = config.band == 4 ? 433 : config.band == 8 ? 868 : 915; - sprintf(buf, "%d.%d", mhz, config.group); - collectStr(0x0003, buf); - collectStr(0x0004, "OK"); - sprintf(buf, "%d", rf12_hdr); - collectStr(0x0005, buf); - collectPayload(0x0006); - - ether.sendUdp ((char*) collBuf, collPos, 23456, destIp, config.port); -#if SERIAL - Serial.println("UDP sent"); -#endif -} - -void loop (){ - word len = ether.packetReceive(); - word pos = ether.packetLoop(len); - // check if valid tcp data is received - if (pos) { - bfill = ether.tcpOffset(); - char* data = (char *) Ethernet::buffer + pos; -#if SERIAL - Serial.println(data); -#endif - // receive buf hasn't been clobbered by reply yet - if (strncmp("GET / ", data, 6) == 0) - homePage(bfill); - else if (strncmp("GET /c", data, 6) == 0) - configPage(data, bfill); - else if (strncmp("GET /s", data, 6) == 0) - sendPage(data, bfill); - else - bfill.emit_p(PSTR( - "HTTP/1.0 401 Unauthorized\r\n" - "Content-Type: text/html\r\n" - "\r\n" - "

401 Unauthorized

")); - ether.httpServerReply(bfill.position()); // send web page data - } - - // RFM12 loop runner, don't report acks - if (rf12_recvDone() && rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0) { - history_rcvd[next_msg][0] = rf12_hdr; - for (byte i = 0; i < rf12_len; ++i) - if (i < MESSAGE_TRUNC) - history_rcvd[next_msg][i+1] = rf12_data[i]; - history_len[next_msg] = rf12_len < MESSAGE_TRUNC ? rf12_len+1 - : MESSAGE_TRUNC+1; - next_msg = (next_msg + 1) % NUM_MESSAGES; - msgs_rcvd = (msgs_rcvd + 1) % 10000; - - if (RF12_WANTS_ACK && !config.collect) { -#if SERIAL - Serial.println(" -> ack"); -#endif - rf12_sendStart(RF12_ACK_REPLY, 0, 0); - } - - forwardToUDP(); - } - - // send a data packet out if requested - if (outCount >= 0 && rf12_canSend()) { - rf12_sendStart(outDest, outBuf, outCount, 1); - outCount = -1; - } -} - diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/SSDP/SSDP.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/SSDP/SSDP.ino deleted file mode 100644 index dd0778d..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/SSDP/SSDP.ino +++ /dev/null @@ -1,145 +0,0 @@ -#include |Mac adress| -#include - -const char SSDP_RESPONSE[] PROGMEM = "HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=1200\r\nEXT:\r\nSERVER:Arduino\r\nST: upnp:rootdevice\r\nUSN: uuid:abcdefgh-7dec-11d0-a765-7499692d3040\r\nLOCATION: http://"; //dont forget our mac adress USN: uuid:abcdefgh-7dec-11d0-a765-Mac addr -const char SSDP_RESPONSE_XML[] PROGMEM = "/??\r\n\r\n"; // here is the adress of xml file /?? in this exemple but you could use another /upnp.xml\r\n\r\n -const char XML_DESCRIP[] PROGMEM = "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\n\r\n\rurn:schemas-upnp-org:device:BinaryLight:1/ArduinoFredycpuhttp://fredycpu.pro1uuid:abcdefgh-7dec-11d0-a765-7499692d3040 "; -const char SSDP_NOTIFY[] PROGMEM = "NOTIFY * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nCACHE-CONTROL: max-age=1200\r\nNT: upnp:rootdevice\r\nUSN: uuid:abcdefga-7dec-11d0-a765-7499692d3040::upnp:rootdevice\r\nNTS: ssdp:alive\r\nSERVER: Arduino UPnP/1.0\r\nLOCATION: http://"; //dont forget our mac adress USN: uuid:abcdefgh-7dec-11d0-a765-Mac addr -// in XML_DESCRIP // urn:schemas-upnp-org:device:BinaryLight:1 // declare as home automation -// in XML_DESCRIP // Arduino // declare the name of the service here Arduino -// in XML_DESCRIP // / // adress of the page who would opened on service double click ,you could use http://ip but if you use dhcp it's better so and dont wase memory -// this is the entire protocol, but you can try to use SSDP_NOTIFY as SSDP_RESPONSE with most systems will work and you can free a bit of flash mem. -static byte myip[] = { - 192,168,1,204 }; -static byte gwip[] = { - 192,168,1,1 }; -static byte ssdp[] = { - 239,255,255,250 }; -static byte mymac[] = { - 0x74,0x99,0x69,0x2D,0x30,0x40 }; // if you change it you must update SSDP_RESPONSE and XML_DESCRIP -byte Ethernet::buffer[750]; // tcp ip send and receive buffer -unsigned long timer=9999; -const char pageA[] PROGMEM = -"HTTP/1.0 200 OK\r\n" -"Content-Type: text/html\r\n" -"\r\n" -"" -"" -"multipackets Test" -"" -"" -"Start here
" -"Image test
" -"

packet 1

" -"

" -"the first packet send " -"

" -; -const char pageB[] PROGMEM = -"

packet 2

" -"

" -"if you read this it mean it works" -"

" -; -const char pageC[] PROGMEM = -"

packet 3

" -"

" -"if you read this it mean it works" -"

" -; -const char pageD[] PROGMEM = -"

packet 4

" -"

" -"if you read this it mean it works" -"

" -; - -void setup(){ - ether.begin(sizeof Ethernet::buffer, mymac);// 53 for the mega ethernet shield and 10 for normal ethernet shield - ether.staticSetup(myip, gwip); - ENC28J60::disableMulticast(); //disable multicast filter means enable multicast reception - Serial.begin(57600); -} - -void loop(){ -wait: - word pos = ether.packetLoop(ether.packetReceive()); - // check if valid tcp data is received - if (pos) { - char* data = (char *) Ethernet::buffer + pos; - if (strncmp("GET / ", data, 6) == 0) { - ether.httpServerReplyAck(); // send ack to the request - memcpy_P(ether.tcpOffset(), pageA, sizeof pageA); // send first packet and not send the terminate flag - ether.httpServerReply_with_flags(sizeof pageA - 1,TCP_FLAGS_ACK_V); - memcpy_P(ether.tcpOffset(), pageB, sizeof pageB); // send second packet and not send the terminate flag - ether.httpServerReply_with_flags(sizeof pageB - 1,TCP_FLAGS_ACK_V); - memcpy_P(ether.tcpOffset(), pageC, sizeof pageC); // send thirdt packet and not send the terminate flag - ether.httpServerReply_with_flags(sizeof pageC - 1,TCP_FLAGS_ACK_V); - memcpy_P(ether.tcpOffset(), pageD, sizeof pageD); // send fourth packet and send the terminate flag - ether.httpServerReply_with_flags(sizeof pageD - 1,TCP_FLAGS_ACK_V|TCP_FLAGS_FIN_V); - goto wait; - } - if (strncmp("GET /??", data, 7) == 0) { // description of services (normaly an xml file but here .....) - ether.httpServerReplyAck(); - memcpy_P(Ethernet::buffer + TCP_OPTIONS_P,XML_DESCRIP, sizeof XML_DESCRIP); - ether.httpServerReply_with_flags(sizeof XML_DESCRIP - 1 ,TCP_FLAGS_ACK_V|TCP_FLAGS_FIN_V); - goto wait; - } - if (strncmp("M-SEARCH", data, 8) == 0) { // service discovery request comes here (udp protocol) - ssdpresp(); - goto wait; - } - } - if (((millis()-timer)>50000)||(timer>millis())) { - timer=millis(); - ssdpnotify(); - } -} -void ssdpresp() { //response to m-search - byte ip_dst[4]; - unsigned int port_dst=Ethernet::buffer[34]*256+Ethernet::buffer[35];//extract source port of request - for( int i=0; i<4;i++) { //extract source IP of request - ip_dst[i]=Ethernet::buffer[i+26]; - } - int udppos = UDP_DATA_P; - - EtherCard::udpPrepare(1900,ip_dst,port_dst); - memcpy_P(Ethernet::buffer + udppos, SSDP_RESPONSE, sizeof SSDP_RESPONSE); - udppos = udppos + sizeof SSDP_RESPONSE-1; - addip(udppos); -} - -void ssdpnotify() { //Notification - int udppos = UDP_DATA_P; - EtherCard::udpPrepare(1900,ssdp,1900); - memcpy_P(Ethernet::buffer + udppos, SSDP_NOTIFY, sizeof SSDP_NOTIFY); -udppos = udppos + sizeof SSDP_NOTIFY-1; -addip(udppos); -} - -void addip(int udppos) { // add current ip to the request and send it - int adr; - for(int i=0;i<4;i++) { // extract the current ip of arduino - adr = ether.myip[i]/100; - if (adr) { - Ethernet::buffer[udppos]=adr+48; - udppos++; - } - adr=(ether.myip[i]%100)/10; - if (adr) { - Ethernet::buffer[udppos]=adr+48; - udppos++; - } - adr=ether.myip[i]%10; - Ethernet::buffer[udppos]=adr+48; - udppos++; - Ethernet::buffer[udppos]=46; - udppos++; //"." - } - udppos--;//erase the last point - memcpy_P(Ethernet::buffer + udppos,SSDP_RESPONSE_XML,sizeof SSDP_RESPONSE_XML); - udppos = udppos + sizeof SSDP_RESPONSE_XML; - udppos--; - EtherCard::udpTransmit(udppos-UDP_DATA_P); // send all to the computer who make the request on her ip and port who make the request -} - diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/backSoon/backSoon.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/backSoon/backSoon.ino deleted file mode 100644 index 9d7834e..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/backSoon/backSoon.ino +++ /dev/null @@ -1,84 +0,0 @@ -// Present a "Will be back soon web page", as stand-in webserver. -// 2011-01-30 http://opensource.org/licenses/mit-license.php -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -#define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below) - -#if STATIC -// ethernet interface ip address -static byte myip[] = { 192,168,1,203 }; -// gateway ip address -static byte gwip[] = { 192,168,1,1 }; -#endif - -// ethernet mac address - must be unique on your network -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -byte Ethernet::buffer[500]; // tcp/ip send and receive buffer - -const char page[] PROGMEM = -"HTTP/1.0 503 Service Unavailable\r\n" -"Content-Type: text/html\r\n" -"Retry-After: 600\r\n" -"\r\n" -"" - "" - "Service Temporarily Unavailable" - "" - "" - "

This service is currently unavailable

" - "

" - "The main server is currently off-line.
" - "Please try again later." - "

" - "" -"" -; - -void setup(){ - Serial.begin(57600); - delay(10); - Serial.println("\n[backSoon]"); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println( "Failed to access Ethernet controller"); -#if STATIC - ether.staticSetup(myip, gwip); -#else - if (!ether.dhcpSetup()) - Serial.println("DHCP failed"); -#endif - - ether.printIp("IP: ", ether.myip); - ether.printIp("GW: ", ether.gwip); - ether.printIp("DNS: ", ether.dnsip); -} - -void loop(){ - // wait for an incoming TCP packet, but ignore its contents - if (ether.packetLoop(ether.packetReceive())) { - memcpy_P(ether.tcpOffset(), page, sizeof page); - ether.httpServerReply(sizeof page - 1); - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/etherNode/etherNode.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/etherNode/etherNode.ino deleted file mode 100644 index 050f7fb..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/etherNode/etherNode.ino +++ /dev/null @@ -1,295 +0,0 @@ -// Arduino demo sketch for testing RFM12B + ethernet -// 2010-05-20 http://opensource.org/licenses/mit-license.php - -// Listens for RF12 messages and displays valid messages on a webpage -// Memory usage exceeds 1K, so use Atmega328 or decrease history/buffers -// -// This sketch is derived from RF12eth.pde: -// May 2010, Andras Tucsni, http://opensource.org/licenses/mit-license.php -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include -#include - -#define DEBUG 1 // set to 1 to display free RAM on web page -#define SERIAL 0 // set to 1 to show incoming requests on serial port - -#define CONFIG_EEPROM_ADDR ((byte*) 0x10) - -// configuration, as stored in EEPROM -struct Config { - byte band; - byte group; - byte collect; - word refresh; - byte valid; // keep this as last byte -} config; - -// ethernet interface mac address - must be unique on your network -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -// buffer for an outgoing data packet -static byte outBuf[RF12_MAXDATA], outDest; -static char outCount = -1; - -#define NUM_MESSAGES 10 // Number of messages saved in history -#define MESSAGE_TRUNC 15 // Truncate message payload to reduce memory use - -static BufferFiller bfill; // used as cursor while filling the buffer - -static byte history_rcvd[NUM_MESSAGES][MESSAGE_TRUNC+1]; //history record -static byte history_len[NUM_MESSAGES]; // # of RF12 messages+header in history -static byte next_msg; // pointer to next rf12rcvd line -static word msgs_rcvd; // total number of lines received modulo 10,000 - -byte Ethernet::buffer[1000]; // tcp/ip send and receive buffer - -static void loadConfig() { - for (byte i = 0; i < sizeof config; ++i) - ((byte*) &config)[i] = eeprom_read_byte(CONFIG_EEPROM_ADDR + i); - if (config.valid != 253) { - config.valid = 253; - config.band = 8; - config.group = 1; - config.collect = 1; - config.refresh = 5; - } - byte freq = config.band == 4 ? RF12_433MHZ : - config.band == 8 ? RF12_868MHZ : - RF12_915MHZ; - rf12_initialize(31, freq, config.group); -} - -static void saveConfig() { - for (byte i = 0; i < sizeof config; ++i) - eeprom_write_byte(CONFIG_EEPROM_ADDR + i, ((byte*) &config)[i]); -} - -#if DEBUG -static int freeRam () { - extern int __heap_start, *__brkval; - int v; - return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); -} -#endif - -void setup(){ -#if SERIAL - Serial.begin(57600); - Serial.println("\n[etherNode]"); -#endif - loadConfig(); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println( "Failed to access Ethernet controller"); - if (!ether.dhcpSetup()) - Serial.println("DHCP failed"); -#if SERIAL - ether.printIp("IP: ", ether.myip); -#endif -} - -const char okHeader[] PROGMEM = - "HTTP/1.0 200 OK\r\n" - "Content-Type: text/html\r\n" - "Pragma: no-cache\r\n" -; - -static void homePage(BufferFiller& buf) { - word mhz = config.band == 4 ? 433 : config.band == 8 ? 868 : 915; - buf.emit_p(PSTR("$F\r\n" - "" - "RF12 etherNode - $D MHz, group $D" - "RF12 etherNode - $D MHz, group $D " - "- configure - send packet" - "

Last $D messages:

" - "
"), okHeader, config.refresh, mhz, config.group,
-                                            mhz, config.group, NUM_MESSAGES);
-    for (byte i = 0; i < NUM_MESSAGES; ++i) {
-        byte j = (next_msg + i) % NUM_MESSAGES;
-        if (history_len[j] > 0) {
-            word n = msgs_rcvd - NUM_MESSAGES + i;
-            buf.emit_p(PSTR("\n$D$D$D$D: OK"), // hack, to show leading zero's
-                                n/1000, (n/100) % 10, (n/10) % 10, n % 10);
-            for (byte k = 0; k < history_len[j]; ++k)
-                buf.emit_p(PSTR(" $D"), history_rcvd[j][k]);
-        }
-    }
-    long t = millis() / 1000;
-    word h = t / 3600;
-    byte m = (t / 60) % 60;
-    byte s = t % 60;
-    buf.emit_p(PSTR(
-        "
" - "Uptime is $D$D:$D$D:$D$D"), h/10, h%10, m/10, m%10, s/10, s%10); -#if DEBUG - buf.emit_p(PSTR(" ($D bytes free)"), freeRam()); -#endif -} - -static int getIntArg(const char* data, const char* key, int value =-1) { - char temp[10]; - if (ether.findKeyVal(data + 7, temp, sizeof temp, key) > 0) - value = atoi(temp); - return value; -} - -static void configPage(const char* data, BufferFiller& buf) { - // pick up submitted data, if present - if (data[6] == '?') { - byte b = getIntArg(data, "b"); - byte g = getIntArg(data, "g"); - byte c = getIntArg(data, "c", 0); - word r = getIntArg(data, "r"); - if (1 <= g && g <= 250 && 1 <= r && r <= 3600) { - // store values as new settings - config.band = b; - config.group = g; - config.collect = c; - config.refresh = r; - saveConfig(); - // re-init RF12 driver - loadConfig(); - // clear history - memset(history_len, 0, sizeof history_len); - // redirect to the home page - buf.emit_p(PSTR( - "HTTP/1.0 302 found\r\n" - "Location: /\r\n" - "\r\n")); - return; - } - } - // else show a configuration form - buf.emit_p(PSTR("$F\r\n" - "

Server node configuration

" - "
" - "

" - "Freq band (4, 8, or 9)
" - "Net group (1..250)
" - "Collect mode: " - "Don't send ACKs

" - "Refresh rate (1..3600 seconds)" - "

" - "" - "
"), okHeader, config.band, config.group, - config.collect ? "CHECKED" : "", - config.refresh); -} - -static void sendPage(const char* data, BufferFiller& buf) { - // pick up submitted data, if present - const char* p = strstr(data, "b="); - byte d = getIntArg(data, "d"); - if (data[6] == '?' && p != 0 && 0 <= d && d <= 31) { - // prepare to send data as soon as possible in loop() - outDest = d & RF12_HDR_MASK ? RF12_HDR_DST | d : 0; - outCount = 0; - // convert the input string to a number of decimal data bytes in outBuf - ++p; - while (*p != 0 && *p != '&') { - outBuf[outCount] = 0; - while ('0' <= *++p && *p <= '9') - outBuf[outCount] = 10 * outBuf[outCount] + (*p - '0'); - ++outCount; - } -#if SERIAL - Serial.print("Send to "); - Serial.print(outDest, DEC); - Serial.print(':'); - for (byte i = 0; i < outCount; ++i) { - Serial.print(' '); - Serial.print(outBuf[i], DEC); - } - Serial.println(); -#endif - // redirect to home page - buf.emit_p(PSTR( - "HTTP/1.0 302 found\r\n" - "Location: /\r\n" - "\r\n")); - return; - } - // else show a send form - buf.emit_p(PSTR("$F\r\n" - "

Send a wireless data packet

" - "
" - "

" - "Data bytes (decimal)
" - "Destination node " - "(1..31, or 0 to broadcast)
" - "

" - "" - "
"), okHeader); -} - -void loop(){ - word len = ether.packetReceive(); - word pos = ether.packetLoop(len); - // check if valid tcp data is received - if (pos) { - bfill = ether.tcpOffset(); - char* data = (char *) Ethernet::buffer + pos; -#if SERIAL - Serial.println(data); -#endif - // receive buf hasn't been clobbered by reply yet - if (strncmp("GET / ", data, 6) == 0) - homePage(bfill); - else if (strncmp("GET /c", data, 6) == 0) - configPage(data, bfill); - else if (strncmp("GET /s", data, 6) == 0) - sendPage(data, bfill); - else - bfill.emit_p(PSTR( - "HTTP/1.0 401 Unauthorized\r\n" - "Content-Type: text/html\r\n" - "\r\n" - "

401 Unauthorized

")); - ether.httpServerReply(bfill.position()); // send web page data - } - - // RFM12 loop runner, don't report acks - if (rf12_recvDone() && rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0) { - history_rcvd[next_msg][0] = rf12_hdr; - for (byte i = 0; i < rf12_len; ++i) - if (i < MESSAGE_TRUNC) - history_rcvd[next_msg][i+1] = rf12_data[i]; - history_len[next_msg] = rf12_len < MESSAGE_TRUNC ? rf12_len+1 - : MESSAGE_TRUNC+1; - next_msg = (next_msg + 1) % NUM_MESSAGES; - msgs_rcvd = (msgs_rcvd + 1) % 10000; - - if (RF12_WANTS_ACK && !config.collect) { -#if SERIAL - Serial.println(" -> ack"); -#endif - rf12_sendStart(RF12_ACK_REPLY, 0, 0); - } - } - - // send a data packet out if requested - if (outCount >= 0 && rf12_canSend()) { - rf12_sendStart(outDest, outBuf, outCount, 1); - outCount = -1; - } -} diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getDHCPandDNS/getDHCPandDNS.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getDHCPandDNS/getDHCPandDNS.ino deleted file mode 100644 index 117922e..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getDHCPandDNS/getDHCPandDNS.ino +++ /dev/null @@ -1,75 +0,0 @@ -// This demo does web requests via DHCP and DNS lookup. -// 2011-07-05 http://opensource.org/licenses/mit-license.php -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -#define REQUEST_RATE 5000 // milliseconds - -// ethernet interface mac address -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; -// remote website name -const char website[] PROGMEM = "google.com"; - -byte Ethernet::buffer[700]; -static long timer; - -// called when the client request is complete -static void my_result_cb (uint8_t status, uint16_t off, uint16_t len) { - Serial.print("<<< reply "); - Serial.print(millis() - timer); - Serial.println(" ms"); - Serial.println((const char*) Ethernet::buffer + off); -} - -void setup () { - Serial.begin(57600); - Serial.println("\n[getDHCPandDNS]"); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println( "Failed to access Ethernet controller"); - - if (!ether.dhcpSetup()) - Serial.println("DHCP failed"); - - ether.printIp("My IP: ", ether.myip); - // ether.printIp("Netmask: ", ether.mymask); - ether.printIp("GW IP: ", ether.gwip); - ether.printIp("DNS IP: ", ether.dnsip); - - if (!ether.dnsLookup(website)) - Serial.println("DNS failed"); - ether.printIp("Server: ", ether.hisip); - - timer = - REQUEST_RATE; // start timing out right away -} - -void loop () { - - ether.packetLoop(ether.packetReceive()); - - if (millis() > timer + REQUEST_RATE) { - timer = millis(); - Serial.println("\n>>> REQ"); - ether.browseUrl(PSTR("/foo/"), "bar", website, my_result_cb); - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getStaticIP/getStaticIP.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getStaticIP/getStaticIP.ino deleted file mode 100644 index 2564e54..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getStaticIP/getStaticIP.ino +++ /dev/null @@ -1,76 +0,0 @@ -// This demo does web requests via DNS lookup, using a fixed gateway. -// 2010-11-27 http://opensource.org/licenses/mit-license.php -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -#define REQUEST_RATE 5000 // milliseconds - -// ethernet interface mac address -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; -// ethernet interface ip address -static byte myip[] = { 192,168,1,203 }; -// gateway ip address -static byte gwip[] = { 192,168,1,1 }; -// domain name server (dns) address -static byte dnsip[] = { 192,168,1,1 }; -// remote website name -const char website[] PROGMEM = "google.com"; - -byte Ethernet::buffer[300]; // a very small tcp/ip buffer is enough here -static long timer; - -// called when the client request is complete -static void my_result_cb (byte status, uint16_t off, uint16_t len) { - Serial.print("<<< reply "); - Serial.print(millis() - timer); - Serial.println(" ms"); - Serial.println((const char*) Ethernet::buffer + off); -} - -void setup () { - Serial.begin(57600); - Serial.println("\n[getViaDNS]"); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println( "Failed to access Ethernet controller"); - - ether.staticSetup(myip, gwip); - - ether.copyIp(ether.dnsip, dnsip); - - if (!ether.dnsLookup(website)) - Serial.println("DNS failed"); - ether.printIp("Server: ", ether.hisip); - - timer = - REQUEST_RATE; // start timing out right away -} - -void loop () { - ether.packetLoop(ether.packetReceive()); - - if (millis() > timer + REQUEST_RATE) { - timer = millis(); - Serial.println("\n>>> REQ"); - ether.browseUrl(PSTR("/foo/"), "bar", website, my_result_cb); - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getViaDNS/getViaDNS.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getViaDNS/getViaDNS.ino deleted file mode 100644 index e67a854..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/getViaDNS/getViaDNS.ino +++ /dev/null @@ -1,72 +0,0 @@ -// This demo does web requests via DNS lookup, using a fixed gateway. -// 2010-11-27 http://opensource.org/licenses/mit-license.php -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -#define REQUEST_RATE 5000 // milliseconds - -// ethernet interface mac address -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; -// ethernet interface ip address -static byte myip[] = { 192,168,1,203 }; -// gateway ip address -static byte gwip[] = { 192,168,1,1 }; -// remote website name -const char website[] PROGMEM = "google.com"; - -byte Ethernet::buffer[300]; // a very small tcp/ip buffer is enough here -static long timer; - -// called when the client request is complete -static void my_result_cb (byte status, uint16_t off, uint16_t len) { - Serial.print("<<< reply "); - Serial.print(millis() - timer); - Serial.println(" ms"); - Serial.println((const char*) Ethernet::buffer + off); -} - -void setup () { - Serial.begin(57600); - Serial.println("\n[getViaDNS]"); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println( "Failed to access Ethernet controller"); - - ether.staticSetup(myip, gwip); - - if (!ether.dnsLookup(website)) - Serial.println("DNS failed"); - ether.printIp("Server: ", ether.hisip); - - timer = - REQUEST_RATE; // start timing out right away -} - -void loop () { - ether.packetLoop(ether.packetReceive()); - - if (millis() > timer + REQUEST_RATE) { - timer = millis(); - Serial.println("\n>>> REQ"); - ether.browseUrl(PSTR("/foo/"), "bar", website, my_result_cb); - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/multipacket/multipacket.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/multipacket/multipacket.ino deleted file mode 100644 index 85d506f..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/multipacket/multipacket.ino +++ /dev/null @@ -1,99 +0,0 @@ -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -#define TCP_FLAGS_FIN_V 1 //as declared in net.h -#define TCP_FLAGS_ACK_V 0x10 //as declared in net.h -static byte myip[] = { 192,168,1,203 }; -static byte gwip[] = { 192,168,1,1 }; -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x39 }; -byte Ethernet::buffer[900]; // tcp ip send and receive buffer -const char pageA[] PROGMEM = -"HTTP/1.0 200 OK\r\n" -"Content-Type: text/html\r\n" -"\r\n" -"" - "" - "multipackets Test" - "" - "" - "Start here
" - "

packet 1

" - "

" - "the first packet send " - "

" -; -const char pageB[] PROGMEM = - "

packet 2

" - "

" - "if you read this it mean it works" - "

" -; -const char pageC[] PROGMEM = - "

packet 3

" - "

" - "if you read this it mean it works" - "

" -; -const char pageD[] PROGMEM = - "

packet 4

" - "

" - "if you read this it mean it works" - "

" -; -const char pageE[] PROGMEM = - "

packet 5

" - "

" - "this is the last packet" - "

" -; - - -void setup(){ - ether.begin(sizeof Ethernet::buffer, mymac);// 53 for the mega ethernet shield and 10 for normal ethernet shield - ether.staticSetup(myip, gwip); -} -void loop(){ - word pos = ether.packetLoop(ether.packetReceive()); - // check if valid tcp data is received - if (pos) { - char* data = (char *) Ethernet::buffer + pos; - if (strncmp("GET / ", data, 6) == 0) { - ether.httpServerReplyAck(); // send ack to the request - memcpy_P(ether.tcpOffset(), pageA, sizeof pageA); // send first packet and not send the terminate flag - ether.httpServerReply_with_flags(sizeof pageA - 1,TCP_FLAGS_ACK_V); - memcpy_P(ether.tcpOffset(), pageB, sizeof pageB); // send second packet and not send the terminate flag - ether.httpServerReply_with_flags(sizeof pageB - 1,TCP_FLAGS_ACK_V); - memcpy_P(ether.tcpOffset(), pageC, sizeof pageC); // send thirdt packet and not send the terminate flag - ether.httpServerReply_with_flags(sizeof pageC - 1,TCP_FLAGS_ACK_V); - memcpy_P(ether.tcpOffset(), pageD, sizeof pageD); // send fourth packet and not send the terminate flag - ether.httpServerReply_with_flags(sizeof pageD - 1,TCP_FLAGS_ACK_V); - memcpy_P(ether.tcpOffset(), pageE, sizeof pageE); // send fiveth packet and send the terminate flag - ether.httpServerReply_with_flags(sizeof pageE - 1,TCP_FLAGS_ACK_V|TCP_FLAGS_FIN_V); } - else - { - ether.httpServerReplyAck(); // send ack to the request - memcpy_P(ether.tcpOffset(), pageA, sizeof pageA);//only the first part will sended - ether.httpServerReply_with_flags(sizeof pageA - 1,TCP_FLAGS_ACK_V|TCP_FLAGS_FIN_V); - } - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/multipacketSD/multipacketSD.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/multipacketSD/multipacketSD.ino deleted file mode 100644 index 8822084..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/multipacketSD/multipacketSD.ino +++ /dev/null @@ -1,129 +0,0 @@ -// works only with tinyfat library -// with SD library packets lost will occurs -// don't know why ! -// tested with arduino mega 1280 and uno -// send 240 Megabyte file without packet loss -// at 100 kbyte/s -// tinyfat read a block of 512 bytes on SD card , -// so the buffer must be 512 + 60 bytes -// on the arduino mega with bigger buffer you can adjust -// if (cur>=512) { // 512 to 1024 with 1100 bytes buffer - -#include -#include -#include -#define TCP_FLAGS_FIN_V 1 //as declared in net.h -#define TCP_FLAGS_ACK_V 16 //as declared in net.h -static byte myip[] = { 192,168,0,66 }; -static byte gwip[] = { 192,168,0,250 }; -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x39 }; -byte Ethernet::buffer[700]; // tcp/ip send and receive buffer -unsigned long cur; -unsigned long pos; -byte res; - -void setup() { - // Initialize serial communication at 115200 baud - Serial.begin(115200); - // Initialize tinyFAT - // You might need to select a lower speed than the default SPISPEED_HIGH - file.setSSpin(4); - res=file.initFAT(0); - if (res==NO_ERROR) Serial.println("SD started"); - ether.begin(sizeof Ethernet::buffer, mymac , 10); //53 on mega ethernet shield 10 on others - ether.staticSetup(myip, gwip); - Serial.println("ETH started"); -} - -void loop() -{ - wait: - pos = ether.packetLoop(ether.packetReceive());// check if valid tcp data is received - if (pos) { - char* data = (char *) Ethernet::buffer + pos; - cur=0; - if (strncmp("GET / ", data, 6) == 0) {// nothing specified - sendfiles("index.htm"); - goto wait; - } - if (strncmp("GET /", data, 5) == 0) { // serve anything on sd card - int i =0; - char temp[15]=""; // here will be the name of requested file - while (data[i+5]!=32) {temp[i]=data[i+5];i++;}//search the end - sendfiles((char*) temp); - goto wait; - } - not_found(); - - } - -} - -void not_found() { //content not found - cur=0; - streamfile ("404.hea",TCP_FLAGS_FIN_V); - // Serial.println("not found"); -} - -byte streamfile (char* name , byte lastflag) { //send a file to the buffer - if (!file.exists(name)) {return 0;} - res=file.openFile(name, FILEMODE_BINARY); - int car=512; - while (car==512) { - car=file.readBinary(); - for(int i=0;i=512) { - ether.httpServerReply_with_flags(cur,TCP_FLAGS_ACK_V); - cur=0; - } else { - - if (lastflag==TCP_FLAGS_FIN_V) { - ether.httpServerReply_with_flags(cur,TCP_FLAGS_ACK_V+TCP_FLAGS_FIN_V); - } - } -} - file.closeFile(); - return 1; -} - -byte sendfiles(char* name) { // function to find the correct header and send a file - ether.httpServerReplyAck(); - int i =0; - char dtype[13]=""; - while (name[i]!=0) { - i++; - }//search the end - int b=i-1; - while ((name[b]!=46)&&(b>0)) { - b--; - }//search the point - int a=b+1; - while (a -#include - -#define BUF_SIZE 512 - -byte mac[] = { 0x00, 0x04, 0xA3, 0x21, 0xCA, 0x38 }; // Nanode MAC address. - -uint8_t ip[] = { 192, 168, 1, 203 }; // The fallback board address. -uint8_t dns[] = { 192, 168, 1, 1 }; // The DNS server address. -uint8_t gateway[] = { 192, 168, 1, 1 }; // The gateway router address. -uint8_t subnet[] = { 255, 255, 255, 0 }; // The subnet mask. -byte Ethernet::buffer[BUF_SIZE]; -byte fixed; // Address fixed, no DHCP - -void setup(void) -{ - Serial.begin(57600); - delay(2000); - - /* Check that the Ethernet controller exists */ - Serial.println("Initialising the Ethernet controller"); - if (ether.begin(sizeof Ethernet::buffer, mac) == 0) { - Serial.println( "Ethernet controller NOT initialized"); - while (true) - /* MT */ ; - } - - /* Get a DHCP connection */ - Serial.println("Attempting to get an IP address using DHCP"); - fixed = false; - if (ether.dhcpSetup()) { - ether.printIp("Got an IP address using DHCP: ", ether.myip); - } - /* If DHCP fails, start with a hard-coded address */ - else { - ether.staticSetup(ip, gateway, dns); - ether.printIp("DHCP FAILED, using fixed address: ", ether.myip); - fixed = true; - } - - return; -} - -void loop(void) -{ - word rc; - - /* These function calls are required if ICMP packets are to be accepted */ - rc = ether.packetLoop(ether.packetReceive()); - Serial.print("ether.packetLoop() returned "); - Serial.println(rc, DEC); - - // For debugging - delay(5000); - - return; -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/noipClient/noipClient.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/noipClient/noipClient.ino deleted file mode 100644 index 01454fc..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/noipClient/noipClient.ino +++ /dev/null @@ -1,293 +0,0 @@ -// NoIP client sketch for ENC28J60 based Ethernet Shield. -// You need a free account from www.no-ip.com -// -// 1. On NoIP website, create a host of type DNS Host (A) -// 2. Insert your host name in noIP_host[] variable -// 3. Encode "username:password" in base64 using an online tool like -// 4. Paste the encoded string in noIP_auth[] variable -// -// Contributed by Luca Dentella -// http://www.lucadentella.it/2012/04/28/enc28j60-e-arduino-6/ -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - - -#include -#include - -// Finite-State Machine states -#define STATUS_IDLE 0 -#define STATUS_WAITING_FOR_PUBLIC_IP 1 -#define STATUS_NOIP_NEEDS_UPDATE 2 -#define STATUS_WAITING_FOR_NOIP 3 -#define STATUS_ERROR 99 - -// The sketch will check your public IP every CHECK_IP_INTERVAL ms, -// and wait for REQUEST_TIMEOUT ms for a response. -// It will retry for maximum of MAX_ATTEMPTS attemps. -#define CHECK_IP_INTERVAL 60000 -#define REQUEST_TIMEOUT 10000 -#define MAX_ATTEMPTS 3 - -// MAC Address of Ethernet Shield -static byte mymac[] = {0x74,0x69,0x69,0x2D,0x30,0x31}; - -// Insert your hostname and authentication string -const char noIP_host[] PROGMEM = ""; //e.g. myname.no-ip.info -const char noIP_auth[] PROGMEM = ""; - -//---------------------------------------------------------- -// Don't change these ones... -const char getIP_web[] PROGMEM = "www.lucadentella.it"; -const char noIP_web[] PROGMEM = "dynupdate.no-ip.com"; -//---------------------------------------------------------- - -// Some global variables -byte Ethernet::buffer[700]; -byte getIP_address[4]; -byte noIP_address[4]; -byte actual_status; -static byte session_id; -static uint32_t check_ip_timer; -static uint32_t request_timer; -int attempt; -Stash stash; - -void setup () { - - Serial.begin(57600); - Serial.println(F("NoIP Client Demo")); - Serial.println(); - - if (!ether.begin(sizeof Ethernet::buffer, mymac)) - Serial.println(F( "Failed to access Ethernet controller")); - else - Serial.println(F("Ethernet controller initialized")); - Serial.println(); - - if (!ether.dhcpSetup()) - Serial.println(F("Failed to get configuration from DHCP")); - else - Serial.println(F("DHCP configuration done")); - - ether.printIp("IP Address:\t", ether.myip); - ether.printIp("Netmask:\t", ether.netmask); - ether.printIp("Gateway:\t", ether.gwip); - Serial.println(); - - actual_status = STATUS_IDLE; - attempt = 0; - - // Resolve IP for getIP_web and noIP_web - // and store them into global variables - if (!ether.dnsLookup(getIP_web)) { - Serial.print(F("Unable to resolve IP for ")); - SerialPrint_P(getIP_web); - actual_status = STATUS_ERROR; - } else { - ether.copyIp(getIP_address, ether.hisip); - SerialPrint_P(getIP_web); - ether.printIp(" resolved to:\t", ether.hisip); - } - if (!ether.dnsLookup(noIP_web)) { - Serial.print(F("Unable to resolve IP for ")); - SerialPrint_P(noIP_web); - actual_status = STATUS_ERROR; - } else { - ether.copyIp(noIP_address, ether.hisip); - SerialPrint_P(noIP_web); - ether.printIp(" resolved to:\t", ether.hisip); - } - - Serial.println(); -} - - -void loop() { - - ether.packetLoop(ether.packetReceive()); - - // FSM - switch(actual_status) { - - case STATUS_IDLE: checkPublicIP(); break; - case STATUS_WAITING_FOR_PUBLIC_IP: checkPublicIPResponse(); break; - case STATUS_NOIP_NEEDS_UPDATE: updateNoIP(); break; - case STATUS_WAITING_FOR_NOIP: checkNoIPResponse(); break; - } -} - -void checkPublicIP() { - - if(millis() > check_ip_timer) { - - Serial.print(F("Checking public IP... ")); - - // Create a request for GetIP service, - // set destination IP and send request saving session_id - Stash::prepare(PSTR("GET /demo/getip.php HTTP/1.1" "\r\n" "Host: $F" "\r\n" "\r\n"), getIP_web); - ether.copyIp(ether.hisip, getIP_address); - session_id = ether.tcpSend(); - - // Change FSM state, prepare for timeout and increment attempts counter - actual_status = STATUS_WAITING_FOR_PUBLIC_IP; - request_timer = millis() + REQUEST_TIMEOUT; - attempt++; - } -} - -void checkPublicIPResponse() { - - String actualIp, dnsIp; - - const char* reply = ether.tcpReply(session_id); - - // We got a valid response - if(reply != 0) { - - // Parse response for public IP - for(int i = 0; i < strlen(reply) - 189; i++) actualIp = actualIp + reply[187 + i]; - Serial.println(actualIp); - - // If we can't resolve actual IP for our hostname on NoIP, - // return to IDLE state and wait for the next interval - if(!ether.dnsLookup(noIP_host)) { - Serial.print(F("Unable to resolve actual IP for ")); - SerialPrint_P(noIP_host); - Serial.println(); - actual_status = STATUS_IDLE; - attempt = 0; - check_ip_timer = millis() + CHECK_IP_INTERVAL; - - // If we can resolve the IP for our hostname, save it in xxx.xxx.xxx.xxx form - // and compare it with our public IP - } else { - for(int i = 0; i < 4; i++) { - dnsIp = dnsIp + String(ether.hisip[i]); - if(i < 3) dnsIp = dnsIp + "."; - } - SerialPrint_P(noIP_host); - Serial.print(F(" resolved to ")); - Serial.println(dnsIp); - - // If they are the same, we can sit down and wait for the next interval - if(actualIp.compareTo(dnsIp) == 0) { - Serial.println(F("No update needed :)")); - actual_status = STATUS_IDLE; - attempt = 0; - check_ip_timer = millis() + CHECK_IP_INTERVAL; - - // Different? We'd better to update NoIP! - } else { - Serial.println(F("Update needed :(")); - actual_status = STATUS_NOIP_NEEDS_UPDATE; - attempt = 0; - } - } - - // No valid response? Check for timeout - // If we've already sent a max number of requests, return to IDLE state - // and wait for the next interval - } else { - if(millis() > request_timer) { - Serial.println(F(" no response :(")); - actual_status = STATUS_IDLE; - if(attempt == MAX_ATTEMPTS) { - Serial.println(F("Max number of attempts reached")); - attempt = 0; - check_ip_timer = millis() + CHECK_IP_INTERVAL; - } - } - } -} - -void updateNoIP() { - - Serial.print(F("Updating NoIP...")); - - // Create a request for updating NoIP using NoIP API, - // set destination IP and send request saving session_id - Stash::prepare(PSTR("GET /nic/update?hostname=$F HTTP/1.0" "\r\n" - "Host: $F" "\r\n" - "Authorization: Basic $F" "\r\n" - "User-Agent: NoIP_Client" "\r\n" "\r\n"), - noIP_host, noIP_web, noIP_auth); - ether.copyIp(ether.hisip, noIP_address); - session_id = ether.tcpSend(); - - // Wait for response or timeout... - actual_status = STATUS_WAITING_FOR_NOIP; - request_timer = millis() + REQUEST_TIMEOUT; - attempt++; -} - -void checkNoIPResponse() { - - const char* reply = ether.tcpReply(session_id); - boolean done; - - // We got a valid response... - if(reply != 0) { - - // Parse NoIP response looking for status/error codes... - if(strstr(reply, "good") != 0) { - Serial.println(F(" done!")); - done = true; - } - else if(strstr(reply, "nochg") != 0) { - Serial.println(F(" no change required!")); - done = true; - } - else if(strstr(reply, "nohost") != 0) Serial.println(F(" host not found :(")); - else if(strstr(reply, "badauth") != 0) Serial.println(F(" invalid username or password :(")); - else if(strstr(reply, "badagent") != 0) Serial.println(F(" agent banned :(")); - else if(strstr(reply, "!donator") != 0) Serial.println(F(" feature not available for specified username :(")); - else if(strstr(reply, "abuse") != 0) Serial.println(F(" username blocked due to abuse :(")); - else Serial.println(F(" generic error :(")); - - // Record has been updated? Ok wait for next interval... - if(done) { - actual_status = STATUS_IDLE; - attempt = 0; - check_ip_timer = millis() + CHECK_IP_INTERVAL; - } - - // No valid response? Check for timeout - // If we've already sent a max number of requests, return to IDLE state - // and wait for the next interval - } else { - - if(millis() > request_timer) { - Serial.println(F("No response from NoIP")); - if(attempt == MAX_ATTEMPTS) { - Serial.println(F("Max number of attempts reached")); - actual_status = STATUS_IDLE; - attempt = 0; - check_ip_timer = millis() + CHECK_IP_INTERVAL; - } - else - actual_status = STATUS_NOIP_NEEDS_UPDATE; - } - } -} - -void SerialPrint_P(PGM_P str) { - for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.write(c); -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/pings/pings.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/pings/pings.ino deleted file mode 100644 index 834b9a0..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/pings/pings.ino +++ /dev/null @@ -1,96 +0,0 @@ -// Ping a remote server, also uses DHCP and DNS. -// 2011-06-12 http://opensource.org/licenses/mit-license.php -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -// ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -byte Ethernet::buffer[700]; - -static uint32_t timer; -static byte myip[] = { 192,168,1,203 }; - -// gateway ip address -static byte gwip[] = { 192,168,1,1 }; - -// domain name server (dns) address -static byte dnsip[] = { 192,168,1,1 }; - -// called when a ping comes in (replies to it are automatic) -static void gotPinged (byte* ptr) { - ether.printIp(">>> ping from: ", ptr); -} - -void setup () { - Serial.begin(57600); - delay(10); - Serial.println("\n[pings]"); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println(("Failed to access Ethernet controller")); - - - if (!ether.dhcpSetup()){//If DHCP fails set the static IP, Gateway and DNS IP. - Serial.println(F("DHCP failed")); - ether.staticSetup(myip, gwip); - ether.copyIp(ether.dnsip, dnsip); - } - - ether.printIp("IP: ", ether.myip); - ether.printIp("GW: ", ether.gwip); - - -//#if 1 - // use DNS to locate the IP address we want to ping - if (!ether.dnsLookup(PSTR("www.google.com"))) - Serial.println("DNS failed"); -//#else - //ether.parseIp(ether.hisip, "173.194.112.119"); -//#endif - ether.printIp("SRV: ", ether.hisip); - - // call this to report others pinging us - ether.registerPingCallback(gotPinged); - - timer = -9999999; // start timing out right away - Serial.println(); -} - -void loop () { - word len = ether.packetReceive(); // go receive new packets - word pos = ether.packetLoop(len); // respond to incoming pings - - // report whenever a reply to our outgoing ping comes back - if (len > 0 && ether.packetLoopIcmpCheckReply(ether.hisip)) { - Serial.print(" "); - Serial.print((micros() - timer) * 0.001, 3); - Serial.println(" ms"); - } - - // ping a remote server once every few seconds - if (micros() - timer >= 5000000) { - ether.printIp("Pinging: ", ether.hisip); - timer = micros(); - ether.clientIcmpRequest(ether.hisip); - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/rbbb_server/rbbb_server.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/rbbb_server/rbbb_server.ino deleted file mode 100644 index 5a21c05..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/rbbb_server/rbbb_server.ino +++ /dev/null @@ -1,72 +0,0 @@ -// This is a demo of the RBBB running as webserver with the Ether Card -// 2010-05-28 http://opensource.org/licenses/mit-license.php -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -// ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; -static byte myip[] = { 192,168,1,203 }; - -byte Ethernet::buffer[500]; -BufferFiller bfill; - -void setup () { - Serial.begin(57600); - delay(10); - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println(F("Failed to access Ethernet controller")); - ether.staticSetup(myip); - - //if (!ether.dhcpSetup()) - // Serial.println("DHCP failed"); - - ether.printIp("IP: ", ether.myip); - ether.printIp("GW: ", ether.gwip); - ether.printIp("DNS: ", ether.dnsip); -} - -static word homePage() { - long t = millis() / 1000; - word h = t / 3600; - byte m = (t / 60) % 60; - byte s = t % 60; - bfill = ether.tcpOffset(); - bfill.emit_p(PSTR( - "HTTP/1.0 200 OK\r\n" - "Content-Type: text/html\r\n" - "Pragma: no-cache\r\n" - "\r\n" - "" - "RBBB server" - "

$D$D:$D$D:$D$D

"), - h/10, h%10, m/10, m%10, s/10, s%10); - return bfill.position(); -} - -void loop () { - - if (ether.packetLoop(ether.packetReceive())){ // check if valid tcp data is received - ether.httpServerReply(homePage()); // send web page data - - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/stashTest/stashTest.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/stashTest/stashTest.ino deleted file mode 100644 index 13344c1..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/stashTest/stashTest.ino +++ /dev/null @@ -1,119 +0,0 @@ -// Test the offloaded RAM stash mechanism. -// 2011-07-10 http://opensource.org/licenses/mit-license.php - -#include -#include - -// ethernet interface mac address, must be unique on the LAN -byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -byte Ethernet::buffer[700]; - -void dumpBlock (const char* msg, byte idx) { - Serial.print(msg); - Serial.print(" ["); - Serial.print(idx, DEC); - Serial.print("] @ "); - Serial.print(Stash::bufs[idx].bnum, DEC); - Serial.print(" free "); - Serial.print(Stash::freeCount(), DEC); - for (byte i = 0; i < 64; ++i) { - if (i % 16 == 0) - Serial.println(); - Serial.print(' '); - Serial.print(Stash::bufs[idx].bytes[i], DEC); - } - Serial.println(); -} - -void dumpStash (const char* msg, void* ptr) { - Stash& buf = *(Stash*) ptr; - Serial.print(msg); - Serial.print(" c"); - Serial.print(buf.count, DEC); - Serial.print(" f"); - Serial.print(buf.first, DEC); - Serial.print(" l"); - Serial.print(buf.last, DEC); - Serial.print(" u"); - Serial.print(buf.curr, DEC); - Serial.print(" o"); - Serial.print(buf.offs, DEC); - Serial.print(" #"); - Serial.println(buf.size()); -} - -void setup () { - Serial.begin(57600); - delay(1); - Serial.println("\n[stashTest]"); - ether.begin(sizeof Ethernet::buffer, mymac); - -#if 1 - Stash buf; - dumpStash("> AAA", &buf); - byte fd = buf.create(); - Serial.print("fd "); - Serial.println(fd, DEC); - dumpStash("> BBB", &buf); - dumpBlock("EMPTY", 0); - for (char c = 'a'; c <= 'z'; ++c) - buf.put(c); - for (char c = 'A'; c <= 'Z'; ++c) - buf.put(c); - dumpBlock("LETTERS", 0); - dumpStash("> CCC", &buf); - for (char c = '0'; c <= '9'; ++c) - buf.put(c); - dumpBlock("DIGITS", 0); - dumpStash("> DDD", &buf); - buf.print(" x = "); - buf.println(123.45); - dumpBlock("PRINT", 0); - dumpStash("> EEE", &buf); - buf.load(1, 1); - dumpBlock("FIRST", 1); - buf.save(); - buf.load(1, 1); - dumpBlock("FLUSHED", 1); - dumpStash("> FFF", &buf); - for (;;) { - char c = buf.get(); - if (c == 0) - break; - Serial.print(c); - } - Serial.println(); - dumpStash("> GGG", &buf); -#endif - - Stash buf2; - byte fd2 = buf2.create(); - buf2.print(""); - buf2.save(); - buf2.load(1, fd2); - dumpBlock("SECOND", 1); - dumpStash("> HHH", &buf2); - - Stash::prepare(PSTR("a $S b $F c $D d $H e"), - "123", PSTR("4567"), -12345, fd2); - dumpBlock("BUFFER", 0); - Serial.println(Stash::length()); - for (word i = 0, n = Stash::length(); i < n; ++i) { - char c; - Stash::extract(i, 1, &c); - Serial.print(c); - } - Serial.println(); - Stash::cleanup(); -#if 1 - buf.release(); -#endif - Serial.print("free "); - Serial.println(Stash::freeCount(), DEC); - Serial.println("DONE"); -} - -void loop () { - // ether.packetLoop(ether.packetReceive()); -} diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/testDHCP/testDHCP.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/testDHCP/testDHCP.ino deleted file mode 100644 index 1066982..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/testDHCP/testDHCP.ino +++ /dev/null @@ -1,60 +0,0 @@ -// Arduino demo sketch for testing the DHCP client code -// -// Original author: Andrew Lindsay -// Major rewrite and API overhaul by jcw, 2011-06-07 -// -// Copyright: GPL V2 -// See http://www.gnu.org/licenses/gpl.html -// -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -byte Ethernet::buffer[700]; - -void setup () { - Serial.begin(57600); - Serial.println(F("\n[testDHCP]")); - - Serial.print("MAC: "); - for (byte i = 0; i < 6; ++i) { - Serial.print(mymac[i], HEX); - if (i < 5) - Serial.print(':'); - } - Serial.println(); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println(F("Failed to access Ethernet controller")); - - Serial.println(F("Setting up DHCP")); - if (!ether.dhcpSetup()) - Serial.println(F("DHCP failed")); - - ether.printIp("My IP: ", ether.myip); - ether.printIp("Netmask: ", ether.netmask); - ether.printIp("GW IP: ", ether.gwip); - ether.printIp("DNS IP: ", ether.dnsip); -} - -void loop () {} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/twitter/twitter.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/twitter/twitter.ino deleted file mode 100644 index 5520678..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/twitter/twitter.ino +++ /dev/null @@ -1,85 +0,0 @@ -// Twitter client sketch for ENC28J60 based Ethernet Shield. Uses -// arduino-tweet.appspot.com as a OAuth gateway. -// Step by step instructions: -// -// 1. Get a oauth token: -// http://arduino-tweet.appspot.com/oauth/twitter/login -// 2. Put the token value in the TOKEN define below -// 3. Run the sketch! -// -// WARNING: Don't send more than 1 tweet per minute! -// NOTE: Twitter rejects tweets with identical content as dupes (returns 403) - -#include -#include - -// OAUTH key from http://arduino-tweet.appspot.com/ -#define TOKEN "Insert-your-token-here" - -// ethernet interface mac address, must be unique on the LAN -byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -const char website[] PROGMEM = "arduino-tweet.appspot.com"; - -static byte session; - -byte Ethernet::buffer[700]; -Stash stash; - -static void sendToTwitter () { - Serial.println("Sending tweet..."); - byte sd = stash.create(); - - const char tweet[] = "@solarkennedy the test Twitter sketch works!"; - stash.print("token="); - stash.print(TOKEN); - stash.print("&status="); - stash.println(tweet); - stash.save(); - int stash_size = stash.size(); - - // Compose the http POST request, taking the headers below and appending - // previously created stash in the sd holder. - Stash::prepare(PSTR("POST http://$F/update HTTP/1.0" "\r\n" - "Host: $F" "\r\n" - "Content-Length: $D" "\r\n" - "\r\n" - "$H"), - website, website, stash_size, sd); - - // send the packet - this also releases all stash buffers once done - // Save the session ID so we can watch for it in the main loop. - session = ether.tcpSend(); -} - -void setup () { - Serial.begin(57600); - Serial.println("\n[Twitter Client]"); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println(F("Failed to access Ethernet controller")); - if (!ether.dhcpSetup()) - Serial.println(F("DHCP failed")); - - ether.printIp("IP: ", ether.myip); - ether.printIp("GW: ", ether.gwip); - ether.printIp("DNS: ", ether.dnsip); - - if (!ether.dnsLookup(website)) - Serial.println(F("DNS failed")); - - ether.printIp("SRV: ", ether.hisip); - - sendToTwitter(); -} - -void loop () { - ether.packetLoop(ether.packetReceive()); - - const char* reply = ether.tcpReply(session); - if (reply != 0) { - Serial.println("Got a response!"); - Serial.println(reply); - } -} - diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/Java_ClientAndServer/UDPClient.java b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/Java_ClientAndServer/UDPClient.java deleted file mode 100644 index 0439c3e..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/Java_ClientAndServer/UDPClient.java +++ /dev/null @@ -1,29 +0,0 @@ -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; -import java.net.UnknownHostException; - -public class UDPClient { - - public static void main(String[] args) throws UnknownHostException { - DatagramSocket s; - byte[] sendBuffer = new byte[1024]; - DatagramPacket sendPacket; - final InetAddress ADDRESS = InetAddress.getByName("localhost"); - final int PORT = 1234; - try { - s = new DatagramSocket(); - System.out.println("Odesilam data na server..."); - - sendBuffer = "abc123".getBytes(); - sendPacket = new DatagramPacket(sendBuffer, sendBuffer.length, - ADDRESS, PORT); - s.send(sendPacket); - - } catch (IOException e) { - e.printStackTrace(); - } - } - -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/Java_ClientAndServer/UDPserver.java b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/Java_ClientAndServer/UDPserver.java deleted file mode 100644 index b7cda60..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/Java_ClientAndServer/UDPserver.java +++ /dev/null @@ -1,39 +0,0 @@ -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class UDPserver { - public static void main(String[] args) { - UDPserver server = new UDPserver(1234); - server.start(); - } - private int port; - private DatagramSocket s; - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - public UDPserver(int port) { - this.port = port; - } - - public void start() { - System.out.println("SERVER: Waiting for incomming connections..."); - System.out.println("DATE TIME IP:PORT received_data"); - try { - s = new DatagramSocket(this.port); - while (true) { - byte[] data = new byte[1412]; - DatagramPacket p = new DatagramPacket(data, - data.length); - s.receive(p); - System.out.print(sdf.format(new Date()).toString() + " "); - System.out.print(p.getSocketAddress() + " "); - System.out.println(new String(p.getData())); - } - } catch (IOException e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/udpClientSendOnly.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/udpClientSendOnly.ino deleted file mode 100644 index da77a35..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpClientSendOnly/udpClientSendOnly.ino +++ /dev/null @@ -1,40 +0,0 @@ - -#include -#include - -static byte mymac[] = { 0x1A,0x2B,0x3C,0x4D,0x5E,0x6F }; -byte Ethernet::buffer[700]; -static uint32_t timer; - -char website[] PROGMEM = "server.example.net"; -const int dstPort PROGMEM = 1234; - -const int srcPort PROGMEM = 4321; - -void setup () { - Serial.begin(9600); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println( "Failed to access Ethernet controller"); - if (!ether.dhcpSetup()) - Serial.println("DHCP failed"); - - ether.printIp("IP: ", ether.myip); - ether.printIp("GW: ", ether.gwip); - ether.printIp("DNS: ", ether.dnsip); - - if (!ether.dnsLookup(website)) - Serial.println("DNS failed"); - - ether.printIp("SRV: ", ether.hisip); -} - -char textToSend[] = "test 123"; - -void loop () { - if (millis() > timer) { - timer = millis() + 5000; - //static void sendUdp (char *data,uint8_t len,uint16_t sport, uint8_t *dip, uint16_t dport); - ether.sendUdp(textToSend, sizeof(textToSend), srcPort, ether.hisip, dstPort ); - } -} diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpListener/udpListener.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpListener/udpListener.ino deleted file mode 100644 index 7f9806c..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/udpListener/udpListener.ino +++ /dev/null @@ -1,101 +0,0 @@ -// Demonstrates usage of the new udpServer feature. -//You can register the same function to multiple ports, and multiple functions to the same port. -// -// 2013-4-7 Brian Lee - - -//************************************************************* -// -// IT DOESN'T WORK ON STM32 YET (IS NOT PORTED YET). -// -//************************************************************* -#include -#include - -#define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below) - -#if STATIC -// ethernet interface ip address -static byte myip[] = { 192,168,0,200 }; -// gateway ip address -static byte gwip[] = { 192,168,0,1 }; -#endif - -// ethernet mac address - must be unique on your network -static byte mymac[] = { 0x70,0x69,0x69,0x2D,0x30,0x31 }; - -byte Ethernet::buffer[500]; // tcp/ip send and receive buffer - -//callback that prints received packets to the serial port -void udpSerialPrint(word port, byte ip[4], const char *data, word len) { - IPAddress src(ip[0], ip[1], ip[2], ip[3]); - Serial.println(src); - Serial.println(port); - Serial.println(data); - Serial.println(len); -} - -void setup(){ - Serial.begin(57600); - Serial.println(F("\n[backSoon]")); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println(F("Failed to access Ethernet controller")); -#if STATIC - ether.staticSetup(myip, gwip); -#else - if (!ether.dhcpSetup()) - Serial.println(F("DHCP failed")); -#endif - - ether.printIp("IP: ", ether.myip); - ether.printIp("GW: ", ether.gwip); - ether.printIp("DNS: ", ether.dnsip); - - //register udpSerialPrint() to port 1337 - ether.udpServerListenOnPort(&udpSerialPrint, 1337); - - //register udpSerialPrint() to port 42. - ether.udpServerListenOnPort(&udpSerialPrint, 42); -} - -void loop(){ - //this must be called for ethercard functions to work. - ether.packetLoop(ether.packetReceive()); -} - - -/* -//Processing sketch to send test UDP packets. - -import hypermedia.net.*; - - UDP udp; // define the UDP object - - - void setup() { - udp = new UDP( this, 6000 ); // create a new datagram connection on port 6000 - //udp.log( true ); // <-- printout the connection activity - udp.listen( true ); // and wait for incoming message - } - - void draw() - { - } - - void keyPressed() { - String ip = "192.168.0.200"; // the remote IP address - int port = 1337; // the destination port - - udp.send("Greetings via UDP!", ip, port ); // the message to send - - } - - void receive( byte[] data ) { // <-- default handler - //void receive( byte[] data, String ip, int port ) { // <-- extended handler - - for(int i=0; i < data.length; i++) - print(char(data[i])); - println(); - } -*/ diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/webClient/webClient.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/webClient/webClient.ino deleted file mode 100644 index 12acc4a..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/webClient/webClient.ino +++ /dev/null @@ -1,69 +0,0 @@ -// Demo using DHCP and DNS to perform a web client request. -// 2011-06-08 http://opensource.org/licenses/mit-license.php -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -// ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -byte Ethernet::buffer[700]; -static uint32_t timer; - -const char website[] PROGMEM = "www.google.com"; - -// called when the client request is complete -static void my_callback (byte status, uint16_t off, uint16_t len) { - Serial.println(">>>"); - Ethernet::buffer[off+300] = 0; - Serial.print((const char*) Ethernet::buffer + off); - Serial.println("..."); -} - -void setup () { - Serial.begin(57600); - Serial.println(F("\n[webClient]")); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) - Serial.println(F("Failed to access Ethernet controller")); - if (!ether.dhcpSetup()) - Serial.println(F("DHCP failed")); - - ether.printIp("IP: ", ether.myip); - ether.printIp("GW: ", ether.gwip); - ether.printIp("DNS: ", ether.dnsip); - - if (!ether.dnsLookup(website)) - Serial.println("DNS failed"); - - ether.printIp("SRV: ", ether.hisip); -} - -void loop () { - ether.packetLoop(ether.packetReceive()); - - if (millis() > timer) { - timer = millis() + 5000; - Serial.println(); - Serial.print("<<< REQ "); - ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback); - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/xively/xively.ino b/GD32F1/libraries/Serasidis_EtherCard_STM/examples/xively/xively.ino deleted file mode 100644 index 3541743..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/examples/xively/xively.ino +++ /dev/null @@ -1,158 +0,0 @@ -// Simple demo for feeding some random data to Pachube. -// 2011-07-08 http://opensource.org/licenses/mit-license.php - -// Handle returning code and reset ethernet module if needed -// 2013-10-22 hneiraf@gmail.com -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -// -// - -#include -#include - -// change these settings to match your own setup -#define FEED "12345678" //Write here your FEED key (look at "Feed Keys" on xively. -#define APIKEY "asgEEwewtwerweTRRWER323SSDFfds" //Write your own APIKEY. - -// ethernet interface mac address, must be unique on the LAN -static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; - -const char website[] PROGMEM = "api.xively.com"; - -byte Ethernet::buffer[350]; -uint32_t timer; -Stash stash; -byte session; - -//timing variable -int res = 0; - - - -void setup () { - Serial.begin(57600); - Serial.println("\n[Xively example]"); - - //Initialize Ethernet - initialize_ethernet(); -} - - -void loop () { - - //if correct answer is not received then re-initialize ethernet module - if (res > 220){ - initialize_ethernet(); - } - - res = res + 1; - - ether.packetLoop(ether.packetReceive()); - - //200 res = 10 seconds (50ms each res) - if (res == 200) { - - - //Generate random info - float demo = random(0,500); - word one = random(0,500); - String msje; - - if (demo < 250){ - msje = "low"; - } - else{ - msje = "high"; - } - - - // generate two fake values as payload - by using a separate stash, - // we can determine the size of the generated message ahead of time - byte sd = stash.create(); - stash.print("demo,"); - stash.println(demo); - stash.print("one,"); - stash.println(one); - stash.print("mensaje,"); - stash.println(msje); - stash.save(); - - //Display data to be sent - Serial.println(demo); - Serial.println(one); - - - // generate the header with payload - note that the stash size is used, - // and that a "stash descriptor" is passed in as argument using "$H" - Stash::prepare(PSTR("PUT http://$F/v2/feeds/$F.csv HTTP/1.0" "\r\n" - "Host: $F" "\r\n" - "X-PachubeApiKey: $F" "\r\n" - "Content-Length: $D" "\r\n" - "\r\n" - "$H"), - website, PSTR(FEED), website, PSTR(APIKEY), stash.size(), sd); - - // send the packet - this also releases all stash buffers once done - session = ether.tcpSend(); - } - - const char* reply = ether.tcpReply(session); - - if (reply != 0) { - res = 0; - Serial.println(reply); - } - delay(50); -} - - - -void initialize_ethernet(void){ - for(;;){ // keep trying until you succeed - //Reinitialize ethernet module - pinMode(5, OUTPUT); - Serial.println("Reseting Ethernet..."); - digitalWrite(5, LOW); - delay(1000); - digitalWrite(5, HIGH); - delay(500); - - if (ether.begin(sizeof Ethernet::buffer, mymac) == 0){ - Serial.println( "Failed to access Ethernet controller"); - continue; - } - - if (!ether.dhcpSetup()){ - Serial.println("DHCP failed"); - continue; - } - - ether.printIp("IP: ", ether.myip); - ether.printIp("GW: ", ether.gwip); - ether.printIp("DNS: ", ether.dnsip); - - if (!ether.dnsLookup(website)) - Serial.println("DNS failed"); - - ether.printIp("SRV: ", ether.hisip); - - //reset init value - res = 0; - break; - } -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/keywords.txt b/GD32F1/libraries/Serasidis_EtherCard_STM/keywords.txt deleted file mode 100644 index ca73a6e..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/keywords.txt +++ /dev/null @@ -1,53 +0,0 @@ -####################################### -# Syntax Coloring Map EtherCard_STM -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -EtherCard_STM KEYWORD1 -ether KEYWORD1 -BufferFiller KEYWORD1 -Stash KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -emit_p KEYWORD2 -emit_raw KEYWORD2 -emit_raw_p KEYWORD2 -buffer KEYWORD2 -Ethernet KEYWORD2 -printIp KEYWORD2 -staticSetup KEYWORD2 -dhcpSetup KEYWORD2 -packetLoop KEYWORD2 -packetReceive KEYWORD2 -httpServerReply KEYWORD2 -browseUrl KEYWORD2 -memcpy_P KEYWORD2 -tcpOffset KEYWORD2 -tcpSend KEYWORD2 -tcpReply KEYWORD2 -dnsLookup KEYWORD2 -httpServerReply KEYWORD2 -sizeof KEYWORD2 -SerialPrint_P KEYWORD2 -copyIp KEYWORD2 -getIP_address KEYWORD2 -hisip KEYWORD2 -myip KEYWORD2 -gwip KEYWORD2 -mymask KEYWORD2 -dnsip KEYWORD2 -cleanup KEYWORD2 -freeCount KEYWORD2 -extract KEYWORD2 -save KEYWORD2 -size KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### -STATUS_ERROR LITERAL1 diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/library.properties b/GD32F1/libraries/Serasidis_EtherCard_STM/library.properties deleted file mode 100644 index 403657b..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/library.properties +++ /dev/null @@ -1,8 +0,0 @@ -name=Serasidis_EtherCard_STM -version=1.0 -author=(Original) Jean-Claude Wippler :: Ported to STM32 by Vassilis Serasidis. -email= -sentence=ENC28J60 Ethernet module library -paragraph=Ethernet module library for STM32F1 -url=https://github.com/Serasidis/STM32duino/tree/master/libraries/Serasidis_EtherCard_STM -architectures=STM32F1 diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/Doxymods.css b/GD32F1/libraries/Serasidis_EtherCard_STM/src/Doxymods.css deleted file mode 100644 index ec01e9e..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/Doxymods.css +++ /dev/null @@ -1,73 +0,0 @@ -/* Get rid of all those overriden font families */ -body, table, div, p, dl, -#projectname, -#projectbrief, -#nav-tree .label { - font: 15px/21px Georgia,serif -} - -#projectname { - color: #990000; - font-weight: bold; - font-size: 24px; -} - -#titlearea table { - padding: 20px; -} - -dl.reflist dt, div.memproto { - border: 1px solid #A8B8D9; -} - -dl.reflist dd, div.memdoc { - border-width: 0; -} - -div.contents { - margin-left: 20px; margin-right: 16px; - width: 700 px; -} - -/* Get rid of the gradient backgrounds and background colors */ -div.header, -#nav-tree, -.navpath ul, -.memproto, dl.reflist dt { - background: none; -} -#nav-tree .selected { - background: none; - background-color: #990000; - text-shadow: none; -} - -a, a:link, a:visited { - color: #2A5685; - text-decoration: underline; -} -a:active, a:hover { - color: #CC0000; -} - -.directory tr.even, -pre.fragment, -.mdescLeft, .mdescRight, .memItemLeft, .memItemRight, .memTemplItemLeft, .memTemplItemRight, .memTemplParams, -.memproto, dl.reflist dt { - background-color: #EEE; - box-shadow: none; - border-radius: 0; -} -.memdoc, dl.reflist dd { - background: none; - box-shadow: none; - border-radius: 0; -} -pre.fragment { - background-color: #FAFAFA; - border: 1px solid #DADADA; - margin: 1em 1em 1em 1.6em; - overflow-x: auto; - overflow-y: hidden; - width: auto; -} diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/EtherCard_STM.cpp b/GD32F1/libraries/Serasidis_EtherCard_STM/src/EtherCard_STM.cpp deleted file mode 100644 index be99de4..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/EtherCard_STM.cpp +++ /dev/null @@ -1,433 +0,0 @@ -// This code slightly follows the conventions of, but is not derived from: -// EHTERSHIELD_H library for Arduino etherShield -// Copyright (c) 2008 Xing Yu. All right reserved. (this is LGPL v2.1) -// It is however derived from the enc28j60 and ip code (which is GPL v2) -// Author: Pascal Stang -// Modified by: Guido Socher -// DHCP code: Andrew Lindsay -// Hence: GPL V2 -// -// 2010-05-19 -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- - - -#include -#include -//#include - -//#define FLOATEMIT // uncomment line to enable $T in emit_P for float emitting - -byte Stash::map[256/8]; -Stash::Block Stash::bufs[2]; - -uint8_t Stash::allocBlock () { - for (uint8_t i = 0; i < sizeof map; ++i) - if (map[i] != 0) - for (uint8_t j = 0; j < 8; ++j) - if (bitRead(map[i], j)) { - bitClear(map[i], j); - return (i << 3) + j; - } - return 0; -} - -void Stash::freeBlock (uint8_t block) { - bitSet(map[block>>3], block & 7); -} - -uint8_t Stash::fetchByte (uint8_t blk, uint8_t off) { - return blk == bufs[0].bnum ? bufs[0].bytes[off] : - blk == bufs[1].bnum ? bufs[1].bytes[off] : - ether.peekin(blk, off); -} - -void Stash::initMap (uint8_t last) { - while (--last > 0) - freeBlock(last); -} - -void Stash::load (uint8_t idx, uint8_t blk) { - if (blk != bufs[idx].bnum) { - if (idx == 0) { - ether.copyout(bufs[idx].bnum, bufs[idx].bytes); - if (blk == bufs[1].bnum) - bufs[1].bnum = 255; // forget read page if same - } else if (blk == bufs[0].bnum) { - // special case: read page is same as write buffer - memcpy(&bufs[1], &bufs[0], sizeof bufs[0]); - return; - } - bufs[idx].bnum = blk; - ether.copyin(bufs[idx].bnum, bufs[idx].bytes); - } -} - -uint8_t Stash::freeCount () { - uint8_t count = 0; - for (uint8_t i = 0; i < 256/8; ++i) - for (uint8_t m = 0x80; m != 0; m >>= 1) - if (map[i] & m) - ++count; - return count; -} - -uint8_t Stash::create () { - uint8_t blk = allocBlock(); - load(0, blk); - bufs[0].head.count = 0; - bufs[0].head.first = bufs[0].head.last = blk; - bufs[0].tail = sizeof (StashHeader); - bufs[0].next = 0; - return open(blk); -} - -uint8_t Stash::open (uint8_t blk) { - curr = blk; - offs = sizeof (StashHeader); - load(1, curr); - memcpy((StashHeader*) this, bufs[1].bytes, sizeof (StashHeader)); - return curr; -} - -void Stash::save () { - load(0, first); - memcpy(bufs[0].bytes, (StashHeader*) this, sizeof (StashHeader)); - if (bufs[1].bnum == first) - load(1, 0); // invalidates original in case it was the same block -} - -void Stash::release () { - while (first > 0) { - freeBlock(first); - first = ether.peekin(first, 63); - } -} - -void Stash::put (char c) { - load(0, last); - uint8_t t = bufs[0].tail; - bufs[0].bytes[t++] = c; - if (t <= 62) - bufs[0].tail = t; - else { - bufs[0].next = allocBlock(); - last = bufs[0].next; - load(0, last); - bufs[0].tail = bufs[0].next = 0; - ++count; - } -} - -char Stash::get () { - load(1, curr); - if (curr == last && offs >= bufs[1].tail) - return 0; - uint8_t b = bufs[1].bytes[offs]; - if (++offs >= 63 && curr != last) { - curr = bufs[1].next; - offs = 0; - } - return b; -} - -uint16_t Stash::size () { - return 63 * count + fetchByte(last, 62) - sizeof (StashHeader); -} - -static char* wtoa (uint16_t value, char* ptr) { - if (value > 9) - ptr = wtoa(value / 10, ptr); - *ptr = '0' + value % 10; - *++ptr = 0; - return ptr; -} - -void Stash::prepare (PGM_P fmt, ...) { - Stash::load(0, 0); - uint16_t* segs = Stash::bufs[0].words; - *segs++ = strlen_P(fmt); -#ifdef __AVR__ - *segs++ = (uint16_t) fmt; -#else - *segs++ = (uint32_t) fmt; - *segs++ = (uint32_t) fmt >> 16; -#endif - va_list ap; - va_start(ap, fmt); - for (;;) { - char c = pgm_read_byte(fmt++); - if (c == 0) - break; - if (c == '$') { -#ifdef __AVR__ - uint16_t argval = va_arg(ap, uint16_t), arglen = 0; -#else - uint32_t argval = va_arg(ap, int), arglen = 0; -#endif - switch (pgm_read_byte(fmt++)) { - case 'D': { - char buf[7]; - wtoa(argval, buf); - arglen = strlen(buf); - break; - } - case 'S': - arglen = strlen((const char*) argval); - break; - case 'F': - arglen = strlen_P((PGM_P) argval); - break; - case 'E': { - byte* s = (byte*) argval; - char d; - //while ((d = eeprom_read_byte(s++)) != 0) - // ++arglen; - break; - } - case 'H': { - Stash stash (argval); - arglen = stash.size(); - break; - } - } -#ifdef __AVR__ - *segs++ = argval; -#else - *segs++ = argval; - *segs++ = argval >> 16; -#endif - Stash::bufs[0].words[0] += arglen - 2; - } - } - va_end(ap); -} - -uint16_t Stash::length () { - Stash::load(0, 0); - return Stash::bufs[0].words[0]; -} - -void Stash::extract (uint16_t offset, uint16_t count, void* buf) { - Stash::load(0, 0); - uint16_t* segs = Stash::bufs[0].words; -#ifdef __AVR__ - PGM_P fmt = (PGM_P) *++segs; -#else - PGM_P fmt = (PGM_P)((segs[2] << 16) | segs[1]); - segs += 2; -#endif - Stash stash; - char mode = '@', tmp[7], *ptr = NULL, *out = (char*) buf; - for (uint16_t i = 0; i < offset + count; ) { - char c = 0; - switch (mode) { - case '@': { - c = pgm_read_byte(fmt++); - if (c == 0) - return; - if (c != '$') - break; -#ifdef __AVR__ - uint16_t arg = *++segs; -#else - uint32_t arg = *++segs; - arg |= *++segs << 16; -#endif - mode = pgm_read_byte(fmt++); - switch (mode) { - case 'D': - wtoa(arg, tmp); - ptr = tmp; - break; - case 'S': - case 'F': - case 'E': - ptr = (char*) arg; - break; - case 'H': - stash.open(arg); - ptr = (char*) &stash; - break; - } - continue; - } - case 'D': - case 'S': - c = *ptr++; - break; - case 'F': - c = pgm_read_byte(ptr++); - break; - case 'E': - //c = eeprom_read_byte((byte*) ptr++); - break; - case 'H': - c = ((Stash*) ptr)->get(); - break; - } - if (c == 0) { - mode = '@'; - continue; - } - if (i >= offset) - *out++ = c; - ++i; - } -} - -void Stash::cleanup () { - Stash::load(0, 0); - uint16_t* segs = Stash::bufs[0].words; -#ifdef __AVR__ - PGM_P fmt = (PGM_P) *++segs; -#else - PGM_P fmt = (PGM_P)((segs[2] << 16) | segs[1]); - segs += 2; -#endif - for (;;) { - char c = pgm_read_byte(fmt++); - if (c == 0) - break; - if (c == '$') { -#ifdef __AVR__ - uint16_t arg = *++segs; -#else - uint32_t arg = *++segs; - arg |= *++segs << 16; -#endif - if (pgm_read_byte(fmt++) == 'H') { - Stash stash (arg); - stash.release(); - } - } - } -} - -void BufferFiller::emit_p(PGM_P fmt, ...) { - va_list ap; - va_start(ap, fmt); - for (;;) { - char c = pgm_read_byte(fmt++); - if (c == 0) - break; - if (c != '$') { - *ptr++ = c; - continue; - } - c = pgm_read_byte(fmt++); - switch (c) { - case 'D': -#ifdef __AVR__ - wtoa(va_arg(ap, uint16_t), (char*) ptr); -#else - wtoa(va_arg(ap, int), (char*) ptr); -#endif - break; -#ifdef FLOATEMIT - case 'T': - dtostrf ( va_arg(ap, double), 10, 3, (char*)ptr ); - break; -#endif - case 'H': { -#ifdef __AVR__ - char p1 = va_arg(ap, uint16_t); -#else - char p1 = va_arg(ap, int); -#endif - char p2; - p2 = (p1 >> 4) & 0x0F; - p1 = p1 & 0x0F; - if (p1 > 9) p1 += 0x07; // adjust 0x0a-0x0f to come out 'a'-'f' - p1 += 0x30; // and complete - if (p2 > 9) p2 += 0x07; // adjust 0x0a-0x0f to come out 'a'-'f' - p2 += 0x30; // and complete - *ptr++ = p2; - *ptr++ = p1; - continue; - } - case 'L': - //ltoa(va_arg(ap, long), (char*) ptr, 10); - break; - case 'S': - strcpy((char*) ptr, va_arg(ap, const char*)); - break; - case 'F': { - PGM_P s = va_arg(ap, PGM_P); - char d; - while ((d = pgm_read_byte(s++)) != 0) - *ptr++ = d; - continue; - } - case 'E': { - byte* s = va_arg(ap, byte*); - char d; - //while ((d = eeprom_read_byte(s++)) != 0) - // *ptr++ = d; - continue; - } - default: - *ptr++ = c; - continue; - } - ptr += strlen((char*) ptr); - } - va_end(ap); -} - -EtherCard ether; - -uint8_t EtherCard::mymac[6]; // my MAC address -uint8_t EtherCard::myip[4]; // my ip address -uint8_t EtherCard::netmask[4]; // subnet mask -uint8_t EtherCard::broadcastip[4]; // broadcast address -uint8_t EtherCard::gwip[4]; // gateway -uint8_t EtherCard::dhcpip[4]; // dhcp server -uint8_t EtherCard::dnsip[4]; // dns server -uint8_t EtherCard::hisip[4]; // ip address of remote host -uint16_t EtherCard::hisport = 80; // tcp port to browse to -bool EtherCard::using_dhcp = false; -bool EtherCard::persist_tcp_connection = false; -uint16_t EtherCard::delaycnt = 0; //request gateway ARP lookup - -uint8_t EtherCard::begin (const uint16_t size, - const uint8_t* macaddr, - uint8_t csPin) { - using_dhcp = false; - Stash::initMap(56); - copyMac(mymac, macaddr); - return initialize(size, mymac, csPin); -} - -bool EtherCard::staticSetup (const uint8_t* my_ip, - const uint8_t* gw_ip, - const uint8_t* dns_ip, - const uint8_t* mask) { - using_dhcp = false; - - if (my_ip != 0) - copyIp(myip, my_ip); - if (gw_ip != 0) - setGwIp(gw_ip); - if (dns_ip != 0) - copyIp(dnsip, dns_ip); - if(mask != 0) - copyIp(netmask, mask); - updateBroadcastAddress(); - delaycnt = 0; //request gateway ARP lookup - return true; -} diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/EtherCard_STM.h b/GD32F1/libraries/Serasidis_EtherCard_STM/src/EtherCard_STM.h deleted file mode 100644 index 7a85834..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/EtherCard_STM.h +++ /dev/null @@ -1,595 +0,0 @@ -// This code slightly follows the conventions of, but is not derived from: -// EHTERSHIELD_H library for Arduino etherShield -// Copyright (c) 2008 Xing Yu. All right reserved. (this is LGPL v2.1) -// It is however derived from the enc28j60 and ip code (which is GPL v2) -// Author: Pascal Stang -// Modified by: Guido Socher -// DHCP code: Andrew Lindsay -// Hence: GPL V2 -// -// 2010-05-19 -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- - - - -#ifndef EtherCard_STM_h -#define EtherCard_STM_h -#ifndef __PROG_TYPES_COMPAT__ - #define __PROG_TYPES_COMPAT__ -#endif - -#if ARDUINO >= 100 -#include // Arduino 1.0 -#define WRITE_RESULT size_t -#define WRITE_RETURN return 1; -#else -#include // Arduino 0022 -#define WRITE_RESULT void -#define WRITE_RETURN -#endif - -#include -#include "enc28j60.h" -#include "net.h" - -/** This type definition defines the structure of a UDP server event handler callback funtion */ -typedef void (*UdpServerCallback)( - uint16_t dest_port, ///< Port the packet was sent to - uint8_t src_ip[4], ///< IP address of the sender - uint16_t src_port, ///< Port the packet was sent from - const char *data, ///< UDP payload data - uint16_t len); ///< Length of the payload data - -/** This type definition defines the structure of a DHCP Option callback funtion */ -typedef void (*DhcpOptionCallback)( - uint8_t option, ///< The option number - const byte* data, ///< DHCP option data - uint8_t len); ///< Length of the DHCP option data - - -/** This structure describes the structure of memory used within the ENC28J60 network interface. */ -typedef struct { - uint8_t count; ///< Number of allocated pages - uint8_t first; ///< First allocated page - uint8_t last; ///< Last allocated page -} StashHeader; - -/** This class provides access to the memory within the ENC28J60 network interface. */ -class Stash : public /*Stream*/ Print, private StashHeader { - uint8_t curr; //!< Current page - uint8_t offs; //!< Current offset in page - - typedef struct { - union { - uint8_t bytes[64]; - uint16_t words[32]; - struct { - StashHeader head; - uint8_t filler[59]; - uint8_t tail; - uint8_t next; - }; - }; - uint8_t bnum; - } Block; - - static uint8_t allocBlock (); - static void freeBlock (uint8_t block); - static uint8_t fetchByte (uint8_t blk, uint8_t off); - - static Block bufs[2]; - static uint8_t map[256/8]; - -public: - static void initMap (uint8_t last); - static void load (uint8_t idx, uint8_t blk); - static uint8_t freeCount (); - - Stash () : curr (0) { first = 0; } - Stash (uint8_t fd) { open(fd); } - - uint8_t create (); - uint8_t open (uint8_t blk); - void save (); - void release (); - - void put (char c); - char get (); - uint16_t size (); - - virtual WRITE_RESULT write(uint8_t b) { put(b); WRITE_RETURN } - - // virtual int available() { - // if (curr != last) - // return 1; - // load(1, last); - // return offs < bufs[1].tail; - // } - // virtual int read() { - // return available() ? get() : -1; - // } - // virtual int peek() { - // return available() ? bufs[1].bytes[offs] : -1; - // } - // virtual void flush() { - // curr = last; - // offs = 63; - // } - - static void prepare (PGM_P fmt, ...); - static uint16_t length (); - static void extract (uint16_t offset, uint16_t count, void* buf); - static void cleanup (); - - friend void dumpBlock (const char* msg, uint8_t idx); // optional - friend void dumpStash (const char* msg, void* ptr); // optional -}; - -/** This class populates network send and receive buffers. -* -* This class provides formatted printing into memory. Users can use it to write into send buffers. -* -* Nota: PGM_P: is a pointer to a string in program space (defined in the source code) -* -* # Format string -* -* | Format | Parameter | Output -* |--------|-------------|---------- -* | $D | uint16_t | Decimal representation -* | $T ¤ | double | Decimal representation with 3 digits after decimal sign ([-]d.ddd) -* | $H | uint16_t | Hexadecimal value of lsb (from 00 to ff) -* | $L | long | Decimal representation -* | $S | const char* | Copy null terminated string from main memory -* | $F | PGM_P | Copy null terminated string from program space -* | $E | byte* | Copy null terminated string from EEPROM space -* | $$ | _none_ | '$' -* -* ¤ _Available only if FLOATEMIT is defined_ -* -* # Examples -* ~~~~~~~~~~~~~{.c} -* uint16_t ddd = 123; -* double ttt = 1.23; -* uint16_t hhh = 0xa4; -* long lll = 123456789; -* char * sss; -* char fff[] PROGMEM = "MyMemory"; -* -* sss[0] = 'G'; -* sss[1] = 'P'; -* sss[2] = 'L'; -* sss[3] = 0; -* buf.emit_p( PSTR("ddd=$D\n"), ddd ); // "ddd=123\n" -* buf.emit_p( PSTR("ttt=$T\n"), ttt ); // "ttt=1.23\n" **TO CHECK** -* buf.emit_p( PSTR("hhh=$H\n"), hhh ); // "hhh=a4\n" -* buf.emit_p( PSTR("lll=$L\n"), lll ); // "lll=123456789\n" -* buf.emit_p( PSTR("sss=$S\n"), sss ); // "sss=GPL\n" -* buf.emit_p( PSTR("fff=$F\n"), fff ); // "fff=MyMemory\n" -* ~~~~~~~~~~~~~ -* -*/ -class BufferFiller : public Print { - uint8_t *start; //!< Pointer to start of buffer - uint8_t *ptr; //!< Pointer to cursor position -public: - /** @brief Empty constructor - */ - BufferFiller () {} - - /** @brief Constructor - * @param buf Pointer to the ethernet data buffer - */ - BufferFiller (uint8_t* buf) : start (buf), ptr (buf) {} - - /** @brief Add formatted text to buffer - * @param fmt Format string (see Class description) - * @param ... parameters for format string - */ - void emit_p (PGM_P fmt, ...); - - /** @brief Add data to buffer from main memory - * @param s Pointer to data - * @param n Number of characters to copy - */ - void emit_raw (const char* s, uint16_t n) { memcpy(ptr, s, n); ptr += n; } - - /** @brief Add data to buffer from program space string - * @param p Program space string pointer - * @param n Number of characters to copy - */ - void emit_raw_p (PGM_P p, uint16_t n) { memcpy_P(ptr, p, n); ptr += n; } - - /** @brief Get pointer to start of buffer - * @return uint8_t* Pointer to start of buffer - */ - uint8_t* buffer () const { return start; } - - /** @brief Get cursor position - * @return uint16_t Cursor postion - */ - uint16_t position () const { return ptr - start; } - - /** @brief Write one byte to buffer - * @param v Byte to add to buffer - */ - virtual WRITE_RESULT write (uint8_t v) { *ptr++ = v; WRITE_RETURN } -}; - -/** This class provides the main interface to a ENC28J60 based network interface card and is the class most users will use. -* @note All TCP/IP client (outgoing) connections are made from source port in range 2816-3071. Do not use these source ports for other purposes. -*/ -class EtherCard : public Ethernet { -public: - static uint8_t mymac[6]; ///< MAC address - static uint8_t myip[4]; ///< IP address - static uint8_t netmask[4]; ///< Netmask - static uint8_t broadcastip[4]; ///< Subnet broadcast address - static uint8_t gwip[4]; ///< Gateway - static uint8_t dhcpip[4]; ///< DHCP server IP address - static uint8_t dnsip[4]; ///< DNS server IP address - static uint8_t hisip[4]; ///< DNS lookup result - static uint16_t hisport; ///< TCP port to connect to (default 80) - static bool using_dhcp; ///< True if using DHCP - static bool persist_tcp_connection; ///< False to break connections on first packet received - static uint16_t delaycnt; ///< Counts number of cycles of packetLoop when no packet received - used to trigger periodic gateway ARP request - - // EtherCard.cpp - /** @brief Initialise the network interface - * @param size Size of data buffer - * @param macaddr Hardware address to assign to the network interface (6 bytes) - * @param csPin Arduino pin number connected to chip select. Default = 8 - * @return uint8_t Firmware version or zero on failure. - */ - static uint8_t begin (const uint16_t size, const uint8_t* macaddr, - uint8_t csPin =PA8); - - /** @brief Configure network interface with static IP - * @param my_ip IP address (4 bytes). 0 for no change. - * @param gw_ip Gateway address (4 bytes). 0 for no change. Default = 0 - * @param dns_ip DNS address (4 bytes). 0 for no change. Default = 0 - * @param mask Subnet mask (4 bytes). 0 for no change. Default = 0 - * @return bool Returns true on success - actually always true - */ - static bool staticSetup (const uint8_t* my_ip, - const uint8_t* gw_ip = 0, - const uint8_t* dns_ip = 0, - const uint8_t* mask = 0); - - // tcpip.cpp - /** @brief Sends a UDP packet to the IP address of last processed received packet - * @param data Pointer to data payload - * @param len Size of data payload (max 220) - * @param port Source IP port - */ - static void makeUdpReply (const char *data, uint8_t len, uint16_t port); - - /** @brief Parse received data - * @param plen Size of data to parse (e.g. return value of packetReceive()). - * @return uint16_t Offset of TCP payload data in data buffer or zero if packet processed - * @note Data buffer is shared by receive and transmit functions - * @note Only handles ARP and IP - */ - static uint16_t packetLoop (uint16_t plen); - - /** @brief Accept a TCP/IP connection - * @param port IP port to accept on - do nothing if wrong port - * @param plen Number of bytes in packet - * @return uint16_t Offset within packet of TCP payload. Zero for no data. - */ - static uint16_t accept (uint16_t port, uint16_t plen); - - /** @brief Send a response to a HTTP request - * @param dlen Size of the HTTP (TCP) payload - */ - static void httpServerReply (uint16_t dlen); - - /** @brief Send a response to a HTTP request - * @param dlen Size of the HTTP (TCP) payload - * @param flags TCP flags - */ - static void httpServerReply_with_flags (uint16_t dlen , uint8_t flags); - - /** @brief Acknowledge TCP message - * @todo Is this / should this be private? - */ - static void httpServerReplyAck (); - - /** @brief Set the gateway address - * @param gwipaddr Gateway address (4 bytes) - */ - static void setGwIp (const uint8_t *gwipaddr); - - /** @brief Updates the broadcast address based on current IP address and subnet mask - */ - static void updateBroadcastAddress(); - - /** @brief Check if got gateway hardware address (ARP lookup) - * @return unit8_t True if gateway found - */ - static uint8_t clientWaitingGw (); - - /** @brief Check if got gateway DNS address (ARP lookup) - * @return unit8_t True if DNS found - */ - static uint8_t clientWaitingDns (); - - /** @brief Prepare a TCP request - * @param result_cb Pointer to callback function that handles TCP result - * @param datafill_cb Pointer to callback function that handles TCP data payload - * @param port Remote TCP/IP port to connect to - * @return unit8_t ID of TCP/IP session (0-7) - * @note Return value provides id of the request to allow up to 7 concurrent requests - */ - static uint8_t clientTcpReq (uint8_t (*result_cb)(uint8_t,uint8_t,uint16_t,uint16_t), - uint16_t (*datafill_cb)(uint8_t),uint16_t port); - - /** @brief Prepare HTTP request - * @param urlbuf Pointer to c-string URL folder - * @param urlbuf_varpart Pointer to c-string URL file - * @param hoststr Pointer to c-string hostname - * @param additionalheaderline Pointer to c-string with additional HTTP header info - * @param callback Pointer to callback function to handle response - * @note Request sent in main packetloop - */ - static void browseUrl (const char *urlbuf, const char *urlbuf_varpart, - const char *hoststr, const char *additionalheaderline, - void (*callback)(uint8_t,uint16_t,uint16_t)); - - /** @brief Prepare HTTP request - * @param urlbuf Pointer to c-string URL folder - * @param urlbuf_varpart Pointer to c-string URL file - * @param hoststr Pointer to c-string hostname - * @param callback Pointer to callback function to handle response - * @note Request sent in main packetloop - */ - static void browseUrl (const char *urlbuf, const char *urlbuf_varpart, - const char *hoststr, - void (*callback)(uint8_t,uint16_t,uint16_t)); - - /** @brief Prepare HTTP post message - * @param urlbuf Pointer to c-string URL folder - * @param hoststr Pointer to c-string hostname - * @param additionalheaderline Pointer to c-string with additional HTTP header info - * @param postval Pointer to c-string HTML Post value - * @param callback Pointer to callback function to handle response - * @note Request sent in main packetloop - */ - static void httpPost (const char *urlbuf, const char *hoststr, - const char *additionalheaderline, const char *postval, - void (*callback)(uint8_t,uint16_t,uint16_t)); - - /** @brief Send NTP request - * @param ntpip IP address of NTP server - * @param srcport IP port to send from - */ - static void ntpRequest (uint8_t *ntpip,uint8_t srcport); - - /** @brief Process network time protocol response - * @param time Pointer to integer to hold result - * @param dstport_l Destination port to expect response. Set to zero to accept on any port - * @return uint8_t True (1) on success - */ - static uint8_t ntpProcessAnswer (uint32_t *time, uint8_t dstport_l); - - /** @brief Prepare a UDP message for transmission - * @param sport Source port - * @param dip Pointer to 4 byte destination IP address - * @param dport Destination port - */ - static void udpPrepare (uint16_t sport, const uint8_t *dip, uint16_t dport); - - /** @brief Transmit UDP packet - * @param len Size of payload - */ - static void udpTransmit (uint16_t len); - - /** @brief Sends a UDP packet - * @param data Pointer to data - * @param len Size of payload (maximum 220 octets / bytes) - * @param sport Source port - * @param dip Pointer to 4 byte destination IP address - * @param dport Destination port - */ - static void sendUdp (const char *data, uint8_t len, uint16_t sport, - const uint8_t *dip, uint16_t dport); - - /** @brief Resister the function to handle ping events - * @param cb Pointer to function - */ - static void registerPingCallback (void (*cb)(uint8_t*)); - - /** @brief Send ping - * @param destip Ponter to 4 byte destination IP address - */ - static void clientIcmpRequest (const uint8_t *destip); - - /** @brief Check for ping response - * @param ip_monitoredhost Pointer to 4 byte IP address of host to check - * @return uint8_t True (1) if ping response from specified host - */ - static uint8_t packetLoopIcmpCheckReply (const uint8_t *ip_monitoredhost); - - /** @brief Send a wake on lan message - * @param wolmac Pointer to 6 byte hardware (MAC) address of host to send message to - */ - static void sendWol (uint8_t *wolmac); - - // new stash-based API - /** @brief Send TCP request - */ - static uint8_t tcpSend (); - - /** @brief Get TCP reply - * @return char* Pointer to TCP reply payload. NULL if no data. - */ - static const char* tcpReply (uint8_t fd); - - /** @brief Configure TCP connections to be persistent or not - * @param persist True to maintain TCP connection. False to finish TCP connection after first packet. - */ - static void persistTcpConnection(bool persist); - - //udpserver.cpp - /** @brief Register function to handle incomint UDP events - * @param callback Function to handle event - * @param port Port to listen on - */ - static void udpServerListenOnPort(UdpServerCallback callback, uint16_t port); - - /** @brief Pause listing on UDP port - * @brief port Port to pause - */ - static void udpServerPauseListenOnPort(uint16_t port); - - /** @brief Resume listing on UDP port - * @brief port Port to pause - */ - static void udpServerResumeListenOnPort(uint16_t port); - - /** @brief Check if UDP server is listening on any ports - * @return bool True if listening on any ports - */ - static bool udpServerListening(); //called by tcpip, in packetLoop - - /** @brief Passes packet to UDP Server - * @param len Not used - * @return bool True if packet processed - */ - static bool udpServerHasProcessedPacket(uint16_t len); //called by tcpip, in packetLoop - - // dhcp.cpp - /** @brief Update DHCP state - * @param len Length of received data packet - */ - static void DhcpStateMachine(uint16_t len); - - /** @brief Not implemented - * @todo Implement dhcpStartTime or remove declaration - */ - static uint32_t dhcpStartTime (); - - /** @brief Not implemented - * @todo Implement dhcpLeaseTime or remove declaration - */ - static uint32_t dhcpLeaseTime (); - - /** @brief Not implemented - * @todo Implement dhcpLease or remove declaration - */ - static bool dhcpLease (); - - /** @brief Configure network interface with DHCP - * @return bool True if DHCP successful - * @note Blocks until DHCP complete or timeout after 60 seconds - */ - static bool dhcpSetup (const char *hname = NULL, bool fromRam =false); - - /** @brief Register a callback for a specific DHCP option number - * @param option The option number to request from the DHCP server - * @param callback The function to be call when the option is received - */ - static void dhcpAddOptionCallback(uint8_t option, DhcpOptionCallback callback); - - // dns.cpp - /** @brief Perform DNS lookup - * @param name Host name to lookup - * @param fromRam Set true to look up cached name. Default = false - * @return bool True on success. - * @note Result is stored in hisip member - */ - static bool dnsLookup (const char* name, bool fromRam =false); - - // webutil.cpp - /** @brief Copies an IP address - * @param dst Pointer to the 4 byte destination - * @param src Pointer to the 4 byte source - * @note There is no check of source or destination size. Ensure both are 4 bytes - */ - static void copyIp (uint8_t *dst, const uint8_t *src); - - /** @brief Copies a hardware address - * @param dst Pointer to the 6 byte destination - * @param src Pointer to the 6 byte destination - * @note There is no check of source or destination size. Ensure both are 6 bytes - */ - static void copyMac (uint8_t *dst, const uint8_t *src); - - /** @brief Output to serial port in dotted decimal IP format - * @param buf Pointer to 4 byte IP address - * @note There is no check of source or destination size. Ensure both are 4 bytes - */ - static void printIp (const uint8_t *buf); - - /** @brief Output message and IP address to serial port in dotted decimal IP format - * @param msg Pointer to null terminated string - * @param buf Pointer to 4 byte IP address - * @note There is no check of source or destination size. Ensure both are 4 bytes - */ - static void printIp (const char* msg, const uint8_t *buf); - - /** @brief Output Flash String Helper and IP address to serial port in dotted decimal IP format - * @param ifsh Pointer to Flash String Helper - * @param buf Pointer to 4 byte IP address - * @note There is no check of source or destination size. Ensure both are 4 bytes - * @todo What is a FlashStringHelper? - */ - static void printIp (const __FlashStringHelper *ifsh, const uint8_t *buf); - - /** @brief Search for a string of the form key=value in a string that looks like q?xyz=abc&uvw=defgh HTTP/1.1\\r\\n - * @param str Pointer to the null terminated string to search - * @param strbuf Pointer to buffer to hold null terminated result string - * @param maxlen Maximum length of result - * @param key Pointer to null terminated string holding the key to search for - * @return unit_t Length of the value. 0 if not found - * @note Ensure strbuf has memory allocated of at least maxlen + 1 (to accomodate result plus terminating null) - */ - static uint8_t findKeyVal(const char *str,char *strbuf, - uint8_t maxlen, const char *key); - - /** @brief Decode a URL string e.g "hello%20joe" or "hello+joe" becomes "hello joe" - * @param urlbuf Pointer to the null terminated URL - * @note urlbuf is modified - */ - static void urlDecode(char *urlbuf); - - /** @brief Encode a URL, replacing illegal charaters like ' ' - * @param str Pointer to the null terminated string to encode - * @param urlbuf Pointer to a buffer to contain the null terminated encoded URL - * @note There must be enough space in urlbuf. In the worst case that is 3 times the length of str - */ - static void urlEncode(char *str,char *urlbuf); - - /** @brief Convert an IP address from dotted decimal formated string to 4 bytes - * @param bytestr Pointer to the 4 byte array to store IP address - * @param str Pointer to string to parse - * @return uint8_t 0 on success - */ - static uint8_t parseIp(uint8_t *bytestr,char *str); - - /** @brief Convert a byte array to a human readable display string - * @param resultstr Pointer to a buffer to hold the resulting null terminated string - * @param bytestr Pointer to the byte array containing the address to convert - * @param len Length of the array (4 for IP address, 6 for hardware (MAC) address) - * @param separator Delimiter character (typically '.' for IP address and ':' for hardware (MAC) address) - * @param base Base for numerical representation (typically 10 for IP address and 16 for hardware (MAC) address - */ - static void makeNetStr(char *resultstr,uint8_t *bytestr,uint8_t len, - char separator,uint8_t base); -}; - -extern EtherCard ether; //!< Global presentation of EtherCard class - -#endif diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/dhcp.cpp b/GD32F1/libraries/Serasidis_EtherCard_STM/src/dhcp.cpp deleted file mode 100644 index f8f8f21..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/dhcp.cpp +++ /dev/null @@ -1,397 +0,0 @@ -// DHCP look-up functions based on the udp client -// http://www.ietf.org/rfc/rfc2131.txt -// -// Author: Andrew Lindsay -// Rewritten and optimized by Jean-Claude Wippler, http://jeelabs.org/ -// -// Rewritten dhcpStateMachine by Chris van den Hooven -// as to implement dhcp-renew when lease expires (jun 2012) -// -// Various modifications and bug fixes contributed by Victor Aprea (oct 2012) -// -// Copyright: GPL V2 -// See http://www.gnu.org/licenses/gpl.html - -//#define DHCPDEBUG - -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -//----------------------------------------------------------------- - -#include "EtherCard_STM.h" -#include "net.h" - -#define gPB ether.buffer - -#define DHCP_BOOTREQUEST 1 -#define DHCP_BOOTRESPONSE 2 - -// DHCP Message Type (option 53) (ref RFC 2132) -#define DHCP_DISCOVER 1 -#define DHCP_OFFER 2 -#define DHCP_REQUEST 3 -#define DHCP_DECLINE 4 -#define DHCP_ACK 5 -#define DHCP_NAK 6 -#define DHCP_RELEASE 7 - -// DHCP States for access in applications (ref RFC 2131) -enum { - DHCP_STATE_INIT, - DHCP_STATE_SELECTING, - DHCP_STATE_REQUESTING, - DHCP_STATE_BOUND, - DHCP_STATE_RENEWING, -}; - -/* - op 1 Message op code / message type. - 1 = BOOTREQUEST, 2 = BOOTREPLY - htype 1 Hardware address type, see ARP section in "Assigned - Numbers" RFC; e.g., '1' = 10mb ethernet. - hlen 1 Hardware address length (e.g. '6' for 10mb - ethernet). - hops 1 Client sets to zero, optionally used by relay agents - when booting via a relay agent. - xid 4 Transaction ID, a random number chosen by the - client, used by the client and server to associate - messages and responses between a client and a - server. - secs 2 Filled in by client, seconds elapsed since client - began address acquisition or renewal process. - flags 2 Flags (see figure 2). - ciaddr 4 Client IP address; only filled in if client is in - BOUND, RENEW or REBINDING state and can respond - to ARP requests. - yiaddr 4 'your' (client) IP address. - siaddr 4 IP address of next server to use in bootstrap; - returned in DHCPOFFER, DHCPACK by server. - giaddr 4 Relay agent IP address, used in booting via a - relay agent. - chaddr 16 Client hardware address. - sname 64 Optional server host name, null terminated string. - file 128 Boot file name, null terminated string; "generic" - name or null in DHCPDISCOVER, fully qualified - directory-path name in DHCPOFFER. - options var Optional parameters field. See the options - documents for a list of defined options. - */ - - - - -// size 236 -typedef struct { - byte op, htype, hlen, hops; - uint32_t xid; - uint16_t secs, flags; - byte ciaddr[4], yiaddr[4], siaddr[4], giaddr[4]; - byte chaddr[16], sname[64], file[128]; - // options -} DHCPdata; - -#define DHCP_SRC_PORT 67 -#define DHCP_DEST_PORT 68 - -// timeouts im ms -#define DHCP_REQUEST_TIMEOUT 10000 - -#define DHCP_HOSTNAME_MAX_LEN 32 - -static byte dhcpState = DHCP_STATE_INIT; -static char hostname[DHCP_HOSTNAME_MAX_LEN] = "Arduino-00"; -static uint32_t currentXid; -static uint32_t stateTimer; -static uint32_t leaseStart; -static uint32_t leaseTime; -static byte* bufPtr; - -static uint8_t dhcpCustomOptionNum = 0; -static DhcpOptionCallback dhcpCustomOptionCallback = NULL; - -// static uint8_t allOnes[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - -static void addToBuf (byte b) { - *bufPtr++ = b; -} - -static void addBytes (byte len, const byte* data) { - while (len-- > 0) - addToBuf(*data++); -} - - -// Main DHCP sending function - -// implemented -// state / msgtype -// INIT / DHCPDISCOVER -// SELECTING / DHCPREQUEST -// BOUND (RENEWING) / DHCPREQUEST - -// ---------------------------------------------------------- -// | |SELECTING |RENEWING |INIT | -// ---------------------------------------------------------- -// |broad/unicast |broadcast |unicast |broadcast | -// |server-ip |MUST |MUST NOT |MUST NOT | option 54 -// |requested-ip |MUST |MUST NOT |MUST NOT | option 50 -// |ciaddr |zero |IP address |zero | -// ---------------------------------------------------------- - -// options used (both send/receive) -// 12 Host Name Option -// 50 Requested IP Address -// 51 IP Address Lease Time -// 53 DHCP message type -// 54 Server-identifier -// 55 Parameter request list -// 58 Renewal (T1) Time Value -// 61 Client-identifier -// 255 End - -static void send_dhcp_message (void) { - - uint8_t allOnes[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - - memset(gPB, 0, UDP_DATA_P + sizeof( DHCPdata )); - - EtherCard::udpPrepare(DHCP_DEST_PORT, - (dhcpState == DHCP_STATE_BOUND ? EtherCard::dhcpip : allOnes), - DHCP_SRC_PORT); // SRC<->DST ?? - - if (dhcpState != DHCP_STATE_BOUND) - EtherCard::copyMac(gPB + ETH_DST_MAC, allOnes); //force broadcast mac - - // Build DHCP Packet from buf[UDP_DATA_P] - DHCPdata *dhcpPtr = (DHCPdata*) (gPB + UDP_DATA_P); - dhcpPtr->op = DHCP_BOOTREQUEST; - dhcpPtr->htype = 1; - dhcpPtr->hlen = 6; - dhcpPtr->xid = currentXid; - if (dhcpState == DHCP_STATE_BOUND) { - EtherCard::copyIp(dhcpPtr->ciaddr, EtherCard::myip); - } - EtherCard::copyMac(dhcpPtr->chaddr, EtherCard::mymac); - - // options defined as option, length, value - bufPtr = gPB + UDP_DATA_P + sizeof( DHCPdata ); - // DHCP magic cookie, followed by message type - static byte cookie[] = { 99, 130, 83, 99, 53, 1 }; - addBytes(sizeof cookie, cookie); - // addToBuf(53); // DHCP_STATE_SELECTING, DHCP_STATE_REQUESTING - // addToBuf(1); // Length - addToBuf(dhcpState == DHCP_STATE_INIT ? DHCP_DISCOVER : DHCP_REQUEST); - - // Client Identifier Option, this is the client mac address - addToBuf(61); // Client identifier - addToBuf(7); // Length - addToBuf(0x01); // Ethernet - addBytes(6, EtherCard::mymac); - - addToBuf(12); // Host name Option - addToBuf(10); - addBytes(10, (byte*) hostname); - - if( dhcpState == DHCP_STATE_SELECTING) { - addToBuf(50); // Request IP address - addToBuf(4); - addBytes(4, EtherCard::myip); - - // Request using server ip address - addToBuf(54); // Server IP address - addToBuf(4); - addBytes(4, EtherCard::dhcpip); - } - - // Additional info in parameter list - minimal list for what we need - byte len = 3; - if (dhcpCustomOptionNum) - len++; - addToBuf(55); // Parameter request list - addToBuf(len); // Length - addToBuf(1); // Subnet mask - addToBuf(3); // Route/Gateway - addToBuf(6); // DNS Server - if (dhcpCustomOptionNum) - addToBuf(dhcpCustomOptionNum); // Custom option - addToBuf(255); // end option - - // packet size will be under 300 bytes - EtherCard::udpTransmit((bufPtr - gPB) - UDP_DATA_P); -} - -static void process_dhcp_offer (uint16_t len) { - // Map struct onto payload - DHCPdata *dhcpPtr = (DHCPdata*) (gPB + UDP_DATA_P); - // Offered IP address is in yiaddr - EtherCard::copyIp(EtherCard::myip, dhcpPtr->yiaddr); - // Scan through variable length option list identifying options we want - byte *ptr = (byte*) (dhcpPtr + 1) + 4; - bool done = false; - do { - byte option = *ptr++; - byte optionLen = *ptr++; - switch (option) { - case 1: EtherCard::copyIp(EtherCard::netmask, ptr); - break; - case 3: EtherCard::copyIp(EtherCard::gwip, ptr); - break; - case 6: EtherCard::copyIp(EtherCard::dnsip, ptr); - break; - case 51: - case 58: leaseTime = 0; // option 58 = Renewal Time, 51 = Lease Time - for (byte i = 0; i<4; i++) - leaseTime = (leaseTime << 8) + ptr[i]; - leaseTime *= 1000; // milliseconds - break; - case 54: EtherCard::copyIp(EtherCard::dhcpip, ptr); - break; - case 255: done = true; - break; - default: { - // Is is a custom configured option? - if (dhcpCustomOptionCallback && option == dhcpCustomOptionNum) { - dhcpCustomOptionCallback(option, ptr, optionLen); - } - } - } - ptr += optionLen; - } while (!done && ptr < gPB + len); -} - -static bool dhcp_received_message_type (uint16_t len, byte msgType) { - // Map struct onto payload - DHCPdata *dhcpPtr = (DHCPdata*) (gPB + UDP_DATA_P); - - if (len >= 70 && gPB[UDP_SRC_PORT_L_P] == DHCP_SRC_PORT && - dhcpPtr->xid == currentXid ) { - - byte *ptr = (byte*) (dhcpPtr + 1) + 4; - do { - byte option = *ptr++; - byte optionLen = *ptr++; - if(option == 53 && *ptr == msgType ) { - // DHCP Message type match found - return true; - } - ptr += optionLen; - } while (ptr < gPB + len); - } - return false; -} - -bool EtherCard::dhcpSetup (const char *hname, bool fromRam) { - // Use during setup, as this discards all incoming requests until it returns. - // That shouldn't be a problem, because we don't have an IP-address yet. - // Will try 60 secs to obtain DHCP-lease. - - using_dhcp = true; - - if(hname != NULL){ - if(fromRam){ - strncpy(hostname, hname, DHCP_HOSTNAME_MAX_LEN); - } - else{ - strncpy(hostname, hname, DHCP_HOSTNAME_MAX_LEN); - } - } - else{ - // Set a unique hostname, use Arduino-?? with last octet of mac address - hostname[8] = '0' + (mymac[5] >> 4); - hostname[9] = '0' + (mymac[5] & 0x0F); - } - - dhcpState = DHCP_STATE_INIT; - uint16_t start = millis(); - - while (dhcpState != DHCP_STATE_BOUND && (uint16_t) (millis() - start) < 60000) { - if (isLinkUp()) DhcpStateMachine(packetReceive()); - } - updateBroadcastAddress(); - delaycnt = 0; - return dhcpState == DHCP_STATE_BOUND ; -} - -void EtherCard::dhcpAddOptionCallback(uint8_t option, DhcpOptionCallback callback) -{ - dhcpCustomOptionNum = option; - dhcpCustomOptionCallback = callback; -} - -void EtherCard::DhcpStateMachine (uint16_t len) { - -#ifdef DHCPDEBUG - if (dhcpState != DHCP_STATE_BOUND) { - Serial.print(millis()); - Serial.print(" State: "); - } - switch (dhcpState) { - case DHCP_STATE_INIT: - Serial.println("Init"); - break; - case DHCP_STATE_SELECTING: - Serial.println("Selecting"); - break; - case DHCP_STATE_REQUESTING: - Serial.println("Requesting"); - break; - case DHCP_STATE_RENEWING: - Serial.println("Renew"); - break; - } -#endif - - switch (dhcpState) { - - case DHCP_STATE_BOUND: - //!@todo Due to millis() 49 day wrap-around, DHCP renewal may not work as expected - if (millis() >= leaseStart + leaseTime) { - send_dhcp_message(); - dhcpState = DHCP_STATE_RENEWING; - stateTimer = millis(); - } - break; - - case DHCP_STATE_INIT: - currentXid = millis(); - memset(myip,0,4); // force ip 0.0.0.0 - send_dhcp_message(); - enableBroadcast(true); //Temporarily enable broadcasts - dhcpState = DHCP_STATE_SELECTING; - stateTimer = millis(); - break; - - case DHCP_STATE_SELECTING: - if (dhcp_received_message_type(len, DHCP_OFFER)) { - process_dhcp_offer(len); - send_dhcp_message(); - dhcpState = DHCP_STATE_REQUESTING; - stateTimer = millis(); - } else { - if (millis() > stateTimer + DHCP_REQUEST_TIMEOUT) { - dhcpState = DHCP_STATE_INIT; - } - } - break; - - case DHCP_STATE_REQUESTING: - case DHCP_STATE_RENEWING: - if (dhcp_received_message_type(len, DHCP_ACK)) { - disableBroadcast(true); //Disable broadcast after temporary enable - leaseStart = millis(); - if (gwip[0] != 0) setGwIp(gwip); // why is this? because it initiates an arp request - dhcpState = DHCP_STATE_BOUND; - } else { - if (millis() > stateTimer + DHCP_REQUEST_TIMEOUT) { - dhcpState = DHCP_STATE_INIT; - } - } - break; - - } -} - - - diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/dns.cpp b/GD32F1/libraries/Serasidis_EtherCard_STM/src/dns.cpp deleted file mode 100644 index 4f4957f..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/dns.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// DNS look-up functions based on the udp client -// Author: Guido Socher -// Copyright: GPL V2 -// -// 2010-05-20 - -#include "EtherCard_STM.h" -#include "net.h" - -#define gPB ether.buffer - -static byte dnstid_l; // a counter for transaction ID -#define DNSCLIENT_SRC_PORT_H 0xE0 - -static void dnsRequest (const char *hostname, bool fromRam) { - ++dnstid_l; // increment for next request, finally wrap - if (ether.dnsip[0] == 0) - memset(ether.dnsip, 8, 4); // use 8.8.8.8 Google DNS as default - ether.udpPrepare((DNSCLIENT_SRC_PORT_H << 8) | dnstid_l, ether.dnsip, 53); - memset(gPB + UDP_DATA_P, 0, 12); - - byte *p = gPB + UDP_DATA_P + 12; - char c; - do { - byte n = 0; - for(;;) { - c = fromRam ? *hostname : pgm_read_byte(hostname); - ++hostname; - if (c == '.' || c == 0) - break; - p[++n] = c; - } - *p++ = n; - p += n; - } while (c != 0); - - *p++ = 0; // terminate with zero, means root domain. - *p++ = 0; - *p++ = 1; // type A - *p++ = 0; - *p++ = 1; // class IN - byte i = p - gPB - UDP_DATA_P; - gPB[UDP_DATA_P] = i; - gPB[UDP_DATA_P+1] = dnstid_l; - gPB[UDP_DATA_P+2] = 1; // flags, standard recursive query - gPB[UDP_DATA_P+5] = 1; // 1 question - ether.udpTransmit(i); -} - -/** @brief Check if packet is DNS response. - @param plen Size of packet - @return bool True if DNS response has error. False if not DNS response or DNS response OK. - @note hisip contains IP address of requested host or 0.0.0.0 on failure -*/ -static bool checkForDnsAnswer (uint16_t plen) { - byte *p = gPB + UDP_DATA_P; //start of UDP payload - if (plen < 70 || gPB[UDP_SRC_PORT_L_P] != 53 || //from DNS source port - gPB[UDP_DST_PORT_H_P] != DNSCLIENT_SRC_PORT_H || //response to same port as we sent from (MSB) - gPB[UDP_DST_PORT_L_P] != dnstid_l || //response to same port as we sent from (LSB) - p[1] != dnstid_l) //message id same as we sent - return false; //not our DNS response - if((p[3] & 0x0F) != 0) - return true; //DNS response recieved with error - - p += *p; // we encoded the query len into tid - for (;;) { - if (*p & 0xC0) - p += 2; - else - while (++p < gPB + plen) { - if (*p == 0) { - ++p; - break; - } - } - if (p + 14 > gPB + plen) - break; - if (p[1] == 1 && p[9] == 4) { // type "A" and IPv4 - ether.copyIp(ether.hisip, p + 10); - break; - } - p += p[9] + 10; - } - return false; //No error -} - -// use during setup, as this discards all incoming requests until it returns -bool EtherCard::dnsLookup (const char* name, bool fromRam) { - uint16_t start = millis(); - - while(!isLinkUp()) - { - if ((uint16_t) (millis() - start) >= 30000) - return false; //timeout waiting for link - } - while(clientWaitingGw()) - { - packetLoop(packetReceive()); - if ((uint16_t) (millis() - start) >= 30000) - return false; //timeout waiting for gateway ARP - } - - memset(hisip, 0, 4); - dnsRequest(name, fromRam); - - start = millis(); - while (hisip[0] == 0) { - if ((uint16_t) (millis() - start) >= 30000) - return false; //timout waiting for dns response - uint16_t len = packetReceive(); - if (len > 0 && packetLoop(len) == 0) //packet not handled by tcp/ip packet loop - if(checkForDnsAnswer(len)) - return false; //DNS response recieved with error - } - - return true; -} diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/enc28j60.cpp b/GD32F1/libraries/Serasidis_EtherCard_STM/src/enc28j60.cpp deleted file mode 100644 index db8b673..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/enc28j60.cpp +++ /dev/null @@ -1,624 +0,0 @@ -// Microchip ENC28J60 Ethernet Interface Driver -// Author: Guido Socher -// Copyright: GPL V2 -// -// Based on the enc28j60.c file from the AVRlib library by Pascal Stang. -// For AVRlib See http://www.procyonengineering.com/ -// Used with explicit permission of Pascal Stang. -// -// 2010-05-20 -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -//----------------------------------------------------------------- - -#if ARDUINO >= 100 -#include // Arduino 1.0 -#else -#include // Arduino 0022 -#endif -#include "enc28j60.h" -#include // Using library SPI in folder: D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI - -uint16_t ENC28J60::bufferSize; -bool ENC28J60::broadcast_enabled = false; - -// ENC28J60 Control Registers -// Control register definitions are a combination of address, -// bank number, and Ethernet/MAC/PHY indicator bits. -// - Register address (bits 0-4) -// - Bank number (bits 5-6) -// - MAC/PHY indicator (bit 7) -#define ADDR_MASK 0x1F -#define BANK_MASK 0x60 -#define SPRD_MASK 0x80 -// All-bank registers -#define EIE 0x1B -#define EIR 0x1C -#define ESTAT 0x1D -#define ECON2 0x1E -#define ECON1 0x1F -// Bank 0 registers -#define ERDPT (0x00|0x00) -#define EWRPT (0x02|0x00) -#define ETXST (0x04|0x00) -#define ETXND (0x06|0x00) -#define ERXST (0x08|0x00) -#define ERXND (0x0A|0x00) -#define ERXRDPT (0x0C|0x00) -// #define ERXWRPT (0x0E|0x00) -#define EDMAST (0x10|0x00) -#define EDMAND (0x12|0x00) -// #define EDMADST (0x14|0x00) -#define EDMACS (0x16|0x00) -// Bank 1 registers -#define EHT0 (0x00|0x20) -#define EHT1 (0x01|0x20) -#define EHT2 (0x02|0x20) -#define EHT3 (0x03|0x20) -#define EHT4 (0x04|0x20) -#define EHT5 (0x05|0x20) -#define EHT6 (0x06|0x20) -#define EHT7 (0x07|0x20) -#define EPMM0 (0x08|0x20) -#define EPMM1 (0x09|0x20) -#define EPMM2 (0x0A|0x20) -#define EPMM3 (0x0B|0x20) -#define EPMM4 (0x0C|0x20) -#define EPMM5 (0x0D|0x20) -#define EPMM6 (0x0E|0x20) -#define EPMM7 (0x0F|0x20) -#define EPMCS (0x10|0x20) -// #define EPMO (0x14|0x20) -#define EWOLIE (0x16|0x20) -#define EWOLIR (0x17|0x20) -#define ERXFCON (0x18|0x20) -#define EPKTCNT (0x19|0x20) -// Bank 2 registers -#define MACON1 (0x00|0x40|0x80) -#define MACON2 (0x01|0x40|0x80) -#define MACON3 (0x02|0x40|0x80) -#define MACON4 (0x03|0x40|0x80) -#define MABBIPG (0x04|0x40|0x80) -#define MAIPG (0x06|0x40|0x80) -#define MACLCON1 (0x08|0x40|0x80) -#define MACLCON2 (0x09|0x40|0x80) -#define MAMXFL (0x0A|0x40|0x80) -#define MAPHSUP (0x0D|0x40|0x80) -#define MICON (0x11|0x40|0x80) -#define MICMD (0x12|0x40|0x80) -#define MIREGADR (0x14|0x40|0x80) -#define MIWR (0x16|0x40|0x80) -#define MIRD (0x18|0x40|0x80) -// Bank 3 registers -#define MAADR1 (0x00|0x60|0x80) -#define MAADR0 (0x01|0x60|0x80) -#define MAADR3 (0x02|0x60|0x80) -#define MAADR2 (0x03|0x60|0x80) -#define MAADR5 (0x04|0x60|0x80) -#define MAADR4 (0x05|0x60|0x80) -#define EBSTSD (0x06|0x60) -#define EBSTCON (0x07|0x60) -#define EBSTCS (0x08|0x60) -#define MISTAT (0x0A|0x60|0x80) -#define EREVID (0x12|0x60) -#define ECOCON (0x15|0x60) -#define EFLOCON (0x17|0x60) -#define EPAUS (0x18|0x60) - -// ENC28J60 ERXFCON Register Bit Definitions -#define ERXFCON_UCEN 0x80 -#define ERXFCON_ANDOR 0x40 -#define ERXFCON_CRCEN 0x20 -#define ERXFCON_PMEN 0x10 -#define ERXFCON_MPEN 0x08 -#define ERXFCON_HTEN 0x04 -#define ERXFCON_MCEN 0x02 -#define ERXFCON_BCEN 0x01 -// ENC28J60 EIE Register Bit Definitions -#define EIE_INTIE 0x80 -#define EIE_PKTIE 0x40 -#define EIE_DMAIE 0x20 -#define EIE_LINKIE 0x10 -#define EIE_TXIE 0x08 -#define EIE_WOLIE 0x04 -#define EIE_TXERIE 0x02 -#define EIE_RXERIE 0x01 -// ENC28J60 EIR Register Bit Definitions -#define EIR_PKTIF 0x40 -#define EIR_DMAIF 0x20 -#define EIR_LINKIF 0x10 -#define EIR_TXIF 0x08 -#define EIR_WOLIF 0x04 -#define EIR_TXERIF 0x02 -#define EIR_RXERIF 0x01 -// ENC28J60 ESTAT Register Bit Definitions -#define ESTAT_INT 0x80 -#define ESTAT_LATECOL 0x10 -#define ESTAT_RXBUSY 0x04 -#define ESTAT_TXABRT 0x02 -#define ESTAT_CLKRDY 0x01 -// ENC28J60 ECON2 Register Bit Definitions -#define ECON2_AUTOINC 0x80 -#define ECON2_PKTDEC 0x40 -#define ECON2_PWRSV 0x20 -#define ECON2_VRPS 0x08 -// ENC28J60 ECON1 Register Bit Definitions -#define ECON1_TXRST 0x80 -#define ECON1_RXRST 0x40 -#define ECON1_DMAST 0x20 -#define ECON1_CSUMEN 0x10 -#define ECON1_TXRTS 0x08 -#define ECON1_RXEN 0x04 -#define ECON1_BSEL1 0x02 -#define ECON1_BSEL0 0x01 -// ENC28J60 MACON1 Register Bit Definitions -#define MACON1_LOOPBK 0x10 -#define MACON1_TXPAUS 0x08 -#define MACON1_RXPAUS 0x04 -#define MACON1_PASSALL 0x02 -#define MACON1_MARXEN 0x01 -// ENC28J60 MACON2 Register Bit Definitions -#define MACON2_MARST 0x80 -#define MACON2_RNDRST 0x40 -#define MACON2_MARXRST 0x08 -#define MACON2_RFUNRST 0x04 -#define MACON2_MATXRST 0x02 -#define MACON2_TFUNRST 0x01 -// ENC28J60 MACON3 Register Bit Definitions -#define MACON3_PADCFG2 0x80 -#define MACON3_PADCFG1 0x40 -#define MACON3_PADCFG0 0x20 -#define MACON3_TXCRCEN 0x10 -#define MACON3_PHDRLEN 0x08 -#define MACON3_HFRMLEN 0x04 -#define MACON3_FRMLNEN 0x02 -#define MACON3_FULDPX 0x01 -// ENC28J60 MICMD Register Bit Definitions -#define MICMD_MIISCAN 0x02 -#define MICMD_MIIRD 0x01 -// ENC28J60 MISTAT Register Bit Definitions -#define MISTAT_NVALID 0x04 -#define MISTAT_SCAN 0x02 -#define MISTAT_BUSY 0x01 - -// ENC28J60 EBSTCON Register Bit Definitions -#define EBSTCON_PSV2 0x80 -#define EBSTCON_PSV1 0x40 -#define EBSTCON_PSV0 0x20 -#define EBSTCON_PSEL 0x10 -#define EBSTCON_TMSEL1 0x08 -#define EBSTCON_TMSEL0 0x04 -#define EBSTCON_TME 0x02 -#define EBSTCON_BISTST 0x01 - -// PHY registers -#define PHCON1 0x00 -#define PHSTAT1 0x01 -#define PHHID1 0x02 -#define PHHID2 0x03 -#define PHCON2 0x10 -#define PHSTAT2 0x11 -#define PHIE 0x12 -#define PHIR 0x13 -#define PHLCON 0x14 - -// ENC28J60 PHY PHCON1 Register Bit Definitions -#define PHCON1_PRST 0x8000 -#define PHCON1_PLOOPBK 0x4000 -#define PHCON1_PPWRSV 0x0800 -#define PHCON1_PDPXMD 0x0100 -// ENC28J60 PHY PHSTAT1 Register Bit Definitions -#define PHSTAT1_PFDPX 0x1000 -#define PHSTAT1_PHDPX 0x0800 -#define PHSTAT1_LLSTAT 0x0004 -#define PHSTAT1_JBSTAT 0x0002 -// ENC28J60 PHY PHCON2 Register Bit Definitions -#define PHCON2_FRCLINK 0x4000 -#define PHCON2_TXDIS 0x2000 -#define PHCON2_JABBER 0x0400 -#define PHCON2_HDLDIS 0x0100 - -// ENC28J60 Packet Control Byte Bit Definitions -#define PKTCTRL_PHUGEEN 0x08 -#define PKTCTRL_PPADEN 0x04 -#define PKTCTRL_PCRCEN 0x02 -#define PKTCTRL_POVERRIDE 0x01 - -// SPI operation codes -#define ENC28J60_READ_CTRL_REG 0x00 -#define ENC28J60_READ_BUF_MEM 0x3A -#define ENC28J60_WRITE_CTRL_REG 0x40 -#define ENC28J60_WRITE_BUF_MEM 0x7A -#define ENC28J60_BIT_FIELD_SET 0x80 -#define ENC28J60_BIT_FIELD_CLR 0xA0 -#define ENC28J60_SOFT_RESET 0xFF - -// The RXSTART_INIT must be zero. See Rev. B4 Silicon Errata point 5. -// Buffer boundaries applied to internal 8K ram -// the entire available packet buffer space is allocated - -#define RXSTART_INIT 0x0000 // start of RX buffer, room for 2 packets -#define RXSTOP_INIT 0x0BFF // end of RX buffer - -#define TXSTART_INIT 0x0C00 // start of TX buffer, room for 1 packet -#define TXSTOP_INIT 0x11FF // end of TX buffer - -#define SCRATCH_START 0x1200 // start of scratch area -#define SCRATCH_LIMIT 0x2000 // past end of area, i.e. 3.5 Kb -#define SCRATCH_PAGE_SHIFT 6 // addressing is in pages of 64 bytes -#define SCRATCH_PAGE_SIZE (1 << SCRATCH_PAGE_SHIFT) - -// max frame length which the conroller will accept: -// (note: maximum ethernet frame length would be 1518) -#define MAX_FRAMELEN 1500 - -#define FULL_SPEED 1 // switch to full-speed SPI for bulk transfers - -static byte Enc28j60Bank; -static int gNextPacketPtr; -static byte selectPin; - -void ENC28J60::initSPI () { - - SPI.begin(); - SPI.setBitOrder(MSBFIRST); - //SPI.setDataMode(SPI_MODE0); - //SPI.setClockDivider(SPI_CLOCK_DIV16); -} - -static void enableChip () { - //cli(); - digitalWrite(selectPin, LOW); -} - -static void disableChip () { - digitalWrite(selectPin, HIGH); - //sei(); -} - -//static void xferSPI (byte data) { - //SPDR = data; - //while (!(SPSR&(1<>5); - } -} - -static byte readRegByte (byte address) { - SetBank(address); - return readOp(ENC28J60_READ_CTRL_REG, address); -} - -static uint16_t readReg(byte address) { - return readRegByte(address) + (readRegByte(address+1) << 8); -} - -static void writeRegByte (byte address, byte data) { - SetBank(address); - writeOp(ENC28J60_WRITE_CTRL_REG, address, data); -} - -static void writeReg(byte address, uint16_t data) { - writeRegByte(address, data); - writeRegByte(address + 1, data >> 8); -} - -static uint16_t readPhyByte (byte address) { - writeRegByte(MIREGADR, address); - writeRegByte(MICMD, MICMD_MIIRD); - while (readRegByte(MISTAT) & MISTAT_BUSY) - ; - writeRegByte(MICMD, 0x00); - return readRegByte(MIRD+1); -} - -static void writePhy (byte address, uint16_t data) { - writeRegByte(MIREGADR, address); - writeReg(MIWR, data); - while (readRegByte(MISTAT) & MISTAT_BUSY) - ; -} - -byte ENC28J60::initialize (uint16_t size, const byte* macaddr, byte csPin) { - - bufferSize = size; - //if (bitRead(SPCR, SPE) == 0) - initSPI(); - selectPin = csPin; - pinMode(selectPin, OUTPUT); - disableChip(); - - writeOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET); - delay(2); // errata B7/2 - while (!readOp(ENC28J60_READ_CTRL_REG, ESTAT) & ESTAT_CLKRDY) - ; - gNextPacketPtr = RXSTART_INIT; - writeReg(ERXST, RXSTART_INIT); - writeReg(ERXRDPT, RXSTART_INIT); - writeReg(ERXND, RXSTOP_INIT); - writeReg(ETXST, TXSTART_INIT); - writeReg(ETXND, TXSTOP_INIT); - enableBroadcast(); // change to add ERXFCON_BCEN recommended by epam - writeReg(EPMM0, 0x303f); - writeReg(EPMCS, 0xf7f9); - writeRegByte(MACON1, MACON1_MARXEN|MACON1_TXPAUS|MACON1_RXPAUS); - writeRegByte(MACON2, 0x00); - writeOp(ENC28J60_BIT_FIELD_SET, MACON3, - MACON3_PADCFG0|MACON3_TXCRCEN|MACON3_FRMLNEN); - writeReg(MAIPG, 0x0C12); - writeRegByte(MABBIPG, 0x12); - writeReg(MAMXFL, MAX_FRAMELEN); - writeRegByte(MAADR5, macaddr[0]); - writeRegByte(MAADR4, macaddr[1]); - writeRegByte(MAADR3, macaddr[2]); - writeRegByte(MAADR2, macaddr[3]); - writeRegByte(MAADR1, macaddr[4]); - writeRegByte(MAADR0, macaddr[5]); - writePhy(PHCON2, PHCON2_HDLDIS); - SetBank(ECON1); - writeOp(ENC28J60_BIT_FIELD_SET, EIE, EIE_INTIE|EIE_PKTIE); - writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN); - - byte rev = readRegByte(EREVID); - // microchip forgot to step the number on the silcon when they - // released the revision B7. 6 is now rev B7. We still have - // to see what they do when they release B8. At the moment - // there is no B8 out yet - if (rev > 5) ++rev; - return rev; -} - -bool ENC28J60::isLinkUp() { - return (readPhyByte(PHSTAT2) >> 2) & 1; -} - -void ENC28J60::packetSend(uint16_t len) { - while (readOp(ENC28J60_READ_CTRL_REG, ECON1) & ECON1_TXRTS) - if (readRegByte(EIR) & EIR_TXERIF) { - writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST); - writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST); - } - writeReg(EWRPT, TXSTART_INIT); - writeReg(ETXND, TXSTART_INIT+len); - writeOp(ENC28J60_WRITE_BUF_MEM, 0, 0x00); - writeBuf(len, buffer); - writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRTS); -} - -uint16_t ENC28J60::packetReceive() { - uint16_t len = 0; - if (readRegByte(EPKTCNT) > 0) { - writeReg(ERDPT, gNextPacketPtr); - - struct { - uint16_t nextPacket; - uint16_t byteCount; - uint16_t status; - } header; - - readBuf(sizeof header, (byte*) &header); - - gNextPacketPtr = header.nextPacket; - len = header.byteCount - 4; //remove the CRC count - if (len>bufferSize-1) - len=bufferSize-1; - if ((header.status & 0x80)==0) - len = 0; - else - readBuf(len, buffer); - buffer[len] = 0; - if (gNextPacketPtr - 1 > RXSTOP_INIT) - writeReg(ERXRDPT, RXSTOP_INIT); - else - writeReg(ERXRDPT, gNextPacketPtr - 1); - writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PKTDEC); - } - return len; -} - -void ENC28J60::copyout (byte page, const byte* data) { - uint16_t destPos = SCRATCH_START + (page << SCRATCH_PAGE_SHIFT); - if (destPos < SCRATCH_START || destPos > SCRATCH_LIMIT - SCRATCH_PAGE_SIZE) - return; - writeReg(EWRPT, destPos); - writeBuf(SCRATCH_PAGE_SIZE, data); -} - -void ENC28J60::copyin (byte page, byte* data) { - uint16_t destPos = SCRATCH_START + (page << SCRATCH_PAGE_SHIFT); - if (destPos < SCRATCH_START || destPos > SCRATCH_LIMIT - SCRATCH_PAGE_SIZE) - return; - writeReg(ERDPT, destPos); - readBuf(SCRATCH_PAGE_SIZE, data); -} - -byte ENC28J60::peekin (byte page, byte off) { - byte result = 0; - uint16_t destPos = SCRATCH_START + (page << SCRATCH_PAGE_SHIFT) + off; - if (SCRATCH_START <= destPos && destPos < SCRATCH_LIMIT) { - writeReg(ERDPT, destPos); - readBuf(1, &result); - } - return result; -} - -// Contributed by Alex M. Based on code from: http://blog.derouineau.fr -// /2011/07/putting-enc28j60-ethernet-controler-in-sleep-mode/ -void ENC28J60::powerDown() { - writeOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_RXEN); - while(readRegByte(ESTAT) & ESTAT_RXBUSY); - while(readRegByte(ECON1) & ECON1_TXRTS); - writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_VRPS); - writeOp(ENC28J60_BIT_FIELD_SET, ECON2, ECON2_PWRSV); -} - -void ENC28J60::powerUp() { - writeOp(ENC28J60_BIT_FIELD_CLR, ECON2, ECON2_PWRSV); - while(!readRegByte(ESTAT) & ESTAT_CLKRDY); - writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_RXEN); -} - -void ENC28J60::enableBroadcast (bool temporary) { - writeRegByte(ERXFCON, readRegByte(ERXFCON) | ERXFCON_BCEN); - if(!temporary) - broadcast_enabled = true; -} - -void ENC28J60::disableBroadcast (bool temporary) { - if(!temporary) - broadcast_enabled = false; - if(!broadcast_enabled) - writeRegByte(ERXFCON, readRegByte(ERXFCON) & ~ERXFCON_BCEN); -} - -void ENC28J60::enableMulticast () { - writeRegByte(ERXFCON, readRegByte(ERXFCON) | ERXFCON_MCEN); -} - -void ENC28J60::disableMulticast () { - writeRegByte(ERXFCON, readRegByte(ERXFCON) & ~ERXFCON_MCEN); -} - -uint8_t ENC28J60::doBIST ( byte csPin) { -#define RANDOM_FILL 0b0000 -#define ADDRESS_FILL 0b0100 -#define PATTERN_SHIFT 0b1000 -#define RANDOM_RACE 0b1100 - -// init - //if (bitRead(SPCR, SPE) == 0) - // initSPI(); - selectPin = csPin; - pinMode(selectPin, OUTPUT); - disableChip(); - - writeOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET); - delay(2); // errata B7/2 - while (!readOp(ENC28J60_READ_CTRL_REG, ESTAT) & ESTAT_CLKRDY) ; - - - // now we can start the memory test - - uint16_t macResult; - uint16_t bitsResult; - - // clear some of the registers registers - writeRegByte(ECON1, 0); - writeReg(EDMAST, 0); - - // Set up necessary pointers for the DMA to calculate over the entire memory - writeReg(EDMAND, 0x1FFFu); - writeReg(ERXND, 0x1FFFu); - - // Enable Test Mode and do an Address Fill - SetBank(EBSTCON); - writeRegByte(EBSTCON, EBSTCON_TME | EBSTCON_BISTST | ADDRESS_FILL); - - // wait for BISTST to be reset, only after that are we actually ready to - // start the test - // this was undocumented :( - while (readOp(ENC28J60_READ_CTRL_REG, EBSTCON) & EBSTCON_BISTST); - writeOp(ENC28J60_BIT_FIELD_CLR, EBSTCON, EBSTCON_TME); - - - // now start the actual reading an calculating the checksum until the end is - // reached - writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_DMAST | ECON1_CSUMEN); - SetBank(EDMACS); - while(readOp(ENC28J60_READ_CTRL_REG, ECON1) & ECON1_DMAST); - macResult = readReg(EDMACS); - bitsResult = readReg(EBSTCS); - // Compare the results - // 0xF807 should always be generated in Address fill mode - if ((macResult != bitsResult) || (bitsResult != 0xF807)) { - return 0; - } - // reset test flag - writeOp(ENC28J60_BIT_FIELD_CLR, EBSTCON, EBSTCON_TME); - - - // Now start the BIST with random data test, and also keep on swapping the - // DMA/BIST memory ports. - writeRegByte(EBSTSD, 0b10101010 | millis()); - writeRegByte(EBSTCON, EBSTCON_TME | EBSTCON_PSEL | EBSTCON_BISTST | RANDOM_FILL); - - - // wait for BISTST to be reset, only after that are we actually ready to - // start the test - // this was undocumented :( - while (readOp(ENC28J60_READ_CTRL_REG, EBSTCON) & EBSTCON_BISTST); - writeOp(ENC28J60_BIT_FIELD_CLR, EBSTCON, EBSTCON_TME); - - - // now start the actual reading an calculating the checksum until the end is - // reached - writeOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_DMAST | ECON1_CSUMEN); - SetBank(EDMACS); - while(readOp(ENC28J60_READ_CTRL_REG, ECON1) & ECON1_DMAST); - - macResult = readReg(EDMACS); - bitsResult = readReg(EBSTCS); - // The checksum should be equal - return macResult == bitsResult; -} - diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/enc28j60.h b/GD32F1/libraries/Serasidis_EtherCard_STM/src/enc28j60.h deleted file mode 100644 index d5007d8..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/enc28j60.h +++ /dev/null @@ -1,129 +0,0 @@ -// Microchip ENC28J60 Ethernet Interface Driver -// Author: Pascal Stang -// Modified by: Guido Socher -// Copyright: GPL V2 -// -// This driver provides initialization and transmit/receive -// functions for the Microchip ENC28J60 10Mb Ethernet Controller and PHY. -// This chip is novel in that it is a full MAC+PHY interface all in a 28-pin -// chip, using an SPI interface to the host processor. -// -// 2010-05-20 -// -//----------------------------------------------------------------- -// Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 -// Home: http://www.serasidis.gr -// email: avrsite@yahoo.gr -// -// PIN Connections (Using STM32F103): -// -// ENC28J60 - STM32F103 -// VCC - 3.3V -// GND - GND -// SCK - Pin PA5 -// SO - Pin PA6 -// SI - Pin PA7 -// CS - Pin PA8 -//----------------------------------------------------------------- -#ifndef ENC28J60_H -#define ENC28J60_H - -/** This class provide low-level interfacing with the ENC28J60 network interface. This is used by the EtherCard class and not intended for use by (normal) end users. */ -class ENC28J60 { -public: - static uint8_t buffer[]; //!< Data buffer (shared by recieve and transmit) - static uint16_t bufferSize; //!< Size of data buffer - static bool broadcast_enabled; //!< True if broadcasts enabled (used to allow temporary disable of broadcast for DHCP or other internal functions) - - static uint8_t* tcpOffset () { return buffer + 0x36; } //!< Pointer to the start of TCP payload - - /** @brief Initialise SPI interface - * @note Configures Arduino pins as input / output, etc. - */ - static void initSPI (); - - /** @brief Initialise network interface - * @param size Size of data buffer - * @param macaddr Pointer to 6 byte hardware (MAC) address - * @param csPin Arduino pin used for chip select (enable network interface SPI bus). Default = 8 = PA9 - * @return uint8_t ENC28J60 firmware version or zero on failure. - */ - static uint8_t initialize (const uint16_t size, const uint8_t* macaddr, - uint8_t csPin = PA8); - - /** @brief Check if network link is connected - * @return bool True if link is up - */ - static bool isLinkUp (); - - /** @brief Sends data to network interface - * @param len Size of data to send - * @note Data buffer is shared by recieve and transmit functions - */ - static void packetSend (uint16_t len); - - /** @brief Copy recieved packets to data buffer - * @return uint16_t Size of recieved data - * @note Data buffer is shared by recieve and transmit functions - */ - static uint16_t packetReceive (); - - /** @brief Copy data from ENC28J60 memory - * @param page Data page of memory - * @param data Pointer to buffer to copy data to - */ - static void copyout (uint8_t page, const uint8_t* data); - - /** @brief Copy data to ENC28J60 memory - * @param page Data page of memory - * @param data Pointer to buffer to copy data from - */ - static void copyin (uint8_t page, uint8_t* data); - - /** @brief Get single byte of data from ENC28J60 memory - * @param page Data page of memory - * @param off Offset of data within page - * @return Data value - */ - static uint8_t peekin (uint8_t page, uint8_t off); - - /** @brief Put ENC28J60 in sleep mode - */ - static void powerDown(); // contrib by Alex M. - - /** @brief Wake ENC28J60 from sleep mode - */ - static void powerUp(); // contrib by Alex M. - - /** @brief Enable reception of broadcast messages - * @param temporary Set true to temporarily enable broadcast - * @note This will increase load on recieved data handling - */ - static void enableBroadcast(bool temporary = false); - - /** @brief Disable reception of broadcast messages - * @param temporary Set true to only disable if temporarily enabled - * @note This will reduce load on recieved data handling - */ - static void disableBroadcast(bool temporary = false); - - /** @brief Enables reception of mulitcast messages - * @note This will increase load on recieved data handling - */ - static void enableMulticast (); - - /** @brief Disable reception of mulitcast messages - * @note This will reduce load on recieved data handling - */ - static void disableMulticast(); - - /** @brief Reset and fully initialise ENC28J60 - * @param csPin Arduino pin used for chip select (enable SPI bus) - * @return uint8_t 0 on failure - */ - static uint8_t doBIST(uint8_t csPin = PA8); -}; - -typedef ENC28J60 Ethernet; //!< Define alias Ethernet for ENC28J60 - -#endif diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/net.h b/GD32F1/libraries/Serasidis_EtherCard_STM/src/net.h deleted file mode 100644 index a80c5b9..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/net.h +++ /dev/null @@ -1,123 +0,0 @@ -// Based on the net.h file from the AVRlib library by Pascal Stang. -// Author: Guido Socher -// Copyright: GPL V2 -// -// For AVRlib See http://www.procyonengineering.com/ -// Used with explicit permission of Pascal Stang. -// -// 2010-05-20 - -// notation: _P = position of a field -// _V = value of a field - -#ifndef NET_H -#define NET_H - -// ******* ETH ******* -#define ETH_HEADER_LEN 14 -// values of certain bytes: -#define ETHTYPE_ARP_H_V 0x08 -#define ETHTYPE_ARP_L_V 0x06 -#define ETHTYPE_IP_H_V 0x08 -#define ETHTYPE_IP_L_V 0x00 -// byte positions in the ethernet frame: -// -// Ethernet type field (2bytes): -#define ETH_TYPE_H_P 12 -#define ETH_TYPE_L_P 13 -// -#define ETH_DST_MAC 0 -#define ETH_SRC_MAC 6 - - -// ******* ARP ******* -#define ETH_ARP_OPCODE_REPLY_H_V 0x0 -#define ETH_ARP_OPCODE_REPLY_L_V 0x02 -#define ETH_ARP_OPCODE_REQ_H_V 0x0 -#define ETH_ARP_OPCODE_REQ_L_V 0x01 -// start of arp header: -#define ETH_ARP_P 0xe -// -#define ETHTYPE_ARP_L_V 0x06 -// arp.dst.ip -#define ETH_ARP_DST_IP_P 0x26 -// arp.opcode -#define ETH_ARP_OPCODE_H_P 0x14 -#define ETH_ARP_OPCODE_L_P 0x15 -// arp.src.mac -#define ETH_ARP_SRC_MAC_P 0x16 -#define ETH_ARP_SRC_IP_P 0x1c -#define ETH_ARP_DST_MAC_P 0x20 -#define ETH_ARP_DST_IP_P 0x26 - -// ******* IP ******* -#define IP_HEADER_LEN 20 -// ip.src -#define IP_SRC_P 0x1a -#define IP_DST_P 0x1e -#define IP_HEADER_LEN_VER_P 0xe -#define IP_CHECKSUM_P 0x18 -#define IP_TTL_P 0x16 -#define IP_FLAGS_P 0x14 -#define IP_P 0xe -#define IP_TOTLEN_H_P 0x10 -#define IP_TOTLEN_L_P 0x11 - -#define IP_PROTO_P 0x17 - -#define IP_PROTO_ICMP_V 1 -#define IP_PROTO_TCP_V 6 -// 17=0x11 -#define IP_PROTO_UDP_V 17 -// ******* ICMP ******* -#define ICMP_TYPE_ECHOREPLY_V 0 -#define ICMP_TYPE_ECHOREQUEST_V 8 -// -#define ICMP_TYPE_P 0x22 -#define ICMP_CHECKSUM_P 0x24 -#define ICMP_CHECKSUM_H_P 0x24 -#define ICMP_CHECKSUM_L_P 0x25 -#define ICMP_IDENT_H_P 0x26 -#define ICMP_IDENT_L_P 0x27 -#define ICMP_DATA_P 0x2a - -// ******* UDP ******* -#define UDP_HEADER_LEN 8 -// -#define UDP_SRC_PORT_H_P 0x22 -#define UDP_SRC_PORT_L_P 0x23 -#define UDP_DST_PORT_H_P 0x24 -#define UDP_DST_PORT_L_P 0x25 -// -#define UDP_LEN_H_P 0x26 -#define UDP_LEN_L_P 0x27 -#define UDP_CHECKSUM_H_P 0x28 -#define UDP_CHECKSUM_L_P 0x29 -#define UDP_DATA_P 0x2a - -// ******* TCP ******* -#define TCP_SRC_PORT_H_P 0x22 -#define TCP_SRC_PORT_L_P 0x23 -#define TCP_DST_PORT_H_P 0x24 -#define TCP_DST_PORT_L_P 0x25 -// the tcp seq number is 4 bytes 0x26-0x29 -#define TCP_SEQ_H_P 0x26 -#define TCP_SEQACK_H_P 0x2a -// flags: SYN=2 -#define TCP_FLAGS_P 0x2f -#define TCP_FLAGS_SYN_V 2 -#define TCP_FLAGS_FIN_V 1 -#define TCP_FLAGS_RST_V 4 -#define TCP_FLAGS_PUSH_V 8 -#define TCP_FLAGS_SYNACK_V 0x12 -#define TCP_FLAGS_ACK_V 0x10 -#define TCP_FLAGS_PSHACK_V 0x18 -// plain len without the options: -#define TCP_HEADER_LEN_PLAIN 20 -#define TCP_HEADER_LEN_P 0x2e -#define TCP_WIN_SIZE 0x30 -#define TCP_CHECKSUM_H_P 0x32 -#define TCP_CHECKSUM_L_P 0x33 -#define TCP_OPTIONS_P 0x36 -// -#endif diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/tcpip.cpp b/GD32F1/libraries/Serasidis_EtherCard_STM/src/tcpip.cpp deleted file mode 100644 index 4713e8c..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/tcpip.cpp +++ /dev/null @@ -1,803 +0,0 @@ -// IP, ARP, UDP and TCP functions. -// Author: Guido Socher -// Copyright: GPL V2 -// -// The TCP implementation uses some size optimisations which are valid -// only if all data can be sent in one single packet. This is however -// not a big limitation for a microcontroller as you will anyhow use -// small web-pages. The web server must send the entire web page in one -// packet. The client "web browser" as implemented here can also receive -// large pages. -// -// 2010-05-20 - -#include "EtherCard_STM.h" -#include "net.h" -#undef word // arduino nonsense - -#define gPB ether.buffer - -#define PINGPATTERN 0x42 - -// Avoid spurious pgmspace warnings - http://forum.jeelabs.net/node/327 -// See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734 -//#undef PROGMEM -//#define PROGMEM __attribute__(( section(".progmem.data") )) -//#undef PSTR -//#define PSTR(s) (__extension__({static prog_char c[] PROGMEM = (s); &c[0];})) - -#define TCPCLIENT_SRC_PORT_H 11 //Source port (MSB) for TCP/IP client connections - hardcode all TCP/IP client connection from ports in range 2816-3071 -static uint8_t tcpclient_src_port_l=1; // Source port (LSB) for tcp/ip client connections - increments on each TCP/IP request -static uint8_t tcp_fd; // a file descriptor, will be encoded into the port -static uint8_t tcp_client_state; //TCP connection state: 1=Send SYN, 2=SYN sent awaiting SYN+ACK, 3=Established, 4=Not used, 5=Closing, 6=Closed -static uint8_t tcp_client_port_h; // Destination port (MSB) of TCP/IP client connection -static uint8_t tcp_client_port_l; // Destination port (LSB) of TCP/IP client connection -static uint8_t (*client_tcp_result_cb)(uint8_t,uint8_t,uint16_t,uint16_t); // Pointer to callback function to handle response to current TCP/IP request -static uint16_t (*client_tcp_datafill_cb)(uint8_t); //Pointer to callback function to handle payload data in response to current TCP/IP request -static uint8_t www_fd; // ID of current http request (only one http request at a time - one of the 8 possible concurrent TCP/IP connections) -static void (*client_browser_cb)(uint8_t,uint16_t,uint16_t); // Pointer to callback function to handle result of current HTTP request -static const char *client_additionalheaderline; // Pointer to c-string additional http request header info -static const char *client_postval; -static const char *client_urlbuf; // Pointer to c-string path part of HTTP request URL -static const char *client_urlbuf_var; // Pointer to c-string filename part of HTTP request URL -static const char *client_hoststr; // Pointer to c-string hostname of current HTTP request -static void (*icmp_cb)(uint8_t *ip); // Pointer to callback function for ICMP ECHO response handler (triggers when localhost recieves ping respnse (pong)) -static uint8_t destmacaddr[6]; // storing both dns server and destination mac addresses, but at different times because both are never needed at same time. -static boolean waiting_for_dns_mac = false; //might be better to use bit flags and bitmask operations for these conditions -static boolean has_dns_mac = false; -static boolean waiting_for_dest_mac = false; -static boolean has_dest_mac = false; -static uint8_t gwmacaddr[6]; // Hardware (MAC) address of gateway router -static uint8_t waitgwmac; // Bitwise flags of gateway router status - see below for states -//Define gatweay router ARP statuses -#define WGW_INITIAL_ARP 1 // First request, no answer yet -#define WGW_HAVE_GW_MAC 2 // Have gateway router MAC -#define WGW_REFRESHING 4 // Refreshing but already have gateway MAC -#define WGW_ACCEPT_ARP_REPLY 8 // Accept an ARP reply - -static uint16_t info_data_len; // Length of TCP/IP payload -static uint8_t seqnum = 0xa; // My initial tcp sequence number -static uint8_t result_fd = 123; // Session id of last reply -static const char* result_ptr; // Pointer to TCP/IP data -static unsigned long SEQ; // TCP/IP sequence number - -#define CLIENTMSS 550 -#define TCP_DATA_START ((uint16_t)TCP_SRC_PORT_H_P+(gPB[TCP_HEADER_LEN_P]>>4)*4) // Get offset of TCP/IP payload data - -const unsigned char arpreqhdr[] PROGMEM = { 0,1,8,0,6,4,0,1 }; // ARP request header -const unsigned char iphdr[] PROGMEM = { 0x45,0,0,0x82,0,0,0x40,0,0x20 }; //IP header -const unsigned char ntpreqhdr[] PROGMEM = { 0xE3,0,4,0xFA,0,1,0,0,0,1 }; //NTP request header -const uint8_t allOnes[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // Used for hardware (MAC) and IP broadcast addresses - -static void fill_checksum(uint8_t dest, uint8_t off, uint16_t len,uint8_t type) { - const uint8_t* ptr = gPB + off; - uint32_t sum = type==1 ? IP_PROTO_UDP_V+len-8 : - type==2 ? IP_PROTO_TCP_V+len-8 : 0; - while(len >1) { - sum += (uint16_t) (((uint32_t)*ptr<<8)|*(ptr+1)); - ptr+=2; - len-=2; - } - if (len) - sum += ((uint32_t)*ptr)<<8; - while (sum>>16) - sum = (uint16_t) sum + (sum >> 16); - uint16_t ck = ~ (uint16_t) sum; - gPB[dest] = ck>>8; - gPB[dest+1] = ck; -} - -static void setMACs (const uint8_t *mac) { - EtherCard::copyMac(gPB + ETH_DST_MAC, mac); - EtherCard::copyMac(gPB + ETH_SRC_MAC, EtherCard::mymac); -} - -static void setMACandIPs (const uint8_t *mac, const uint8_t *dst) { - setMACs(mac); - EtherCard::copyIp(gPB + IP_DST_P, dst); - EtherCard::copyIp(gPB + IP_SRC_P, EtherCard::myip); -} - -static uint8_t check_ip_message_is_from(const uint8_t *ip) { - return memcmp(gPB + IP_SRC_P, ip, 4) == 0; -} - -static boolean is_lan(const uint8_t source[4], const uint8_t destination[4]) { - if(source[0] == 0 || destination[0] == 0) { - return false; - } - for(int i = 0; i < 4; i++) - if((source[i] & EtherCard::netmask[i]) != (destination[i] & EtherCard::netmask[i])) { - return false; - } - return true; -} - -static uint8_t eth_type_is_arp_and_my_ip(uint16_t len) { - return len >= 41 && gPB[ETH_TYPE_H_P] == ETHTYPE_ARP_H_V && - gPB[ETH_TYPE_L_P] == ETHTYPE_ARP_L_V && - memcmp(gPB + ETH_ARP_DST_IP_P, EtherCard::myip, 4) == 0; -} - -static uint8_t eth_type_is_ip_and_my_ip(uint16_t len) { - return len >= 42 && gPB[ETH_TYPE_H_P] == ETHTYPE_IP_H_V && - gPB[ETH_TYPE_L_P] == ETHTYPE_IP_L_V && - gPB[IP_HEADER_LEN_VER_P] == 0x45 && - (memcmp(gPB + IP_DST_P, EtherCard::myip, 4) == 0 //not my IP - || (memcmp(gPB + IP_DST_P, EtherCard::broadcastip, 4) == 0) //not subnet broadcast - || (memcmp(gPB + IP_DST_P, allOnes, 4) == 0)); //not global broadcasts - //!@todo Handle multicast -} - -static void fill_ip_hdr_checksum() { - gPB[IP_CHECKSUM_P] = 0; - gPB[IP_CHECKSUM_P+1] = 0; - gPB[IP_FLAGS_P] = 0x40; // don't fragment - gPB[IP_FLAGS_P+1] = 0; // fragement offset - gPB[IP_TTL_P] = 64; // ttl - fill_checksum(IP_CHECKSUM_P, IP_P, IP_HEADER_LEN,0); -} - -static void make_eth_ip() { - setMACs(gPB + ETH_SRC_MAC); - EtherCard::copyIp(gPB + IP_DST_P, gPB + IP_SRC_P); - EtherCard::copyIp(gPB + IP_SRC_P, EtherCard::myip); - fill_ip_hdr_checksum(); -} - -static void step_seq(uint16_t rel_ack_num,uint8_t cp_seq) { - uint8_t i; - uint8_t tseq; - i = 4; - while(i>0) { - rel_ack_num = gPB[TCP_SEQ_H_P+i-1]+rel_ack_num; - tseq = gPB[TCP_SEQACK_H_P+i-1]; - gPB[TCP_SEQACK_H_P+i-1] = rel_ack_num; - if (cp_seq) - gPB[TCP_SEQ_H_P+i-1] = tseq; - else - gPB[TCP_SEQ_H_P+i-1] = 0; // some preset value - rel_ack_num = rel_ack_num>>8; - i--; - } -} - -static void make_tcphead(uint16_t rel_ack_num,uint8_t cp_seq) { - uint8_t i = gPB[TCP_DST_PORT_H_P]; - gPB[TCP_DST_PORT_H_P] = gPB[TCP_SRC_PORT_H_P]; - gPB[TCP_SRC_PORT_H_P] = i; - uint8_t j = gPB[TCP_DST_PORT_L_P]; - gPB[TCP_DST_PORT_L_P] = gPB[TCP_SRC_PORT_L_P]; - gPB[TCP_SRC_PORT_L_P] = j; - step_seq(rel_ack_num,cp_seq); - gPB[TCP_CHECKSUM_H_P] = 0; - gPB[TCP_CHECKSUM_L_P] = 0; - gPB[TCP_HEADER_LEN_P] = 0x50; -} - -static void make_arp_answer_from_request() { - setMACs(gPB + ETH_SRC_MAC); - gPB[ETH_ARP_OPCODE_H_P] = ETH_ARP_OPCODE_REPLY_H_V; - gPB[ETH_ARP_OPCODE_L_P] = ETH_ARP_OPCODE_REPLY_L_V; - EtherCard::copyMac(gPB + ETH_ARP_DST_MAC_P, gPB + ETH_ARP_SRC_MAC_P); - EtherCard::copyMac(gPB + ETH_ARP_SRC_MAC_P, EtherCard::mymac); - EtherCard::copyIp(gPB + ETH_ARP_DST_IP_P, gPB + ETH_ARP_SRC_IP_P); - EtherCard::copyIp(gPB + ETH_ARP_SRC_IP_P, EtherCard::myip); - EtherCard::packetSend(42); -} - -static void make_echo_reply_from_request(uint16_t len) { - make_eth_ip(); - gPB[ICMP_TYPE_P] = ICMP_TYPE_ECHOREPLY_V; - if (gPB[ICMP_CHECKSUM_P] > (0xFF-0x08)) - gPB[ICMP_CHECKSUM_P+1]++; - gPB[ICMP_CHECKSUM_P] += 0x08; - EtherCard::packetSend(len); -} - -void EtherCard::makeUdpReply (const char *data,uint8_t datalen,uint16_t port) { - if (datalen>220) - datalen = 220; - gPB[IP_TOTLEN_H_P] = (IP_HEADER_LEN+UDP_HEADER_LEN+datalen) >>8; - gPB[IP_TOTLEN_L_P] = IP_HEADER_LEN+UDP_HEADER_LEN+datalen; - make_eth_ip(); - gPB[UDP_DST_PORT_H_P] = gPB[UDP_SRC_PORT_H_P]; - gPB[UDP_DST_PORT_L_P] = gPB[UDP_SRC_PORT_L_P]; - gPB[UDP_SRC_PORT_H_P] = port>>8; - gPB[UDP_SRC_PORT_L_P] = port; - gPB[UDP_LEN_H_P] = (UDP_HEADER_LEN+datalen) >> 8; - gPB[UDP_LEN_L_P] = UDP_HEADER_LEN+datalen; - gPB[UDP_CHECKSUM_H_P] = 0; - gPB[UDP_CHECKSUM_L_P] = 0; - memcpy(gPB + UDP_DATA_P, data, datalen); - fill_checksum(UDP_CHECKSUM_H_P, IP_SRC_P, 16 + datalen,1); - packetSend(UDP_HEADER_LEN+IP_HEADER_LEN+ETH_HEADER_LEN+datalen); -} - -static void make_tcp_synack_from_syn() { - gPB[IP_TOTLEN_H_P] = 0; - gPB[IP_TOTLEN_L_P] = IP_HEADER_LEN+TCP_HEADER_LEN_PLAIN+4; - make_eth_ip(); - gPB[TCP_FLAGS_P] = TCP_FLAGS_SYNACK_V; - make_tcphead(1,0); - gPB[TCP_SEQ_H_P+0] = 0; - gPB[TCP_SEQ_H_P+1] = 0; - gPB[TCP_SEQ_H_P+2] = seqnum; - gPB[TCP_SEQ_H_P+3] = 0; - seqnum += 3; - gPB[TCP_OPTIONS_P] = 2; - gPB[TCP_OPTIONS_P+1] = 4; - gPB[TCP_OPTIONS_P+2] = 0x05; - gPB[TCP_OPTIONS_P+3] = 0x0; - gPB[TCP_HEADER_LEN_P] = 0x60; - gPB[TCP_WIN_SIZE] = 0x5; // 1400=0x578 - gPB[TCP_WIN_SIZE+1] = 0x78; - fill_checksum(TCP_CHECKSUM_H_P, IP_SRC_P, 8+TCP_HEADER_LEN_PLAIN+4,2); - EtherCard::packetSend(IP_HEADER_LEN+TCP_HEADER_LEN_PLAIN+4+ETH_HEADER_LEN); -} - -static uint16_t get_tcp_data_len() { - int16_t i = (((int16_t)gPB[IP_TOTLEN_H_P])<<8)|gPB[IP_TOTLEN_L_P]; - i -= IP_HEADER_LEN; - i -= (gPB[TCP_HEADER_LEN_P]>>4)*4; // generate len in bytes; - if (i<=0) - i = 0; - return (uint16_t)i; -} - -static void make_tcp_ack_from_any(int16_t datlentoack,uint8_t addflags) { - gPB[TCP_FLAGS_P] = TCP_FLAGS_ACK_V|addflags; - if (addflags!=TCP_FLAGS_RST_V && datlentoack==0) - datlentoack = 1; - make_tcphead(datlentoack,1); // no options - uint16_t j = IP_HEADER_LEN+TCP_HEADER_LEN_PLAIN; - gPB[IP_TOTLEN_H_P] = j>>8; - gPB[IP_TOTLEN_L_P] = j; - make_eth_ip(); - gPB[TCP_WIN_SIZE] = 0x4; // 1024=0x400, 1280=0x500 2048=0x800 768=0x300 - gPB[TCP_WIN_SIZE+1] = 0; - fill_checksum(TCP_CHECKSUM_H_P, IP_SRC_P, 8+TCP_HEADER_LEN_PLAIN,2); - EtherCard::packetSend(IP_HEADER_LEN+TCP_HEADER_LEN_PLAIN+ETH_HEADER_LEN); -} - -static void make_tcp_ack_with_data_noflags(uint16_t dlen) { - uint16_t j = IP_HEADER_LEN+TCP_HEADER_LEN_PLAIN+dlen; - gPB[IP_TOTLEN_H_P] = j>>8; - gPB[IP_TOTLEN_L_P] = j; - fill_ip_hdr_checksum(); - gPB[TCP_CHECKSUM_H_P] = 0; - gPB[TCP_CHECKSUM_L_P] = 0; - fill_checksum(TCP_CHECKSUM_H_P, IP_SRC_P, 8+TCP_HEADER_LEN_PLAIN+dlen,2); - EtherCard::packetSend(IP_HEADER_LEN+TCP_HEADER_LEN_PLAIN+dlen+ETH_HEADER_LEN); -} - -void EtherCard::httpServerReply (uint16_t dlen) { - make_tcp_ack_from_any(info_data_len,0); // send ack for http get - gPB[TCP_FLAGS_P] = TCP_FLAGS_ACK_V|TCP_FLAGS_PUSH_V|TCP_FLAGS_FIN_V; - make_tcp_ack_with_data_noflags(dlen); // send data -} - -static void get_seq() { //get the sequence number of packets after an ack from GET - SEQ =(((unsigned long)gPB[TCP_SEQ_H_P]*256+gPB[TCP_SEQ_H_P+1])*256+gPB[TCP_SEQ_H_P+2])*256+gPB[TCP_SEQ_H_P+3]; -} //thanks to mstuetz for the missing (unsigned long) - -static void set_seq() { //set the correct sequence number and calculate the next with the lenght of current packet - gPB[TCP_SEQ_H_P]= (SEQ & 0xff000000 ) >> 24; - gPB[TCP_SEQ_H_P+1]= (SEQ & 0xff0000 ) >> 16; - gPB[TCP_SEQ_H_P+2]= (SEQ & 0xff00 ) >> 8; - gPB[TCP_SEQ_H_P+3]= (SEQ & 0xff ); -} - -void EtherCard::httpServerReplyAck () { - make_tcp_ack_from_any(info_data_len,0); // send ack for http get - get_seq(); //get the sequence number of packets after an ack from GET -} - -void EtherCard::httpServerReply_with_flags (uint16_t dlen , uint8_t flags) { - set_seq(); - gPB[TCP_FLAGS_P] = flags; // final packet - make_tcp_ack_with_data_noflags(dlen); // send data - SEQ=SEQ+dlen; -} - -void EtherCard::clientIcmpRequest(const uint8_t *destip) { - if(is_lan(EtherCard::myip, destip)) { - setMACandIPs(destmacaddr, destip); - } else - setMACandIPs(gwmacaddr, destip); - gPB[ETH_TYPE_H_P] = ETHTYPE_IP_H_V; - gPB[ETH_TYPE_L_P] = ETHTYPE_IP_L_V; - memcpy_P(gPB + IP_P,iphdr,9); - gPB[IP_TOTLEN_L_P] = 0x54; - gPB[IP_PROTO_P] = IP_PROTO_ICMP_V; - fill_ip_hdr_checksum(); - gPB[ICMP_TYPE_P] = ICMP_TYPE_ECHOREQUEST_V; - gPB[ICMP_TYPE_P+1] = 0; // code - gPB[ICMP_CHECKSUM_H_P] = 0; - gPB[ICMP_CHECKSUM_L_P] = 0; - gPB[ICMP_IDENT_H_P] = 5; // some number - gPB[ICMP_IDENT_L_P] = EtherCard::myip[3]; // last byte of my IP - gPB[ICMP_IDENT_L_P+1] = 0; // seq number, high byte - gPB[ICMP_IDENT_L_P+2] = 1; // seq number, low byte, we send only 1 ping at a time - memset(gPB + ICMP_DATA_P, PINGPATTERN, 56); - fill_checksum(ICMP_CHECKSUM_H_P, ICMP_TYPE_P, 56+8,0); - packetSend(98); -} - -void EtherCard::ntpRequest (uint8_t *ntpip,uint8_t srcport) { - if(is_lan(myip, ntpip)) { - setMACandIPs(destmacaddr, ntpip); - } else - setMACandIPs(gwmacaddr, ntpip); - gPB[ETH_TYPE_H_P] = ETHTYPE_IP_H_V; - gPB[ETH_TYPE_L_P] = ETHTYPE_IP_L_V; - memcpy_P(gPB + IP_P,iphdr,9); - gPB[IP_TOTLEN_L_P] = 0x4c; - gPB[IP_PROTO_P] = IP_PROTO_UDP_V; - fill_ip_hdr_checksum(); - gPB[UDP_DST_PORT_H_P] = 0; - gPB[UDP_DST_PORT_L_P] = 0x7b; // ntp = 123 - gPB[UDP_SRC_PORT_H_P] = 10; - gPB[UDP_SRC_PORT_L_P] = srcport; // lower 8 bit of src port - gPB[UDP_LEN_H_P] = 0; - gPB[UDP_LEN_L_P] = 56; // fixed len - gPB[UDP_CHECKSUM_H_P] = 0; - gPB[UDP_CHECKSUM_L_P] = 0; - memset(gPB + UDP_DATA_P, 0, 48); - memcpy_P(gPB + UDP_DATA_P,ntpreqhdr,10); - fill_checksum(UDP_CHECKSUM_H_P, IP_SRC_P, 16 + 48,1); - packetSend(90); -} - -uint8_t EtherCard::ntpProcessAnswer (uint32_t *time,uint8_t dstport_l) { - if ((dstport_l && gPB[UDP_DST_PORT_L_P]!=dstport_l) || gPB[UDP_LEN_H_P]!=0 || - gPB[UDP_LEN_L_P]!=56 || gPB[UDP_SRC_PORT_L_P]!=0x7b) - return 0; - ((uint8_t*) time)[3] = gPB[0x52]; - ((uint8_t*) time)[2] = gPB[0x53]; - ((uint8_t*) time)[1] = gPB[0x54]; - ((uint8_t*) time)[0] = gPB[0x55]; - return 1; -} - -void EtherCard::udpPrepare (uint16_t sport, const uint8_t *dip, uint16_t dport) { - if(is_lan(myip, dip)) // this works because both dns mac and destinations mac are stored in same variable - destmacaddr - setMACandIPs(destmacaddr, dip); // at different times. The program could have separate variable for dns mac, then here should be - else // checked if dip is dns ip and separately if dip is hisip and then use correct mac. - setMACandIPs(gwmacaddr, dip); - // see http://tldp.org/HOWTO/Multicast-HOWTO-2.html - // multicast or broadcast address, https://github.com/jcw/ethercard/issues/59 - if ((dip[0] & 0xF0) == 0xE0 || *((unsigned long*) dip) == 0xFFFFFFFF) - EtherCard::copyMac(gPB + ETH_DST_MAC, allOnes); - gPB[ETH_TYPE_H_P] = ETHTYPE_IP_H_V; - gPB[ETH_TYPE_L_P] = ETHTYPE_IP_L_V; - memcpy_P(gPB + IP_P,iphdr,9); - gPB[IP_TOTLEN_H_P] = 0; - gPB[IP_PROTO_P] = IP_PROTO_UDP_V; - gPB[UDP_DST_PORT_H_P] = (dport>>8); - gPB[UDP_DST_PORT_L_P] = dport; - gPB[UDP_SRC_PORT_H_P] = (sport>>8); - gPB[UDP_SRC_PORT_L_P] = sport; - gPB[UDP_LEN_H_P] = 0; - gPB[UDP_CHECKSUM_H_P] = 0; - gPB[UDP_CHECKSUM_L_P] = 0; -} - -void EtherCard::udpTransmit (uint16_t datalen) { - gPB[IP_TOTLEN_H_P] = (IP_HEADER_LEN+UDP_HEADER_LEN+datalen) >> 8; - gPB[IP_TOTLEN_L_P] = IP_HEADER_LEN+UDP_HEADER_LEN+datalen; - fill_ip_hdr_checksum(); - gPB[UDP_LEN_H_P] = (UDP_HEADER_LEN+datalen) >>8; - gPB[UDP_LEN_L_P] = UDP_HEADER_LEN+datalen; - fill_checksum(UDP_CHECKSUM_H_P, IP_SRC_P, 16 + datalen,1); - packetSend(UDP_HEADER_LEN+IP_HEADER_LEN+ETH_HEADER_LEN+datalen); -} - -void EtherCard::sendUdp (const char *data, uint8_t datalen, uint16_t sport, - const uint8_t *dip, uint16_t dport) { - udpPrepare(sport, dip, dport); - if (datalen>220) - datalen = 220; - memcpy(gPB + UDP_DATA_P, data, datalen); - udpTransmit(datalen); -} - -void EtherCard::sendWol (uint8_t *wolmac) { - setMACandIPs(allOnes, allOnes); - gPB[ETH_TYPE_H_P] = ETHTYPE_IP_H_V; - gPB[ETH_TYPE_L_P] = ETHTYPE_IP_L_V; - memcpy_P(gPB + IP_P,iphdr,9); - gPB[IP_TOTLEN_L_P] = 0x82; - gPB[IP_PROTO_P] = IP_PROTO_UDP_V; - fill_ip_hdr_checksum(); - gPB[UDP_DST_PORT_H_P] = 0; - gPB[UDP_DST_PORT_L_P] = 0x9; // wol = normally 9 - gPB[UDP_SRC_PORT_H_P] = 10; - gPB[UDP_SRC_PORT_L_P] = 0x42; // source port does not matter - gPB[UDP_LEN_H_P] = 0; - gPB[UDP_LEN_L_P] = 110; // fixed len - gPB[UDP_CHECKSUM_H_P] = 0; - gPB[UDP_CHECKSUM_L_P] = 0; - copyMac(gPB + UDP_DATA_P, allOnes); - uint8_t pos = UDP_DATA_P; - for (uint8_t m = 0; m < 16; ++m) { - pos += 6; - copyMac(gPB + pos, wolmac); - } - fill_checksum(UDP_CHECKSUM_H_P, IP_SRC_P, 16 + 102,1); - packetSend(pos + 6); -} - -// make a arp request -static void client_arp_whohas(uint8_t *ip_we_search) { - setMACs(allOnes); - gPB[ETH_TYPE_H_P] = ETHTYPE_ARP_H_V; - gPB[ETH_TYPE_L_P] = ETHTYPE_ARP_L_V; - memcpy_P(gPB + ETH_ARP_P,arpreqhdr,8); - memset(gPB + ETH_ARP_DST_MAC_P, 0, 6); - EtherCard::copyMac(gPB + ETH_ARP_SRC_MAC_P, EtherCard::mymac); - EtherCard::copyIp(gPB + ETH_ARP_DST_IP_P, ip_we_search); - EtherCard::copyIp(gPB + ETH_ARP_SRC_IP_P, EtherCard::myip); - EtherCard::packetSend(42); -} - -uint8_t EtherCard::clientWaitingGw () { - return !(waitgwmac & WGW_HAVE_GW_MAC); -} - -static uint8_t client_store_mac(uint8_t *source_ip, uint8_t *mac) { - if (memcmp(gPB + ETH_ARP_SRC_IP_P, source_ip, 4) != 0) - return 0; - EtherCard::copyMac(mac, gPB + ETH_ARP_SRC_MAC_P); - return 1; -} - -// static void client_gw_arp_refresh() { -// if (waitgwmac & WGW_HAVE_GW_MAC) -// waitgwmac |= WGW_REFRESHING; -// } - -void EtherCard::setGwIp (const uint8_t *gwipaddr) { - delaycnt = 0; //request gateway ARP lookup - waitgwmac = WGW_INITIAL_ARP; // causes an arp request in the packet loop - copyIp(gwip, gwipaddr); -} - -void EtherCard::updateBroadcastAddress() -{ - for(uint8_t i=0; i<4; i++) - broadcastip[i] = myip[i] | ~netmask[i]; -} - -static void client_syn(uint8_t srcport,uint8_t dstport_h,uint8_t dstport_l) { - if(is_lan(EtherCard::myip, EtherCard::hisip)) { - setMACandIPs(destmacaddr, EtherCard::hisip); - } else - setMACandIPs(gwmacaddr, EtherCard::hisip); - gPB[ETH_TYPE_H_P] = ETHTYPE_IP_H_V; - gPB[ETH_TYPE_L_P] = ETHTYPE_IP_L_V; - memcpy_P(gPB + IP_P,iphdr,9); - gPB[IP_TOTLEN_L_P] = 44; // good for syn - gPB[IP_PROTO_P] = IP_PROTO_TCP_V; - fill_ip_hdr_checksum(); - gPB[TCP_DST_PORT_H_P] = dstport_h; - gPB[TCP_DST_PORT_L_P] = dstport_l; - gPB[TCP_SRC_PORT_H_P] = TCPCLIENT_SRC_PORT_H; - gPB[TCP_SRC_PORT_L_P] = srcport; // lower 8 bit of src port - memset(gPB + TCP_SEQ_H_P, 0, 8); - gPB[TCP_SEQ_H_P+2] = seqnum; - seqnum += 3; - gPB[TCP_HEADER_LEN_P] = 0x60; // 0x60=24 len: (0x60>>4) * 4 - gPB[TCP_FLAGS_P] = TCP_FLAGS_SYN_V; - gPB[TCP_WIN_SIZE] = 0x3; // 1024 = 0x400 768 = 0x300, initial window - gPB[TCP_WIN_SIZE+1] = 0x0; - gPB[TCP_CHECKSUM_H_P] = 0; - gPB[TCP_CHECKSUM_L_P] = 0; - gPB[TCP_CHECKSUM_L_P+1] = 0; - gPB[TCP_CHECKSUM_L_P+2] = 0; - gPB[TCP_OPTIONS_P] = 2; - gPB[TCP_OPTIONS_P+1] = 4; - gPB[TCP_OPTIONS_P+2] = (CLIENTMSS>>8); - gPB[TCP_OPTIONS_P+3] = (uint8_t) CLIENTMSS; - fill_checksum(TCP_CHECKSUM_H_P, IP_SRC_P, 8 +TCP_HEADER_LEN_PLAIN+4,2); - // 4 is the tcp mss option: - EtherCard::packetSend(IP_HEADER_LEN+TCP_HEADER_LEN_PLAIN+ETH_HEADER_LEN+4); -} - -uint8_t EtherCard::clientTcpReq (uint8_t (*result_cb)(uint8_t,uint8_t,uint16_t,uint16_t), - uint16_t (*datafill_cb)(uint8_t),uint16_t port) { - client_tcp_result_cb = result_cb; - client_tcp_datafill_cb = datafill_cb; - tcp_client_port_h = port>>8; - tcp_client_port_l = port; - tcp_client_state = 1; // Flag to packetloop to initiate a TCP/IP session by send a syn - tcp_fd = (tcp_fd + 1) & 7; - return tcp_fd; -} - -static uint16_t www_client_internal_datafill_cb(uint8_t fd) { - BufferFiller bfill = EtherCard::tcpOffset(); - if (fd==www_fd) { - if (client_postval == 0) { - bfill.emit_p(PSTR("GET $F$S HTTP/1.0\r\n" - "Host: $F\r\n" - "$F\r\n" - "\r\n"), client_urlbuf, - client_urlbuf_var, - client_hoststr, client_additionalheaderline); - } else { - const char* ahl = client_additionalheaderline; - bfill.emit_p(PSTR("POST $F HTTP/1.0\r\n" - "Host: $F\r\n" - "$F$S" - "Accept: */*\r\n" - "Content-Length: $D\r\n" - "Content-Type: application/x-www-form-urlencoded\r\n" - "\r\n" - "$S"), client_urlbuf, - client_hoststr, - ahl != 0 ? ahl : PSTR(""), - ahl != 0 ? "\r\n" : "", - strlen(client_postval), - client_postval); - } - } - return bfill.position(); -} - -static uint8_t www_client_internal_result_cb(uint8_t fd, uint8_t statuscode, uint16_t datapos, uint16_t len_of_data) { - if (fd!=www_fd) - (*client_browser_cb)(4,0,0); - else if (statuscode==0 && len_of_data>12 && client_browser_cb) { - uint8_t f = strncmp("200",(char *)&(gPB[datapos+9]),3) != 0; - (*client_browser_cb)(f, ((uint16_t)TCP_SRC_PORT_H_P+(gPB[TCP_HEADER_LEN_P]>>4)*4),len_of_data); - } - return 0; -} - -void EtherCard::browseUrl (const char *urlbuf, const char *urlbuf_varpart, const char *hoststr, void (*callback)(uint8_t,uint16_t,uint16_t)) { - browseUrl(urlbuf, urlbuf_varpart, hoststr, PSTR("Accept: text/html"), callback); -} - -void EtherCard::browseUrl (const char *urlbuf, const char *urlbuf_varpart, const char *hoststr, const char *additionalheaderline, void (*callback)(uint8_t,uint16_t,uint16_t)) { - client_urlbuf = urlbuf; - client_urlbuf_var = urlbuf_varpart; - client_hoststr = hoststr; - client_additionalheaderline = additionalheaderline; - client_postval = 0; - client_browser_cb = callback; - www_fd = clientTcpReq(&www_client_internal_result_cb,&www_client_internal_datafill_cb,hisport); -} - -void EtherCard::httpPost (const char *urlbuf, const char *hoststr, const char *additionalheaderline, const char *postval, void (*callback)(uint8_t,uint16_t,uint16_t)) { - client_urlbuf = urlbuf; - client_hoststr = hoststr; - client_additionalheaderline = additionalheaderline; - client_postval = postval; - client_browser_cb = callback; - www_fd = clientTcpReq(&www_client_internal_result_cb,&www_client_internal_datafill_cb,hisport); -} - -static uint16_t tcp_datafill_cb(uint8_t fd) { - uint16_t len = Stash::length(); - Stash::extract(0, len, EtherCard::tcpOffset()); - Stash::cleanup(); - EtherCard::tcpOffset()[len] = 0; -#if SERIAL - Serial.print("REQUEST: "); - Serial.println(len); - Serial.println((char*) EtherCard::tcpOffset()); -#endif - result_fd = 123; // bogus value - return len; -} - -static uint8_t tcp_result_cb(uint8_t fd, uint8_t status, uint16_t datapos, uint16_t datalen) { - if (status == 0) { - result_fd = fd; // a valid result has been received, remember its session id - result_ptr = (char*) ether.buffer + datapos; - // result_ptr[datalen] = 0; - } - return 1; -} - -uint8_t EtherCard::tcpSend () { - www_fd = clientTcpReq(&tcp_result_cb, &tcp_datafill_cb, hisport); - return www_fd; -} - -const char* EtherCard::tcpReply (uint8_t fd) { - if (result_fd != fd) - return 0; - result_fd = 123; // set to a bogus value to prevent future match - return result_ptr; -} - -void EtherCard::registerPingCallback (void (*callback)(uint8_t *srcip)) { - icmp_cb = callback; -} - -uint8_t EtherCard::packetLoopIcmpCheckReply (const uint8_t *ip_monitoredhost) { - return gPB[IP_PROTO_P]==IP_PROTO_ICMP_V && - gPB[ICMP_TYPE_P]==ICMP_TYPE_ECHOREPLY_V && - gPB[ICMP_DATA_P]== PINGPATTERN && - check_ip_message_is_from(ip_monitoredhost); -} - -uint16_t EtherCard::accept(const uint16_t port, uint16_t plen) { - uint16_t pos; - - if (gPB[TCP_DST_PORT_H_P] == (port >> 8) && - gPB[TCP_DST_PORT_L_P] == ((uint8_t) port)) - { //Packet targetted at specified port - if (gPB[TCP_FLAGS_P] & TCP_FLAGS_SYN_V) - make_tcp_synack_from_syn(); //send SYN+ACK - else if (gPB[TCP_FLAGS_P] & TCP_FLAGS_ACK_V) - { //This is an acknowledgement to our SYN+ACK so let's start processing that payload - info_data_len = get_tcp_data_len(); - if (info_data_len > 0) - { //Got some data - pos = TCP_DATA_START; // TCP_DATA_START is a formula - if (pos <= plen - 8) - return pos; - } - else if (gPB[TCP_FLAGS_P] & TCP_FLAGS_FIN_V) - make_tcp_ack_from_any(0,0); //No data so close connection - } - } - return 0; -} - -uint16_t EtherCard::packetLoop (uint16_t plen) { - uint16_t len; - if(using_dhcp){ - ether.DhcpStateMachine(plen); - } - - if (plen==0) { - //Check every 65536 (no-packet) cycles whether we need to retry ARP request for gateway - if ((waitgwmac & WGW_INITIAL_ARP || waitgwmac & WGW_REFRESHING) && - delaycnt==0 && isLinkUp()) { - client_arp_whohas(gwip); - waitgwmac |= WGW_ACCEPT_ARP_REPLY; - } - - - - delaycnt++; - //Initiate TCP/IP session if pending - if (tcp_client_state==1 && (waitgwmac & WGW_HAVE_GW_MAC)) { // send a syn - tcp_client_state = 2; - tcpclient_src_port_l++; // allocate a new port - client_syn(((tcp_fd<<5) | (0x1f & tcpclient_src_port_l)),tcp_client_port_h,tcp_client_port_l); - } - //!@todo this is trying to find mac only once. Need some timeout to make another call if first one doesn't succeed. - if(is_lan(myip, dnsip) && !has_dns_mac && !waiting_for_dns_mac) { - client_arp_whohas(dnsip); - waiting_for_dns_mac = true; - } - //!@todo this is trying to find mac only once. Need some timeout to make another call if first one doesn't succeed. - if(is_lan(myip, hisip) && !has_dest_mac && !waiting_for_dest_mac) { - client_arp_whohas(hisip); - waiting_for_dest_mac = true; - } - - return 0; - } - - if (eth_type_is_arp_and_my_ip(plen)) - { //Service ARP request - if (gPB[ETH_ARP_OPCODE_L_P]==ETH_ARP_OPCODE_REQ_L_V) - make_arp_answer_from_request(); - if (waitgwmac & WGW_ACCEPT_ARP_REPLY && (gPB[ETH_ARP_OPCODE_L_P]==ETH_ARP_OPCODE_REPLY_L_V) && client_store_mac(gwip, gwmacaddr)) - waitgwmac = WGW_HAVE_GW_MAC; - if (!has_dns_mac && waiting_for_dns_mac && client_store_mac(dnsip, destmacaddr)) { - has_dns_mac = true; - waiting_for_dns_mac = false; - } - if (!has_dest_mac && waiting_for_dest_mac && client_store_mac(hisip, destmacaddr)){ - has_dest_mac = true; - waiting_for_dest_mac = false; - } - return 0; - } - - if (eth_type_is_ip_and_my_ip(plen)==0) - { //Not IP so ignoring - //!@todo Add other protocols (and make each optional at compile time) - return 0; - } - if (gPB[IP_PROTO_P]==IP_PROTO_ICMP_V && gPB[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V) - { //Service ICMP echo request (ping) - if (icmp_cb) - (*icmp_cb)(&(gPB[IP_SRC_P])); - make_echo_reply_from_request(plen); - return 0; - } - if (ether.udpServerListening() && gPB[IP_PROTO_P]==IP_PROTO_UDP_V) - { //Call UDP server handler (callback) if one is defined for this packet - if(ether.udpServerHasProcessedPacket(plen)) - return 0; //An UDP server handler (callback) has processed this packet - } - if (plen<54 && gPB[IP_PROTO_P]!=IP_PROTO_TCP_V ) - return 0; //Packet flagged as TCP but shorter than minimum TCP packet length - if (gPB[TCP_DST_PORT_H_P]==TCPCLIENT_SRC_PORT_H) - { //Source port is in range reserved (by EtherCard) for client TCP/IP connections - if (check_ip_message_is_from(hisip)==0) - return 0; //Not current TCP/IP connection (only handle one at a time) - if (gPB[TCP_FLAGS_P] & TCP_FLAGS_RST_V) - { //TCP reset flagged - if (client_tcp_result_cb) - (*client_tcp_result_cb)((gPB[TCP_DST_PORT_L_P]>>5)&0x7,3,0,0); - tcp_client_state = 5; - return 0; - } - len = get_tcp_data_len(); - if (tcp_client_state==2) - { //Waiting for SYN-ACK - if ((gPB[TCP_FLAGS_P] & TCP_FLAGS_SYN_V) && (gPB[TCP_FLAGS_P] &TCP_FLAGS_ACK_V)) - { //SYN and ACK flags set so this is an acknowledgement to our SYN - make_tcp_ack_from_any(0,0); - gPB[TCP_FLAGS_P] = TCP_FLAGS_ACK_V|TCP_FLAGS_PUSH_V; - if (client_tcp_datafill_cb) - len = (*client_tcp_datafill_cb)((gPB[TCP_SRC_PORT_L_P]>>5)&0x7); - else - len = 0; - tcp_client_state = 3; - make_tcp_ack_with_data_noflags(len); - } - else - { //Expecting SYN+ACK so reset and resend SYN - tcp_client_state = 1; // retry - len++; - if (gPB[TCP_FLAGS_P] & TCP_FLAGS_ACK_V) - len = 0; - make_tcp_ack_from_any(len,TCP_FLAGS_RST_V); - } - return 0; - } - if (tcp_client_state==3 && len>0) - { //TCP connection established so read data - if (client_tcp_result_cb) { - uint16_t tcpstart = TCP_DATA_START; // TCP_DATA_START is a formula - if (tcpstart>plen-8) - tcpstart = plen-8; // dummy but save - uint16_t save_len = len; - if (tcpstart+len>plen) - save_len = plen-tcpstart; - (*client_tcp_result_cb)((gPB[TCP_DST_PORT_L_P]>>5)&0x7,0,tcpstart,save_len); //Call TCP handler (callback) function - - if(persist_tcp_connection) - { //Keep connection alive by sending ACK - make_tcp_ack_from_any(len,TCP_FLAGS_PUSH_V); - } - else - { //Close connection - make_tcp_ack_from_any(len,TCP_FLAGS_PUSH_V|TCP_FLAGS_FIN_V); - tcp_client_state = 6; - } - return 0; - } - } - if (tcp_client_state != 5) - { // - if (gPB[TCP_FLAGS_P] & TCP_FLAGS_FIN_V) { - if(tcp_client_state == 3) { - return 0; // In some instances FIN is received *before* DATA. If that is the case, we just return here and keep looking for the data packet - } - make_tcp_ack_from_any(len+1,TCP_FLAGS_PUSH_V|TCP_FLAGS_FIN_V); - tcp_client_state = 6; // connection terminated - } else if (len>0) { - make_tcp_ack_from_any(len,0); - } - } - return 0; - } - - //If we are here then this is a TCP/IP packet targetted at us and not related to out client connection so accept - return accept(hisport, plen); -} - -void EtherCard::persistTcpConnection(bool persist){ - persist_tcp_connection = persist; -} diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/udpserver.cpp b/GD32F1/libraries/Serasidis_EtherCard_STM/src/udpserver.cpp deleted file mode 100644 index 08ac5fe..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/udpserver.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Simple UDP listening server -// -// Author: Brian Lee -// -// Copyright: GPL V2 -// See http://www.gnu.org/licenses/gpl.html - -#include "EtherCard_STM.h" -#include "net.h" - -#define gPB ether.buffer - -#define UDPSERVER_MAXLISTENERS 8 //the maximum number of port listeners. - -typedef struct { - UdpServerCallback callback; - uint16_t port; - bool listening; -} UdpServerListener; - -UdpServerListener listeners[UDPSERVER_MAXLISTENERS]; -byte numListeners = 0; - -void EtherCard::udpServerListenOnPort(UdpServerCallback callback, uint16_t port) { - if(numListeners < UDPSERVER_MAXLISTENERS) - { - listeners[numListeners] = (UdpServerListener) { - callback, port, true - }; - numListeners++; - } -} - -void EtherCard::udpServerPauseListenOnPort(uint16_t port) { - for(int i = 0; i < numListeners; i++) - { - if(gPB[UDP_DST_PORT_H_P] == (listeners[i].port >> 8) && gPB[UDP_DST_PORT_L_P] == ((byte) listeners[i].port)) { - listeners[i].listening = false; - } - } -} - -void EtherCard::udpServerResumeListenOnPort(uint16_t port) { - for(int i = 0; i < numListeners; i++) - { - if(gPB[UDP_DST_PORT_H_P] == (listeners[i].port >> 8) && gPB[UDP_DST_PORT_L_P] == ((byte) listeners[i].port)) { - listeners[i].listening = true; - } - } -} - -bool EtherCard::udpServerListening() { - return numListeners > 0; -} - -bool EtherCard::udpServerHasProcessedPacket(uint16_t plen) { - bool packetProcessed = false; - for(int i = 0; i < numListeners; i++) - { - if(gPB[UDP_DST_PORT_H_P] == (listeners[i].port >> 8) && gPB[UDP_DST_PORT_L_P] == ((byte) listeners[i].port) && listeners[i].listening) - { - uint16_t datalen = (uint16_t) (gPB[UDP_LEN_H_P] << 8) + gPB[UDP_LEN_L_P] - UDP_HEADER_LEN; - listeners[i].callback( - listeners[i].port, - gPB + IP_SRC_P, - (gPB[UDP_SRC_PORT_H_P] << 8) | gPB[UDP_SRC_PORT_L_P], - (const char *) (gPB + UDP_DATA_P), - datalen); - packetProcessed = true; - } - } - return packetProcessed; -} diff --git a/GD32F1/libraries/Serasidis_EtherCard_STM/src/webutil.cpp b/GD32F1/libraries/Serasidis_EtherCard_STM/src/webutil.cpp deleted file mode 100644 index 282ae48..0000000 --- a/GD32F1/libraries/Serasidis_EtherCard_STM/src/webutil.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// Some common utilities needed for IP and web applications -// Author: Guido Socher -// Copyright: GPL V2 -// -// 2010-05-20 - -#include "EtherCard_STM.h" - -void EtherCard::copyIp (uint8_t *dst, const uint8_t *src) { - memcpy(dst, src, 4); -} - -void EtherCard::copyMac (uint8_t *dst, const uint8_t *src) { - memcpy(dst, src, 6); -} - -void EtherCard::printIp (const char* msg, const uint8_t *buf) { - Serial.print(msg); - EtherCard::printIp(buf); - Serial.println(); -} - -void EtherCard::printIp (const __FlashStringHelper *ifsh, const uint8_t *buf) { - Serial.print(ifsh); - EtherCard::printIp(buf); - Serial.println(); -} - -void EtherCard::printIp (const uint8_t *buf) { - for (uint8_t i = 0; i < 4; ++i) { - Serial.print( buf[i], DEC ); - if (i < 3) - Serial.print('.'); - } -} - -// search for a string of the form key=value in -// a string that looks like q?xyz=abc&uvw=defgh HTTP/1.1\r\n -// -// The returned value is stored in strbuf. You must allocate -// enough storage for strbuf, maxlen is the size of strbuf. -// I.e the value it is declated with: strbuf[5]-> maxlen=5 -uint8_t EtherCard::findKeyVal (const char *str,char *strbuf, uint8_t maxlen,const char *key) -{ - uint8_t found=0; - uint8_t i=0; - const char *kp; - kp=key; - while(*str && *str!=' ' && *str!='\n' && found==0){ - if (*str == *kp){ - kp++; - if (*kp == '\0'){ - str++; - kp=key; - if (*str == '='){ - found=1; - } - } - }else{ - kp=key; - } - str++; - } - if (found==1){ - // copy the value to a buffer and terminate it with '\0' - while(*str && *str!=' ' && *str!='\n' && *str!='&' && i= '0' && c <='9'){ - return((unsigned char)c - '0'); - } - if (c >= 'a' && c <='f'){ - return((unsigned char)c - 'a' + 10); - } - if (c >= 'A' && c <='F'){ - return((unsigned char)c - 'A' + 10); - } - return(0); -} - -// decode a url string e.g "hello%20joe" or "hello+joe" becomes "hello joe" -void EtherCard::urlDecode (char *urlbuf) -{ - char c; - char *dst = urlbuf; - while ((c = *urlbuf) != 0) { - if (c == '+') c = ' '; - if (c == '%') { - c = *++urlbuf; - c = (h2int(c) << 4) | h2int(*++urlbuf); - } - *dst++ = c; - urlbuf++; - } - *dst = '\0'; -} - -// convert a single character to a 2 digit hex str -// a terminating '\0' is added -void int2h(char c, char *hstr) -{ - hstr[1]=(c & 0xf)+'0'; - if ((c & 0xf) >9){ - hstr[1]=(c & 0xf) - 10 + 'a'; - } - c=(c>>4)&0xf; - hstr[0]=c+'0'; - if (c > 9){ - hstr[0]=c - 10 + 'a'; - } - hstr[2]='\0'; -} - -// there must be enough space in urlbuf. In the worst case that is -// 3 times the length of str -void EtherCard::urlEncode (char *str,char *urlbuf) -{ - char c; - while ((c = *str) != 0) { - if (c == ' '||isalnum(c)){ - if (c == ' '){ - c = '+'; - } - *urlbuf=c; - str++; - urlbuf++; - continue; - } - *urlbuf='%'; - urlbuf++; - int2h(c,urlbuf); - urlbuf++; - urlbuf++; - str++; - } - *urlbuf='\0'; -} - -// parse a string and extract the IP to bytestr -uint8_t EtherCard::parseIp (uint8_t *bytestr,char *str) -{ - char *sptr; - uint8_t i=0; - sptr=NULL; - while(i<4){ - bytestr[i]=0; - i++; - } - i=0; - while(*str && i<4){ - // if a number then start - if (sptr==NULL && isdigit(*str)){ - sptr=str; - } - if (*str == '.'){ - *str ='\0'; - bytestr[i]=(atoi(sptr)&0xff); - i++; - sptr=NULL; - } - str++; - } - *str ='\0'; - if (i==3){ - bytestr[i]=(atoi(sptr)&0xff); - return(0); - } - return(1); -} - -// take a byte string and convert it to a human readable display string (base is 10 for ip and 16 for mac addr), len is 4 for IP addr and 6 for mac. -void EtherCard::makeNetStr (char *resultstr,uint8_t *bytestr,uint8_t len,char separator,uint8_t base) -{ - uint8_t i=0; - uint8_t j=0; - while(i -#include - -/* - * VS1003 development board connected by it's header pins the following way: - * - * GND - GND - - * XDCS - D6 - PB10 - * DREQ - D7 - PA8 - * XRES - D8 - PA9 - * XCS - D9 - PC14 - * SCLK - D13 - PA5 - * SI - D11 - PA7 - * SO - D12 - PA6 - * GND - GND - - * 5V - 5V - - */ - -static const unsigned char HelloMP3[] = { - 0xFF,0xF2,0x40,0xC0,0x19,0xB7,0x00,0x14,0x02,0xE6,0x5C, /* ..@.......\ */ - 0x01,0x92,0x68,0x01,0xF1,0x5E,0x03,0x08,0xF0,0x24,0x80, /* ..h..^...$. */ - 0x05,0x9E,0x20,0xC6,0xFC,0x12,0x32,0x5C,0xBF,0xF9,0xB9, /* .. ...2\... */ - 0x20,0x4A,0x7F,0x85,0xEC,0x4C,0xCD,0xC7,0x27,0xFE,0x5C, /* J...L..'.\ */ - 0x34,0x25,0xCB,0xE6,0xFF,0xFF,0x8E,0x42,0xE1,0xA0,0x5E, /* 4%.....B..^ */ - 0xCA,0x6E,0x30,0x9F,0xFF,0xF8,0xC2,0x12,0x84,0xB9,0x7C, /* .n0.......| */ - 0xDC,0x61,0x09,0x4A,0x7F,0xFF,0xFF,0xF9,0x7D,0x32,0x51, /* .a.J....}2Q */ - 0x09,0x7C,0xE1,0xA5,0x6E,0xB4,0xFF,0xFF,0xFF,0xFF,0xD3, /* .|..n...... */ - 0x34,0x41,0x91,0xF0,0x11,0x8F,0x00,0x0F,0x81,0x9C,0x10, /* 4A......... */ - 0xEE,0x59,0xCE,0x56,0x67,0xFF,0xF2,0x42,0xC0,0xEC,0x53, /* .Y.Vg..B..S */ - 0x09,0x15,0xF9,0xAA,0xA8,0x0D,0xD9,0x40,0x00,0xCA,0x34, /* .......@..4 */ - 0x53,0xD9,0x18,0xAB,0x7D,0xF7,0x89,0x3F,0x11,0x38,0x94, /* S...}..?.8. */ - 0x82,0x59,0x93,0x20,0x6A,0x0C,0xEE,0x8E,0x58,0xFA,0x38, /* .Y. j...X.8 */ - 0x82,0xCA,0xF0,0x58,0xBB,0xDA,0x0C,0x50,0x56,0x1F,0xBB, /* ...X...PV.. */ - 0x18,0x5D,0x8B,0x9F,0xDA,0x71,0x4F,0xFF,0xBD,0xFE,0xEF, /* .]...qO.... */ - 0x69,0x36,0x86,0x3C,0x50,0xBB,0x0A,0x07,0x89,0x54,0xF0, /* i6. .(4.... */ - 0xC0,0x01,0x75,0xF8,0x05,0x6B,0x5F,0x41,0x17,0x0B,0xE7, /* ..u..k_A... */ - 0xFF,0xF2,0x40,0xC0,0x61,0xE5,0x0B,0x16,0x09,0xC6,0xC5, /* ..@.a...... */ - 0x74,0x7B,0xCC,0x94,0x7A,0xF7,0x80,0x76,0xB2,0xD2,0xF8, /* t{..z..v... */ - 0x39,0x06,0x38,0xFD,0x71,0xC5,0xDE,0x3A,0x38,0xBF,0xD5, /* 9.8.q..:8.. */ - 0xF7,0x12,0x37,0xCB,0xF5,0x63,0x0C,0x9B,0xCE,0x77,0x25, /* ..7..c...w% */ - 0xED,0xFB,0x3D,0x6B,0x35,0xF9,0x6D,0xD7,0xF9,0x2C,0xD1, /* ..=k5.m..,. */ - 0x97,0x15,0x87,0x93,0xA4,0x49,0x4A,0x18,0x16,0x07,0xA1, /* .....IJ.... */ - 0x60,0xF7,0x52,0x94,0xDB,0x02,0x16,0x70,0xB2,0xD8,0x80, /* `.R....p... */ - 0x30,0xC2,0x94,0x40,0x81,0x74,0x5A,0x19,0x7A,0x80,0x60, /* 0..@.tZ.z.` */ - 0x41,0x21,0x46,0x95,0xD5,0xC4,0x40,0xD2,0x01,0xC0,0x01, /* A!F...@.... */ - 0xDA,0xD9,0xA0,0xB1,0x01,0xFF,0xF2,0x42,0xC0,0x82,0x10, /* .......B... */ - 0x0B,0x12,0xF9,0x9E,0xC9,0x7E,0x7A,0xC6,0x95,0x55,0x09, /* .....~z..U. */ - 0x8B,0x19,0x5E,0x8B,0x26,0xCA,0xEB,0x68,0x8A,0x05,0x8F, /* ..^.&..h... */ - 0x36,0xA5,0xA5,0x03,0xB8,0x9C,0xED,0x24,0x51,0x59,0x90, /* 6......$QY. */ - 0xF6,0xC5,0x7D,0xB5,0xAD,0xAF,0xF6,0x3B,0x18,0xEF,0x3F, /* ..}....;..? */ - 0xFF,0xFF,0x4E,0xDE,0x16,0x66,0x0B,0xAA,0x33,0x23,0xDD, /* ..N..f..3#. */ - 0x9C,0x4E,0x6E,0x55,0x22,0x9D,0xA2,0x40,0xA6,0x36,0x31, /* .NnU"..@.61 */ - 0x69,0xA5,0xE1,0xD9,0x7F,0xF7,0xC6,0xCC,0x48,0x00,0x0E, /* i.......H.. */ - 0x90,0x16,0x00,0x0F,0xDE,0x6E,0x80,0x11,0x0C,0x9A,0x4F, /* .....n....O */ - 0x56,0xDB,0x88,0xD3,0xB2,0x1C,0x00,0xE0,0x2E,0x3E,0xAC, /* V........>. */ - 0xFF,0xF2,0x40,0xC0,0x1C,0xE5,0x19,0x13,0x31,0x4E,0xCD, /* ..@.....1N. */ - 0x9E,0xC3,0x06,0x71,0x03,0x85,0xE5,0xB5,0x6D,0x88,0x50, /* ...q....m.P */ - 0x8E,0x0E,0x17,0x3B,0x19,0xFB,0x4E,0x3B,0x99,0xEF,0x4C, /* ...;..N;..L */ - 0x9E,0xF7,0x7B,0x31,0x7C,0x3C,0x5F,0xFF,0xF4,0xF8,0xE3, /* ..{1|<_.... */ - 0x92,0x42,0x07,0x8E,0x83,0x8E,0x0F,0x05,0x08,0x91,0xA3, /* .B......... */ - 0x16,0xE2,0xDF,0xB7,0x62,0x60,0x48,0x31,0x3C,0xFF,0xD4, /* ....b`H1<.. */ - 0x9E,0x0C,0x68,0x00,0x77,0x54,0xE3,0x1E,0x05,0xC5,0xF8, /* ..h.wT..... */ - 0xEA,0x8D,0x82,0x9D,0x08,0xA9,0x06,0x8D,0x1E,0x5D,0x7C, /* .........]| */ - 0x7F,0x08,0xC0,0x50,0x45,0x42,0xD0,0x36,0xF8,0xB2,0x4D, /* ...PEB.6..M */ - 0x53,0x0C,0x80,0x3B,0x4D,0xFF,0xF2,0x42,0xC0,0x2F,0x3C, /* S..;M..B./< */ - 0x25,0x19,0x29,0xFE,0xBC,0x2E,0xC4,0xD0,0x99,0x4C,0x48, /* %.)......LH */ - 0xB0,0x9C,0x49,0xD2,0x1A,0x2D,0x02,0xC2,0x79,0x69,0x16, /* ..I..-..yi. */ - 0x92,0xA8,0xC5,0xAB,0x45,0x5A,0x68,0xE8,0x75,0x57,0xCD, /* ....EZh.uW. */ - 0xF1,0xB9,0xAA,0x13,0x88,0xE4,0x87,0x42,0x15,0xB3,0x58, /* .......B..X */ - 0xF5,0xA3,0x46,0xB1,0xCF,0xD3,0x59,0x7E,0xBA,0xB5,0xA7, /* ..F...Y~... */ - 0x6B,0x0B,0x17,0x57,0x6B,0x5C,0x4A,0xCD,0x53,0x76,0x2A, /* k..Wk\J.Sv* */ - 0x1D,0x28,0xC5,0x1C,0x76,0x5C,0xDD,0x0A,0x00,0x4B,0xC0, /* .(..v\...K. */ - 0x1B,0xCA,0xA8,0xE9,0x81,0x5B,0xA6,0xDC,0xA4,0x59,0x13, /* .....[...Y. */ - 0xFC,0xBA,0x8F,0x98,0x79,0x44,0x25,0xC9,0x35,0x38,0xCA, /* ....yD%.58. */ - 0xFF,0xF2,0x40,0xC0,0xB9,0x7D,0x1A,0x13,0x79,0x6A,0xC8, /* ..@..}..yj. */ - 0x3E,0xC4,0x46,0x94,0x8D,0x3C,0x67,0x85,0xB1,0xA8,0x89, /* >.F...n.f.. */ - 0xE3,0xC2,0xE0,0x29,0x43,0x87,0x5F,0x4F,0x27,0x9C,0x2C, /* ...)C._O'., */ - 0xD0,0x91,0xF3,0x87,0x9B,0x54,0xED,0xD1,0xB4,0xF3,0x39, /* .....T....9 */ - 0x87,0x22,0x06,0x86,0x0D,0x71,0xE4,0x6F,0x2A,0x08,0x04, /* ."...q.o*.. */ - 0xC0,0x03,0x2A,0xB1,0xE2,0x05,0x4D,0x64,0xA1,0x9C,0xA6, /* ..*...Md... */ - 0x0D,0x41,0xA6,0xF2,0x7A,0xC1,0x30,0xC3,0x38,0x26,0x09, /* .A..z.0.8&. */ - 0x50,0x08,0xC4,0xF6,0x30,0x0C,0xA6,0xA9,0x17,0x00,0x13, /* P...0...... */ - 0x0C,0xDC,0xC4,0x2F,0x28,0xEB,0x3F,0xCD,0x7A,0x3D,0x2F, /* .../(.?.z=/ */ - 0xFF,0xF2,0x40,0xC0,0x18,0x6F,0x2E,0x13,0xA1,0xF2,0xBC, /* ..@..o..... */ - 0x36,0xCB,0x4E,0x99,0x6E,0xFC,0xEE,0xC5,0xF0,0xA0,0xB7, /* 6.N.n...... */ - 0x92,0xD4,0xEE,0x79,0x7C,0x50,0x5D,0xE5,0x04,0x94,0xA9, /* ...y|P].... */ - 0x76,0xCF,0x6C,0x70,0xDD,0x0D,0xD4,0xEE,0xED,0x98,0xE8, /* v.lp....... */ - 0xC8,0x35,0x36,0x7A,0x0C,0x05,0x80,0x03,0xBC,0xBE,0x91, /* .56z....... */ - 0x00,0x7C,0xAE,0x65,0xB8,0x91,0xA3,0x33,0xBA,0x68,0x60, /* .|.e...3.h` */ - 0xD4,0x1A,0x66,0xF8,0x43,0xA0,0x20,0x89,0xE7,0x80,0xD8, /* ..f.C. .... */ - 0x1E,0x4F,0xA0,0x04,0x60,0x06,0x0A,0xA4,0x91,0x24,0xFA, /* .O..`....$. */ - 0x9F,0x57,0x53,0xF4,0x7A,0xDB,0x5F,0x56,0xE3,0x6E,0x0B, /* .WS.z._V.n. */ - 0x8B,0x3A,0x1C,0xF9,0x5E,0xFF,0xF2,0x42,0xC0,0xB1,0x00, /* .:..^..B... */ - 0x38,0x14,0x09,0xEE,0xB4,0x36,0xD3,0x4E,0x99,0xA4,0x78, /* 8....6.N..x */ - 0x94,0x73,0xC4,0x66,0x30,0xF5,0xEA,0xDB,0xBA,0x67,0x67, /* .s.f0....gg */ - 0x95,0x6B,0xAB,0x68,0x5D,0x08,0xA1,0x39,0x56,0xAB,0x1E, /* .k.h]..9V.. */ - 0xD5,0x03,0xE8,0x01,0x70,0x00,0xB3,0x93,0x33,0x19,0x8C, /* ....p...3.. */ - 0x61,0x8F,0xBB,0x5D,0x24,0x12,0x63,0xD3,0x4B,0x5D,0x91, /* a..]$.c.K]. */ - 0x08,0x43,0x22,0x56,0x1A,0xC5,0x10,0x21,0x84,0xA8,0xEA, /* .C"V...!... */ - 0x80,0xBF,0x16,0x8E,0x3D,0x46,0x18,0x9C,0x6E,0x9A,0x91, /* ....=F..n.. */ - 0xE6,0xC9,0x6F,0xD2,0x7D,0x27,0xD7,0xE9,0x6B,0xFF,0x0A, /* ..o.}'..k.. */ - 0x03,0x43,0x89,0xD5,0xBF,0x52,0x97,0x0A,0x25,0x95,0x0D, /* .C...R..%.. */ - 0xFF,0xF2,0x40,0xC0,0xF5,0xC3,0x41,0x13,0x81,0xEE,0xA8, /* ..@...A.... */ - 0x5E,0xD3,0x44,0x98,0xFC,0xCF,0x97,0xF9,0x58,0xB5,0x33, /* ^.D.....X.3 */ - 0xB1,0x85,0x47,0x86,0xD7,0x98,0x01,0x3B,0xA3,0x4F,0x7E, /* ..G....;.O~ */ - 0x04,0xA6,0xC3,0x39,0x21,0x70,0x27,0x62,0xB5,0x18,0x10, /* ...9!p'b... */ - 0x09,0x99,0x00,0x8B,0x7E,0xF2,0xBF,0x52,0x18,0x26,0x30, /* ....~..R.&0 */ - 0x1C,0xB0,0x01,0x49,0x30,0xE0,0xC3,0x11,0x46,0x05,0xCC, /* ...I0...F.. */ - 0x49,0x14,0x28,0xB2,0xED,0x4B,0x57,0x5A,0x2F,0xB7,0x46, /* I.(..KWZ/.F */ - 0x63,0x34,0xD2,0xDA,0x9F,0x56,0x32,0xB7,0xA2,0x25,0xFF, /* c4...V2..%. */ - 0x94,0x28,0x33,0x7F,0x3B,0xC4,0x50,0xEC,0xB1,0xE2,0x26, /* .(3.;.P...& */ - 0xA1,0xB7,0x07,0x7F,0xFB,0xFF,0xF2,0x42,0xC0,0x67,0x6A, /* .......B.gj */ - 0x4C,0x13,0xF9,0x6A,0x90,0x7E,0xDB,0x44,0x94,0x3F,0xFF, /* L..j.~.D.?. */ - 0x14,0xD6,0x2A,0xFF,0xFF,0xC1,0x34,0x8C,0x48,0x22,0x00, /* ..*...4.H". */ - 0x06,0x8F,0x21,0xFD,0x64,0x60,0x04,0x92,0x42,0xEA,0x74, /* ..!.d`..B.t */ - 0x32,0x37,0xAA,0x5A,0x9F,0x67,0x01,0x8B,0x3F,0x37,0x31, /* 27.Z.g..?71 */ - 0xDD,0x06,0x3C,0x01,0x34,0x30,0xE0,0x5C,0x78,0x78,0xCB, /* ..<.40.\xx. */ - 0xD6,0xF1,0x31,0x8A,0x69,0x61,0x93,0x92,0x42,0xCE,0x4B, /* ..1.ia..B.K */ - 0xC5,0x02,0x4E,0x73,0xC6,0x24,0x30,0xCD,0x08,0x66,0xC6, /* ..Ns.$0..f. */ - 0x35,0xAB,0xA2,0x3D,0x2F,0xB3,0xBD,0x34,0x87,0x13,0xEE, /* 5..=/..4... */ - 0x71,0x45,0x68,0xFA,0xEA,0x05,0x84,0x41,0x36,0x4C,0x9A, /* qEh....A6L. */ - 0xFF,0xF2,0x40,0xC0,0xC9,0x92,0x56,0x13,0xD0,0x6E,0x70, /* ..@...V..np */ - 0x54,0xD3,0xCC,0x28,0x06,0xD7,0x0E,0xA4,0x1D,0x9C,0x9D, /* T..(....... */ - 0xD9,0xA9,0x88,0x7B,0xB5,0xA3,0x56,0xB7,0x4B,0x4B,0x5A, /* ...{..V.KKZ */ - 0x9B,0x2C,0xA9,0xAD,0x6F,0x99,0x6C,0xC0,0x4C,0x14,0x14, /* .,..o.l.L.. */ - 0xEF,0xB4,0x20,0x91,0x5F,0xBC,0x81,0x41,0x41,0x5D,0xD4, /* .. ._..AA]. */ - 0x20,0xBD,0x05,0x1A,0x6F,0xE2,0x68,0x56,0x41,0x41,0x57, /* ...o.hVAAW */ - 0xF9,0xBF,0x89,0x82,0x8E,0xC7,0x8F,0x0A,0x0A,0x09,0x37, /* ..........7 */ - 0xF1,0x05,0x0A,0x0A,0x0A,0x0A,0x09,0x05,0x37,0xFF,0x10, /* ........7.. */ - 0x50,0x50,0x53,0x65,0xFF,0xFF,0xFD,0x75,0xDF,0xFF,0xFF, /* PPSe...u... */ - 0x68,0x4F,0xFF,0x84,0x70,0xFF,0xF2,0x42,0xC0,0x27,0x50, /* hO..p..B.'P */ - 0x5F,0x17,0xE8,0x82,0x3C,0x11,0x58,0x18,0x01,0x55,0x48, /* _...<.X..UH */ - 0xBC,0x52,0xFC,0x4A,0x4C,0x3C,0xD5,0xF6,0x11,0x2D,0xBF, /* .R.JL<...-. */ - 0xEA,0x03,0x5C,0x57,0x29,0xBF,0xC3,0x75,0x1C,0xE6,0xDD, /* ..\W)..u... */ - 0xBF,0xED,0xEF,0xD0,0x98,0x77,0x71,0x95,0x73,0xFF,0xED, /* .....wq.s.. */ - 0x54,0xBE,0xD5,0xEE,0xAE,0xC2,0xD5,0x0B,0xFF,0xF1,0x97, /* T.......... */ - 0x8A,0xE4,0x42,0x09,0x99,0xB1,0xEA,0x94,0xDC,0x78,0xB5, /* ..B......x. */ - 0x34,0x0F,0xF1,0x8F,0xFC,0x15,0xF6,0xFA,0xB1,0x47,0xA9, /* 4........G. */ - 0x6C,0x67,0x43,0x8B,0xF2,0x76,0x22,0xED,0xDA,0x85,0xBA, /* lgC..v".... */ - 0x2F,0xC7,0xF9,0xCF,0xFC,0xDB,0x46,0x2E,0x50,0x0A,0x84, /* /.....F.P.. */ - 0xFF,0xF2,0x40,0xC0,0xC6,0x4A,0x59,0x28,0x2B,0x19,0xE0, /* ..@..JY(+.. */ - 0x01,0x89,0x78,0x00,0x52,0x85,0x3C,0x8E,0x54,0x9A,0x48, /* ..x.R.<.T.H */ - 0x5A,0x72,0x32,0x94,0xBF,0x43,0x4F,0x24,0x53,0x4B,0xEC, /* Zr2..CO$SK. */ - 0x4B,0x99,0x0E,0x66,0x1F,0xFF,0xCE,0x7F,0xFF,0x3F,0x10, /* K..f.....?. */ - 0xAE,0x82,0x62,0x71,0x34,0x18,0x59,0x9B,0x51,0xC7,0x59, /* ..bq4.Y.Q.Y */ - 0xCE,0xEE,0xA5,0xFE,0x02,0xBB,0x30,0x91,0x49,0xD5,0x4B, /* ......0.I.K */ - 0xF3,0xDC,0x9A,0xA9,0x57,0x8E,0x72,0x10,0xC0,0x5D,0x60, /* ....W.r..]` */ - 0x67,0xFC,0x7D,0xD6,0xBA,0xDD,0xB3,0x8B,0x5A,0x0A,0x4C, /* g.}.....Z.L */ - 0x41,0x4D,0x45,0x33,0x2E,0x39,0x33,0xAA,0xAA,0xAA,0xAA, /* AME3.93.... */ - 0xAA,0xAA,0xAA,0xAA,0xAA,0x54,0x41,0x47,0x48,0x65,0x6C, /* .....TAGHel */ - 0x6C,0x6F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, /* lo */ - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, /* */ - 0x20,0x20,0x20,0x20,0x20,0x50,0x61,0x6E,0x75,0x2D,0x4B, /* Panu-K */ - 0x72,0x69,0x73,0x74,0x69,0x61,0x6E,0x20,0x50,0x6F,0x69, /* ristian Poi */ - 0x6B,0x73,0x61,0x6C,0x6F,0x20,0x20,0x20,0x20,0x20,0x20, /* ksalo */ - 0x20,0x20,0x56,0x53,0x44,0x53,0x50,0x20,0x54,0x65,0x73, /* VSDSP Tes */ - 0x74,0x69,0x6E,0x67,0x20,0x20,0x20,0x20,0x20,0x20,0x20, /* ting */ - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, /* */ - 0x20,0x20,0x20,0x4D,0x50,0x33,0x20,0x48,0x65,0x6C,0x6C, /* MP3 Hell */ - 0x6F,0x2C,0x20,0x57,0x6F,0x72,0x6C,0x64,0x21,0x20,0x20, /* o, World! */ - 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, /* */ - 0x00 -}; - -VS1003 player(PC14, PB10, PA8, PA9); // cs_pin, dcs_pin, dreq_pin, reset_pin, SPI channel - defaults to SPI - -/* Example of how to use the VS21003 attached to SPI 2 -VS1003 player(PC14, PB10, PA8, PA9,SPIClass(2)); // cs_pin, dcs_pin, dreq_pin, reset_pin, use SPI 2 -*/ - -/* Example of how to use the VS21003 attached to SPI 2 -VS1003 player(PC14, PB10, PA8, PA9,SPIClass(3)); // cs_pin, dcs_pin, dreq_pin, reset_pin, use SPI 3 -*/ -void setup () -{ - Serial.begin(9600); - Serial.println("VS1003 HelloMP3"); - - player.begin(); - player.modeSwitch(); //Change mode from MIDI to MP3 decoding (Vassilis Serasidis). - player.setVolume(0x00); // set maximum output volume -} - -void loop() { - player.playChunk(HelloMP3, sizeof(HelloMP3)); // play hellomp3 - this blocks until the player is ready to receive more data - delay(1000); -} \ No newline at end of file diff --git a/GD32F1/libraries/Serasidis_VS1003B_STM/keywords.txt b/GD32F1/libraries/Serasidis_VS1003B_STM/keywords.txt deleted file mode 100644 index e488f47..0000000 --- a/GD32F1/libraries/Serasidis_VS1003B_STM/keywords.txt +++ /dev/null @@ -1,30 +0,0 @@ -####################################### -# Syntax Coloring Map For VS1003 -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -VS1003 KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -begin KEYWORD2 -startSong KEYWORD2 -playChunk KEYWORD2 -stopSong KEYWORD2 -printDetails KEYWORD2 -modeSwitch KEYWORD2 -setVolume KEYWORD2 - -####################################### -# Instances (KEYWORD2) -####################################### - - -####################################### -# Constants (LITERAL1) -####################################### diff --git a/GD32F1/libraries/Serasidis_VS1003B_STM/library.properties b/GD32F1/libraries/Serasidis_VS1003B_STM/library.properties deleted file mode 100644 index 67c5b61..0000000 --- a/GD32F1/libraries/Serasidis_VS1003B_STM/library.properties +++ /dev/null @@ -1,8 +0,0 @@ -name=Serasidis_VS1003B_STM -version=1.0 -author=Andy Karpov - ported to STM by Vasillis Serasidis. Updated by Roger Clark -email= -sentence=VS1003 and VS1053 MP3, MP3 player and recorder -paragraph=VS1003 and VS1053 MP3, MP3 player and recorder -url= -architectures=STM32F1 diff --git a/GD32F1/libraries/Serasidis_VS1003B_STM/src/VS1003_STM.cpp b/GD32F1/libraries/Serasidis_VS1003B_STM/src/VS1003_STM.cpp deleted file mode 100644 index 07540d5..0000000 --- a/GD32F1/libraries/Serasidis_VS1003B_STM/src/VS1003_STM.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/* - Copyright (C) 2012 Andy Karpov - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as published by the Free Software Foundation. - - Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 - Home: http://www.serasidis.gr - email: avrsite@yahoo.gr - 29 May 2015 - Added a fix for booting the VS1053B boards into - mp3 decoding instead of booting into MID (modeSwitch function). - 01 July 2015 - Added a Flac decoder patch. - */ - -//#include -#include - -#if defined(USEFLAC) -#include "flac.h" -#endif - -#define vs1003_chunk_size 32 -/****************************************************************************/ - -// VS1003 SCI Write Command byte is 0x02 -#define VS_WRITE_COMMAND 0x02 - -// VS1003 SCI Read COmmand byte is 0x03 -#define VS_READ_COMMAND 0x03 - -// SCI Registers - -const uint8_t SCI_MODE = 0x0; -const uint8_t SCI_STATUS = 0x1; -const uint8_t SCI_BASS = 0x2; -const uint8_t SCI_CLOCKF = 0x3; -const uint8_t SCI_DECODE_TIME = 0x4; -const uint8_t SCI_AUDATA = 0x5; -const uint8_t SCI_WRAM = 0x6; -const uint8_t SCI_WRAMADDR = 0x7; -const uint8_t SCI_HDAT0 = 0x8; -const uint8_t SCI_HDAT1 = 0x9; -const uint8_t SCI_AIADDR = 0xa; -const uint8_t SCI_VOL = 0xb; -const uint8_t SCI_AICTRL0 = 0xc; -const uint8_t SCI_AICTRL1 = 0xd; -const uint8_t SCI_AICTRL2 = 0xe; -const uint8_t SCI_AICTRL3 = 0xf; -const uint8_t SCI_num_registers = 0xf; - -// SCI_MODE bits - -const uint8_t SM_DIFF = 0; -const uint8_t SM_LAYER12 = 1; -const uint8_t SM_RESET = 2; -const uint8_t SM_OUTOFWAV = 3; -const uint8_t SM_EARSPEAKER_LO = 4; -const uint8_t SM_TESTS = 5; -const uint8_t SM_STREAM = 6; -const uint8_t SM_EARSPEAKER_HI = 7; -const uint8_t SM_DACT = 8; -const uint8_t SM_SDIORD = 9; -const uint8_t SM_SDISHARE = 10; -const uint8_t SM_SDINEW = 11; -const uint8_t SM_ADPCM = 12; -const uint8_t SM_ADCPM_HP = 13; -const uint8_t SM_LINE_IN = 14; - -// Register names - -const char reg_name_MODE[] = "MODE"; -const char reg_name_STATUS[] = "STATUS"; -const char reg_name_BASS[] = "BASS"; -const char reg_name_CLOCKF[] = "CLOCKF"; -const char reg_name_DECODE_TIME[] = "DECODE_TIME"; -const char reg_name_AUDATA[] = "AUDATA"; -const char reg_name_WRAM[] = "WRAM"; -const char reg_name_WRAMADDR[] = "WRAMADDR"; -const char reg_name_HDAT0[] = "HDAT0"; -const char reg_name_HDAT1[] = "HDAT1"; -const char reg_name_AIADDR[] = "AIADDR"; -const char reg_name_VOL[] = "VOL"; -const char reg_name_AICTRL0[] = "AICTRL0"; -const char reg_name_AICTRL1[] = "AICTRL1"; -const char reg_name_AICTRL2[] = "AICTRL2"; -const char reg_name_AICTRL3[] = "AICTRL3"; - -static PGM_P const register_names[] = -{ - reg_name_MODE, - reg_name_STATUS, - reg_name_BASS, - reg_name_CLOCKF, - reg_name_DECODE_TIME, - reg_name_AUDATA, - reg_name_WRAM, - reg_name_WRAMADDR, - reg_name_HDAT0, - reg_name_HDAT1, - reg_name_AIADDR, - reg_name_VOL, - reg_name_AICTRL0, - reg_name_AICTRL1, - reg_name_AICTRL2, - reg_name_AICTRL3, -}; - -/****************************************************************************/ - -inline void DMA1_CH3_Event() { - dma1_ch3_Active = 0; - dma_disable(DMA1, DMA_CH3); -} - -/****************************************************************************/ - -uint16_t VS1003::read_register(uint8_t _reg) const -{ - uint16_t result; - control_mode_on(); - delayMicroseconds(1); // tXCSS - my_SPI.transfer(VS_READ_COMMAND); // Read operation - my_SPI.transfer(_reg); // Which register - result = my_SPI.transfer(0xff) << 8; // read high byte - result |= my_SPI.transfer(0xff); // read low byte - delayMicroseconds(1); // tXCSH - await_data_request(); - control_mode_off(); - return result; -} - -/****************************************************************************/ - -void VS1003::write_register(uint8_t _reg,uint16_t _value) const -{ - control_mode_on(); - delayMicroseconds(1); // tXCSS - my_SPI.transfer(VS_WRITE_COMMAND); // Write operation - my_SPI.transfer(_reg); // Which register - my_SPI.transfer(_value >> 8); // Send hi byte - my_SPI.transfer(_value & 0xff); // Send lo byte - delayMicroseconds(1); // tXCSH - await_data_request(); - control_mode_off(); -} - -/****************************************************************************/ - -void VS1003::sdi_send_buffer(const uint8_t* data, size_t len) -{ - data_mode_on(); - while ( len ) - { - await_data_request(); - delayMicroseconds(3); - - size_t chunk_length = min(len,vs1003_chunk_size); - len -= chunk_length; - while ( chunk_length-- ) - my_SPI.transfer(*data++); - } - data_mode_off(); -} - -/****************************************************************************/ - -void VS1003::sdi_send_zeroes(size_t len) -{ - data_mode_on(); - while ( len ) - { - await_data_request(); - - size_t chunk_length = min(len,vs1003_chunk_size); - len -= chunk_length; - while ( chunk_length-- ) - my_SPI.transfer(0); - } - data_mode_off(); -} - -/****************************************************************************/ - -VS1003::VS1003( uint8_t _cs_pin, uint8_t _dcs_pin, uint8_t _dreq_pin, uint8_t _reset_pin, SPIClass _spiChan): - cs_pin(_cs_pin), dcs_pin(_dcs_pin), dreq_pin(_dreq_pin), reset_pin(_reset_pin), my_SPI(_spiChan) -{ -} - -/****************************************************************************/ - -void VS1003::begin(void) -{ - - // Keep the chip in reset until we are ready - pinMode(reset_pin,OUTPUT); - digitalWrite(reset_pin,LOW); - - // The SCI and SDI will start deselected - pinMode(cs_pin,OUTPUT); - digitalWrite(cs_pin,HIGH); - pinMode(dcs_pin,OUTPUT); - digitalWrite(dcs_pin,HIGH); - - // DREQ is an input - pinMode(dreq_pin,INPUT); - - - // Boot VS1003 - //printf(("Booting VS1003...\r\n")); - - delay(1); - - my_SPI.begin(); - my_SPI.setBitOrder(MSBFIRST); - my_SPI.setDataMode(SPI_MODE0); - // init SPI slow mode - - my_SPI.setClockDivider(SPI_CLOCK_DIV64); // Slow! - - // release from reset - digitalWrite(reset_pin,HIGH); - - // Declick: Immediately switch analog off - write_register(SCI_VOL,0xffff); // VOL - - /* Declick: Slow sample rate for slow analog part startup */ - write_register(SCI_AUDATA,10); - - delay(100); - - /* Switch on the analog parts */ - write_register(SCI_VOL,0xfefe); // VOL - - //printf(("VS1003 still booting\r\n")); - - write_register(SCI_AUDATA,44101); // 44.1kHz stereo - - write_register(SCI_VOL,0x2020); // VOL - - // soft reset - write_register(SCI_MODE, (1<(pgm_read_word( register_names + reg )); - char extra_tab = strlen_P(name) < 5 ? '\t' : 0; - //printf(("%02x %S\t%c = 0x%02x\r\n"),reg,name,extra_tab,read_register(reg)); -} - -/****************************************************************************/ - -void VS1003::printDetails(void) const -{ - //printf(("VS1003 Configuration:\r\n")); - int i = 0; - while ( i <= SCI_num_registers ) - print_byte_register(i++); -} - -/****************************************************************************/ -void VS1003::modeSwitch(void) -{ - //GPIO_DDR - write_register(SCI_WRAMADDR, 0xc017); - write_register(SCI_WRAM, 0x0003); - //GPIO_ODATA - write_register(SCI_WRAMADDR, 0xc019); - write_register(SCI_WRAM, 0x0000); - - delay(100); - write_register(SCI_MODE, (1< - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as published by the Free Software Foundation. - - Ported to STM32F103 by Vassilis Serasidis on 21 May 2015 - Home: http://www.serasidis.gr - email: avrsite@yahoo.gr - - 29 May 2015 - Added a fix for booting the VS1053B boards into mp3 decoding instead of booting into MIDI. - 01 July 2015 - Added a Flac decoder patch. - */ - -//This is an additional test line -#ifndef __VS1003_STM_H__ -#define __VS1003_STM_H__ - -// STL headers -// C headers -// Framework headers - -//#define USEFLAC - -#include -#include -/** - * Driver for VS1003 - MP3 / WMA / MIDI Audio Codec Chip - * - * See http://www.vlsi.fi/en/products/vs1003.html - */ - -class VS1003 -{ -private: - uint8_t cs_pin; /**< Pin where CS line is connected */ - uint8_t dcs_pin; /**< Pin where DCS line is connected */ - uint8_t dreq_pin; /**< Pin where DREQ line is connected */ - uint8_t reset_pin; /**< Pin where RESET line is connected */ - uint8_t my_SPCR; /**< Value of the SPCR register how we like it. */ - uint8_t my_SPSR; /**< Value of the SPSR register how we like it. */ - SPIClass my_SPI; - - inline void await_data_request(void) const - { - while ( !digitalRead(dreq_pin) ); - } - - inline void control_mode_on(void) const - { - digitalWrite(dcs_pin,HIGH); - digitalWrite(cs_pin,LOW); - } - - inline void control_mode_off(void) const - { - digitalWrite(cs_pin,HIGH); - } - - inline void data_mode_on(void) const - { - digitalWrite(cs_pin,HIGH); - digitalWrite(dcs_pin,LOW); - } - - inline void data_mode_off(void) const - { - digitalWrite(dcs_pin,HIGH); - } - - uint16_t read_register(uint8_t _reg) const; - void write_register(uint8_t _reg,uint16_t _value) const; - void sdi_send_buffer(const uint8_t* data,size_t len); - void sdi_send_zeroes(size_t length); - void print_byte_register(uint8_t reg) const; - - /** - * Load a user code plugin - * - * @param buf Location of memory (in PROGMEM) where the code is - * @param len Number of words to load - */ - void loadUserCode(const uint16_t* buf, size_t len) const; - -public: - - /** - * Constructor - * - * Only sets pin values. Doesn't do touch the chip. Be sure to call begin()! - */ - VS1003( uint8_t _cs_pin, uint8_t _dcs_pin, uint8_t _dreq_pin, uint8_t _reset_pin, SPIClass _spi = SPIClass(1)); - - /** - * Begin operation - * - * Sets pins correctly, and prepares SPI bus. - */ - void begin(void); - - /** - * Prepare to start playing - * - * Call this each time a new song starts. - */ - void startSong(void); - - /** - * Play a chunk of data. Copies the data to the chip. Blocks until complete. - * - * @param data Pointer to where the data lives - * @param len How many bytes of data to play - */ - void playChunk(const uint8_t* data, size_t len); - - /** - * Finish playing a song. - * - * Call this after the last playChunk call. - */ - void stopSong(void); - - /** - * Print configuration details - * - * Dumps all registers to stdout. Be sure to have stdout configured first - * (see fdevopen() in avr/io.h). - */ - void printDetails(void) const; - - /** - * - * - */ - void modeSwitch(void); - - /** - * Set the player volume - * - * @param vol Volume level from 0-255, lower is louder. - */ - void setVolume(uint8_t vol) const; - -}; - -#endif - diff --git a/GD32F1/libraries/Serasidis_VS1003B_STM/src/flac.h b/GD32F1/libraries/Serasidis_VS1003B_STM/src/flac.h deleted file mode 100644 index 106483f..0000000 --- a/GD32F1/libraries/Serasidis_VS1003B_STM/src/flac.h +++ /dev/null @@ -1,1078 +0,0 @@ -#define FLAC_PATCHLEN 8161 - //Taken from FLAC decoder patch 2015-05-25 v2.30 - const unsigned short flac_patch[FLAC_PATCHLEN] = - { - 0x0007,0x0001, /*copy 1*/ - 0x8050, - 0x0006,0x0002, /*copy 2*/ - 0x2a00,0xc000, - 0x0006, 0x801e, 0x0000, /*Rle(30)*/ - 0x0006,0x0540, /*copy 1344*/ - 0xf400,0x4095,0x0000,0x02c2,0x6124,0x0024,0x0000,0x0024, - 0x2800,0x1ac5,0x4192,0x4542,0x0000,0x0041,0x2000,0x0015, - 0x0030,0x0317,0x2000,0x0000,0x3f00,0x4024,0x2000,0x0000, - 0x0000,0x0000,0x3e12,0x3800,0x3e00,0xb804,0x0030,0x0015, - 0x0007,0x8257,0x3700,0x984c,0xf224,0x1444,0xf224,0x0024, - 0x0008,0x0002,0x2910,0x0181,0x0000,0x1bc8,0xb428,0x1402, - 0x0000,0x8004,0x2910,0x0195,0x0000,0x1bc8,0xb428,0x0024, - 0x0006,0x0095,0x2800,0x2945,0x3e13,0x780e,0x3e11,0x7803, - 0x3e13,0xf806,0x3e11,0xf801,0x3510,0xb808,0x003f,0xe004, - 0xfec4,0x3800,0x48be,0x17c3,0xfe46,0x41c2,0x48be,0x4497, - 0x4090,0x1c46,0xf06c,0x0024,0x2400,0x2580,0x6090,0x41c3, - 0x6628,0x1c47,0x0000,0x0024,0x2800,0x2449,0xf07e,0x0024, - 0xf400,0x4182,0x673a,0x1c46,0x0000,0x0024,0x2800,0x2589, - 0xf06c,0x0024,0xf400,0x41c3,0x0000,0x0024,0x4224,0x3442, - 0x2903,0xbe80,0x4336,0x37c3,0x0000,0x1805,0x2903,0xbe80, - 0x4508,0x40c2,0x450a,0x9808,0x0000,0x0207,0xa478,0x1bc0, - 0xc45a,0x1807,0x0030,0x03d5,0x3d01,0x5bc1,0x36f3,0xd806, - 0x3601,0x5803,0x36f3,0x0024,0x36f3,0x580e,0x0007,0x8257, - 0x0000,0x6004,0x3730,0x8024,0xb244,0x1c04,0xd428,0x3c02, - 0x0006,0xc717,0x2800,0x2d05,0x4284,0x0024,0x3613,0x3c02, - 0x0006,0xc357,0x2901,0x6780,0x3e11,0x5c05,0x4284,0x1bc5, - 0x0000,0x0024,0x2800,0x2fc5,0x0000,0x0024,0x3613,0x0024, - 0x3e10,0x3813,0x3e14,0x8024,0x3e04,0x8024,0x2900,0x4c00, - 0x0006,0x02d3,0x36e3,0x0024,0x3009,0x1bd3,0x0007,0x8257, - 0x3700,0x8024,0xf224,0x0024,0x0000,0x0024,0x2800,0x31d1, - 0x3600,0x9844,0x2900,0x3780,0x0000,0x3248,0x2911,0xf140, - 0x0000,0x0024,0x0030,0x0057,0x3700,0x0024,0xf200,0x4595, - 0x0fff,0xfe02,0xa024,0x164c,0x8000,0x17cc,0x3f00,0x0024, - 0x3500,0x0024,0x0021,0x6d82,0xd024,0x44c0,0x0006,0xa402, - 0x2800,0x3695,0xd024,0x0024,0x0000,0x0000,0x2800,0x3695, - 0x000b,0x6d57,0x3009,0x3c00,0x36f0,0x8024,0x36f2,0x1800, - 0x2000,0x0000,0x0000,0x0024,0x3e14,0x7810,0x3e13,0xb80d, - 0x3e13,0xf80a,0x3e10,0xb803,0x3e11,0x3805,0x3e11,0xb807, - 0x3e14,0xf801,0x0001,0x000a,0x0006,0xc4d5,0xbf8e,0x9442, - 0x3e01,0x9403,0x0006,0xa017,0x0023,0xffd1,0x0000,0x0053, - 0x3281,0xf806,0x4091,0x2d64,0x2400,0x3d00,0x4efa,0x9c10, - 0xf1eb,0x6061,0xfe55,0x2f66,0x5653,0x2d64,0x48b2,0xa201, - 0x4efa,0xa201,0x36f3,0x3c10,0x36f4,0xd801,0x36f1,0x9807, - 0x36f1,0x1805,0x36f0,0x9803,0x36f3,0xd80a,0x36f3,0x980d, - 0x2000,0x0000,0x36f4,0x5810,0x3e12,0xb817,0x3e14,0xf812, - 0x3e01,0xb811,0x0007,0x9717,0x0020,0xffd2,0x0030,0x11d1, - 0x3111,0x8024,0x3704,0xc024,0x3b81,0x8024,0x3101,0x8024, - 0x3b81,0x8024,0x3f04,0xc024,0x2808,0x4800,0x36f1,0x9811, - 0x36f3,0x0024,0x3009,0x3848,0x3e14,0x3811,0x3e00,0x0024, - 0x0000,0x4000,0x0001,0x0010,0x2915,0x94c0,0x0001,0xcc11, - 0x36f0,0x0024,0x2927,0x9e40,0x3604,0x1811,0x3613,0x0024, - 0x3e14,0x3811,0x3e00,0x0024,0x0000,0x4000,0x0001,0x0010, - 0x2915,0x94c0,0x0001,0xcc11,0x36f0,0x0024,0x36f4,0x1811, - 0x3009,0x1808,0x2000,0x0000,0x0000,0x190d,0x3600,0x3840, - 0x3e13,0x780e,0x3e13,0xf808,0x3e00,0x0024,0x0000,0x430e, - 0x0027,0x9e0f,0x2922,0xb680,0x0000,0x190d,0x36f3,0x0024, - 0x36f3,0xd808,0x36f3,0x580e,0x2000,0x0000,0x3009,0x1800, - 0x3613,0x0024,0x3e22,0xb815,0x3e05,0xb814,0x3615,0x0024, - 0x0000,0x800a,0x3e13,0x7801,0x3e10,0xb803,0x3e11,0x3805, - 0x3e11,0xb807,0x3e14,0x3811,0x3e14,0xb813,0x3e03,0xf80e, - 0xb488,0x44d5,0x3543,0x134c,0x34e5,0xc024,0x3524,0x8024, - 0x35a4,0xc024,0x3710,0x8a0c,0x3540,0x4a0c,0x3d44,0x8024, - 0x3a10,0x8024,0x3590,0x0024,0x4010,0x15c1,0x6010,0x3400, - 0x3710,0x8024,0x2800,0x57c4,0x3af0,0x8024,0x3df0,0x0024, - 0x3591,0x4024,0x3530,0x4024,0x4192,0x4050,0x6100,0x1482, - 0x4020,0x1753,0xbf8e,0x1582,0x4294,0x4011,0xbd86,0x408e, - 0x2400,0x55ce,0xfe6d,0x2819,0x520e,0x0a00,0x5207,0x2819, - 0x4fbe,0x0024,0xad56,0x904c,0xaf5e,0x1010,0xf7d4,0x0024, - 0xf7fc,0x2042,0x6498,0x2046,0x3cf4,0x0024,0x3400,0x170c, - 0x4090,0x1492,0x35a4,0xc024,0x2800,0x5055,0x3c00,0x0024, - 0x4480,0x914c,0x36f3,0xd80e,0x36f4,0x9813,0x36f4,0x1811, - 0x36f1,0x9807,0x36f1,0x1805,0x36f0,0x9803,0x36f3,0x5801, - 0x3405,0x9014,0x36e3,0x0024,0x2000,0x0000,0x36f2,0x9815, - 0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814,0x3625,0x0024, - 0x0000,0x800a,0x3e10,0x3801,0x3e10,0xb803,0x3e11,0x3805, - 0x3e11,0xb807,0x3e14,0x3811,0x0006,0xa090,0x2912,0x0d00, - 0x3e14,0xc024,0x4088,0x8000,0x4080,0x0024,0x0007,0x90d1, - 0x2800,0x61c5,0x0000,0x0024,0x0007,0x9051,0x3100,0x4024, - 0x4100,0x0024,0x3900,0x0024,0x0007,0x90d1,0x0004,0x0000, - 0x31f0,0x4024,0x6014,0x0400,0x0000,0x0024,0x2800,0x6611, - 0x4080,0x0024,0x0000,0x0000,0x2800,0x6585,0x0000,0x0024, - 0x0007,0x9053,0x3300,0x0024,0x4080,0x0024,0x0000,0x0000, - 0x2800,0x6618,0x0000,0x0024,0x0007,0x9051,0x3900,0x0024, - 0x3200,0x504c,0x6410,0x0024,0x3cf0,0x0000,0x4080,0x0024, - 0x0006,0xc691,0x2800,0x7ec5,0x3009,0x0400,0x0007,0x9051, - 0x0000,0x1001,0x3100,0x0024,0x6012,0x0024,0x0006,0xc6d0, - 0x2800,0x7309,0x003f,0xe000,0x0006,0xc693,0x3900,0x0c00, - 0x3009,0x0001,0x6014,0x0024,0x0007,0x1ad0,0x2800,0x7315, - 0x3009,0x0000,0x4080,0x0024,0x0000,0x0301,0x2800,0x6d05, - 0x4090,0x0024,0x0000,0x0024,0x2800,0x6e15,0x0000,0x0024, - 0x3009,0x0000,0xc012,0x0024,0x2800,0x7300,0x3009,0x2001, - 0x3009,0x0000,0x6012,0x0024,0x0000,0x0341,0x2800,0x7015, - 0x0000,0x0024,0x6190,0x0024,0x2800,0x7300,0x3009,0x2000, - 0x6012,0x0024,0x0000,0x0381,0x2800,0x71d5,0x0000,0x0024, - 0x6190,0x0024,0x2800,0x7300,0x3009,0x2000,0x6012,0x0024, - 0x0000,0x00c0,0x2800,0x7315,0x0000,0x0024,0x3009,0x2000, - 0x0006,0xa090,0x3009,0x0000,0x4080,0x0024,0x0000,0x0081, - 0x2800,0x77d5,0x0007,0x8c13,0x3300,0x104c,0xb010,0x0024, - 0x0002,0x8001,0x2800,0x7a45,0x34f0,0x0024,0x2800,0x77c0, - 0x0000,0x0024,0x0006,0xc351,0x3009,0x0000,0x6090,0x0024, - 0x3009,0x2000,0x2900,0x0b80,0x3009,0x0405,0x0006,0xc690, - 0x0006,0xc6d1,0x3009,0x0000,0x3009,0x0401,0x6014,0x0024, - 0x0006,0xa093,0x2800,0x7651,0xb880,0x0024,0x2800,0x8780, - 0x3009,0x2c00,0x4040,0x0024,0x6012,0x0024,0x0006,0xc6d0, - 0x2800,0x8798,0x0000,0x0024,0x0006,0xc693,0x3009,0x0c00, - 0x3009,0x0001,0x6014,0x0024,0x0006,0xc350,0x2800,0x8781, - 0x0000,0x0024,0x6090,0x0024,0x3009,0x2c00,0x3009,0x0005, - 0x2900,0x0b80,0x0000,0x8788,0x3009,0x0400,0x4080,0x0024, - 0x0003,0x8000,0x2800,0x8785,0x0000,0x0024,0x6400,0x0024, - 0x0000,0x0081,0x2800,0x8789,0x0000,0x0024,0x0007,0x8c13, - 0x3300,0x0024,0xb010,0x0024,0x0006,0xc650,0x2800,0x8795, - 0x0000,0x0024,0x0001,0x0002,0x3413,0x0000,0x3009,0x0401, - 0x4010,0x8406,0x0000,0x0281,0xa010,0x13c1,0x4122,0x0024, - 0x0000,0x03c2,0x6122,0x8002,0x462c,0x0024,0x469c,0x0024, - 0xfee2,0x0024,0x48be,0x0024,0x6066,0x8400,0x0006,0xc350, - 0x2800,0x8781,0x0000,0x0024,0x4090,0x0024,0x3009,0x2400, - 0x2900,0x0b80,0x3009,0x0005,0x0007,0x1b50,0x2912,0x0d00, - 0x3613,0x0024,0x3a00,0x0380,0x4080,0x0024,0x0000,0x00c1, - 0x2800,0x9045,0x3009,0x0000,0xb010,0x008c,0x4192,0x0024, - 0x6012,0x0024,0x0006,0xf051,0x2800,0x8e58,0x3009,0x0400, - 0x0007,0x1fd1,0x30e3,0x0400,0x4080,0x0024,0x0000,0x0301, - 0x2800,0x9045,0x3009,0x0000,0xb010,0x0024,0x0000,0x0101, - 0x6012,0x0024,0x0006,0xf051,0x2800,0x9055,0x0000,0x0024, - 0x3023,0x0400,0xf200,0x184c,0xb880,0xa400,0x3009,0x2000, - 0x3009,0x0441,0x3e10,0x4402,0x2909,0xa9c0,0x3e10,0x8024, - 0x36e3,0x0024,0x36f4,0xc024,0x36f4,0x1811,0x36f1,0x9807, - 0x36f1,0x1805,0x36f0,0x9803,0x36f0,0x1801,0x3405,0x9014, - 0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000,0x36f2,0x9817, - 0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814, - 0x3615,0x0024,0x0000,0x800a,0x3e10,0xb803,0x0012,0x5103, - 0x3e11,0x3805,0x3e11,0xb807,0x3e14,0x380d,0x0030,0x0250, - 0x3e13,0xf80e,0xbe8b,0x83e0,0x290c,0x4840,0x3613,0x0024, - 0x290c,0x4840,0x4086,0x984c,0x0000,0x00ce,0x2400,0x9a4e, - 0x3009,0x1bc0,0x0000,0x01c3,0xae3a,0x184c,0x0000,0x0043, - 0x3009,0x3842,0x290c,0x4840,0x3009,0x3840,0x4084,0x9bc0, - 0xfe26,0x9bc2,0xceba,0x0024,0x4e8e,0x0024,0x4e9a,0x0024, - 0x4f8e,0x0024,0x0000,0x0102,0x2800,0x9f85,0x0030,0x0010, - 0x0000,0x0206,0x3613,0x0024,0x290c,0x4840,0x3009,0x3840, - 0x3000,0xdbc0,0xb366,0x0024,0x0000,0x0024,0x2800,0x9f95, - 0x4e8e,0x0024,0x4e9a,0x0024,0x4f8e,0x0024,0x0030,0x0010, - 0x2800,0x9c55,0x0000,0x0206,0x36f3,0xd80e,0x36f4,0x180d, - 0x36f1,0x9807,0x36f1,0x1805,0x36f0,0x9803,0x3405,0x9014, - 0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000,0x36f2,0x9817, - 0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814, - 0x3635,0x0024,0x0000,0x800a,0x3e10,0x7802,0x3e14,0x0024, - 0x2903,0x5400,0x0000,0x0201,0x0000,0x0601,0x3413,0x184c, - 0x2903,0x5b40,0x3cf0,0x0024,0x3413,0x184c,0x3400,0x3040, - 0x3009,0x33c1,0x0000,0x1fc1,0xb010,0x0024,0x6014,0x9040, - 0x0006,0x8010,0x2800,0xa8d5,0x0000,0x0024,0x34e3,0x1bcc, - 0x6890,0x0024,0x2800,0xaa80,0xb880,0x2000,0x3e10,0x1381, - 0x2903,0x9d80,0x3e00,0x4024,0x003f,0xfe41,0x36e3,0x104c, - 0x34f0,0x0024,0xa010,0x0024,0x36f4,0x0024,0x36f0,0x5802, - 0x3405,0x9014,0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000, - 0x36f2,0x9817,0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815, - 0x3e05,0xb814,0x3615,0x0024,0x0000,0x800a,0x3e10,0xb804, - 0x3e01,0x534c,0xbe8a,0x10c0,0x4080,0x0024,0x0000,0x0024, - 0x2800,0xb3c5,0x0000,0x0024,0x2903,0x5b40,0x4082,0x184c, - 0x4c8a,0x134c,0x0000,0x0001,0x6890,0x10c2,0x4294,0x0024, - 0xac22,0x0024,0xbec2,0x0024,0x0000,0x0024,0x2800,0xb3c5, - 0x0000,0x0024,0x6890,0x134c,0xb882,0x10c2,0xac22,0x0024, - 0x4c92,0x0024,0xdc92,0x0024,0xceca,0x0024,0x4e82,0x1bc5, - 0x36f0,0x9804,0x3405,0x9014,0x36f3,0x0024,0x36f2,0x1815, - 0x2000,0x0000,0x36f2,0x9817,0x3613,0x0024,0x3e12,0xb817, - 0x3e12,0x3815,0x3e05,0xb814,0x3615,0x0024,0x0000,0x800a, - 0x3e10,0x3801,0x3e10,0xb804,0x3e11,0xb807,0x3e14,0x3811, - 0x3e04,0x934c,0x3430,0x0024,0x4080,0x0024,0x0000,0x0206, - 0x2800,0xbc05,0x0006,0x8151,0x3101,0x130c,0xff0c,0x1102, - 0x6408,0x0024,0x4204,0x0024,0xb882,0x4092,0x1005,0xfe02, - 0x48be,0x0024,0x4264,0x0024,0x2903,0xaa00,0xf400,0x4090, - 0x36f4,0x8024,0x36f4,0x1811,0x36f1,0x9807,0x36f0,0x9804, - 0x36f0,0x1801,0x3405,0x9014,0x36f3,0x0024,0x36f2,0x1815, - 0x2000,0x0000,0x36f2,0x9817,0x2a08,0x1b8e,0x2803,0x7140, - 0x0000,0xbe97,0x0006,0xd397,0x2000,0x0000,0x3f00,0x0024, - 0x0007,0x0001, /*copy 1*/ - 0x8300, - 0x0006,0x1844, /*copy 6212*/ - 0x0030,0x0055,0xb080,0x1402,0x0fdf,0xffc1,0x0007,0x9257, - 0xb212,0x3c00,0x3d00,0x4024,0x0030,0x0297,0x3f00,0x0024, - 0x0007,0x9017,0x3f00,0x0024,0x0007,0x81d7,0x3f10,0x0024, - 0xc090,0x3c00,0x0006,0x0297,0xb080,0x3c00,0x0000,0x0401, - 0x000a,0x1055,0x0006,0x0017,0x3f10,0x3401,0x000a,0x2795, - 0x3f00,0x3401,0x0001,0x6757,0xf400,0x55c0,0x0000,0x0817, - 0xb080,0x57c0,0x0006,0x01d7,0x3f00,0x0024,0x0000,0x190d, - 0x000f,0xf94f,0x0000,0xca0e,0x280f,0xe100,0x0006,0x2016, - 0x0000,0x0080,0x0005,0x4f92,0x2909,0xf840,0x3613,0x2800, - 0x0006,0x0197,0x0006,0xa115,0xb080,0x0024,0x3f00,0x3400, - 0x0007,0x8a57,0x3700,0x0024,0x4080,0x0024,0x0000,0x0040, - 0x2800,0xcbd5,0x0006,0xa2d7,0x3009,0x3c00,0x0006,0xa157, - 0x3009,0x1c00,0x0006,0x01d7,0x0000,0x190d,0x000a,0x708f, - 0x0000,0xd4ce,0x290b,0x1a80,0x3f00,0x184c,0x0030,0x0017, - 0x4080,0x1c01,0x0000,0x0200,0x2800,0xc815,0xb102,0x0024, - 0x0000,0xca08,0x2800,0xc815,0x0000,0xd0ce,0x0011,0x210f, - 0x0000,0x190d,0x280f,0xcb00,0x3613,0x0024,0x0006,0xa115, - 0x0006,0x01d7,0x37f0,0x1401,0x6100,0x1c01,0x4012,0x0024, - 0x0000,0x8000,0x6010,0x0024,0x34f3,0x0400,0x2800,0xd398, - 0x0000,0x0024,0x0000,0x8001,0x6010,0x3c01,0x0000,0x000d, - 0x2811,0x8259,0x0000,0x0024,0x2a11,0x2100,0x0030,0x0257, - 0x3700,0x0024,0x4080,0x0024,0x0000,0x0024,0x2800,0xd6d5, - 0x0006,0x0197,0x0006,0xa115,0x3f00,0x3400,0x003f,0xc000, - 0xb600,0x41c1,0x0012,0x5103,0x000c,0xc002,0xdcd6,0x0024, - 0x0019,0xd4c2,0x2800,0x9305,0x0001,0x0e48,0x0013,0xd9c3, - 0x6fd6,0x0024,0x0000,0x190d,0x2800,0xdc95,0x0014,0x1b01, - 0x0020,0x480f,0x0000,0xdb4e,0x0000,0x190d,0x2820,0x41c0, - 0x0001,0x0e48,0x0039,0x324f,0x0001,0x3b4e,0x2820,0x4a18, - 0xb882,0x0024,0x2a20,0x48c0,0x003f,0xfd00,0xb700,0x0024, - 0x003f,0xf901,0x6010,0x0024,0x0014,0x1b01,0x280a,0xc505, - 0x0000,0x190d,0x0015,0x59c0,0x6fc2,0x0024,0x0019,0x9301, - 0x2800,0xe695,0x0018,0x50c0,0x290c,0x4840,0x3613,0x0024, - 0x290c,0x4840,0x4086,0x184c,0x0000,0x18c2,0x6234,0x0024, - 0x0000,0x1d02,0x2800,0xe295,0x6234,0x0024,0x0030,0x0317, - 0x2800,0xe800,0x3f00,0x0024,0x0000,0x1d82,0x2800,0xe515, - 0x6234,0x0024,0x2912,0x0d00,0x4084,0x184c,0xf200,0x0024, - 0x6200,0x0024,0x0006,0x0017,0x2800,0xe200,0xb080,0x3c40, - 0x0000,0x0202,0x2800,0xe815,0xa024,0x0024,0xc020,0x0024, - 0x2800,0xe200,0x0030,0x02d7,0x6fc2,0x0024,0x0000,0x0024, - 0x2800,0xe815,0x0000,0x0024,0x2802,0xffc0,0x000a,0xcac8, - 0x000a,0x8c8f,0x0000,0xe94e,0x000c,0x0981,0x280a,0x71c0, - 0x002c,0x9d40,0x000a,0x708f,0x0000,0xd4ce,0x280a,0xc0d5, - 0x0012,0x5182,0x6fd6,0x0024,0x003f,0xfd81,0x280a,0x8e45, - 0xb710,0x0024,0xb710,0x0024,0x003f,0xfc01,0x6012,0x0024, - 0x0000,0x0101,0x2801,0x0515,0xffd2,0x0024,0x48b2,0x0024, - 0x4190,0x0024,0x0000,0x190d,0x2801,0x0515,0x0030,0x0250, - 0xb880,0x104c,0x3cf0,0x0024,0x0010,0x5500,0xb880,0x23c0, - 0xb882,0x2000,0x0007,0x8590,0x2914,0xbec0,0x0000,0x0440, - 0x0007,0x8b50,0xb880,0x0024,0x2920,0x0100,0x3800,0x0024, - 0x2920,0x0000,0x0006,0x8a91,0x0000,0x0800,0xb880,0xa440, - 0x003f,0xfd81,0xb710,0xa7c0,0x003f,0xfc01,0x6012,0x0024, - 0x0000,0x0101,0x2801,0x0e55,0x0000,0x0024,0xffe2,0x0024, - 0x48b2,0x0024,0x4190,0x0024,0x0000,0x0024,0x2801,0x0e55, - 0x0000,0x0024,0x2912,0x2d80,0x0000,0x0780,0x4080,0x0024, - 0x0006,0x8a90,0x2801,0x0e55,0x0000,0x01c2,0xb886,0x8040, - 0x3613,0x03c1,0xbcd2,0x0024,0x0030,0x0011,0x2800,0xfad5, - 0x003f,0xff42,0xb886,0x8040,0x3009,0x03c1,0x0000,0x0020, - 0xac22,0x0024,0x0000,0x0102,0x6cd2,0x0024,0x3e10,0x0024, - 0x2909,0x8c80,0x3e00,0x4024,0x36f3,0x0024,0x3e11,0x8024, - 0x3e01,0xc024,0x2901,0x3200,0x0000,0x0201,0xf400,0x4512, - 0x2900,0x0c80,0x3213,0x1b8c,0x3100,0x0024,0xb010,0x0024, - 0x0000,0x0024,0x2801,0x0e55,0x0000,0x0024,0x291a,0x8a40, - 0x0000,0x0100,0x2920,0x0200,0x3633,0x0024,0x2920,0x0280, - 0x0000,0x0401,0x408e,0x0024,0x2920,0x0280,0x0000,0x0401, - 0x003f,0xfd81,0xb710,0x4006,0x003f,0xfc01,0x6012,0x0024, - 0x0000,0x0101,0x2801,0x0e55,0x0000,0x0024,0xffe2,0x0024, - 0x48b2,0x0024,0x4190,0x0024,0x0000,0x0024,0x2801,0x0e55, - 0x0000,0x0024,0x2912,0x2d80,0x0000,0x0780,0x4080,0x0024, - 0x0000,0x01c2,0x2800,0xf6c5,0x0006,0x8a90,0x2a01,0x0e40, - 0x2920,0x0100,0x0000,0x0401,0x0000,0x0180,0x2920,0x0200, - 0x3613,0x0024,0x2920,0x0280,0x3613,0x0024,0x0000,0x0401, - 0x2920,0x0280,0x4084,0x984c,0x0019,0x9d01,0x6212,0x0024, - 0x001e,0x5c01,0x2801,0x0995,0x6012,0x0024,0x0000,0x0024, - 0x2801,0x0b85,0x0000,0x0024,0x001b,0x5bc1,0x6212,0x0024, - 0x001b,0xdd81,0x2801,0x0f55,0x6012,0x0024,0x0000,0x0024, - 0x2801,0x0f55,0x0000,0x0024,0x0000,0x004d,0x000a,0xbf4f, - 0x280a,0xb880,0x0001,0x0c8e,0x0020,0xfb4f,0x0000,0x190d, - 0x0001,0x138e,0x2920,0x0480,0x3009,0x2bc1,0x291a,0x8a40, - 0x36e3,0x0024,0x0000,0x190d,0x000a,0x708f,0x280a,0xcac0, - 0x0000,0xd4ce,0x0030,0x0017,0x3700,0x4024,0x0000,0x0200, - 0xb102,0x0024,0x0000,0x00c0,0x2801,0x1285,0x0005,0x4f92, - 0x2909,0xf840,0x3613,0x2800,0x0006,0x0197,0x0006,0xa115, - 0xb080,0x0024,0x3f00,0x3400,0x0000,0x190d,0x000a,0x708f, - 0x280a,0xc0c0,0x0000,0xd4ce,0x0000,0x004d,0x0020,0xfe0f, - 0x2820,0xfb40,0x0001,0x148e,0x2801,0x1655,0x3009,0x1000, - 0x6012,0x93cc,0x0000,0x0024,0x2801,0x3105,0x0000,0x0024, - 0x3413,0x0024,0x34b0,0x0024,0x4080,0x0024,0x0000,0x0200, - 0x2801,0x1955,0xb882,0x0024,0x3453,0x0024,0x3009,0x13c0, - 0x4080,0x0024,0x0000,0x0200,0x2801,0x3105,0x0000,0x0024, - 0xb882,0x130c,0x0000,0x004d,0x0021,0x058f,0x2821,0x0340, - 0x0001,0x1a4e,0x2801,0x2a95,0x6012,0x0024,0x0000,0x0024, - 0x2801,0x2a95,0x0000,0x0024,0x34c3,0x184c,0x3e13,0xb80f, - 0xf400,0x4500,0x0026,0x9dcf,0x0001,0x1e4e,0x0000,0xfa0d, - 0x2926,0x8e80,0x3e10,0x110c,0x36f3,0x0024,0x2801,0x2a80, - 0x36f3,0x980f,0x001c,0xdd00,0x001c,0xd901,0x6ec2,0x0024, - 0x001c,0xdd00,0x2801,0x2155,0x0018,0xdbc1,0x3413,0x184c, - 0xf400,0x4500,0x2926,0xc640,0x3e00,0x13cc,0x2801,0x2840, - 0x36f3,0x0024,0x6ec2,0x0024,0x003f,0xc000,0x2801,0x23d5, - 0x002a,0x4001,0x3413,0x184c,0xf400,0x4500,0x2926,0xafc0, - 0x3e00,0x13cc,0x2801,0x2840,0x36f3,0x0024,0xb400,0x0024, - 0xd100,0x0024,0x0000,0x0024,0x2801,0x2845,0x0000,0x0024, - 0x3613,0x0024,0x3e11,0x4024,0x2926,0x8540,0x3e01,0x0024, - 0x4080,0x1b8c,0x0000,0x0024,0x2801,0x2845,0x0000,0x0024, - 0x3413,0x184c,0xf400,0x4500,0x2926,0x8e80,0x3e10,0x13cc, - 0x36f3,0x0024,0x3110,0x8024,0x31f0,0xc024,0x0000,0x4000, - 0x0000,0x0021,0x6d06,0x0024,0x3110,0x8024,0x2826,0xa8c4, - 0x31f0,0xc024,0x2a26,0xad00,0x34c3,0x184c,0x3410,0x8024, - 0x3430,0xc024,0x0000,0x4000,0x0000,0x0021,0x6d06,0x0024, - 0x0000,0x0024,0x2801,0x3114,0x4d06,0x0024,0x0000,0x0200, - 0x2922,0x1885,0x0001,0x2f88,0x0000,0x0200,0x3e10,0x8024, - 0x2921,0xca80,0x3e00,0xc024,0x291a,0x8a40,0x0000,0x0024, - 0x2922,0x1880,0x36f3,0x0024,0x0000,0x004d,0x0021,0x0ecf, - 0x2821,0x0bc0,0x0001,0x308e,0x2801,0x1380,0x3c30,0x4024, - 0x0000,0x190d,0x0000,0x430e,0x2821,0x0f80,0x0027,0x9e0f, - 0x0020,0xcd4f,0x2820,0xc780,0x0001,0x32ce,0x0006,0xf017, - 0x0000,0x0015,0xb070,0xbc15,0x0000,0x430e,0x0027,0x9e0f, - 0x2820,0xcd80,0x0000,0x190d,0x3613,0x0024,0x3e10,0xb803, - 0x3e14,0x3811,0x3e11,0x3805,0x3e00,0x3801,0x0007,0xc390, - 0x0006,0xa011,0x3010,0x0444,0x3050,0x4405,0x6458,0x0302, - 0xff94,0x4081,0x0003,0xffc5,0x48b6,0x0024,0xff82,0x0024, - 0x42b2,0x0042,0xb458,0x0003,0x4cd6,0x9801,0xf248,0x1bc0, - 0xb58a,0x0024,0x6de6,0x1804,0x0006,0x0010,0x3810,0x9bc5, - 0x3800,0xc024,0x36f4,0x1811,0x36f0,0x9803,0x283e,0x2d80, - 0x0fff,0xffc3,0x2801,0x4900,0x0000,0x0024,0x3413,0x0024, - 0x2801,0x3d05,0xf400,0x4517,0x2801,0x4100,0x6894,0x13cc, - 0x37b0,0x184c,0x6090,0x1d51,0x0000,0x0910,0x3f00,0x060c, - 0x3100,0x4024,0x6016,0xb812,0x000c,0x8012,0x2801,0x3f91, - 0xb884,0x0024,0x6894,0x3002,0x0000,0x028d,0x003a,0x5e0f, - 0x0001,0x510e,0x2939,0xb0c0,0x3e10,0x93cc,0x4084,0x9bd2, - 0x4282,0x0024,0x0000,0x0040,0x2801,0x4305,0x4292,0x130c, - 0x3443,0x0024,0x2801,0x4445,0x000c,0x8390,0x2a01,0x47c0, - 0x3444,0x0024,0x3073,0x0024,0xc090,0x014c,0x2801,0x47c0, - 0x3800,0x0024,0x000c,0x4113,0xb880,0x2380,0x3304,0x4024, - 0x3800,0x05cc,0xcc92,0x05cc,0x3910,0x0024,0x3910,0x4024, - 0x000c,0x8110,0x3910,0x0024,0x39f0,0x4024,0x3810,0x0024, - 0x38d0,0x4024,0x3810,0x0024,0x38f0,0x4024,0x34c3,0x0024, - 0x3444,0x0024,0x3073,0x0024,0x3063,0x0024,0x3000,0x0024, - 0x4080,0x0024,0x0000,0x0024,0x2839,0x53d5,0x4284,0x0024, - 0x3613,0x0024,0x2801,0x4b05,0x6898,0xb804,0x0000,0x0084, - 0x293b,0x1cc0,0x3613,0x0024,0x000c,0x8117,0x3711,0x0024, - 0x37d1,0x4024,0x4e8a,0x0024,0x0000,0x0015,0x2801,0x4dc5, - 0xce9a,0x0024,0x3f11,0x0024,0x3f01,0x4024,0x000c,0x8197, - 0x408a,0x9bc4,0x3f15,0x4024,0x2801,0x5005,0x4284,0x3c15, - 0x6590,0x0024,0x0000,0x0024,0x2839,0x53d5,0x4284,0x0024, - 0x0000,0x0024,0x2801,0x3bd8,0x458a,0x0024,0x2a39,0x53c0, - 0x003e,0x2d4f,0x283a,0x5ed5,0x0001,0x348e,0x000c,0x4653, - 0x0000,0x0246,0xffac,0x0c01,0x48be,0x0024,0x4162,0x4546, - 0x6642,0x4055,0x3501,0x8024,0x0000,0x0087,0x667c,0x4057, - 0x000c,0x41d5,0x283a,0x62d5,0x3501,0x8024,0x667c,0x1c47, - 0x3701,0x8024,0x283a,0x62d5,0xc67c,0x0024,0x0000,0x0024, - 0x283a,0x62c5,0x0000,0x0024,0x2a3a,0x5ec0,0x3009,0x3851, - 0x3e14,0xf812,0x3e12,0xb817,0x3e11,0x8024,0x0006,0x0293, - 0x3301,0x8024,0x468c,0x3804,0x0006,0xa057,0x2801,0x5d04, - 0x0006,0x0011,0x469c,0x0024,0x3be1,0x8024,0x2801,0x5d15, - 0x0006,0xc392,0x3311,0x0024,0x33f1,0x2844,0x3009,0x2bc4, - 0x0030,0x04d2,0x3311,0x0024,0x3a11,0x0024,0x3201,0x8024, - 0x003f,0xfc04,0xb64c,0x0fc4,0xc648,0x0024,0x3a01,0x0024, - 0x3111,0x1fd3,0x6498,0x07c6,0x868c,0x2444,0x0023,0xffd2, - 0x3901,0x8e06,0x0030,0x0551,0x3911,0x8e06,0x3961,0x9c44, - 0xf400,0x44c6,0xd46c,0x1bc4,0x36f1,0xbc13,0x2801,0x6695, - 0x36f2,0x9817,0x002b,0xffd2,0x3383,0x188c,0x3e01,0x8c06, - 0x0006,0xa097,0x3009,0x1c12,0x3213,0x0024,0x468c,0xbc12, - 0x002b,0xffd2,0xf400,0x4197,0x2801,0x6384,0x3713,0x0024, - 0x2801,0x63c5,0x37e3,0x0024,0x3009,0x2c17,0x3383,0x0024, - 0x3009,0x0c06,0x468c,0x4197,0x0006,0xa052,0x2801,0x65c4, - 0x3713,0x2813,0x2801,0x6605,0x37e3,0x0024,0x3009,0x2c17, - 0x36f1,0x8024,0x36f2,0x9817,0x36f4,0xd812,0x2100,0x0000, - 0x3904,0x5bd1,0x2a01,0x56ce,0x3e11,0x7804,0x0030,0x0257, - 0x3701,0x0024,0x0013,0x4d05,0xd45b,0xe0e1,0x0007,0xc795, - 0x2801,0x6e15,0x0fff,0xff45,0x3511,0x184c,0x4488,0xb808, - 0x0006,0x8a97,0x2801,0x6dc5,0x3009,0x1c40,0x3511,0x1fc1, - 0x0000,0x0020,0xac52,0x1405,0x6ce2,0x0024,0x0000,0x0024, - 0x2801,0x6dc1,0x68c2,0x0024,0x291a,0x8a40,0x3e10,0x0024, - 0x2921,0xca80,0x3e00,0x4024,0x36f3,0x0024,0x3009,0x1bc8, - 0x36f0,0x1801,0x3601,0x5804,0x3e13,0x780f,0x3e13,0xb808, - 0x0008,0x9b0f,0x0001,0x70ce,0x2908,0x9300,0x0000,0x004d, - 0x36f3,0x9808,0x2000,0x0000,0x36f3,0x580f,0x0007,0x81d7, - 0x3711,0x8024,0x3711,0xc024,0x3700,0x0024,0x0000,0x2001, - 0xb012,0x0024,0x0034,0x0000,0x2801,0x7385,0x0000,0x01c1, - 0x0014,0xc000,0x0000,0x01c1,0x4fce,0x0024,0xffea,0x0024, - 0x48b6,0x0024,0x4384,0x4097,0xb886,0x45c6,0xfede,0x0024, - 0x4db6,0x0024,0x466c,0x0024,0x0006,0xc610,0x8dd6,0x8007, - 0x0000,0x00c6,0xff6e,0x0024,0x48b2,0x0024,0x0034,0x2406, - 0xffee,0x0024,0x2914,0xaa80,0x40b2,0x0024,0xf1c6,0x0024, - 0xf1d6,0x0024,0x0000,0x0201,0x8d86,0x0024,0x61de,0x0024, - 0x0006,0xc612,0x2801,0x7a01,0x0006,0xc713,0x4c86,0x0024, - 0x2912,0x1180,0x0006,0xc351,0x0006,0x0210,0x2912,0x0d00, - 0x3810,0x984c,0xf200,0x2043,0x2808,0xa000,0x3800,0x0024, - 0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814, - 0x3645,0x0024,0x0000,0x800a,0x3e10,0x3801,0x3e10,0xb803, - 0x3e11,0x3805,0x3e11,0xb807,0x3e14,0x104c,0x2903,0x5400, - 0x0000,0x0081,0x4080,0x3040,0x0000,0x0101,0x2801,0x8145, - 0x0000,0x0024,0x4090,0x0024,0x0006,0x8050,0x2801,0x9555, - 0x0000,0x0024,0x2903,0x5400,0x3613,0x0024,0xb880,0x3000, - 0x2801,0x9300,0x3009,0x3380,0x2903,0x5400,0x4122,0x10cc, - 0x3cf0,0x0024,0x3001,0x0024,0x3400,0x0024,0x6800,0x0024, - 0xa408,0x9040,0x4080,0x0024,0x0000,0x07c1,0x2801,0x86d5, - 0x6894,0x1380,0x6894,0x130c,0x3460,0x0024,0x6408,0x4481, - 0x4102,0x1380,0xf400,0x4052,0x0000,0x07c1,0x34f0,0xc024, - 0x6234,0x0024,0x6824,0x0024,0xa122,0x0024,0x6014,0x0024, - 0x0000,0x0141,0x2801,0x8dd5,0x0000,0x0024,0x2903,0x5400, - 0x3613,0x0024,0x2801,0x8c40,0xb88a,0x4002,0x2900,0xac40, - 0x3e00,0x8024,0x4c8e,0xa801,0x0000,0x0201,0x3a10,0x1bcc, - 0x3000,0x0024,0xb010,0x0024,0x0000,0x0024,0x2801,0x91d5, - 0x659a,0x0024,0x6540,0x184c,0x0030,0x0010,0x2801,0x89c8, - 0x0000,0x0024,0x2801,0x91c0,0x36f3,0x0024,0x2801,0x9080, - 0xb88a,0x0024,0x2903,0x1c40,0x34d0,0x4024,0x4c8f,0xa0a1, - 0x0000,0x0201,0x3000,0x084c,0xb010,0x0024,0x0000,0x0024, - 0x2801,0x91d5,0x659a,0x0024,0x6540,0x10cc,0x0030,0x0010, - 0x2801,0x8e48,0x0000,0x0024,0x34d3,0x0024,0x3423,0x0024, - 0xf400,0x4510,0x3009,0x1380,0x6090,0x0024,0x3009,0x2000, - 0x6892,0x108c,0x34f0,0x9000,0xa122,0x984c,0x6016,0x13c1, - 0x0000,0x0102,0x2801,0x8288,0x0006,0x8150,0x2801,0x95c0, - 0x3009,0x1bcc,0x6890,0x938c,0x3800,0x0024,0x36f4,0x0024, - 0x36f1,0x9807,0x36f1,0x1805,0x36f0,0x9803,0x36f0,0x1801, - 0x3405,0x9014,0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000, - 0x36f2,0x9817,0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815, - 0x3e05,0xb814,0x3675,0x0024,0x3643,0x0024,0x0000,0x800a, - 0x3e10,0x3801,0x0000,0x0181,0x3e10,0xb803,0x3e11,0x3806, - 0x3e11,0xf810,0x3e14,0x7812,0x3e13,0xf80e,0x2903,0x2540, - 0x3e03,0x4024,0x2903,0x5400,0x4088,0x184c,0x3413,0x184c, - 0x2903,0x5400,0x6892,0x3040,0x4080,0x3040,0x0000,0x0000, - 0x2801,0xa345,0x0000,0x0024,0x6890,0x0024,0x2903,0x2540, - 0x3cd0,0x0024,0x4080,0x0024,0x0000,0x0024,0x2801,0xa395, - 0x0000,0x0024,0x3433,0x0024,0xf400,0x4510,0x34d0,0x0024, - 0x6090,0x0024,0x2903,0x2540,0x3800,0x0024,0x4080,0x10cc, - 0xf400,0x4510,0x2801,0xa105,0x34d0,0x0024,0x2801,0xa380, - 0x0000,0x0024,0x3cd0,0x0024,0x3433,0x0024,0x34a0,0x0024, - 0xf400,0x4510,0x3430,0x4024,0x6100,0x0024,0x0000,0x0341, - 0x3840,0x0024,0x3000,0x0024,0x6012,0x0024,0x0006,0x0581, - 0x2801,0xc101,0x4012,0x0024,0xf400,0x4057,0x3702,0x0024, - 0x2000,0x0000,0x0000,0x0024,0x34d3,0x184c,0x3430,0x8024, - 0x2900,0xac40,0x3e00,0x8024,0x36f3,0x11cc,0xb888,0x104c, - 0x3c10,0x0024,0x3c90,0x4024,0x2801,0xacc0,0x34e3,0x0024, - 0x3411,0x8024,0x3491,0xc024,0x4f82,0x128c,0x3400,0x4024, - 0x4142,0x0024,0xf400,0x4050,0x3800,0x0024,0x3440,0x4024, - 0x4142,0x0024,0x6498,0x4050,0x3009,0x2007,0x0006,0x8150, - 0x3000,0x11cc,0x6402,0x104c,0x0000,0x0024,0x2801,0xaa08, - 0x0000,0x0024,0x3493,0x0024,0x2801,0xdcc0,0x34f3,0x0024, - 0x2801,0xb440,0xb888,0x0024,0x3430,0x8024,0x2900,0xac40, - 0x3e00,0x8024,0x4c8e,0x130c,0x3400,0x5bcc,0x4142,0x0024, - 0xf400,0x4050,0x3800,0x0024,0x3440,0x4024,0x4142,0x0024, - 0xf400,0x4050,0x0000,0x0201,0x3009,0x2007,0x0030,0x0010, - 0x3000,0x0024,0xb010,0x0024,0x0000,0x0024,0x2801,0xdcd5, - 0x6498,0x0024,0x0006,0x8150,0x3000,0x134c,0x6402,0x984c, - 0x0000,0x0024,0x2801,0xaf88,0x0000,0x0024,0x2801,0xdcc0, - 0x3433,0x1bcc,0x0000,0x0201,0xb888,0x104c,0x3430,0x184c, - 0x6010,0x0024,0x6402,0x3000,0x0000,0x0201,0x2801,0xbcd8, - 0x0030,0x0010,0x4090,0x124c,0x2401,0xbbc0,0x0000,0x0024, - 0x3430,0x8024,0x2900,0xac40,0x3e00,0x8024,0x4c8e,0x130c, - 0x3400,0x4024,0x4142,0x0024,0xf400,0x4050,0x3800,0x0024, - 0x3410,0x4024,0x4142,0x0024,0x6498,0x4050,0x3009,0x2007, - 0x0030,0x0010,0x0000,0x0201,0x3473,0x0024,0x3490,0x0024, - 0x3e00,0x13cc,0x2901,0x7c00,0x3444,0x8024,0x3000,0x1bcc, - 0xb010,0x0024,0x0000,0x0024,0x2801,0xdcd5,0x0000,0x0024, - 0x34c3,0x184c,0x3470,0x0024,0x3e10,0x104c,0x34c0,0x4024, - 0x2900,0xb580,0x3e00,0x4024,0x2801,0xdcc0,0x36e3,0x0024, - 0x0000,0x0801,0x3413,0x0024,0x34f0,0x0024,0x6012,0x0024, - 0x0000,0x07c1,0x2801,0xdc08,0x0000,0x0024,0x6010,0x114c, - 0xb888,0x32c0,0x6402,0x0024,0x0000,0x0101,0x2801,0xc898, - 0x0000,0x0024,0x4090,0x134c,0x2401,0xc7c0,0x3009,0x184c, - 0x3430,0x8024,0x2900,0xac40,0x3e00,0x8024,0x4c8e,0x130c, - 0x3400,0x4024,0x4142,0x0024,0xf400,0x4050,0x3800,0x0024, - 0x3410,0x4024,0x4142,0x0024,0x6498,0x4050,0x3009,0x2007, - 0x0000,0x0101,0x3433,0x1bcc,0x2903,0x5400,0x3613,0x0024, - 0x0000,0x0141,0x6090,0x118c,0x2903,0x5400,0x3ca0,0x184c, - 0x3473,0x184c,0xb888,0x3380,0x3400,0x0024,0x6402,0x0024, - 0x0000,0x0201,0x2801,0xcf58,0x0000,0x0024,0x4090,0x104c, - 0x2401,0xce80,0x0000,0x0024,0x34a0,0x8024,0x2900,0xac40, - 0x3e00,0x8024,0x0006,0x8002,0x4244,0x118c,0x4244,0x0024, - 0x6498,0x4095,0x3009,0x3440,0x3009,0x37c1,0x0000,0x0201, - 0x34f3,0x0024,0x0030,0x0010,0x3490,0x0024,0x3e00,0x138c, - 0x2901,0x7c00,0x3444,0x8024,0x3000,0x1bcc,0xb010,0x0024, - 0x0000,0x0024,0x2801,0xdcd5,0x4112,0x0024,0x3463,0x0024, - 0x34a0,0x0024,0x6012,0x0024,0x0006,0x8111,0x2801,0xd899, - 0x0000,0x0024,0x3100,0x11cc,0x3490,0x4024,0x4010,0x0024, - 0x0000,0x0a01,0x6012,0x0024,0x0006,0x8151,0x2801,0xd898, - 0x0000,0x0024,0x3613,0x114c,0x3101,0x3804,0x3490,0x8024, - 0x6428,0x138c,0x3470,0x8024,0x3423,0x0024,0x3420,0xc024, - 0x4234,0x1241,0x4380,0x4092,0x2903,0xaa00,0x0006,0x8010, - 0x2801,0xdcc0,0x3009,0x1bcc,0x0006,0x8151,0x3613,0x114c, - 0x3101,0x3804,0x3490,0x8024,0x6428,0x138c,0x3470,0x8024, - 0x3423,0x0024,0x3420,0xc024,0x4234,0x1241,0x4380,0x4092, - 0x2903,0xb3c0,0x0006,0x8010,0x2801,0xdcc0,0x3009,0x1bcc, - 0x0006,0x8050,0x6890,0x0024,0x3800,0x0024,0x3433,0x0024, - 0x34d0,0x0024,0x4080,0x0024,0x0006,0x8150,0x2801,0xe245, - 0x0000,0x0024,0x3000,0x11cc,0xb888,0x10cc,0x6402,0x3240, - 0x3493,0x0024,0x3444,0x8024,0x2801,0xe258,0x4090,0x0024, - 0x2401,0xe200,0x0000,0x0024,0x6499,0x2620,0xb78e,0x4001, - 0x0000,0x0000,0x3433,0x0024,0xcfce,0x1340,0xaf0e,0x0024, - 0x3a11,0xa807,0x36f3,0x4024,0x36f3,0xd80e,0x36f4,0x5812, - 0x36f1,0xd810,0x36f1,0x1806,0x36f0,0x9803,0x36f0,0x1801, - 0x3405,0x9014,0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000, - 0x36f2,0x9817,0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815, - 0x3e05,0xb814,0x3615,0x0024,0x0000,0x800a,0x3e10,0x7802, - 0x3e10,0xf804,0x0000,0x3fc3,0x3e11,0x7806,0x3e11,0xf810, - 0xbc82,0x12cc,0x3404,0x0024,0x3023,0x0024,0x3810,0x0024, - 0x38f0,0x4024,0x3454,0x0024,0x3810,0x0024,0x38f0,0x4024, - 0x2903,0x5400,0x0000,0x0201,0x0006,0x9301,0x4088,0x134c, - 0x3400,0x8024,0xd204,0x0024,0xb234,0x0024,0x4122,0x0024, - 0xf400,0x4055,0x3500,0x0024,0x3c30,0x0024,0x0000,0x2000, - 0xb400,0x0024,0x0000,0x3001,0x2801,0xefd5,0x0000,0x3800, - 0x0000,0x0041,0xfe42,0x12cc,0x48b2,0x1090,0x3810,0x0024, - 0x38f0,0x4024,0x2802,0x10c0,0x3430,0x0024,0xb400,0x0024, - 0x6012,0x0024,0x0000,0x3801,0x2801,0xf315,0x0000,0x3c00, - 0x0000,0x07c0,0x0000,0x0041,0xb400,0x12cc,0xfe02,0x1150, - 0x48b2,0x0024,0x689a,0x2040,0x2802,0x0f80,0x38f0,0x4024, - 0xb400,0x0024,0x6012,0x0024,0x0000,0x3c01,0x2801,0xf695, - 0x0000,0x3e00,0x0000,0x03c0,0x0000,0x0085,0x4592,0x12cc, - 0xb400,0x1150,0xfe02,0x0024,0x48b2,0x0024,0x3810,0x0024, - 0x2802,0x0f80,0x38f0,0x4024,0xb400,0x0024,0x6012,0x0024, - 0x0000,0x3e01,0x2801,0xfa15,0x0000,0x3f00,0x0000,0x01c0, - 0xf20a,0x12cc,0xb400,0x1150,0xf252,0x0024,0xfe02,0x0024, - 0x48b2,0x0024,0x3810,0x0024,0x2802,0x0f80,0x38f0,0x4024, - 0xb400,0x130c,0x6012,0x0024,0x0000,0x3f01,0x2801,0xfd95, - 0x4390,0x0024,0x0000,0x0041,0x0000,0x0105,0x4590,0x13cc, - 0xb400,0x1150,0xfe02,0x0024,0x48b2,0x0024,0x3810,0x0024, - 0x2802,0x0f80,0x38f0,0x4024,0xb400,0x0024,0x6012,0x1100, - 0x0000,0x01c1,0x2802,0x0115,0x0000,0x0024,0x0000,0x0041, - 0x0000,0x0145,0x6890,0x12cc,0xb400,0x1150,0xfe02,0x0024, - 0x48b2,0x0024,0x3810,0x0024,0x2802,0x0f80,0x38f0,0x4024, - 0x6012,0x0024,0x0000,0x3f81,0x2802,0x0395,0xb430,0x0024, - 0x6012,0x0024,0x0000,0x0024,0x2802,0x0395,0x0000,0x0024, - 0x2802,0x0f80,0x0000,0x0185,0x2802,0x10c0,0xc890,0x0024, - 0x0000,0x3fc3,0x0000,0x0201,0x34d3,0x0024,0x2903,0x5400, - 0x3433,0x184c,0x0006,0x9301,0x4088,0x134c,0x3400,0x8024, - 0xd204,0x0024,0xb234,0x0024,0x4122,0x0024,0xf400,0x4055, - 0x0000,0x2001,0x3500,0x0024,0x3c30,0x0024,0x0000,0x3000, - 0xb400,0x0024,0x6012,0x0024,0x0000,0x0182,0x2802,0x09c5, - 0x0000,0x0024,0x2802,0x10c0,0xc890,0x0024,0x459a,0x12cc, - 0x3404,0x0024,0x3023,0x0024,0x3010,0x0024,0x30d0,0x4024, - 0xac22,0x0046,0x003f,0xf982,0x3011,0xc024,0x0000,0x0023, - 0xaf2e,0x0024,0x0000,0x0182,0xccf2,0x0024,0x0000,0x0fc6, - 0x0000,0x0047,0xb46c,0x2040,0xfe6e,0x23c1,0x3454,0x0024, - 0x3010,0x0024,0x30f0,0x4024,0xac22,0x0024,0xccb2,0x0024, - 0x3810,0x0024,0x38f0,0x4024,0x458a,0x134c,0x0000,0x0201, - 0x2802,0x04d5,0x0000,0x3fc3,0x3430,0x0024,0x36f1,0xd810, - 0x36f1,0x5806,0x36f0,0xd804,0x36f0,0x5802,0x3405,0x9014, - 0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000,0x36f2,0x9817, - 0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814, - 0x3675,0x0024,0x3633,0x0024,0x0000,0x800a,0x3e10,0x3801, - 0x3e10,0xb803,0x3e11,0x3805,0x3e11,0xb807,0x3e14,0x3811, - 0x3e14,0xb813,0x3e13,0xf80e,0x3e03,0x4024,0x2903,0x9100, - 0x0000,0x0381,0x000f,0xff81,0x6012,0x184c,0x0000,0x0201, - 0x2802,0x1945,0x0000,0x0024,0x2903,0x5400,0x0002,0xfc88, - 0x3613,0x0024,0x0000,0x0401,0x0006,0x8a10,0x2900,0xbf40, - 0xb880,0x1bcc,0xb880,0x11cc,0x3413,0x184c,0x3c90,0x0024, - 0x2903,0x5400,0x34f3,0x0024,0x3473,0x184c,0x3c00,0x0000, - 0x4080,0x0024,0x0006,0x9301,0x2802,0x1ec5,0x003f,0xfe04, - 0x3490,0x8024,0xa244,0x0024,0x2903,0x7400,0xb880,0x0024, - 0x2900,0xbf40,0x003f,0xfe04,0x3473,0x184c,0x0006,0x8091, - 0x3413,0x0024,0x34f0,0x8024,0x3400,0xc024,0xa346,0x0024, - 0xd234,0x0024,0x0000,0x3fc3,0xb234,0x0024,0x4122,0x1042, - 0xf400,0x4055,0x0006,0x9301,0x3500,0x0024,0xd024,0x3000, - 0xb234,0x0024,0x4122,0x0024,0x6892,0x4055,0x3500,0x0024, - 0x3cf0,0x0024,0x34a0,0x0024,0xf100,0x0024,0xb010,0x0024, - 0x3c60,0x0024,0x34b0,0x0024,0xb010,0x0024,0x0000,0x0201, - 0x2903,0x5400,0x3ce0,0x0024,0x0006,0x9301,0x3473,0x184c, - 0x3c10,0x0024,0x34f0,0x8024,0x3410,0xc024,0xd234,0x0024, - 0x0000,0x3fc3,0xb234,0x0024,0x4122,0x0024,0xf400,0x4055, - 0x003f,0xff01,0x3500,0x0024,0x3cf0,0x0024,0x34c0,0x0024, - 0xa010,0x0024,0x0000,0x03c1,0x3c40,0x0024,0x34d0,0x0024, - 0xb010,0x0024,0x0000,0x0201,0x2903,0x5400,0x3cc0,0x0024, - 0x0006,0x9301,0x3473,0x0024,0x3c10,0x0024,0x34f0,0x8024, - 0x3410,0xc024,0xd234,0x0024,0x0000,0x3fc3,0xb234,0x0024, - 0x4122,0x0024,0xf400,0x4055,0x003f,0xff01,0x3500,0x0024, - 0x3cf0,0x0024,0x3400,0x0024,0xa010,0x0024,0x0000,0x01c1, - 0x3900,0x0024,0x34e0,0x0024,0xf100,0x0024,0xb010,0x0024, - 0x6892,0x3080,0x34f0,0x0024,0xb010,0x0024,0x3cb0,0x0024, - 0x3450,0x0024,0x34a0,0x4024,0xc010,0x0024,0x0000,0x0181, - 0x2802,0x3345,0x3100,0x0024,0x6890,0x07cc,0x2802,0xfc80, - 0x3900,0x0024,0x6012,0x0024,0x0000,0x0201,0x2802,0x34d8, - 0x0000,0x0024,0x2802,0x37c0,0x6090,0x044c,0x6012,0x0024, - 0x0000,0x0281,0x2802,0x3708,0x6012,0x0024,0x0000,0x0080, - 0x2802,0x3719,0x0000,0x0024,0x2802,0x37c0,0x3113,0x0024, - 0x6890,0x07cc,0x2802,0xfc80,0x3900,0x0024,0x0000,0x0201, - 0x3900,0x114c,0x34b0,0x0024,0x6012,0x0024,0x0006,0x08c1, - 0x2802,0x4201,0x4012,0x0024,0xf400,0x4057,0x3702,0x0024, - 0x2000,0x0000,0x0000,0x0024,0x2802,0x4200,0x0000,0x0024, - 0x0000,0x0200,0x0006,0x8110,0x2802,0x4200,0x3800,0x0024, - 0x0000,0x0300,0x0006,0x8110,0x2802,0x4200,0x3800,0x0024, - 0x0006,0x8050,0x6890,0x0024,0x2802,0xfc80,0x3800,0x0024, - 0x0000,0x0400,0x0006,0x8110,0x2802,0x4200,0x3800,0x0024, - 0x0000,0x0500,0x0006,0x8110,0x2802,0x4200,0x3800,0x0024, - 0x0000,0x0600,0x0006,0x8110,0x2802,0x4200,0x3800,0x0024, - 0x0006,0x8050,0x6890,0x0024,0x2802,0xfc80,0x3800,0x0024, - 0x3423,0x184c,0x3460,0x0024,0x4080,0x0024,0x0006,0x8200, - 0x2802,0x4745,0x3e10,0x0024,0x0000,0x01c0,0x3e10,0x0024, - 0x3490,0x0024,0x2901,0xe540,0x3e00,0x13cc,0x36d3,0x11cc, - 0x3413,0x0024,0x4080,0x3240,0x34f3,0x0024,0x2802,0x4b18, - 0x0000,0x0024,0x0006,0x8010,0x6890,0x0024,0x2802,0xfc80, - 0x3800,0x0024,0x0000,0x0180,0x3e10,0x0024,0x3490,0x0024, - 0x2901,0xe540,0x3e00,0x13cc,0x36d3,0x11cc,0x3413,0x0024, - 0x4080,0x3240,0x34f3,0x0024,0x2802,0x4b18,0x0000,0x0024, - 0x0006,0x8010,0x6890,0x0024,0x2802,0xfc80,0x3800,0x0024, - 0x0000,0x0201,0x3433,0x0024,0x34d0,0x0024,0x6012,0x0024, - 0x0006,0x0ac1,0x2802,0x5d01,0x4012,0x0024,0xf400,0x4057, - 0x3702,0x0024,0x2000,0x0000,0x0000,0x0024,0x0006,0x8050, - 0x6890,0x0024,0x2802,0xfc80,0x3800,0x0024,0x0000,0x3000, - 0x2802,0x5ec0,0x0006,0x8150,0x0000,0x9000,0x0006,0x8150, - 0x3433,0x0024,0x34d0,0x4024,0x4192,0x0024,0x4192,0x0024, - 0x2802,0x5ec0,0xa010,0x0024,0x0000,0x0201,0x0006,0x8150, - 0x2903,0x5400,0x3613,0x0024,0x0006,0x9301,0x3473,0x0024, - 0x3c10,0x0024,0x34f0,0x8024,0x3410,0xc024,0xd234,0x0024, - 0x0000,0x3fc3,0xb234,0x0024,0x4122,0x0024,0xf400,0x4055, - 0x3500,0x0024,0x3cf0,0x0024,0x3490,0x0024,0x2802,0x5ec0, - 0x6090,0x0024,0x003f,0xfe04,0x0000,0x0401,0x0006,0x8150, - 0x2903,0x5400,0x3613,0x0024,0x0006,0x9301,0x3473,0x0024, - 0x3c10,0x0024,0x34f0,0x8024,0x3400,0xc024,0xa346,0x0024, - 0xd234,0x0024,0x0000,0x3fc3,0xb234,0x0024,0x4122,0x1042, - 0xf400,0x4055,0x0006,0x9301,0x3500,0x0024,0xd024,0x3000, - 0xb234,0x0024,0x4122,0x0024,0xf400,0x4055,0x3500,0x0024, - 0x3cf0,0x0024,0x3490,0x0024,0x2802,0x5ec0,0x6090,0x0024, - 0x0000,0x4000,0x0000,0x0202,0x0006,0x8150,0x3433,0x0024, - 0x34d0,0x4024,0x6122,0x0024,0xa010,0x0024,0x0004,0x8001, - 0x3800,0x110c,0x0006,0x8150,0x3000,0x0024,0x6012,0x1300, - 0x0000,0x0401,0x2802,0x6189,0x0000,0x0024,0x6890,0x82cc, - 0x2802,0xfc80,0x3800,0x0024,0x6012,0x0024,0x0006,0x0cc1, - 0x2802,0x8901,0x4012,0x0024,0xf400,0x4057,0x3702,0x0024, - 0x2000,0x0000,0x0000,0x0024,0x2802,0x8900,0x0000,0x0024, - 0x0016,0x2200,0x0006,0x8190,0x6892,0x2040,0x2802,0x8900, - 0x38f0,0x4024,0x002c,0x4400,0x0000,0x0081,0x0006,0x8190, - 0x3810,0x0024,0x2802,0x8900,0x38f0,0x4024,0x003b,0x8000, - 0x0000,0x0081,0x0006,0x8190,0x3810,0x0024,0x2802,0x8900, - 0x38f0,0x4024,0x0007,0xd000,0x0006,0x8190,0xb882,0x2040, - 0x2802,0x8900,0x38f0,0x4024,0x000f,0xa000,0x0006,0x8190, - 0xb882,0x2040,0x2802,0x8900,0x38f0,0x4024,0x0015,0x8880, - 0x0006,0x8190,0xb882,0x2040,0x2802,0x8900,0x38f0,0x4024, - 0x0017,0x7000,0x0006,0x8190,0xb882,0x2040,0x2802,0x8900, - 0x38f0,0x4024,0x001f,0x4000,0x0006,0x8190,0xb882,0x2040, - 0x2802,0x8900,0x38f0,0x4024,0x002b,0x1100,0x0006,0x8190, - 0xb882,0x2040,0x2802,0x8900,0x38f0,0x4024,0x002e,0xe000, - 0x0006,0x8190,0xb882,0x2040,0x2802,0x8900,0x38f0,0x4024, - 0x001d,0xc000,0x0006,0x8190,0x6892,0x2040,0x2802,0x8900, - 0x38f0,0x4024,0x0006,0x8190,0x0000,0x0201,0x0000,0xfa04, - 0x2903,0x5400,0x3613,0x0024,0x0006,0x9301,0xb88a,0x11cc, - 0x3c10,0x0024,0x34f0,0x8024,0x3410,0xc024,0xd234,0x0024, - 0x0000,0x3fc3,0xb234,0x0024,0x4122,0x0024,0xf400,0x4055, - 0x3500,0x0024,0x3cf0,0x0024,0x3490,0x0024,0xfe50,0x4005, - 0x48b2,0x0024,0xfeca,0x0024,0x40b2,0x0024,0x3810,0x0024, - 0x2802,0x8900,0x38f0,0x4024,0x003f,0xfe04,0x0000,0x0401, - 0x0006,0x8190,0x2903,0x5400,0x3613,0x0024,0x0006,0x9301, - 0x3473,0x0024,0x3c10,0x0024,0x34f0,0x8024,0x3400,0xc024, - 0xa346,0x0024,0xd234,0x0024,0x0000,0x3fc3,0xb234,0x0024, - 0x4122,0x1042,0xf400,0x4055,0x0006,0x9301,0x3500,0x0024, - 0xd024,0x3000,0xb234,0x0024,0x4122,0x0024,0xf400,0x4055, - 0x0000,0x0041,0x3500,0x0024,0x3cf0,0x0024,0x3490,0x0024, - 0xfe02,0x0024,0x48b2,0x0024,0x3810,0x0024,0x2802,0x8900, - 0x38f0,0x4024,0x003f,0xfe04,0x0000,0x0401,0x0006,0x8190, - 0x2903,0x5400,0x3613,0x0024,0x0006,0x9301,0x3473,0x0024, - 0x3c10,0x0024,0x34f0,0x8024,0x3400,0xc024,0xa346,0x0024, - 0xd234,0x0024,0x0000,0x3fc3,0xb234,0x0024,0x4122,0x1042, - 0xf400,0x4055,0x0006,0x9301,0x3500,0x0024,0xd024,0x3000, - 0xb234,0x0024,0x4122,0x0024,0xf400,0x4055,0x3500,0x0024, - 0x3cf0,0x0024,0x0000,0x0280,0x3490,0x4024,0xfe02,0x0024, - 0x48b2,0x0024,0x3810,0x0024,0x2802,0x8900,0x38f0,0x4024, - 0x0006,0x8010,0x6890,0x0024,0x2802,0xfc80,0x3800,0x0024, - 0x0000,0x0201,0x2903,0x5400,0x3613,0x11cc,0x3c10,0x0024, - 0x3490,0x4024,0x6014,0x13cc,0x0000,0x0081,0x2802,0x8c45, - 0x0006,0x80d0,0x0006,0x8010,0x6890,0x0024,0x2802,0xfc80, - 0x3800,0x0024,0x3010,0x0024,0x6012,0x0024,0x0000,0x0241, - 0x2802,0xabc9,0x0006,0x8112,0x0008,0x0001,0x3009,0x184c, - 0x3e10,0x4024,0x3000,0x8024,0x2901,0x9840,0x3e00,0x8024, - 0x36f3,0x004c,0x3000,0x3844,0x0008,0x0010,0xb884,0x3840, - 0x0000,0x0400,0x3e00,0x8024,0x3201,0x0024,0x2903,0x3400, - 0x6408,0x4091,0x0001,0x0000,0x000b,0x8011,0x0004,0x0010, - 0x36e3,0x0024,0x2915,0x8300,0x3009,0x1bc4,0x000b,0x8000, - 0x3613,0x0024,0x3e10,0x0024,0x3200,0xc024,0x2901,0x9840, - 0x3e00,0xc024,0x36f3,0x084c,0x32f0,0xf844,0x3e10,0xc024, - 0x3e00,0x8024,0x2b01,0x0091,0x0000,0x0400,0xf204,0x0804, - 0x2903,0x3400,0x6408,0x0024,0x000b,0x8011,0x0008,0x0010, - 0x0000,0x0084,0x36d3,0x0024,0x2915,0x8300,0x0003,0x8000, - 0x0005,0x0010,0x0001,0x0000,0x2915,0x8300,0x000f,0x0011, - 0x1006,0x0ac0,0x32f3,0x11cc,0x3200,0xd08c,0xff34,0x0024, - 0x48b6,0x0024,0x4020,0x0024,0x3c90,0x0024,0x2802,0xa800, - 0x34e3,0x0024,0x0006,0x8112,0x3613,0x0024,0x3e10,0x0024, - 0x3000,0x4024,0x2901,0x9840,0x3e00,0x4024,0x36f3,0x004c, - 0x3000,0x7844,0xb884,0x3841,0x2b01,0x0091,0x0000,0x0400, - 0x3e00,0x8024,0x3201,0x0024,0x2903,0x3400,0x6408,0x0024, - 0x0003,0x8000,0x000b,0x8011,0x0008,0x0010,0x36e3,0x11cc, - 0x3423,0x0024,0x3494,0xc024,0x2903,0x5f80,0x3301,0x138c, - 0x0001,0x0000,0x000f,0x0011,0x0004,0x0010,0x2903,0x64c0, - 0x3301,0x0024,0xf400,0x4510,0x000b,0x8011,0x3073,0x0024, - 0x3023,0x0024,0x3000,0x0024,0x6090,0x0024,0x3800,0x0024, - 0x0003,0x8000,0x3004,0xc024,0x0008,0x0010,0x2903,0x64c0, - 0x3301,0x0024,0x0001,0x0000,0x000f,0x0011,0x0005,0x0010, - 0x2903,0x64c0,0x3301,0x0024,0xf400,0x4510,0x3073,0x1bc4, - 0x6498,0x008c,0x3000,0x0024,0x6090,0x0024,0x3800,0x0024, - 0x0006,0x80d0,0x3000,0x0024,0x6402,0x0024,0x0006,0x8110, - 0x2802,0x9b48,0x000b,0x8000,0x000b,0x8010,0x0001,0x0000, - 0x2903,0xc580,0x0004,0x0011,0x0005,0x0011,0x000b,0x8010, - 0x0001,0x0000,0x291f,0xc6c0,0x0002,0xbd08,0x30e1,0x184c, - 0x3000,0x0024,0x6012,0x0024,0x0008,0x0001,0x2802,0xad95, - 0x0000,0x0024,0x6498,0x0024,0x3e10,0x4024,0x0000,0x0081, - 0x2901,0x9840,0x3e01,0x0024,0x36e3,0x004c,0x3000,0x0024, - 0x6012,0x0024,0x000b,0x8011,0x2802,0xb9d5,0x0006,0x8112, - 0x0000,0x0201,0x0004,0x0010,0x2915,0x8300,0x0001,0x0000, - 0x000b,0x8011,0x0005,0x0010,0x291f,0xc6c0,0x0001,0x0000, - 0x0006,0x8110,0x30e1,0x0024,0x3000,0x0024,0x6012,0x0024, - 0x0000,0x0281,0x2802,0xb4c5,0x6012,0x0024,0x000b,0x8001, - 0x2802,0xb555,0x3613,0x0024,0x36f3,0x0024,0x000b,0x8001, - 0x6498,0x184c,0x0006,0x8112,0x0003,0x8000,0x3e10,0x4024, - 0x2901,0x9840,0x3e01,0x0024,0x36f3,0x0024,0x3009,0x3844, - 0x3e10,0x0024,0x0000,0x0400,0x3000,0x8024,0x0008,0x0010, - 0x3e00,0x8024,0x3201,0x0024,0x2903,0x3400,0x6408,0x4051, - 0x36e3,0x0024,0x2802,0xbd00,0x3009,0x1bc4,0x0000,0x0400, - 0x0000,0x0011,0x3613,0x008c,0x30d0,0x7844,0x3e10,0x4024, - 0x3000,0x8024,0x0008,0x0010,0x3e00,0x8024,0x3201,0x0024, - 0x2903,0x3400,0x6408,0x0024,0x36e3,0x0024,0x3009,0x1bc4, - 0x0006,0x8a10,0x0000,0x01c1,0x3009,0x0000,0xb010,0x0024, - 0x0000,0x0024,0x2802,0xc105,0x6192,0x0024,0x2903,0x5400, - 0x6102,0x184c,0x4088,0x0024,0x0000,0x0024,0x2802,0xc105, - 0x0000,0x0024,0x0006,0x8051,0x6890,0x0024,0x3900,0x0024, - 0x3009,0x0000,0x4080,0x0024,0x0000,0x0024,0x2903,0x7345, - 0x0002,0xc5c8,0x0006,0x9f92,0x0000,0x4003,0x3009,0x0811, - 0x3100,0x8024,0xffa6,0x0024,0x48b6,0x0024,0x2903,0x7340, - 0x4384,0x0024,0x2903,0x7400,0x3613,0x0024,0x2900,0xbf40, - 0x0000,0x0024,0x2903,0x7340,0x0000,0x0024,0x0000,0x0401, - 0x3473,0x184c,0x2903,0x5400,0x3c10,0x0024,0x3c90,0x0024, - 0x290b,0x1400,0x34f3,0x0024,0x4080,0x0024,0x0000,0x0024, - 0x2802,0xf915,0x0000,0x0024,0x3473,0x0024,0x3410,0x0024, - 0x34a0,0x4024,0x6014,0x1380,0x0000,0x0024,0x2802,0xcdc5, - 0x4080,0x0024,0x0006,0x8011,0x6890,0x0024,0xb882,0x2400, - 0x0004,0x8000,0x2914,0xbec0,0x0008,0x0010,0x0000,0x0400, - 0x3143,0x108c,0x6890,0x27c0,0x3920,0x0024,0x0004,0x8000, - 0x3900,0x0024,0x34e0,0x0024,0x4080,0x0024,0x0006,0x8150, - 0x2802,0xd1c5,0x0000,0x3200,0x0000,0x0142,0x0006,0x8210, - 0x3613,0x0024,0x3e00,0x7800,0x3011,0x8024,0x30d1,0xc024, - 0xfef4,0x4087,0x48b6,0x0040,0xfeee,0x03c1,0x2914,0xa580, - 0x42b6,0x0024,0x2802,0xd5c0,0x0007,0x89d0,0x0000,0x0142, - 0x3613,0x0024,0x3e00,0x7800,0x3031,0x8024,0x3010,0x0024, - 0x30d0,0x4024,0xfe9c,0x4181,0x48be,0x0024,0xfe82,0x0040, - 0x46be,0x03c1,0xfef4,0x4087,0x48b6,0x0024,0xfeee,0x0024, - 0x2914,0xa580,0x42b6,0x0024,0x0007,0x89d0,0x0006,0x8191, - 0x4c8a,0x9800,0xfed0,0x4005,0x48b2,0x0024,0xfeca,0x0024, - 0x40b2,0x0024,0x3810,0x0024,0x38f0,0x4024,0x3111,0x8024, - 0x468a,0x0707,0x2908,0xbe80,0x3101,0x0024,0x3123,0x11cc, - 0x3100,0x108c,0x3009,0x3000,0x0004,0x8000,0x3009,0x1241, - 0x6014,0x138c,0x000b,0x8011,0x2802,0xdc01,0x0000,0x0024, - 0x3473,0x0024,0x3423,0x0024,0x3009,0x3240,0x34e3,0x0024, - 0x2802,0xf740,0x0008,0x0012,0x0000,0x0081,0x2802,0xdd89, - 0x0006,0x80d0,0xf400,0x4004,0x3000,0x0024,0x6012,0x0024, - 0x0000,0x0005,0x2802,0xe309,0x0000,0x0024,0x6540,0x0024, - 0x0000,0x0024,0x2802,0xf358,0x4490,0x0024,0x2402,0xe240, - 0x0000,0x0024,0x0006,0x8301,0x4554,0x0800,0x4122,0x0024, - 0x659a,0x4055,0x0006,0x8341,0x3d00,0x0840,0x4122,0x0024, - 0xf400,0x4055,0x3d00,0x0024,0x2802,0xf340,0x0000,0x0024, - 0x4090,0x0024,0xf400,0x4480,0x2802,0xe855,0x000b,0x8001, - 0x6540,0x0024,0x0000,0x0024,0x2802,0xf358,0x4490,0x0024, - 0x2402,0xe780,0x0000,0x0024,0x0006,0x8301,0x4554,0x0800, - 0x4122,0x0024,0x659a,0x4055,0x0006,0x8341,0x4122,0x3400, - 0xf400,0x4055,0x3210,0x0024,0x3d00,0x0024,0x2802,0xf340, - 0x0000,0x0024,0x6014,0x0024,0x0001,0x0000,0x2802,0xef95, - 0x0003,0x8001,0x0008,0x0012,0x0008,0x0010,0x0006,0x8153, - 0x3613,0x0024,0x3009,0x3811,0x2903,0xc580,0x0004,0x0011, - 0x0008,0x0010,0x0001,0x0000,0x291f,0xc6c0,0x0005,0x0011, - 0x000f,0x0011,0x0008,0x0010,0x33d0,0x184c,0x6010,0xb844, - 0x3e10,0x0024,0x0000,0x0400,0x3320,0x4024,0x3e00,0x4024, - 0x3301,0x0024,0x2903,0x3400,0x6408,0x0024,0x36e3,0x0024, - 0x3009,0x1bc4,0x3009,0x1bd1,0x6540,0x0024,0x0000,0x0024, - 0x2802,0xf358,0x4490,0x0024,0x2402,0xf300,0x0000,0x0024, - 0x0006,0x8301,0x4554,0x0840,0x4122,0x0024,0x659a,0x4055, - 0x0006,0x8341,0x4122,0x3400,0xf400,0x4055,0x3110,0x0024, - 0x3d00,0x0024,0xf400,0x4510,0x0030,0x0013,0x3073,0x184c, - 0x3e11,0x008c,0x3009,0x0001,0x6140,0x0024,0x0000,0x0201, - 0x3009,0x2000,0x0006,0x8300,0x290c,0x7300,0x3e10,0x0024, - 0x3300,0x1b8c,0xb010,0x0024,0x0000,0x0024,0x2802,0xf915, - 0x0000,0x0024,0x3473,0x0024,0x3423,0x0024,0x3009,0x1240, - 0x4080,0x138c,0x0000,0x0804,0x2802,0xdc95,0x6402,0x0024, - 0x0006,0xd312,0x0006,0xd310,0x0006,0x8191,0x3010,0x984c, - 0x30f0,0xc024,0x0000,0x0021,0xf2d6,0x07c6,0x290a,0xf5c0, - 0x4682,0x0400,0x6894,0x0840,0xb886,0x0bc1,0xbcd6,0x0024, - 0x3a10,0x8024,0x3af0,0xc024,0x36f3,0x4024,0x36f3,0xd80e, - 0x36f4,0x9813,0x36f4,0x1811,0x36f1,0x9807,0x36f1,0x1805, - 0x36f0,0x9803,0x36f0,0x1801,0x3405,0x9014,0x36f3,0x0024, - 0x36f2,0x1815,0x2000,0x0000,0x36f2,0x9817,0x3613,0x0024, - 0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814,0x3615,0x0024, - 0x0000,0x800a,0x3e10,0x3801,0x0020,0x0001,0x3e14,0x3811, - 0x0030,0x0050,0x0030,0x0251,0x3e04,0xb813,0x3000,0x0024, - 0xc012,0x0024,0x0019,0x9300,0x3800,0x4024,0x2903,0x7100, - 0x3900,0x0024,0x2903,0x8500,0x0000,0x0300,0xb882,0x0024, - 0x2914,0xbec0,0x0006,0x8010,0x0000,0x1540,0x0007,0x8190, - 0x2900,0xa200,0x3800,0x0024,0x4080,0x0024,0x0000,0x0024, - 0x2803,0x0cd5,0x0000,0x0024,0x0006,0x8012,0x3200,0x0024, - 0x4080,0x0024,0x0030,0x0010,0x2803,0x0cd5,0x0000,0x0201, - 0x3000,0x0024,0xb010,0x0024,0x0000,0x0024,0x2803,0x0cd5, - 0x0000,0x0024,0x2900,0xa200,0x0000,0x0024,0x4080,0x0024, - 0x0006,0x8010,0x2803,0x0cd5,0x3000,0x0024,0x4080,0x0024, - 0x0000,0x0201,0x2803,0x0905,0x0030,0x0010,0x0030,0x0050, - 0xf292,0x0000,0xb012,0x0024,0x3800,0x4024,0x0030,0x0010, - 0x0000,0x0201,0x3000,0x0024,0xb010,0x0024,0x0000,0x0024, - 0x2900,0xbed5,0x0003,0x1688,0x0006,0x8011,0x3100,0x0024, - 0x4080,0x0024,0x0000,0x0024,0x2803,0x14c5,0x0000,0x0024, - 0x0007,0x8a52,0x3200,0x0024,0x4080,0x0024,0x0000,0x0024, - 0x2803,0x14c9,0x0000,0x0024,0xf292,0x0800,0x6012,0x0024, - 0x0000,0x0000,0x2803,0x1485,0x0000,0x0024,0x3200,0x0024, - 0x4090,0x0024,0xb880,0x2800,0x3900,0x0024,0x3100,0x0024, - 0x4080,0x0024,0x0000,0x0024,0x2902,0x1305,0x0003,0x0dc8, - 0x2900,0xbec0,0x0000,0x0024,0x0000,0x0010,0x0006,0x9f51, - 0x0006,0x9f92,0x0030,0x0493,0x0000,0x0201,0x6890,0xa410, - 0x3b00,0x2810,0x0006,0x8a10,0x3009,0x0000,0x6012,0x0024, - 0x0006,0x9fd0,0x2803,0x1a08,0xb880,0x0024,0x6890,0x0024, - 0x3009,0x2000,0x36f4,0x9813,0x36f4,0x1811,0x36f0,0x1801, - 0x3405,0x9014,0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000, - 0x36f2,0x9817,0x3613,0x0024,0x3e10,0xb810,0x3e11,0x3805, - 0x3e02,0x0024,0x0030,0x0010,0xce9a,0x0002,0x0000,0x0200, - 0x2903,0x2540,0xb024,0x0024,0xc020,0x0024,0x0000,0x0200, - 0x2803,0x1e05,0x6e9a,0x0002,0x4182,0x0024,0x0000,0x0400, - 0x2803,0x23c5,0xae1a,0x0024,0x6104,0x984c,0x0000,0x0024, - 0x2903,0x5409,0x0003,0x2388,0x6103,0xe4e5,0x2903,0x5400, - 0x408a,0x188c,0x2903,0x5400,0x408a,0x4141,0x4583,0x6465, - 0x2803,0x23c0,0xceca,0x1bcc,0xc408,0x0024,0xf2e2,0x1bc8, - 0x36f1,0x1805,0x2000,0x0011,0x36f0,0x9810,0x2000,0x0000, - 0xdc92,0x0024,0x0006,0x8a17,0x3613,0x1c00,0x6093,0xe1e3, - 0x0000,0x03c3,0x0006,0x9f95,0xb132,0x9415,0x3500,0xfc01, - 0x2803,0x3355,0xa306,0x0024,0x0006,0xd397,0x003f,0xc001, - 0x3500,0x184c,0xb011,0xe4e5,0xb182,0x1c04,0xd400,0x184c, - 0x0000,0x0205,0xac52,0x3802,0x0006,0xd3c2,0x4212,0x0024, - 0xf400,0x4057,0xb182,0x1c04,0xd400,0x0024,0xac52,0x1404, - 0xd142,0x0024,0x0000,0x3fc4,0xb142,0x0024,0x4122,0x1bc2, - 0xf400,0x4057,0x3700,0x4024,0xd101,0x6465,0x0006,0xd397, - 0x3f00,0x3814,0x0025,0xffd4,0x0006,0xd317,0x3710,0x160c, - 0x0006,0x9f94,0x37f0,0x73d5,0x6c92,0x3808,0x3f10,0x0024, - 0x3ff0,0x4024,0x3009,0x1040,0x3009,0x13c1,0x6010,0x0024, - 0x0000,0x0024,0x2903,0x8dc5,0x0003,0x2f48,0x2803,0x3194, - 0x0006,0x0001,0x4010,0x0024,0x0005,0xf601,0x6010,0x0024, - 0x0000,0x0040,0x2803,0x3314,0x0030,0x0497,0x3f00,0x0024, - 0x36f2,0x1814,0x4330,0x9803,0x2000,0x0000,0x8880,0x1bc1, - 0x3613,0x0024,0x3e22,0xb806,0x3e05,0xb814,0x3615,0x0024, - 0x0000,0x800a,0x3e10,0x3801,0x3e10,0xb803,0x3e11,0x7807, - 0x6848,0x930c,0x3411,0x780d,0x459a,0x10c0,0x0000,0x0201, - 0x6012,0x384e,0x0000,0x0241,0x2803,0x3a95,0x6012,0x380f, - 0x2403,0x39c5,0x0000,0x0024,0x3000,0x0001,0x3101,0x8407, - 0x6cfe,0x0024,0xac42,0x0024,0xaf4e,0x2040,0x3911,0x8024, - 0x2803,0x4640,0x0000,0x0024,0x0000,0x0281,0x2803,0x3dd5, - 0x6012,0x4455,0x2403,0x3d05,0x0000,0x0024,0x3000,0x0001, - 0x3101,0x8407,0x4cf2,0x0024,0xac42,0x0024,0xaf4e,0x2040, - 0x3911,0x8024,0x2803,0x4640,0x0000,0x0024,0x0000,0x0024, - 0x2803,0x4215,0x4080,0x0024,0x3110,0x0401,0xf20f,0x0203, - 0x2403,0x4145,0x8dd6,0x0024,0x4dce,0x0024,0xf1fe,0x0024, - 0xaf4e,0x0024,0x6dc6,0x2046,0xf1df,0x0203,0xaf4f,0x1011, - 0xf20e,0x07cc,0x8dd6,0x2486,0x2803,0x4640,0x0000,0x0024, - 0x0000,0x0024,0x2803,0x4495,0x0000,0x0024,0x0fff,0xffd1, - 0x2403,0x43c5,0x3010,0x0001,0xac4f,0x0801,0x3821,0x8024, - 0x2803,0x4640,0x0000,0x0024,0x0fff,0xffd1,0x2403,0x4605, - 0x3010,0x0001,0x3501,0x9407,0xac47,0x0801,0xaf4e,0x2082, - 0x3d11,0x8024,0x36f3,0xc024,0x36f3,0x980d,0x36f1,0x5807, - 0x36f0,0x9803,0x36f0,0x1801,0x3405,0x9014,0x36e3,0x0024, - 0x2000,0x0000,0x36f2,0x9806,0x0006,0x9f97,0x3e00,0x5c15, - 0x0006,0xd397,0x003f,0xc001,0x3500,0x3840,0xb011,0xe4e5, - 0xb182,0x1c04,0xd400,0x184c,0x0000,0x0205,0xac52,0x3802, - 0x0006,0xd3c2,0x4212,0x0024,0xb182,0x4057,0x3701,0x0024, - 0xd400,0x0024,0xac52,0x1404,0xd142,0x0024,0x0000,0x3fc4, - 0xb142,0x0024,0x4122,0x1bc2,0xf400,0x4057,0x3700,0x4024, - 0xd101,0x6465,0x0006,0xd397,0x3f00,0x3814,0x0025,0xffd4, - 0x0006,0xd317,0x3710,0x160c,0x0006,0x9f94,0x37f0,0x73d5, - 0x6c92,0x0024,0x3f10,0x1040,0x3ff0,0x53c1,0x6010,0x0024, - 0x0000,0x0024,0x2803,0x5214,0x0006,0x0001,0x4010,0x0024, - 0x0005,0xf601,0x6010,0x9bd4,0x0000,0x0040,0x2803,0x5394, - 0x0030,0x0497,0x3f00,0x0024,0x2000,0x0000,0x36f0,0x5800, - 0x3e10,0xb812,0x3e11,0xb810,0x3e12,0x0024,0x0006,0x9f92, - 0x0025,0xffd0,0x3e04,0x4bd1,0x3181,0xf847,0xb68c,0x4440, - 0x3009,0x0802,0x6024,0x3806,0x0006,0x8a10,0x2903,0x8dc5, - 0x0003,0x5608,0x0000,0x0800,0x6101,0x1602,0xaf2e,0x0024, - 0x4214,0x1be3,0xaf0e,0x1811,0x0fff,0xfc00,0xb200,0x9bc7, - 0x0000,0x03c0,0x2803,0x5a45,0xb204,0xa002,0x2903,0x4880, - 0x3613,0x2002,0x4680,0x1bc8,0x36f1,0x9810,0x2000,0x0000, - 0x36f0,0x9812,0x0000,0x0400,0x6102,0x0024,0x3e11,0x3805, - 0x2803,0x5e49,0x3e02,0x0024,0x2903,0x5400,0x408a,0x188c, - 0x2903,0x5400,0x408a,0x4141,0x4582,0x1bc8,0x2000,0x0000, - 0x36f1,0x1805,0x2903,0x5400,0x4102,0x184c,0xb182,0x1bc8, - 0x2000,0x0000,0x36f1,0x1805,0x3613,0x0024,0x3e12,0xb815, - 0x3e11,0xb807,0x3e13,0xf80e,0x3e03,0x4024,0x680c,0x0024, - 0x0000,0x0024,0x2803,0x6398,0x409c,0x0024,0x2403,0x6346, - 0x0000,0x000a,0x3111,0xc024,0xfe4e,0x0007,0x47be,0x0024, - 0xf6fe,0x0024,0x3811,0xc024,0x36f3,0x4024,0x36f3,0xd80e, - 0x36f1,0x9807,0x2000,0x0000,0x36f2,0x9815,0x3613,0x0024, - 0x3e12,0xb815,0x3e11,0xb807,0x3e13,0xf80e,0x3e03,0x4024, - 0x680c,0x0024,0x0000,0x0024,0x2803,0x68d8,0x409c,0x0024, - 0x2403,0x6886,0x0000,0x000a,0x3111,0xc024,0xfe4e,0x8007, - 0x47be,0x0024,0xf6fe,0x0024,0x3009,0x2047,0x36f3,0x4024, - 0x36f3,0xd80e,0x36f1,0x9807,0x2000,0x0000,0x36f2,0x9815, - 0x2a03,0x6a4e,0x3e12,0xb817,0x3e10,0x3802,0x0000,0x800a, - 0x0006,0x9f97,0x3009,0x1fc2,0x3e04,0x5c00,0x6020,0xb810, - 0x0030,0x0451,0x2803,0x6d14,0x0006,0x0002,0x4020,0x0024, - 0x0005,0xfb02,0x6024,0x0024,0x0025,0xffd0,0x2803,0x6f51, - 0x3100,0x1c11,0xb284,0x0024,0x0030,0x0490,0x3800,0x8024, - 0x0025,0xffd0,0x3980,0x1810,0x36f4,0x7c11,0x36f0,0x1802, - 0x0030,0x0717,0x3602,0x8024,0x2100,0x0000,0x3f05,0xdbd7, - 0x0003,0x6a17,0x3613,0x0024,0x3e00,0x3801,0xf400,0x55c0, - 0x0000,0x0897,0xf400,0x57c0,0x0000,0x0024,0x2000,0x0000, - 0x36f0,0x1801,0x0006,0xd397,0x2000,0x0000,0x3700,0x0024, - 0xb183,0xe1e3,0x0000,0x0203,0xac32,0x40d5,0xd122,0x0024, - 0x0000,0x3fc3,0xb132,0x0024,0x0006,0xd3c3,0x4316,0x0024, - 0xf400,0x40d5,0x3500,0x5803,0x2000,0x0000,0xd010,0x1bc1, - 0x3613,0x0024,0x3e22,0xb815,0x3e05,0xb814,0x3615,0x0024, - 0x0000,0x800a,0x3e10,0x3801,0x3e10,0xb803,0xb884,0xb805, - 0xb888,0x3844,0x3e11,0xb80d,0x3e03,0xf80e,0x0000,0x03ce, - 0xf400,0x4083,0x2403,0x7f8e,0xf400,0x4105,0x0000,0x0206, - 0xa562,0x0024,0x455a,0x0024,0x0020,0x0006,0xd312,0x0024, - 0xb16c,0x0024,0x0020,0x0006,0x2803,0x7e05,0xd342,0x0024, - 0x0000,0x01c6,0xd342,0x0024,0xd56a,0x0024,0x0020,0x0006, - 0x4448,0x0024,0xb16c,0x0024,0x0020,0x0146,0x2803,0x7f85, - 0x0000,0x0024,0xd468,0x0024,0x4336,0x0024,0x0000,0x4000, - 0x0006,0xd3c1,0x0006,0x9306,0x4122,0x0024,0x462c,0x4055, - 0x4092,0x3404,0xb512,0x4195,0x6294,0x3401,0x6200,0x0024, - 0x0000,0x03ce,0x2803,0x7a11,0xb888,0x0024,0x36f3,0xd80e, - 0x36f1,0x980d,0x36f1,0x1805,0x36f0,0x9803,0x36f0,0x1801, - 0x3405,0x9014,0x36e3,0x0024,0x2000,0x0000,0x36f2,0x9815, - 0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814, - 0x3615,0x0024,0x0000,0x800a,0x3e10,0x3801,0xb880,0xb810, - 0x0006,0x9fd0,0x3e10,0x8001,0x4182,0x3811,0x0006,0xd311, - 0x2803,0x88c5,0x0006,0x8a10,0x0000,0x0200,0xbc82,0xa000, - 0x3910,0x0024,0x2903,0x7700,0x39f0,0x4024,0x0006,0x9f90, - 0x0006,0x9f51,0x3009,0x0000,0x3009,0x0401,0x6014,0x0024, - 0x0000,0x0024,0x2903,0x8dc5,0x0003,0x89c8,0x36f4,0x4024, - 0x36f0,0x9810,0x36f0,0x1801,0x3405,0x9014,0x36f3,0x0024, - 0x36f2,0x1815,0x2000,0x0000,0x36f2,0x9817,0x3613,0x0024, - 0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814,0x290a,0xd900, - 0x3605,0x0024,0x2910,0x0180,0x3613,0x0024,0x3405,0x9014, - 0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000,0x36f2,0x9817, - 0x3613,0x0024,0x3e12,0xb817,0x3e12,0x3815,0x3e05,0xb814, - 0x3615,0x0024,0x0000,0x800a,0x3e10,0xb803,0x0006,0x0002, - 0x3e11,0x3805,0x3e11,0xb807,0x3e14,0x3811,0x0006,0x9f90, - 0x3e04,0xb813,0x3009,0x0012,0x3213,0x0024,0xf400,0x4480, - 0x6026,0x0024,0x0000,0x0024,0x2803,0x9655,0x0000,0x0024, - 0x0000,0x0012,0xf400,0x4480,0x0006,0x9f50,0x3009,0x0002, - 0x6026,0x0024,0x0000,0x0024,0x2903,0x8dc5,0x0003,0x9648, - 0x0006,0x9f93,0x3201,0x0c11,0xb58a,0x0406,0x0006,0x8a11, - 0x468e,0x8400,0xb68c,0x9813,0xcfee,0x1bd2,0x0000,0x0804, - 0xaf0e,0x9811,0x4f86,0x1bd0,0x0000,0x0021,0x6418,0x9807, - 0x6848,0x1bc6,0xad46,0x9805,0xf400,0x4080,0x36f1,0x0024, - 0x36f0,0x9803,0x3405,0x9014,0x36f3,0x0024,0x36f2,0x1815, - 0x2000,0x0000,0x36f2,0x9817,0x3613,0x0024,0x3e12,0xb817, - 0x3e12,0x3815,0x3e05,0xb814,0x3615,0x0024,0x0000,0x800a, - 0x3e10,0x3801,0x3e10,0xb803,0x3e11,0x3805,0x2803,0xa480, - 0x3e04,0x3811,0x0000,0x0401,0x2903,0x5400,0x3613,0x0024, - 0x0000,0x0080,0xb882,0x130c,0xf400,0x4510,0x3010,0x910c, - 0x30f0,0xc024,0x6dc2,0x0024,0x3810,0x0024,0x38f0,0x4024, - 0x0000,0x0201,0x3100,0x0024,0xb010,0x0024,0x0000,0x0024, - 0x2803,0xa7d5,0x0000,0x0024,0x6894,0x130c,0xb886,0x1040, - 0x3430,0x4024,0x6dca,0x0024,0x0030,0x0011,0x2803,0xa051, - 0x0000,0x0024,0xbcd2,0x0024,0x0000,0x0201,0x2803,0xa7c5, - 0x0000,0x0024,0x2903,0x5400,0x3613,0x0024,0x36f4,0x1811, - 0x36f1,0x1805,0x36f0,0x9803,0x36f0,0x1801,0x3405,0x9014, - 0x36f3,0x0024,0x36f2,0x1815,0x2000,0x0000,0x36f2,0x9817, - 0x3613,0x0024,0x3e12,0xb815,0x0000,0x800a,0x3e14,0x7813, - 0x3e10,0xb803,0x3e11,0x3805,0x3e11,0xb807,0x3e13,0xf80e, - 0x6812,0x0024,0x3e03,0x7810,0x0fff,0xffd3,0x0000,0x0091, - 0xbd86,0x9850,0x3e10,0x3804,0x3e00,0x7812,0xbe8a,0x8bcc, - 0x409e,0x8086,0x2403,0xaf07,0xfe49,0x2821,0x526a,0x8801, - 0x5c87,0x280e,0x4eba,0x9812,0x4286,0x40e1,0xb284,0x1bc1, - 0x4de6,0x0024,0xad17,0x2627,0x4fde,0x9804,0x4498,0x1bc0, - 0x0000,0x0024,0x2803,0xad15,0x3a11,0xa807,0x36f3,0x4024, - 0x36f3,0xd80e,0x36f1,0x9807,0x36f1,0x1805,0x36f0,0x9803, - 0x36f4,0x5813,0x2000,0x0000,0x36f2,0x9815,0x3613,0x0024, - 0x3e12,0xb815,0x0000,0x800a,0x3e10,0xb803,0x3e11,0x3805, - 0x3e11,0xb807,0x3e13,0xf80e,0x6812,0x0024,0x3e03,0x7810, - 0x3009,0x1850,0x3e10,0x3804,0x3e10,0x7812,0x32f3,0x0024, - 0xbd86,0x0024,0x4091,0xe2e3,0x3009,0x0046,0x2403,0xba80, - 0x3009,0x0047,0x32f0,0x0801,0xfe1f,0x6465,0x5e8a,0x0024, - 0x44ba,0x0024,0xfee2,0x0024,0x5d8a,0x1800,0x4482,0x4160, - 0x48ba,0x8046,0x4dc6,0x1822,0x4de6,0x8047,0x36f3,0x0024, - 0x36f0,0x5812,0xad17,0x2627,0x4fde,0x9804,0x4498,0x1bc0, - 0x0000,0x0024,0x2803,0xb615,0x3a11,0xa807,0x36f3,0x4024, - 0x36f3,0xd80e,0x36f1,0x9807,0x36f1,0x1805,0x36f0,0x9803, - 0x2000,0x0000,0x36f2,0x9815,0xb386,0x40d7,0x4284,0x184c, - 0x0000,0x05c0,0x2803,0xc015,0xf5d8,0x3804,0x0000,0x0984, - 0x6400,0xb84a,0x3e13,0xf80d,0xa204,0x380e,0x0000,0x800a, - 0x0000,0x00ce,0x2403,0xc34e,0xffa4,0x0024,0x48b6,0x0024, - 0x0000,0x0024,0x2803,0xc344,0x4000,0x40c2,0x4224,0x0024, - 0x6090,0x0024,0xffa4,0x0024,0x0fff,0xfe83,0xfe86,0x1bce, - 0x36f3,0xd80d,0x48b6,0x0024,0x0fff,0xff03,0xa230,0x45c3, - 0x2000,0x0000,0x36f1,0x180a,0x4080,0x184c,0x3e13,0x780f, - 0x2803,0xc785,0x4090,0xb80e,0x2403,0xc700,0x3e04,0x0440, - 0x3810,0x0440,0x3604,0x0024,0x3009,0x1bce,0x3603,0x5bcf, - 0x2000,0x0000,0x0000,0x0024, - 0x0007,0x0001, /*copy 1*/ - 0x802e, - 0x0006,0x0002, /*copy 2*/ - 0x2801,0x6780, - 0x0007,0x0001, /*copy 1*/ - 0x8030, - 0x0006,0x0002, /*copy 2*/ - 0x2800,0x1b40, - 0x0007,0x0001, /*copy 1*/ - 0x8028, - 0x0006,0x0002, /*copy 2*/ - 0x2a00,0x3f8e, - 0x0007,0x0001, /*copy 1*/ - 0x8032, - 0x0006,0x0002, /*copy 2*/ - 0x2800,0x5c00, - 0x0007,0x0001, /*copy 1*/ - 0x3580, - 0x0006, 0x8038, 0x0000, /*Rle(56)*/ - 0x0007,0x0001, /*copy 1*/ - 0xfab3, - 0x0006,0x01a4, /*copy 420*/ - 0x0001,0x0001,0x0001,0x0001,0x0000,0xffff,0xfffe,0xfffb, - 0xfff9,0xfff5,0xfff2,0xffed,0xffe8,0xffe3,0xffde,0xffd8, - 0xffd3,0xffce,0xffca,0xffc7,0xffc4,0xffc4,0xffc5,0xffc7, - 0xffcc,0xffd3,0xffdc,0xffe6,0xfff3,0x0001,0x0010,0x001f, - 0x002f,0x003f,0x004e,0x005b,0x0066,0x006f,0x0074,0x0075, - 0x0072,0x006b,0x005f,0x004f,0x003c,0x0024,0x0009,0xffed, - 0xffcf,0xffb0,0xff93,0xff77,0xff5f,0xff4c,0xff3d,0xff35, - 0xff34,0xff3b,0xff4a,0xff60,0xff7e,0xffa2,0xffcd,0xfffc, - 0x002e,0x0061,0x0094,0x00c4,0x00f0,0x0114,0x0131,0x0144, - 0x014b,0x0146,0x0134,0x0116,0x00eb,0x00b5,0x0075,0x002c, - 0xffde,0xff8e,0xff3d,0xfeef,0xfea8,0xfe6a,0xfe39,0xfe16, - 0xfe05,0xfe06,0xfe1b,0xfe43,0xfe7f,0xfecd,0xff2a,0xff95, - 0x0009,0x0082,0x00fd,0x0173,0x01e1,0x0242,0x0292,0x02cc, - 0x02ec,0x02f2,0x02da,0x02a5,0x0253,0x01e7,0x0162,0x00c9, - 0x0021,0xff70,0xfebc,0xfe0c,0xfd68,0xfcd5,0xfc5b,0xfc00, - 0xfbc9,0xfbb8,0xfbd2,0xfc16,0xfc85,0xfd1b,0xfdd6,0xfeae, - 0xff9e,0x009c,0x01a0,0x02a1,0x0392,0x046c,0x0523,0x05b0, - 0x060a,0x062c,0x0613,0x05bb,0x0526,0x0456,0x0351,0x021f, - 0x00c9,0xff5a,0xfde1,0xfc6a,0xfb05,0xf9c0,0xf8aa,0xf7d0, - 0xf73d,0xf6fa,0xf70f,0xf77e,0xf848,0xf96b,0xfadf,0xfc9a, - 0xfe8f,0x00ad,0x02e3,0x051a,0x073f,0x0939,0x0af4,0x0c5a, - 0x0d59,0x0de1,0x0de5,0x0d5c,0x0c44,0x0a9e,0x0870,0x05c7, - 0x02b4,0xff4e,0xfbaf,0xf7f8,0xf449,0xf0c7,0xed98,0xeae0, - 0xe8c4,0xe765,0xe6e3,0xe756,0xe8d2,0xeb67,0xef19,0xf3e9, - 0xf9cd,0x00b5,0x088a,0x112b,0x1a72,0x2435,0x2e42,0x3866, - 0x426b,0x4c1b,0x553e,0x5da2,0x6516,0x6b6f,0x7087,0x7441, - 0x7686,0x774a,0x7686,0x7441,0x7087,0x6b6f,0x6516,0x5da2, - 0x553e,0x4c1b,0x426b,0x3866,0x2e42,0x2435,0x1a72,0x112b, - 0x088a,0x00b5,0xf9cd,0xf3e9,0xef19,0xeb67,0xe8d2,0xe756, - 0xe6e3,0xe765,0xe8c4,0xeae0,0xed98,0xf0c7,0xf449,0xf7f8, - 0xfbaf,0xff4e,0x02b4,0x05c7,0x0870,0x0a9e,0x0c44,0x0d5c, - 0x0de5,0x0de1,0x0d59,0x0c5a,0x0af4,0x0939,0x073f,0x051a, - 0x02e3,0x00ad,0xfe8f,0xfc9a,0xfadf,0xf96b,0xf848,0xf77e, - 0xf70f,0xf6fa,0xf73d,0xf7d0,0xf8aa,0xf9c0,0xfb05,0xfc6a, - 0xfde1,0xff5a,0x00c9,0x021f,0x0351,0x0456,0x0526,0x05bb, - 0x0613,0x062c,0x060a,0x05b0,0x0523,0x046c,0x0392,0x02a1, - 0x01a0,0x009c,0xff9e,0xfeae,0xfdd6,0xfd1b,0xfc85,0xfc16, - 0xfbd2,0xfbb8,0xfbc9,0xfc00,0xfc5b,0xfcd5,0xfd68,0xfe0c, - 0xfebc,0xff70,0x0021,0x00c9,0x0162,0x01e7,0x0253,0x02a5, - 0x02da,0x02f2,0x02ec,0x02cc,0x0292,0x0242,0x01e1,0x0173, - 0x00fd,0x0082,0x0009,0xff95,0xff2a,0xfecd,0xfe7f,0xfe43, - 0xfe1b,0xfe06,0xfe05,0xfe16,0xfe39,0xfe6a,0xfea8,0xfeef, - 0xff3d,0xff8e,0xffde,0x002c,0x0075,0x00b5,0x00eb,0x0116, - 0x0134,0x0146,0x014b,0x0144,0x0131,0x0114,0x00f0,0x00c4, - 0x0094,0x0061,0x002e,0xfffc,0xffcd,0xffa2,0xff7e,0xff60, - 0xff4a,0xff3b,0xff34,0xff35,0xff3d,0xff4c,0xff5f,0xff77, - 0xff93,0xffb0,0xffcf,0xffed,0x0009,0x0024,0x003c,0x004f, - 0x005f,0x006b,0x0072,0x0075,0x0074,0x006f,0x0066,0x005b, - 0x004e,0x003f,0x002f,0x001f,0x0010,0x0001,0xfff3,0xffe6, - 0xffdc,0xffd3,0xffcc,0xffc7,0xffc5,0xffc4,0xffc4,0xffc7, - 0xffca,0xffce,0xffd3,0xffd8,0xffde,0xffe3,0xffe8,0xffed, - 0xfff2,0xfff5,0xfff9,0xfffb,0xfffe,0xffff,0x0000,0x0001, - 0x0001,0x0001,0x0001,0x0000, - 0x0007,0x0001, /*copy 1*/ - 0x180b, - 0x0006,0x000d, /*copy 13*/ - 0x000f,0x0010,0x001c,0xfab3,0x3580,0x804b,0xa04b,0x0001, - 0x0000,0x3580,0x01a4,0x069e,0x06bc, - 0x0006, 0x8006, 0x0704, /*Rle(6)*/ - 0x0006,0x0027, /*copy 39*/ - 0x06d9,0x06d9,0x06d9,0x06d9,0x06d9,0x0908,0x08ec,0x08f0, - 0x08f4,0x08f8,0x08fc,0x0900,0x0904,0x0937,0x093b,0x093e, - 0x093e,0x093e,0x093e,0x0946,0x0959,0x0a24,0x0990,0x0995, - 0x099b,0x09a1,0x09a6,0x09ab,0x09b0,0x09b5,0x09ba,0x09bf, - 0x09c4,0x09c9,0x09e2,0x0a01,0x0a20,0x5a82,0x5a82, - 0x0006, 0x8006, 0x0000, /*Rle(6)*/ - 0x0006,0x0018, /*copy 24*/ - 0x6fb8,0xc180,0xc180,0x6fb8,0x0000,0x0000,0x0000,0x0000, - 0x5a82,0x5a82,0x6fb8,0xc180,0xc180,0x6fb8,0x0000,0x0000, - 0x5a82,0x5a82,0x5a82,0x5a82,0x6fb8,0xc180,0xc180,0x6fb8, - 0x0007,0x0001, /*copy 1*/ - 0x5800, - 0x0006,0x0001, /*copy 1*/ - 0x0001, - 0x0006, 0x8007, 0x0000, /*Rle(7)*/ - 0x0006,0x0018, /*copy 24*/ - 0x0002,0x0000,0xffff,0xffff,0x0000,0x0000,0x0000,0x0000, - 0x0003,0x0000,0xfffd,0xffff,0x0001,0x0000,0x0000,0x0000, - 0x0004,0x0000,0xfffa,0xffff,0x0004,0x0000,0xffff,0xffff, - 0x000a,0x0001, /*copy 1*/ - 0x0300, - }; - - - - - - - - - - - - - - - - diff --git a/GD32F1/libraries/Servo/Servo.cpp b/GD32F1/libraries/Servo/Servo.cpp deleted file mode 100644 index 6ab7045..0000000 --- a/GD32F1/libraries/Servo/Servo.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010, LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#include "Servo.h" - -#include -#include -#include -#include - -// 20 millisecond period config. For a 1-based prescaler, -// -// (prescaler * overflow / CYC_MSEC) msec = 1 timer cycle = 20 msec -// => prescaler * overflow = 20 * CYC_MSEC -// -// This picks the smallest prescaler that allows an overflow < 2^16. -#define MAX_OVERFLOW ((1 << 16) - 1) -#define CYC_MSEC (1000 * CYCLES_PER_MICROSECOND) -#define TAU_MSEC 20 -#define TAU_USEC (TAU_MSEC * 1000) -#define TAU_CYC (TAU_MSEC * CYC_MSEC) -#define SERVO_PRESCALER (TAU_CYC / MAX_OVERFLOW + 1) -#define SERVO_OVERFLOW ((uint16)round((double)TAU_CYC / SERVO_PRESCALER)) - -// Unit conversions -#define US_TO_COMPARE(us) ((uint16)map((us), 0, TAU_USEC, 0, SERVO_OVERFLOW)) -#define COMPARE_TO_US(c) ((uint32)map((c), 0, SERVO_OVERFLOW, 0, TAU_USEC)) -#define ANGLE_TO_US(a) ((uint16)(map((a), this->minAngle, this->maxAngle, \ - this->minPW, this->maxPW))) -#define US_TO_ANGLE(us) ((int16)(map((us), this->minPW, this->maxPW, \ - this->minAngle, this->maxAngle))) - -Servo::Servo() { - this->resetFields(); -} - -bool Servo::attach(uint8 pin, - uint16 minPW, - uint16 maxPW, - int16 minAngle, - int16 maxAngle) { - timer_dev *tdev = PIN_MAP[pin].timer_device; - - if (tdev == NULL) { - // don't reset any fields or ASSERT(0), to keep driving any - // previously attach()ed servo. - return false; - } - - if (this->attached()) { - this->detach(); - } - - this->pin = pin; - this->minPW = minPW; - this->maxPW = maxPW; - this->minAngle = minAngle; - this->maxAngle = maxAngle; - - pinMode(pin, PWM); - - timer_pause(tdev); - timer_set_prescaler(tdev, SERVO_PRESCALER - 1); // prescaler is 1-based - timer_set_reload(tdev, SERVO_OVERFLOW); - timer_generate_update(tdev); - timer_resume(tdev); - - return true; -} - -bool Servo::detach() { - if (!this->attached()) { - return false; - } - - timer_dev *tdev = PIN_MAP[this->pin].timer_device; - uint8 tchan = PIN_MAP[this->pin].timer_channel; - timer_set_mode(tdev, tchan, TIMER_DISABLED); - - this->resetFields(); - - return true; -} - -void Servo::write(int degrees) { - degrees = constrain(degrees, this->minAngle, this->maxAngle); - this->writeMicroseconds(ANGLE_TO_US(degrees)); -} - -int Servo::read() const { - int a = US_TO_ANGLE(this->readMicroseconds()); - // map() round-trips in a weird way we mostly correct for here; - // the round-trip is still sometimes off-by-one for write(1) and - // write(179). - return a == this->minAngle || a == this->maxAngle ? a : a + 1; -} - -void Servo::writeMicroseconds(uint16 pulseWidth) { - if (!this->attached()) { - ASSERT(0); - return; - } - - pulseWidth = constrain(pulseWidth, this->minPW, this->maxPW); - pwmWrite(this->pin, US_TO_COMPARE(pulseWidth)); -} - -uint16 Servo::readMicroseconds() const { - if (!this->attached()) { - ASSERT(0); - return 0; - } - - stm32_pin_info pin_info = PIN_MAP[this->pin]; - uint16 compare = timer_get_compare(pin_info.timer_device, - pin_info.timer_channel); - - return COMPARE_TO_US(compare); -} - -void Servo::resetFields(void) { - this->pin = NOT_ATTACHED; - this->minAngle = SERVO_DEFAULT_MIN_ANGLE; - this->maxAngle = SERVO_DEFAULT_MAX_ANGLE; - this->minPW = SERVO_DEFAULT_MIN_PW; - this->maxPW = SERVO_DEFAULT_MAX_PW; -} diff --git a/GD32F1/libraries/Servo/Servo.h b/GD32F1/libraries/Servo/Servo.h deleted file mode 100644 index 8469ee3..0000000 --- a/GD32F1/libraries/Servo/Servo.h +++ /dev/null @@ -1,196 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010, LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#ifndef _SERVO_H_ -#define _SERVO_H_ - -#include -#include - -#include - -/* - * Note on Arduino compatibility: - * - * In the Arduino implementation, PWM is done "by hand" in the sense - * that timer channels are hijacked in groups and an ISR is set which - * toggles Servo::attach()ed pins using digitalWrite(). - * - * While this scheme allows any pin to drive a servo, it chews up - * cycles and complicates the programmer's notion of when a particular - * timer channel will be in use. - * - * This implementation only allows Servo instances to attach() to pins - * that already have a timer channel associated with them, and just - * uses pwmWrite() to drive the wave. - * - * This introduces an incompatibility: while the Arduino - * implementation of attach() returns the affected channel on success - * and 0 on failure, this one returns true on success and false on - * failure. - * - * RC Servos expect a pulse every 20ms. Since periods are set for - * entire timers, rather than individual channels, attach()ing a Servo - * to a pin can interfere with other pins associated with the same - * timer. As always, your board's pin map is your friend. - */ - -// Pin number of unattached pins -#define NOT_ATTACHED (-1) - -// Default min/max pulse widths (in microseconds) and angles (in -// degrees). Values chosen for Arduino compatibility. These values -// are part of the public API; DO NOT CHANGE THEM. -#define SERVO_DEFAULT_MIN_PW 544 -#define SERVO_DEFAULT_MAX_PW 2400 -#define SERVO_DEFAULT_MIN_ANGLE 0 -#define SERVO_DEFAULT_MAX_ANGLE 180 - -/** Class for interfacing with RC servomotors. */ -class Servo { -public: - /** - * @brief Construct a new Servo instance. - * - * The new instance will not be attached to any pin. - */ - Servo(); - - /** - * @brief Associate this instance with a servomotor whose input is - * connected to pin. - * - * If this instance is already attached to a pin, it will be - * detached before being attached to the new pin. This function - * doesn't detach any interrupt attached with the pin's timer - * channel. - * - * @param pin Pin connected to the servo pulse wave input. This - * pin must be capable of PWM output. - * - * @param minPulseWidth Minimum pulse width to write to pin, in - * microseconds. This will be associated - * with a minAngle degree angle. Defaults to - * SERVO_DEFAULT_MIN_PW = 544. - * - * @param maxPulseWidth Maximum pulse width to write to pin, in - * microseconds. This will be associated - * with a maxAngle degree angle. Defaults to - * SERVO_DEFAULT_MAX_PW = 2400. - * - * @param minAngle Target angle (in degrees) associated with - * minPulseWidth. Defaults to - * SERVO_DEFAULT_MIN_ANGLE = 0. - * - * @param maxAngle Target angle (in degrees) associated with - * maxPulseWidth. Defaults to - * SERVO_DEFAULT_MAX_ANGLE = 180. - * - * @sideeffect May set pinMode(pin, PWM). - * - * @return true if successful, false when pin doesn't support PWM. - */ - bool attach(uint8 pin, - uint16 minPulseWidth=SERVO_DEFAULT_MIN_PW, - uint16 maxPulseWidth=SERVO_DEFAULT_MAX_PW, - int16 minAngle=SERVO_DEFAULT_MIN_ANGLE, - int16 maxAngle=SERVO_DEFAULT_MAX_ANGLE); - - /** - * @brief Check if this instance is attached to a servo. - * @return true if this instance is attached to a servo, false otherwise. - * @see Servo::attachedPin() - */ - bool attached() const { return this->pin != NOT_ATTACHED; } - - /** - * @brief Get the pin this instance is attached to. - * @return Pin number if currently attached to a pin, NOT_ATTACHED - * otherwise. - * @see Servo::attach() - */ - int attachedPin() const { return this->pin; } - - /** - * @brief Stop driving the servo pulse train. - * - * If not currently attached to a motor, this function has no effect. - * - * @return true if this call did anything, false otherwise. - */ - bool detach(); - - /** - * @brief Set the servomotor target angle. - * - * @param angle Target angle, in degrees. If the target angle is - * outside the range specified at attach() time, it - * will be clamped to lie in that range. - * - * @see Servo::attach() - */ - void write(int angle); - - - /** - * Get the servomotor's target angle, in degrees. This will - * lie inside the range specified at attach() time. - * - * @see Servo::attach() - */ - int read() const; - - /** - * @brief Set the pulse width, in microseconds. - * - * @param pulseWidth Pulse width to send to the servomotor, in - * microseconds. If outside of the range - * specified at attach() time, it is clamped to - * lie in that range. - * - * @see Servo::attach() - */ - void writeMicroseconds(uint16 pulseWidth); - - /** - * Get the current pulse width, in microseconds. This will - * lie within the range specified at attach() time. - * - * @see Servo::attach() - */ - uint16 readMicroseconds() const; - -private: - int16 pin; - uint16 minPW; - uint16 maxPW; - int16 minAngle; - int16 maxAngle; - - void resetFields(void); -}; - -#endif /* _SERVO_H_ */ diff --git a/GD32F1/libraries/Servo/rules.mk b/GD32F1/libraries/Servo/rules.mk deleted file mode 100644 index e013754..0000000 --- a/GD32F1/libraries/Servo/rules.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -# Local flags -CXXFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) - -# Local rules and targets -cSRCS_$(d) := - -cppSRCS_$(d) := Servo.cpp - -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ - $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CXXFLAGS := $(CXXFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) \ No newline at end of file diff --git a/GD32F1/libraries/Wire/HardWire.cpp b/GD32F1/libraries/Wire/HardWire.cpp deleted file mode 100644 index 8a63183..0000000 --- a/GD32F1/libraries/Wire/HardWire.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file HardWire.cpp - * @author Trystan Jones - * @brief Wire library, uses the hardware I2C available in the Maple to - * interact with I2C slave devices. - */ - -/* - * Library created by crenn to use the new WireBase system and allow Arduino - * users easy interaction with the I2C Hardware in a familiar method. - */ - -#include "HardWire.h" - -uint8 HardWire::process() { - int8 res = i2c_master_xfer(sel_hard, &itc_msg, 1, 0); - if (res == I2C_ERROR_PROTOCOL) { - if (sel_hard->error_flags & I2C_SR1_AF) { /* NACK */ - res = (sel_hard->error_flags & I2C_SR1_ADDR ? ENACKADDR : - ENACKTRNS); - } else if (sel_hard->error_flags & I2C_SR1_OVR) { /* Over/Underrun */ - res = EDATA; - } else { /* Bus or Arbitration error */ - res = EOTHER; - } - i2c_disable(sel_hard); - i2c_master_enable(sel_hard, (I2C_BUS_RESET | dev_flags)); - } - return res; -} - -// TODO: Add in Error Handling if devsel is out of range for other Maples -HardWire::HardWire(uint8 dev_sel, uint8 flags) { - if (dev_sel == 1) { - sel_hard = I2C1; - } else if (dev_sel == 2) { - sel_hard = I2C2; - } else { - ASSERT(1); - } - dev_flags = flags; -} - -HardWire::~HardWire() { - i2c_disable(sel_hard); - sel_hard = 0; -} - -void HardWire::begin(uint8 self_addr) { - i2c_master_enable(sel_hard, dev_flags); -} diff --git a/GD32F1/libraries/Wire/HardWire.h b/GD32F1/libraries/Wire/HardWire.h deleted file mode 100644 index 6f137b8..0000000 --- a/GD32F1/libraries/Wire/HardWire.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file HardWire.h - * @author Trystan Jones - * @brief Wire library, uses the hardware I2C available in the Maple to - * interact with I2C slave devices. - */ - -/* - * Library created by crenn to use the new WireBase system and allow Arduino - * users easy interaction with the I2C Hardware in a familiar method. - */ - -#ifndef _HARDWIRE_H_ -#define _HARDWIRE_H_ - -#include "WireBase.h" -#include "wirish.h" -#include - -class HardWire : public WireBase { -private: - i2c_dev* sel_hard; - uint8 dev_flags; -protected: - /* - * Processes the incoming I2C message defined by WireBase to the - * hardware. If an error occured, restart the I2C device. - */ - uint8 process(); -public: - /* - * Check if devsel is within range and enable selected I2C interface with - * passed flags - */ - HardWire(uint8, uint8 = 0); - - /* - * Disables the I2C device and remove the device address. - */ - ~HardWire(); - - void begin(uint8 = 0x00); -}; -extern HardWire HWire; -#endif // _HARDWIRE_H_ diff --git a/GD32F1/libraries/Wire/Wire.cpp b/GD32F1/libraries/Wire/Wire.cpp deleted file mode 100644 index 7ab4e76..0000000 --- a/GD32F1/libraries/Wire/Wire.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file Wire.cpp - * @author Trystan Jones - * @brief Wire library, uses the WireBase to create the primary interface - * while keeping low level interactions invisible to the user. - */ - -/* - * Library updated by crenn to follow new Wire system. - * Code was derived from the original Wire for maple code by leaflabs and the - * modifications by gke and ala42. - */ - /* - * Updated by Roger Clark. 20141111. Fixed issue when process() returned because of missing ACK (often caused by invalid device address being used), caused SCL to be left - * LOW so that in the next call to process() , the first clock pulse was not sent, because SCL was LOW when it should have been high. - */ - -#include "Wire.h" - -#define I2C_WRITE 0 -#define I2C_READ 1 - -/* low level conventions: - * - SDA/SCL idle high (expected high) - * - always start with i2c_delay rather than end - */ - -void TwoWire::set_scl(bool state) { - I2C_DELAY(this->i2c_delay); - digitalWrite(this->scl_pin,state); - //Allow for clock stretching - dangerous currently - if (state == HIGH) { - while(digitalRead(this->scl_pin) == 0); - } -} - -void TwoWire::set_sda(bool state) { - I2C_DELAY(this->i2c_delay); - digitalWrite(this->sda_pin, state); -} - -void TwoWire::i2c_start() { - set_sda(LOW); - set_scl(LOW); -} - -void TwoWire::i2c_stop() { - set_sda(LOW); - set_scl(HIGH); - set_sda(HIGH); -} - -bool TwoWire::i2c_get_ack() { - set_scl(LOW); - set_sda(HIGH); - set_scl(HIGH); - - bool ret = !digitalRead(this->sda_pin); - set_scl(LOW); - return ret; -} - -void TwoWire::i2c_send_ack() { - set_sda(LOW); - set_scl(HIGH); - set_scl(LOW); -} - -void TwoWire::i2c_send_nack() { - set_sda(HIGH); - set_scl(HIGH); - set_scl(LOW); -} - -uint8 TwoWire::i2c_shift_in() { - uint8 data = 0; - set_sda(HIGH); - - int i; - for (i = 0; i < 8; i++) { - set_scl(HIGH); - data |= digitalRead(this->sda_pin) << (7-i); - set_scl(LOW); - } - - return data; -} - -void TwoWire::i2c_shift_out(uint8 val) { - int i; - for (i = 0; i < 8; i++) { - set_sda(!!(val & (1 << (7 - i)) ) ); - set_scl(HIGH); - set_scl(LOW); - } -} - -uint8 TwoWire::process() { - itc_msg.xferred = 0; - - uint8 sla_addr = (itc_msg.addr << 1); - if (itc_msg.flags == I2C_MSG_READ) { - sla_addr |= I2C_READ; - } - i2c_start(); - // shift out the address we're transmitting to - i2c_shift_out(sla_addr); - if (!i2c_get_ack()) - { - i2c_stop();// Roger Clark. 20141110 added to set clock high again, as it will be left in a low state otherwise - return ENACKADDR; - } - // Recieving - if (itc_msg.flags == I2C_MSG_READ) { - while (itc_msg.xferred < itc_msg.length) { - itc_msg.data[itc_msg.xferred++] = i2c_shift_in(); - if (itc_msg.xferred < itc_msg.length) - { - i2c_send_ack(); - } - else - { - i2c_send_nack(); - } - } - } - // Sending - else { - for (uint8 i = 0; i < itc_msg.length; i++) { - i2c_shift_out(itc_msg.data[i]); - if (!i2c_get_ack()) - { - i2c_stop();// Roger Clark. 20141110 added to set clock high again, as it will be left in a low state otherwise - return ENACKTRNS; - } - itc_msg.xferred++; - } - } - i2c_stop(); - return SUCCESS; -} - -// TODO: Add in Error Handling if pins is out of range for other Maples -// TODO: Make delays more capable -TwoWire::TwoWire(uint8 scl, uint8 sda, uint8 delay) : i2c_delay(delay) { - this->scl_pin=scl; - this->sda_pin=sda; -} - -void TwoWire::begin(uint8 self_addr) { - tx_buf_idx = 0; - tx_buf_overflow = false; - rx_buf_idx = 0; - rx_buf_len = 0; - pinMode(this->scl_pin, OUTPUT_OPEN_DRAIN); - pinMode(this->sda_pin, OUTPUT_OPEN_DRAIN); - set_scl(HIGH); - set_sda(HIGH); -} - -TwoWire::~TwoWire() { - this->scl_pin=0; - this->sda_pin=0; -} - -// Declare the instance that the users of the library can use -//TwoWire Wire(SCL, SDA, SOFT_STANDARD); -TwoWire Wire(PB6, PB7, SOFT_STANDARD); diff --git a/GD32F1/libraries/Wire/Wire.h b/GD32F1/libraries/Wire/Wire.h deleted file mode 100644 index 0861309..0000000 --- a/GD32F1/libraries/Wire/Wire.h +++ /dev/null @@ -1,141 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file Wire.h - * @author Trystan Jones - * @brief Wire library, uses the WireBase to create the primary interface - * while keeping low level interactions invisible to the user. - */ - -/* - * Library updated by crenn to follow new Wire system. - * Code was derived from the original Wire for maple code by leaflabs and the - * modifications by gke and ala42. - */ - -#ifndef _WIRE_H_ -#define _WIRE_H_ - -#include "WireBase.h" -#include "wirish.h" - -/* - * On the Maple, let the default pins be in the same location as the Arduino - * pins - */ -#define SDA 19 -#define SCL 20 - -#define SOFT_STANDARD 27 -#define SOFT_FAST 0 - - -//#define I2C_DELAY(x) {uint32 time=micros(); while(time>(micros()+x));} -#define I2C_DELAY(x) do{for(int i=0;i - * @brief Wire library, following the majority of the interface from Arduino. - * Provides a 'standard' interface to I2C (two-wire) communication for - * derived classes. - */ - -/* - * Library created by crenn to allow a system which would provide users the - * 'standardised' Arduino method for interfacing with I2C devices regardless of - * whether it is I2C hardware or emulating software. - */ - -#include "WireBase.h" -#include "wirish.h" - -void WireBase::begin(uint8 self_addr) { - tx_buf_idx = 0; - tx_buf_overflow = false; - rx_buf_idx = 0; - rx_buf_len = 0; -} - -void WireBase::beginTransmission(uint8 slave_address) { - itc_msg.addr = slave_address; - itc_msg.data = &tx_buf[tx_buf_idx]; - itc_msg.length = 0; - itc_msg.flags = 0; -} - -void WireBase::beginTransmission(int slave_address) { - beginTransmission((uint8)slave_address); -} - -uint8 WireBase::endTransmission(void) { - uint8 retVal; - if (tx_buf_overflow) { - return EDATA; - } - retVal = process();// Changed so that the return value from process is returned by this function see also the return line below - tx_buf_idx = 0; - tx_buf_overflow = false; - return retVal;//SUCCESS; -} - -//TODO: Add the ability to queue messages (adding a boolean to end of function -// call, allows for the Arduino style to stay while also giving the flexibility -// to bulk send -uint8 WireBase::requestFrom(uint8 address, int num_bytes) { - if (num_bytes > WIRE_BUFSIZ) { - num_bytes = WIRE_BUFSIZ; - } - itc_msg.addr = address; - itc_msg.flags = I2C_MSG_READ; - itc_msg.length = num_bytes; - itc_msg.data = &rx_buf[rx_buf_idx]; - process(); - rx_buf_len += itc_msg.xferred; - itc_msg.flags = 0; - return rx_buf_len; -} - -uint8 WireBase::requestFrom(int address, int numBytes) { - return WireBase::requestFrom((uint8)address, numBytes); -} - -void WireBase::write(uint8 value) { - if (tx_buf_idx == WIRE_BUFSIZ) { - tx_buf_overflow = true; - return; - } - tx_buf[tx_buf_idx++] = value; - itc_msg.length++; -} - -void WireBase::write(uint8* buf, int len) { - for (uint8 i = 0; i < len; i++) { - write(buf[i]); - } -} - -void WireBase::write(int value) { - write((uint8)value); -} - -void WireBase::write(int* buf, int len) { - write((uint8*)buf, (uint8)len); -} - -void WireBase::write(char* buf) { - uint8 *ptr = (uint8*)buf; - while (*ptr) { - write(*ptr); - ptr++; - } -} - -uint8 WireBase::available() { - return rx_buf_len - rx_buf_idx; -} - -uint8 WireBase::read() { - if (rx_buf_idx == rx_buf_len) { - rx_buf_idx = 0; - rx_buf_len = 0; - return 0; - } else if (rx_buf_idx == (rx_buf_len-1)) { - uint8 temp = rx_buf[rx_buf_idx]; - rx_buf_idx = 0; - rx_buf_len = 0; - return temp; - } - return rx_buf[rx_buf_idx++]; -} diff --git a/GD32F1/libraries/Wire/WireBase.h b/GD32F1/libraries/Wire/WireBase.h deleted file mode 100644 index 4e51c0d..0000000 --- a/GD32F1/libraries/Wire/WireBase.h +++ /dev/null @@ -1,143 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file WireBase.h - * @author Trystan Jones - * @brief Wire library, following the majority of the interface from Arduino. - * Provides a 'standard' interface to I2C (two-wire) communication for - * derived classes. - */ - -/* - * Library created by crenn to allow a system which would provide users the - * 'standardised' Arduino method for interfacing with I2C devices regardless of - * whether it is I2C hardware or emulating software. - */ - -#ifndef _WIREBASE_H_ -#define _WIREBASE_H_ - -#include "wirish.h" -#include - -#define WIRE_BUFSIZ 32 - -/* return codes from endTransmission() */ -#define SUCCESS 0 /* transmission was successful */ -#define EDATA 1 /* too much data */ -#define ENACKADDR 2 /* received nack on transmit of address */ -#define ENACKTRNS 3 /* received nack on transmit of data */ -#define EOTHER 4 /* other error */ - -class WireBase { // Abstraction is awesome! -protected: - i2c_msg itc_msg; - uint8 rx_buf[WIRE_BUFSIZ]; /* receive buffer */ - uint8 rx_buf_idx; /* first unread idx in rx_buf */ - uint8 rx_buf_len; /* number of bytes read */ - - uint8 tx_buf[WIRE_BUFSIZ]; /* transmit buffer */ - uint8 tx_buf_idx; // next idx available in tx_buf, -1 overflow - boolean tx_buf_overflow; - - // Force derived classes to define process function - virtual uint8 process() = 0; -public: - WireBase() {} - ~WireBase() {} - - /* - * Initialises the class interface - */ - // Allow derived classes to overwrite begin function - virtual void begin(uint8 = 0x00); - - /* - * Sets up the transmission message to be processed - */ - void beginTransmission(uint8); - - /* - * Allow only 8 bit addresses to be used - */ - void beginTransmission(int); - - /* - * Call the process function to process the message if the TX - * buffer has not overflowed. - */ - uint8 endTransmission(void); - - /* - * Request bytes from a slave device and process the request, - * storing into the receiving buffer. - */ - uint8 requestFrom(uint8, int); - - /* - * Allow only 8 bit addresses to be used when requesting bytes - */ - uint8 requestFrom(int, int); - - /* - * Stack up bytes to be sent when transmitting - */ - void write(uint8); - - /* - * Stack up bytes from the array to be sent when transmitting - */ - void write(uint8*, int); - - /* - * Ensure that a sending data will only be 8-bit bytes - */ - void write(int); - - /* - * Ensure that an array sending data will only be 8-bit bytes - */ - void write(int*, int); - - /* - * Stack up bytes from a string to be sent when transmitting - */ - void write(char*); - - /* - * Return the amount of bytes that is currently in the receiving buffer - */ - uint8 available(); - - /* - * Return the value of byte in the receiving buffer that is currently being - * pointed to - */ - uint8 read(); -}; - -#endif // _WIREBASE_H_ diff --git a/GD32F1/libraries/Wire/examples/i2c_scanner_hwire/i2c_scanner_hwire.ino b/GD32F1/libraries/Wire/examples/i2c_scanner_hwire/i2c_scanner_hwire.ino deleted file mode 100644 index 745cae6..0000000 --- a/GD32F1/libraries/Wire/examples/i2c_scanner_hwire/i2c_scanner_hwire.ino +++ /dev/null @@ -1,76 +0,0 @@ -// -------------------------------------- -// i2c_scanner -// -// Version 1 -// This program (or code that looks like it) -// can be found in many places. -// For example on the Arduino.cc forum. -// The original author is not know. -// Version 2, Juni 2012, Using Arduino 1.0.1 -// Adapted to be as simple as possible by Arduino.cc user Krodal -// Version 3, Feb 26 2013 -// V3 by louarnold -// Version 4, March 3, 2013, Using Arduino 1.0.3 -// by Arduino.cc user Krodal. -// Changes by louarnold removed. -// Scanning addresses changed from 0...127 to 1...119, -// according to the i2c scanner by Nick Gammon -// http://www.gammon.com.au/forum/?id=10896 -// Version 5, March 28, 2013 -// As version 4, but address scans now to 127. -// A sensor seems to use address 120. -// Version 6, August 1, 2015 -// Modified to support HardWire for STM32duino -// -// This sketch tests the standard 7-bit addresses -// Devices with higher bit address might not be seen properly. -// - -#include - -HardWire HWire(1, I2C_FAST_MODE); // I2c1 - -void setup() { - Serial.begin(115200); - HWire.begin(); - Serial.println("\nI2C Scanner"); -} - - -void loop() { - byte error, address; - int nDevices; - - Serial.println("Scanning..."); - - nDevices = 0; - for(address = 1; address < 127; address++) { - // The i2c_scanner uses the return value of - // the Write.endTransmisstion to see if - // a device did acknowledge to the address. - - HWire.beginTransmission(address); - error = HWire.endTransmission(); - - if (error == 0) { - Serial.print("I2C device found at address 0x"); - if (address < 16) - Serial.print("0"); - Serial.println(address, HEX); - - nDevices++; - } - else if (error == 4) { - Serial.print("Unknown error at address 0x"); - if (address < 16) - Serial.print("0"); - Serial.println(address, HEX); - } - } - if (nDevices == 0) - Serial.println("No I2C devices found"); - else - Serial.println("done"); - - delay(5000); // wait 5 seconds for next scan -} \ No newline at end of file diff --git a/GD32F1/libraries/Wire/examples/i2c_scanner_wire/i2c_scanner_wire.ino b/GD32F1/libraries/Wire/examples/i2c_scanner_wire/i2c_scanner_wire.ino deleted file mode 100644 index 30224d2..0000000 --- a/GD32F1/libraries/Wire/examples/i2c_scanner_wire/i2c_scanner_wire.ino +++ /dev/null @@ -1,74 +0,0 @@ -// -------------------------------------- -// i2c_scanner -// -// Version 1 -// This program (or code that looks like it) -// can be found in many places. -// For example on the Arduino.cc forum. -// The original author is not know. -// Version 2, Juni 2012, Using Arduino 1.0.1 -// Adapted to be as simple as possible by Arduino.cc user Krodal -// Version 3, Feb 26 2013 -// V3 by louarnold -// Version 4, March 3, 2013, Using Arduino 1.0.3 -// by Arduino.cc user Krodal. -// Changes by louarnold removed. -// Scanning addresses changed from 0...127 to 1...119, -// according to the i2c scanner by Nick Gammon -// http://www.gammon.com.au/forum/?id=10896 -// Version 5, March 28, 2013 -// As version 4, but address scans now to 127. -// A sensor seems to use address 120. -// -// This sketch tests the standard 7-bit addresses -// Devices with higher bit address might not be seen properly. -// - -#include - - -void setup() { - - Serial.begin(115200); - Wire.begin(); - Serial.println("\nI2C Scanner"); -} - - -void loop() { - byte error, address; - int nDevices; - - Serial.println("Scanning..."); - - nDevices = 0; - for(address = 1; address < 127; address++) { - // The i2c_scanner uses the return value of - // the Write.endTransmisstion to see if - // a device did acknowledge to the address. - - Wire.beginTransmission(address); - error = Wire.endTransmission(); - - if (error == 0) { - Serial.print("I2C device found at address 0x"); - if (address < 16) - Serial.print("0"); - Serial.println(address, HEX); - - nDevices++; - } - else if (error == 4) { - Serial.print("Unknown error at address 0x"); - if (address < 16) - Serial.print("0"); - Serial.println(address, HEX); - } - } - if (nDevices == 0) - Serial.println("No I2C devices found"); - else - Serial.println("done"); - - delay(5000); // wait 5 seconds for next scan -} \ No newline at end of file diff --git a/GD32F1/libraries/Wire/rules.mk b/GD32F1/libraries/Wire/rules.mk deleted file mode 100644 index e16f4db..0000000 --- a/GD32F1/libraries/Wire/rules.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -# Local flags -CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) - -# Local rules and targets -cSRCS_$(d) := - -cppSRCS_$(d) := WireBase.cpp HardWire.cpp Wire.cpp - -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ - $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) \ No newline at end of file diff --git a/GD32F1/platform.txt b/GD32F1/platform.txt deleted file mode 100644 index 3cd1d25..0000000 --- a/GD32F1/platform.txt +++ /dev/null @@ -1,174 +0,0 @@ -# -# -# For more info: -# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification - -name=GD32 Boards (STM32duino.com) -version=0.1.2 - -compiler.warning_flags=-w -DDEBUG_LEVEL=DEBUG_NONE -compiler.warning_flags.none=-w -DDEBUG_LEVEL=DEBUG_NONE -compiler.warning_flags.default=-DDEBUG_LEVEL=DEBUG_NONE -compiler.warning_flags.more=-Wall -DDEBUG_LEVEL=DEBUG_FAULT -compiler.warning_flags.all=-Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL - -# compiler variables -# ---------------------- -compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ -compiler.c.cmd=arm-none-eabi-gcc -compiler.c.flags=-c -g -Os {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin} -compiler.c.elf.cmd=arm-none-eabi-g++ -compiler.c.elf.flags=-Os -Wl,--gc-sections -compiler.S.cmd=arm-none-eabi-gcc -compiler.S.flags=-c -g -x assembler-with-cpp -MMD -compiler.cpp.cmd=arm-none-eabi-g++ -compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin} -compiler.ar.cmd=arm-none-eabi-ar -compiler.ar.flags=rcs -compiler.objcopy.cmd=arm-none-eabi-objcopy -compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 -compiler.elf2hex.flags=-O binary -compiler.elf2hex.cmd=arm-none-eabi-objcopy -compiler.ldflags= -compiler.size.cmd=arm-none-eabi-size -compiler.define=-DARDUINO= - -# this can be overriden in boards.txt -#build.f_cpu=72000000L -build.mcu=cortex-m3 -build.common_flags=-mthumb -march=armv7-m -D__STM32F1__ -build.variant_system_lib=libmaple.a -## LED stuff is not really used but is still required in the code -build.error_led_port=GPIOC -build.error_led_pin=13 -build.cpu_flags= -build.hs_flag= -build.upload_flags= -build.extra_flags= {build.upload_flags} {build.cpu_flags} {build.hs_flag} {build.common_flags} - - - -# These can be overridden in platform.local.txt -compiler.c.extra_flags= -compiler.c.elf.extra_flags="-L{build.variant.path}/ld" -compiler.cpp.extra_flags= -compiler.S.extra_flags= -compiler.ar.extra_flags= -compiler.elf2hex.extra_flags= - - -##compiler.libsam.c.flags="-I{build.system.path}/libsam" "-I{build.system.path}/CMSIS/CMSIS/Include/" "-I{build.system.path}/CMSIS/Device/ATMEL/" - -##compiler.libs.c.flags="-I{build.system.path}/libmaple" "-I{build.system.path}/libmaple/include" "-I{build.system.path}/libmaple/stm32f1/include" "-I{build.system.path}/libmaple/stm32f1/include/series" "-I{build.system.path}/libmaple/usb/stm32f1" "-I{build.system.path}/libmaple/usb/usb_lib" -compiler.libs.c.flags="-I{build.system.path}/libmaple" "-I{build.system.path}/libmaple/include" "-I{build.system.path}/libmaple/stm32f1/include" "-I{build.system.path}/libmaple/usb/stm32f1" "-I{build.system.path}/libmaple/usb/usb_lib" - - - - -# USB Flags -# --------- -## build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' - -# Default usb manufacturer will be replaced at compile time using -# numeric vendor ID if available or by board's specific value. -## build.usb_manufacturer="Unknown" - - -# build patterns -# --------------------- - -## Compile c files -recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.libs.c.flags} {includes} "{source_file}" -o "{object_file}" - -## Compile c++ files -recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cpu_flags} {build.hs_flag} {build.common_flags} {compiler.libs.c.flags} {includes} "{source_file}" -o "{object_file}" - -## Compile S files -recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cpu_flags} {build.hs_flag} {build.common_flags} {compiler.libs.c.flags} {includes} "{source_file}" -o "{object_file}" -#recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" "{source_file}" -o "{object_file}" - -## Create archives -recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}" - -## Combine gc-sections, archives, and objects -recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group {object_files} "{build.path}/{archive_file}" -Wl,--end-group -#recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group {object_files} -Wl,--whole-archive "{build.path}/{archive_file}" -Wl,--no-whole-archive -Wl,--end-group - -## Create eeprom -recipe.objcopy.eep.pattern= - -## Create hex -recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" - -## Compute size -recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" -#recipe.size.regex=\.text\s+([0-9]+).* -#recipe.size.regex=^(?:\.text|\.rodata|\.ARM.exidx)\s+([0-9]+).* -recipe.size.regex=^(?:\.text|\.data|\.rodata|\.text.align|\.ARM.exidx)\s+([0-9]+).* - -recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).* - -# Uploader tools -# ------------------- - - - -# Upload using Maple bootloader over DFU -tools.maple_upload.cmd=maple_upload -tools.maple_upload.cmd.windows=maple_upload.bat -#tools.maple_upload.cmd.linux=maple_upload -tools.maple_upload.path={runtime.hardware.path}/tools/win -tools.maple_upload.path.macosx={runtime.hardware.path}/tools/macosx -tools.maple_upload.path.linux={runtime.hardware.path}/tools/linux - -tools.maple_upload.upload.params.verbose=-d -tools.maple_upload.upload.params.quiet= -tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" - -#Added tool for generic STM32 upload via serial to Serial Port 1 (pins PA9 and PA10) - note. Boot0 line needs to high on board reset to enable upload via serial -# at the end up the upload the program is automatically run, without the board being reset - -tools.serial_upload.cmd=serial_upload -tools.serial_upload.cmd.windows=serial_upload.bat -tools.serial_upload.cmd.macosx=serial_upload -tools.serial_upload.path={runtime.hardware.path}/tools/win -tools.serial_upload.path.macosx={runtime.hardware.path}/tools/macosx -tools.serial_upload.path.linux={runtime.hardware.path}/tools/linux - -tools.serial_upload.upload.params.verbose=-d -tools.serial_upload.upload.params.quiet=n -tools.serial_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" - - -tools.upload_router.cmd=upload_router -tools.upload_router.cmd.windows=upload_router.bat -tools.upload_router.path={runtime.hardware.path}/tools/win -tools.upload_router.path.macosx={runtime.hardware.path}/tools/macosx -tools.upload_router.path.linux={runtime.hardware.path}/tools/linux - -tools.upload_router.upload.params.verbose=-d -tools.upload_router.upload.params.quiet= -tools.upload_router.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}" {upload.protocol} {build.debuggingMode} "{runtime.ide.path}/hardware/tools/{build.gcc_ver}/bin/" - -# stlink upload -tools.stlink_upload.cmd=stlink_upload -tools.stlink_upload.cmd.windows=stlink_upload.bat -tools.stlink_upload.path.windows={runtime.hardware.path}/tools/win -tools.stlink_upload.path.macosx={runtime.hardware.path}/tools/macosx -tools.stlink_upload.path.linux={runtime.hardware.path}/tools/linux - -tools.stlink_upload.upload.params.verbose=-d -tools.stlink_upload.upload.params.quiet= -tools.stlink_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" - -# blackmagic probe upload -tools.bmp_upload.cmd=arm-none-eabi-gdb -#tools.bmp_upload.cmd.windows=bmp_upload.bat -tools.bmp_upload.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ -#tools.bmp_upload.path.windows={runtime.hardware.path}/tools/win - -tools.bmp_upload.upload.speed=230400 -tools.bmp_upload.upload.params.verbose= -tools.bmp_upload.upload.params.quiet=-q --batch-silent -tools.bmp_upload.upload.pattern="{path}{cmd}" -cd "{build.path}" -b {upload.speed} {upload.verbose} -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 60" -ex "set mem inaccessible-by-default off" -ex "set confirm off" -ex "set height 0" -ex "target extended-remote {serial.port}" -ex "monitor swdp_scan" -ex "attach 1" -ex "x/wx 0x8000004" -ex "monitor erase_mass" -ex "echo 0x8000004 expect 0xffffffff after erase\n" -ex "x/wx 0x8000004" -ex "file {build.project_name}.elf" -ex "load" -ex "x/wx 0x08000004" -ex "tbreak main" -ex "run" -ex "echo \n\n\nUpload finished!" -ex "quit" -#tools.bmp_upload.upload.pattern.windows="{path}/{cmd}" {runtime.tools.arm-none-eabi-gcc.path}/bin/ {upload.speed} {upload.verbose} "target extended-remote {serial.port}" "{build.path}/{build.project_name}.elf" diff --git a/GD32F1/system/Makefile b/GD32F1/system/Makefile deleted file mode 100644 index 0c6dfc0..0000000 --- a/GD32F1/system/Makefile +++ /dev/null @@ -1,204 +0,0 @@ -# Try "make help" first - -.DEFAULT_GOAL := sketch - -## -## Useful paths, constants, etc. -## - -ifeq ($(LIB_MAPLE_HOME),) -SRCROOT := . -else -SRCROOT := $(LIB_MAPLE_HOME) -endif - -BUILD_PATH = build -LIBMAPLE_PATH := $(SRCROOT)/libmaple -WIRISH_PATH := $(SRCROOT)/wirish -SUPPORT_PATH := $(SRCROOT)/support -LIBRARIES_PATH := $(SRCROOT)/libraries -# Support files for linker -LDDIR := $(SUPPORT_PATH)/ld -# Support files for this Makefile -MAKEDIR := $(SUPPORT_PATH)/make -BOARD_INCLUDE_DIR := $(MAKEDIR)/board-includes - -## -## Target-specific configuration. This determines some compiler and -## linker options/flags. -## - -# Try "make help" for more information on BOARD and MEMORY_TARGET; -# these default to a Maple Flash build. -BOARD ?= maple -MEMORY_TARGET ?= flash - -# Chooses the bootloader, available: maple and robotis -BOOTLOADER ?= maple - -# This is the serial port used by robotis bootloader -ROBOTIS_PORT ?= /dev/ttyACM0 - -# $(BOARD)- and $(MEMORY_TARGET)-specific configuration -include $(MAKEDIR)/target-config.mk - -## -## Build rules and useful templates -## - -include $(MAKEDIR)/build-rules.mk -include $(MAKEDIR)/build-templates.mk - -## -## Compilation flags -## - -# FIXME: the following allows for deprecated include style, e.g.: -# #include "libmaple.h" -# or -# #include "wirish.h" -# It slows compilation noticeably; remove after 1 release. -TARGET_FLAGS += -I$(LIBMAPLE_PATH)/include/libmaple \ - -I$(WIRISH_PATH)/include/wirish -TARGET_FLAGS += -I$(LIBRARIES_PATH) # for internal lib. includes, e.g. -GLOBAL_CFLAGS := -Os -g3 -gdwarf-2 -nostdlib \ - -ffunction-sections -fdata-sections \ - -Wl,--gc-sections $(TARGET_FLAGS) \ - -DBOOTLOADER_$(BOOTLOADER) -GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall $(TARGET_FLAGS) -GLOBAL_ASFLAGS := -x assembler-with-cpp $(TARGET_FLAGS) -LDFLAGS = $(TARGET_LDFLAGS) $(TOOLCHAIN_LDFLAGS) -mcpu=cortex-m3 -mthumb \ - -Xlinker --gc-sections \ - -Xassembler --march=armv7-m -Wall -# -Xlinker --print-gc-sections \ - -## -## Set all submodules here -## - -LIBMAPLE_MODULES += $(SRCROOT)/libmaple -LIBMAPLE_MODULES += $(SRCROOT)/libmaple/usb # The USB module is kept separate -LIBMAPLE_MODULES += $(LIBMAPLE_MODULE_SERIES) # STM32 series submodule in libmaple -## LIBMAPLE_MODULES += $(SRCROOT)/wirish - -# Official libraries: -##LIBMAPLE_MODULES += $(SRCROOT)/libraries/Servo -##LIBMAPLE_MODULES += $(SRCROOT)/libraries/LiquidCrystal -##LIBMAPLE_MODULES += $(SRCROOT)/libraries/Wire -# Experimental libraries: -##LIBMAPLE_MODULES += $(SRCROOT)/libraries/FreeRTOS - -# User modules: -ifneq ($(USER_MODULES),) -LIBMAPLE_MODULES += $(USER_MODULES) -endif - -# Call each module's rules.mk: -$(foreach m,$(LIBMAPLE_MODULES),$(eval $(call LIBMAPLE_MODULE_template,$(m)))) - -## -## Targets -## - -# main target -include $(SRCROOT)/build-targets.mk - -.PHONY: install sketch clean help cscope tags ctags ram flash jtag doxygen mrproper list-boards - -# Target upload commands -# USB ID for DFU upload -- FIXME: do something smarter with this -BOARD_USB_VENDOR_ID := 1EAF -BOARD_USB_PRODUCT_ID := 0003 - -ifeq ($(BOOTLOADER),maple) -UPLOAD_ram := $(SUPPORT_PATH)/scripts/reset.py && \ - sleep 1 && \ - $(DFU) -a0 -d $(BOARD_USB_VENDOR_ID):$(BOARD_USB_PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R -UPLOAD_flash := $(SUPPORT_PATH)/scripts/reset.py && \ - sleep 1 && \ - $(DFU) -a1 -d $(BOARD_USB_VENDOR_ID):$(BOARD_USB_PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R -endif - -ifeq ($(BOOTLOADER),robotis) -UPLOAD_flash := $(SUPPORT_PATH)/scripts/robotis-loader.py $(ROBOTIS_PORT) $(BUILD_PATH)/$(BOARD).bin -endif - -# Conditionally upload to whatever the last build was -install: INSTALL_TARGET = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null) -install: $(BUILD_PATH)/$(BOARD).bin - @echo "Install target:" $(INSTALL_TARGET) - $(UPLOAD_$(INSTALL_TARGET)) - -# Force a rebuild if the target changed -PREV_BUILD_TYPE = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null) -build-check: -ifneq ($(PREV_BUILD_TYPE), $(MEMORY_TARGET)) - $(shell rm -rf $(BUILD_PATH)) -endif - -sketch: build-check MSG_INFO $(BUILD_PATH)/$(BOARD).bin - -clean: - rm -rf build - -mrproper: clean - rm -rf doxygen - -help: - @echo "" - @echo "Basic usage (BOARD defaults to maple):" - @echo " $$ cp your-main.cpp main.cpp" - @echo " $$ make BOARD=your_board" - @echo " $$ make BOARD=your_board install" - @echo "" - @echo "(Multiple source files? Link with libmaple.a (\`$$ make library')" - @echo "or hack build-targets.mk appropriately.)" - @echo "" - @echo "Important targets:" - @echo " sketch: Compile for BOARD to MEMORY_TARGET (default)." - @echo " install: Compile and upload over USB using Maple bootloader" - @echo "" - @echo "You *must* set BOARD if not compiling for Maple (e.g." - @echo "use BOARD=maple_mini for mini, etc.), and MEMORY_TARGET" - @echo "if not compiling to Flash. Run \`$$ make list-boards' for" - @echo "a list of all boards." - @echo "" - @echo "Valid MEMORY_TARGETs (default=flash):" - @echo " ram: Compile to RAM (doesn't touch Flash)" - @echo " flash: Compile to Flash (for Maple bootloader)" - @echo " jtag: Compile for JTAG/SWD upload (overwrites bootloader)" - @echo "" - @echo "Other targets:" - @echo " clean: Remove all build and object files" - @echo " doxygen: Build Doxygen HTML and XML documentation" - @echo " help: Show this message" - @echo " mrproper: Remove all generated files" - @echo "" - -cscope: - rm -rf cscope.* - find . -name '*.[hcS]' -o -name '*.cpp' | xargs cscope -b - -tags: - etags `find . -name "*.c" -o -name "*.cpp" -o -name "*.h"` - @echo "Made TAGS file for EMACS code browsing" - -ctags: - ctags-exuberant -R . - @echo "Made tags file for VIM code browsing" - -ram: - @$(MAKE) MEMORY_TARGET=ram --no-print-directory sketch - -flash: - @$(MAKE) MEMORY_TARGET=flash --no-print-directory sketch - -jtag: - @$(MAKE) MEMORY_TARGET=jtag --no-print-directory sketch - -doxygen: - doxygen $(SUPPORT_PATH)/doxygen/Doxyfile - -# This output is kind of ugly, but I don't understand make very well. -list-boards: - @echo " $(addsuffix "\\n",$(basename $(notdir $(wildcard $(BOARD_INCLUDE_DIR)/*.mk))))" diff --git a/GD32F1/system/build-targets.mk b/GD32F1/system/build-targets.mk deleted file mode 100644 index aaff2d0..0000000 --- a/GD32F1/system/build-targets.mk +++ /dev/null @@ -1,42 +0,0 @@ -# main project target -$(BUILD_PATH)/main.o: $(SRCROOT)/main.cpp - $(SILENT_CXX) $(CXX) $(CFLAGS) $(CXXFLAGS) $(LIBMAPLE_INCLUDES) $(WIRISH_INCLUDES) -o $@ -c $< - -$(BUILD_PATH)/libmaple.a: $(BUILDDIRS) $(TGT_BIN) - - rm -f $@ - $(AR) crv $(BUILD_PATH)/libmaple.a $(TGT_BIN) - -library: $(BUILD_PATH)/libmaple.a - -.PHONY: library - -$(BUILD_PATH)/$(BOARD).elf: $(BUILDDIRS) $(TGT_BIN) $(BUILD_PATH)/main.o - $(SILENT_LD) $(CXX) $(LDFLAGS) -o $@ $(TGT_BIN) $(BUILD_PATH)/main.o -Wl,-Map,$(BUILD_PATH)/$(BOARD).map - -$(BUILD_PATH)/$(BOARD).bin: $(BUILD_PATH)/$(BOARD).elf - $(SILENT_OBJCOPY) $(OBJCOPY) -v -Obinary $(BUILD_PATH)/$(BOARD).elf $@ 1>/dev/null - $(SILENT_DISAS) $(DISAS) -d $(BUILD_PATH)/$(BOARD).elf > $(BUILD_PATH)/$(BOARD).disas - @echo " " - @echo "Object file sizes:" - @find $(BUILD_PATH) -iname *.o | xargs $(SIZE) -t > $(BUILD_PATH)/$(BOARD).sizes - @cat $(BUILD_PATH)/$(BOARD).sizes - @echo " " - @echo "Final Size:" - @$(SIZE) $< - @echo $(MEMORY_TARGET) > $(BUILD_PATH)/build-type - -$(BUILDDIRS): - @mkdir -p $@ - -MSG_INFO: - @echo "================================================================================" - @echo "" - @echo " Build info:" - @echo " BOARD: " $(BOARD) - @echo " MCU: " $(MCU) - @echo " MEMORY_TARGET: " $(MEMORY_TARGET) - @echo "" - @echo " See 'make help' for all possible targets" - @echo "" - @echo "================================================================================" - @echo "" diff --git a/GD32F1/system/libmaple/dma_private.h b/GD32F1/system/libmaple/dma_private.h deleted file mode 100644 index c0ee11f..0000000 --- a/GD32F1/system/libmaple/dma_private.h +++ /dev/null @@ -1,62 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*****************************************************************************/ - -#ifndef _LIBMAPLE_DMA_PRIVATE_H_ -#define _LIBMAPLE_DMA_PRIVATE_H_ - -#include -#include - -/* - * IRQ handling - */ - -/* Wrap this in an ifdef to shut up GCC. (We provide DMA_GET_HANDLER - * in the series support files, which need dma_irq_handler().) */ -#ifdef DMA_GET_HANDLER -static __always_inline void dma_irq_handler(dma_dev *dev, dma_tube tube) { - - void (*handler)(void) = DMA_GET_HANDLER(dev, tube); - if (handler) { - handler(); - dma_clear_isr_bits(dev, tube); /* in case handler doesn't */ - } -} -#endif - -/* - * Conveniences for dealing with tube sources/destinations - */ - -enum dma_atype { - DMA_ATYPE_MEM, - DMA_ATYPE_PER, - DMA_ATYPE_OTHER, -}; - -enum dma_atype _dma_addr_type(__io void *addr); - -#endif diff --git a/GD32F1/system/libmaple/exti_private.h b/GD32F1/system/libmaple/exti_private.h deleted file mode 100644 index 4f0a4cf..0000000 --- a/GD32F1/system/libmaple/exti_private.h +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*****************************************************************************/ - -#ifndef _LIBMAPLE_EXTI_PRIVATE_H_ -#define _LIBMAPLE_EXTI_PRIVATE_H_ - -#include - -void exti_do_select(__io uint32 *exti_cr, exti_num num, exti_cfg port); - -#endif diff --git a/GD32F1/system/libmaple/i2c_private.h b/GD32F1/system/libmaple/i2c_private.h deleted file mode 100644 index 5b79516..0000000 --- a/GD32F1/system/libmaple/i2c_private.h +++ /dev/null @@ -1,79 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#ifndef _LIBMAPLE_I2C_PRIVATE_H_ -#define _LIBMAPLE_I2C_PRIVATE_H_ - -#include - -/* For old-style definitions (SDA/SCL on same GPIO device) */ -#define I2C_DEV_OLD(num, port, sda, scl) \ - { \ - .regs = I2C##num##_BASE, \ - .gpio_port = port, \ - .scl_port = NULL, \ - .sda_port = NULL, \ - .sda_pin = sda, \ - .scl_pin = scl, \ - .clk_id = RCC_I2C##num, \ - .ev_nvic_line = NVIC_I2C##num##_EV, \ - .er_nvic_line = NVIC_I2C##num##_ER, \ - .state = I2C_STATE_DISABLED, \ - } - -/* For new-style definitions (SDA/SCL may be on different GPIO devices) */ -#define I2C_DEV_NEW(num, sdaport, sdabit, sclport, sclbit) \ - { \ - .regs = I2C##num##_BASE, \ - .gpio_port = NULL, \ - .scl_port = sclport, \ - .scl_pin = sclbit, \ - .sda_port = sdaport, \ - .sda_pin = sdabit, \ - .clk_id = RCC_I2C##num, \ - .ev_nvic_line = NVIC_I2C##num##_EV, \ - .er_nvic_line = NVIC_I2C##num##_ER, \ - .state = I2C_STATE_DISABLED, \ - } - -void _i2c_irq_handler(i2c_dev *dev); -void _i2c_irq_error_handler(i2c_dev *dev); - -struct gpio_dev; - -static inline struct gpio_dev* scl_port(const i2c_dev *dev) { - return (dev->gpio_port == NULL) ? dev->scl_port : dev->gpio_port; -} - -static inline struct gpio_dev* sda_port(const i2c_dev *dev) { - return (dev->gpio_port == NULL) ? dev->sda_port : dev->gpio_port; -} - -/* Auxiliary procedure for enabling an I2C peripheral; `flags' as for - * i2c_master_enable(). */ -void _i2c_set_ccr_trise(i2c_dev *dev, uint32 flags); - -#endif /* _LIBMAPLE_I2C_PRIVATE_H_ */ diff --git a/GD32F1/system/libmaple/include/libmaple/adc.h b/GD32F1/system/libmaple/include/libmaple/adc.h deleted file mode 100644 index 4c6a253..0000000 --- a/GD32F1/system/libmaple/include/libmaple/adc.h +++ /dev/null @@ -1,332 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/adc.h - * @author Marti Bolivar , - * Perry Hung - * @brief Analog-to-Digital Conversion (ADC) header. - */ - -#ifndef _LIBMAPLE_ADC_H_ -#define _LIBMAPLE_ADC_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include -#include -/* We include the series header below, after defining the register map - * and device structs. */ - -/* - * Register map - */ - -/** ADC register map type. */ -typedef struct adc_reg_map { - __io uint32 SR; ///< Status register - __io uint32 CR1; ///< Control register 1 - __io uint32 CR2; ///< Control register 2 - __io uint32 SMPR1; ///< Sample time register 1 - __io uint32 SMPR2; ///< Sample time register 2 - __io uint32 JOFR1; ///< Injected channel data offset register 1 - __io uint32 JOFR2; ///< Injected channel data offset register 2 - __io uint32 JOFR3; ///< Injected channel data offset register 3 - __io uint32 JOFR4; ///< Injected channel data offset register 4 - __io uint32 HTR; ///< Watchdog high threshold register - __io uint32 LTR; ///< Watchdog low threshold register - __io uint32 SQR1; ///< Regular sequence register 1 - __io uint32 SQR2; ///< Regular sequence register 2 - __io uint32 SQR3; ///< Regular sequence register 3 - __io uint32 JSQR; ///< Injected sequence register - __io uint32 JDR1; ///< Injected data register 1 - __io uint32 JDR2; ///< Injected data register 2 - __io uint32 JDR3; ///< Injected data register 3 - __io uint32 JDR4; ///< Injected data register 4 - __io uint32 DR; ///< Regular data register -} adc_reg_map; - -/** ADC device type. */ -typedef struct adc_dev { - adc_reg_map *regs; /**< Register map */ - rcc_clk_id clk_id; /**< RCC clock information */ -} adc_dev; - -/* Pull in the series header (which may need the above struct - * definitions). - * - * IMPORTANT: The series header must define the following: - * - * - enum adc_extsel_event (and typedef to adc_extsel_event): One per - * external event used to trigger start of conversion of a regular - * group. If two different series support the same event as a - * trigger, they must use the same token for the enumerator for that - * event. (The value of the enumerator is of course allowed to be - * different). - * - * - enum adc_smp_rate (and typedef to adc_smp_rate): One per - * available sampling time. These must be in the form ADC_SMPR_X_Y - * for X.Y cycles (e.g. ADC_SMPR_1_5 means 1.5 cycles), or - * ADC_SMPR_X for X cycles (e.g. ADC_SMPR_3 means 3 cycles). - * - * - enum adc_prescaler (and typedef): One per available prescaler, - * suitable for adc_set_prescaler. Series which have the same - * prescaler dividers (e.g. STM32F1 and STM32F2 both divide PCLK2 by - * 2, 4, 6, or 8) must provide the same tokens as enumerators, for - * portability. - */ - - /* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/adc.h" - - -/* - * Register bit definitions - */ - -/* Status register */ - -#define ADC_SR_AWD_BIT 0 -#define ADC_SR_EOC_BIT 1 -#define ADC_SR_JEOC_BIT 2 -#define ADC_SR_JSTRT_BIT 3 -#define ADC_SR_STRT_BIT 4 - -#define ADC_SR_AWD BIT(ADC_SR_AWD_BIT) -#define ADC_SR_EOC BIT(ADC_SR_EOC_BIT) -#define ADC_SR_JEOC BIT(ADC_SR_JEOC_BIT) -#define ADC_SR_JSTRT BIT(ADC_SR_JSTRT_BIT) -#define ADC_SR_STRT BIT(ADC_SR_STRT_BIT) - -/* Control register 1 */ - -#define ADC_CR1_EOCIE_BIT 5 -#define ADC_CR1_AWDIE_BIT 6 -#define ADC_CR1_JEOCIE_BIT 7 -#define ADC_CR1_SCAN_BIT 8 -#define ADC_CR1_AWDSGL_BIT 9 -#define ADC_CR1_JAUTO_BIT 10 -#define ADC_CR1_DISCEN_BIT 11 -#define ADC_CR1_JDISCEN_BIT 12 -#define ADC_CR1_JAWDEN_BIT 22 -#define ADC_CR1_AWDEN_BIT 23 - -#define ADC_CR1_AWDCH (0x1F) -#define ADC_CR1_EOCIE BIT(ADC_CR1_EOCIE_BIT) -#define ADC_CR1_AWDIE BIT(ADC_CR1_AWDIE_BIT) -#define ADC_CR1_JEOCIE BIT(ADC_CR1_JEOCIE_BIT) -#define ADC_CR1_SCAN BIT(ADC_CR1_SCAN_BIT) -#define ADC_CR1_AWDSGL BIT(ADC_CR1_AWDSGL_BIT) -#define ADC_CR1_JAUTO BIT(ADC_CR1_JAUTO_BIT) -#define ADC_CR1_DISCEN BIT(ADC_CR1_DISCEN_BIT) -#define ADC_CR1_JDISCEN BIT(ADC_CR1_JDISCEN_BIT) -#define ADC_CR1_DISCNUM (0xE000) -#define ADC_CR1_JAWDEN BIT(ADC_CR1_JAWDEN_BIT) -#define ADC_CR1_AWDEN BIT(ADC_CR1_AWDEN_BIT) - -/* Control register 2 */ - -/* Because this register varies significantly by series (e.g. some - * bits moved and others disappeared in the F1->F2 transition), its - * definitions are in the series headers. */ - -/* Sample time register 1 */ - -#define ADC_SMPR1_SMP17 (0x7 << 21) -#define ADC_SMPR1_SMP16 (0x7 << 18) -#define ADC_SMPR1_SMP15 (0x7 << 15) -#define ADC_SMPR1_SMP14 (0x7 << 12) -#define ADC_SMPR1_SMP13 (0x7 << 9) -#define ADC_SMPR1_SMP12 (0x7 << 6) -#define ADC_SMPR1_SMP11 (0x7 << 3) -#define ADC_SMPR1_SMP10 0x7 - -/* Sample time register 2 */ - -#define ADC_SMPR2_SMP9 (0x7 << 27) -#define ADC_SMPR2_SMP8 (0x7 << 24) -#define ADC_SMPR2_SMP7 (0x7 << 21) -#define ADC_SMPR2_SMP6 (0x7 << 18) -#define ADC_SMPR2_SMP5 (0x7 << 15) -#define ADC_SMPR2_SMP4 (0x7 << 12) -#define ADC_SMPR2_SMP3 (0x7 << 9) -#define ADC_SMPR2_SMP2 (0x7 << 6) -#define ADC_SMPR2_SMP1 (0x7 << 3) -#define ADC_SMPR2_SMP0 0x7 - -/* Injected channel data offset register */ - -#define ADC_JOFR_JOFFSET 0x3FF - -/* Watchdog high threshold register */ - -#define ADC_HTR_HT 0x3FF - -/* Watchdog low threshold register */ - -#define ADC_LTR_LT 0x3FF - -/* Regular sequence register 1 */ - -#define ADC_SQR1_L (0x1F << 20) -#define ADC_SQR1_SQ16 (0x1F << 15) -#define ADC_SQR1_SQ15 (0x1F << 10) -#define ADC_SQR1_SQ14 (0x1F << 5) -#define ADC_SQR1_SQ13 0x1F - -/* Regular sequence register 2 */ - -#define ADC_SQR2_SQ12 (0x1F << 25) -#define ADC_SQR2_SQ11 (0x1F << 20) -#define ADC_SQR2_SQ10 (0x1F << 16) -#define ADC_SQR2_SQ9 (0x1F << 10) -#define ADC_SQR2_SQ8 (0x1F << 5) -#define ADC_SQR2_SQ7 0x1F - -/* Regular sequence register 3 */ - -#define ADC_SQR3_SQ6 (0x1F << 25) -#define ADC_SQR3_SQ5 (0x1F << 20) -#define ADC_SQR3_SQ4 (0x1F << 16) -#define ADC_SQR3_SQ3 (0x1F << 10) -#define ADC_SQR3_SQ2 (0x1F << 5) -#define ADC_SQR3_SQ1 0x1F - -/* Injected sequence register */ - -#define ADC_JSQR_JL (0x3 << 20) -#define ADC_JSQR_JL_1CONV (0x0 << 20) -#define ADC_JSQR_JL_2CONV (0x1 << 20) -#define ADC_JSQR_JL_3CONV (0x2 << 20) -#define ADC_JSQR_JL_4CONV (0x3 << 20) -#define ADC_JSQR_JSQ4 (0x1F << 15) -#define ADC_JSQR_JSQ3 (0x1F << 10) -#define ADC_JSQR_JSQ2 (0x1F << 5) -#define ADC_JSQR_JSQ1 0x1F - -/* Injected data registers */ - -#define ADC_JDR_JDATA 0xFFFF - -/* Regular data register */ - -#define ADC_DR_ADC2DATA (0xFFFF << 16) -#define ADC_DR_DATA 0xFFFF - -/* - * Routines - */ - -void adc_init(const adc_dev *dev); -void adc_set_extsel(const adc_dev *dev, adc_extsel_event event); -void adc_set_sample_rate(const adc_dev *dev, adc_smp_rate smp_rate); -uint16 adc_read(const adc_dev *dev, uint8 channel); - -/** - * @brief Set the ADC prescaler. - * - * This determines the ADC clock for all devices. - */ -extern void adc_set_prescaler(adc_prescaler pre); - -/** - * @brief Call a function on all ADC devices. - * @param fn Function to call on each ADC device. - */ -extern void adc_foreach(void (*fn)(const adc_dev*)); - -struct gpio_dev; -/** - * @brief Configure a GPIO pin for ADC conversion. - * @param dev ADC device to use for conversion (currently ignored on - * all targets). - * @param gdev GPIO device to configure. - * @param bit Bit on gdev to configure for ADC conversion. - */ -extern void adc_config_gpio(const struct adc_dev *dev, - struct gpio_dev *gdev, - uint8 bit); - -/** - * @brief Enable an ADC and configure it for single conversion mode. - * - * This function performs any initialization necessary to allow the - * ADC device to perform a single synchronous regular software - * triggered conversion, using adc_read(). - * - * @param dev Device to enable. - * @see adc_read() - */ -extern void adc_enable_single_swstart(const adc_dev* dev); - -/** - * @brief Set the regular channel sequence length. - * - * Defines the total number of conversions in the regular channel - * conversion sequence. - * - * @param dev ADC device. - * @param length Regular channel sequence length, from 1 to 16. - */ -static inline void adc_set_reg_seqlen(const adc_dev *dev, uint8 length) { - uint32 tmp = dev->regs->SQR1; - tmp &= ~ADC_SQR1_L; - tmp |= (length - 1) << 20; - dev->regs->SQR1 = tmp; -} - -/** - * @brief Enable an adc peripheral - * @param dev ADC device to enable - */ -static inline void adc_enable(const adc_dev *dev) { - *bb_perip(&dev->regs->CR2, ADC_CR2_ADON_BIT) = 1; -} - -/** - * @brief Disable an ADC peripheral - * @param dev ADC device to disable - */ -static inline void adc_disable(const adc_dev *dev) { - *bb_perip(&dev->regs->CR2, ADC_CR2_ADON_BIT) = 0; -} - -/** - * @brief Disable all ADC peripherals. - */ -static inline void adc_disable_all(void) { - adc_foreach(adc_disable); -} - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/bitband.h b/GD32F1/system/libmaple/include/libmaple/bitband.h deleted file mode 100644 index 6e77991..0000000 --- a/GD32F1/system/libmaple/include/libmaple/bitband.h +++ /dev/null @@ -1,128 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/bitband.h - * - * @brief Bit-banding utility functions - */ - -#ifndef _LIBMAPLE_BITBAND_H_ -#define _LIBMAPLE_BITBAND_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define BB_SRAM_REF 0x20000000 -#define BB_SRAM_BASE 0x22000000 -#define BB_PERI_REF 0x40000000 -#define BB_PERI_BASE 0x42000000 - -static inline volatile uint32* __bb_addr(volatile void*, - uint32, - uint32, - uint32); - -/** - * @brief Obtain a pointer to the bit-band address corresponding to a - * bit in a volatile SRAM address. - * @param address Address in the bit-banded SRAM region - * @param bit Bit in address to bit-band - */ -static inline volatile uint32* bb_sramp(volatile void *address, uint32 bit) { - return __bb_addr(address, bit, BB_SRAM_BASE, BB_SRAM_REF); -} - -/** - * @brief Get a bit from an address in the SRAM bit-band region. - * @param address Address in the SRAM bit-band region to read from - * @param bit Bit in address to read - * @return bit's value in address. - */ -static inline uint8 bb_sram_get_bit(volatile void *address, uint32 bit) { - return *bb_sramp(address, bit); -} - -/** - * @brief Set a bit in an address in the SRAM bit-band region. - * @param address Address in the SRAM bit-band region to write to - * @param bit Bit in address to write to - * @param val Value to write for bit, either 0 or 1. - */ -static inline void bb_sram_set_bit(volatile void *address, - uint32 bit, - uint8 val) { - *bb_sramp(address, bit) = val; -} - -/** - * @brief Obtain a pointer to the bit-band address corresponding to a - * bit in a peripheral address. - * @param address Address in the bit-banded peripheral region - * @param bit Bit in address to bit-band - */ -static inline volatile uint32* bb_perip(volatile void *address, uint32 bit) { - return __bb_addr(address, bit, BB_PERI_BASE, BB_PERI_REF); -} - -/** - * @brief Get a bit from an address in the peripheral bit-band region. - * @param address Address in the peripheral bit-band region to read from - * @param bit Bit in address to read - * @return bit's value in address. - */ -static inline uint8 bb_peri_get_bit(volatile void *address, uint32 bit) { - return *bb_perip(address, bit); -} - -/** - * @brief Set a bit in an address in the peripheral bit-band region. - * @param address Address in the peripheral bit-band region to write to - * @param bit Bit in address to write to - * @param val Value to write for bit, either 0 or 1. - */ -static inline void bb_peri_set_bit(volatile void *address, - uint32 bit, - uint8 val) { - *bb_perip(address, bit) = val; -} - -static inline volatile uint32* __bb_addr(volatile void *address, - uint32 bit, - uint32 bb_base, - uint32 bb_ref) { - return (volatile uint32*)(bb_base + ((uint32)address - bb_ref) * 32 + - bit * 4); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/bkp.h b/GD32F1/system/libmaple/include/libmaple/bkp.h deleted file mode 100644 index bb63a2f..0000000 --- a/GD32F1/system/libmaple/include/libmaple/bkp.h +++ /dev/null @@ -1,166 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/bkp.h - * @brief Backup register support (STM32F1 only). - */ - -#ifndef _LIBMAPLE_BKP_H_ -#define _LIBMAPLE_BKP_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#if defined(STM32_MEDIUM_DENSITY) -#define BKP_NR_DATA_REGS 10 -#elif defined(STM32_HIGH_DENSITY) -#define BKP_NR_DATA_REGS 42 -#endif - -/** Backup peripheral register map type. */ -typedef struct bkp_reg_map { - const uint32 RESERVED1; ///< Reserved - __io uint32 DR1; ///< Data register 1 - __io uint32 DR2; ///< Data register 2 - __io uint32 DR3; ///< Data register 3 - __io uint32 DR4; ///< Data register 4 - __io uint32 DR5; ///< Data register 5 - __io uint32 DR6; ///< Data register 6 - __io uint32 DR7; ///< Data register 7 - __io uint32 DR8; ///< Data register 8 - __io uint32 DR9; ///< Data register 9 - __io uint32 DR10; ///< Data register 10 - __io uint32 RTCCR; ///< RTC control register - __io uint32 CR; ///< Control register - __io uint32 CSR; ///< Control and status register -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) - const uint32 RESERVED2; ///< Reserved - const uint32 RESERVED3; ///< Reserved - __io uint32 DR11; ///< Data register 11 - __io uint32 DR12; ///< Data register 12 - __io uint32 DR13; ///< Data register 13 - __io uint32 DR14; ///< Data register 14 - __io uint32 DR15; ///< Data register 15 - __io uint32 DR16; ///< Data register 16 - __io uint32 DR17; ///< Data register 17 - __io uint32 DR18; ///< Data register 18 - __io uint32 DR19; ///< Data register 19 - __io uint32 DR20; ///< Data register 20 - __io uint32 DR21; ///< Data register 21 - __io uint32 DR22; ///< Data register 22 - __io uint32 DR23; ///< Data register 23 - __io uint32 DR24; ///< Data register 24 - __io uint32 DR25; ///< Data register 25 - __io uint32 DR26; ///< Data register 26 - __io uint32 DR27; ///< Data register 27 - __io uint32 DR28; ///< Data register 28 - __io uint32 DR29; ///< Data register 29 - __io uint32 DR30; ///< Data register 30 - __io uint32 DR31; ///< Data register 31 - __io uint32 DR32; ///< Data register 32 - __io uint32 DR33; ///< Data register 33 - __io uint32 DR34; ///< Data register 34 - __io uint32 DR35; ///< Data register 35 - __io uint32 DR36; ///< Data register 36 - __io uint32 DR37; ///< Data register 37 - __io uint32 DR38; ///< Data register 38 - __io uint32 DR39; ///< Data register 39 - __io uint32 DR40; ///< Data register 40 - __io uint32 DR41; ///< Data register 41 - __io uint32 DR42; ///< Data register 42 -#endif -} bkp_reg_map; - -/** Backup peripheral register map base pointer. */ -#define BKP_BASE ((struct bkp_reg_map*)0x40006C00) - -/** Backup peripheral device type. */ -typedef struct bkp_dev { - bkp_reg_map *regs; /**< Register map */ -} bkp_dev; - -extern const bkp_dev *BKP; - -/* - * Register bit definitions - */ - -/* Data Registers */ - -#define BKP_DR_D 0xFFFF - -/* RTC Clock Calibration Register */ - -#define BKP_RTCCR_ASOS_BIT 9 -#define BKP_RTCCR_ASOE_BIT 8 -#define BKP_RTCCR_CCO_BIT 7 - -#define BKP_RTCCR_ASOS BIT(BKP_RTCCR_ASOS_BIT) -#define BKP_RTCCR_ASOE BIT(BKP_RTCCR_ASOE_BIT) -#define BKP_RTCCR_CCO BIT(BKP_RTCCR_CCO_BIT) -#define BKP_RTCCR_CAL 0x7F - -/* Backup control register */ - -#define BKP_CR_TPAL_BIT 1 -#define BKP_CR_TPE_BIT 0 - -#define BKP_CR_TPAL BIT(BKP_CR_TPAL_BIT) -#define BKP_CR_TPE BIT(BKP_CR_TPE_BIT) - -/* Backup control/status register */ - -#define BKP_CSR_TIF_BIT 9 -#define BKP_CSR_TEF_BIT 8 -#define BKP_CSR_TPIE_BIT 2 -#define BKP_CSR_CTI_BIT 1 -#define BKP_CSR_CTE_BIT 0 - -#define BKP_CSR_TIF BIT(BKP_CSR_TIF_BIT) -#define BKP_CSR_TEF BIT(BKP_CSR_TEF_BIT) -#define BKP_CSR_TPIE BIT(BKP_CSR_TPIE_BIT) -#define BKP_CSR_CTI BIT(BKP_CSR_CTI_BIT) -#define BKP_CSR_CTE BIT(BKP_CSR_CTE_BIT) - -/* - * Convenience functions - */ - -void bkp_init(void); -void bkp_enable_writes(void); -void bkp_disable_writes(void); -uint16 bkp_read(uint8 reg); -void bkp_write(uint8 reg, uint16 val); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/dac.h b/GD32F1/system/libmaple/include/libmaple/dac.h deleted file mode 100644 index 7768423..0000000 --- a/GD32F1/system/libmaple/include/libmaple/dac.h +++ /dev/null @@ -1,162 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * Copyright (c) 2010 Bryan Newbold. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/dac.h - * @brief Digital to analog converter support. - */ - -/* See notes/dac.txt for more info */ - -#ifndef _LIBMAPLE_DAC_H_ -#define _LIBMAPLE_DAC_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - - /* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/dac.h" -#include -#include -#include - -/* - * Register map base and device pointers. - * - * The DACs are the same on all supported targets, so it's not worth - * repeating these in the series headers. - */ - -#define DAC_BASE ((struct dac_reg_map*)0x40007400) - -/** DAC device type. */ -typedef struct dac_dev { - dac_reg_map *regs; /**< Register map */ -} dac_dev; - -#if STM32_HAVE_DAC -extern const dac_dev *DAC; -#endif - -/* - * Register bit definitions - */ - -/* Control register */ - -/* Channel 1 control */ -#define DAC_CR_EN1 (1U << 0) /* Enable */ -#define DAC_CR_BOFF1 (1U << 1) /* Output buffer disable */ -#define DAC_CR_TEN1 (1U << 2) /* Trigger enable */ -#define DAC_CR_TSEL1 (0x7 << 3) /* Trigger selection */ -#define DAC_CR_WAVE1 (0x3 << 6) /* Noise/triangle wave */ -#define DAC_CR_MAMP1 (0xF << 8) /* Mask/amplitude selector */ -#define DAC_CR_DMAEN1 (1U << 12) /* DMA enable */ -/* Channel 2 control */ -#define DAC_CR_EN2 (1U << 16) /* Enable */ -#define DAC_CR_BOFF2 (1U << 17) /* Output buffer disable */ -#define DAC_CR_TEN2 (1U << 18) /* Trigger enable */ -#define DAC_CR_TSEL2 (0x7 << 19) /* Trigger selection */ -#define DAC_CR_WAVE2 (0x3 << 22) /* Noise/triangle wave */ -#define DAC_CR_MAMP2 (0xF << 24) /* Mask/amplitude selector */ -#define DAC_CR_DMAEN2 (1U << 28) /* DMA enable */ - -/* Software trigger register */ - -#define DAC_SWTRIGR_SWTRIG1 (1U << 0) /* Channel 1 software trigger */ -#define DAC_SWTRIGR_SWTRIG2 (1U << 1) /* Channel 2 software trigger */ - -/* Channel 1 12-bit right-aligned data holding register */ - -#define DAC_DHR12R1_DACC1DHR 0x00000FFF - -/* Channel 1 12-bit left-aligned data holding register */ - -#define DAC_DHR12L1_DACC1DHR 0x0000FFF0 - -/* Channel 1 8-bit left-aligned data holding register */ - -#define DAC_DHR8R1_DACC1DHR 0x000000FF - -/* Channel 2 12-bit right-aligned data holding register */ - -#define DAC_DHR12R2_DACC2DHR 0x00000FFF - -/* Channel 2 12-bit left-aligned data holding register */ - -#define DAC_DHR12L2_DACC2DHR 0x0000FFF0 - -/* Channel 2 8-bit left-aligned data holding register */ - -#define DAC_DHR8R2_DACC2DHR 0x000000FF - -/* Dual DAC 12-bit right-aligned data holding register */ - -#define DAC_DHR12RD_DACC1DHR 0x00000FFF -#define DAC_DHR12RD_DACC2DHR 0x0FFF0000 - -/* Dual DAC 12-bit left-aligned data holding register */ - -#define DAC_DHR12LD_DACC1DHR 0x0000FFF0 -#define DAC_DHR12LD_DACC2DHR 0xFFF00000 - -/* Dual DAC 8-bit left-aligned data holding register */ - -#define DAC_DHR8RD_DACC1DHR 0x000000FF -#define DAC_DHR8RD_DACC2DHR 0x0000FF00 - -/* Channel 1 data output register */ - -#define DAC_DOR1_DACC1DOR 0x00000FFF - -/* Channel 1 data output register */ - -#define DAC_DOR2_DACC2DOR 0x00000FFF - -/* - * Routines - */ - -/* We take the dev argument in these for future-proofing */ - -#define DAC_CH1 0x1 -#define DAC_CH2 0x2 -void dac_init(const dac_dev *dev, uint32 flags); - -void dac_write_channel(const dac_dev *dev, uint8 channel, uint16 val); -void dac_enable_channel(const dac_dev *dev, uint8 channel); -void dac_disable_channel(const dac_dev *dev, uint8 channel); - -#define dac_write_channel1(val) ( DAC->regs->DHR12R1 = DAC_DHR12R1_DACC1DHR & val ) -#define dac_write_channel2(val) ( DAC->regs->DHR12R2 = DAC_DHR12R2_DACC2DHR & val ) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/delay.h b/GD32F1/system/libmaple/include/libmaple/delay.h deleted file mode 100644 index 472a208..0000000 --- a/GD32F1/system/libmaple/include/libmaple/delay.h +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/delay.h - * @brief Delay implementation - */ - -#ifndef _LIBMAPLE_DELAY_H_ -#define _LIBMAPLE_DELAY_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * @brief Delay the given number of microseconds. - * - * @param us Number of microseconds to delay. - */ -static inline void delay_us(uint32 us) { - us *= STM32_DELAY_US_MULT; - - /* fudge for function call overhead */ - us--; - asm volatile(" mov r0, %[us] \n\t" - "1: subs r0, #1 \n\t" - " bhi 1b \n\t" - : - : [us] "r" (us) - : "r0"); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/dma.h b/GD32F1/system/libmaple/include/libmaple/dma.h deleted file mode 100644 index a75b314..0000000 --- a/GD32F1/system/libmaple/include/libmaple/dma.h +++ /dev/null @@ -1,447 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Michael Hope. - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/dma.h - * - * @author Marti Bolivar ; - * Original implementation by Michael Hope - * - * @brief Direct Memory Access peripheral support - */ - -#ifndef _LIBMAPLE_DMA_H_ -#define _LIBMAPLE_DMA_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -/* provides: - * - * - An opaque dma_tube type, and predefined rvalues for each tube - * supported by the series. - * - * A "DMA tube" is a series-specific (hopefully integer) datatype - * that abstracts the conduit through which DMA-ed data flow. - * - * Examples: On STM32F1, dma_tube is just an alias for dma_channel, - * and the tube values are just DMA_CH1 (=1), DMA_CH2 (=2), etc. - * - * Note that a dma_tube doesn't have to be an enum, and its values - * don't have to be integral. They _do_ need to be cheap to pass as - * arguments, though. - * - * - struct dma_tube_reg_map (and typedef to dma_tube_reg_map). DMA - * register maps tend to be split into global registers and per-tube - * registers. It's convenient to pass around pointers to a tube's - * registers, since that makes it possible to configure or otherwise - * mess with a tube without knowing which one you're dealing with. - * - * - Base pointers to the various dma_tube_reg_maps. - * - * Examples: On STM32F1, these are DMAxCHy_BASE. You can access - * registers like DMAxCHy_BASE->CPAR, etc. - * - * - enum dma_request_src (and typedef to dma_request_src). This - * specifies the peripheral DMA request sources (e.g. USART TX DMA - * requests, etc.). - * - * - enum dma_mode_flags (and typedef to dma_mode_flags). Used in - * dma_tube_config. If two series both support the same mode flags, - * they must use the same enumerator names for those flags (the - * values of those enumerators are of course allowed to differ). - * - * - Normal stuff: dma_reg_map and base pointers, register bit - * definitions, dma_dev pointer declarations, and any other - * convenience functions useful for the series. */ - - /* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/dma.h" - -/* buys us dma_dev and other necessities. */ -#include -#include - -/* - * Declarations/documentation for some of the series-provided types. - */ - -/** - * @brief (Series-dependent) DMA request sources. - * - * These specify the various pieces of peripheral functionality which - * may make DMA requests. Use them to set up a DMA transfer (see - * struct dma_tube_config, dma_tube_cfg()). - */ -enum dma_request_src; - -/** - * @brief (Series-dependent) DMA tube configuration flags. - * These specify miscellaneous bits of configuration for a DMA tube. - * @see struct dma_mode_config - */ -enum dma_cfg_flags; - -/** - * @brief (Series-dependent) DMA tube register map type. - * This allows you to access a tube's registers as a group. - * @see dma_tube_regs() - */ -struct dma_tube_reg_map; - -/* - * Convenience functions - */ - -/* Initialization */ - -void dma_init(dma_dev *dev); - -/* dma_tube configuration - * - * Use these types and functions to set up DMA transfers, handle - * interrupts, etc. The main function of interest is dma_tube_cfg(), - * which the various series implement separately. */ - -/** - * @brief Specifies a DMA tube configuration. - * - * Use one of these to set up a DMA transfer by passing it to - * dma_tube_cfg(). - * - * @see dma_tube_cfg() - * @see dma_xfer_size - */ -typedef struct dma_tube_config { - /** Source of data */ - __io void *tube_src; - /** Source transfer size */ - dma_xfer_size tube_src_size; - - /** Destination of data */ - __io void *tube_dst; - /** Destination transfer size */ - dma_xfer_size tube_dst_size; - - /** - * Number of data to transfer (0 to 65,535). - * - * Note that this is NOT measured in bytes; it's measured in - * number of data, which occur in multiples of tube_src_size. For - * example, if tube_src_size is DMA_SIZE_32BITS and tube_nr_xfers - * is 2, then 8 total bytes will be transferred. - */ - unsigned tube_nr_xfers; - - /** - * Target-specific configuration flags. - * - * These are an OR of series-specific enum dma_mode_flags values. - * Consult the documentation for your target for what flags you - * can use here. - * - * Typical flag examples: DMA_CFG_SRC_INC, DMA_CFG_DST_INC, - * DMA_CFG_CIRC, DMA_CFG_CMPLT_IE, etc. - */ - unsigned tube_flags; - - /** - * Currently unused. You must set this to 0 or something valid for - * your target. */ - void *target_data; - - /** - * Hardware DMA request source. - * - * This is ignored for memory-to-memory transfers. - */ - enum dma_request_src tube_req_src; -} dma_tube_config; - -#define DMA_TUBE_CFG_SUCCESS 0 -#define DMA_TUBE_CFG_EREQ 1 -#define DMA_TUBE_CFG_ENDATA 2 -#define DMA_TUBE_CFG_EDEV 3 -#define DMA_TUBE_CFG_ESRC 4 -#define DMA_TUBE_CFG_EDST 5 -#define DMA_TUBE_CFG_EDIR 6 -#define DMA_TUBE_CFG_ESIZE 7 -#define DMA_TUBE_CFG_ECFG 0xFF -/** - * @brief Configure a DMA tube. - * - * Use this function to set up a DMA transfer. The tube will be - * disabled before being reconfigured. The transfer will have low - * priority by default. You can choose another priority before the - * transfer begins using dma_set_priority(). You can manage your - * interrupt handlers for the tube using dma_attach_interrupt() and - * dma_detach_interrupt(). - * - * After calling dma_tube_cfg() and performing any other desired - * configuration, start the transfer using dma_enable(). - * - * @param dev DMA device. - * @param tube DMA tube to configure. - * @param cfg Configuration to apply to tube. - * - * @return DMA_TUBE_CFG_SUCCESS (0) on success, <0 on failure. On - * failure, returned value will be the opposite (-) of one of: - * - * - DMA_TUBE_CFG_EREQ: tube doesn't work with cfg->tube_req_src - * - DMA_TUBE_CFG_ENDATA: cfg->tube_[src,dst]_size are - * incompatible with cfg->tube_nr_xfers, or cfg->tube_nr_xfers - * is out of bounds. - * - DMA_TUBE_CFG_EDEV: dev does not support cfg - * - DMA_TUBE_CFG_ESRC: bad cfg->tube_src - * - DMA_TUBE_CFG_EDST: bad cfg->tube_dst - * - DMA_TUBE_CFG_EDIR: dev can't transfer from cfg->tube_src to - * cfg->tube_dst - * - DMA_TUBE_CFG_ESIZE: something ended up wrong due to MSIZE/PSIZE - * - DMA_TUBE_CFG_ECFG: generic "something's wrong" - * - * @sideeffect Disables tube. May alter tube's registers even when an - * error occurs. - * @see struct dma_tube_config - * @see dma_attach_interrupt() - * @see dma_detach_interrupt() - * @see dma_enable() - */ -extern int dma_tube_cfg(dma_dev *dev, dma_tube tube, dma_tube_config *cfg); - -/* Other tube configuration functions. You can use these if - * dma_tube_cfg() isn't enough, or to adjust parts of an existing tube - * configuration. */ - -/** DMA transfer priority. */ -typedef enum dma_priority { - DMA_PRIORITY_LOW = 0, /**< Low priority */ - DMA_PRIORITY_MEDIUM = 1, /**< Medium priority */ - DMA_PRIORITY_HIGH = 2, /**< High priority */ - DMA_PRIORITY_VERY_HIGH = 3, /**< Very high priority */ -} dma_priority; - -/** - * @brief Set the priority of a DMA transfer. - * - * You may not call this function while the tube is enabled. - * - * @param dev DMA device - * @param tube DMA tube - * @param priority priority to set. - */ -extern void dma_set_priority(dma_dev *dev, dma_tube tube, - dma_priority priority); - -/** - * @brief Set the number of data transfers on a DMA tube. - * - * You may not call this function while the tube is enabled. - * - * @param dev DMA device - * @param tube Tube through which the transfer will occur. - * @param num_transfers Number of DMA transactions to set. - */ -extern void dma_set_num_transfers(dma_dev *dev, dma_tube tube, - uint16 num_transfers); - -/** - * @brief Set the base memory address where data will be read from or - * written to. - * - * You must not call this function while the tube is enabled. - * - * If the DMA memory size is 16 bits, the address is automatically - * aligned to a half-word. If the DMA memory size is 32 bits, the - * address is aligned to a word. - * - * @param dev DMA Device - * @param tube Tube whose base memory address to set. - * @param address Memory base address to use. - */ -extern void dma_set_mem_addr(dma_dev *dev, dma_tube tube, __io void *address); - -/** - * @brief Set the base peripheral address where data will be read from - * or written to. - * - * You must not call this function while the channel is enabled. - * - * If the DMA peripheral size is 16 bits, the address is automatically - * aligned to a half-word. If the DMA peripheral size is 32 bits, the - * address is aligned to a word. - * - * @param dev DMA Device - * @param tube Tube whose peripheral data register base address to set. - * @param address Peripheral memory base address to use. - */ -extern void dma_set_per_addr(dma_dev *dev, dma_tube tube, __io void *address); - -/* Interrupt handling */ - -/** - * @brief Attach an interrupt to a DMA transfer. - * - * Interrupts are enabled using series-specific mode flags in - * dma_tube_cfg(). - * - * @param dev DMA device - * @param tube Tube to attach handler to - * @param handler Interrupt handler to call when tube interrupt fires. - * @see dma_tube_cfg() - * @see dma_get_irq_cause() - * @see dma_detach_interrupt() - */ -extern void dma_attach_interrupt(dma_dev *dev, dma_tube tube, - void (*handler)(void)); - - -/** - * @brief Detach a DMA transfer interrupt handler. - * - * After calling this function, the given tube's interrupts will be - * disabled. - * - * @param dev DMA device - * @param tube Tube whose handler to detach - * @sideeffect Clears the tube's interrupt enable bits. - * @see dma_attach_interrupt() - */ -extern void dma_detach_interrupt(dma_dev *dev, dma_tube tube); - -/* Tube enable/disable */ - -/** - * @brief Enable a DMA tube. - * - * If the tube has been properly configured, calling this function - * allows it to start serving DMA requests. - * - * @param dev DMA device - * @param tube Tube to enable - * @see dma_tube_cfg() - */ -extern void dma_enable(dma_dev *dev, dma_tube tube); - -/** - * @brief Disable a DMA channel. - * - * Calling this function makes the tube stop serving DMA requests. - * - * @param dev DMA device - * @param tube Tube to disable - */ -extern void dma_disable(dma_dev *dev, dma_tube tube); - -/** - * @brief Check if a DMA tube is enabled. - * @param dev DMA device. - * @param tube Tube to check. - * @return 0 if the tube is disabled, >0 if it is enabled. - */ -static inline uint8 dma_is_enabled(dma_dev *dev, dma_tube tube); - -/* Other conveniences */ - -/** - * @brief Obtain a pointer to an individual DMA tube's registers. - * - * Examples: - * - * - On STM32F1, dma_channel_regs(DMA1, DMA_CH1)->CCR is DMA1_BASE->CCR1. - * - * @param dev DMA device. - * @param tube DMA tube whose register map to obtain. - * @return (Series-specific) tube register map. - */ -static inline dma_tube_reg_map* dma_tube_regs(dma_dev *dev, dma_tube tube); - -/** - * Encodes the reason why a DMA interrupt was called. - * @see dma_get_irq_cause() - */ -typedef enum dma_irq_cause { - DMA_TRANSFER_COMPLETE, /**< Transfer is complete. */ - DMA_TRANSFER_HALF_COMPLETE, /**< Transfer is half complete. */ - DMA_TRANSFER_ERROR, /**< Error occurred during transfer. */ - DMA_TRANSFER_DME_ERROR, /**< - * @brief Direct mode error occurred during - * transfer. */ - DMA_TRANSFER_FIFO_ERROR, /**< FIFO error occurred during transfer. */ -} dma_irq_cause; - -/** - * @brief Discover the reason why a DMA interrupt was called. - * - * You may only call this function within an attached interrupt - * handler for the given channel. - * - * This function resets the internal DMA register state which encodes - * the cause of the interrupt; consequently, it can only be called - * once per interrupt handler invocation. - * - * @param dev DMA device - * @param tube Tube whose interrupt is being handled. - * @return Reason why the interrupt fired. - * @sideeffect Clears flags in dev's interrupt status registers. - * @see dma_attach_interrupt() - * @see dma_irq_cause - */ -extern dma_irq_cause dma_get_irq_cause(dma_dev *dev, dma_tube tube); - -/** - * @brief Get the ISR status bits for a DMA channel. - * - * The bits are returned right-aligned, in the order they appear in - * the corresponding ISR register. - * - * If you're trying to figure out why a DMA interrupt fired, you may - * find dma_get_irq_cause() more convenient. - * - * @param dev DMA device - * @param tube Tube whose ISR bits to return. - * @see dma_get_irq_cause(). - */ -static inline uint8 dma_get_isr_bits(dma_dev *dev, dma_tube tube); - -/** - * @brief Clear the ISR status bits for a given DMA tube. - * - * If you're trying to clean up after yourself in a DMA interrupt, you - * may find dma_get_irq_cause() more convenient. - * - * @param dev DMA device - * @param tube Tube whose ISR bits to clear. - * @see dma_get_irq_cause() - */ -static inline void dma_clear_isr_bits(dma_dev *dev, dma_tube tube); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/dma_common.h b/GD32F1/system/libmaple/include/libmaple/dma_common.h deleted file mode 100644 index 3765cd5..0000000 --- a/GD32F1/system/libmaple/include/libmaple/dma_common.h +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/dma_common.h - * @author Marti Bolivar - * @brief Common DMA sub-header for and . - * - * CONTENTS UNSTABLE. The existence of this file is an implementation - * detail. Never include it directly. If you need something from - * here, include instead. - */ - -/* - * There's a fair amount of common DMA functionality needed by each - * and . This header exists in order - * to provide it to both, avoiding some hacks and circular - * dependencies. - */ - -#ifndef _LIBMAPLE_DMA_COMMON_H_ -#define _LIBMAPLE_DMA_COMMON_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include -#include - -/* - * Devices - */ - -struct dma_reg_map; - -/* Encapsulates state related to user interrupt handlers. You - * shouldn't touch these directly; use dma_attach_interrupt() and - * dma_detach_interupt() instead. */ -typedef struct dma_handler_config { - void (*handler)(void); /* User handler */ - nvic_irq_num irq_line; /* IRQ line for interrupt */ -} dma_handler_config; - -/** DMA device type */ -typedef struct dma_dev { - struct dma_reg_map *regs; /**< Register map */ - rcc_clk_id clk_id; /**< Clock ID */ - struct dma_handler_config handlers[]; /**< For internal use */ -} dma_dev; - -/** - * @brief DMA channels - * - * Notes: - * - This is also the dma_tube type for STM32F1. - * - Channel 0 is not available on all STM32 series. - * - * @see dma_tube - */ -typedef enum dma_channel { - DMA_CH0 = 0, /**< Channel 0 */ - DMA_CH1 = 1, /**< Channel 1 */ - DMA_CH2 = 2, /**< Channel 2 */ - DMA_CH3 = 3, /**< Channel 3 */ - DMA_CH4 = 4, /**< Channel 4 */ - DMA_CH5 = 5, /**< Channel 5 */ - DMA_CH6 = 6, /**< Channel 6 */ - DMA_CH7 = 7, /**< Channel 7 */ -} dma_channel; - -/** - * @brief Source and destination transfer sizes. - * Use these when initializing a struct dma_tube_config. - * @see struct dma_tube_config - * @see dma_tube_cfg - */ -typedef enum dma_xfer_size { - DMA_SIZE_8BITS = 0, /**< 8-bit transfers */ - DMA_SIZE_16BITS = 1, /**< 16-bit transfers */ - DMA_SIZE_32BITS = 2, /**< 32-bit transfers */ -} dma_xfer_size; - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/exti.h b/GD32F1/system/libmaple/include/libmaple/exti.h deleted file mode 100644 index 69362d6..0000000 --- a/GD32F1/system/libmaple/include/libmaple/exti.h +++ /dev/null @@ -1,144 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/exti.h - * @brief External interrupt control - */ - -/* See notes/exti.txt for more info */ - -#ifndef _LIBMAPLE_EXTI_H_ -#define _LIBMAPLE_EXTI_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -/* Roger clark. replaced by line below #include */ /* provides EXTI_BASE */ -#include "stm32f1/include/series/exti.h" -#include - -/* - * Register map and base pointer. - */ - -/** EXTI register map type */ -typedef struct exti_reg_map { - __io uint32 IMR; /**< Interrupt mask register */ - __io uint32 EMR; /**< Event mask register */ - __io uint32 RTSR; /**< Rising trigger selection register */ - __io uint32 FTSR; /**< Falling trigger selection register */ - __io uint32 SWIER; /**< Software interrupt event register */ - __io uint32 PR; /**< Pending register */ -} exti_reg_map; - -/* - * Types: exti_num, exti_cfg, exti_trigger_mode. - * - * A combination of these three specifies an external interrupt - * configuration (see exti_attach_interrupt()). - */ - -/** EXTI line. */ -typedef enum exti_num { - EXTI0, /**< EXTI line 0 */ - EXTI1, /**< EXTI line 1 */ - EXTI2, /**< EXTI line 2 */ - EXTI3, /**< EXTI line 3 */ - EXTI4, /**< EXTI line 4 */ - EXTI5, /**< EXTI line 5 */ - EXTI6, /**< EXTI line 6 */ - EXTI7, /**< EXTI line 7 */ - EXTI8, /**< EXTI line 8 */ - EXTI9, /**< EXTI line 9 */ - EXTI10, /**< EXTI line 10 */ - EXTI11, /**< EXTI line 11 */ - EXTI12, /**< EXTI line 12 */ - EXTI13, /**< EXTI line 13 */ - EXTI14, /**< EXTI line 14 */ - EXTI15, /**< EXTI line 15 */ -} exti_num; - -/** - * @brief EXTI port configuration - * - * These specify which GPIO port an external interrupt line should be - * connected to. - */ -typedef enum exti_cfg { - EXTI_PA, /**< Use PAx pin */ - EXTI_PB, /**< Use PBx pin */ - EXTI_PC, /**< Use PCx pin */ - EXTI_PD, /**< Use PDx pin */ - EXTI_PE, /**< Use PEx pin */ - EXTI_PF, /**< Use PFx pin */ - EXTI_PG, /**< Use PGx pin */ - EXTI_PH, /**< Use PHx pin */ - EXTI_PI, /**< Use PIx pin */ -} exti_cfg; - -/** External interrupt trigger mode */ -typedef enum exti_trigger_mode { - EXTI_RISING, /**< Trigger on the rising edge */ - EXTI_FALLING, /**< Trigger on the falling edge */ - EXTI_RISING_FALLING /**< Trigger on both the rising and falling edges */ -} exti_trigger_mode; - -/* - * Routines - */ - -void exti_attach_interrupt(exti_num num, - exti_cfg port, - voidFuncPtr handler, - exti_trigger_mode mode); -void exti_attach_callback(exti_num num, - exti_cfg port, - voidArgumentFuncPtr handler, - void *arg, - exti_trigger_mode mode); -void exti_detach_interrupt(exti_num num); - -/** - * @brief Set the GPIO port for an EXTI line. - * - * This is a low-level routine that most users will not - * need. exti_attach_interrupt() handles calling this function - * appropriately. - * - * @param num EXTI line - * @param port EXTI configuration for GPIO port to connect to num. - * @see exti_num - * @see exti_cfg - */ -extern void exti_select(exti_num num, exti_cfg port); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/flash.h b/GD32F1/system/libmaple/include/libmaple/flash.h deleted file mode 100644 index 3b1d7b3..0000000 --- a/GD32F1/system/libmaple/include/libmaple/flash.h +++ /dev/null @@ -1,107 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/flash.h - * @brief Flash support. - */ - -#ifndef _LIBMAPLE_FLASH_H_ -#define _LIBMAPLE_FLASH_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -#define FLASH_WAIT_STATE_0 0x0 -#define FLASH_WAIT_STATE_1 0x1 -#define FLASH_WAIT_STATE_2 0x2 -#define FLASH_WAIT_STATE_3 0x3 -#define FLASH_WAIT_STATE_4 0x4 -#define FLASH_WAIT_STATE_5 0x5 -#define FLASH_WAIT_STATE_6 0x6 -#define FLASH_WAIT_STATE_7 0x7 - -/* The series header must define: - * - * - FLASH_SAFE_WAIT_STATES, the smallest number of wait states that - * it is safe to use when SYSCLK is at its fastest documented rate - * and the MCU is powered at 3.3V (i.e. this doesn't consider - * overclocking or low voltage operation). - * - * - The following bit flags, for flash_enable_features(): - * - * -- FLASH_PREFETCH: prefetcher - * -- FLASH_ICACHE: instruction cache - * -- FLASH_DCACHE: data cache - * - * See that function's Doxygen for more restrictions. - */ - /* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/flash.h" - -#ifdef __DOXYGEN__ -/** Flash register map base pointer. */ -#define FLASH_BASE -#endif - -/* - * Flash routines - */ - -void flash_set_latency(uint32 wait_states); - -/** - * @brief Enable Flash memory features - * - * If the target MCU doesn't provide a feature (e.g. instruction and - * data caches on the STM32F1), the flag will be ignored. This allows - * using these flags unconditionally, with the desired effect taking - * place on targets that support them. - * - * @param feature_flags Bitwise OR of the following: - * FLASH_PREFETCH (turns on prefetcher), - * FLASH_ICACHE (turns on instruction cache), - * FLASH_DCACHE (turns on data cache). - */ -static inline void flash_enable_features(uint32 feature_flags) { - FLASH_BASE->ACR |= feature_flags; -} - -/** - * @brief Deprecated. Use flash_enable_features(FLASH_PREFETCH) instead. - */ -static inline void flash_enable_prefetch(void) { - flash_enable_features(FLASH_PREFETCH); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/fsmc.h b/GD32F1/system/libmaple/include/libmaple/fsmc.h deleted file mode 100644 index 6225fee..0000000 --- a/GD32F1/system/libmaple/include/libmaple/fsmc.h +++ /dev/null @@ -1,340 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Bryan Newbold. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/fsmc.h - * @brief Flexible static memory controller support. - */ - -/* - * See ../notes/fsmc.txt for more info - */ - -#ifndef _LIBMAPLE_FSMC_H_ -#define _LIBMAPLE_FSMC_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include - -#if !STM32_HAVE_FSMC -#error "FSMC is unavailable on your MCU" -#endif - -/* - * Register maps and devices - */ - -/** FSMC register map type */ -typedef struct fsmc_reg_map { - __io uint32 BCR1; /**< SRAM/NOR-Flash chip-select control register 1 */ - __io uint32 BTR1; /**< SRAM/NOR-Flash chip-select timing register 1 */ - __io uint32 BCR2; /**< SRAM/NOR-Flash chip-select control register 2 */ - __io uint32 BTR2; /**< SRAM/NOR-Flash chip-select timing register 2 */ - __io uint32 BCR3; /**< SRAM/NOR-Flash chip-select control register 3 */ - __io uint32 BTR3; /**< SRAM/NOR-Flash chip-select timing register 3 */ - __io uint32 BCR4; /**< SRAM/NOR-Flash chip-select control register 4 */ - __io uint32 BTR4; /**< SRAM/NOR-Flash chip-select timing register 4 */ - const uint8 RESERVED1[64]; /**< Reserved */ - __io uint32 PCR2; /**< PC Card/NAND Flash control register 2 */ - __io uint32 SR2; /**< FIFO status and interrupt register 2 */ - __io uint32 PMEM2; /**< Common memory space timing register 2 */ - __io uint32 PATT2; /**< Attribute memory space timing register 2 */ - const uint8 RESERVED2[4]; /**< Reserved */ - __io uint32 ECCR2; /**< ECC result register 2 */ - const uint8 RESERVED3[2]; - __io uint32 PCR3; /**< PC Card/NAND Flash control register 3 */ - __io uint32 SR3; /**< FIFO status and interrupt register 3 */ - __io uint32 PMEM3; /**< Common memory space timing register 3 */ - __io uint32 PATT3; /**< Attribute memory space timing register 3 */ - const uint32 RESERVED4; /**< Reserved */ - __io uint32 ECCR3; /**< ECC result register 3 */ - const uint8 RESERVED5[8]; /**< Reserved */ - __io uint32 PCR4; /**< PC Card/NAND Flash control register 4 */ - __io uint32 SR4; /**< FIFO status and interrupt register 4 */ - __io uint32 PMEM4; /**< Common memory space timing register 4 */ - __io uint32 PATT4; /**< Attribute memory space timing register 4 */ - __io uint32 PIO4; /**< I/O space timing register 4 */ - const uint8 RESERVED6[80]; /**< Reserved */ - __io uint32 BWTR1; /**< SRAM/NOR-Flash write timing register 1 */ - const uint32 RESERVED7; /**< Reserved */ - __io uint32 BWTR2; /**< SRAM/NOR-Flash write timing register 2 */ - const uint32 RESERVED8; /**< Reserved */ - __io uint32 BWTR3; /**< SRAM/NOR-Flash write timing register 3 */ - const uint32 RESERVED9; /**< Reserved */ - __io uint32 BWTR4; /**< SRAM/NOR-Flash write timing register 4 */ -} __attribute__((packed)) fsmc_reg_map; - -#define __FSMCB 0xA0000000 - -/** FSMC register map base pointer */ -#define FSMC_BASE ((struct fsmc_reg_map*)__FSMCB) - -/** FSMC NOR/PSRAM register map type */ -typedef struct fsmc_nor_psram_reg_map { - __io uint32 BCR; /**< Chip-select control register */ - __io uint32 BTR; /**< Chip-select timing register */ - const uint8 RESERVED[252]; /**< Reserved */ - __io uint32 BWTR; /**< Write timing register */ -} fsmc_nor_psram_reg_map; - -/** FSMC NOR/PSRAM base pointer 1 */ -#define FSMC_NOR_PSRAM1_BASE ((struct fsmc_nor_psram_reg_map*)__FSMCB) - -/** FSMC NOR/PSRAM base pointer 2 */ -#define FSMC_NOR_PSRAM2_BASE ((struct fsmc_nor_psram_reg_map*)(__FSMCB + 0x8)) - -/** FSMC NOR/PSRAM base pointer 3 */ -#define FSMC_NOR_PSRAM3_BASE ((struct fsmc_nor_psram_reg_map*)(__FSMCB + 0x10)) - -/** FSMC NOR/PSRAM base pointer 4 */ -#define FSMC_NOR_PSRAM4_BASE ((struct fsmc_nor_psram_reg_map*)(__FSMCB + 0x18)) - -/* - * Register bit definitions - */ - -/* NOR/PSRAM chip-select control registers */ - -#define FSMC_BCR_CBURSTRW_BIT 19 -#define FSMC_BCR_ASYNCWAIT_BIT 15 -#define FSMC_BCR_EXTMOD_BIT 14 -#define FSMC_BCR_WAITEN_BIT 13 -#define FSMC_BCR_WREN_BIT 12 -#define FSMC_BCR_WAITCFG_BIT 11 -#define FSMC_BCR_WRAPMOD_BIT 10 -#define FSMC_BCR_WAITPOL_BIT 9 -#define FSMC_BCR_BURSTEN_BIT 8 -#define FSMC_BCR_FACCEN_BIT 6 -#define FSMC_BCR_MUXEN_BIT 1 -#define FSMC_BCR_MBKEN_BIT 0 - -#define FSMC_BCR_CBURSTRW (1U << FSMC_BCR_CBURSTRW_BIT) -#define FSMC_BCR_ASYNCWAIT (1U << FSMC_BCR_ASYNCWAIT_BIT) -#define FSMC_BCR_EXTMOD (1U << FSMC_BCR_EXTMOD_BIT) -#define FSMC_BCR_WAITEN (1U << FSMC_BCR_WAITEN_BIT) -#define FSMC_BCR_WREN (1U << FSMC_BCR_WREN_BIT) -#define FSMC_BCR_WAITCFG (1U << FSMC_BCR_WAITCFG_BIT) -#define FSMC_BCR_WRAPMOD (1U << FSMC_BCR_WRAPMOD_BIT) -#define FSMC_BCR_WAITPOL (1U << FSMC_BCR_WAITPOL_BIT) -#define FSMC_BCR_BURSTEN (1U << FSMC_BCR_BURSTEN_BIT) -#define FSMC_BCR_FACCEN (1U << FSMC_BCR_FACCEN_BIT) -#define FSMC_BCR_MWID (0x3 << 4) -#define FSMC_BCR_MWID_8BITS (0x0 << 4) -#define FSMC_BCR_MWID_16BITS (0x1 << 4) -#define FSMC_BCR_MTYP (0x3 << 2) -#define FSMC_BCR_MTYP_SRAM (0x0 << 2) -#define FSMC_BCR_MTYP_PSRAM (0x1 << 2) -#define FSMC_BCR_MTYP_NOR_FLASH (0x2 << 2) -#define FSMC_BCR_MUXEN (1U << FSMC_BCR_MUXEN_BIT) -#define FSMC_BCR_MBKEN (1U << FSMC_BCR_MBKEN_BIT) - -/* SRAM/NOR-Flash chip-select timing registers */ - -#define FSMC_BTR_ACCMOD (0x3 << 28) -#define FSMC_BTR_ACCMOD_A (0x0 << 28) -#define FSMC_BTR_ACCMOD_B (0x1 << 28) -#define FSMC_BTR_ACCMOD_C (0x2 << 28) -#define FSMC_BTR_ACCMOD_D (0x3 << 28) -#define FSMC_BTR_DATLAT (0xF << 24) -#define FSMC_BTR_CLKDIV (0xF << 20) -#define FSMC_BTR_BUSTURN (0xF << 16) -#define FSMC_BTR_DATAST (0xFF << 8) -#define FSMC_BTR_ADDHLD (0xF << 4) -#define FSMC_BTR_ADDSET 0xF - -/* SRAM/NOR-Flash write timing registers */ - -#define FSMC_BWTR_ACCMOD (0x3 << 28) -#define FSMC_BWTR_ACCMOD_A (0x0 << 28) -#define FSMC_BWTR_ACCMOD_B (0x1 << 28) -#define FSMC_BWTR_ACCMOD_C (0x2 << 28) -#define FSMC_BWTR_ACCMOD_D (0x3 << 28) -#define FSMC_BWTR_DATLAT (0xF << 24) -#define FSMC_BWTR_CLKDIV (0xF << 20) -#define FSMC_BWTR_DATAST (0xFF << 8) -#define FSMC_BWTR_ADDHLD (0xF << 4) -#define FSMC_BWTR_ADDSET 0xF - -/* NAND Flash/PC Card controller registers */ - -#define FSMC_PCR_ECCEN_BIT 6 -#define FSMC_PCR_PTYP_BIT 3 -#define FSMC_PCR_PBKEN_BIT 2 -#define FSMC_PCR_PWAITEN_BIT 1 - -#define FSMC_PCR_ECCPS (0x7 << 17) -#define FSMC_PCR_ECCPS_256B (0x0 << 17) -#define FSMC_PCR_ECCPS_512B (0x1 << 17) -#define FSMC_PCR_ECCPS_1024B (0x2 << 17) -#define FSMC_PCR_ECCPS_2048B (0x3 << 17) -#define FSMC_PCR_ECCPS_4096B (0x4 << 17) -#define FSMC_PCR_ECCPS_8192B (0x5 << 17) -#define FSMC_PCR_TAR (0xF << 13) -#define FSMC_PCR_TCLR (0xF << 9) -#define FSMC_PCR_ECCEN (1U << FSMC_PCR_ECCEN_BIT) -#define FSMC_PCR_PWID (0x3 << 4) -#define FSMC_PCR_PWID_8BITS (0x0 << 4) -#define FSMC_PCR_PWID_16BITS (0x1 << 4) -#define FSMC_PCR_PTYP (1U << FSMC_PCR_PTYP_BIT) -#define FSMC_PCR_PTYP_PC_CF_PCMCIA (0x0 << FSMC_PCR_PTYP_BIT) -#define FSMC_PCR_PTYP_NAND (0x1 << FSMC_PCR_PTYP_BIT) -#define FSMC_PCR_PBKEN (1U << FSMC_PCR_PBKEN_BIT) -#define FSMC_PCR_PWAITEN (1U << FSMC_PCR_PWAITEN_BIT) - -/* FIFO status and interrupt registers */ - -#define FSMC_SR_FEMPT_BIT 6 -#define FSMC_SR_IFEN_BIT 5 -#define FSMC_SR_ILEN_BIT 4 -#define FSMC_SR_IREN_BIT 3 -#define FSMC_SR_IFS_BIT 2 -#define FSMC_SR_ILS_BIT 1 -#define FSMC_SR_IRS_BIT 0 - -#define FSMC_SR_FEMPT (1U << FSMC_SR_FEMPT_BIT) -#define FSMC_SR_IFEN (1U << FSMC_SR_IFEN_BIT) -#define FSMC_SR_ILEN (1U << FSMC_SR_ILEN_BIT) -#define FSMC_SR_IREN (1U << FSMC_SR_IREN_BIT) -#define FSMC_SR_IFS (1U << FSMC_SR_IFS_BIT) -#define FSMC_SR_ILS (1U << FSMC_SR_ILS_BIT) -#define FSMC_SR_IRS (1U << FSMC_SR_IRS_BIT) - -/* Common memory space timing registers */ - -#define FSMC_PMEM_MEMHIZ (0xFF << 24) -#define FSMC_PMEM_MEMHOLD (0xFF << 16) -#define FSMC_PMEM_MEMWAIT (0xFF << 8) -#define FSMC_PMEM_MEMSET 0xFF - -/* Attribute memory space timing registers */ - -#define FSMC_PATT_ATTHIZ (0xFF << 24) -#define FSMC_PATT_ATTHOLD (0xFF << 16) -#define FSMC_PATT_ATTWAIT (0xFF << 8) -#define FSMC_PATT_ATTSET 0xFF - -/* I/O space timing register 4 */ - -#define FSMC_PIO_IOHIZ (0xFF << 24) -#define FSMC_PIO_IOHOLD (0xFF << 16) -#define FSMC_PIO_IOWAIT (0xFF << 8) -#define FSMC_PIO_IOSET 0xFF - -/* - * Memory bank boundary addresses - */ - -/** - * @brief Void pointer to base address of FSMC memory bank 1 (NOR/PSRAM). - * - * This bank is split into 4 regions. Each region supports interfacing - * with 1 NOR Flash, SRAM, or PSRAM chip. The base addresses of these - * regions are FSMC_NOR_PSRAM_REGIONx, for x = 1, 2, 3, 4. - */ -#define FSMC_BANK1 ((void*)0x60000000) - -/** - * @brief Void pointer to base address of FSMC memory bank 1, region 1 - * (NOR/PSRAM). - */ -#define FSMC_NOR_PSRAM_REGION1 FSMC_BANK1 - -/** - * @brief Void pointer to base address of FSMC memory bank 1, region 2 - * (NOR/PSRAM). - */ -#define FSMC_NOR_PSRAM_REGION2 ((void*)0x64000000) - -/** - * @brief Void pointer to base address of FSMC memory bank 1, region 3 - * (NOR/PSRAM). - */ -#define FSMC_NOR_PSRAM_REGION3 ((void*)0x68000000) - -/** - * @brief Void pointer to base address of FSMC memory bank 1, region 4 - * (NOR/PSRAM). - */ -#define FSMC_NOR_PSRAM_REGION4 ((void*)0x6C000000) - -/** Void pointer to base address of FSMC memory bank 2 (NAND Flash). */ -#define FSMC_BANK2 ((void*)0x70000000) - -/** Void pointer to base address of FSMC memory bank 3 (NAND Flash). */ -#define FSMC_BANK3 ((void*)0x80000000) - -/** - * @brief Void pointer to base address of FSMC memory bank 4 (PC card - * devices). - */ -#define FSMC_BANK4 ((void*)0x90000000) - -/* - * SRAM/NOR Flash routines - */ - -/** - * @brief Configure FSMC GPIOs for use with SRAM. - */ -void fsmc_sram_init_gpios(void); - -/** - * Set the DATAST bits in the given NOR/PSRAM register map's - * chip-select timing register (FSMC_BTR). - * - * @param regs NOR Flash/PSRAM register map whose chip-select timing - * register to set. - * @param datast Value to use for DATAST bits. - */ -static inline void fsmc_nor_psram_set_datast(fsmc_nor_psram_reg_map *regs, - uint8 datast) { - regs->BTR &= ~FSMC_BTR_DATAST; - regs->BTR |= datast << 8; -} - -/** - * Set the ADDHLD bits in the given NOR/PSRAM register map's chip - * select timing register (FSMC_BTRx). - * - * @param regs NOR Flash/PSRAM register map whose chip-select timing - * register to set. - * @param addset Value to use for ADDSET bits. - */ -static inline void fsmc_nor_psram_set_addset(fsmc_nor_psram_reg_map *regs, - uint8 addset) { - regs->BTR &= ~FSMC_BTR_ADDSET; - regs->BTR |= addset & 0xF; -} - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/gpio.h b/GD32F1/system/libmaple/include/libmaple/gpio.h deleted file mode 100644 index aba4e11..0000000 --- a/GD32F1/system/libmaple/include/libmaple/gpio.h +++ /dev/null @@ -1,123 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*****************************************************************************/ - -/** - * @file libmaple/include/libmaple/gpio.h - * @brief General Purpose I/O (GPIO) interace. - */ - -#ifndef _LIBMAPLE_GPIO_H_ -#define _LIBMAPLE_GPIO_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -/* - * Note: Series header must define: - * - enum gpio_pin_mode (TODO think harder about portability here) - */ - -// roger clark. replaced with line below #include -#include "stm32f1/include/series/gpio.h" -#include -#include -#include - -/* - * Device type - */ - -/** GPIO device type */ -typedef struct gpio_dev { - gpio_reg_map *regs; /**< Register map */ - rcc_clk_id clk_id; /**< RCC clock information */ - /** - * @brief (Deprecated) External interrupt port. - * Instead of dev->exti_port, use gpio_exti_port(dev). - */ - exti_cfg exti_port; -} gpio_dev; - -/* - * Portable routines - */ - -void gpio_init(gpio_dev *dev); -void gpio_init_all(void); -/* TODO flags argument version? */ -void gpio_set_mode(gpio_dev *dev, uint8 pin, gpio_pin_mode mode); -gpio_pin_mode gpio_get_mode(gpio_dev *dev, uint8 pin); -/** - * @brief Get a GPIO port's corresponding EXTI port configuration. - * @param dev GPIO port whose exti_cfg to return. - */ -static inline exti_cfg gpio_exti_port(gpio_dev *dev) { - return (exti_cfg)(EXTI_PA + (dev->clk_id - RCC_GPIOA)); -} - -/** - * Set or reset a GPIO pin. - * - * Pin must have previously been configured to output mode. - * - * @param dev GPIO device whose pin to set. - * @param pin Pin on to set or reset - * @param val If true, set the pin. If false, reset the pin. - */ -static inline void gpio_write_bit(gpio_dev *dev, uint8 pin, uint8 val) { - val = !val; /* "set" bits are lower than "reset" bits */ - dev->regs->BSRR = (1U << pin) << (16 * val); -} - -/** - * Determine whether or not a GPIO pin is set. - * - * Pin must have previously been configured to input mode. - * - * @param dev GPIO device whose pin to test. - * @param pin Pin on dev to test. - * @return True if the pin is set, false otherwise. - */ -static inline uint32 gpio_read_bit(gpio_dev *dev, uint8 pin) { - return dev->regs->IDR & (1U << pin); -} - -/** - * Toggle a pin configured as output push-pull. - * @param dev GPIO device. - * @param pin Pin on dev to toggle. - */ -static inline void gpio_toggle_bit(gpio_dev *dev, uint8 pin) { - dev->regs->ODR = dev->regs->ODR ^ (1U << pin); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/i2c.h b/GD32F1/system/libmaple/include/libmaple/i2c.h deleted file mode 100644 index 92ec29e..0000000 --- a/GD32F1/system/libmaple/include/libmaple/i2c.h +++ /dev/null @@ -1,414 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/i2c.h - * @brief Inter-Integrated Circuit (I2C) peripheral support - * - * Currently master-only. Usage notes: - * - * - Enable an I2C device with i2c_master_enable(). - * - Initialize an array of struct i2c_msg to suit the bus - * transactions (reads/writes) you wish to perform. - * - Call i2c_master_xfer() to do the work. - */ - -#ifndef _LIBMAPLE_I2C_H_ -#define _LIBMAPLE_I2C_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Series header must provide: - * - * - uint32 _i2c_bus_clk(i2c_dev*): Clock frequency of dev's bus, in - * MHz. (This is for internal use only). - * - * - (optional) _I2C_HAVE_IRQ_FIXUP: Leave undefined, or define to 1. - * This is for internal use only. It's a hack to work around a - * silicon bug related to I2C IRQ pre-emption on some targets. If 1, - * the series header must also declare and implement a routine with - * this signature (it may also be provided as a macro): - * - * void _i2c_irq_priority_fixup(i2c_dev*) - * - * This will be called by i2c_enable_irq() before actually enabling - * I2C interrupts. - * - * - Reg. map base pointers, device pointer declarations. - */ - - /* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/i2c.h" -#include - -#include -#include -#include -#include - -/** I2C register map type */ -typedef struct i2c_reg_map { - __io uint32 CR1; /**< Control register 1 */ - __io uint32 CR2; /**< Control register 2 */ - __io uint32 OAR1; /**< Own address register 1 */ - __io uint32 OAR2; /**< Own address register 2 */ - __io uint32 DR; /**< Data register */ - __io uint32 SR1; /**< Status register 1 */ - __io uint32 SR2; /**< Status register 2 */ - __io uint32 CCR; /**< Clock control register */ - __io uint32 TRISE; /**< TRISE (rise time) register */ -} i2c_reg_map; - -/** - * @brief I2C message type - */ -typedef struct i2c_msg { - uint16 addr; /**< Address */ - -#define I2C_MSG_READ 0x1 -#define I2C_MSG_10BIT_ADDR 0x2 - /** - * Bitwise OR of: - * - I2C_MSG_READ (write is default) - * - I2C_MSG_10BIT_ADDR (7-bit is default) */ - uint16 flags; - - uint16 length; /**< Message length */ - uint16 xferred; /**< Messages transferred */ - uint8 *data; /**< Data */ -} i2c_msg; - -/* - * Register bit definitions - */ - -/* Control register 1 */ - -#define I2C_CR1_SWRST (1U << 15) // Software reset -#define I2C_CR1_ALERT (1U << 13) // SMBus alert -#define I2C_CR1_PEC (1U << 12) // Packet error checking -#define I2C_CR1_POS (1U << 11) // Acknowledge/PEC position -#define I2C_CR1_ACK (1U << 10) // Acknowledge enable -#define I2C_CR1_STOP (1U << 9) // Stop generation -#define I2C_CR1_START (1U << 8) // Start generation -#define I2C_CR1_NOSTRETCH (1U << 7) // Clock stretching disable -#define I2C_CR1_ENGC (1U << 6) // General call enable -#define I2C_CR1_ENPEC (1U << 5) // PEC enable -#define I2C_CR1_ENARP (1U << 4) // ARP enable -#define I2C_CR1_SMBTYPE (1U << 3) // SMBus type -#define I2C_CR1_SMBTYPE_DEVICE (0U << 3) // SMBus type: device -#define I2C_CR1_SMBTYPE_HOST (1U << 3) // SMBus type: host -#define I2C_CR1_SMBUS (1U << 1) // SMBus mode -#define I2C_CR1_SMBUS_I2C (0U << 1) // SMBus mode: I2C -#define I2C_CR1_SMBUS_SMBUS (1U << 1) // SMBus mode: SMBus -#define I2C_CR1_PE (1U << 0) // Peripheral Enable - -/* Control register 2 */ - -#define I2C_CR2_LAST (1U << 12) // DMA last transfer -#define I2C_CR2_DMAEN (1U << 11) // DMA requests enable -#define I2C_CR2_ITBUFEN (1U << 10) // Buffer interrupt enable -#define I2C_CR2_ITEVTEN (1U << 9) // Event interupt enable -#define I2C_CR2_ITERREN (1U << 8) // Error interupt enable -#define I2C_CR2_FREQ 0x3F // Peripheral input frequency - -/* Own address register 1 */ - -#define I2C_OAR1_ADDMODE (1U << 15) // Addressing mode -#define I2C_OAR1_ADDMODE_7_BIT (0U << 15) // Addressing mode: 7-bit -#define I2C_OAR1_ADDMODE_10_BIT (1U << 15) // Addressing mode: 10-bit -#define I2C_OAR1_ADD 0x3FF // Interface address - -/* Own address register 2 */ - -#define I2C_OAR2_ADD2 0xFE // Interface address -#define I2C_OAR2_ENDUAL 1U // Dual addressing mode enable - -/* Status register 1 */ - -#define I2C_SR1_SMBALERT (1U << 15) // SMBus alert -#define I2C_SR1_TIMEOUT (1U << 14) // Timeout or Tlow error -#define I2C_SR1_PECERR (1U << 12) // PEC Error in reception -#define I2C_SR1_OVR (1U << 11) // Overrun/underrun -#define I2C_SR1_AF (1U << 10) // Acknowledge failure -#define I2C_SR1_ARLO (1U << 9) // Arbitration lost -#define I2C_SR1_BERR (1U << 8) // Bus error -#define I2C_SR1_TXE (1U << 7) // Data register empty -#define I2C_SR1_RXNE (1U << 6) // Data register not empty -#define I2C_SR1_STOPF (1U << 4) // Stop detection -#define I2C_SR1_ADD10 (1U << 3) // 10-bit header sent -#define I2C_SR1_BTF (1U << 2) // Byte transfer finished -#define I2C_SR1_ADDR (1U << 1) // Address sent/matched -#define I2C_SR1_SB (1U << 0) // Start bit - -/* Status register 2 */ - -#define I2C_SR2_PEC 0xFF00 // Packet error checking register -#define I2C_SR2_DUALF (1U << 7) // Dual flag -#define I2C_SR2_SMBHOST (1U << 6) // SMBus host header -#define I2C_SR2_SMBDEFAULT (1U << 5) // SMBus device default address -#define I2C_SR2_GENCALL (1U << 4) // General call address -#define I2C_SR2_TRA (1U << 2) // Transmitter/receiver -#define I2C_SR2_BUSY (1U << 1) // Bus busy -#define I2C_SR2_MSL (1U << 0) // Master/slave - -/* Clock control register */ - -#define I2C_CCR_FS (1U << 15) // Fast mode selection -#define I2C_CCR_DUTY (1U << 14) // Fast mode duty cycle -#define I2C_CCR_DUTY_2_1 (0U << 14) // Fast mode duty: 2/1 -#define I2C_CCR_DUTY_16_9 (1U << 14) // Fast mode duty: 16/9 -#define I2C_CCR_CCR 0xFFF // Clock control bits - -/* - * Convenience routines - */ - -/* Main I2C API */ - -/* I2C enable options */ -#define I2C_FAST_MODE 0x1 // 400 khz -#define I2C_DUTY_16_9 0x2 // 16/9 duty ratio -/* Flag 0x4 is reserved; DO NOT USE. */ -#define I2C_BUS_RESET 0x8 // Perform a bus reset -void i2c_master_enable(i2c_dev *dev, uint32 flags); - -#define I2C_ERROR_PROTOCOL (-1) -#define I2C_ERROR_TIMEOUT (-2) -int32 i2c_master_xfer(i2c_dev *dev, i2c_msg *msgs, uint16 num, uint32 timeout); - -void i2c_bus_reset(const i2c_dev *dev); - -/** - * @brief Disable an I2C device - * - * This function disables the corresponding peripheral and marks dev's - * state as I2C_STATE_DISABLED. - * - * @param dev Device to disable. - */ -static inline void i2c_disable(i2c_dev *dev) { - dev->regs->CR1 &= ~I2C_CR1_PE; - dev->state = I2C_STATE_DISABLED; -} - -/* Start/stop conditions */ - -/** - * @brief Generate a start condition on the bus. - * @param dev I2C device - */ -static inline void i2c_start_condition(i2c_dev *dev) { - uint32 cr1; - while ((cr1 = dev->regs->CR1) & (I2C_CR1_START | - I2C_CR1_STOP | - I2C_CR1_PEC)) { - ; - } - dev->regs->CR1 |= I2C_CR1_START; -} - -/** - * @brief Generate a stop condition on the bus - * @param dev I2C device - */ -static inline void i2c_stop_condition(i2c_dev *dev) { - uint32 cr1; - while ((cr1 = dev->regs->CR1) & (I2C_CR1_START | - I2C_CR1_STOP | - I2C_CR1_PEC)) { - ; - } - dev->regs->CR1 |= I2C_CR1_STOP; - while ((cr1 = dev->regs->CR1) & (I2C_CR1_START | - I2C_CR1_STOP | - I2C_CR1_PEC)) { - ; - } - -} - -/* IRQ enable/disable */ - -#ifndef _I2C_HAVE_IRQ_FIXUP -/* The series header provides this if _I2C_HAVE_IRQ_FIXUP is defined, - * but we need it either way. */ -#define _i2c_irq_priority_fixup(dev) ((void)0) -#endif - -#define I2C_IRQ_ERROR I2C_CR2_ITERREN -#define I2C_IRQ_EVENT I2C_CR2_ITEVTEN -#define I2C_IRQ_BUFFER I2C_CR2_ITBUFEN -/** - * @brief Enable one or more I2C interrupts - * @param dev I2C device - * @param irqs Bitwise or of: - * I2C_IRQ_ERROR (error interrupt), - * I2C_IRQ_EVENT (event interrupt), and - * I2C_IRQ_BUFFER (buffer interrupt). - */ -static inline void i2c_enable_irq(i2c_dev *dev, uint32 irqs) { - _i2c_irq_priority_fixup(dev); - dev->regs->CR2 |= irqs; -} - -/** - * @brief Disable one or more I2C interrupts - * @param dev I2C device - * @param irqs Bitwise or of: - * I2C_IRQ_ERROR (error interrupt), - * I2C_IRQ_EVENT (event interrupt), and - * I2C_IRQ_BUFFER (buffer interrupt). - */ -static inline void i2c_disable_irq(i2c_dev *dev, uint32 irqs) { - dev->regs->CR2 &= ~irqs; -} - -/* ACK/NACK */ - -/** - * @brief Enable I2C acknowledgment - * @param dev I2C device - */ -static inline void i2c_enable_ack(i2c_dev *dev) { - dev->regs->CR1 |= I2C_CR1_ACK; -} - -/** - * @brief Disable I2C acknowledgment - * @param dev I2C device - */ -static inline void i2c_disable_ack(i2c_dev *dev) { - dev->regs->CR1 &= ~I2C_CR1_ACK; -} - -/* GPIO control */ - -/** - * @brief Configure device GPIOs. - * - * Configure GPIO bits dev->sda_pin and dev->scl_pin on GPIO device - * dev->gpio_port for use with I2C device dev. - * - * @param dev I2C Device - * @see i2c_release_gpios() - */ -extern void i2c_config_gpios(const i2c_dev *dev); - -/** - * @brief Release GPIOs controlling an I2C bus - * - * Releases the I2C bus controlled by dev as master, and disconnects - * GPIO bits dev->sda_pin and dev->scl_pin on GPIO device - * dev->gpio_port from I2C device dev. - * - * @param dev I2C device - * @see i2c_config_gpios() - */ -extern void i2c_master_release_bus(const i2c_dev *dev); - -/* Miscellaneous low-level routines */ - -void i2c_init(i2c_dev *dev); - -/** - * @brief Turn on an I2C peripheral - * @param dev Device to enable - */ -static inline void i2c_peripheral_enable(i2c_dev *dev) { - dev->regs->CR1 |= I2C_CR1_PE; -} - -/** - * @brief Turn off an I2C peripheral - * @param dev Device to turn off - */ -static inline void i2c_peripheral_disable(i2c_dev *dev) { - dev->regs->CR1 &= ~I2C_CR1_PE; -} - -/** - * @brief Fill transmit register - * @param dev I2C device - * @param byte Byte to write - */ -static inline void i2c_write(i2c_dev *dev, uint8 byte) { - dev->regs->DR = byte; -} - -/** - * @brief Set input clock frequency, in MHz - * @param dev I2C device - * @param freq Frequency, in MHz. This must be at least 2, and at most - * the APB frequency of dev's bus. (For example, if - * rcc_dev_clk(dev) == RCC_APB1, freq must be at most - * PCLK1, in MHz). There is an additional limit of 46 MHz. - */ -static inline void i2c_set_input_clk(i2c_dev *dev, uint32 freq) { -#define I2C_MAX_FREQ_MHZ 46 - ASSERT(2 <= freq && freq <= _i2c_bus_clk(dev) && freq <= I2C_MAX_FREQ_MHZ); - uint32 cr2 = dev->regs->CR2; - cr2 &= ~I2C_CR2_FREQ; - cr2 |= freq; - dev->regs->CR2 = freq; -#undef I2C_MAX_FREQ_MHZ -} - -/** - * @brief Set I2C clock control register. - * - * See the chip reference manual for the details. - * - * @param dev I2C device - * @param val Value to use for clock control register (in - * Fast/Standard mode) - */ -static inline void i2c_set_clk_control(i2c_dev *dev, uint32 val) { - uint32 ccr = dev->regs->CCR; - ccr &= ~I2C_CCR_CCR; - ccr |= val; - dev->regs->CCR = ccr; -} - -/** - * @brief Set SCL rise time - * @param dev I2C device - * @param trise Maximum rise time in fast/standard mode (see chip - * reference manual for the relevant formulas). - */ -static inline void i2c_set_trise(i2c_dev *dev, uint32 trise) { - dev->regs->TRISE = trise; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/i2c_common.h b/GD32F1/system/libmaple/include/libmaple/i2c_common.h deleted file mode 100644 index 17cabe3..0000000 --- a/GD32F1/system/libmaple/include/libmaple/i2c_common.h +++ /dev/null @@ -1,93 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung (from ). - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/i2c_common.h - * @author Marti Bolivar - * @brief This file is an implementation detail - * - * CONTENTS UNSTABLE. The existence of this file is an implementation - * detail. Never include it directly. If you need something from - * here, include instead. - */ - -#ifndef _LIBMAPLE_I2C_COMMON_H_ -#define _LIBMAPLE_I2C_COMMON_H_ - -#include -#include -#include - -struct gpio_dev; -struct i2c_reg_map; -struct i2c_msg; - -/** I2C device states */ -typedef enum i2c_state { - I2C_STATE_DISABLED = 0, /**< Disabled */ - I2C_STATE_IDLE = 1, /**< Idle */ - I2C_STATE_XFER_DONE = 2, /**< Done with transfer */ - I2C_STATE_BUSY = 3, /**< Busy */ - I2C_STATE_ERROR = -1 /**< Error occurred */ -} i2c_state; - -/** - * @brief I2C device type. - */ -typedef struct i2c_dev { - struct i2c_reg_map *regs; /**< Register map */ - struct i2c_msg *msg; /**< Messages */ - uint32 error_flags; /**< Error flags, set on I2C error condition */ - volatile uint32 timestamp; /**< For internal use */ - - /** - * @brief Deprecated. Use .scl_port or .sda_port instead. - * If non-null, this will be used as SDA, SCL pins' GPIO port. If - * null, then .sda_port will be used for SDA, and .sda_port for - * SDA. */ - struct gpio_dev *gpio_port; - - /** - * @brief SDA GPIO device (but see .gpio_port). - */ - struct gpio_dev *sda_port; - - /** - * @brief SCL GPIO device (but see .gpio_port). - */ - struct gpio_dev *scl_port; - - uint16 msgs_left; /**< Messages left */ - uint8 sda_pin; /**< SDA bit on gpio_port */ - uint8 scl_pin; /**< SCL bit on gpio_port */ - rcc_clk_id clk_id; /**< RCC clock information */ - nvic_irq_num ev_nvic_line; /**< Event IRQ number */ - nvic_irq_num er_nvic_line; /**< Error IRQ number */ - volatile i2c_state state; /**< Device state */ -} i2c_dev; - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/iwdg.h b/GD32F1/system/libmaple/include/libmaple/iwdg.h deleted file mode 100644 index 3a16c55..0000000 --- a/GD32F1/system/libmaple/include/libmaple/iwdg.h +++ /dev/null @@ -1,115 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Michael Hope. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/iwdg.h - * @author Michael Hope, Marti Bolivar - * @brief Independent watchdog support. - * - * To use the independent watchdog, first call iwdg_init() with the - * appropriate prescaler and IWDG counter reload values for your - * application. Afterwards, you must periodically call iwdg_feed() - * before the IWDG counter reaches 0 to reset the counter to its - * reload value. If you do not, the chip will reset. - * - * Once started, the independent watchdog cannot be turned off. - */ - -#ifndef _LIBMAPLE_IWDG_H_ -#define _LIBMAPLE_IWDG_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -/* - * Register map - */ - -/** Independent watchdog register map type. */ -typedef struct iwdg_reg_map { - __io uint32 KR; /**< Key register. */ - __io uint32 PR; /**< Prescaler register. */ - __io uint32 RLR; /**< Reload register. */ - __io uint32 SR; /**< Status register */ -} iwdg_reg_map; - -/** Independent watchdog base pointer */ -#define IWDG_BASE ((struct iwdg_reg_map*)0x40003000) - -/* - * Register bit definitions - */ - -/* Key register */ - -#define IWDG_KR_UNLOCK 0x5555 -#define IWDG_KR_FEED 0xAAAA -#define IWDG_KR_START 0xCCCC - -/* Prescaler register */ - -#define IWDG_PR_DIV_4 0x0 -#define IWDG_PR_DIV_8 0x1 -#define IWDG_PR_DIV_16 0x2 -#define IWDG_PR_DIV_32 0x3 -#define IWDG_PR_DIV_64 0x4 -#define IWDG_PR_DIV_128 0x5 -#define IWDG_PR_DIV_256 0x6 - -/* Status register */ - -#define IWDG_SR_RVU_BIT 1 -#define IWDG_SR_PVU_BIT 0 - -#define IWDG_SR_RVU (1U << IWDG_SR_RVU_BIT) -#define IWDG_SR_PVU (1U << IWDG_SR_PVU_BIT) - -/** - * @brief Independent watchdog prescalers. - * - * These divide the 40 kHz IWDG clock. - */ -typedef enum iwdg_prescaler { - IWDG_PRE_4 = IWDG_PR_DIV_4, /**< Divide by 4 */ - IWDG_PRE_8 = IWDG_PR_DIV_8, /**< Divide by 8 */ - IWDG_PRE_16 = IWDG_PR_DIV_16, /**< Divide by 16 */ - IWDG_PRE_32 = IWDG_PR_DIV_32, /**< Divide by 32 */ - IWDG_PRE_64 = IWDG_PR_DIV_64, /**< Divide by 64 */ - IWDG_PRE_128 = IWDG_PR_DIV_128, /**< Divide by 128 */ - IWDG_PRE_256 = IWDG_PR_DIV_256 /**< Divide by 256 */ -} iwdg_prescaler; - -void iwdg_init(iwdg_prescaler prescaler, uint16 reload); -void iwdg_feed(void); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/libmaple.h b/GD32F1/system/libmaple/include/libmaple/libmaple.h deleted file mode 100644 index c9034d7..0000000 --- a/GD32F1/system/libmaple/include/libmaple/libmaple.h +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/libmaple.h - * @brief General include file for libmaple - */ - -#ifndef _LIBMAPLE_LIBMAPLE_H_ -#define _LIBMAPLE_LIBMAPLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/libmaple_types.h b/GD32F1/system/libmaple/include/libmaple/libmaple_types.h deleted file mode 100644 index 882a910..0000000 --- a/GD32F1/system/libmaple/include/libmaple/libmaple_types.h +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/libmaple_types.h - * - * @brief libmaple's types, and operations on types. - */ - -#ifndef _LIBMAPLE_LIBMAPLE_TYPES_H_ -#define _LIBMAPLE_LIBMAPLE_TYPES_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef uint32_t uint32; -typedef unsigned long long uint64; - -typedef signed char int8; -typedef short int16; -typedef int int32; -typedef long long int64; - -typedef void (*voidFuncPtr)(void); -typedef void (*voidArgumentFuncPtr)(void *); - -#define __io volatile -#define __attr_flash __attribute__((section (".USER_FLASH"))) -#define __packed __attribute__((__packed__)) -#define __deprecated __attribute__((__deprecated__)) -#define __weak __attribute__((weak)) -#define __always_inline inline __attribute__((always_inline)) -#define __unused __attribute__((unused)) - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef offsetof -#define offsetof(type, member) __builtin_offsetof(type, member) -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/nvic.h b/GD32F1/system/libmaple/include/libmaple/nvic.h deleted file mode 100644 index 4642363..0000000 --- a/GD32F1/system/libmaple/include/libmaple/nvic.h +++ /dev/null @@ -1,157 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/nvic.h - * @brief Nested vectored interrupt controller support. - * - * Basic usage: - * - * @code - * // Initialise the interrupt controller and point to the vector - * // table at the start of flash. - * nvic_init(0x08000000, 0); - * // Bind in a timer interrupt handler - * timer_attach_interrupt(TIMER_CC1_INTERRUPT, handler); - * // Optionally set the priority - * nvic_irq_set_priority(NVIC_TIMER1_CC, 5); - * // All done, enable all interrupts - * nvic_globalirq_enable(); - * @endcode - */ - -#ifndef _LIBMAPLE_NVIC_H_ -#define _LIBMAPLE_NVIC_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include - -/** NVIC register map type. */ -typedef struct nvic_reg_map { - __io uint32 ISER[8]; /**< Interrupt Set Enable Registers */ - /** Reserved */ - uint32 RESERVED0[24]; - - __io uint32 ICER[8]; /**< Interrupt Clear Enable Registers */ - /** Reserved */ - uint32 RESERVED1[24]; - - __io uint32 ISPR[8]; /**< Interrupt Set Pending Registers */ - /** Reserved */ - uint32 RESERVED2[24]; - - __io uint32 ICPR[8]; /**< Interrupt Clear Pending Registers */ - /** Reserved */ - uint32 RESERVED3[24]; - - __io uint32 IABR[8]; /**< Interrupt Active bit Registers */ - /** Reserved */ - uint32 RESERVED4[56]; - - __io uint8 IP[240]; /**< Interrupt Priority Registers */ - /** Reserved */ - uint32 RESERVED5[644]; - - __io uint32 STIR; /**< Software Trigger Interrupt Registers */ -} nvic_reg_map; - -/** NVIC register map base pointer. */ -#define NVIC_BASE ((struct nvic_reg_map*)0xE000E100) - -/* - * Note: The series header must define enum nvic_irq_num, which gives - * descriptive names to the interrupts and exceptions from NMI (-14) - * to the largest interrupt available in the series, where the value - * for nonnegative enumerators corresponds to its position in the - * vector table. - * - * It also must define a static inline nvic_irq_disable_all(), which - * writes 0xFFFFFFFF to all ICE registers available in the series. (We - * place the include here to give the series header access to - * NVIC_BASE, in order to let it do so). - */ - -/* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/nvic.h" - -void nvic_init(uint32 address, uint32 offset); -void nvic_set_vector_table(uint32 address, uint32 offset); -void nvic_irq_set_priority(nvic_irq_num irqn, uint8 priority); -void nvic_sys_reset(); - -/** - * Enables interrupts and configurable fault handlers (clear PRIMASK). - */ -static __always_inline void nvic_globalirq_enable() { - asm volatile("cpsie i"); -} - -/** - * Disable interrupts and configurable fault handlers (set PRIMASK). - */ -static __always_inline void nvic_globalirq_disable() { - asm volatile("cpsid i"); -} - -/** - * @brief Enable interrupt irq_num - * @param irq_num Interrupt to enable - */ -static inline void nvic_irq_enable(nvic_irq_num irq_num) { - if (irq_num < 0) { - return; - } - NVIC_BASE->ISER[irq_num / 32] = BIT(irq_num % 32); -} - -/** - * @brief Disable interrupt irq_num - * @param irq_num Interrupt to disable - */ -static inline void nvic_irq_disable(nvic_irq_num irq_num) { - if (irq_num < 0) { - return; - } - NVIC_BASE->ICER[irq_num / 32] = BIT(irq_num % 32); -} - -/** - * @brief Quickly disable all interrupts. - * - * Calling this function is significantly faster than calling - * nvic_irq_disable() in a loop. - */ -static inline void nvic_irq_disable_all(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/pwr.h b/GD32F1/system/libmaple/include/libmaple/pwr.h deleted file mode 100644 index f711c7c..0000000 --- a/GD32F1/system/libmaple/include/libmaple/pwr.h +++ /dev/null @@ -1,117 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/pwr.h - * @brief Power control (PWR). - */ - -#ifndef _LIBMAPLE_PWR_H_ -#define _LIBMAPLE_PWR_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - /* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/pwr.h" - - -/** Power interface register map. */ -typedef struct pwr_reg_map { - __io uint32 CR; /**< Control register */ - __io uint32 CSR; /**< Control and status register */ -} pwr_reg_map; - -/** Power peripheral register map base pointer. */ -#define PWR_BASE ((struct pwr_reg_map*)0x40007000) - -/* - * Register bit definitions - */ - -/* Control register */ - -/** Disable backup domain write protection bit */ -#define PWR_CR_DBP_BIT 8 -/** Power voltage detector enable bit */ -#define PWR_CR_PVDE_BIT 4 -/** Clear standby flag bit */ -#define PWR_CR_CSBF_BIT 3 -/** Clear wakeup flag bit */ -#define PWR_CR_CWUF_BIT 2 -/** Power down deepsleep bit */ -#define PWR_CR_PDDS_BIT 1 -/** Low-power deepsleep bit */ -#define PWR_CR_LPDS_BIT 0 - -/** Disable backup domain write protection */ -#define PWR_CR_DBP (1U << PWR_CR_DBP_BIT) -/** Power voltage detector (PVD) level selection */ -#define PWR_CR_PLS (0x7 << 5) -/** Power voltage detector enable */ -#define PWR_CR_PVDE (1U << PWR_CR_PVDE_BIT) -/** Clear standby flag */ -#define PWR_CR_CSBF (1U << PWR_CR_CSBF_BIT) -/** Clear wakeup flag */ -#define PWR_CR_CWUF (1U << PWR_CR_CWUF_BIT) -/** Power down deepsleep */ -#define PWR_CR_PDDS (1U << PWR_CR_PDDS_BIT) -/** Low-power deepsleep */ -#define PWR_CR_LPDS (1U << PWR_CR_LPDS_BIT) - -/* Control and status register */ - -/** Enable wakeup pin bit */ -#define PWR_CSR_EWUP_BIT 8 -/** PVD output bit */ -#define PWR_CSR_PVDO_BIT 2 -/** Standby flag bit */ -#define PWR_CSR_SBF_BIT 1 -/** Wakeup flag bit */ -#define PWR_CSR_WUF_BIT 0 - -/** Enable wakeup pin */ -#define PWR_CSR_EWUP (1U << PWR_CSR_EWUP_BIT) -/** PVD output */ -#define PWR_CSR_PVDO (1U << PWR_CSR_PVDO_BIT) -/** Standby flag */ -#define PWR_CSR_SBF (1U << PWR_CSR_SBF_BIT) -/** Wakeup flag */ -#define PWR_CSR_WUF (1U << PWR_CSR_WUF_BIT) - -/* - * Convenience functions - */ - -void pwr_init(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/rcc.h b/GD32F1/system/libmaple/include/libmaple/rcc.h deleted file mode 100644 index 27d48fb..0000000 --- a/GD32F1/system/libmaple/include/libmaple/rcc.h +++ /dev/null @@ -1,182 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/rcc.h - * @brief Reset and Clock Control (RCC) interface. - */ - -#ifndef _LIBMAPLE_RCC_H_ -#define _LIBMAPLE_RCC_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -/* Put the SYSCLK sources before the series header is included, as it - * might need them. */ -/** - * @brief SYSCLK sources - * @see rcc_switch_sysclk() - */ -typedef enum rcc_sysclk_src { - RCC_CLKSRC_HSI = 0x0, - RCC_CLKSRC_HSE = 0x1, - RCC_CLKSRC_PLL = 0x2, -} rcc_sysclk_src; - -/* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/rcc.h" - -/* Note: Beyond the usual (registers, etc.), it's up to the series - * header to define the following types: - * - * - enum rcc_clk: Available system and secondary clock sources, - * e.g. RCC_CLK_HSE, RCC_CLK_PLL, RCC_CLK_LSE. - * - * Note that the inclusion of secondary clock sources (like LSI and - * LSE) makes enum rcc_clk different from the SYSCLK sources, which - * are defined in this header as enum rcc_sysclk_src. - * - * IMPORTANT NOTE TO IMPLEMENTORS: If you are adding support for a - * new STM32 series, see the comment near rcc_clk_reg() in - * libmaple/rcc.c for information on how to choose these values so - * that rcc_turn_on_clk() etc. will work on your series. - * - * - enum rcc_clk_id: For each available peripheral. These are widely used - * as unique IDs (TODO extricate from RCC?). Peripherals which are - * common across STM32 series should use the same token for their - * rcc_clk_id in each series header. - * - * - enum rcc_clk_domain: For each clock domain. This is returned by - * rcc_dev_clk(). For instance, each AHB and APB is a clock domain. - * - * - enum rcc_prescaler: And a suitable set of dividers for - * rcc_set_prescaler(). - * - * - enum rcc_pllsrc: For each PLL source. Same source, same token. - * - * - A target-dependent type to be pointed to by the data field in a - * struct rcc_pll_cfg. - */ - -#ifdef __DOXYGEN__ -/** RCC register map base pointer */ -#define RCC_BASE -#endif - -/* Clock prescaler management. */ - -/** - * @brief Set the divider on a peripheral prescaler - * @param prescaler prescaler to set - * @param divider prescaler divider - */ -extern void rcc_set_prescaler(rcc_prescaler prescaler, uint32 divider); - -/* SYSCLK. */ - -void rcc_switch_sysclk(rcc_sysclk_src sysclk_src); - -/* PLL configuration */ - -/** - * @brief Specifies a configuration for the main PLL. - */ -typedef struct rcc_pll_cfg { - rcc_pllsrc pllsrc; /**< PLL source */ - - /** Series-specific configuration data. */ - void *data; -} rcc_pll_cfg; - -/** - * @brief Configure the main PLL. - * - * You may only call this function while the PLL is disabled. - * - * @param pll_cfg Desired PLL configuration. The contents of this - * struct depend entirely on the target. - */ -extern void rcc_configure_pll(rcc_pll_cfg *pll_cfg); - -/* System and secondary clock sources. */ - -void rcc_turn_on_clk(rcc_clk clock); -void rcc_turn_off_clk(rcc_clk clock); -int rcc_is_clk_on(rcc_clk clock); -int rcc_is_clk_ready(rcc_clk clock); - -/* Peripheral clock lines and clock domains. */ - -/** - * @brief Turn on the clock line on a peripheral - * @param id Clock ID of the peripheral to turn on. - */ -extern void rcc_clk_enable(rcc_clk_id id); - -/** - * @brief Reset a peripheral. - * - * Caution: not all rcc_clk_id values refer to a peripheral which can - * be reset. (Only rcc_clk_ids for peripherals with bits in an RCC - * reset register can be used here.) - * - * @param id Clock ID of the peripheral to reset. - */ -extern void rcc_reset_dev(rcc_clk_id id); - -rcc_clk_domain rcc_dev_clk(rcc_clk_id id); - -/* Clock security system */ - -/** - * @brief Enable the clock security system (CSS). - */ -static inline void rcc_enable_css() { - RCC_BASE->CR |= RCC_CR_CSSON; -} - -/** - * @brief Disable the clock security system (CSS). - */ -static inline void rcc_disable_css() { - RCC_BASE->CR &= ~RCC_CR_CSSON; -} - -/** - * @brief Turn off the clock line on a peripheral - * @param id Clock ID of the peripheral to turn on. - */ -extern void rcc_clk_disable(rcc_clk_id id); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/ring_buffer.h b/GD32F1/system/libmaple/include/libmaple/ring_buffer.h deleted file mode 100644 index eb38634..0000000 --- a/GD32F1/system/libmaple/include/libmaple/ring_buffer.h +++ /dev/null @@ -1,208 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/ring_buffer.h - * @brief Simple circular buffer - * - * This implementation is not thread-safe. In particular, none of - * these functions is guaranteed re-entrant. - */ - -#ifndef _LIBMAPLE_RING_BUFFER_H_ -#define _LIBMAPLE_RING_BUFFER_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -/** - * Ring buffer type. - * - * The buffer is empty when head == tail. - * - * The buffer is full when the head is one byte in front of the tail, - * modulo buffer length. - * - * One byte is left free to distinguish empty from full. */ -typedef struct ring_buffer { - volatile uint8 *buf; /**< Buffer items are stored into */ - uint16 head; /**< Index of the next item to remove */ - uint16 tail; /**< Index where the next item will get inserted */ - uint16 size; /**< Buffer capacity minus one */ -} ring_buffer; - -/** - * Initialise a ring buffer. - * - * @param rb Instance to initialise - * - * @param size Number of items in buf. The ring buffer will always - * leave one element unoccupied, so the maximum number of - * elements it can store will be size - 1. Thus, size - * must be at least 2. - * - * @param buf Buffer to store items into - */ -static inline void rb_init(ring_buffer *rb, uint16 size, uint8 *buf) { - rb->head = 0; - rb->tail = 0; - rb->size = size - 1; - rb->buf = buf; -} - -/** - * @brief Return the number of elements stored in the ring buffer. - * @param rb Buffer whose elements to count. - */ -static inline uint16 rb_full_count(ring_buffer *rb) { - __io ring_buffer *arb = rb; - int32 size = arb->tail - arb->head; - if (arb->tail < arb->head) { - size += arb->size + 1; - } - return (uint16)size; -} - -/** - * @brief Returns true if and only if the ring buffer is full. - * @param rb Buffer to test. - */ -static inline int rb_is_full(ring_buffer *rb) { - return (rb->tail + 1 == rb->head) || - (rb->tail == rb->size && rb->head == 0); -} - -/** - * @brief Returns true if and only if the ring buffer is empty. - * @param rb Buffer to test. - */ -static inline int rb_is_empty(ring_buffer *rb) { - return rb->head == rb->tail; -} - -/** - * Append element onto the end of a ring buffer. - * @param rb Buffer to append onto. - * @param element Value to append. - */ -static inline void rb_insert(ring_buffer *rb, uint8 element) { - rb->buf[rb->tail] = element; - rb->tail = (rb->tail == rb->size) ? 0 : rb->tail + 1; -} - -/** - * @brief Remove and return the first item from a ring buffer. - * @param rb Buffer to remove from, must contain at least one element. - */ -static inline uint8 rb_remove(ring_buffer *rb) { - uint8 ch = rb->buf[rb->head]; - rb->head = (rb->head == rb->size) ? 0 : rb->head + 1; - return ch; -} - -/* - * Roger Clark. 20141125, - * added peek function. - * @brief Return the first item from a ring buffer, without removing it - * @param rb Buffer to remove from, must contain at least one element. - */ - -static inline int rb_peek(ring_buffer *rb) -{ - if (rb->head == rb->tail) - { - return -1; - } - else - { - return rb->buf[rb->head]; - } -} - - -/** - * @brief Attempt to remove the first item from a ring buffer. - * - * If the ring buffer is nonempty, removes and returns its first item. - * If it is empty, does nothing and returns a negative value. - * - * @param rb Buffer to attempt to remove from. - */ -static inline int16 rb_safe_remove(ring_buffer *rb) { - return rb_is_empty(rb) ? -1 : rb_remove(rb); -} - -/** - * @brief Attempt to insert an element into a ring buffer. - * - * @param rb Buffer to insert into. - * @param element Value to insert into rb. - * @sideeffect If rb is not full, appends element onto buffer. - * @return If element was appended, then true; otherwise, false. */ -static inline int rb_safe_insert(ring_buffer *rb, uint8 element) { - if (rb_is_full(rb)) { - return 0; - } - rb_insert(rb, element); - return 1; -} - -/** - * @brief Append an item onto the end of a non-full ring buffer. - * - * If the buffer is full, removes its first item, then inserts the new - * element at the end. - * - * @param rb Ring buffer to insert into. - * @param element Value to insert into ring buffer. - * @return On success, returns -1. If an element was popped, returns - * the popped value. - */ -static inline int rb_push_insert(ring_buffer *rb, uint8 element) { - int ret = -1; - if (rb_is_full(rb)) { - ret = rb_remove(rb); - } - rb_insert(rb, element); - return ret; -} - -/** - * @brief Discard all items from a ring buffer. - * @param rb Ring buffer to discard all items from. - */ -static inline void rb_reset(ring_buffer *rb) { - rb->tail = rb->head; -} - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/scb.h b/GD32F1/system/libmaple/include/libmaple/scb.h deleted file mode 100644 index c42a0f2..0000000 --- a/GD32F1/system/libmaple/include/libmaple/scb.h +++ /dev/null @@ -1,214 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011-2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/scb.h - * @brief System control block header - */ - -/* - * FIXME: STM32F2? - */ - -#ifndef _LIBMAPLE_SCB_H_ -#define _LIBMAPLE_SCB_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* - * Register map and base pointer - */ - -/** System control block register map type */ -typedef struct scb_reg_map { - __io uint32 CPUID; /**< CPU ID Base Register */ - __io uint32 ICSR; /**< Interrupt Control State Register */ - __io uint32 VTOR; /**< Vector Table Offset Register */ - __io uint32 AIRCR; /**< Application Interrupt / Reset Control Register */ - __io uint32 SCR; /**< System Control Register */ - __io uint32 CCR; /**< Configuration and Control Register */ - __io uint8 SHP[12]; /**< System Handler Priority Registers - (4-7, 8-11, 12-15) */ - __io uint32 SHCSR; /**< System Handler Control and State Register */ - __io uint32 CFSR; /**< Configurable Fault Status Register */ - __io uint32 HFSR; /**< Hard Fault Status Register */ - /* DFSR is not documented by ST in PM0056 (as of Revision 4), but - * there's a 4 byte hole in the SCB register map docs right where - * it belongs. Since it's specified as "always implemented" in - * the ARM v7-M ARM, I'm assuming its absence is a bug in the ST - * doc, but I haven't proven it. [mbolivar] */ - __io uint32 DFSR; /**< Debug Fault Status Register */ - __io uint32 MMFAR; /**< Mem Manage Address Register */ - __io uint32 BFAR; /**< Bus Fault Address Register */ -#if 0 - /* The following registers are implementation-defined according to - * ARM v7-M, and I can't find evidence of their existence in ST's - * docs. I'm removing them. Feel free to yell at me if they do - * exist. [mbolivar] - */ - __io uint32 AFSR; /**< Auxiliary Fault Status Register */ - __io uint32 PFR[2]; /**< Processor Feature Register */ - __io uint32 DFR; /**< Debug Feature Register */ - __io uint32 AFR; /**< Auxiliary Feature Register */ - __io uint32 MMFR[4]; /**< Memory Model Feature Register */ - __io uint32 ISAR[5]; /**< ISA Feature Register */ -#endif -} scb_reg_map; - -/** System control block register map base pointer */ -#define SCB_BASE ((struct scb_reg_map*)0xE000ED00) - -/* - * Register bit definitions - */ - -/* No SCB_REG_FIELD_BIT macros as the relevant addresses are not in a - * bit-band region. */ - -/* CPUID base register (SCB_CPUID) */ - -#define SCB_CPUID_IMPLEMENTER (0xFF << 24) -#define SCB_CPUID_VARIANT (0xF << 20) -#define SCB_CPUID_CONSTANT (0xF << 16) -#define SCB_CPUID_PARTNO (0xFFF << 4) -#define SCB_CPUID_REVISION 0xF - -/* Interrupt control state register (SCB_ICSR) */ - -#define SCB_ICSR_NMIPENDSET (1U << 31) -#define SCB_ICSR_PENDSVSET (1U << 28) -#define SCB_ICSR_PENDSVCLR (1U << 27) -#define SCB_ICSR_PENDSTSET (1U << 26) -#define SCB_ICSR_PENDSTCLR (1U << 25) -#define SCB_ICSR_ISRPENDING (1U << 22) -#define SCB_ICSR_VECTPENDING (0x3FF << 12) -#define SCB_ICSR_RETOBASE (1U << 11) -#define SCB_ICSR_VECTACTIVE 0xFF - -/* Vector table offset register (SCB_VTOR) */ - -#define SCB_VTOR_TBLOFF (0x1FFFFF << 9) - -/* Application interrupt and reset control register (SCB_AIRCR) */ - -#define SCB_AIRCR_VECTKEYSTAT (0x5FA << 16) -#define SCB_AIRCR_VECTKEY (0x5FA << 16) -#define SCB_AIRCR_ENDIANNESS (1U << 15) -#define SCB_AIRCR_PRIGROUP (0x3 << 8) -#define SCB_AIRCR_SYSRESETREQ (1U << 2) -#define SCB_AIRCR_VECTCLRACTIVE (1U << 1) -#define SCB_AIRCR_VECTRESET (1U << 0) - -/* System control register (SCB_SCR) */ - -#define SCB_SCR_SEVONPEND (1U << 4) -#define SCB_SCR_SLEEPDEEP (1U << 2) -#define SCB_SCR_SLEEPONEXIT (1U << 1) - -/* Configuration and Control Register (SCB_CCR) */ - -#define SCB_CCR_STKALIGN (1U << 9) -#define SCB_CCR_BFHFNMIGN (1U << 8) -#define SCB_CCR_DIV_0_TRP (1U << 4) -#define SCB_CCR_UNALIGN_TRP (1U << 3) -#define SCB_CCR_USERSETMPEND (1U << 1) -#define SCB_CCR_NONBASETHRDENA (1U << 0) - -/* System handler priority registers (SCB_SHPRx) */ - -#define SCB_SHPR1_PRI6 (0xFF << 16) -#define SCB_SHPR1_PRI5 (0xFF << 8) -#define SCB_SHPR1_PRI4 0xFF - -#define SCB_SHPR2_PRI11 (0xFF << 24) - -#define SCB_SHPR3_PRI15 (0xFF << 24) -#define SCB_SHPR3_PRI14 (0xFF << 16) - -/* System Handler Control and state register (SCB_SHCSR) */ - -#define SCB_SHCSR_USGFAULTENA (1U << 18) -#define SCB_SHCSR_BUSFAULTENA (1U << 17) -#define SCB_SHCSR_MEMFAULTENA (1U << 16) -#define SCB_SHCSR_SVCALLPENDED (1U << 15) -#define SCB_SHCSR_BUSFAULTPENDED (1U << 14) -#define SCB_SHCSR_MEMFAULTPENDED (1U << 13) -#define SCB_SHCSR_USGFAULTPENDED (1U << 12) -#define SCB_SHCSR_SYSTICKACT (1U << 11) -#define SCB_SHCSR_PENDSVACT (1U << 10) -#define SCB_SHCSR_MONITORACT (1U << 8) -#define SCB_SHCSR_SVCALLACT (1U << 7) -#define SCB_SHCSR_USGFAULTACT (1U << 3) -#define SCB_SHCSR_BUSFAULTACT (1U << 1) -#define SCB_SHCSR_MEMFAULTACT (1U << 0) - -/* Configurable fault status register (SCB_CFSR) */ - -#define SCB_CFSR_DIVBYZERO (1U << 25) -#define SCB_CFSR_UNALIGNED (1U << 24) -#define SCB_CFSR_NOCP (1U << 19) -#define SCB_CFSR_INVPC (1U << 18) -#define SCB_CFSR_INVSTATE (1U << 17) -#define SCB_CFSR_UNDEFINSTR (1U << 16) -#define SCB_CFSR_BFARVALID (1U << 15) -#define SCB_CFSR_STKERR (1U << 12) -#define SCB_CFSR_UNSTKERR (1U << 11) -#define SCB_CFSR_IMPRECISERR (1U << 10) -#define SCB_CFSR_PRECISERR (1U << 9) -#define SCB_CFSR_IBUSERR (1U << 8) -#define SCB_CFSR_MMARVALID (1U << 7) -#define SCB_CFSR_MSTKERR (1U << 4) -#define SCB_CFSR_MUNSTKERR (1U << 3) -#define SCB_CFSR_DACCVIOL (1U << 1) -#define SCB_CFSR_IACCVIOL (1U << 0) - -/* Hard Fault Status Register (SCB_HFSR) */ - -#define SCB_HFSR_DEBUG_VT (1U << 31) -#define SCB_CFSR_FORCED (1U << 30) -#define SCB_CFSR_VECTTBL (1U << 1) - -/* Debug Fault Status Register */ - -/* Not specified by PM0056, but required by ARM. The bit definitions - * here are based on the names given in the ARM v7-M ARM. */ - -#define SCB_DFSR_EXTERNAL (1U << 4) -#define SCB_DFSR_VCATCH (1U << 3) -#define SCB_DFSR_DWTTRAP (1U << 2) -#define SCB_DFSR_BKPT (1U << 1) -#define SCB_DFSR_HALTED (1U << 0) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/spi.h b/GD32F1/system/libmaple/include/libmaple/spi.h deleted file mode 100644 index 0da4129..0000000 --- a/GD32F1/system/libmaple/include/libmaple/spi.h +++ /dev/null @@ -1,472 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/spi.h - * @author Marti Bolivar - * @brief Serial Peripheral Interface (SPI) and Integrated - * Interchip Sound (I2S) peripheral support. - * - * I2S support is currently limited to register maps and bit definitions. - */ - -#ifndef _LIBMAPLE_SPI_H_ -#define _LIBMAPLE_SPI_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - /* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/spi.h" - - -/* - * Register maps - */ - -/** SPI register map type. */ -typedef struct spi_reg_map { - __io uint32 CR1; /**< Control register 1 */ - __io uint32 CR2; /**< Control register 2 */ - __io uint32 SR; /**< Status register */ - __io uint32 DR; /**< Data register */ - __io uint32 CRCPR; /**< CRC polynomial register */ - __io uint32 RXCRCR; /**< RX CRC register */ - __io uint32 TXCRCR; /**< TX CRC register */ - __io uint32 I2SCFGR; /**< I2S configuration register */ - __io uint32 I2SPR; /**< I2S prescaler register */ -} spi_reg_map; - -/* - * Register bit definitions - */ - -/* Control register 1 */ - -#define SPI_CR1_BIDIMODE_BIT 15 -#define SPI_CR1_BIDIOE_BIT 14 -#define SPI_CR1_CRCEN_BIT 13 -#define SPI_CR1_CRCNEXT_BIT 12 -#define SPI_CR1_DFF_BIT 11 -#define SPI_CR1_RXONLY_BIT 10 -#define SPI_CR1_SSM_BIT 9 -#define SPI_CR1_SSI_BIT 8 -#define SPI_CR1_LSBFIRST_BIT 7 -#define SPI_CR1_SPE_BIT 6 -#define SPI_CR1_MSTR_BIT 2 -#define SPI_CR1_CPOL_BIT 1 -#define SPI_CR1_CPHA_BIT 0 - -#define SPI_CR1_BIDIMODE (1U << SPI_CR1_BIDIMODE_BIT) -#define SPI_CR1_BIDIMODE_2_LINE (0x0 << SPI_CR1_BIDIMODE_BIT) -#define SPI_CR1_BIDIMODE_1_LINE (0x1 << SPI_CR1_BIDIMODE_BIT) -#define SPI_CR1_BIDIOE (1U << SPI_CR1_BIDIOE_BIT) -#define SPI_CR1_CRCEN (1U << SPI_CR1_CRCEN_BIT) -#define SPI_CR1_CRCNEXT (1U << SPI_CR1_CRCNEXT_BIT) -#define SPI_CR1_DFF (1U << SPI_CR1_DFF_BIT) -#define SPI_CR1_DFF_8_BIT (0x0 << SPI_CR1_DFF_BIT) -#define SPI_CR1_DFF_16_BIT (0x1 << SPI_CR1_DFF_BIT) -#define SPI_CR1_RXONLY (1U << SPI_CR1_RXONLY_BIT) -#define SPI_CR1_SSM (1U << SPI_CR1_SSM_BIT) -#define SPI_CR1_SSI (1U << SPI_CR1_SSI_BIT) -#define SPI_CR1_LSBFIRST (1U << SPI_CR1_LSBFIRST_BIT) -#define SPI_CR1_SPE (1U << SPI_CR1_SPE_BIT) -#define SPI_CR1_BR (0x7 << 3) -#define SPI_CR1_BR_PCLK_DIV_2 (0x0 << 3) -#define SPI_CR1_BR_PCLK_DIV_4 (0x1 << 3) -#define SPI_CR1_BR_PCLK_DIV_8 (0x2 << 3) -#define SPI_CR1_BR_PCLK_DIV_16 (0x3 << 3) -#define SPI_CR1_BR_PCLK_DIV_32 (0x4 << 3) -#define SPI_CR1_BR_PCLK_DIV_64 (0x5 << 3) -#define SPI_CR1_BR_PCLK_DIV_128 (0x6 << 3) -#define SPI_CR1_BR_PCLK_DIV_256 (0x7 << 3) -#define SPI_CR1_MSTR (1U << SPI_CR1_MSTR_BIT) -#define SPI_CR1_CPOL (1U << SPI_CR1_CPOL_BIT) -#define SPI_CR1_CPOL_LOW (0x0 << SPI_CR1_CPOL_BIT) -#define SPI_CR1_CPOL_HIGH (0x1 << SPI_CR1_CPOL_BIT) -#define SPI_CR1_CPHA (1U << SPI_CR1_CPHA_BIT) - -/* Control register 2 */ - -#define SPI_CR2_TXEIE_BIT 7 -#define SPI_CR2_RXNEIE_BIT 6 -#define SPI_CR2_ERRIE_BIT 5 -#define SPI_CR2_SSOE_BIT 2 -#define SPI_CR2_TXDMAEN_BIT 1 -#define SPI_CR2_RXDMAEN_BIT 0 - -#define SPI_CR2_TXEIE (1U << SPI_CR2_TXEIE_BIT) -#define SPI_CR2_RXNEIE (1U << SPI_CR2_RXNEIE_BIT) -#define SPI_CR2_ERRIE (1U << SPI_CR2_ERRIE_BIT) -#define SPI_CR2_SSOE (1U << SPI_CR2_SSOE_BIT) -#define SPI_CR2_TXDMAEN (1U << SPI_CR2_TXDMAEN_BIT) -#define SPI_CR2_RXDMAEN (1U << SPI_CR2_RXDMAEN_BIT) - -/* Status register */ - -#define SPI_SR_BSY_BIT 7 -#define SPI_SR_OVR_BIT 6 -#define SPI_SR_MODF_BIT 5 -#define SPI_SR_CRCERR_BIT 4 -#define SPI_SR_UDR_BIT 3 -#define SPI_SR_CHSIDE_BIT 2 -#define SPI_SR_TXE_BIT 1 -#define SPI_SR_RXNE_BIT 0 - -#define SPI_SR_BSY (1U << SPI_SR_BSY_BIT) -#define SPI_SR_OVR (1U << SPI_SR_OVR_BIT) -#define SPI_SR_MODF (1U << SPI_SR_MODF_BIT) -#define SPI_SR_CRCERR (1U << SPI_SR_CRCERR_BIT) -#define SPI_SR_UDR (1U << SPI_SR_UDR_BIT) -#define SPI_SR_CHSIDE (1U << SPI_SR_CHSIDE_BIT) -#define SPI_SR_CHSIDE_LEFT (0x0 << SPI_SR_CHSIDE_BIT) -#define SPI_SR_CHSIDE_RIGHT (0x1 << SPI_SR_CHSIDE_BIT) -#define SPI_SR_TXE (1U << SPI_SR_TXE_BIT) -#define SPI_SR_RXNE (1U << SPI_SR_RXNE_BIT) - -/* I2S configuration register */ - -#define SPI_I2SCFGR_I2SMOD_BIT 11 -#define SPI_I2SCFGR_I2SE_BIT 10 -#define SPI_I2SCFGR_PCMSYNC_BIT 7 -#define SPI_I2SCFGR_CKPOL_BIT 3 -#define SPI_I2SCFGR_CHLEN_BIT 0 - -#define SPI_I2SCFGR_I2SMOD (1U << SPI_I2SCFGR_I2SMOD_BIT) -#define SPI_I2SCFGR_I2SMOD_SPI (0x0 << SPI_I2SCFGR_I2SMOD_BIT) -#define SPI_I2SCFGR_I2SMOD_I2S (0x1 << SPI_I2SCFGR_I2SMOD_BIT) -#define SPI_I2SCFGR_I2SE (1U << SPI_I2SCFGR_I2SE_BIT) -#define SPI_I2SCFGR_I2SCFG (0x3 << 8) -#define SPI_I2SCFGR_I2SCFG_SLAVE_TX (0x0 << 8) -#define SPI_I2SCFGR_I2SCFG_SLAVE_RX (0x1 << 8) -#define SPI_I2SCFGR_I2SCFG_MASTER_TX (0x2 << 8) -#define SPI_I2SCFGR_I2SCFG_MASTER_RX (0x3 << 8) -#define SPI_I2SCFGR_PCMSYNC (1U << SPI_I2SCFGR_PCMSYNC_BIT) -#define SPI_I2SCFGR_PCMSYNC_SHORT (0x0 << SPI_I2SCFGR_PCMSYNC_BIT) -#define SPI_I2SCFGR_PCMSYNC_LONG (0x1 << SPI_I2SCFGR_PCMSYNC_BIT) -#define SPI_I2SCFGR_I2SSTD (0x3 << 4) -#define SPI_I2SCFGR_I2SSTD_PHILLIPS (0x0 << 4) -#define SPI_I2SCFGR_I2SSTD_MSB (0x1 << 4) -#define SPI_I2SCFGR_I2SSTD_LSB (0x2 << 4) -#define SPI_I2SCFGR_I2SSTD_PCM (0x3 << 4) -#define SPI_I2SCFGR_CKPOL (1U << SPI_I2SCFGR_CKPOL_BIT) -#define SPI_I2SCFGR_CKPOL_LOW (0x0 << SPI_I2SCFGR_CKPOL_BIT) -#define SPI_I2SCFGR_CKPOL_HIGH (0x1 << SPI_I2SCFGR_CKPOL_BIT) -#define SPI_I2SCFGR_DATLEN (0x3 << 1) -#define SPI_I2SCFGR_DATLEN_16_BIT (0x0 << 1) -#define SPI_I2SCFGR_DATLEN_24_BIT (0x1 << 1) -#define SPI_I2SCFGR_DATLEN_32_BIT (0x2 << 1) -#define SPI_I2SCFGR_CHLEN (1U << SPI_I2SCFGR_CHLEN_BIT) -#define SPI_I2SCFGR_CHLEN_16_BIT (0x0 << SPI_I2SCFGR_CHLEN_BIT) -#define SPI_I2SCFGR_CHLEN_32_BIT (0x1 << SPI_I2SCFGR_CHLEN_BIT) - -/* I2S prescaler register */ - -#define SPI_I2SPR_MCKOE_BIT 9 -#define SPI_I2SPR_ODD_BIT 8 - -#define SPI_I2SPR_MCKOE (1U << SPI_I2SPR_MCKOE_BIT) -#define SPI_I2SPR_ODD (1U << SPI_I2SPR_ODD_BIT) -#define SPI_I2SPR_I2SDIV 0xFF - -/* - * Devices - */ - -/** SPI device type */ -typedef struct spi_dev { - spi_reg_map *regs; /**< Register map */ - rcc_clk_id clk_id; /**< RCC clock information */ - nvic_irq_num irq_num; /**< NVIC interrupt number */ -} spi_dev; - -/* - * SPI Convenience functions - */ - -void spi_init(spi_dev *dev); - -struct gpio_dev; -/** - * @brief Configure GPIO bit modes for use as a SPI port's pins. - * - * @param dev SPI device - * @param as_master If true, configure as bus master; otherwise, as slave. - * @param nss_dev NSS pin's GPIO device - * @param nss_bit NSS pin's GPIO bit on nss_dev - * @param comm_dev SCK, MISO, MOSI pins' GPIO device - * @param sck_bit SCK pin's GPIO bit on comm_dev - * @param miso_bit MISO pin's GPIO bit on comm_dev - * @param mosi_bit MOSI pin's GPIO bit on comm_dev - */ -extern void spi_config_gpios(spi_dev *dev, - uint8 as_master, - struct gpio_dev *nss_dev, - uint8 nss_bit, - struct gpio_dev *comm_dev, - uint8 sck_bit, - uint8 miso_bit, - uint8 mosi_bit); - -/** - * @brief SPI mode configuration. - * - * A SPI mode determines a combination of the idle state of the clock - * line (the clock polarity, or "CPOL"), and which clock edge triggers - * data capture (the clock phase, or "CPHA"). - */ -typedef enum spi_mode { - /** Clock idles low, data captured on rising edge (first transition) */ - SPI_MODE_LOW_RISING = 0, - /** Clock idles low, data captured on falling edge (second transition) */ - SPI_MODE_LOW_FALLING = 1, - /** Clock idles high, data captured on falling edge (first transition) */ - SPI_MODE_HIGH_FALLING = 2, - /** Clock idles high, data captured on rising edge (second transition) */ - SPI_MODE_HIGH_RISING = 3, - - SPI_MODE_0 = SPI_MODE_LOW_RISING, /**< Same as SPI_MODE_LOW_RISING */ - SPI_MODE_1 = SPI_MODE_LOW_FALLING, /**< Same as SPI_MODE_LOW_FALLING */ - SPI_MODE_2 = SPI_MODE_HIGH_FALLING, /**< Same as SPI_MODE_HIGH_FALLING */ - SPI_MODE_3 = SPI_MODE_HIGH_RISING, /**< Same as SPI_MODE_HIGH_RISING */ -} spi_mode; - -/** - * @brief SPI baud rate configuration, as a divisor of f_PCLK, the - * PCLK clock frequency. - */ -typedef enum spi_baud_rate { - SPI_BAUD_PCLK_DIV_2 = SPI_CR1_BR_PCLK_DIV_2, /**< f_PCLK/2 */ - SPI_BAUD_PCLK_DIV_4 = SPI_CR1_BR_PCLK_DIV_4, /**< f_PCLK/4 */ - SPI_BAUD_PCLK_DIV_8 = SPI_CR1_BR_PCLK_DIV_8, /**< f_PCLK/8 */ - SPI_BAUD_PCLK_DIV_16 = SPI_CR1_BR_PCLK_DIV_16, /**< f_PCLK/16 */ - SPI_BAUD_PCLK_DIV_32 = SPI_CR1_BR_PCLK_DIV_32, /**< f_PCLK/32 */ - SPI_BAUD_PCLK_DIV_64 = SPI_CR1_BR_PCLK_DIV_64, /**< f_PCLK/64 */ - SPI_BAUD_PCLK_DIV_128 = SPI_CR1_BR_PCLK_DIV_128, /**< f_PCLK/128 */ - SPI_BAUD_PCLK_DIV_256 = SPI_CR1_BR_PCLK_DIV_256, /**< f_PCLK/256 */ -} spi_baud_rate; - -/** - * @brief SPI initialization flags. - * @see spi_master_enable() - * @see spi_slave_enable() - */ -typedef enum spi_cfg_flag { - SPI_BIDIMODE = SPI_CR1_BIDIMODE, /**< Bidirectional mode enable */ - SPI_BIDIOE = SPI_CR1_BIDIOE, /**< Output enable in bidirectional - mode */ - SPI_CRCEN = SPI_CR1_CRCEN, /**< Cyclic redundancy check (CRC) - enable */ - SPI_DFF_8_BIT = SPI_CR1_DFF_8_BIT, /**< 8-bit data frame format (this is - the default) */ - SPI_DFF_16_BIT = SPI_CR1_DFF_16_BIT, /**< 16-bit data frame format */ - SPI_RX_ONLY = SPI_CR1_RXONLY, /**< Receive only */ - SPI_SW_SLAVE = SPI_CR1_SSM, /**< Software slave management */ - SPI_SOFT_SS = SPI_CR1_SSI, /**< Software (internal) slave - select. This flag only has an - effect when used in combination - with SPI_SW_SLAVE. */ - SPI_FRAME_LSB = SPI_CR1_LSBFIRST, /**< LSB-first (little-endian) frame - format */ - SPI_FRAME_MSB = 0, /**< MSB-first (big-endian) frame - format (this is the default) */ -} spi_cfg_flag; - -void spi_master_enable(spi_dev *dev, - spi_baud_rate baud, - spi_mode mode, - uint32 flags); - -void spi_slave_enable(spi_dev *dev, - spi_mode mode, - uint32 flags); - -uint32 spi_tx(spi_dev *dev, const void *buf, uint32 len); - -/** - * @brief Call a function on each SPI port - * @param fn Function to call. - */ -extern void spi_foreach(void (*fn)(spi_dev*)); - -void spi_peripheral_enable(spi_dev *dev); -void spi_peripheral_disable(spi_dev *dev); - -void spi_tx_dma_enable(spi_dev *dev); -void spi_tx_dma_disable(spi_dev *dev); - -void spi_rx_dma_enable(spi_dev *dev); -void spi_rx_dma_disable(spi_dev *dev); - -/** - * @brief Determine if a SPI peripheral is enabled. - * @param dev SPI device - * @return True, if and only if dev's peripheral is enabled. - */ -static inline uint8 spi_is_enabled(spi_dev *dev) { - return dev->regs->CR1 & SPI_CR1_SPE_BIT; -} - -/** - * @brief Disable all SPI peripherals - */ -static inline void spi_peripheral_disable_all(void) { - spi_foreach(spi_peripheral_disable); -} - -/** Available SPI interrupts */ -typedef enum spi_interrupt { - SPI_TXE_INTERRUPT = SPI_CR2_TXEIE, /**< TX buffer empty interrupt */ - SPI_RXNE_INTERRUPT = SPI_CR2_RXNEIE, /**< RX buffer not empty interrupt */ - SPI_ERR_INTERRUPT = SPI_CR2_ERRIE /**< - * Error interrupt (CRC, overrun, - * and mode fault errors for SPI; - * underrun, overrun errors for I2S) - */ -} spi_interrupt; - -/** - * @brief Mask for all spi_interrupt values - * @see spi_interrupt - */ -#define SPI_INTERRUPTS_ALL (SPI_TXE_INTERRUPT | \ - SPI_RXNE_INTERRUPT | \ - SPI_ERR_INTERRUPT) - -/** - * @brief Enable SPI interrupt requests - * @param dev SPI device - * @param interrupt_flags Bitwise OR of spi_interrupt values to enable - * @see spi_interrupt - */ -static inline void spi_irq_enable(spi_dev *dev, uint32 interrupt_flags) { - dev->regs->CR2 |= interrupt_flags; - nvic_irq_enable(dev->irq_num); -} - -/** - * @brief Disable SPI interrupt requests - * @param dev SPI device - * @param interrupt_flags Bitwise OR of spi_interrupt values to disable - * @see spi_interrupt - */ -static inline void spi_irq_disable(spi_dev *dev, uint32 interrupt_flags) { - dev->regs->CR2 &= ~interrupt_flags; -} - -/** - * @brief Get the data frame format flags with which a SPI port is - * configured. - * @param dev SPI device whose data frame format to get. - * @return SPI_DFF_8_BIT, if dev has an 8-bit data frame format. - * Otherwise, SPI_DFF_16_BIT. - */ -static inline spi_cfg_flag spi_dff(spi_dev *dev) { - return ((dev->regs->CR1 & SPI_CR1_DFF) == SPI_CR1_DFF_8_BIT ? - SPI_DFF_8_BIT : - SPI_DFF_16_BIT); -} - -/** - * @brief Determine whether the device's peripheral receive (RX) - * register is empty. - * @param dev SPI device - * @return true, iff dev's RX register is empty. - */ -static inline uint8 spi_is_rx_nonempty(spi_dev *dev) { - return dev->regs->SR & SPI_SR_RXNE; -} - -/** - * @brief Retrieve the contents of the device's peripheral receive - * (RX) register. - * - * You may only call this function when the RX register is nonempty. - * Calling this function clears the contents of the RX register. - * - * @param dev SPI device - * @return Contents of dev's peripheral RX register - * @see spi_is_rx_reg_nonempty() - */ -static inline uint16 spi_rx_reg(spi_dev *dev) { - return (uint16)dev->regs->DR; -} - -/** - * @brief Determine whether the device's peripheral transmit (TX) - * register is empty. - * @param dev SPI device - * @return true, iff dev's TX register is empty. - */ -static inline uint8 spi_is_tx_empty(spi_dev *dev) { - return dev->regs->SR & SPI_SR_TXE; -} - -/** - * @brief Load a value into the device's peripheral transmit (TX) register. - * - * You may only call this function when the TX register is empty. - * Calling this function loads val into the peripheral's TX register. - * If the device is properly configured, this will initiate a - * transmission, the completion of which will cause the TX register to - * be empty again. - * - * @param dev SPI device - * @param val Value to load into the TX register. If the SPI data - * frame format is 8 bit, the value must be right-aligned. - * @see spi_is_tx_reg_empty() - * @see spi_init() - * @see spi_master_enable() - * @see spi_slave_enable() - */ -static inline void spi_tx_reg(spi_dev *dev, uint16 val) { - dev->regs->DR = val; -} - -/** - * @brief Determine whether the device's peripheral busy (SPI_SR_BSY) - * flag is set. - * @param dev SPI device - * @return true, iff dev's BSY flag is set. - */ -static inline uint8 spi_is_busy(spi_dev *dev) { - return dev->regs->SR & SPI_SR_BSY; -} - -/* - * I2S convenience functions (TODO) - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/stm32.h b/GD32F1/system/libmaple/include/libmaple/stm32.h deleted file mode 100644 index f1990dd..0000000 --- a/GD32F1/system/libmaple/include/libmaple/stm32.h +++ /dev/null @@ -1,238 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010, 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/stm32.h - * @brief STM32 chip header - * - * This header supplies various chip-specific values for the current - * build target. It's useful both to abstract away hardware details - * (e.g. through use of STM32_NR_INTERRUPTS) and to decide what to do - * when you want something nonportable (e.g. by checking - * STM32_MCU_SERIES). - */ - -#ifndef _LIBMAPLE_STM32_H_ -#define _LIBMAPLE_STM32_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * STM32 series identifiers. - * - * Don't make these into an enum; the preprocessor needs them. - */ - -/** STM32F1 series. */ -#define STM32_SERIES_F1 0 -/** STM32F2 series. */ -#define STM32_SERIES_F2 1 -/** STM32L1 series. */ -#define STM32_SERIES_L1 2 -/** STM32F4 series. */ -#define STM32_SERIES_F4 3 - -/* The series header is responsible for defining: - * - * - Everything in the following __DOXYGEN__ conditional block. - * - * - STM32_HAVE_FSMC: 1 if the MCU has the FSMC peripheral, and 0 - * otherwise. - * - * - STM32_HAVE_USB: 1 if the MCU has a USB peripheral, and 0 - * otherwise. - */ - /* roger clark. replaced with line below #include */ -#include "stm32f1/include/series/stm32.h" - -/* Ensure the series header isn't broken. */ -#if (!defined(STM32_PCLK1) || \ - !defined(STM32_PCLK2) || \ - !defined(STM32_MCU_SERIES) || \ - !defined(STM32_NR_INTERRUPTS) || \ - !defined(STM32_NR_GPIO_PORTS) || \ - !defined(STM32_TIMER_MASK) || \ - !defined(STM32_DELAY_US_MULT) || \ - !defined(STM32_SRAM_END) || \ - !defined(STM32_HAVE_DAC) || \ - !defined(STM32_HAVE_FSMC) || \ - !defined(STM32_HAVE_USB)) -#error "Bad STM32F1 configuration. Check header for your MCU." -#endif - -/* - * Derived macros - */ - -/* FIXME [0.0.13] add this to ReST API page */ -/** - * @brief Statically determine whether a timer is present. - * - * Given a constant timer number n (starting from 1), this macro has a - * nonzero value exactly when TIMERn is available. - */ -#define STM32_HAVE_TIMER(n) (STM32_TIMER_MASK & (1 << (n))) - -/* - * Doxygen for functionality provided by series header. - */ - -#ifdef __DOXYGEN__ - -/* - * Clock configuration. - * - * These defines depend upon how the MCU is configured. Because of - * the potential for a mismatch between them and the actual clock - * configuration, keep their number to a minimum. - */ - -/** - * @brief APB1 clock speed, in Hz. - */ -#define STM32_PCLK1 - -/** - * @brief APB2 clock speed, in Hz. - */ -#define STM32_PCLK2 - -/** @brief Deprecated. Use STM32_PCLK1 instead. */ -#define PCLK1 -/** @brief Deprecated. Use STM32_PCLK2 instead. */ -#define PCLK2 - -/* - * Series- and MCU-specific values. - */ - -/** - * @brief STM32 series value for the MCU being targeted. - * - * At time of writing, allowed values are: STM32_SERIES_F1, - * STM32_SERIES_F2. This set of values will expand as libmaple adds - * support for more STM32 series MCUs. - */ -#define STM32_MCU_SERIES - -/** - * @brief Number of interrupts in the vector table. - * - * This does not include Cortex-M interrupts (NMI, HardFault, etc.). - */ -#define STM32_NR_INTERRUPTS - -/** - * Number of GPIO ports. - */ -#define STM32_NR_GPIO_PORTS - -/* FIXME [0.0.13] add this to ReST API page */ -/** - * @brief Bitmask of timers available on the MCU. - * - * That is, if TIMERn is available, then STM32_TIMER_MASK & (1 << n) - * will be nonzero. For example, a nonzero value of "STM32_TIMER_MASK - * & 0x2" means TIMER1 is available. - * - * A bitmask is necessary as some STM32 MCUs have "holes" in the range - * of available timers. - */ -#define STM32_TIMER_MASK - -/** - * @brief Multiplier to convert microseconds into loop iterations - * in delay_us(). - * - * @see delay_us() - */ -#define STM32_DELAY_US_MULT - -/** - * @brief Pointer to end of built-in SRAM. - * - * Points to the address which is 1 byte past the last valid - * SRAM address. - */ -#define STM32_SRAM_END - -/** - * @brief 1 if the target MCU has a DAC, and 0 otherwise. - */ -#define STM32_HAVE_DAC - -/** - * @brief 1 if the target MCU has the FSMC peripheral, and 0 otherwise. - * - * Note that the feature set of the FSMC peripheral is restricted on - * some MCUs. - */ -#define STM32_HAVE_FSMC - -/** - * @brief 1 if the target MCU has a USB peripheral, and 0 otherwise. - * - * Note that a variety of USB peripherals are available across the - * different series, with widely varying feature sets and programming - * interfaces. This macro will be 1 if any such peripheral is present. - */ -#define STM32_HAVE_USB - -#endif /* __DOXYGEN__ */ - -/* - * The following are for backwards compatibility only. - */ - -/* PCLK1 and PCLK2 are for backwards compatibility only; don't use in - * new code. */ -#ifndef PCLK1 -#define PCLK1 STM32_PCLK1 -#endif -#if PCLK1 != STM32_PCLK1 -#error "PCLK1 (which is deprecated) differs from STM32_PCLK1." -#endif -#ifndef PCLK2 -#define PCLK2 STM32_PCLK2 -#endif -#if PCLK2 != STM32_PCLK2 -#error "PCLK2 (which is deprecated) differs from STM32_PCLK2." -#endif - -/** @brief Deprecated. Use STM32_NR_INTERRUPTS instead. */ -#define NR_INTERRUPTS STM32_NR_INTERRUPTS -/** @brief Deprecated. Use STM32_NR_GPIO_PORTS instead. */ -#define NR_GPIO_PORTS STM32_NR_GPIO_PORTS -/** @brief Deprecated. Use STM32_DELAY_US_MULT instead. */ -#define DELAY_US_MULT STM32_DELAY_US_MULT - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/syscfg.h b/GD32F1/system/libmaple/include/libmaple/syscfg.h deleted file mode 100644 index 6b375d3..0000000 --- a/GD32F1/system/libmaple/include/libmaple/syscfg.h +++ /dev/null @@ -1,151 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/syscfg.h - * @brief System configuration controller (SYSCFG) - * - * Availability: STM32F2, STM32F4. - */ - -#ifndef _LIBMAPLE_SYSCFG_H_ -#define _LIBMAPLE_SYSCFG_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* - * Register map and base pointer - */ - -/** - * @brief SYSCFG register map type. - */ -typedef struct syscfg_reg_map { - __io uint32 MEMRMP; /**< Memory remap register */ - __io uint32 PMC; /**< Peripheral mode configuration */ - __io uint32 EXTICR[4]; /**< External interrupt configuration registers */ - const uint32 RESERVED1; - const uint32 RESERVED2; - __io uint32 CMPCR; /**< Compensation cell control register */ -} syscfg_reg_map; - -/** SYSCFG register map base pointer */ -#define SYSCFG_BASE ((struct syscfg_reg_map*)0x40013800) - -/* - * Register bit definitions - */ - -/* Memory remap register */ - -#define SYSCFG_MEMRMP_MEM_MODE 0x3 -#define SYSCFG_MEMRMP_MEM_MODE_FLASH 0x0 -#define SYSCFG_MEMRMP_MEM_MODE_SYS_FLASH 0x1 -#define SYSCFG_MEMRMP_MEM_MODE_FSMC_1 0x2 -#define SYSCFG_MEMRMP_MEM_MODE_EMB_SRAM 0x3 - -/* Peripheral mode configuration register */ - -#define SYSCFG_PMC_MII_RMII_SEL_BIT 23 - -#define SYSCFG_PMC_MII_RMII_SEL (1U << SYSCFG_PMC_MII_RMII_SEL_BIT) -#define SYSCFG_PMC_MII_RMII_SEL_MII (0U << SYSCFG_PMC_MII_RMII_SEL_BIT) -#define SYSCFG_PMC_MII_RMII_SEL_RMII (1U << SYSCFG_PMC_MII_RMII_SEL_BIT) - -/* External interrupt configuration register 1 */ - -#define SYSCFG_EXTICR1_EXTI0 0xF -#define SYSCFG_EXTICR1_EXTI1 0xF0 -#define SYSCFG_EXTICR1_EXTI2 0xF00 -#define SYSCFG_EXTICR1_EXTI3 0xF000 - -/* External interrupt configuration register 2 */ - -#define SYSCFG_EXTICR2_EXTI4 0xF -#define SYSCFG_EXTICR2_EXTI5 0xF0 -#define SYSCFG_EXTICR2_EXTI6 0xF00 -#define SYSCFG_EXTICR2_EXTI7 0xF000 - -/* External interrupt configuration register 3 */ - -#define SYSCFG_EXTICR3_EXTI8 0xF -#define SYSCFG_EXTICR3_EXTI9 0xF0 -#define SYSCFG_EXTICR3_EXTI10 0xF00 -#define SYSCFG_EXTICR3_EXTI11 0xF000 - -/* External interrupt configuration register 4 */ - -#define SYSCFG_EXTICR4_EXTI12 0xF -#define SYSCFG_EXTICR4_EXTI13 0xF0 -#define SYSCFG_EXTICR4_EXTI14 0xF00 -#define SYSCFG_EXTICR4_EXTI15 0xF000 - -/* Compensation cell control register */ - -#define SYSCFG_CMPCR_READY_BIT 8 -#define SYSCFG_CMPCR_CMP_PD_BIT 0 - -#define SYSCFG_CMPCR_READY (1U << SYSCFG_CMPCR_READY_BIT) -#define SYSCFG_CMPCR_CMP_PD (1U << SYSCFG_CMPCR_CMP_PD_BIT) -#define SYSCFG_CMPCR_CMP_PD_PDWN (0U << SYSCFG_CMPCR_CMP_PD_BIT) -#define SYSCFG_CMPCR_CMP_PD_ENABLE (1U << SYSCFG_CMPCR_CMP_PD_BIT) - -/* - * Routines - */ - -void syscfg_init(void); - -void syscfg_enable_io_compensation(void); -void syscfg_disable_io_compensation(void); - -/** - * @brief System memory mode - * These values specify what memory to map to address 0x00000000. - * @see syscfg_set_mem_mode - */ -typedef enum syscfg_mem_mode { - /** Main flash memory is mapped at 0x0. */ - SYCFG_MEM_MODE_FLASH = SYSCFG_MEMRMP_MEM_MODE_FLASH, - /** System flash (i.e. ST's baked-in bootloader) is mapped at 0x0. */ - SYCFG_MEM_MODE_SYSTEM_FLASH = SYSCFG_MEMRMP_MEM_MODE_SYS_FLASH, - /** FSMC bank 1 (NOR/PSRAM 1 and 2) is mapped at 0x0. */ - SYCFG_MEM_MODE_FSMC_BANK_1 = SYSCFG_MEMRMP_MEM_MODE_FSMC_1, - /** Embedded SRAM (i.e., not backup SRAM) is mapped at 0x0. */ - SYCFG_MEM_MODE_SRAM = SYSCFG_MEMRMP_MEM_MODE_EMB_SRAM, -} syscfg_mem_mode; - -void syscfg_set_mem_mode(syscfg_mem_mode); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/systick.h b/GD32F1/system/libmaple/include/libmaple/systick.h deleted file mode 100644 index 551f800..0000000 --- a/GD32F1/system/libmaple/include/libmaple/systick.h +++ /dev/null @@ -1,115 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/systick.h - * @brief System timer definitions - */ - -#ifndef _LIBMAPLE_SYSTICK_H_ -#define _LIBMAPLE_SYSTICK_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include - -/** SysTick register map type */ -typedef struct systick_reg_map { - __io uint32 CSR; /**< Control and status register */ - __io uint32 RVR; /**< Reload value register */ - __io uint32 CNT; /**< Current value register ("count") */ - __io uint32 CVR; /**< Calibration value register */ -} systick_reg_map; - -/** SysTick register map base pointer */ -#define SYSTICK_BASE ((struct systick_reg_map*)0xE000E010) - -/* - * Register bit definitions. - */ - -/* Control and status register */ - -#define SYSTICK_CSR_COUNTFLAG BIT(16) -#define SYSTICK_CSR_CLKSOURCE BIT(2) -#define SYSTICK_CSR_CLKSOURCE_EXTERNAL 0 -#define SYSTICK_CSR_CLKSOURCE_CORE BIT(2) -#define SYSTICK_CSR_TICKINT BIT(1) -#define SYSTICK_CSR_TICKINT_PEND BIT(1) -#define SYSTICK_CSR_TICKINT_NO_PEND 0 -#define SYSTICK_CSR_ENABLE BIT(0) -#define SYSTICK_CSR_ENABLE_MULTISHOT BIT(0) -#define SYSTICK_CSR_ENABLE_DISABLED 0 - -/* Calibration value register */ - -#define SYSTICK_CVR_NOREF BIT(31) -#define SYSTICK_CVR_SKEW BIT(30) -#define SYSTICK_CVR_TENMS 0xFFFFFF - -/** System elapsed time, in milliseconds */ -extern volatile uint32 systick_uptime_millis; - -/** - * @brief Returns the system uptime, in milliseconds. - */ -static inline uint32 systick_uptime(void) { - return systick_uptime_millis; -} - - -void systick_init(uint32 reload_val); -void systick_disable(); -void systick_enable(); - -/** - * @brief Returns the current value of the SysTick counter. - */ -static inline uint32 systick_get_count(void) { - return SYSTICK_BASE->CNT; -} - -/** - * @brief Check for underflow. - * - * This function returns 1 if the SysTick timer has counted to 0 since - * the last time it was called. However, any reads of any part of the - * SysTick Control and Status Register SYSTICK_BASE->CSR will - * interfere with this functionality. See the ARM Cortex M3 Technical - * Reference Manual for more details (e.g. Table 8-3 in revision r1p1). - */ -static inline uint32 systick_check_underflow(void) { - return SYSTICK_BASE->CSR & SYSTICK_CSR_COUNTFLAG; -} - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/timer.h b/GD32F1/system/libmaple/include/libmaple/timer.h deleted file mode 100644 index 6c88f16..0000000 --- a/GD32F1/system/libmaple/include/libmaple/timer.h +++ /dev/null @@ -1,1125 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/timer.h - * @author Marti Bolivar - * @brief Timer interface. - */ - -#ifndef _LIBMAPLE_TIMER_H_ -#define _LIBMAPLE_TIMER_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -/* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/timer.h" -#include -#include -#include -#include - -/* - * Register maps - */ - -/** Advanced control timer register map type */ -typedef struct timer_adv_reg_map { - __io uint32 CR1; /**< Control register 1 */ - __io uint32 CR2; /**< Control register 2 */ - __io uint32 SMCR; /**< Slave mode control register */ - __io uint32 DIER; /**< DMA/interrupt enable register */ - __io uint32 SR; /**< Status register */ - __io uint32 EGR; /**< Event generation register */ - __io uint32 CCMR1; /**< Capture/compare mode register 1 */ - __io uint32 CCMR2; /**< Capture/compare mode register 2 */ - __io uint32 CCER; /**< Capture/compare enable register */ - __io uint32 CNT; /**< Counter */ - __io uint32 PSC; /**< Prescaler */ - __io uint32 ARR; /**< Auto-reload register */ - __io uint32 RCR; /**< Repetition counter register */ - __io uint32 CCR1; /**< Capture/compare register 1 */ - __io uint32 CCR2; /**< Capture/compare register 2 */ - __io uint32 CCR3; /**< Capture/compare register 3 */ - __io uint32 CCR4; /**< Capture/compare register 4 */ - __io uint32 BDTR; /**< Break and dead-time register */ - __io uint32 DCR; /**< DMA control register */ - __io uint32 DMAR; /**< DMA address for full transfer */ -} timer_adv_reg_map; - -/* General purpose timer register map type: intentionally omitted. - * - * General purpose timers differ slightly across series, so leave it - * up to the series header to define struct timer_gen_reg_map. */ - -/** Basic timer register map type */ -typedef struct timer_bas_reg_map { - __io uint32 CR1; /**< Control register 1 */ - __io uint32 CR2; /**< Control register 2 */ - const uint32 RESERVED1; /**< Reserved */ - __io uint32 DIER; /**< DMA/interrupt enable register */ - __io uint32 SR; /**< Status register */ - __io uint32 EGR; /**< Event generation register */ - const uint32 RESERVED2; /**< Reserved */ - const uint32 RESERVED3; /**< Reserved */ - const uint32 RESERVED4; /**< Reserved */ - __io uint32 CNT; /**< Counter */ - __io uint32 PSC; /**< Prescaler */ - __io uint32 ARR; /**< Auto-reload register */ -} timer_bas_reg_map; - -/* - * Timer devices - */ - -/** - * @brief Timer register map type. - * - * Just holds a pointer to the correct type of register map, based on - * the timer's type. - */ -typedef union timer_reg_map { - timer_adv_reg_map *adv; /**< Advanced register map */ - timer_gen_reg_map *gen; /**< General purpose register map */ - timer_bas_reg_map *bas; /**< Basic register map */ -} timer_reg_map; - -/** - * @brief Timer type - * - * Type marker for timer_dev. - * - * @see timer_dev - */ -typedef enum timer_type { - TIMER_ADVANCED, /**< Advanced type */ - TIMER_GENERAL, /**< General purpose type */ - TIMER_BASIC, /**< Basic type */ -} timer_type; - -/** Timer device type */ -typedef struct timer_dev { - timer_reg_map regs; /**< Register map */ - rcc_clk_id clk_id; /**< RCC clock information */ - timer_type type; /**< Timer's type */ - voidFuncPtr handlers[]; /**< - * Don't touch these. Use these instead: - * @see timer_attach_interrupt() - * @see timer_detach_interrupt() */ -} timer_dev; - -#if STM32_HAVE_TIMER(1) -extern timer_dev *const TIMER1; -extern timer_dev timer1; -#endif -#if STM32_HAVE_TIMER(2) -extern timer_dev *const TIMER2; -extern timer_dev timer2; -#endif -#if STM32_HAVE_TIMER(3) -extern timer_dev *const TIMER3; -extern timer_dev timer3; -#endif -#if STM32_HAVE_TIMER(4) -extern timer_dev *const TIMER4; -extern timer_dev timer4; -#endif -#if STM32_HAVE_TIMER(5) -extern timer_dev *const TIMER5; -extern timer_dev timer5; -#endif -#if STM32_HAVE_TIMER(6) -extern timer_dev *const TIMER6; -extern timer_dev timer6; -#endif -#if STM32_HAVE_TIMER(7) -extern timer_dev *const TIMER7; -extern timer_dev timer7; -#endif -#if STM32_HAVE_TIMER(8) -extern timer_dev *const TIMER8; -extern timer_dev timer8; -#endif -#if STM32_HAVE_TIMER(9) -extern timer_dev *const TIMER9; -extern timer_dev timer9; -#endif -#if STM32_HAVE_TIMER(10) -extern timer_dev *const TIMER10; -extern timer_dev timer10; -#endif -#if STM32_HAVE_TIMER(11) -extern timer_dev *const TIMER11; -extern timer_dev timer11; -#endif -#if STM32_HAVE_TIMER(12) -extern timer_dev *const TIMER12; -extern timer_dev timer12; -#endif -#if STM32_HAVE_TIMER(13) -extern timer_dev *const TIMER13; -extern timer_dev timer13; -#endif -#if STM32_HAVE_TIMER(14) -extern timer_dev *const TIMER14; -extern timer_dev timer14; -#endif - -/* - * Register bit definitions - */ - -/* Control register 1 (CR1) */ - -#define TIMER_CR1_ARPE_BIT 7 -#define TIMER_CR1_DIR_BIT 4 -#define TIMER_CR1_OPM_BIT 3 -#define TIMER_CR1_URS_BIT 2 -#define TIMER_CR1_UDIS_BIT 1 -#define TIMER_CR1_CEN_BIT 0 - -#define TIMER_CR1_CKD (0x3 << 8) -#define TIMER_CR1_CKD_1TCKINT (0x0 << 8) -#define TIMER_CR1_CKD_2TCKINT (0x1 << 8) -#define TIMER_CR1_CKD_4TICKINT (0x2 << 8) -#define TIMER_CR1_ARPE (1U << TIMER_CR1_ARPE_BIT) -#define TIMER_CR1_CKD_CMS (0x3 << 5) -#define TIMER_CR1_CKD_CMS_EDGE (0x0 << 5) -#define TIMER_CR1_CKD_CMS_CENTER1 (0x1 << 5) -#define TIMER_CR1_CKD_CMS_CENTER2 (0x2 << 5) -#define TIMER_CR1_CKD_CMS_CENTER3 (0x3 << 5) -#define TIMER_CR1_DIR (1U << TIMER_CR1_DIR_BIT) -#define TIMER_CR1_OPM (1U << TIMER_CR1_OPM_BIT) -#define TIMER_CR1_URS (1U << TIMER_CR1_URS_BIT) -#define TIMER_CR1_UDIS (1U << TIMER_CR1_UDIS_BIT) -#define TIMER_CR1_CEN (1U << TIMER_CR1_CEN_BIT) - -/* Control register 2 (CR2) */ - -#define TIMER_CR2_OIS4_BIT 14 -#define TIMER_CR2_OIS3N_BIT 13 -#define TIMER_CR2_OIS3_BIT 12 -#define TIMER_CR2_OIS2N_BIT 11 -#define TIMER_CR2_OIS2_BIT 10 -#define TIMER_CR2_OIS1N_BIT 9 -#define TIMER_CR2_OIS1_BIT 8 -#define TIMER_CR2_TI1S_BIT 7 -#define TIMER_CR2_CCDS_BIT 3 -#define TIMER_CR2_CCUS_BIT 2 -#define TIMER_CR2_CCPC_BIT 0 - -#define TIMER_CR2_OIS4 (1U << TIMER_CR2_OIS4_BIT) -#define TIMER_CR2_OIS3N (1U << TIMER_CR2_OIS3N_BIT) -#define TIMER_CR2_OIS3 (1U << TIMER_CR2_OIS3_BIT) -#define TIMER_CR2_OIS2N (1U << TIMER_CR2_OIS2N_BIT) -#define TIMER_CR2_OIS2 (1U << TIMER_CR2_OIS2_BIT) -#define TIMER_CR2_OIS1N (1U << TIMER_CR2_OIS1N_BIT) -#define TIMER_CR2_OIS1 (1U << TIMER_CR2_OIS1_BIT) -#define TIMER_CR2_TI1S (1U << TIMER_CR2_TI1S_BIT) -#define TIMER_CR2_MMS (0x7 << 4) -#define TIMER_CR2_MMS_RESET (0x0 << 4) -#define TIMER_CR2_MMS_ENABLE (0x1 << 4) -#define TIMER_CR2_MMS_UPDATE (0x2 << 4) -#define TIMER_CR2_MMS_COMPARE_PULSE (0x3 << 4) -#define TIMER_CR2_MMS_COMPARE_OC1REF (0x4 << 4) -#define TIMER_CR2_MMS_COMPARE_OC2REF (0x5 << 4) -#define TIMER_CR2_MMS_COMPARE_OC3REF (0x6 << 4) -#define TIMER_CR2_MMS_COMPARE_OC4REF (0x7 << 4) -#define TIMER_CR2_CCDS (1U << TIMER_CR2_CCDS_BIT) -#define TIMER_CR2_CCUS (1U << TIMER_CR2_CCUS_BIT) -#define TIMER_CR2_CCPC (1U << TIMER_CR2_CCPC_BIT) - -/* Slave mode control register (SMCR) */ - -#define TIMER_SMCR_ETP_BIT 15 -#define TIMER_SMCR_ECE_BIT 14 -#define TIMER_SMCR_MSM_BIT 7 - -#define TIMER_SMCR_ETP (1U << TIMER_SMCR_ETP_BIT) -#define TIMER_SMCR_ECE (1U << TIMER_SMCR_ECE_BIT) -#define TIMER_SMCR_ETPS (0x3 << 12) -#define TIMER_SMCR_ETPS_OFF (0x0 << 12) -#define TIMER_SMCR_ETPS_DIV2 (0x1 << 12) -#define TIMER_SMCR_ETPS_DIV4 (0x2 << 12) -#define TIMER_SMCR_ETPS_DIV8 (0x3 << 12) -#define TIMER_SMCR_ETF (0xF << 12) -#define TIMER_SMCR_MSM (1U << TIMER_SMCR_MSM_BIT) -#define TIMER_SMCR_TS (0x7 << 4) -#define TIMER_SMCR_TS_ITR0 (0x0 << 4) -#define TIMER_SMCR_TS_ITR1 (0x1 << 4) -#define TIMER_SMCR_TS_ITR2 (0x2 << 4) -#define TIMER_SMCR_TS_ITR3 (0x3 << 4) -#define TIMER_SMCR_TS_TI1F_ED (0x4 << 4) -#define TIMER_SMCR_TS_TI1FP1 (0x5 << 4) -#define TIMER_SMCR_TS_TI2FP2 (0x6 << 4) -#define TIMER_SMCR_TS_ETRF (0x7 << 4) -#define TIMER_SMCR_SMS 0x7 -#define TIMER_SMCR_SMS_DISABLED 0x0 -#define TIMER_SMCR_SMS_ENCODER1 0x1 -#define TIMER_SMCR_SMS_ENCODER2 0x2 -#define TIMER_SMCR_SMS_ENCODER3 0x3 -#define TIMER_SMCR_SMS_RESET 0x4 -#define TIMER_SMCR_SMS_GATED 0x5 -#define TIMER_SMCR_SMS_TRIGGER 0x6 -#define TIMER_SMCR_SMS_EXTERNAL 0x7 - -/* DMA/Interrupt enable register (DIER) */ - -#define TIMER_DIER_TDE_BIT 14 -#define TIMER_DIER_COMDE_BIT 13 -#define TIMER_DIER_CC4DE_BIT 12 -#define TIMER_DIER_CC3DE_BIT 11 -#define TIMER_DIER_CC2DE_BIT 10 -#define TIMER_DIER_CC1DE_BIT 9 -#define TIMER_DIER_UDE_BIT 8 -#define TIMER_DIER_BIE_BIT 7 -#define TIMER_DIER_TIE_BIT 6 -#define TIMER_DIER_COMIE_BIT 5 -#define TIMER_DIER_CC4IE_BIT 4 -#define TIMER_DIER_CC3IE_BIT 3 -#define TIMER_DIER_CC2IE_BIT 2 -#define TIMER_DIER_CC1IE_BIT 1 -#define TIMER_DIER_UIE_BIT 0 - -#define TIMER_DIER_TDE (1U << TIMER_DIER_TDE_BIT) -#define TIMER_DIER_COMDE (1U << TIMER_DIER_COMDE_BIT) -#define TIMER_DIER_CC4DE (1U << TIMER_DIER_CC4DE_BIT) -#define TIMER_DIER_CC3DE (1U << TIMER_DIER_CC3DE_BIT) -#define TIMER_DIER_CC2DE (1U << TIMER_DIER_CC2DE_BIT) -#define TIMER_DIER_CC1DE (1U << TIMER_DIER_CC1DE_BIT) -#define TIMER_DIER_UDE (1U << TIMER_DIER_UDE_BIT) -#define TIMER_DIER_BIE (1U << TIMER_DIER_BIE_BIT) -#define TIMER_DIER_TIE (1U << TIMER_DIER_TIE_BIT) -#define TIMER_DIER_COMIE (1U << TIMER_DIER_COMIE_BIT) -#define TIMER_DIER_CC4IE (1U << TIMER_DIER_CC4IE_BIT) -#define TIMER_DIER_CC3IE (1U << TIMER_DIER_CC3IE_BIT) -#define TIMER_DIER_CC2IE (1U << TIMER_DIER_CC2IE_BIT) -#define TIMER_DIER_CC1IE (1U << TIMER_DIER_CC1IE_BIT) -#define TIMER_DIER_UIE (1U << TIMER_DIER_UIE_BIT) - -/* Status register (SR) */ - -#define TIMER_SR_CC4OF_BIT 12 -#define TIMER_SR_CC3OF_BIT 11 -#define TIMER_SR_CC2OF_BIT 10 -#define TIMER_SR_CC1OF_BIT 9 -#define TIMER_SR_BIF_BIT 7 -#define TIMER_SR_TIF_BIT 6 -#define TIMER_SR_COMIF_BIT 5 -#define TIMER_SR_CC4IF_BIT 4 -#define TIMER_SR_CC3IF_BIT 3 -#define TIMER_SR_CC2IF_BIT 2 -#define TIMER_SR_CC1IF_BIT 1 -#define TIMER_SR_UIF_BIT 0 - -#define TIMER_SR_CC4OF (1U << TIMER_SR_CC4OF_BIT) -#define TIMER_SR_CC3OF (1U << TIMER_SR_CC3OF_BIT) -#define TIMER_SR_CC2OF (1U << TIMER_SR_CC2OF_BIT) -#define TIMER_SR_CC1OF (1U << TIMER_SR_CC1OF_BIT) -#define TIMER_SR_BIF (1U << TIMER_SR_BIF_BIT) -#define TIMER_SR_TIF (1U << TIMER_SR_TIF_BIT) -#define TIMER_SR_COMIF (1U << TIMER_SR_COMIF_BIT) -#define TIMER_SR_CC4IF (1U << TIMER_SR_CC4IF_BIT) -#define TIMER_SR_CC3IF (1U << TIMER_SR_CC3IF_BIT) -#define TIMER_SR_CC2IF (1U << TIMER_SR_CC2IF_BIT) -#define TIMER_SR_CC1IF (1U << TIMER_SR_CC1IF_BIT) -#define TIMER_SR_UIF (1U << TIMER_SR_UIF_BIT) - -/* Event generation register (EGR) */ - -#define TIMER_EGR_BG_BIT 7 -#define TIMER_EGR_TG_BIT 6 -#define TIMER_EGR_COMG_BIT 5 -#define TIMER_EGR_CC4G_BIT 4 -#define TIMER_EGR_CC3G_BIT 3 -#define TIMER_EGR_CC2G_BIT 2 -#define TIMER_EGR_CC1G_BIT 1 -#define TIMER_EGR_UG_BIT 0 - -#define TIMER_EGR_BG (1U << TIMER_EGR_BG_BIT) -#define TIMER_EGR_TG (1U << TIMER_EGR_TG_BIT) -#define TIMER_EGR_COMG (1U << TIMER_EGR_COMG_BIT) -#define TIMER_EGR_CC4G (1U << TIMER_EGR_CC4G_BIT) -#define TIMER_EGR_CC3G (1U << TIMER_EGR_CC3G_BIT) -#define TIMER_EGR_CC2G (1U << TIMER_EGR_CC2G_BIT) -#define TIMER_EGR_CC1G (1U << TIMER_EGR_CC1G_BIT) -#define TIMER_EGR_UG (1U << TIMER_EGR_UG_BIT) - -/* Capture/compare mode registers, common values */ - -#define TIMER_CCMR_CCS_OUTPUT 0x0 -#define TIMER_CCMR_CCS_INPUT_TI1 0x1 -#define TIMER_CCMR_CCS_INPUT_TI2 0x2 -#define TIMER_CCMR_CCS_INPUT_TRC 0x3 - -/* Capture/compare mode register 1 (CCMR1) */ - -#define TIMER_CCMR1_OC2CE_BIT 15 -#define TIMER_CCMR1_OC2PE_BIT 11 -#define TIMER_CCMR1_OC2FE_BIT 10 -#define TIMER_CCMR1_OC1CE_BIT 7 -#define TIMER_CCMR1_OC1PE_BIT 3 -#define TIMER_CCMR1_OC1FE_BIT 2 - -#define TIMER_CCMR1_OC2CE (1U << TIMER_CCMR1_OC2CE_BIT) -#define TIMER_CCMR1_OC2M (0x3 << 12) -#define TIMER_CCMR1_IC2F (0xF << 12) -#define TIMER_CCMR1_OC2PE (1U << TIMER_CCMR1_OC2PE_BIT) -#define TIMER_CCMR1_OC2FE (1U << TIMER_CCMR1_OC2FE_BIT) -#define TIMER_CCMR1_IC2PSC (0x3 << 10) -#define TIMER_CCMR1_CC2S (0x3 << 8) -#define TIMER_CCMR1_CC2S_OUTPUT (TIMER_CCMR_CCS_OUTPUT << 8) -#define TIMER_CCMR1_CC2S_INPUT_TI1 (TIMER_CCMR_CCS_INPUT_TI1 << 8) -#define TIMER_CCMR1_CC2S_INPUT_TI2 (TIMER_CCMR_CCS_INPUT_TI2 << 8) -#define TIMER_CCMR1_CC2S_INPUT_TRC (TIMER_CCMR_CCS_INPUT_TRC << 8) -#define TIMER_CCMR1_OC1CE (1U << TIMER_CCMR1_OC1CE_BIT) -#define TIMER_CCMR1_OC1M (0x3 << 4) -#define TIMER_CCMR1_IC1F (0xF << 4) -#define TIMER_CCMR1_OC1PE (1U << TIMER_CCMR1_OC1PE_BIT) -#define TIMER_CCMR1_OC1FE (1U << TIMER_CCMR1_OC1FE_BIT) -#define TIMER_CCMR1_IC1PSC (0x3 << 2) -#define TIMER_CCMR1_CC1S 0x3 -#define TIMER_CCMR1_CC1S_OUTPUT TIMER_CCMR_CCS_OUTPUT -#define TIMER_CCMR1_CC1S_INPUT_TI1 TIMER_CCMR_CCS_INPUT_TI1 -#define TIMER_CCMR1_CC1S_INPUT_TI2 TIMER_CCMR_CCS_INPUT_TI2 -#define TIMER_CCMR1_CC1S_INPUT_TRC TIMER_CCMR_CCS_INPUT_TRC - -/* Capture/compare mode register 2 (CCMR2) */ - -#define TIMER_CCMR2_OC4CE_BIT 15 -#define TIMER_CCMR2_OC4PE_BIT 11 -#define TIMER_CCMR2_OC4FE_BIT 10 -#define TIMER_CCMR2_OC3CE_BIT 7 -#define TIMER_CCMR2_OC3PE_BIT 3 -#define TIMER_CCMR2_OC3FE_BIT 2 - -#define TIMER_CCMR2_OC4CE (1U << TIMER_CCMR2_OC4CE_BIT) -#define TIMER_CCMR2_OC4M (0x3 << 12) -#define TIMER_CCMR2_IC4F (0xF << 12) -#define TIMER_CCMR2_OC4PE (1U << TIMER_CCMR2_OC4PE_BIT) -#define TIMER_CCMR2_OC4FE (1U << TIMER_CCMR2_OC4FE_BIT) -#define TIMER_CCMR2_IC4PSC (0x3 << 10) -#define TIMER_CCMR2_CC4S (0x3 << 8) -#define TIMER_CCMR2_CC4S_OUTPUT (TIMER_CCMR_CCS_OUTPUT << 8) -#define TIMER_CCMR2_CC4S_INPUT_TI1 (TIMER_CCMR_CCS_INPUT_TI1 << 8) -#define TIMER_CCMR2_CC4S_INPUT_TI2 (TIMER_CCMR_CCS_INPUT_TI2 << 8) -#define TIMER_CCMR2_CC4S_INPUT_TRC (TIMER_CCMR_CCS_INPUT_TRC << 8) -#define TIMER_CCMR2_OC3CE (1U << TIMER_CCMR2_OC3CE_BIT) -#define TIMER_CCMR2_OC3M (0x3 << 4) -#define TIMER_CCMR2_IC3F (0xF << 4) -#define TIMER_CCMR2_OC3PE (1U << TIMER_CCMR2_OC3PE_BIT) -#define TIMER_CCMR2_OC3FE (1U << TIMER_CCMR2_OC3FE_BIT) -#define TIMER_CCMR2_IC3PSC (0x3 << 2) -#define TIMER_CCMR2_CC3S 0x3 -#define TIMER_CCMR2_CC3S_OUTPUT TIMER_CCMR_CCS_OUTPUT -#define TIMER_CCMR2_CC3S_INPUT_TI1 TIMER_CCMR_CCS_INPUT_TI1 -#define TIMER_CCMR2_CC3S_INPUT_TI2 TIMER_CCMR_CCS_INPUT_TI2 -#define TIMER_CCMR2_CC3S_INPUT_TRC TIMER_CCMR_CCS_INPUT_TRC - -/* Capture/compare enable register (CCER) */ - -#define TIMER_CCER_CC4P_BIT 13 -#define TIMER_CCER_CC4E_BIT 12 -#define TIMER_CCER_CC3NP_BIT 11 -#define TIMER_CCER_CC3NE_BIT 10 -#define TIMER_CCER_CC3P_BIT 9 -#define TIMER_CCER_CC3E_BIT 8 -#define TIMER_CCER_CC2NP_BIT 7 -#define TIMER_CCER_CC2NE_BIT 6 -#define TIMER_CCER_CC2P_BIT 5 -#define TIMER_CCER_CC2E_BIT 4 -#define TIMER_CCER_CC1NP_BIT 3 -#define TIMER_CCER_CC1NE_BIT 2 -#define TIMER_CCER_CC1P_BIT 1 -#define TIMER_CCER_CC1E_BIT 0 - -#define TIMER_CCER_CC4P (1U << TIMER_CCER_CC4P_BIT) -#define TIMER_CCER_CC4E (1U << TIMER_CCER_CC4E_BIT) -#define TIMER_CCER_CC3NP (1U << TIMER_CCER_CC3NP_BIT) -#define TIMER_CCER_CC3NE (1U << TIMER_CCER_CC3NE_BIT) -#define TIMER_CCER_CC3P (1U << TIMER_CCER_CC3P_BIT) -#define TIMER_CCER_CC3E (1U << TIMER_CCER_CC3E_BIT) -#define TIMER_CCER_CC2NP (1U << TIMER_CCER_CC2NP_BIT) -#define TIMER_CCER_CC2NE (1U << TIMER_CCER_CC2NE_BIT) -#define TIMER_CCER_CC2P (1U << TIMER_CCER_CC2P_BIT) -#define TIMER_CCER_CC2E (1U << TIMER_CCER_CC2E_BIT) -#define TIMER_CCER_CC1NP (1U << TIMER_CCER_CC1NP_BIT) -#define TIMER_CCER_CC1NE (1U << TIMER_CCER_CC1NE_BIT) -#define TIMER_CCER_CC1P (1U << TIMER_CCER_CC1P_BIT) -#define TIMER_CCER_CC1E (1U << TIMER_CCER_CC1E_BIT) - -/* Break and dead-time register (BDTR) */ - -#define TIMER_BDTR_MOE_BIT 15 -#define TIMER_BDTR_AOE_BIT 14 -#define TIMER_BDTR_BKP_BIT 13 -#define TIMER_BDTR_BKE_BIT 12 -#define TIMER_BDTR_OSSR_BIT 11 -#define TIMER_BDTR_OSSI_BIT 10 - -#define TIMER_BDTR_MOE (1U << TIMER_BDTR_MOE_BIT) -#define TIMER_BDTR_AOE (1U << TIMER_BDTR_AOE_BIT) -#define TIMER_BDTR_BKP (1U << TIMER_BDTR_BKP_BIT) -#define TIMER_BDTR_BKE (1U << TIMER_BDTR_BKE_BIT) -#define TIMER_BDTR_OSSR (1U << TIMER_BDTR_OSSR_BIT) -#define TIMER_BDTR_OSSI (1U << TIMER_BDTR_OSSI_BIT) -#define TIMER_BDTR_LOCK (0x3 << 8) -#define TIMER_BDTR_LOCK_OFF (0x0 << 8) -#define TIMER_BDTR_LOCK_LEVEL1 (0x1 << 8) -#define TIMER_BDTR_LOCK_LEVEL2 (0x2 << 8) -#define TIMER_BDTR_LOCK_LEVEL3 (0x3 << 8) -#define TIMER_BDTR_DTG 0xFF - -/* DMA control register (DCR) */ - -#define TIMER_DCR_DBL (0x1F << 8) -#define TIMER_DCR_DBL_1_XFER (0x0 << 8) -#define TIMER_DCR_DBL_2_XFER (0x1 << 8) -#define TIMER_DCR_DBL_3_XFER (0x2 << 8) -#define TIMER_DCR_DBL_4_XFER (0x3 << 8) -#define TIMER_DCR_DBL_5_XFER (0x4 << 8) -#define TIMER_DCR_DBL_6_XFER (0x5 << 8) -#define TIMER_DCR_DBL_7_XFER (0x6 << 8) -#define TIMER_DCR_DBL_8_XFER (0x7 << 8) -#define TIMER_DCR_DBL_9_XFER (0x8 << 8) -#define TIMER_DCR_DBL_10_XFER (0x9 << 8) -#define TIMER_DCR_DBL_11_XFER (0xA << 8) -#define TIMER_DCR_DBL_12_XFER (0xB << 8) -#define TIMER_DCR_DBL_13_XFER (0xC << 8) -#define TIMER_DCR_DBL_14_XFER (0xD << 8) -#define TIMER_DCR_DBL_15_XFER (0xE << 8) -#define TIMER_DCR_DBL_16_XFER (0xF << 8) -#define TIMER_DCR_DBL_17_XFER (0x10 << 8) -#define TIMER_DCR_DBL_18_XFER (0x11 << 8) -#define TIMER_DCR_DBA 0x1F -#define TIMER_DCR_DBA_CR1 0x0 -#define TIMER_DCR_DBA_CR2 0x1 -#define TIMER_DCR_DBA_SMCR 0x2 -#define TIMER_DCR_DBA_DIER 0x3 -#define TIMER_DCR_DBA_SR 0x4 -#define TIMER_DCR_DBA_EGR 0x5 -#define TIMER_DCR_DBA_CCMR1 0x6 -#define TIMER_DCR_DBA_CCMR2 0x7 -#define TIMER_DCR_DBA_CCER 0x8 -#define TIMER_DCR_DBA_CNT 0x9 -#define TIMER_DCR_DBA_PSC 0xA -#define TIMER_DCR_DBA_ARR 0xB -#define TIMER_DCR_DBA_RCR 0xC -#define TIMER_DCR_DBA_CCR1 0xD -#define TIMER_DCR_DBA_CCR2 0xE -#define TIMER_DCR_DBA_CCR3 0xF -#define TIMER_DCR_DBA_CCR4 0x10 -#define TIMER_DCR_DBA_BDTR 0x11 -#define TIMER_DCR_DBA_DCR 0x12 -#define TIMER_DCR_DBA_DMAR 0x13 - -/* - * Convenience routines - */ - -/** - * @brief Used to configure the behavior of a timer channel. - * - * Be careful: not all timers can be configured in every mode. - */ -typedef enum timer_mode { - /** - * The timer stops counting, channel interrupts are detached, and - * no state changes are output. */ - TIMER_DISABLED, - - /** PWM output. */ - TIMER_PWM, - - /* TIMER_PWM_CENTER_ALIGNED, TODO: Center-aligned PWM output mode. */ - - /** - * The timer counts from 0 to its reload value repeatedly; every - * time the counter value reaches one of the channel compare - * values, the corresponding interrupt is fired. */ - TIMER_OUTPUT_COMPARE, - - /* TIMER_INPUT_CAPTURE, TODO: In this mode, the timer can measure the - * pulse lengths of input signals */ - /* TIMER_ONE_PULSE, TODO: In this mode, the timer can generate a single - * pulse on a GPIO pin for a specified amount of - * time. */ -} timer_mode; - -/** Timer channel numbers */ -typedef enum timer_channel { - TIMER_CH1 = 1, /**< Channel 1 */ - TIMER_CH2 = 2, /**< Channel 2 */ - TIMER_CH3 = 3, /**< Channel 3 */ - TIMER_CH4 = 4 /**< Channel 4 */ -} timer_channel; - -/* - * Note: Don't require timer_channel arguments! We want to be able to say - * - * for (int channel = 1; channel <= 4; channel++) { - * ... - * } - * - * without the compiler yelling at us. - */ - -void timer_init(timer_dev *dev); -void timer_disable(timer_dev *dev); -void timer_set_mode(timer_dev *dev, uint8 channel, timer_mode mode); -void timer_foreach(void (*fn)(timer_dev*)); -int timer_has_cc_channel(timer_dev *dev, uint8 channel); - -/** - * @brief Timer interrupt number. - * - * Not all timers support all of these values. All timers support - * TIMER_UPDATE_INTERRUPT. "General purpose" timers can be a special - * nuisance in this regard, as they individually support different - * subsets of the available interupts. Consult your target's reference - * manual for the details. - */ -typedef enum timer_interrupt_id { - TIMER_UPDATE_INTERRUPT, /**< Update interrupt. */ - TIMER_CC1_INTERRUPT, /**< Capture/compare 1 interrupt. */ - TIMER_CC2_INTERRUPT, /**< Capture/compare 2 interrupt. */ - TIMER_CC3_INTERRUPT, /**< Capture/compare 3 interrupt. */ - TIMER_CC4_INTERRUPT, /**< Capture/compare 4 interrupt. */ - TIMER_COM_INTERRUPT, /**< COM interrupt. */ - TIMER_TRG_INTERRUPT, /**< Trigger interrupt. */ - TIMER_BREAK_INTERRUPT, /**< Break interrupt. */ -} timer_interrupt_id; - -void timer_attach_interrupt(timer_dev *dev, - uint8 interrupt, - voidFuncPtr handler); -void timer_detach_interrupt(timer_dev *dev, uint8 interrupt); - -/** - * Initialize all timer devices on the chip. - */ -static inline void timer_init_all(void) { - timer_foreach(timer_init); -} - -/** - * Disables all timers on the device. - */ -static inline void timer_disable_all(void) { - timer_foreach(timer_disable); -} - -/** - * @brief Stop a timer's counter from changing. - * - * Does not affect the timer's mode or other settings. - * - * @param dev Device whose counter to pause. - */ -static inline void timer_pause(timer_dev *dev) { - *bb_perip(&(dev->regs).bas->CR1, TIMER_CR1_CEN_BIT) = 0; -} - -/** - * @brief Start a timer's counter. - * - * Does not affect the timer's mode or other settings. - * - * @param dev Device whose counter to resume - */ -static inline void timer_resume(timer_dev *dev) { - *bb_perip(&(dev->regs).bas->CR1, TIMER_CR1_CEN_BIT) = 1; -} - -/** - * @brief Returns the timer's counter value. - * - * This value is likely to be inaccurate if the counter is running - * with a low prescaler. - * - * @param dev Timer whose counter to return - */ -static inline uint16 timer_get_count(timer_dev *dev) { - return (uint16)(dev->regs).bas->CNT; -} - -/** - * @brief Sets the counter value for the given timer. - * @param dev Timer whose counter to set - * @param value New counter value - */ -static inline void timer_set_count(timer_dev *dev, uint16 value) { - (dev->regs).bas->CNT = value; -} - -/** - * @brief Returns the given timer's prescaler. - * - * Note that if the timer's prescaler is set (e.g. via - * timer_set_prescaler() or accessing a TIMx_PSC register), the value - * returned by this function will reflect the new setting, but the - * timer's counter will only reflect the new prescaler at the next - * update event. - * - * @param dev Timer whose prescaler to return - * @see timer_generate_update() - */ -static inline uint16 timer_get_prescaler(timer_dev *dev) { - return (uint16)(dev->regs).bas->PSC; -} - -/** - * @brief Set a timer's prescale value. - * - * Divides the input clock by (PSC+1). The new value will not take - * effect until the next update event. - * - * @param dev Timer whose prescaler to set - * @param psc New prescaler value - * @see timer_generate_update() - */ -static inline void timer_set_prescaler(timer_dev *dev, uint16 psc) { - (dev->regs).bas->PSC = psc; -} - -/** - * @brief Returns a timer's reload value. - * @param dev Timer whose reload value to return - */ -static inline uint16 timer_get_reload(timer_dev *dev) { - return (uint16)(dev->regs).bas->ARR; -} - -/** - * @brief Set a timer's reload value. - * @param dev Timer whose reload value to set - * @param arr New reload value to use. Takes effect at next update event. - * @see timer_generate_update() - */ -static inline void timer_set_reload(timer_dev *dev, uint16 arr) { - (dev->regs).bas->ARR = arr; -} - -/** - * @brief Get the compare value for the given timer channel. - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param channel Channel whose compare value to get. - */ -static inline uint16 timer_get_compare(timer_dev *dev, uint8 channel) { - __io uint32 *ccr = &(dev->regs).gen->CCR1 + (channel - 1); - return *ccr; -} - -/** - * @brief Set the compare value for the given timer channel. - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param channel Channel whose compare value to set. - * @param value New compare value. - */ -static inline void timer_set_compare(timer_dev *dev, - uint8 channel, - uint16 value) { - __io uint32 *ccr = &(dev->regs).gen->CCR1 + (channel - 1); - *ccr = value; -} - -/** - * @brief Generate an update event for the given timer. - * - * Normally, this will cause the prescaler and auto-reload values in - * the PSC and ARR registers to take immediate effect. However, this - * function will do nothing if the UDIS bit is set in the timer's CR1 - * register (UDIS is cleared by default). - * - * @param dev Timer device to generate an update for. - */ -static inline void timer_generate_update(timer_dev *dev) { - *bb_perip(&(dev->regs).bas->EGR, TIMER_EGR_UG_BIT) = 1; -} - -/** - * @brief Enable a timer's trigger DMA request - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL - */ -static inline void timer_dma_enable_trg_req(timer_dev *dev) { - *bb_perip(&(dev->regs).gen->DIER, TIMER_DIER_TDE_BIT) = 1; -} - -/** - * @brief Disable a timer's trigger DMA request - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL - */ -static inline void timer_dma_disable_trg_req(timer_dev *dev) { - *bb_perip(&(dev->regs).gen->DIER, TIMER_DIER_TDE_BIT) = 0; -} - -/** - * @brief Enable a timer channel's DMA request. - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL - * @param channel Channel whose DMA request to enable. - */ -static inline void timer_dma_enable_req(timer_dev *dev, uint8 channel) { - *bb_perip(&(dev->regs).gen->DIER, channel + 8) = 1; -} - -/** - * @brief Disable a timer channel's DMA request. - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param channel Channel whose DMA request to disable. - */ -static inline void timer_dma_disable_req(timer_dev *dev, uint8 channel) { - *bb_perip(&(dev->regs).gen->DIER, channel + 8) = 0; -} - -/** - * @brief Enable a timer interrupt. - * @param dev Timer device. - * @param interrupt Interrupt number to enable; this may be any - * timer_interrupt_id value appropriate for the timer. - * @see timer_interrupt_id - * @see timer_channel - */ -static inline void timer_enable_irq(timer_dev *dev, uint8 interrupt) { - *bb_perip(&(dev->regs).adv->DIER, interrupt) = 1; -} - -/** - * @brief Disable a timer interrupt. - * @param dev Timer device. - * @param interrupt Interrupt number to disable; this may be any - * timer_interrupt_id value appropriate for the timer. - * @see timer_interrupt_id - * @see timer_channel - */ -static inline void timer_disable_irq(timer_dev *dev, uint8 interrupt) { - *bb_perip(&(dev->regs).adv->DIER, interrupt) = 0; -} - -/** - * @brief Enable a timer channel's capture/compare signal. - * - * If the channel is configured as output, the corresponding output - * compare signal will be output on the corresponding output pin. If - * the channel is configured as input, enables capture of the counter - * value into the input capture/compare register. - * - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param channel Channel to enable, from 1 to 4. - */ -static inline void timer_cc_enable(timer_dev *dev, uint8 channel) { - *bb_perip(&(dev->regs).gen->CCER, 4 * (channel - 1)) = 1; -} - -/** - * @brief Disable a timer channel's output compare or input capture signal. - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param channel Channel to disable, from 1 to 4. - * @see timer_cc_enable() - */ -static inline void timer_cc_disable(timer_dev *dev, uint8 channel) { - *bb_perip(&(dev->regs).gen->CCER, 4 * (channel - 1)) = 0; -} - -/** - * @brief Get a channel's capture/compare output polarity - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param channel Channel whose capture/compare output polarity to get. - * @return Polarity, either 0 or 1. - * @see timer_cc_set_polarity() - */ -static inline uint8 timer_cc_get_pol(timer_dev *dev, uint8 channel) { - return *bb_perip(&(dev->regs).gen->CCER, 4 * (channel - 1) + 1); -} - -/** - * @brief Set a timer channel's capture/compare output polarity. - * - * If the timer channel is configured as output: polarity == 0 means - * the output channel will be active high; polarity == 1 means active - * low. - * - * If the timer channel is configured as input: polarity == 0 means - * capture is done on the rising edge of ICn; when used as an external - * trigger, ICn is non-inverted. polarity == 1 means capture is done - * on the falling edge of ICn; when used as an external trigger, ICn - * is inverted. - * - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param channel Channel whose capture/compare output polarity to set. - * @param pol New polarity, 0 or 1. - */ -static inline void timer_cc_set_pol(timer_dev *dev, uint8 channel, uint8 pol) { - *bb_perip(&(dev->regs).gen->CCER, 4 * (channel - 1) + 1) = pol; -} - -/** - * @brief Get a timer's DMA burst length. - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @return Number of transfers per read or write to timer DMA register, - * from 1 to 18. - */ -static inline uint8 timer_dma_get_burst_len(timer_dev *dev) { - uint32 dbl = ((dev->regs).gen->DCR & TIMER_DCR_DBL) >> 8; - return dbl + 1; /* 0 means 1 transfer, etc. */ -} - -/** - * @brief Set a timer's DMA burst length. - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param length DMA burst length; i.e., number of DMA transfers per - * read/write to timer DMA register, from 1 to 18. - */ -static inline void timer_dma_set_burst_len(timer_dev *dev, uint8 length) { - uint32 tmp = (dev->regs).gen->DCR; - tmp &= ~TIMER_DCR_DBL; - tmp |= (length - 1) << 8; - (dev->regs).gen->DCR = tmp; -} - -/** - * @brief Timer DMA base address. - * - * Defines the base address for DMA transfers. - */ -typedef enum timer_dma_base_addr { - /** Base is control register 1 */ - TIMER_DMA_BASE_CR1 = TIMER_DCR_DBA_CR1, - /** Base is control register 2 */ - TIMER_DMA_BASE_CR2 = TIMER_DCR_DBA_CR2, - /** Base is slave mode control register */ - TIMER_DMA_BASE_SMCR = TIMER_DCR_DBA_SMCR, - /** Base is DMA interrupt enable register */ - TIMER_DMA_BASE_DIER = TIMER_DCR_DBA_DIER, - /** Base is status register */ - TIMER_DMA_BASE_SR = TIMER_DCR_DBA_SR, - /** Base is event generation register */ - TIMER_DMA_BASE_EGR = TIMER_DCR_DBA_EGR, - /** Base is capture/compare mode register 1 */ - TIMER_DMA_BASE_CCMR1 = TIMER_DCR_DBA_CCMR1, - /** Base is capture/compare mode register 2 */ - TIMER_DMA_BASE_CCMR2 = TIMER_DCR_DBA_CCMR2, - /** Base is capture/compare enable register */ - TIMER_DMA_BASE_CCER = TIMER_DCR_DBA_CCER, - /** Base is counter */ - TIMER_DMA_BASE_CNT = TIMER_DCR_DBA_CNT, - /** Base is prescaler */ - TIMER_DMA_BASE_PSC = TIMER_DCR_DBA_PSC, - /** Base is auto-reload register */ - TIMER_DMA_BASE_ARR = TIMER_DCR_DBA_ARR, - /** Base is repetition counter register */ - TIMER_DMA_BASE_RCR = TIMER_DCR_DBA_RCR, - /** Base is capture/compare register 1 */ - TIMER_DMA_BASE_CCR1 = TIMER_DCR_DBA_CCR1, - /** Base is capture/compare register 2 */ - TIMER_DMA_BASE_CCR2 = TIMER_DCR_DBA_CCR2, - /** Base is capture/compare register 3 */ - TIMER_DMA_BASE_CCR3 = TIMER_DCR_DBA_CCR3, - /** Base is capture/compare register 4 */ - TIMER_DMA_BASE_CCR4 = TIMER_DCR_DBA_CCR4, - /** Base is break and dead-time register */ - TIMER_DMA_BASE_BDTR = TIMER_DCR_DBA_BDTR, - /** Base is DMA control register */ - TIMER_DMA_BASE_DCR = TIMER_DCR_DBA_DCR, - /** Base is DMA address for full transfer */ - TIMER_DMA_BASE_DMAR = TIMER_DCR_DBA_DMAR, -} timer_dma_base_addr; - -/** - * @brief Get the timer's DMA base address. - * - * Some restrictions apply; see the reference manual for your chip. - * - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @return DMA base address - */ -static inline timer_dma_base_addr timer_dma_get_base_addr(timer_dev *dev) { - uint32 dcr = (dev->regs).gen->DCR; - return (timer_dma_base_addr)(dcr & TIMER_DCR_DBA); -} - -/** - * @brief Set the timer's DMA base address. - * - * Some restrictions apply; see the reference manual for your chip. - * - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param dma_base DMA base address. - */ -static inline void timer_dma_set_base_addr(timer_dev *dev, - timer_dma_base_addr dma_base) { - uint32 tmp = (dev->regs).gen->DCR; - tmp &= ~TIMER_DCR_DBA; - tmp |= dma_base; - (dev->regs).gen->DCR = tmp; -} - -/** - * Timer output compare modes. - */ -typedef enum timer_oc_mode { - /** - * Frozen: comparison between output compare register and counter - * has no effect on the outputs. */ - TIMER_OC_MODE_FROZEN = 0 << 4, - /** - * OCxREF signal is forced high when the count matches the channel - * capture/compare register. */ - TIMER_OC_MODE_ACTIVE_ON_MATCH = 1 << 4, - /** - * OCxREF signal is forced low when the counter matches the - * channel capture/compare register. */ - TIMER_OC_MODE_INACTIVE_ON_MATCH = 2 << 4, - /** - * OCxREF toggles when counter matches the channel capture/compare - * register. */ - TIMER_OC_MODE_TOGGLE = 3 << 4, - /** OCxREF is forced low. */ - TIMER_OC_MODE_FORCE_INACTIVE = 4 << 4, - /** OCxREF is forced high. */ - TIMER_OC_MODE_FORCE_ACTIVE = 5 << 4, - /** - * PWM mode 1. In upcounting, channel is active as long as count - * is less than channel capture/compare register, else inactive. - * In downcounting, channel is inactive as long as count exceeds - * capture/compare register, else active. */ - TIMER_OC_MODE_PWM_1 = 6 << 4, - /** - * PWM mode 2. In upcounting, channel is inactive as long as count - * is less than capture/compare register, else active. In - * downcounting, channel is active as long as count exceeds - * capture/compare register, else inactive. */ - TIMER_OC_MODE_PWM_2 = 7 << 4, -} timer_oc_mode; - -/** - * Timer output compare mode flags. - * @see timer_oc_set_mode() - */ -typedef enum timer_oc_mode_flags { - TIMER_OC_CE = 1U << 7, /**< Output compare clear enable. */ - TIMER_OC_PE = 1U << 3, /**< Output compare preload enable. */ - TIMER_OC_FE = 1U << 2, /**< Output compare fast enable. */ -} timer_oc_mode_flags; - -/** - * @brief Configure a channel's output compare mode. - * - * @param dev Timer device, must have type TIMER_ADVANCED or TIMER_GENERAL. - * @param channel Channel to configure in output compare mode. - * @param mode Timer mode to set. - * @param flags OR of timer_oc_mode_flags. - * @see timer_oc_mode - * @see timer_oc_mode_flags - */ -static inline void timer_oc_set_mode(timer_dev *dev, - uint8 channel, - timer_oc_mode mode, - uint8 flags) { - /* channel == 1,2 -> CCMR1; channel == 3,4 -> CCMR2 */ - __io uint32 *ccmr = &(dev->regs).gen->CCMR1 + (((channel - 1) >> 1) & 1); - /* channel == 1,3 -> shift = 0, channel == 2,4 -> shift = 8 */ - uint8 shift = 8 * (1 - (channel & 1)); - - uint32 tmp = *ccmr; - tmp &= ~(0xFF << shift); - tmp |= (mode | flags | TIMER_CCMR_CCS_OUTPUT) << shift; - *ccmr = tmp; -} - -/* - * Old, erroneous bit definitions from previous releases, kept for - * backwards compatibility: - */ - -/** Deprecated. Use TIMER_CCMR1_CC4S_OUTPUT instead. */ -#define TIMER_CCMR1_CC4S_OUTPUT TIMER_CCMR2_CC4S_OUTPUT -/** Deprecated. Use TIMER_CCMR1_CC4S_INPUT_TI1 instead. */ -#define TIMER_CCMR1_CC4S_INPUT_TI1 TIMER_CCMR2_CC4S_INPUT_TI1 -/** Deprecated. Use TIMER_CCMR1_CC4S_INPUT_TI2 instead. */ -#define TIMER_CCMR1_CC4S_INPUT_TI2 TIMER_CCMR2_CC4S_INPUT_TI2 -/** Deprecated. Use TIMER_CCMR1_CC4S_INPUT_TRC instead. */ -#define TIMER_CCMR1_CC4S_INPUT_TRC TIMER_CCMR2_CC4S_INPUT_TRC -/** Deprecated. Use TIMER_CCMR2_IC4F instead. */ -#define TIMER_CCMR2_IC2F TIMER_CCMR2_IC4F -/** Deprecated. Use TIMER_CCMR2_IC4PSC instead. */ -#define TIMER_CCMR2_IC2PSC TIMER_CCMR2_IC4PSC -/** Deprecated. Use TIMER_CCMR2_IC3F instead. */ -#define TIMER_CCMR2_IC1F TIMER_CCMR2_IC3F -/** Deprecated. Use TIMER_CCMR2_IC3PSC instead. */ -#define TIMER_CCMR2_IC1PSC TIMER_CCMR2_IC3PSC -/** Deprecated. Use TIMER_CCMR1_CC3S_OUTPUT instead. */ -#define TIMER_CCMR1_CC3S_OUTPUT TIMER_CCMR2_CC3S_OUTPUT -/** Deprecated. Use TIMER_CCMR1_CC3S_INPUT_TI1 instead. */ -#define TIMER_CCMR1_CC3S_INPUT_TI1 TIMER_CCMR2_CC3S_INPUT_TI1 -/** Deprecated. Use TIMER_CCMR1_CC3S_INPUT_TI2 instead. */ -#define TIMER_CCMR1_CC3S_INPUT_TI2 TIMER_CCMR2_CC3S_INPUT_TI2 -/** Deprecated. Use TIMER_CCMR1_CC3S_INPUT_TRC instead. */ -#define TIMER_CCMR1_CC3S_INPUT_TRC TIMER_CCMR2_CC3S_INPUT_TRC - -/** Deprecated. Use TIMER_DCR_DBL_1_XFER instead. */ -#define TIMER_DCR_DBL_1BYTE TIMER_DCR_DBL_1_XFER -/** Deprecated. Use TIMER_DCR_DBL_2_XFER instead. */ -#define TIMER_DCR_DBL_2BYTE TIMER_DCR_DBL_2_XFER -/** Deprecated. Use TIMER_DCR_DBL_3_XFER instead. */ -#define TIMER_DCR_DBL_3BYTE TIMER_DCR_DBL_3_XFER -/** Deprecated. Use TIMER_DCR_DBL_4_XFER instead. */ -#define TIMER_DCR_DBL_4BYTE TIMER_DCR_DBL_4_XFER -/** Deprecated. Use TIMER_DCR_DBL_5_XFER instead. */ -#define TIMER_DCR_DBL_5BYTE TIMER_DCR_DBL_5_XFER -/** Deprecated. Use TIMER_DCR_DBL_6_XFER instead. */ -#define TIMER_DCR_DBL_6BYTE TIMER_DCR_DBL_6_XFER -/** Deprecated. Use TIMER_DCR_DBL_7_XFER instead. */ -#define TIMER_DCR_DBL_7BYTE TIMER_DCR_DBL_7_XFER -/** Deprecated. Use TIMER_DCR_DBL_8_XFER instead. */ -#define TIMER_DCR_DBL_8BYTE TIMER_DCR_DBL_8_XFER -/** Deprecated. Use TIMER_DCR_DBL_9_XFER instead. */ -#define TIMER_DCR_DBL_9BYTE TIMER_DCR_DBL_9_XFER -/** Deprecated. Use TIMER_DCR_DBL_10_XFER instead. */ -#define TIMER_DCR_DBL_10BYTE TIMER_DCR_DBL_10_XFER -/** Deprecated. Use TIMER_DCR_DBL_11_XFER instead. */ -#define TIMER_DCR_DBL_11BYTE TIMER_DCR_DBL_11_XFER -/** Deprecated. Use TIMER_DCR_DBL_12_XFER instead. */ -#define TIMER_DCR_DBL_12BYTE TIMER_DCR_DBL_12_XFER -/** Deprecated. Use TIMER_DCR_DBL_13_XFER instead. */ -#define TIMER_DCR_DBL_13BYTE TIMER_DCR_DBL_13_XFER -/** Deprecated. Use TIMER_DCR_DBL_14_XFER instead. */ -#define TIMER_DCR_DBL_14BYTE TIMER_DCR_DBL_14_XFER -/** Deprecated. Use TIMER_DCR_DBL_15_XFER instead. */ -#define TIMER_DCR_DBL_15BYTE TIMER_DCR_DBL_15_XFER -/** Deprecated. Use TIMER_DCR_DBL_16_XFER instead. */ -#define TIMER_DCR_DBL_16BYTE TIMER_DCR_DBL_16_XFER -/** Deprecated. Use TIMER_DCR_DBL_17_XFER instead. */ -#define TIMER_DCR_DBL_17BYTE TIMER_DCR_DBL_17_XFER -/** Deprecated. Use TIMER_DCR_DBL_18_XFER instead. */ -#define TIMER_DCR_DBL_18BYTE TIMER_DCR_DBL_18_XFER - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/usart.h b/GD32F1/system/libmaple/include/libmaple/usart.h deleted file mode 100644 index c85980c..0000000 --- a/GD32F1/system/libmaple/include/libmaple/usart.h +++ /dev/null @@ -1,509 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/usart.h - * @author Marti Bolivar , - * Perry Hung - * @brief USART definitions and prototypes - */ - -#ifndef _LIBMAPLE_USART_H_ -#define _LIBMAPLE_USART_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include -#include -#include -#include - - /* Roger clark. Replaced with line below #include */ -#include "stm32f1/include/series/usart.h" - -/* - * Register map (common across supported STM32 series). - */ - -/** USART register map type */ -typedef struct usart_reg_map { - __io uint32 SR; /**< Status register */ - __io uint32 DR; /**< Data register */ - __io uint32 BRR; /**< Baud rate register */ - __io uint32 CR1; /**< Control register 1 */ - __io uint32 CR2; /**< Control register 2 */ - __io uint32 CR3; /**< Control register 3 */ - __io uint32 GTPR; /**< Guard time and prescaler register */ -} usart_reg_map; - -/* - * Register bit definitions - */ - -/* Status register */ - -/** Clear to send bit */ -#define USART_SR_CTS_BIT 9 -/** Line break detection bit */ -#define USART_SR_LBD_BIT 8 -/** Transmit data register empty bit */ -#define USART_SR_TXE_BIT 7 -/** Transmission complete bit */ -#define USART_SR_TC_BIT 6 -/** Read data register not empty bit */ -#define USART_SR_RXNE_BIT 5 -/** IDLE line detected bit */ -#define USART_SR_IDLE_BIT 4 -/** Overrun error bit */ -#define USART_SR_ORE_BIT 3 -/** Noise error bit */ -#define USART_SR_NE_BIT 2 -/** - * @brief Synonym for USART_SR_NE_BIT. - * - * Some series (e.g. STM32F2) use "NF" for "noise flag" instead of the - * original "NE" for "noise error". The meaning of the bit is - * unchanged, but the NF flag can be disabled when the line is - * noise-free. - * - * @see USART_SR_NE_BIT - */ -#define USART_SR_NF_BIT USART_SR_NE_BIT -/** Framing error bit */ -#define USART_SR_FE_BIT 1 -/** Parity error bit */ -#define USART_SR_PE_BIT 0 - -/** Clear to send mask */ -#define USART_SR_CTS BIT(USART_SR_CTS_BIT) -/** Line break detected mask */ -#define USART_SR_LBD BIT(USART_SR_LBD_BIT) -/** Transmit data register empty mask */ -#define USART_SR_TXE BIT(USART_SR_TXE_BIT) -/** Transmission complete mask */ -#define USART_SR_TC BIT(USART_SR_TC_BIT) -/** Read data register not empty mask */ -#define USART_SR_RXNE BIT(USART_SR_RXNE_BIT) -/** IDLE line detected mask */ -#define USART_SR_IDLE BIT(USART_SR_IDLE_BIT) -/** Overrun error mask */ -#define USART_SR_ORE BIT(USART_SR_ORE_BIT) -/** Noise error mask */ -#define USART_SR_NE BIT(USART_SR_NE_BIT) -/** - * @brief Synonym for USART_SR_NE. - * @see USART_SR_NF_BIT - */ -#define USART_SR_NF USART_SR_NE -/** Framing error mask */ -#define USART_SR_FE BIT(USART_SR_FE_BIT) -/** Parity error mask */ -#define USART_SR_PE BIT(USART_SR_PE_BIT) - -/* Data register */ - -/** Data register data value mask */ -#define USART_DR_DR 0xFF - -/* Baud rate register */ - -/** Mantissa of USARTDIV mask */ -#define USART_BRR_DIV_MANTISSA (0xFFF << 4) -/** Fraction of USARTDIV mask */ -#define USART_BRR_DIV_FRACTION 0xF - -/* Control register 1 */ - -/** USART enable bit */ -#define USART_CR1_UE_BIT 13 -/** Word length bit */ -#define USART_CR1_M_BIT 12 -/** Wakeup method bit */ -#define USART_CR1_WAKE_BIT 11 -/** Parity control enable bit */ -#define USART_CR1_PCE_BIT 10 -/** Parity selection bit */ -#define USART_CR1_PS_BIT 9 -/** Parity error interrupt enable bit */ -#define USART_CR1_PEIE_BIT 8 -/** Transmit data regsiter not empty interrupt enable bit */ -#define USART_CR1_TXEIE_BIT 7 -/** Transmission complete interrupt enable bit */ -#define USART_CR1_TCIE_BIT 6 -/** RXNE interrupt enable bit */ -#define USART_CR1_RXNEIE_BIT 5 -/** IDLE interrupt enable bit */ -#define USART_CR1_IDLEIE_BIT 4 -/** Transmitter enable bit */ -#define USART_CR1_TE_BIT 3 -/** Receiver enable bit */ -#define USART_CR1_RE_BIT 2 -/** Receiver wakeup bit */ -#define USART_CR1_RWU_BIT 1 -/** Send break bit */ -#define USART_CR1_SBK_BIT 0 - -/** USART enable mask */ -#define USART_CR1_UE BIT(USART_CR1_UE_BIT) -/** Word length mask */ -#define USART_CR1_M BIT(USART_CR1_M_BIT) -/** Word length: 1 start bit, 8 data bits, n stop bit */ -#define USART_CR1_M_8N1 (0 << USART_CR1_M_BIT) -/** Word length: 1 start bit, 9 data bits, n stop bit */ -#define USART_CR1_M_9N1 (1 << USART_CR1_M_BIT) -/** Wakeup method mask */ -#define USART_CR1_WAKE BIT(USART_CR1_WAKE_BIT) -/** Wakeup on idle line */ -#define USART_CR1_WAKE_IDLE (0 << USART_CR1_WAKE_BIT) -/** Wakeup on address mark */ -#define USART_CR1_WAKE_ADDR (1 << USART_CR1_WAKE_BIT) -/** Parity control enable mask */ -#define USART_CR1_PCE BIT(USART_CR1_PCE_BIT) -/** Parity selection mask */ -#define USART_CR1_PS BIT(USART_CR1_PS_BIT) -/** Parity selection: even parity */ -#define USART_CR1_PS_EVEN (0 << USART_CR1_PS_BIT) -/** Parity selection: odd parity */ -#define USART_CR1_PS_ODD (1 << USART_CR1_PS_BIT) -/** Parity error interrupt enable mask */ -#define USART_CR1_PEIE BIT(USART_CR1_PEIE_BIT) -/** Transmit data register empty interrupt enable mask */ -#define USART_CR1_TXEIE BIT(USART_CR1_TXEIE_BIT) -/** Transmission complete interrupt enable mask */ -#define USART_CR1_TCIE BIT(USART_CR1_TCIE_BIT) -/** RXNE interrupt enable mask */ -#define USART_CR1_RXNEIE BIT(USART_CR1_RXNEIE_BIT) -/** IDLE line interrupt enable mask */ -#define USART_CR1_IDLEIE BIT(USART_CR1_IDLEIE_BIT) -/** Transmitter enable mask */ -#define USART_CR1_TE BIT(USART_CR1_TE_BIT) -/** Receiver enable mask */ -#define USART_CR1_RE BIT(USART_CR1_RE_BIT) -/** Receiver wakeup mask */ -#define USART_CR1_RWU BIT(USART_CR1_RWU_BIT) -/** Receiver wakeup: receiver in active mode */ -#define USART_CR1_RWU_ACTIVE (0 << USART_CR1_RWU_BIT) -/** Receiver wakeup: receiver in mute mode */ -#define USART_CR1_RWU_MUTE (1 << USART_CR1_RWU_BIT) -/** Send break */ -#define USART_CR1_SBK BIT(USART_CR1_SBK_BIT) - -/* Control register 2 */ - -/** LIN mode enable bit */ -#define USART_CR2_LINEN_BIT 14 -/** Clock enable bit */ -#define USART_CR2_CLKEN_BIT 11 -/** Clock polarity bit */ -#define USART_CR2_CPOL_BIT 10 -/** Clock phase bit */ -#define USART_CR2_CPHA_BIT 9 -/** Last bit clock pulse bit */ -#define USART_CR2_LBCL_BIT 8 -/** LIN break detection interrupt enable bit */ -#define USART_CR2_LBDIE_BIT 6 -/** LIN break detection length bit */ -#define USART_CR2_LBDL_BIT 5 - -/** LIN mode enable mask */ -#define USART_CR2_LINEN BIT(USART_CR2_LINEN_BIT) -/** STOP bits mask */ -#define USART_CR2_STOP (0x3 << 12) -/** STOP bits: 1 stop bit */ -#define USART_CR2_STOP_BITS_1 (0x0 << 12) -/** - * @brief STOP bits: 0.5 stop bits - * Not available on UART4, UART5. */ -#define USART_CR2_STOP_BITS_POINT_5 (0x1 << 12) -/** STOP bits: 2 stop bits */ -#define USART_CR2_STOP_BITS_2 (0x2 << 12) -/** - * @brief STOP bits: 1.5 stop bits - * Not available on UART4, UART5. */ -#define USART_CR2_STOP_BITS_1_POINT_5 (0x3 << 12) -/** - * @brief Clock enable. - * Not available on UART4, UART5 */ -#define USART_CR2_CLKEN BIT(USART_CR2_CLKEN_BIT) -/** - * @brief Clock polarity mask. - * Not available on UART4, UART5 */ -#define USART_CR2_CPOL BIT(USART_CR2_CPOL_BIT) -/** Clock polarity: low */ -#define USART_CR2_CPOL_LOW (0x0 << USART_CR2_CLKEN_BIT) -/** Clock polarity: high */ -#define USART_CR2_CPOL_HIGH (0x1 << USART_CR2_CLKEN_BIT) -/** - * @brief Clock phase mask. - * Not available on UART4, UART5 */ -#define USART_CR2_CPHA BIT(USART_CR2_CPHA_BIT) -/** - * @brief Clock phase: first - * First clock transition is the first data capture edge. */ -#define USART_CR2_CPHA_FIRST (0x0 << USART_CR2_CPHA_BIT) -/** - * @brief Clock phase: second - * Second clock transition is the first data capture edge. */ -#define USART_CR2_CPHA_SECOND (0x1 << USART_CR2_CPHA_BIT) -/** - * @brief Last bit clock pulse mask. - * - * When set, the last bit transmitted causes a clock pulse in - * synchronous mode. - * - * Not available on UART4, UART5 */ -#define USART_CR2_LBCL BIT(USART_CR2_LBCL_BIT) -/** LIN break detection interrupt enable mask. */ -#define USART_CR2_LBDIE BIT(USART_CR2_LBDIE_BIT) -/** LIN break detection length. */ -#define USART_CR2_LBDL BIT(USART_CR2_LBDL_BIT) -/** LIN break detection length: 10 bits */ -#define USART_CR2_LBDL_10_BIT (0 << USART_CR2_LBDL_BIT) -/** LIN break detection length: 11 bits */ -#define USART_CR2_LBDL_11_BIT (1 << USART_CR2_LBDL_BIT) -/** - * @brief Address of the USART node - * This is useful during multiprocessor communication. */ -#define USART_CR2_ADD 0xF - -/* Control register 3 */ - -/** Clear to send interrupt enable bit */ -#define USART_CR3_CTSIE_BIT 10 -/** Clear to send enable bit */ -#define USART_CR3_CTSE_BIT 9 -/** Ready to send enable bit */ -#define USART_CR3_RTSE_BIT 8 -/** DMA enable transmitter bit */ -#define USART_CR3_DMAT_BIT 7 -/** DMA enable receiver bit */ -#define USART_CR3_DMAR_BIT 6 -/** Smartcard mode enable bit */ -#define USART_CR3_SCEN_BIT 5 -/** Smartcard NACK enable bit */ -#define USART_CR3_NACK_BIT 4 -/** Half-duplex selection bit */ -#define USART_CR3_HDSEL_BIT 3 -/** IrDA low power bit */ -#define USART_CR3_IRLP_BIT 2 -/** IrDA mode enable bit */ -#define USART_CR3_IREN_BIT 1 -/** Error interrupt enable bit */ -#define USART_CR3_EIE_BIT 0 - -/** - * @brief Clear to send interrupt enable - * Not available on UART4, UART5. */ -#define USART_CR3_CTSIE BIT(USART_CR3_CTSIE_BIT) -/** - * @brief Clear to send enable - * Not available on UART4, UART5. */ -#define USART_CR3_CTSE BIT(USART_CR3_CTSE_BIT) -/** - * @brief Ready to send enable - * Not available on UART4, UART5. */ -#define USART_CR3_RTSE BIT(USART_CR3_RTSE_BIT) -/** - * @brief DMA enable transmitter - * Not available on UART5. */ -#define USART_CR3_DMAT BIT(USART_CR3_DMAT_BIT) -/** - * @brief DMA enable receiver - * Not available on UART5. */ -#define USART_CR3_DMAR BIT(USART_CR3_DMAR_BIT) -/** - * @brief Smartcard mode enable - * Not available on UART4, UART5. */ -#define USART_CR3_SCEN BIT(USART_CR3_SCEN_BIT) -/** - * @brief Smartcard NACK enable - * Not available on UART4, UART5. */ -#define USART_CR3_NACK BIT(USART_CR3_NACK_BIT) -/** - * @brief Half-duplex selection - * When set, single-wire half duplex mode is selected. - */ -#define USART_CR3_HDSEL BIT(USART_CR3_HDSEL_BIT) -/** IrDA low power mode */ -#define USART_CR3_IRLP BIT(USART_CR3_IRLP_BIT) -/** IrDA mode: normal */ -#define USART_CR3_IRLP_NORMAL (0U << USART_CR3_IRLP_BIT) -/** IrDA mode: low power */ -#define USART_CR3_IRLP_LOW_POWER (1U << USART_CR3_IRLP_BIT) -/** IrDA mode enable */ -#define USART_CR3_IREN BIT(USART_CR3_IREN_BIT) -/** Error interrupt enable */ -#define USART_CR3_EIE BIT(USART_CR3_EIE_BIT) - -/* Guard time and prescaler register */ - -/** - * @brief Guard time value mask - * Used in Smartcard mode. Not available on UART4, UART5. */ -#define USART_GTPR_GT (0xFF << 8) -/** - * @brief Prescaler value mask - * Restrictions on this value apply, depending on the USART mode. Not - * available on UART4, UART5. */ -#define USART_GTPR_PSC 0xFF - -/* - * Devices - */ - -#ifndef USART_RX_BUF_SIZE -#define USART_RX_BUF_SIZE 64 -#endif - -/** USART device type */ -typedef struct usart_dev { - usart_reg_map *regs; /**< Register map */ - ring_buffer *rb; /**< RX ring buffer */ - uint32 max_baud; /**< @brief Deprecated. - * Maximum baud rate. */ - uint8 rx_buf[USART_RX_BUF_SIZE]; /**< @brief Deprecated. - * Actual RX buffer used by rb. - * This field will be removed in - * a future release. */ - rcc_clk_id clk_id; /**< RCC clock information */ - nvic_irq_num irq_num; /**< USART NVIC interrupt */ -} usart_dev; - -void usart_init(usart_dev *dev); - -struct gpio_dev; /* forward declaration */ -/* FIXME [PRE 0.0.13] decide if flags are necessary */ -/** - * @brief Configure GPIOs for use as USART TX/RX. - * @param udev USART device to use - * @param rx_dev RX pin gpio_dev - * @param rx RX pin bit on rx_dev - * @param tx_dev TX pin gpio_dev - * @param tx TX pin bit on tx_dev - * @param flags Currently ignored - */ -extern void usart_config_gpios_async(usart_dev *udev, - struct gpio_dev *rx_dev, uint8 rx, - struct gpio_dev *tx_dev, uint8 tx, - unsigned flags); - -#define USART_USE_PCLK 0 -void usart_set_baud_rate(usart_dev *dev, uint32 clock_speed, uint32 baud); - -void usart_enable(usart_dev *dev); -void usart_disable(usart_dev *dev); -void usart_foreach(void (*fn)(usart_dev *dev)); -uint32 usart_tx(usart_dev *dev, const uint8 *buf, uint32 len); -uint32 usart_rx(usart_dev *dev, uint8 *buf, uint32 len); -void usart_putudec(usart_dev *dev, uint32 val); - -/** - * @brief Disable all serial ports. - */ -static inline void usart_disable_all(void) { - usart_foreach(usart_disable); -} - -/** - * @brief Transmit one character on a serial port. - * - * This function blocks until the character has been successfully - * transmitted. - * - * @param dev Serial port to send on. - * @param byte Byte to transmit. - */ -static inline void usart_putc(usart_dev* dev, uint8 byte) { - while (!usart_tx(dev, &byte, 1)) - ; -} - -/** - * @brief Transmit a character string on a serial port. - * - * This function blocks until str is completely transmitted. - * - * @param dev Serial port to send on - * @param str String to send - */ -static inline void usart_putstr(usart_dev *dev, const char* str) { - uint32 i = 0; - while (str[i] != '\0') { - usart_putc(dev, str[i++]); - } -} - -/** - * @brief Read one character from a serial port. - * - * It's not safe to call this function if the serial port has no data - * available. - * - * @param dev Serial port to read from - * @return byte read - * @see usart_data_available() - */ -static inline uint8 usart_getc(usart_dev *dev) { - return rb_remove(dev->rb); -} - -/* - * Roger Clark. 20141125, - * added peek function. - * @param dev Serial port to read from - * @return byte read - */ -static inline int usart_peek(usart_dev *dev) -{ - return rb_peek(dev->rb); -} - - -/** - * @brief Return the amount of data available in a serial port's RX buffer. - * @param dev Serial port to check - * @return Number of bytes in dev's RX buffer. - */ -static inline uint32 usart_data_available(usart_dev *dev) { - return rb_full_count(dev->rb); -} - -/** - * @brief Discard the contents of a serial port's RX buffer. - * @param dev Serial port whose buffer to empty. - */ -static inline void usart_reset_rx(usart_dev *dev) { - rb_reset(dev->rb); -} - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/usb.h b/GD32F1/system/libmaple/include/libmaple/usb.h deleted file mode 100644 index ea24030..0000000 --- a/GD32F1/system/libmaple/include/libmaple/usb.h +++ /dev/null @@ -1,176 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010, 2011, 2012 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* - * NOTE: This API is _unstable_ and will change drastically over time. - */ - -#ifndef _LIBMAPLE_USB_H_ -#define _LIBMAPLE_USB_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* - * Descriptors and other paraphernalia - */ - -/* Descriptor types */ - -#define USB_DESCRIPTOR_TYPE_DEVICE 0x01 -#define USB_DESCRIPTOR_TYPE_CONFIGURATION 0x02 -#define USB_DESCRIPTOR_TYPE_STRING 0x03 -#define USB_DESCRIPTOR_TYPE_INTERFACE 0x04 -#define USB_DESCRIPTOR_TYPE_ENDPOINT 0x05 - -/* Descriptor structs and declaration helpers */ - -#define USB_DESCRIPTOR_STRING_LEN(x) (2 + (x << 1)) - -#define USB_DESCRIPTOR_STRING(len) \ - struct { \ - uint8 bLength; \ - uint8 bDescriptorType; \ - uint16 bString[len]; \ - } __packed - -typedef struct usb_descriptor_device { - uint8 bLength; - uint8 bDescriptorType; - uint16 bcdUSB; - uint8 bDeviceClass; - uint8 bDeviceSubClass; - uint8 bDeviceProtocol; - uint8 bMaxPacketSize0; - uint16 idVendor; - uint16 idProduct; - uint16 bcdDevice; - uint8 iManufacturer; - uint8 iProduct; - uint8 iSerialNumber; - uint8 bNumConfigurations; -} __packed usb_descriptor_device; - -typedef struct usb_descriptor_config_header { - uint8 bLength; - uint8 bDescriptorType; - uint16 wTotalLength; - uint8 bNumInterfaces; - uint8 bConfigurationValue; - uint8 iConfiguration; - uint8 bmAttributes; - uint8 bMaxPower; -} __packed usb_descriptor_config_header; - -typedef struct usb_descriptor_interface { - uint8 bLength; - uint8 bDescriptorType; - uint8 bInterfaceNumber; - uint8 bAlternateSetting; - uint8 bNumEndpoints; - uint8 bInterfaceClass; - uint8 bInterfaceSubClass; - uint8 bInterfaceProtocol; - uint8 iInterface; -} __packed usb_descriptor_interface; - -typedef struct usb_descriptor_endpoint { - uint8 bLength; - uint8 bDescriptorType; - uint8 bEndpointAddress; - uint8 bmAttributes; - uint16 wMaxPacketSize; - uint8 bInterval; -} __packed usb_descriptor_endpoint; - -typedef struct usb_descriptor_string { - uint8 bLength; - uint8 bDescriptorType; - uint8 bString[]; -} usb_descriptor_string; - -/* Common values that go inside descriptors */ - -#define USB_CONFIG_ATTR_BUSPOWERED 0b10000000 -#define USB_CONFIG_ATTR_SELF_POWERED 0b11000000 - -#define USB_EP_TYPE_INTERRUPT 0x03 -#define USB_EP_TYPE_BULK 0x02 - -#define USB_DESCRIPTOR_ENDPOINT_IN 0x80 -#define USB_DESCRIPTOR_ENDPOINT_OUT 0x00 - -/* - * USB module core - */ - -#ifndef USB_ISR_MSK -/* Handle CTRM, WKUPM, SUSPM, ERRM, SOFM, ESOFM, RESETM */ -#define USB_ISR_MSK 0xBF00 -#endif - -typedef enum usb_dev_state { - USB_UNCONNECTED, - USB_ATTACHED, - USB_POWERED, - USB_SUSPENDED, - USB_ADDRESSED, - USB_CONFIGURED -} usb_dev_state; - -/* Encapsulates global state formerly handled by usb_lib/ */ -typedef struct usblib_dev { - uint32 irq_mask; - void (**ep_int_in)(void); - void (**ep_int_out)(void); - usb_dev_state state; - usb_dev_state prevState; - rcc_clk_id clk_id; -} usblib_dev; - -extern usblib_dev *USBLIB; - -void usb_init_usblib(usblib_dev *dev, - void (**ep_int_in)(void), - void (**ep_int_out)(void)); - -static inline uint8 usb_is_connected(usblib_dev *dev) { - return dev->state != USB_UNCONNECTED; -} - -static inline uint8 usb_is_configured(usblib_dev *dev) { - return dev->state == USB_CONFIGURED; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/usb_cdcacm.h b/GD32F1/system/libmaple/include/libmaple/usb_cdcacm.h deleted file mode 100644 index 13e1bac..0000000 --- a/GD32F1/system/libmaple/include/libmaple/usb_cdcacm.h +++ /dev/null @@ -1,180 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/usb_cdcacm.h - * @brief USB CDC ACM (virtual serial terminal) support - * - * IMPORTANT: this API is unstable, and may change without notice. - */ - -#ifndef _LIBMAPLE_USB_CDCACM_H_ -#define _LIBMAPLE_USB_CDCACM_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * CDC ACM Requests - */ - -#define USB_CDCACM_SET_LINE_CODING 0x20 -#define USB_CDCACM_GET_LINE_CODING 0x21 -#define USB_CDCACM_SET_COMM_FEATURE 0x02 -#define USB_CDCACM_SET_CONTROL_LINE_STATE 0x22 -#define USB_CDCACM_CONTROL_LINE_DTR (0x01) -#define USB_CDCACM_CONTROL_LINE_RTS (0x02) - -/* - * Descriptors, etc. - */ - -#define CDC_FUNCTIONAL_DESCRIPTOR_SIZE(DataSize) (3 + DataSize) -#define CDC_FUNCTIONAL_DESCRIPTOR(DataSize) \ - struct { \ - uint8 bLength; \ - uint8 bDescriptorType; \ - uint8 SubType; \ - uint8 Data[DataSize]; \ - } __packed - -#define USB_DEVICE_CLASS_CDC 0x02 -#define USB_DEVICE_SUBCLASS_CDC 0x00 -#define USB_INTERFACE_CLASS_CDC 0x02 -#define USB_INTERFACE_SUBCLASS_CDC_ACM 0x02 -#define USB_INTERFACE_CLASS_DIC 0x0A - -/* - * Endpoint configuration - */ - -#define USB_CDCACM_CTRL_ENDP 0 -#define USB_CDCACM_CTRL_RX_ADDR 0x40 -#define USB_CDCACM_CTRL_TX_ADDR 0x80 -#define USB_CDCACM_CTRL_EPSIZE 0x40 - -#define USB_CDCACM_TX_ENDP 1 -#define USB_CDCACM_TX_ADDR 0xC0 -#define USB_CDCACM_TX_EPSIZE 0x40 - -#define USB_CDCACM_MANAGEMENT_ENDP 2 -#define USB_CDCACM_MANAGEMENT_ADDR 0x100 -#define USB_CDCACM_MANAGEMENT_EPSIZE 0x40 - -#define USB_CDCACM_RX_ENDP 3 -#define USB_CDCACM_RX_ADDR 0x110 -#define USB_CDCACM_RX_EPSIZE 0x40 - -#ifndef __cplusplus -#define USB_CDCACM_DECLARE_DEV_DESC(vid, pid) \ - { \ - .bLength = sizeof(usb_descriptor_device), \ - .bDescriptorType = USB_DESCRIPTOR_TYPE_DEVICE, \ - .bcdUSB = 0x0200, \ - .bDeviceClass = USB_DEVICE_CLASS_CDC, \ - .bDeviceSubClass = USB_DEVICE_SUBCLASS_CDC, \ - .bDeviceProtocol = 0x00, \ - .bMaxPacketSize0 = 0x40, \ - .idVendor = vid, \ - .idProduct = pid, \ - .bcdDevice = 0x0200, \ - .iManufacturer = 0x01, \ - .iProduct = 0x02, \ - .iSerialNumber = 0x00, \ - .bNumConfigurations = 0x01, \ - } -#endif - -/* - * CDC ACM interface - */ - -void usb_cdcacm_enable(gpio_dev*, uint8); -void usb_cdcacm_disable(gpio_dev*, uint8); - -void usb_cdcacm_putc(char ch); -uint32 usb_cdcacm_tx(const uint8* buf, uint32 len); -uint32 usb_cdcacm_rx(uint8* buf, uint32 len); -uint32 usb_cdcacm_peek(uint8* buf, uint32 len); -uint32 usb_cdcacm_peek_ex(uint8* buf, uint32 offset, uint32 len); - -uint32 usb_cdcacm_data_available(void); /* in RX buffer */ -uint16 usb_cdcacm_get_pending(void); -uint8 usb_cdcacm_is_transmitting(void); - -uint8 usb_cdcacm_get_dtr(void); -uint8 usb_cdcacm_get_rts(void); - -typedef struct usb_cdcacm_line_coding { - uint32 dwDTERate; /* Baud rate */ - -#define USB_CDCACM_STOP_BITS_1 0 -#define USB_CDCACM_STOP_BITS_1_5 1 -#define USB_CDCACM_STOP_BITS_2 2 - uint8 bCharFormat; /* Stop bits */ - -#define USB_CDCACM_PARITY_NONE 0 -#define USB_CDCACM_PARITY_ODD 1 -#define USB_CDCACM_PARITY_EVEN 2 -#define USB_CDCACM_PARITY_MARK 3 -#define USB_CDCACM_PARITY_SPACE 4 - uint8 bParityType; /* Parity type */ - - uint8 bDataBits; /* Data bits: 5, 6, 7, 8, or 16 */ -} __packed usb_cdcacm_line_coding; - -/* Retrieve a copy of the current line coding structure. */ -void usb_cdcacm_get_line_coding(usb_cdcacm_line_coding*); - -/* Line coding conveniences. */ -int usb_cdcacm_get_baud(void); /* dwDTERate */ -int usb_cdcacm_get_stop_bits(void); /* bCharFormat */ -int usb_cdcacm_get_parity(void); /* bParityType */ -int usb_cdcacm_get_n_data_bits(void); /* bDataBits */ - -/* - * Hack: hooks for bootloader reset signalling - */ - -#define USB_CDCACM_HOOK_RX 0x1 -#define USB_CDCACM_HOOK_IFACE_SETUP 0x2 - -void usb_cdcacm_set_hooks(unsigned hook_flags, void (*hook)(unsigned, void*)); - -static __always_inline void usb_cdcacm_remove_hooks(unsigned hook_flags) { - usb_cdcacm_set_hooks(hook_flags, 0); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/include/libmaple/util.h b/GD32F1/system/libmaple/include/libmaple/util.h deleted file mode 100644 index 5a70348..0000000 --- a/GD32F1/system/libmaple/include/libmaple/util.h +++ /dev/null @@ -1,111 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/include/libmaple/util.h - * @brief Miscellaneous utility macros and procedures. - */ - -#ifndef _LIBMAPLE_UTIL_H_ -#define _LIBMAPLE_UTIL_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -/* - * Bit manipulation - */ - -/** 1UL shifted left by 'shift' */ -#define BIT(shift) (1UL << (shift)) -/** 'Mask' shifted left by 'shift' */ -#define BIT_MASK_SHIFT(mask, shift) ((mask) << (shift)) -/** Bits m to n of x */ -#define GET_BITS(x, m, n) ((((uint32)x) << (31 - (n))) >> ((31 - (n)) + (m))) -/** True iff v is a power of two (1, 2, 4, 8, ...) */ -#define IS_POWER_OF_TWO(v) ((v) && !((v) & ((v) - 1))) - -/* - * Failure routines - */ - -void __error(void); -void _fail(const char*, int, const char*); -void throb(void); - -/* - * Asserts and debug levels - */ - -#define DEBUG_NONE 0 -#define DEBUG_FAULT 1 -#define DEBUG_ALL 2 - -/** - * \def DEBUG_LEVEL - * - * Controls the level of assertion checking. - * - * The higher the debug level, the more assertions will be compiled - * in. This increases the amount of debugging information, but slows - * down (and increases the size of) the binary. - * - * The debug levels, from lowest to highest, are DEBUG_NONE, - * DEBUG_FAULT, and DEBUG_ALL. The default level is DEBUG_ALL. - */ - -#ifndef DEBUG_LEVEL -#define DEBUG_LEVEL DEBUG_ALL -#endif - -#if DEBUG_LEVEL >= DEBUG_ALL -#define ASSERT(exp) \ - if (exp) { \ - } else { \ - _fail(__FILE__, __LINE__, #exp); \ - } -#else -#define ASSERT(exp) (void)((0)) -#endif - -#if DEBUG_LEVEL >= DEBUG_FAULT -#define ASSERT_FAULT(exp) \ - if (exp) { \ - } else { \ - _fail(__FILE__, __LINE__, #exp); \ - } -#else -#define ASSERT_FAULT(exp) (void)((0)) -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/rcc_private.h b/GD32F1/system/libmaple/rcc_private.h deleted file mode 100644 index afb8a31..0000000 --- a/GD32F1/system/libmaple/rcc_private.h +++ /dev/null @@ -1,74 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* - * RCC private header. - */ - -#ifndef _LIBMAPLE_PRIVATE_RCC_H_ -#define _LIBMAPLE_PRIVATE_RCC_H_ - -#include - -struct rcc_dev_info { - const rcc_clk_domain clk_domain; - const uint8 line_num; -}; - -extern const struct rcc_dev_info rcc_dev_table[]; - -static inline void rcc_do_clk_enable(__io uint32** enable_regs, - rcc_clk_id id) { - __io uint32 *enable_reg = enable_regs[rcc_dev_clk(id)]; - uint8 line_num = rcc_dev_table[id].line_num; - bb_peri_set_bit(enable_reg, line_num, 1); -} - -static inline void rcc_do_reset_dev(__io uint32** reset_regs, - rcc_clk_id id) { - __io uint32 *reset_reg = reset_regs[rcc_dev_clk(id)]; - uint8 line_num = rcc_dev_table[id].line_num; - bb_peri_set_bit(reset_reg, line_num, 1); - bb_peri_set_bit(reset_reg, line_num, 0); -} - -static inline void rcc_do_set_prescaler(const uint32 *masks, - rcc_prescaler prescaler, - uint32 divider) { - uint32 cfgr = RCC_BASE->CFGR; - cfgr &= ~masks[prescaler]; - cfgr |= divider; - RCC_BASE->CFGR = cfgr; -} - -static inline void rcc_do_clk_disable(__io uint32** enable_regs, - rcc_clk_id id) { - __io uint32 *enable_reg = enable_regs[rcc_dev_clk(id)]; - uint8 line_num = rcc_dev_table[id].line_num; - bb_peri_set_bit(enable_reg, line_num, 0); -} - -#endif diff --git a/GD32F1/system/libmaple/rules.mk b/GD32F1/system/libmaple/rules.mk deleted file mode 100644 index 71979f0..0000000 --- a/GD32F1/system/libmaple/rules.mk +++ /dev/null @@ -1,50 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -LIBMAPLE_INCLUDES := -I$(LIBMAPLE_PATH)/include -I$(LIBMAPLE_MODULE_SERIES)/include -LIBMAPLE_PRIVATE_INCLUDES := -I$(LIBMAPLE_PATH) - -# Local flags -CFLAGS_$(d) = $(LIBMAPLE_PRIVATE_INCLUDES) $(LIBMAPLE_INCLUDES) -Wall -Werror - -# Local rules and targets -cSRCS_$(d) := adc.c -cSRCS_$(d) += dac.c -cSRCS_$(d) += dma.c -cSRCS_$(d) += exti.c -cSRCS_$(d) += flash.c -cSRCS_$(d) += gpio.c -cSRCS_$(d) += iwdg.c -cSRCS_$(d) += nvic.c -cSRCS_$(d) += pwr.c -cSRCS_$(d) += rcc.c -cSRCS_$(d) += spi.c -cSRCS_$(d) += systick.c -cSRCS_$(d) += timer.c -cSRCS_$(d) += usart.c -cSRCS_$(d) += usart_private.c -cSRCS_$(d) += util.c -sSRCS_$(d) := exc.S -# I2C support must be ported to F2: -ifeq ($(MCU_SERIES),stm32f1) -cSRCS_$(d) += i2c.c -endif - -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) -$(OBJS_$(d)): TGT_ASFLAGS := - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) diff --git a/GD32F1/system/libmaple/spi_private.h b/GD32F1/system/libmaple/spi_private.h deleted file mode 100644 index f0e0bd1..0000000 --- a/GD32F1/system/libmaple/spi_private.h +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#ifndef _LIBMAPLE_SPI_PRIVATE_H_ -#define _LIBMAPLE_SPI_PRIVATE_H_ - -#define SPI_DEV(num) \ - { \ - .regs = SPI##num##_BASE, \ - .clk_id = RCC_SPI##num, \ - .irq_num = NVIC_SPI##num, \ - } - -#endif diff --git a/GD32F1/system/libmaple/stm32_private.h b/GD32F1/system/libmaple/stm32_private.h deleted file mode 100644 index 427417a..0000000 --- a/GD32F1/system/libmaple/stm32_private.h +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*****************************************************************************/ - -#ifndef _LIBMAPLE_STM32_PRIVATE_H_ -#define _LIBMAPLE_STM32_PRIVATE_H_ - -typedef enum stm32_mem_block_purpose { - STM32_BLOCK_CODE, - STM32_BLOCK_SRAM, - STM32_BLOCK_PERIPH, - STM32_BLOCK_FSMC_1_2, - STM32_BLOCK_FSMC_3_4, - STM32_BLOCK_FSMC_REG, - STM32_BLOCK_UNUSED, - STM32_BLOCK_CORTEX_INTERNAL, -} stm32_mem_block_purpose; - -static inline stm32_mem_block_purpose stm32_block_purpose(void *addr) { - return (stm32_mem_block_purpose)((unsigned)addr >> 29); -} - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/adc.h b/GD32F1/system/libmaple/stm32f1/include/series/adc.h deleted file mode 100644 index 3e0d1de..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/adc.h +++ /dev/null @@ -1,255 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/adc.h - * @author Marti Bolivar , - * Perry Hung - * @brief STM32F1 ADC header. - */ - -#ifndef _LIBMAPLE_STM32F1_ADC_H_ -#define _LIBMAPLE_STM32F1_ADC_H_ - -#include -#include -#include /* For the prescalers */ - -/* - * Devices - */ -extern adc_dev adc1; -extern const struct adc_dev *ADC1; -extern adc_dev adc2; -extern const struct adc_dev *ADC2; -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -extern adc_dev adc3; -extern const struct adc_dev *ADC3; -#endif - -/* - * Register map base pointers - */ - -/** STM32F1 ADC1 register map base pointer. */ -#define ADC1_BASE ((struct adc_reg_map*)0x40012400) -/** STM32F1 ADC2 register map base pointer. */ -#define ADC2_BASE ((struct adc_reg_map*)0x40012800) -/** STM32F1 ADC3 register map base pointer. */ -#define ADC3_BASE ((struct adc_reg_map*)0x40013C00) - -/* - * Register bit definitions - */ - -/* Control register 2 */ - -#define ADC_CR2_ADON_BIT 0 -#define ADC_CR2_CONT_BIT 1 -#define ADC_CR2_CAL_BIT 2 -#define ADC_CR2_RSTCAL_BIT 3 -#define ADC_CR2_DMA_BIT 8 -#define ADC_CR2_ALIGN_BIT 11 -#define ADC_CR2_JEXTTRIG_BIT 15 -#define ADC_CR2_EXTTRIG_BIT 20 -#define ADC_CR2_JSWSTART_BIT 21 -#define ADC_CR2_SWSTART_BIT 22 -#define ADC_CR2_TSEREFE_BIT 23 - -#define ADC_CR2_ADON (1U << ADC_CR2_ADON_BIT) -#define ADC_CR2_CONT (1U << ADC_CR2_CONT_BIT) -#define ADC_CR2_CAL (1U << ADC_CR2_CAL_BIT) -#define ADC_CR2_RSTCAL (1U << ADC_CR2_RSTCAL_BIT) -#define ADC_CR2_DMA (1U << ADC_CR2_DMA_BIT) -#define ADC_CR2_ALIGN (1U << ADC_CR2_ALIGN_BIT) -#define ADC_CR2_JEXTSEL 0x7000 -#define ADC_CR2_JEXTTRIG (1U << ADC_CR2_JEXTTRIG_BIT) -#define ADC_CR2_EXTSEL 0xE0000 -#define ADC_CR2_EXTTRIG (1U << ADC_CR2_EXTTRIG_BIT) -#define ADC_CR2_JSWSTART (1U << ADC_CR2_JSWSTART_BIT) -#define ADC_CR2_SWSTART (1U << ADC_CR2_SWSTART_BIT) -#define ADC_CR2_TSEREFE (1U << ADC_CR2_TSEREFE_BIT) - -/* - * Other types - */ - -/** - * @brief STM32F1 external event selectors for regular group - * conversion. - * - * Some external events are only available on ADCs 1 and 2, others - * only on ADC3, while others are available on all three ADCs. - * Additionally, some events are only available on high- and - * XL-density STM32F1 MCUs, as they use peripherals only available on - * those MCU densities. - * - * For ease of use, each event selector is given along with the ADCs - * it's available on, along with any other availability restrictions. - * - * @see adc_set_extsel() - */ -typedef enum adc_extsel_event { - /* TODO: Smarten this up a bit, as follows. - * - * The EXTSEL bits on F1 are a little brain-damaged in that the - * TIM8 TRGO event has different bits depending on whether you're - * using ADC1/2 or ADC3. We route around this by declaring two - * enumerators, ADC_EXT_EV_ADC12_TIM8_TRGO and - * ADC_EXT_EV_ADC3_TIM8_TRGO. - * - * The right thing to do is to provide a single - * ADC_EXT_EV_TIM8_TRGO enumerator and override adc_set_extsel on - * STM32F1 to handle this situation correctly. We can do that - * later, though, and change the per-ADC enumerator values to - * ADC_EXT_EV_TIM8_TRGO to preserve compatibility. */ - - /* ADC1 and ADC2 only: */ - ADC_EXT_EV_TIM1_CC1 = 0x00000, /**< ADC1, ADC2: Timer 1 CC1 event */ - ADC_EXT_EV_TIM1_CC2 = 0x20000, /**< ADC1, ADC2: Timer 1 CC2 event */ - ADC_EXT_EV_TIM2_CC2 = 0x60000, /**< ADC1, ADC2: Timer 2 CC2 event */ - ADC_EXT_EV_TIM3_TRGO = 0x80000, /**< ADC1, ADC2: Timer 3 TRGO event */ - ADC_EXT_EV_TIM4_CC4 = 0xA0000, /**< ADC1, ADC2: Timer 4 CC4 event */ - ADC_EXT_EV_EXTI11 = 0xC0000, /**< ADC1, ADC2: EXTI11 event */ - - /* Common: */ - ADC_EXT_EV_TIM1_CC3 = 0x40000, /**< ADC1, ADC2, ADC3: Timer 1 CC3 event */ - ADC_EXT_EV_SWSTART = 0xE0000, /**< ADC1, ADC2, ADC3: Software start */ - - /* HD only: */ - ADC_EXT_EV_TIM3_CC1 = 0x00000, /**< - * ADC3: Timer 3 CC1 event - * Availability: high- and XL-density. */ - ADC_EXT_EV_TIM2_CC3 = 0x20000, /**< - * ADC3: Timer 2 CC3 event - * Availability: high- and XL-density. */ - ADC_EXT_EV_TIM8_CC1 = 0x60000, /**< - * ADC3: Timer 8 CC1 event - * Availability: high- and XL-density. */ - ADC_EXT_EV_ADC3_TIM8_TRGO = 0x80000, /**< - * ADC3: Timer 8 TRGO event - * Availability: high- and XL-density. */ - ADC_EXT_EV_TIM5_CC1 = 0xA0000, /**< - * ADC3: Timer 5 CC1 event - * Availability: high- and XL-density. */ - ADC_EXT_EV_ADC12_TIM8_TRGO = 0xC0000, /**< - * ADC1, ADC2: Timer 8 TRGO event - * Availability: high- and XL-density. */ - ADC_EXT_EV_TIM5_CC3 = 0xC0000, /**< - * ADC3: Timer 5 CC3 event - * Availability: high- and XL-density. */ -} adc_extsel_event; - -/* We'll keep these old adc_extsel_event enumerators around for a - * while, for backwards compatibility: */ -/** Deprecated. Use ADC_EXT_EV_TIM1_CC1 instead. */ -#define ADC_ADC12_TIM1_CC1 ADC_EXT_EV_TIM1_CC1 -/** Deprecated. Use ADC_EXT_EV_TIM1_CC2 instead. */ -#define ADC_ADC12_TIM1_CC2 ADC_EXT_EV_TIM1_CC2 -/** Deprecated. Use ADC_EXT_EV_TIM1_CC3 instead. */ -#define ADC_ADC12_TIM1_CC3 ADC_EXT_EV_TIM1_CC3 -/** Deprecated. Use ADC_EXT_EV_TIM2_CC2 instead. */ -#define ADC_ADC12_TIM2_CC2 ADC_EXT_EV_TIM2_CC2 -/** Deprecated. Use ADC_EXT_EV_TIM3_TRGO instead. */ -#define ADC_ADC12_TIM3_TRGO ADC_EXT_EV_TIM3_TRGO -/** Deprecated. Use ADC_EXT_EV_TIM4_CC4 instead. */ -#define ADC_ADC12_TIM4_CC4 ADC_EXT_EV_TIM4_CC4 -/** Deprecated. Use ADC_EXT_EV_EXTI11 instead. */ -#define ADC_ADC12_EXTI11 ADC_EXT_EV_EXTI11 -/** Deprecated. Use ADC_EXT_EV_ADC12_TIM8_TRGO instead. */ -#define ADC_ADC12_TIM8_TRGO ADC_EXT_EV_ADC12_TIM8_TRGO -/** Deprecated. Use ADC_EXT_EV_SWSTART instead. */ -#define ADC_ADC12_SWSTART ADC_EXT_EV_SWSTART -/** Deprecated. Use ADC_EXT_EV_TIM1_CC1 instead. */ -#define ADC_ADC3_TIM3_CC1 ADC_EXT_EV_TIM1_CC1 -/** Deprecated. Use ADC_EXT_EV_TIM1_CC2 instead. */ -#define ADC_ADC3_TIM2_CC3 ADC_EXT_EV_TIM1_CC2 -/** Deprecated. Use ADC_EXT_EV_TIM1_CC3 instead. */ -#define ADC_ADC3_TIM1_CC3 ADC_EXT_EV_TIM1_CC3 -/** Deprecated. Use ADC_EXT_EV_TIM2_CC2 instead. */ -#define ADC_ADC3_TIM8_CC1 ADC_EXT_EV_TIM2_CC2 -/** Deprecated. Use ADC_EXT_EV_TIM3_TRGO instead. */ -#define ADC_ADC3_TIM8_TRGO ADC_EXT_EV_TIM3_TRGO -/** Deprecated. Use ADC_EXT_EV_TIM4_CC4 instead. */ -#define ADC_ADC3_TIM5_CC1 ADC_EXT_EV_TIM4_CC4 -/** Deprecated. Use ADC_EXT_EV_EXTI11 instead. */ -#define ADC_ADC3_TIM5_CC3 ADC_EXT_EV_EXTI11 -/** Deprecated. Use ADC_EXT_EV_TIM8_TRGO instead. */ -#define ADC_ADC3_SWSTART ADC_EXT_EV_TIM8_TRGO -/** Deprecated. Use ADC_EXT_EV_SWSTART instead. */ -#define ADC_SWSTART ADC_EXT_EV_SWSTART - -/** - * @brief STM32F1 sample times, in ADC clock cycles. - * - * These control the amount of time spent sampling the input voltage. - */ -typedef enum adc_smp_rate { - ADC_SMPR_1_5, /**< 1.5 ADC cycles */ - ADC_SMPR_7_5, /**< 7.5 ADC cycles */ - ADC_SMPR_13_5, /**< 13.5 ADC cycles */ - ADC_SMPR_28_5, /**< 28.5 ADC cycles */ - ADC_SMPR_41_5, /**< 41.5 ADC cycles */ - ADC_SMPR_55_5, /**< 55.5 ADC cycles */ - ADC_SMPR_71_5, /**< 71.5 ADC cycles */ - ADC_SMPR_239_5, /**< 239.5 ADC cycles */ -} adc_smp_rate; - -/** - * @brief STM32F1 ADC prescalers, as divisors of PCLK2. - */ -typedef enum adc_prescaler { - /** PCLK2 divided by 2 */ - ADC_PRE_PCLK2_DIV_2 = RCC_ADCPRE_PCLK_DIV_2, - /** PCLK2 divided by 4 */ - ADC_PRE_PCLK2_DIV_4 = RCC_ADCPRE_PCLK_DIV_4, - /** PCLK2 divided by 6 */ - ADC_PRE_PCLK2_DIV_6 = RCC_ADCPRE_PCLK_DIV_6, - /** PCLK2 divided by 8 */ - ADC_PRE_PCLK2_DIV_8 = RCC_ADCPRE_PCLK_DIV_8, -} adc_prescaler; - -/* - * Routines - */ - -void adc_calibrate(const adc_dev *dev); - -/** - * @brief Set external trigger conversion mode event for regular channels - * - * Availability: STM32F1. - * - * @param dev ADC device - * @param enable If 1, conversion on external events is enabled; if 0, - * disabled. - */ -static inline void adc_set_exttrig(const adc_dev *dev, uint8 enable) { - *bb_perip(&dev->regs->CR2, ADC_CR2_EXTTRIG_BIT) = !!enable; -} - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/dac.h b/GD32F1/system/libmaple/stm32f1/include/series/dac.h deleted file mode 100644 index c0d026b..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/dac.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/dac.h - * @brief STM32F1 DAC support - */ - -#ifndef _LIBMAPLE_STM32F1_DAC_H_ -#define _LIBMAPLE_STM32F1_DAC_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -/** STM32F1 DAC register map type. */ -typedef struct dac_reg_map { - __io uint32 CR; /**< Control register */ - __io uint32 SWTRIGR; /**< Software trigger register */ - __io uint32 DHR12R1; /**< Channel 1 12-bit right-aligned data - holding register */ - __io uint32 DHR12L1; /**< Channel 1 12-bit left-aligned data - holding register */ - __io uint32 DHR8R1; /**< Channel 1 8-bit left-aligned data - holding register */ - __io uint32 DHR12R2; /**< Channel 2 12-bit right-aligned data - holding register */ - __io uint32 DHR12L2; /**< Channel 2 12-bit left-aligned data - holding register */ - __io uint32 DHR8R2; /**< Channel 2 8-bit left-aligned data - holding register */ - __io uint32 DHR12RD; /**< Dual DAC 12-bit right-aligned data - holding register */ - __io uint32 DHR12LD; /**< Dual DAC 12-bit left-aligned data - holding register */ - __io uint32 DHR8RD; /**< Dual DAC 8-bit right-aligned data holding - register */ - __io uint32 DOR1; /**< Channel 1 data output register */ - __io uint32 DOR2; /**< Channel 2 data output register */ -} dac_reg_map; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/dma.h b/GD32F1/system/libmaple/stm32f1/include/series/dma.h deleted file mode 100644 index bedb602..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/dma.h +++ /dev/null @@ -1,575 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Michael Hope. - * Copyright (c) 2012 LeafLabs, LLC - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/dma.h - * @author Marti Bolivar ; - * Original implementation by Michael Hope - * @brief STM32F1 DMA series header. - */ - -/* - * See /notes/dma-stm32f1.txt for more information. - */ - -#ifndef _LIBMAPLE_STM32F1_DMA_H_ -#define _LIBMAPLE_STM32F1_DMA_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include - -/* - * Register maps and base pointers - */ - -/** - * @brief STM32F1 DMA register map type. - * - * Note that DMA controller 2 (register map base pointer DMA2_BASE) - * only supports channels 1--5. - */ -typedef struct dma_reg_map { - __io uint32 ISR; /**< Interrupt status register */ - __io uint32 IFCR; /**< Interrupt flag clear register */ - __io uint32 CCR1; /**< Channel 1 configuration register */ - __io uint32 CNDTR1; /**< Channel 1 number of data register */ - __io uint32 CPAR1; /**< Channel 1 peripheral address register */ - __io uint32 CMAR1; /**< Channel 1 memory address register */ - const uint32 RESERVED1; /**< Reserved. */ - __io uint32 CCR2; /**< Channel 2 configuration register */ - __io uint32 CNDTR2; /**< Channel 2 number of data register */ - __io uint32 CPAR2; /**< Channel 2 peripheral address register */ - __io uint32 CMAR2; /**< Channel 2 memory address register */ - const uint32 RESERVED2; /**< Reserved. */ - __io uint32 CCR3; /**< Channel 3 configuration register */ - __io uint32 CNDTR3; /**< Channel 3 number of data register */ - __io uint32 CPAR3; /**< Channel 3 peripheral address register */ - __io uint32 CMAR3; /**< Channel 3 memory address register */ - const uint32 RESERVED3; /**< Reserved. */ - __io uint32 CCR4; /**< Channel 4 configuration register */ - __io uint32 CNDTR4; /**< Channel 4 number of data register */ - __io uint32 CPAR4; /**< Channel 4 peripheral address register */ - __io uint32 CMAR4; /**< Channel 4 memory address register */ - const uint32 RESERVED4; /**< Reserved. */ - __io uint32 CCR5; /**< Channel 5 configuration register */ - __io uint32 CNDTR5; /**< Channel 5 number of data register */ - __io uint32 CPAR5; /**< Channel 5 peripheral address register */ - __io uint32 CMAR5; /**< Channel 5 memory address register */ - const uint32 RESERVED5; /**< Reserved. */ - __io uint32 CCR6; /**< Channel 6 configuration register */ - __io uint32 CNDTR6; /**< Channel 6 number of data register */ - __io uint32 CPAR6; /**< Channel 6 peripheral address register */ - __io uint32 CMAR6; /**< Channel 6 memory address register */ - const uint32 RESERVED6; /**< Reserved. */ - __io uint32 CCR7; /**< Channel 7 configuration register */ - __io uint32 CNDTR7; /**< Channel 7 number of data register */ - __io uint32 CPAR7; /**< Channel 7 peripheral address register */ - __io uint32 CMAR7; /**< Channel 7 memory address register */ - const uint32 RESERVED7; /**< Reserved. */ -} dma_reg_map; - -/** DMA controller 1 register map base pointer */ -#define DMA1_BASE ((struct dma_reg_map*)0x40020000) -/** DMA controller 2 register map base pointer */ -#define DMA2_BASE ((struct dma_reg_map*)0x40020400) - -/** - * @brief STM32F1 DMA channel (i.e. tube) register map type. - * Provides access to an individual channel's registers. - * @see dma_tube_regs() - */ -typedef struct dma_tube_reg_map { - __io uint32 CCR; /**< Channel configuration register */ - __io uint32 CNDTR; /**< Channel number of data register */ - __io uint32 CPAR; /**< Channel peripheral address register */ - __io uint32 CMAR; /**< Channel memory address register */ -} dma_tube_reg_map; - -/** DMA1 channel 1 register map base pointer */ -#define DMA1CH1_BASE ((struct dma_tube_reg_map*)0x40020008) -/** DMA1 channel 2 register map base pointer */ -#define DMA1CH2_BASE ((struct dma_tube_reg_map*)0x4002001C) -/** DMA1 channel 3 register map base pointer */ -#define DMA1CH3_BASE ((struct dma_tube_reg_map*)0x40020030) -/** DMA1 channel 4 register map base pointer */ -#define DMA1CH4_BASE ((struct dma_tube_reg_map*)0x40020044) -/** DMA1 channel 5 register map base pointer */ -#define DMA1CH5_BASE ((struct dma_tube_reg_map*)0x40020058) -/** DMA1 channel 6 register map base pointer */ -#define DMA1CH6_BASE ((struct dma_tube_reg_map*)0x4002006C) -/** DMA1 channel 7 register map base pointer */ -#define DMA1CH7_BASE ((struct dma_tube_reg_map*)0x40020080) - -/** DMA2 channel 1 register map base pointer */ -#define DMA2CH1_BASE ((struct dma_tube_reg_map*)0x40020408) -/** DMA2 channel 2 register map base pointer */ -#define DMA2CH2_BASE ((struct dma_tube_reg_map*)0x4002041C) -/** DMA2 channel 3 register map base pointer */ -#define DMA2CH3_BASE ((struct dma_tube_reg_map*)0x40020430) -/** DMA2 channel 4 register map base pointer */ -#define DMA2CH4_BASE ((struct dma_tube_reg_map*)0x40020444) -/** DMA2 channel 5 register map base pointer */ -#define DMA2CH5_BASE ((struct dma_tube_reg_map*)0x40020458) - -/* - * Register bit definitions - */ - -/* Interrupt status register */ - -#define DMA_ISR_TEIF_BIT 3 -#define DMA_ISR_HTIF_BIT 2 -#define DMA_ISR_TCIF_BIT 1 -#define DMA_ISR_GIF_BIT 0 - -#define DMA_ISR_TEIF (1 << DMA_ISR_TEIF_BIT) -#define DMA_ISR_HTIF (1 << DMA_ISR_HTIF_BIT) -#define DMA_ISR_TCID (1 << DMA_ISR_TCIF_BIT) -#define DMA_ISR_GIF (1 << DMA_ISR_GIF_BIT) - -#define DMA_ISR_TEIF7_BIT 27 -#define DMA_ISR_HTIF7_BIT 26 -#define DMA_ISR_TCIF7_BIT 25 -#define DMA_ISR_GIF7_BIT 24 -#define DMA_ISR_TEIF6_BIT 23 -#define DMA_ISR_HTIF6_BIT 22 -#define DMA_ISR_TCIF6_BIT 21 -#define DMA_ISR_GIF6_BIT 20 -#define DMA_ISR_TEIF5_BIT 19 -#define DMA_ISR_HTIF5_BIT 18 -#define DMA_ISR_TCIF5_BIT 17 -#define DMA_ISR_GIF5_BIT 16 -#define DMA_ISR_TEIF4_BIT 15 -#define DMA_ISR_HTIF4_BIT 14 -#define DMA_ISR_TCIF4_BIT 13 -#define DMA_ISR_GIF4_BIT 12 -#define DMA_ISR_TEIF3_BIT 11 -#define DMA_ISR_HTIF3_BIT 10 -#define DMA_ISR_TCIF3_BIT 9 -#define DMA_ISR_GIF3_BIT 8 -#define DMA_ISR_TEIF2_BIT 7 -#define DMA_ISR_HTIF2_BIT 6 -#define DMA_ISR_TCIF2_BIT 5 -#define DMA_ISR_GIF2_BIT 4 -#define DMA_ISR_TEIF1_BIT 3 -#define DMA_ISR_HTIF1_BIT 2 -#define DMA_ISR_TCIF1_BIT 1 -#define DMA_ISR_GIF1_BIT 0 - -#define DMA_ISR_TEIF7 (1U << DMA_ISR_TEIF7_BIT) -#define DMA_ISR_HTIF7 (1U << DMA_ISR_HTIF7_BIT) -#define DMA_ISR_TCIF7 (1U << DMA_ISR_TCIF7_BIT) -#define DMA_ISR_GIF7 (1U << DMA_ISR_GIF7_BIT) -#define DMA_ISR_TEIF6 (1U << DMA_ISR_TEIF6_BIT) -#define DMA_ISR_HTIF6 (1U << DMA_ISR_HTIF6_BIT) -#define DMA_ISR_TCIF6 (1U << DMA_ISR_TCIF6_BIT) -#define DMA_ISR_GIF6 (1U << DMA_ISR_GIF6_BIT) -#define DMA_ISR_TEIF5 (1U << DMA_ISR_TEIF5_BIT) -#define DMA_ISR_HTIF5 (1U << DMA_ISR_HTIF5_BIT) -#define DMA_ISR_TCIF5 (1U << DMA_ISR_TCIF5_BIT) -#define DMA_ISR_GIF5 (1U << DMA_ISR_GIF5_BIT) -#define DMA_ISR_TEIF4 (1U << DMA_ISR_TEIF4_BIT) -#define DMA_ISR_HTIF4 (1U << DMA_ISR_HTIF4_BIT) -#define DMA_ISR_TCIF4 (1U << DMA_ISR_TCIF4_BIT) -#define DMA_ISR_GIF4 (1U << DMA_ISR_GIF4_BIT) -#define DMA_ISR_TEIF3 (1U << DMA_ISR_TEIF3_BIT) -#define DMA_ISR_HTIF3 (1U << DMA_ISR_HTIF3_BIT) -#define DMA_ISR_TCIF3 (1U << DMA_ISR_TCIF3_BIT) -#define DMA_ISR_GIF3 (1U << DMA_ISR_GIF3_BIT) -#define DMA_ISR_TEIF2 (1U << DMA_ISR_TEIF2_BIT) -#define DMA_ISR_HTIF2 (1U << DMA_ISR_HTIF2_BIT) -#define DMA_ISR_TCIF2 (1U << DMA_ISR_TCIF2_BIT) -#define DMA_ISR_GIF2 (1U << DMA_ISR_GIF2_BIT) -#define DMA_ISR_TEIF1 (1U << DMA_ISR_TEIF1_BIT) -#define DMA_ISR_HTIF1 (1U << DMA_ISR_HTIF1_BIT) -#define DMA_ISR_TCIF1 (1U << DMA_ISR_TCIF1_BIT) -#define DMA_ISR_GIF1 (1U << DMA_ISR_GIF1_BIT) - -/* Interrupt flag clear register */ - -#define DMA_IFCR_CTEIF7_BIT 27 -#define DMA_IFCR_CHTIF7_BIT 26 -#define DMA_IFCR_CTCIF7_BIT 25 -#define DMA_IFCR_CGIF7_BIT 24 -#define DMA_IFCR_CTEIF6_BIT 23 -#define DMA_IFCR_CHTIF6_BIT 22 -#define DMA_IFCR_CTCIF6_BIT 21 -#define DMA_IFCR_CGIF6_BIT 20 -#define DMA_IFCR_CTEIF5_BIT 19 -#define DMA_IFCR_CHTIF5_BIT 18 -#define DMA_IFCR_CTCIF5_BIT 17 -#define DMA_IFCR_CGIF5_BIT 16 -#define DMA_IFCR_CTEIF4_BIT 15 -#define DMA_IFCR_CHTIF4_BIT 14 -#define DMA_IFCR_CTCIF4_BIT 13 -#define DMA_IFCR_CGIF4_BIT 12 -#define DMA_IFCR_CTEIF3_BIT 11 -#define DMA_IFCR_CHTIF3_BIT 10 -#define DMA_IFCR_CTCIF3_BIT 9 -#define DMA_IFCR_CGIF3_BIT 8 -#define DMA_IFCR_CTEIF2_BIT 7 -#define DMA_IFCR_CHTIF2_BIT 6 -#define DMA_IFCR_CTCIF2_BIT 5 -#define DMA_IFCR_CGIF2_BIT 4 -#define DMA_IFCR_CTEIF1_BIT 3 -#define DMA_IFCR_CHTIF1_BIT 2 -#define DMA_IFCR_CTCIF1_BIT 1 -#define DMA_IFCR_CGIF1_BIT 0 - -#define DMA_IFCR_CTEIF7 (1U << DMA_IFCR_CTEIF7_BIT) -#define DMA_IFCR_CHTIF7 (1U << DMA_IFCR_CHTIF7_BIT) -#define DMA_IFCR_CTCIF7 (1U << DMA_IFCR_CTCIF7_BIT) -#define DMA_IFCR_CGIF7 (1U << DMA_IFCR_CGIF7_BIT) -#define DMA_IFCR_CTEIF6 (1U << DMA_IFCR_CTEIF6_BIT) -#define DMA_IFCR_CHTIF6 (1U << DMA_IFCR_CHTIF6_BIT) -#define DMA_IFCR_CTCIF6 (1U << DMA_IFCR_CTCIF6_BIT) -#define DMA_IFCR_CGIF6 (1U << DMA_IFCR_CGIF6_BIT) -#define DMA_IFCR_CTEIF5 (1U << DMA_IFCR_CTEIF5_BIT) -#define DMA_IFCR_CHTIF5 (1U << DMA_IFCR_CHTIF5_BIT) -#define DMA_IFCR_CTCIF5 (1U << DMA_IFCR_CTCIF5_BIT) -#define DMA_IFCR_CGIF5 (1U << DMA_IFCR_CGIF5_BIT) -#define DMA_IFCR_CTEIF4 (1U << DMA_IFCR_CTEIF4_BIT) -#define DMA_IFCR_CHTIF4 (1U << DMA_IFCR_CHTIF4_BIT) -#define DMA_IFCR_CTCIF4 (1U << DMA_IFCR_CTCIF4_BIT) -#define DMA_IFCR_CGIF4 (1U << DMA_IFCR_CGIF4_BIT) -#define DMA_IFCR_CTEIF3 (1U << DMA_IFCR_CTEIF3_BIT) -#define DMA_IFCR_CHTIF3 (1U << DMA_IFCR_CHTIF3_BIT) -#define DMA_IFCR_CTCIF3 (1U << DMA_IFCR_CTCIF3_BIT) -#define DMA_IFCR_CGIF3 (1U << DMA_IFCR_CGIF3_BIT) -#define DMA_IFCR_CTEIF2 (1U << DMA_IFCR_CTEIF2_BIT) -#define DMA_IFCR_CHTIF2 (1U << DMA_IFCR_CHTIF2_BIT) -#define DMA_IFCR_CTCIF2 (1U << DMA_IFCR_CTCIF2_BIT) -#define DMA_IFCR_CGIF2 (1U << DMA_IFCR_CGIF2_BIT) -#define DMA_IFCR_CTEIF1 (1U << DMA_IFCR_CTEIF1_BIT) -#define DMA_IFCR_CHTIF1 (1U << DMA_IFCR_CHTIF1_BIT) -#define DMA_IFCR_CTCIF1 (1U << DMA_IFCR_CTCIF1_BIT) -#define DMA_IFCR_CGIF1 (1U << DMA_IFCR_CGIF1_BIT) - -/* Channel configuration register */ - -#define DMA_CCR_MEM2MEM_BIT 14 -#define DMA_CCR_MINC_BIT 7 -#define DMA_CCR_PINC_BIT 6 -#define DMA_CCR_CIRC_BIT 5 -#define DMA_CCR_DIR_BIT 4 -#define DMA_CCR_TEIE_BIT 3 -#define DMA_CCR_HTIE_BIT 2 -#define DMA_CCR_TCIE_BIT 1 -#define DMA_CCR_EN_BIT 0 - -#define DMA_CCR_MEM2MEM (1U << DMA_CCR_MEM2MEM_BIT) -#define DMA_CCR_PL (0x3 << 12) -#define DMA_CCR_PL_LOW (0x0 << 12) -#define DMA_CCR_PL_MEDIUM (0x1 << 12) -#define DMA_CCR_PL_HIGH (0x2 << 12) -#define DMA_CCR_PL_VERY_HIGH (0x3 << 12) -#define DMA_CCR_MSIZE (0x3 << 10) -#define DMA_CCR_MSIZE_8BITS (0x0 << 10) -#define DMA_CCR_MSIZE_16BITS (0x1 << 10) -#define DMA_CCR_MSIZE_32BITS (0x2 << 10) -#define DMA_CCR_PSIZE (0x3 << 8) -#define DMA_CCR_PSIZE_8BITS (0x0 << 8) -#define DMA_CCR_PSIZE_16BITS (0x1 << 8) -#define DMA_CCR_PSIZE_32BITS (0x2 << 8) -#define DMA_CCR_MINC (1U << DMA_CCR_MINC_BIT) -#define DMA_CCR_PINC (1U << DMA_CCR_PINC_BIT) -#define DMA_CCR_CIRC (1U << DMA_CCR_CIRC_BIT) -#define DMA_CCR_DIR (1U << DMA_CCR_DIR_BIT) -#define DMA_CCR_DIR_FROM_PER (0U << DMA_CCR_DIR_BIT) -#define DMA_CCR_DIR_FROM_MEM (1U << DMA_CCR_DIR_BIT) -#define DMA_CCR_TEIE (1U << DMA_CCR_TEIE_BIT) -#define DMA_CCR_HTIE (1U << DMA_CCR_HTIE_BIT) -#define DMA_CCR_TCIE (1U << DMA_CCR_TCIE_BIT) -#define DMA_CCR_EN (1U << DMA_CCR_EN_BIT) - -/* - * Devices - */ - -extern dma_dev *DMA1; -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -extern dma_dev *DMA2; -#endif - -/* - * Other types needed by, or useful for, . - */ - -/** - * @brief STM32F1 dma_tube. - * On STM32F1, DMA tubes are just channels. - */ -#define dma_tube dma_channel - -/** - * @brief On STM32F1, dma_channel_reg_map is an alias for dma_tube_reg_map. - * This is for backwards compatibility. */ -#define dma_channel_reg_map dma_tube_reg_map - -/** - * @brief STM32F1 configuration flags for dma_tube_config - * @see struct dma_tube_config - */ -typedef enum dma_cfg_flags { - /** - * Source address increment mode - * - * If this flag is set, the source address is incremented (by the - * source size) after each DMA transfer. - */ - DMA_CFG_SRC_INC = 1U << 31, - - /** - * Destination address increment mode - * - * If this flag is set, the destination address is incremented (by - * the destination size) after each DMA transfer. - */ - DMA_CFG_DST_INC = 1U << 30, - - /** - * Circular mode - * - * This mode is not available for memory-to-memory transfers. - */ - DMA_CFG_CIRC = DMA_CCR_CIRC, - - /** Transfer complete interrupt enable */ - DMA_CFG_CMPLT_IE = DMA_CCR_TCIE, - /** Transfer half-complete interrupt enable */ - DMA_CFG_HALF_CMPLT_IE = DMA_CCR_HTIE, - /** Transfer error interrupt enable */ - DMA_CFG_ERR_IE = DMA_CCR_TEIE, -} dma_cfg_flags; - -/** - * @brief STM32F1 DMA request sources. - * - * IMPORTANT: - * - * 1. On STM32F1, each dma_request_src can only be used by a - * particular tube on a particular DMA controller. For example, - * DMA_REQ_SRC_ADC1 belongs to DMA1, tube 1. DMA2 cannot serve - * requests from ADC1, nor can DMA1 tube 2, etc. If you try to use a - * request source with the wrong DMA controller or tube on STM32F1, - * dma_tube_cfg() will fail. - * - * 2. In general, a DMA tube can only serve a single request source at - * a time, and on STM32F1, Terrible Super-Bad Things will happen if - * two request sources are active for a single tube. - * - * To make all this easier to sort out, these dma_request_src - * enumerators are grouped by DMA controller and tube. - * - * @see struct dma_tube_config - * @see dma_tube_cfg() - */ -typedef enum dma_request_src { - /* Each request source encodes the DMA controller and channel it - * belongs to, for error checking in dma_tube_cfg(). */ - - /* DMA1 request sources */ - - /**@{*/ - /** (DMA1, tube 1) */ - DMA_REQ_SRC_ADC1 = (RCC_DMA1 << 3) | 1, - DMA_REQ_SRC_TIM2_CH3 = (RCC_DMA1 << 3) | 1, - DMA_REQ_SRC_TIM4_CH1 = (RCC_DMA1 << 3) | 1, - /**@}*/ - - /**@{*/ - /** (DMA1, tube 2)*/ - DMA_REQ_SRC_SPI1_RX = (RCC_DMA1 << 3) | 2, - DMA_REQ_SRC_USART3_TX = (RCC_DMA1 << 3) | 2, - DMA_REQ_SRC_TIM1_CH1 = (RCC_DMA1 << 3) | 2, - DMA_REQ_SRC_TIM2_UP = (RCC_DMA1 << 3) | 2, - DMA_REQ_SRC_TIM3_CH3 = (RCC_DMA1 << 3) | 2, - /**@}*/ - - /**@{*/ - /** (DMA1, tube 3)*/ - DMA_REQ_SRC_SPI1_TX = (RCC_DMA1 << 3) | 3, - DMA_REQ_SRC_USART3_RX = (RCC_DMA1 << 3) | 3, - DMA_REQ_SRC_TIM1_CH2 = (RCC_DMA1 << 3) | 3, - DMA_REQ_SRC_TIM3_CH4 = (RCC_DMA1 << 3) | 3, - DMA_REQ_SRC_TIM3_UP = (RCC_DMA1 << 3) | 3, - /**@}*/ - - /**@{*/ - /** (DMA1, tube 4)*/ - DMA_REQ_SRC_SPI2_RX = (RCC_DMA1 << 3) | 4, - DMA_REQ_SRC_I2S2_RX = (RCC_DMA1 << 3) | 4, - DMA_REQ_SRC_USART1_TX = (RCC_DMA1 << 3) | 4, - DMA_REQ_SRC_I2C2_TX = (RCC_DMA1 << 3) | 4, - DMA_REQ_SRC_TIM1_CH4 = (RCC_DMA1 << 3) | 4, - DMA_REQ_SRC_TIM1_TRIG = (RCC_DMA1 << 3) | 4, - DMA_REQ_SRC_TIM1_COM = (RCC_DMA1 << 3) | 4, - DMA_REQ_SRC_TIM4_CH2 = (RCC_DMA1 << 3) | 4, - /**@}*/ - - /**@{*/ - /** (DMA1, tube 5)*/ - DMA_REQ_SRC_SPI2_TX = (RCC_DMA1 << 3) | 5, - DMA_REQ_SRC_I2S2_TX = (RCC_DMA1 << 3) | 5, - DMA_REQ_SRC_USART1_RX = (RCC_DMA1 << 3) | 5, - DMA_REQ_SRC_I2C2_RX = (RCC_DMA1 << 3) | 5, - DMA_REQ_SRC_TIM1_UP = (RCC_DMA1 << 3) | 5, - DMA_REQ_SRC_TIM2_CH1 = (RCC_DMA1 << 3) | 5, - DMA_REQ_SRC_TIM4_CH3 = (RCC_DMA1 << 3) | 5, - /**@}*/ - - /**@{*/ - /** (DMA1, tube 6)*/ - DMA_REQ_SRC_USART2_RX = (RCC_DMA1 << 3) | 6, - DMA_REQ_SRC_I2C1_TX = (RCC_DMA1 << 3) | 6, - DMA_REQ_SRC_TIM1_CH3 = (RCC_DMA1 << 3) | 6, - DMA_REQ_SRC_TIM3_CH1 = (RCC_DMA1 << 3) | 6, - DMA_REQ_SRC_TIM3_TRIG = (RCC_DMA1 << 3) | 6, - /**@}*/ - - /**@{*/ - /* Tube 7 */ - DMA_REQ_SRC_USART2_TX = (RCC_DMA1 << 3) | 7, - DMA_REQ_SRC_I2C1_RX = (RCC_DMA1 << 3) | 7, - DMA_REQ_SRC_TIM2_CH2 = (RCC_DMA1 << 3) | 7, - DMA_REQ_SRC_TIM2_CH4 = (RCC_DMA1 << 3) | 7, - DMA_REQ_SRC_TIM4_UP = (RCC_DMA1 << 3) | 7, - /**@}*/ - - /* DMA2 request sources */ - - /**@{*/ - /** (DMA2, tube 1)*/ - DMA_REQ_SRC_SPI3_RX = (RCC_DMA2 << 3) | 1, - DMA_REQ_SRC_I2S3_RX = (RCC_DMA2 << 3) | 1, - DMA_REQ_SRC_TIM5_CH4 = (RCC_DMA2 << 3) | 1, - DMA_REQ_SRC_TIM5_TRIG = (RCC_DMA2 << 3) | 1, - /**@}*/ - - /**@{*/ - /** (DMA2, tube 2)*/ - DMA_REQ_SRC_SPI3_TX = (RCC_DMA2 << 3) | 2, - DMA_REQ_SRC_I2S3_TX = (RCC_DMA2 << 3) | 2, - DMA_REQ_SRC_TIM5_CH3 = (RCC_DMA2 << 3) | 2, - DMA_REQ_SRC_TIM5_UP = (RCC_DMA2 << 3) | 2, - /**@}*/ - - /**@{*/ - /** (DMA2, tube 3)*/ - DMA_REQ_SRC_UART4_RX = (RCC_DMA2 << 3) | 3, - DMA_REQ_SRC_TIM6_UP = (RCC_DMA2 << 3) | 3, - DMA_REQ_SRC_DAC_CH1 = (RCC_DMA2 << 3) | 3, - /**@}*/ - - /**@{*/ - /** (DMA2, tube 4)*/ - DMA_REQ_SRC_SDIO = (RCC_DMA2 << 3) | 4, - DMA_REQ_SRC_TIM5_CH2 = (RCC_DMA2 << 3) | 4, - /**@}*/ - - /**@{*/ - /** (DMA2, tube 5)*/ - DMA_REQ_SRC_ADC3 = (RCC_DMA2 << 3) | 5, - DMA_REQ_SRC_UART4_TX = (RCC_DMA2 << 3) | 5, - DMA_REQ_SRC_TIM5_CH1 = (RCC_DMA2 << 3) | 5, - /**@}*/ -} dma_request_src; - -/* - * Convenience routines. - */ - -/** - * @brief On STM32F1, dma_is_channel_enabled() is an alias for - * dma_is_enabled(). - * This is for backwards compatibility. - */ -#define dma_is_channel_enabled dma_is_enabled - -#define DMA_CHANNEL_NREGS 5 /* accounts for reserved word */ -static inline dma_tube_reg_map* dma_tube_regs(dma_dev *dev, dma_tube tube) { - __io uint32 *ccr1 = &dev->regs->CCR1; - return (dma_channel_reg_map*)(ccr1 + DMA_CHANNEL_NREGS * (tube - 1)); -} - -/** - * @brief On STM32F1, dma_channel_regs() is an alias for dma_tube_regs(). - * This is for backwards compatibility. */ -#define dma_channel_regs(dev, ch) dma_tube_regs(dev, ch) - -static inline uint8 dma_is_enabled(dma_dev *dev, dma_tube tube) { - return (uint8)(dma_tube_regs(dev, tube)->CCR & DMA_CCR_EN); -} - -static inline uint8 dma_get_isr_bits(dma_dev *dev, dma_tube tube) { - uint8 shift = (tube - 1) * 4; - return (dev->regs->ISR >> shift) & 0xF; -} - -static inline void dma_clear_isr_bits(dma_dev *dev, dma_tube tube) { - dev->regs->IFCR = (1U << (4 * (tube - 1))); -} - -/** - * @brief Deprecated - * STM32F1 mode flags for dma_setup_xfer(). Use dma_tube_cfg() instead. - * @see dma_tube_cfg() - */ -typedef enum dma_mode_flags { - DMA_MEM_2_MEM = 1 << 14, /**< Memory to memory mode */ - DMA_MINC_MODE = 1 << 7, /**< Auto-increment memory address */ - DMA_PINC_MODE = 1 << 6, /**< Auto-increment peripheral address */ - DMA_CIRC_MODE = 1 << 5, /**< Circular mode */ - DMA_FROM_MEM = 1 << 4, /**< Read from memory to peripheral */ - DMA_TRNS_ERR = 1 << 3, /**< Interrupt on transfer error */ - DMA_HALF_TRNS = 1 << 2, /**< Interrupt on half-transfer */ - DMA_TRNS_CMPLT = 1 << 1 /**< Interrupt on transfer completion */ -} dma_mode_flags; - -/* Keep this around for backwards compatibility, but it's deprecated. - * New code should use dma_tube_cfg() instead. - * - * (It's not possible to fully configure a DMA stream on F2 with just - * this information, so this interface is too tied to the F1.) */ -__deprecated -void dma_setup_transfer(dma_dev *dev, - dma_channel channel, - __io void *peripheral_address, - dma_xfer_size peripheral_size, - __io void *memory_address, - dma_xfer_size memory_size, - uint32 mode); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/exti.h b/GD32F1/system/libmaple/stm32f1/include/series/exti.h deleted file mode 100644 index 1ece664..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/exti.h +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/exti.h - * @brief STM32F1 external interrupts - */ - -#ifndef _LIBMAPLE_STM32F1_EXTI_H_ -#define _LIBMAPLE_STM32F1_EXTI_H_ - -#ifdef __cpluspus -extern "C" { -#endif - -struct exti_reg_map; -#define EXTI_BASE ((struct exti_reg_map*)0x40010400) - -#ifdef __cpluspus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/flash.h b/GD32F1/system/libmaple/stm32f1/include/series/flash.h deleted file mode 100644 index 24efb0b..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/flash.h +++ /dev/null @@ -1,149 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/flash.h - * @brief STM32F1 Flash header. - * - * Provides register map, base pointer, and register bit definitions - * for the Flash controller on the STM32F1 line, along with - * series-specific configuration values. - */ - -#ifndef _LIBMAPLE_STM32F1_FLASH_H_ -#define _LIBMAPLE_STM32F1_FLASH_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -/* - * Register map - */ - -/** @brief STM32F1 Flash register map type */ -typedef struct flash_reg_map { - __io uint32 ACR; /**< Access control register */ - __io uint32 KEYR; /**< Key register */ - __io uint32 OPTKEYR; /**< OPTKEY register */ - __io uint32 SR; /**< Status register */ - __io uint32 CR; /**< Control register */ - __io uint32 AR; /**< Address register */ - __io uint32 OBR; /**< Option byte register */ - __io uint32 WRPR; /**< Write protection register */ -} flash_reg_map; - -#define FLASH_BASE ((struct flash_reg_map*)0x40022000) - -/* - * Register bit definitions - */ - -/* Access control register */ - -#define FLASH_ACR_PRFTBS_BIT 5 -#define FLASH_ACR_PRFTBE_BIT 4 -#define FLASH_ACR_HLFCYA_BIT 3 - -#define FLASH_ACR_PRFTBS (1U << FLASH_ACR_PRFTBS_BIT) -#define FLASH_ACR_PRFTBE (1U << FLASH_ACR_PRFTBE_BIT) -#define FLASH_ACR_HLFCYA (1U << FLASH_ACR_HLFCYA_BIT) -#define FLASH_ACR_LATENCY 0x7 - -/* Status register */ - -#define FLASH_SR_EOP_BIT 5 -#define FLASH_SR_WRPRTERR_BIT 4 -#define FLASH_SR_PGERR_BIT 2 -#define FLASH_SR_BSY_BIT 0 - -#define FLASH_SR_EOP (1U << FLASH_SR_EOP_BIT) -#define FLASH_SR_WRPRTERR (1U << FLASH_SR_WRPRTERR_BIT) -#define FLASH_SR_PGERR (1U << FLASH_SR_PGERR_BIT) -#define FLASH_SR_BSY (1U << FLASH_SR_BSY_BIT) - -/* Control register */ - -#define FLASH_CR_EOPIE_BIT 12 -#define FLASH_CR_ERRIE_BIT 10 -#define FLASH_CR_OPTWRE_BIT 9 -#define FLASH_CR_LOCK_BIT 7 -#define FLASH_CR_STRT_BIT 6 -#define FLASH_CR_OPTER_BIT 5 -#define FLASH_CR_OPTPG_BIT 4 -#define FLASH_CR_MER_BIT 2 -#define FLASH_CR_PER_BIT 1 -#define FLASH_CR_PG_BIT 0 - -#define FLASH_CR_EOPIE (1U << FLASH_CR_EOPIE_BIT) -#define FLASH_CR_ERRIE (1U << FLASH_CR_ERRIE_BIT) -#define FLASH_CR_OPTWRE (1U << FLASH_CR_OPTWRE_BIT) -#define FLASH_CR_LOCK (1U << FLASH_CR_LOCK_BIT) -#define FLASH_CR_STRT (1U << FLASH_CR_STRT_BIT) -#define FLASH_CR_OPTER (1U << FLASH_CR_OPTER_BIT) -#define FLASH_CR_OPTPG (1U << FLASH_CR_OPTPG_BIT) -#define FLASH_CR_MER (1U << FLASH_CR_MER_BIT) -#define FLASH_CR_PER (1U << FLASH_CR_PER_BIT) -#define FLASH_CR_PG (1U << FLASH_CR_PG_BIT) - -/* Option byte register */ - -#define FLASH_OBR_nRST_STDBY_BIT 4 -#define FLASH_OBR_nRST_STOP_BIT 3 -#define FLASH_OBR_WDG_SW_BIT 2 -#define FLASH_OBR_RDPRT_BIT 1 -#define FLASH_OBR_OPTERR_BIT 0 - -#define FLASH_OBR_DATA1 (0xFF << 18) -#define FLASH_OBR_DATA0 (0xFF << 10) -#define FLASH_OBR_USER 0x3FF -#define FLASH_OBR_nRST_STDBY (1U << FLASH_OBR_nRST_STDBY_BIT) -#define FLASH_OBR_nRST_STOP (1U << FLASH_OBR_nRST_STOP_BIT) -#define FLASH_OBR_WDG_SW (1U << FLASH_OBR_WDG_SW_BIT) -#define FLASH_OBR_RDPRT (1U << FLASH_OBR_RDPRT_BIT) -#define FLASH_OBR_OPTERR (1U << FLASH_OBR_OPTERR_BIT) - -/* - * Series-specific configuration values. - */ - -#define FLASH_SAFE_WAIT_STATES FLASH_WAIT_STATE_2 - -/* Flash memory features available via ACR */ -enum { - FLASH_PREFETCH = 0x10, - FLASH_HALF_CYCLE = 0x8, - FLASH_ICACHE = 0x0, /* Not available on STM32F1 */ - FLASH_DCACHE = 0x0, /* Not available on STM32F1 */ -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/gpio.h b/GD32F1/system/libmaple/stm32f1/include/series/gpio.h deleted file mode 100644 index 04376fe..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/gpio.h +++ /dev/null @@ -1,495 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/gpio.h - * @brief STM32F1 GPIO and AFIO support. - * General purpose I/O (GPIO) and Alternate Function I/O (AFIO). - */ - -#ifndef _LIBMAPLE_STM32F1_GPIO_H_ -#define _LIBMAPLE_STM32F1_GPIO_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include -#include - -/* - * GPIO register maps and devices - */ - -/** GPIO register map type */ -typedef struct gpio_reg_map { - __io uint32 CRL; /**< Port configuration register low */ - __io uint32 CRH; /**< Port configuration register high */ - __io uint32 IDR; /**< Port input data register */ - __io uint32 ODR; /**< Port output data register */ - __io uint32 BSRR; /**< Port bit set/reset register */ - __io uint32 BRR; /**< Port bit reset register */ - __io uint32 LCKR; /**< Port configuration lock register */ -} gpio_reg_map; - -struct gpio_dev; -extern struct gpio_dev gpioa; -extern struct gpio_dev* const GPIOA; -extern struct gpio_dev gpiob; -extern struct gpio_dev* const GPIOB; -extern struct gpio_dev gpioc; -extern struct gpio_dev* const GPIOC; -extern struct gpio_dev gpiod; -extern struct gpio_dev* const GPIOD; -#ifdef STM32_HIGH_DENSITY -extern struct gpio_dev gpioe; -extern struct gpio_dev* const GPIOE; -extern struct gpio_dev gpiof; -extern struct gpio_dev* const GPIOF; -extern struct gpio_dev gpiog; -extern struct gpio_dev* const GPIOG; -#endif - -/** GPIO port A register map base pointer */ -#define GPIOA_BASE ((struct gpio_reg_map*)0x40010800) -/** GPIO port B register map base pointer */ -#define GPIOB_BASE ((struct gpio_reg_map*)0x40010C00) -/** GPIO port C register map base pointer */ -#define GPIOC_BASE ((struct gpio_reg_map*)0x40011000) -/** GPIO port D register map base pointer */ -#define GPIOD_BASE ((struct gpio_reg_map*)0x40011400) -/** GPIO port E register map base pointer */ -#define GPIOE_BASE ((struct gpio_reg_map*)0x40011800) -/** GPIO port F register map base pointer */ -#define GPIOF_BASE ((struct gpio_reg_map*)0x40011C00) -/** GPIO port G register map base pointer */ -#define GPIOG_BASE ((struct gpio_reg_map*)0x40012000) - -/* - * GPIO register bit definitions - */ - -/* Control registers, low and high */ - -#define GPIO_CR_CNF (0x3 << 2) -#define GPIO_CR_CNF_INPUT_ANALOG (0x0 << 2) -#define GPIO_CR_CNF_INPUT_FLOATING (0x1 << 2) -#define GPIO_CR_CNF_INPUT_PU_PD (0x2 << 2) -#define GPIO_CR_CNF_OUTPUT_PP (0x0 << 2) -#define GPIO_CR_CNF_OUTPUT_OD (0x1 << 2) -#define GPIO_CR_CNF_AF_OUTPUT_PP (0x2 << 2) -#define GPIO_CR_CNF_AF_OUTPUT_OD (0x3 << 2) -#define GPIO_CR_MODE 0x3 -#define GPIO_CR_MODE_INPUT 0x0 -#define GPIO_CR_MODE_OUTPUT_10MHZ 0x1 -#define GPIO_CR_MODE_OUTPUT_2MHZ 0x2 -#define GPIO_CR_MODE_OUTPUT_50MHZ 0x3 - -/** - * @brief GPIO pin modes. - * - * These only allow for 50MHZ max output speeds; if you want slower, - * use direct register access. - */ -typedef enum gpio_pin_mode { - /** Output push-pull. */ - GPIO_OUTPUT_PP = GPIO_CR_CNF_OUTPUT_PP | GPIO_CR_MODE_OUTPUT_50MHZ, - /** Output open-drain. */ - GPIO_OUTPUT_OD = GPIO_CR_CNF_OUTPUT_OD | GPIO_CR_MODE_OUTPUT_50MHZ, - /** Alternate function output push-pull. */ - GPIO_AF_OUTPUT_PP = GPIO_CR_CNF_AF_OUTPUT_PP | GPIO_CR_MODE_OUTPUT_50MHZ, - /** Alternate function output open drain. */ - GPIO_AF_OUTPUT_OD = GPIO_CR_CNF_AF_OUTPUT_OD | GPIO_CR_MODE_OUTPUT_50MHZ, - /** Analog input. */ - GPIO_INPUT_ANALOG = GPIO_CR_CNF_INPUT_ANALOG | GPIO_CR_MODE_INPUT, - /** Input floating. */ - GPIO_INPUT_FLOATING = GPIO_CR_CNF_INPUT_FLOATING | GPIO_CR_MODE_INPUT, - /** Input pull-down. */ - GPIO_INPUT_PD = GPIO_CR_CNF_INPUT_PU_PD | GPIO_CR_MODE_INPUT, - /** Input pull-up. */ - GPIO_INPUT_PU, /* (treated a special case, for ODR twiddling) */ -} gpio_pin_mode; - -/* Hacks for F2: */ -#define GPIO_MODE_ANALOG GPIO_INPUT_ANALOG -#define GPIO_MODE_OUTPUT GPIO_OUTPUT_PP - -/* - * AFIO register map - */ - -/** AFIO register map */ -typedef struct afio_reg_map { - __io uint32 EVCR; /**< Event control register. */ - __io uint32 MAPR; /**< AF remap and debug I/O configuration register. */ - __io uint32 EXTICR1; /**< External interrupt configuration register 1. */ - __io uint32 EXTICR2; /**< External interrupt configuration register 2. */ - __io uint32 EXTICR3; /**< External interrupt configuration register 3. */ - __io uint32 EXTICR4; /**< External interrupt configuration register 4. */ - __io uint32 MAPR2; /**< - * AF remap and debug I/O configuration register 2. */ -} afio_reg_map; - -/** AFIO register map base pointer. */ -#define AFIO_BASE ((struct afio_reg_map *)0x40010000) - -/* - * AFIO register bit definitions - */ - -/* Event control register */ - -#define AFIO_EVCR_EVOE (0x1 << 7) -#define AFIO_EVCR_PORT_PA (0x0 << 4) -#define AFIO_EVCR_PORT_PB (0x1 << 4) -#define AFIO_EVCR_PORT_PC (0x2 << 4) -#define AFIO_EVCR_PORT_PD (0x3 << 4) -#define AFIO_EVCR_PORT_PE (0x4 << 4) -#define AFIO_EVCR_PIN_0 0x0 -#define AFIO_EVCR_PIN_1 0x1 -#define AFIO_EVCR_PIN_2 0x2 -#define AFIO_EVCR_PIN_3 0x3 -#define AFIO_EVCR_PIN_4 0x4 -#define AFIO_EVCR_PIN_5 0x5 -#define AFIO_EVCR_PIN_6 0x6 -#define AFIO_EVCR_PIN_7 0x7 -#define AFIO_EVCR_PIN_8 0x8 -#define AFIO_EVCR_PIN_9 0x9 -#define AFIO_EVCR_PIN_10 0xA -#define AFIO_EVCR_PIN_11 0xB -#define AFIO_EVCR_PIN_12 0xC -#define AFIO_EVCR_PIN_13 0xD -#define AFIO_EVCR_PIN_14 0xE -#define AFIO_EVCR_PIN_15 0xF - -/* AF remap and debug I/O configuration register */ - -#define AFIO_MAPR_SWJ_CFG (0x7 << 24) -#define AFIO_MAPR_SWJ_CFG_FULL_SWJ (0x0 << 24) -#define AFIO_MAPR_SWJ_CFG_FULL_SWJ_NO_NJRST (0x1 << 24) -#define AFIO_MAPR_SWJ_CFG_NO_JTAG_SW (0x2 << 24) -#define AFIO_MAPR_SWJ_CFG_NO_JTAG_NO_SW (0x4 << 24) -#define AFIO_MAPR_ADC2_ETRGREG_REMAP (1U << 20) -#define AFIO_MAPR_ADC2_ETRGINJ_REMAP (1U << 19) -#define AFIO_MAPR_ADC1_ETRGREG_REMAP (1U << 18) -#define AFIO_MAPR_ADC1_ETRGINJ_REMAP (1U << 17) -#define AFIO_MAPR_TIM5CH4_IREMAP (1U << 16) -#define AFIO_MAPR_PD01_REMAP (1U << 15) -#define AFIO_MAPR_CAN_REMAP (0x3 << 13) -#define AFIO_MAPR_CAN_REMAP_NONE (0x0 << 13) -#define AFIO_MAPR_CAN_REMAP_PB8_PB9 (0x2 << 13) -#define AFIO_MAPR_CAN_REMAP_PD0_PD1 (0x3 << 13) -#define AFIO_MAPR_TIM4_REMAP (1U << 12) -#define AFIO_MAPR_TIM3_REMAP (0x3 << 10) -#define AFIO_MAPR_TIM3_REMAP_NONE (0x0 << 10) -#define AFIO_MAPR_TIM3_REMAP_PARTIAL (0x2 << 10) -#define AFIO_MAPR_TIM3_REMAP_FULL (0x3 << 10) -#define AFIO_MAPR_TIM2_REMAP (0x3 << 8) -#define AFIO_MAPR_TIM2_REMAP_NONE (0x0 << 8) -#define AFIO_MAPR_TIM2_REMAP_PA15_PB3_PA2_PA3 (0x1 << 8) -#define AFIO_MAPR_TIM2_REMAP_PA0_PA1_PB10_PB11 (0x2 << 8) -#define AFIO_MAPR_TIM2_REMAP_FULL (0x3 << 8) -#define AFIO_MAPR_TIM1_REMAP (0x3 << 6) -#define AFIO_MAPR_TIM1_REMAP_NONE (0x0 << 6) -#define AFIO_MAPR_TIM1_REMAP_PARTIAL (0x1 << 6) -#define AFIO_MAPR_TIM1_REMAP_FULL (0x3 << 6) -#define AFIO_MAPR_USART3_REMAP (0x3 << 4) -#define AFIO_MAPR_USART3_REMAP_NONE (0x0 << 4) -#define AFIO_MAPR_USART3_REMAP_PARTIAL (0x1 << 4) -#define AFIO_MAPR_USART3_REMAP_FULL (0x3 << 4) -#define AFIO_MAPR_USART2_REMAP (1U << 3) -#define AFIO_MAPR_USART1_REMAP (1U << 2) -#define AFIO_MAPR_I2C1_REMAP (1U << 1) -#define AFIO_MAPR_SPI1_REMAP (1U << 0) - -/* External interrupt configuration register 1 */ - -#define AFIO_EXTICR1_EXTI3 (0xF << 12) -#define AFIO_EXTICR1_EXTI3_PA (0x0 << 12) -#define AFIO_EXTICR1_EXTI3_PB (0x1 << 12) -#define AFIO_EXTICR1_EXTI3_PC (0x2 << 12) -#define AFIO_EXTICR1_EXTI3_PD (0x3 << 12) -#define AFIO_EXTICR1_EXTI3_PE (0x4 << 12) -#define AFIO_EXTICR1_EXTI3_PF (0x5 << 12) -#define AFIO_EXTICR1_EXTI3_PG (0x6 << 12) -#define AFIO_EXTICR1_EXTI2 (0xF << 8) -#define AFIO_EXTICR1_EXTI2_PA (0x0 << 8) -#define AFIO_EXTICR1_EXTI2_PB (0x1 << 8) -#define AFIO_EXTICR1_EXTI2_PC (0x2 << 8) -#define AFIO_EXTICR1_EXTI2_PD (0x3 << 8) -#define AFIO_EXTICR1_EXTI2_PE (0x4 << 8) -#define AFIO_EXTICR1_EXTI2_PF (0x5 << 8) -#define AFIO_EXTICR1_EXTI2_PG (0x6 << 8) -#define AFIO_EXTICR1_EXTI1 (0xF << 4) -#define AFIO_EXTICR1_EXTI1_PA (0x0 << 4) -#define AFIO_EXTICR1_EXTI1_PB (0x1 << 4) -#define AFIO_EXTICR1_EXTI1_PC (0x2 << 4) -#define AFIO_EXTICR1_EXTI1_PD (0x3 << 4) -#define AFIO_EXTICR1_EXTI1_PE (0x4 << 4) -#define AFIO_EXTICR1_EXTI1_PF (0x5 << 4) -#define AFIO_EXTICR1_EXTI1_PG (0x6 << 4) -#define AFIO_EXTICR1_EXTI0 0xF -#define AFIO_EXTICR1_EXTI0_PA 0x0 -#define AFIO_EXTICR1_EXTI0_PB 0x1 -#define AFIO_EXTICR1_EXTI0_PC 0x2 -#define AFIO_EXTICR1_EXTI0_PD 0x3 -#define AFIO_EXTICR1_EXTI0_PE 0x4 -#define AFIO_EXTICR1_EXTI0_PF 0x5 -#define AFIO_EXTICR1_EXTI0_PG 0x6 - -/* External interrupt configuration register 2 */ - -#define AFIO_EXTICR2_EXTI7 (0xF << 12) -#define AFIO_EXTICR2_EXTI7_PA (0x0 << 12) -#define AFIO_EXTICR2_EXTI7_PB (0x1 << 12) -#define AFIO_EXTICR2_EXTI7_PC (0x2 << 12) -#define AFIO_EXTICR2_EXTI7_PD (0x3 << 12) -#define AFIO_EXTICR2_EXTI7_PE (0x4 << 12) -#define AFIO_EXTICR2_EXTI7_PF (0x5 << 12) -#define AFIO_EXTICR2_EXTI7_PG (0x6 << 12) -#define AFIO_EXTICR2_EXTI6 (0xF << 8) -#define AFIO_EXTICR2_EXTI6_PA (0x0 << 8) -#define AFIO_EXTICR2_EXTI6_PB (0x1 << 8) -#define AFIO_EXTICR2_EXTI6_PC (0x2 << 8) -#define AFIO_EXTICR2_EXTI6_PD (0x3 << 8) -#define AFIO_EXTICR2_EXTI6_PE (0x4 << 8) -#define AFIO_EXTICR2_EXTI6_PF (0x5 << 8) -#define AFIO_EXTICR2_EXTI6_PG (0x6 << 8) -#define AFIO_EXTICR2_EXTI5 (0xF << 4) -#define AFIO_EXTICR2_EXTI5_PA (0x0 << 4) -#define AFIO_EXTICR2_EXTI5_PB (0x1 << 4) -#define AFIO_EXTICR2_EXTI5_PC (0x2 << 4) -#define AFIO_EXTICR2_EXTI5_PD (0x3 << 4) -#define AFIO_EXTICR2_EXTI5_PE (0x4 << 4) -#define AFIO_EXTICR2_EXTI5_PF (0x5 << 4) -#define AFIO_EXTICR2_EXTI5_PG (0x6 << 4) -#define AFIO_EXTICR2_EXTI4 0xF -#define AFIO_EXTICR2_EXTI4_PA 0x0 -#define AFIO_EXTICR2_EXTI4_PB 0x1 -#define AFIO_EXTICR2_EXTI4_PC 0x2 -#define AFIO_EXTICR2_EXTI4_PD 0x3 -#define AFIO_EXTICR2_EXTI4_PE 0x4 -#define AFIO_EXTICR2_EXTI4_PF 0x5 -#define AFIO_EXTICR2_EXTI4_PG 0x6 - -/* AF remap and debug I/O configuration register 2 */ - -#define AFIO_MAPR2_FSMC_NADV (1U << 10) -#define AFIO_MAPR2_TIM14_REMAP (1U << 9) -#define AFIO_MAPR2_TIM13_REMAP (1U << 8) -#define AFIO_MAPR2_TIM11_REMAP (1U << 7) -#define AFIO_MAPR2_TIM10_REMAP (1U << 6) -#define AFIO_MAPR2_TIM9_REMAP (1U << 5) - -/* - * AFIO convenience routines - */ - -void afio_init(void); - -/* HACK: Use upper bit to denote MAPR2, Bit 31 is reserved and - * not used in either MAPR or MAPR2 */ -#define AFIO_REMAP_USE_MAPR2 (1U << 31) - -/** - * @brief Available peripheral remaps. - * @see afio_remap() - */ -typedef enum afio_remap_peripheral { - /** ADC 2 external trigger regular conversion remapping */ - AFIO_REMAP_ADC2_ETRGREG = AFIO_MAPR_ADC2_ETRGREG_REMAP, - /** ADC 2 external trigger injected conversion remapping */ - AFIO_REMAP_ADC2_ETRGINJ = AFIO_MAPR_ADC2_ETRGINJ_REMAP, - /** ADC 1 external trigger regular conversion remapping */ - AFIO_REMAP_ADC1_ETRGREG = AFIO_MAPR_ADC1_ETRGREG_REMAP, - /** ADC 1 external trigger injected conversion remapping */ - AFIO_REMAP_ADC1_ETRGINJ = AFIO_MAPR_ADC1_ETRGINJ_REMAP, - /** Timer 5 channel 4 internal remapping */ - AFIO_REMAP_TIM5CH4_I = AFIO_MAPR_TIM5CH4_IREMAP, - /** Port D0/Port D1 mapping on OSC_IN/OSC_OUT */ - AFIO_REMAP_PD01 = AFIO_MAPR_PD01_REMAP, - /** CAN alternate function remapping 1 (RX on PB8, TX on PB9) */ - AFIO_REMAP_CAN_1 = AFIO_MAPR_CAN_REMAP_PB8_PB9, - /** CAN alternate function remapping 2 (RX on PD0, TX on PD1) */ - AFIO_REMAP_CAN_2 = AFIO_MAPR_CAN_REMAP_PD0_PD1, - /** Timer 4 remapping */ - AFIO_REMAP_TIM4 = AFIO_MAPR_TIM4_REMAP, - /** Timer 3 partial remapping */ - AFIO_REMAP_TIM3_PARTIAL = AFIO_MAPR_TIM3_REMAP_PARTIAL, - /** Timer 3 full remapping */ - AFIO_REMAP_TIM3_FULL = AFIO_MAPR_TIM3_REMAP_FULL, - /** - * Timer 2 partial remapping 1 (CH1 and ETR on PA15, CH2 on PB3, - * CH3 on PA2, CH4 on PA3) */ - AFIO_REMAP_TIM2_PARTIAL_1 = AFIO_MAPR_TIM2_REMAP_PA15_PB3_PA2_PA3, - /** - * Timer 2 partial remapping 2 (CH1 and ETR on PA0, CH2 on PA1, - * CH3 on PB10, CH4 on PB11) */ - AFIO_REMAP_TIM2_PARTIAL_2 = AFIO_MAPR_TIM2_REMAP_PA0_PA1_PB10_PB11, - /** Timer 2 full remapping */ - AFIO_REMAP_TIM2_FULL = AFIO_MAPR_TIM2_REMAP_FULL, - /** USART 3 part remapping */ - AFIO_REMAP_USART3_PARTIAL = AFIO_MAPR_USART3_REMAP_PARTIAL, - /** USART 2 remapping */ - AFIO_REMAP_USART2 = AFIO_MAPR_USART2_REMAP, - /** USART 1 remapping */ - AFIO_REMAP_USART1 = AFIO_MAPR_USART1_REMAP, - /** I2C 1 remapping */ - AFIO_REMAP_I2C1 = AFIO_MAPR_I2C1_REMAP, - /** SPI 1 remapping */ - AFIO_REMAP_SPI1 = AFIO_MAPR_SPI1_REMAP, - /** NADV signal not connected */ - AFIO_REMAP_FSMC_NADV = AFIO_MAPR2_FSMC_NADV | AFIO_REMAP_USE_MAPR2, - /** Timer 14 remapping */ - AFIO_REMAP_TIM14 = AFIO_MAPR2_TIM14_REMAP | AFIO_REMAP_USE_MAPR2, - /** Timer 13 remapping */ - AFIO_REMAP_TIM13 = AFIO_MAPR2_TIM13_REMAP | AFIO_REMAP_USE_MAPR2, - /** Timer 11 remapping */ - AFIO_REMAP_TIM11 = AFIO_MAPR2_TIM11_REMAP | AFIO_REMAP_USE_MAPR2, - /** Timer 10 remapping */ - AFIO_REMAP_TIM10 = AFIO_MAPR2_TIM10_REMAP | AFIO_REMAP_USE_MAPR2, - /** Timer 9 remapping */ - AFIO_REMAP_TIM9 = AFIO_MAPR2_TIM9_REMAP | AFIO_REMAP_USE_MAPR2, -} afio_remap_peripheral; - -void afio_remap(afio_remap_peripheral p); - -/** - * @brief Debug port configuration - * - * Used to configure the behavior of JTAG and Serial Wire (SW) debug - * ports and their associated GPIO pins. - * - * @see afio_cfg_debug_ports() - */ -typedef enum afio_debug_cfg { - /** Full Serial Wire and JTAG debug */ - AFIO_DEBUG_FULL_SWJ = AFIO_MAPR_SWJ_CFG_FULL_SWJ, - /** Full Serial Wire and JTAG, but no NJTRST. */ - AFIO_DEBUG_FULL_SWJ_NO_NJRST = AFIO_MAPR_SWJ_CFG_FULL_SWJ_NO_NJRST, - /** Serial Wire debug only (JTAG-DP disabled, SW-DP enabled) */ - AFIO_DEBUG_SW_ONLY = AFIO_MAPR_SWJ_CFG_NO_JTAG_SW, - /** No debug; all JTAG and SW pins are free for use as GPIOs. */ - AFIO_DEBUG_NONE = AFIO_MAPR_SWJ_CFG_NO_JTAG_NO_SW, -} afio_debug_cfg; - -/** - * @brief Enable or disable the JTAG and SW debug ports. - * @param config Desired debug port configuration - * @see afio_debug_cfg - */ -static inline void afio_cfg_debug_ports(afio_debug_cfg config) { - __io uint32 *mapr = &AFIO_BASE->MAPR; - *mapr = (*mapr & ~AFIO_MAPR_SWJ_CFG) | config; -} - -/* - * Deprecated bits - */ - -/** - * @brief Deprecated. Use exti_cfg instead. - * - * In previous versions of libmaple, exti_attach_interrupt() took an - * afio_exti_port argument; afio_exti_port was also a member of struct - * gpio_dev. This isn't portable, so we now use exti_cfg - * instead. This typedef (and the macros AFIO_EXTI_PA, ..., - * AFIO_EXTI_PG) exist to preserve backwards compatibility. - */ -typedef exti_cfg afio_exti_port; - -/** Deprecated. Use EXTI_PA instead. */ -#define AFIO_EXTI_PA EXTI_PA -/** Deprecated. Use EXTI_PB instead. */ -#define AFIO_EXTI_PB EXTI_PB -/** Deprecated. Use EXTI_PC instead. */ -#define AFIO_EXTI_PC EXTI_PC -/** Deprecated. Use EXTI_PD instead. */ -#define AFIO_EXTI_PD EXTI_PD -/** Deprecated. Use EXTI_PE instead. */ -#define AFIO_EXTI_PE EXTI_PE -/** Deprecated. Use EXTI_PF instead. */ -#define AFIO_EXTI_PF EXTI_PF -/** Deprecated. Use EXTI_PG instead. */ -#define AFIO_EXTI_PG EXTI_PG - -/** - * @brief Deprecated. Use exti_num instead. - * - * In previous versions of libmaple, exti_attach_interrupt() took an - * afio_exti_num argument. This isn't portable, so we use exti_num - * instead. This typedef (and the macros AFIO_EXTI_0, ..., - * AFIO_EXTI_15) exist to preserve backwards compatibility. - */ -typedef exti_num afio_exti_num; - -/** Deprecated. Use EXTI0 instead. */ -#define AFIO_EXTI_0 EXTI0 -/** Deprecated. Use EXTI1 instead. */ -#define AFIO_EXTI_1 EXTI1 -/** Deprecated. Use EXTI2 instead. */ -#define AFIO_EXTI_2 EXTI2 -/** Deprecated. Use EXTI3 instead. */ -#define AFIO_EXTI_3 EXTI3 -/** Deprecated. Use EXTI4 instead. */ -#define AFIO_EXTI_4 EXTI4 -/** Deprecated. Use EXTI5 instead. */ -#define AFIO_EXTI_5 EXTI5 -/** Deprecated. Use EXTI6 instead. */ -#define AFIO_EXTI_6 EXTI6 -/** Deprecated. Use EXTI7 instead. */ -#define AFIO_EXTI_7 EXTI7 -/** Deprecated. Use EXTI8 instead. */ -#define AFIO_EXTI_8 EXTI8 -/** Deprecated. Use EXTI9 instead. */ -#define AFIO_EXTI_9 EXTI9 -/** Deprecated. Use EXTI10 instead. */ -#define AFIO_EXTI_10 EXTI10 -/** Deprecated. Use EXTI11 instead. */ -#define AFIO_EXTI_11 EXTI11 -/** Deprecated. Use EXTI12 instead. */ -#define AFIO_EXTI_12 EXTI12 -/** Deprecated. Use EXTI13 instead. */ -#define AFIO_EXTI_13 EXTI13 -/** Deprecated. Use EXTI14 instead. */ -#define AFIO_EXTI_14 EXTI14 -/** Deprecated. Use EXTI15 instead. */ -#define AFIO_EXTI_15 EXTI15 - -/** - * @brief Deprecated. Use exti_select(exti, port) instead. - */ -static __always_inline void afio_exti_select(exti_num exti, exti_cfg port) { - exti_select(exti, port); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/i2c.h b/GD32F1/system/libmaple/stm32f1/include/series/i2c.h deleted file mode 100644 index f407955..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/i2c.h +++ /dev/null @@ -1,85 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung (from ). - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/i2c.h - * @brief STM32F1 I2C - */ - -#ifndef _LIBMAPLE_STM32F1_I2C_H_ -#define _LIBMAPLE_STM32F1_I2C_H_ - -#include -#include -#include - -/* - * Register maps - */ - -struct i2c_reg_map; - -/** STM32F1 I2C1 register map base pointer */ -#define I2C1_BASE ((struct i2c_reg_map*)0x40005400) -/** STM32F1 I2C2 register map base pointer */ -#define I2C2_BASE ((struct i2c_reg_map*)0x40005800) - -/* - * Devices - */ - -extern i2c_dev* const I2C1; -extern i2c_dev* const I2C2; - -/* - * For internal use - */ - -static inline uint32 _i2c_bus_clk(i2c_dev *dev) { - /* Both I2C peripherals are on APB1 */ - return STM32_PCLK1 / (1000 * 1000); -} - -#define _I2C_HAVE_IRQ_FIXUP 1 -void _i2c_irq_priority_fixup(i2c_dev *dev); - -/* - * Deprecated functionality - */ - -/* Flag to use alternate pin mapping in i2c_master_enable(). */ -#define _I2C_HAVE_DEPRECATED_I2C_REMAP 1 -#define I2C_REMAP 0x4 -static inline void _i2c_handle_remap(i2c_dev *dev, uint32 flags) { - if ((dev == I2C1) && (flags & I2C_REMAP)) { - afio_remap(AFIO_REMAP_I2C1); - I2C1->sda_pin = 9; - I2C1->scl_pin = 8; - } -} - -#endif /* _LIBMAPLE_STM32F1_I2C_H_ */ diff --git a/GD32F1/system/libmaple/stm32f1/include/series/nvic.h b/GD32F1/system/libmaple/stm32f1/include/series/nvic.h deleted file mode 100644 index cdac737..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/nvic.h +++ /dev/null @@ -1,173 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/nvic.h - * @brief STM32F1 Nested Vectored Interrupt Controller (NVIC) support. - */ - -#ifndef _LIBMAPLE_STM32F1_NVIC_H_ -#define _LIBMAPLE_STM32F1_NVIC_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include - -/** - * @brief STM32F1 interrupt vector table interrupt numbers. - * @see - */ -typedef enum nvic_irq_num { - NVIC_NMI = -14, /**< Non-maskable interrupt */ - NVIC_HARDFAULT = -13, /**< Hard fault (all class of fault) */ - NVIC_MEM_MANAGE = -12, /**< Memory management */ - NVIC_BUS_FAULT = -11, /**< Bus fault: prefetch fault, memory - access fault. */ - NVIC_USAGE_FAULT = -10, /**< Usage fault: Undefined instruction or - illegal state. */ - NVIC_SVC = -5, /**< System service call via SWI insruction */ - NVIC_DEBUG_MON = -4, /**< Debug monitor */ - NVIC_PEND_SVC = -2, /**< Pendable request for system service */ - NVIC_SYSTICK = -1, /**< System tick timer */ - NVIC_WWDG = 0, /**< Window watchdog interrupt */ - NVIC_PVD = 1, /**< PVD through EXTI line detection */ - NVIC_TAMPER = 2, /**< Tamper */ - NVIC_RTC = 3, /**< Real-time clock */ - NVIC_FLASH = 4, /**< Flash */ - NVIC_RCC = 5, /**< Reset and clock control */ - NVIC_EXTI0 = 6, /**< EXTI line 0 */ - NVIC_EXTI1 = 7, /**< EXTI line 1 */ - NVIC_EXTI2 = 8, /**< EXTI line 2 */ - NVIC_EXTI3 = 9, /**< EXTI line 3 */ - NVIC_EXTI4 = 10, /**< EXTI line 4 */ - NVIC_DMA_CH1 = 11, /**< DMA1 channel 1 */ - NVIC_DMA_CH2 = 12, /**< DMA1 channel 2 */ - NVIC_DMA_CH3 = 13, /**< DMA1 channel 3 */ - NVIC_DMA_CH4 = 14, /**< DMA1 channel 4 */ - NVIC_DMA_CH5 = 15, /**< DMA1 channel 5 */ - NVIC_DMA_CH6 = 16, /**< DMA1 channel 6 */ - NVIC_DMA_CH7 = 17, /**< DMA1 channel 7 */ - NVIC_ADC_1_2 = 18, /**< ADC1 and ADC2 */ - NVIC_USB_HP_CAN_TX = 19, /**< USB high priority or CAN TX */ - NVIC_USB_LP_CAN_RX0 = 20, /**< USB low priority or CAN RX0 */ - NVIC_CAN_RX1 = 21, /**< CAN RX1 */ - NVIC_CAN_SCE = 22, /**< CAN SCE */ - NVIC_EXTI_9_5 = 23, /**< EXTI line [9:5] */ - NVIC_TIMER1_BRK_TIMER9 = 24, /**< Timer 1 break, Timer 9. */ - NVIC_TIMER1_UP_TIMER10 = 25, /**< Timer 1 update, Timer 10. */ - NVIC_TIMER1_TRG_COM_TIMER11 = 26, /**< - * Timer 1 trigger and commutation, - * Timer 11. */ - NVIC_TIMER1_CC = 27, /**< Timer 1 capture/compare */ - NVIC_TIMER2 = 28, /**< Timer 2 */ - NVIC_TIMER3 = 29, /**< Timer 3 */ - NVIC_TIMER4 = 30, /**< Timer 4 */ - NVIC_I2C1_EV = 31, /**< I2C1 event */ - NVIC_I2C1_ER = 32, /**< I2C1 error */ - NVIC_I2C2_EV = 33, /**< I2C2 event */ - NVIC_I2C2_ER = 34, /**< I2C2 error */ - NVIC_SPI1 = 35, /**< SPI1 */ - NVIC_SPI2 = 36, /**< SPI2 */ - NVIC_USART1 = 37, /**< USART1 */ - NVIC_USART2 = 38, /**< USART2 */ - NVIC_USART3 = 39, /**< USART3 */ - NVIC_EXTI_15_10 = 40, /**< EXTI line [15:10] */ - NVIC_RTCALARM = 41, /**< RTC alarm through EXTI line */ - NVIC_USBWAKEUP = 42, /**< USB wakeup from suspend through - EXTI line */ - NVIC_TIMER8_BRK_TIMER12 = 43, /**< Timer 8 break, timer 12 */ - NVIC_TIMER8_UP_TIMER13 = 44, /**< Timer 8 update, timer 13 */ - NVIC_TIMER8_TRG_COM_TIMER14 = 45, /**< - * Timer 8 trigger and commutation, - * Timer 14. */ - NVIC_TIMER8_CC = 46, /**< Timer 8 capture/compare */ - NVIC_ADC3 = 47, /**< ADC3 */ - NVIC_FSMC = 48, /**< FSMC */ - NVIC_SDIO = 49, /**< SDIO */ - NVIC_TIMER5 = 50, /**< Timer 5 */ - NVIC_SPI3 = 51, /**< SPI3 */ - NVIC_UART4 = 52, /**< UART4 */ - NVIC_UART5 = 53, /**< UART5 */ - NVIC_TIMER6 = 54, /**< Timer 6 */ - NVIC_TIMER7 = 55, /**< Timer 7 */ - NVIC_DMA2_CH1 = 56, /**< DMA2 channel 1 */ - NVIC_DMA2_CH2 = 57, /**< DMA2 channel 2 */ - NVIC_DMA2_CH3 = 58, /**< DMA2 channel 3 */ - NVIC_DMA2_CH_4_5 = 59, /**< DMA2 channels 4 and 5 */ - - /* Old enumerators kept around for backwards compatibility: */ - NVIC_TIMER1_BRK = - NVIC_TIMER1_BRK_TIMER9, /**< @brief (Deprecated) Timer 1 break - * - * For backwards compatibility only. - * Use NVIC_TIMER1_BRK_TIMER9 instead. */ - NVIC_TIMER1_UP = - NVIC_TIMER1_UP_TIMER10, /**< @brief (Deprecated) Timer 1 update. - * - * For backwards compatibility only. - * Use NVIC_TIMER1_UP_TIMER10 instead. */ - NVIC_TIMER1_TRG_COM = - NVIC_TIMER1_TRG_COM_TIMER11, /**< @brief (deprecated) Timer 1 trigger - * and commutation. - * - * For backwards compatibility only. - * Use NVIC_TIMER1_TRG_COM_TIMER11 - * instead. */ - NVIC_TIMER8_BRK = - NVIC_TIMER8_BRK_TIMER12, /**< @brief (deprecated) Timer 8 break - * - * For backwards compatibility only. - * Use NVIC_TIMER8_BRK_TIMER12 instead. */ - NVIC_TIMER8_UP = - NVIC_TIMER8_UP_TIMER13, /**< @brief (deprecated) Timer 8 update - * For backwards compatibility only. - * Use NVIC_TIMER8_UP_TIMER13 instead. */ - NVIC_TIMER8_TRG_COM = - NVIC_TIMER8_TRG_COM_TIMER14, /**< @brief (deprecated) Timer 8 trigger - * and commutation. - * For backwards compatibility only. - * Use NVIC_TIMER8_TRG_COM_TIMER14 - * instead. */ -} nvic_irq_num; - -static inline void nvic_irq_disable_all(void) { - /* Even low-density devices have over 32 interrupt lines. */ - NVIC_BASE->ICER[0] = 0xFFFFFFFF; - NVIC_BASE->ICER[1] = 0xFFFFFFFF; -#if STM32_NR_INTERRUPTS > 64 - /* Only some have over 64; e.g. connectivity line MCUs. */ - NVIC_BASE->ICER[2] = 0xFFFFFFFF; -#endif -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/pwr.h b/GD32F1/system/libmaple/stm32f1/include/series/pwr.h deleted file mode 100644 index e143a8c..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/pwr.h +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/pwr.h - * @author Marti Bolivar - * @brief STM32F1 Power control (PWR) support. - */ - -#ifndef _LIBMAPLE_STM32F1_PWR_H_ -#define _LIBMAPLE_STM32F1_PWR_H_ - -/* - * Register bit definitions - */ - -/* Control register */ - -/* PVD level selection */ -#define PWR_CR_PLS_2_2V (0x0 << 5) -#define PWR_CR_PLS_2_3V (0x1 << 5) -#define PWR_CR_PLS_2_4V (0x2 << 5) -#define PWR_CR_PLS_2_5V (0x3 << 5) -#define PWR_CR_PLS_2_6V (0x4 << 5) -#define PWR_CR_PLS_2_7V (0x5 << 5) -#define PWR_CR_PLS_2_8V (0x6 << 5) -#define PWR_CR_PLS_2_9V (0x7 << 5) - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/rcc.h b/GD32F1/system/libmaple/stm32f1/include/series/rcc.h deleted file mode 100644 index f902dbb..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/rcc.h +++ /dev/null @@ -1,642 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/rcc.h - * @brief STM32F1 reset and clock control (RCC) support. - */ - -#ifndef _LIBMAPLE_STM32F1_RCC_H_ -#define _LIBMAPLE_STM32F1_RCC_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -#include -#include - -/* - * Register map - */ - -/** STM32F1 RCC register map type */ -typedef struct rcc_reg_map { - __io uint32 CR; /**< Clock control register */ - __io uint32 CFGR; /**< Clock configuration register */ - __io uint32 CIR; /**< Clock interrupt register */ - __io uint32 APB2RSTR; /**< APB2 peripheral reset register */ - __io uint32 APB1RSTR; /**< APB1 peripheral reset register */ - __io uint32 AHBENR; /**< AHB peripheral clock enable register */ - __io uint32 APB2ENR; /**< APB2 peripheral clock enable register */ - __io uint32 APB1ENR; /**< APB1 peripheral clock enable register */ - __io uint32 BDCR; /**< Backup domain control register */ - __io uint32 CSR; /**< Control/status register */ -} rcc_reg_map; - -#define RCC_BASE ((struct rcc_reg_map*)0x40021000) - -/* - * Register bit definitions - */ - -/* Clock control register */ - -#define RCC_CR_PLLRDY_BIT 25 -#define RCC_CR_PLLON_BIT 24 -#define RCC_CR_CSSON_BIT 19 -#define RCC_CR_HSEBYP_BIT 18 -#define RCC_CR_HSERDY_BIT 17 -#define RCC_CR_HSEON_BIT 16 -#define RCC_CR_HSIRDY_BIT 1 -#define RCC_CR_HSION_BIT 0 - -#define RCC_CR_PLLRDY (1U << RCC_CR_PLLRDY_BIT) -#define RCC_CR_PLLON (1U << RCC_CR_PLLON_BIT) -#define RCC_CR_CSSON (1U << RCC_CR_CSSON_BIT) -#define RCC_CR_HSEBYP (1U << RCC_CR_HSEBYP_BIT) -#define RCC_CR_HSERDY (1U << RCC_CR_HSERDY_BIT) -#define RCC_CR_HSEON (1U << RCC_CR_HSEON_BIT) -#define RCC_CR_HSICAL (0xFF << 8) -#define RCC_CR_HSITRIM (0x1F << 3) -#define RCC_CR_HSIRDY (1U << RCC_CR_HSIRDY_BIT) -#define RCC_CR_HSION (1U << RCC_CR_HSION_BIT) - -/* Clock configuration register */ - -#define RCC_CFGR_USBPRE_BIT 22 -#define RCC_CFGR_PLLXTPRE_BIT 17 -#define RCC_CFGR_PLLSRC_BIT 16 - -#define RCC_CFGR_MCO (0x3 << 24) -#define RCC_CFGR_USBPRE (0x3 << RCC_CFGR_USBPRE_BIT) -#define RCC_CFGR_PLLMUL (0xF << 18) -#define RCC_CFGR_PLLXTPRE (1U << RCC_CFGR_PLLXTPRE_BIT) -#define RCC_CFGR_PLLSRC (1U << RCC_CFGR_PLLSRC_BIT) -#define RCC_CFGR_ADCPRE (0x3 << 14) -#define RCC_CFGR_PPRE2 (0x7 << 11) -#define RCC_CFGR_PPRE1 (0x7 << 8) -#define RCC_CFGR_HPRE (0xF << 4) -#define RCC_CFGR_SWS (0x3 << 2) -#define RCC_CFGR_SWS_PLL (0x2 << 2) -#define RCC_CFGR_SWS_HSE (0x1 << 2) -#define RCC_CFGR_SW 0x3 -#define RCC_CFGR_SW_PLL 0x2 -#define RCC_CFGR_SW_HSE 0x1 - -/* Clock interrupt register */ - -#define RCC_CIR_CSSC_BIT 23 -#define RCC_CIR_PLLRDYC_BIT 20 -#define RCC_CIR_HSERDYC_BIT 19 -#define RCC_CIR_HSIRDYC_BIT 18 -#define RCC_CIR_LSERDYC_BIT 17 -#define RCC_CIR_LSIRDYC_BIT 16 -#define RCC_CIR_PLLRDYIE_BIT 12 -#define RCC_CIR_HSERDYIE_BIT 11 -#define RCC_CIR_HSIRDYIE_BIT 10 -#define RCC_CIR_LSERDYIE_BIT 9 -#define RCC_CIR_LSIRDYIE_BIT 8 -#define RCC_CIR_CSSF_BIT 7 -#define RCC_CIR_PLLRDYF_BIT 4 -#define RCC_CIR_HSERDYF_BIT 3 -#define RCC_CIR_HSIRDYF_BIT 2 -#define RCC_CIR_LSERDYF_BIT 1 -#define RCC_CIR_LSIRDYF_BIT 0 - -#define RCC_CIR_CSSC (1U << RCC_CIR_CSSC_BIT) -#define RCC_CIR_PLLRDYC (1U << RCC_CIR_PLLRDYC_BIT) -#define RCC_CIR_HSERDYC (1U << RCC_CIR_HSERDYC_BIT) -#define RCC_CIR_HSIRDYC (1U << RCC_CIR_HSIRDYC_BIT) -#define RCC_CIR_LSERDYC (1U << RCC_CIR_LSERDYC_BIT) -#define RCC_CIR_LSIRDYC (1U << RCC_CIR_LSIRDYC_BIT) -#define RCC_CIR_PLLRDYIE (1U << RCC_CIR_PLLRDYIE_BIT) -#define RCC_CIR_HSERDYIE (1U << RCC_CIR_HSERDYIE_BIT) -#define RCC_CIR_HSIRDYIE (1U << RCC_CIR_HSIRDYIE_BIT) -#define RCC_CIR_LSERDYIE (1U << RCC_CIR_LSERDYIE_BIT) -#define RCC_CIR_LSIRDYIE (1U << RCC_CIR_LSIRDYIE_BIT) -#define RCC_CIR_CSSF (1U << RCC_CIR_CSSF_BIT) -#define RCC_CIR_PLLRDYF (1U << RCC_CIR_PLLRDYF_BIT) -#define RCC_CIR_HSERDYF (1U << RCC_CIR_HSERDYF_BIT) -#define RCC_CIR_HSIRDYF (1U << RCC_CIR_HSIRDYF_BIT) -#define RCC_CIR_LSERDYF (1U << RCC_CIR_LSERDYF_BIT) -#define RCC_CIR_LSIRDYF (1U << RCC_CIR_LSIRDYF_BIT) - -/* APB2 peripheral reset register */ - -#define RCC_APB2RSTR_TIM11RST_BIT 21 -#define RCC_APB2RSTR_TIM10RST_BIT 20 -#define RCC_APB2RSTR_TIM9RST_BIT 19 -#define RCC_APB2RSTR_ADC3RST_BIT 15 -#define RCC_APB2RSTR_USART1RST_BIT 14 -#define RCC_APB2RSTR_TIM8RST_BIT 13 -#define RCC_APB2RSTR_SPI1RST_BIT 12 -#define RCC_APB2RSTR_TIM1RST_BIT 11 -#define RCC_APB2RSTR_ADC2RST_BIT 10 -#define RCC_APB2RSTR_ADC1RST_BIT 9 -#define RCC_APB2RSTR_IOPGRST_BIT 8 -#define RCC_APB2RSTR_IOPFRST_BIT 7 -#define RCC_APB2RSTR_IOPERST_BIT 6 -#define RCC_APB2RSTR_IOPDRST_BIT 5 -#define RCC_APB2RSTR_IOPCRST_BIT 4 -#define RCC_APB2RSTR_IOPBRST_BIT 3 -#define RCC_APB2RSTR_IOPARST_BIT 2 -#define RCC_APB2RSTR_AFIORST_BIT 0 - -#define RCC_APB2RSTR_TIM11RST (1U << RCC_APB2RSTR_TIM11RST_BIT) -#define RCC_APB2RSTR_TIM10RST (1U << RCC_APB2RSTR_TIM10RST_BIT) -#define RCC_APB2RSTR_TIM9RST (1U << RCC_APB2RSTR_TIM9RST_BIT) -#define RCC_APB2RSTR_ADC3RST (1U << RCC_APB2RSTR_ADC3RST_BIT) -#define RCC_APB2RSTR_USART1RST (1U << RCC_APB2RSTR_USART1RST_BIT) -#define RCC_APB2RSTR_TIM8RST (1U << RCC_APB2RSTR_TIM8RST_BIT) -#define RCC_APB2RSTR_SPI1RST (1U << RCC_APB2RSTR_SPI1RST_BIT) -#define RCC_APB2RSTR_TIM1RST (1U << RCC_APB2RSTR_TIM1RST_BIT) -#define RCC_APB2RSTR_ADC2RST (1U << RCC_APB2RSTR_ADC2RST_BIT) -#define RCC_APB2RSTR_ADC1RST (1U << RCC_APB2RSTR_ADC1RST_BIT) -#define RCC_APB2RSTR_IOPGRST (1U << RCC_APB2RSTR_IOPGRST_BIT) -#define RCC_APB2RSTR_IOPFRST (1U << RCC_APB2RSTR_IOPFRST_BIT) -#define RCC_APB2RSTR_IOPERST (1U << RCC_APB2RSTR_IOPERST_BIT) -#define RCC_APB2RSTR_IOPDRST (1U << RCC_APB2RSTR_IOPDRST_BIT) -#define RCC_APB2RSTR_IOPCRST (1U << RCC_APB2RSTR_IOPCRST_BIT) -#define RCC_APB2RSTR_IOPBRST (1U << RCC_APB2RSTR_IOPBRST_BIT) -#define RCC_APB2RSTR_IOPARST (1U << RCC_APB2RSTR_IOPARST_BIT) -#define RCC_APB2RSTR_AFIORST (1U << RCC_APB2RSTR_AFIORST_BIT) - -/* APB1 peripheral reset register */ - -#define RCC_APB1RSTR_DACRST_BIT 29 -#define RCC_APB1RSTR_PWRRST_BIT 28 -#define RCC_APB1RSTR_BKPRST_BIT 27 -#define RCC_APB1RSTR_CANRST_BIT 25 -#define RCC_APB1RSTR_USBRST_BIT 23 -#define RCC_APB1RSTR_I2C2RST_BIT 22 -#define RCC_APB1RSTR_I2C1RST_BIT 21 -#define RCC_APB1RSTR_UART5RST_BIT 20 -#define RCC_APB1RSTR_UART4RST_BIT 19 -#define RCC_APB1RSTR_USART3RST_BIT 18 -#define RCC_APB1RSTR_USART2RST_BIT 17 -#define RCC_APB1RSTR_SPI3RST_BIT 15 -#define RCC_APB1RSTR_SPI2RST_BIT 14 -#define RCC_APB1RSTR_WWDRST_BIT 11 -#define RCC_APB1RSTR_TIM14RST_BIT 8 -#define RCC_APB1RSTR_TIM13RST_BIT 7 -#define RCC_APB1RSTR_TIM12RST_BIT 6 -#define RCC_APB1RSTR_TIM7RST_BIT 5 -#define RCC_APB1RSTR_TIM6RST_BIT 4 -#define RCC_APB1RSTR_TIM5RST_BIT 3 -#define RCC_APB1RSTR_TIM4RST_BIT 2 -#define RCC_APB1RSTR_TIM3RST_BIT 1 -#define RCC_APB1RSTR_TIM2RST_BIT 0 - -#define RCC_APB1RSTR_DACRST (1U << RCC_APB1RSTR_DACRST_BIT) -#define RCC_APB1RSTR_PWRRST (1U << RCC_APB1RSTR_PWRRST_BIT) -#define RCC_APB1RSTR_BKPRST (1U << RCC_APB1RSTR_BKPRST_BIT) -#define RCC_APB1RSTR_CANRST (1U << RCC_APB1RSTR_CANRST_BIT) -#define RCC_APB1RSTR_USBRST (1U << RCC_APB1RSTR_USBRST_BIT) -#define RCC_APB1RSTR_I2C2RST (1U << RCC_APB1RSTR_I2C2RST_BIT) -#define RCC_APB1RSTR_I2C1RST (1U << RCC_APB1RSTR_I2C1RST_BIT) -#define RCC_APB1RSTR_UART5RST (1U << RCC_APB1RSTR_UART5RST_BIT) -#define RCC_APB1RSTR_UART4RST (1U << RCC_APB1RSTR_UART4RST_BIT) -#define RCC_APB1RSTR_USART3RST (1U << RCC_APB1RSTR_USART3RST_BIT) -#define RCC_APB1RSTR_USART2RST (1U << RCC_APB1RSTR_USART2RST_BIT) -#define RCC_APB1RSTR_SPI3RST (1U << RCC_APB1RSTR_SPI3RST_BIT) -#define RCC_APB1RSTR_SPI2RST (1U << RCC_APB1RSTR_SPI2RST_BIT) -#define RCC_APB1RSTR_WWDRST (1U << RCC_APB1RSTR_WWDRST_BIT) -#define RCC_APB1RSTR_TIM14RST (1U << RCC_APB1RSTR_TIM14RST_BIT) -#define RCC_APB1RSTR_TIM13RST (1U << RCC_APB1RSTR_TIM13RST_BIT) -#define RCC_APB1RSTR_TIM12RST (1U << RCC_APB1RSTR_TIM12RST_BIT) -#define RCC_APB1RSTR_TIM7RST (1U << RCC_APB1RSTR_TIM7RST_BIT) -#define RCC_APB1RSTR_TIM6RST (1U << RCC_APB1RSTR_TIM6RST_BIT) -#define RCC_APB1RSTR_TIM5RST (1U << RCC_APB1RSTR_TIM5RST_BIT) -#define RCC_APB1RSTR_TIM4RST (1U << RCC_APB1RSTR_TIM4RST_BIT) -#define RCC_APB1RSTR_TIM3RST (1U << RCC_APB1RSTR_TIM3RST_BIT) -#define RCC_APB1RSTR_TIM2RST (1U << RCC_APB1RSTR_TIM2RST_BIT) - -/* AHB peripheral clock enable register */ - -#define RCC_AHBENR_SDIOEN_BIT 10 -#define RCC_AHBENR_FSMCEN_BIT 8 -#define RCC_AHBENR_CRCEN_BIT 7 -#define RCC_AHBENR_FLITFEN_BIT 4 -#define RCC_AHBENR_SRAMEN_BIT 2 -#define RCC_AHBENR_DMA2EN_BIT 1 -#define RCC_AHBENR_DMA1EN_BIT 0 - -#define RCC_AHBENR_SDIOEN (1U << RCC_AHBENR_SDIOEN_BIT) -#define RCC_AHBENR_FSMCEN (1U << RCC_AHBENR_FSMCEN_BIT) -#define RCC_AHBENR_CRCEN (1U << RCC_AHBENR_CRCEN_BIT) -#define RCC_AHBENR_FLITFEN (1U << RCC_AHBENR_FLITFEN_BIT) -#define RCC_AHBENR_SRAMEN (1U << RCC_AHBENR_SRAMEN_BIT) -#define RCC_AHBENR_DMA2EN (1U << RCC_AHBENR_DMA2EN_BIT) -#define RCC_AHBENR_DMA1EN (1U << RCC_AHBENR_DMA1EN_BIT) - -/* APB2 peripheral clock enable register */ - -#define RCC_APB2ENR_TIM11EN_BIT 21 -#define RCC_APB2ENR_TIM10EN_BIT 20 -#define RCC_APB2ENR_TIM9EN_BIT 19 -#define RCC_APB2ENR_ADC3EN_BIT 15 -#define RCC_APB2ENR_USART1EN_BIT 14 -#define RCC_APB2ENR_TIM8EN_BIT 13 -#define RCC_APB2ENR_SPI1EN_BIT 12 -#define RCC_APB2ENR_TIM1EN_BIT 11 -#define RCC_APB2ENR_ADC2EN_BIT 10 -#define RCC_APB2ENR_ADC1EN_BIT 9 -#define RCC_APB2ENR_IOPGEN_BIT 8 -#define RCC_APB2ENR_IOPFEN_BIT 7 -#define RCC_APB2ENR_IOPEEN_BIT 6 -#define RCC_APB2ENR_IOPDEN_BIT 5 -#define RCC_APB2ENR_IOPCEN_BIT 4 -#define RCC_APB2ENR_IOPBEN_BIT 3 -#define RCC_APB2ENR_IOPAEN_BIT 2 -#define RCC_APB2ENR_AFIOEN_BIT 0 - -#define RCC_APB2ENR_TIM11EN (1U << RCC_APB2ENR_TIM11EN_BIT) -#define RCC_APB2ENR_TIM10EN (1U << RCC_APB2ENR_TIM10EN_BIT) -#define RCC_APB2ENR_TIM9EN (1U << RCC_APB2ENR_TIM9EN_BIT) -#define RCC_APB2ENR_ADC3EN (1U << RCC_APB2ENR_ADC3EN_BIT) -#define RCC_APB2ENR_USART1EN (1U << RCC_APB2ENR_USART1EN_BIT) -#define RCC_APB2ENR_TIM8EN (1U << RCC_APB2ENR_TIM8EN_BIT) -#define RCC_APB2ENR_SPI1EN (1U << RCC_APB2ENR_SPI1EN_BIT) -#define RCC_APB2ENR_TIM1EN (1U << RCC_APB2ENR_TIM1EN_BIT) -#define RCC_APB2ENR_ADC2EN (1U << RCC_APB2ENR_ADC2EN_BIT) -#define RCC_APB2ENR_ADC1EN (1U << RCC_APB2ENR_ADC1EN_BIT) -#define RCC_APB2ENR_IOPGEN (1U << RCC_APB2ENR_IOPGEN_BIT) -#define RCC_APB2ENR_IOPFEN (1U << RCC_APB2ENR_IOPFEN_BIT) -#define RCC_APB2ENR_IOPEEN (1U << RCC_APB2ENR_IOPEEN_BIT) -#define RCC_APB2ENR_IOPDEN (1U << RCC_APB2ENR_IOPDEN_BIT) -#define RCC_APB2ENR_IOPCEN (1U << RCC_APB2ENR_IOPCEN_BIT) -#define RCC_APB2ENR_IOPBEN (1U << RCC_APB2ENR_IOPBEN_BIT) -#define RCC_APB2ENR_IOPAEN (1U << RCC_APB2ENR_IOPAEN_BIT) -#define RCC_APB2ENR_AFIOEN (1U << RCC_APB2ENR_AFIOEN_BIT) - -/* APB1 peripheral clock enable register */ - -#define RCC_APB1ENR_DACEN_BIT 29 -#define RCC_APB1ENR_PWREN_BIT 28 -#define RCC_APB1ENR_BKPEN_BIT 27 -#define RCC_APB1ENR_CANEN_BIT 25 -#define RCC_APB1ENR_USBEN_BIT 23 -#define RCC_APB1ENR_I2C2EN_BIT 22 -#define RCC_APB1ENR_I2C1EN_BIT 21 -#define RCC_APB1ENR_UART5EN_BIT 20 -#define RCC_APB1ENR_UART4EN_BIT 19 -#define RCC_APB1ENR_USART3EN_BIT 18 -#define RCC_APB1ENR_USART2EN_BIT 17 -#define RCC_APB1ENR_SPI3EN_BIT 15 -#define RCC_APB1ENR_SPI2EN_BIT 14 -#define RCC_APB1ENR_WWDEN_BIT 11 -#define RCC_APB1ENR_TIM14EN_BIT 8 -#define RCC_APB1ENR_TIM13EN_BIT 7 -#define RCC_APB1ENR_TIM12EN_BIT 6 -#define RCC_APB1ENR_TIM7EN_BIT 5 -#define RCC_APB1ENR_TIM6EN_BIT 4 -#define RCC_APB1ENR_TIM5EN_BIT 3 -#define RCC_APB1ENR_TIM4EN_BIT 2 -#define RCC_APB1ENR_TIM3EN_BIT 1 -#define RCC_APB1ENR_TIM2EN_BIT 0 - -#define RCC_APB1ENR_DACEN (1U << RCC_APB1ENR_DACEN_BIT) -#define RCC_APB1ENR_PWREN (1U << RCC_APB1ENR_PWREN_BIT) -#define RCC_APB1ENR_BKPEN (1U << RCC_APB1ENR_BKPEN_BIT) -#define RCC_APB1ENR_CANEN (1U << RCC_APB1ENR_CANEN_BIT) -#define RCC_APB1ENR_USBEN (1U << RCC_APB1ENR_USBEN_BIT) -#define RCC_APB1ENR_I2C2EN (1U << RCC_APB1ENR_I2C2EN_BIT) -#define RCC_APB1ENR_I2C1EN (1U << RCC_APB1ENR_I2C1EN_BIT) -#define RCC_APB1ENR_UART5EN (1U << RCC_APB1ENR_UART5EN_BIT) -#define RCC_APB1ENR_UART4EN (1U << RCC_APB1ENR_UART4EN_BIT) -#define RCC_APB1ENR_USART3EN (1U << RCC_APB1ENR_USART3EN_BIT) -#define RCC_APB1ENR_USART2EN (1U << RCC_APB1ENR_USART2EN_BIT) -#define RCC_APB1ENR_SPI3EN (1U << RCC_APB1ENR_SPI3EN_BIT) -#define RCC_APB1ENR_SPI2EN (1U << RCC_APB1ENR_SPI2EN_BIT) -#define RCC_APB1ENR_WWDEN (1U << RCC_APB1ENR_WWDEN_BIT) -#define RCC_APB1ENR_TIM14EN (1U << RCC_APB1ENR_TIM14EN_BIT) -#define RCC_APB1ENR_TIM13EN (1U << RCC_APB1ENR_TIM13EN_BIT) -#define RCC_APB1ENR_TIM12EN (1U << RCC_APB1ENR_TIM12EN_BIT) -#define RCC_APB1ENR_TIM7EN (1U << RCC_APB1ENR_TIM7EN_BIT) -#define RCC_APB1ENR_TIM6EN (1U << RCC_APB1ENR_TIM6EN_BIT) -#define RCC_APB1ENR_TIM5EN (1U << RCC_APB1ENR_TIM5EN_BIT) -#define RCC_APB1ENR_TIM4EN (1U << RCC_APB1ENR_TIM4EN_BIT) -#define RCC_APB1ENR_TIM3EN (1U << RCC_APB1ENR_TIM3EN_BIT) -#define RCC_APB1ENR_TIM2EN (1U << RCC_APB1ENR_TIM2EN_BIT) - -/* Backup domain control register */ - -#define RCC_BDCR_BDRST_BIT 16 -#define RCC_BDCR_RTCEN_BIT 15 -#define RCC_BDCR_LSEBYP_BIT 2 -#define RCC_BDCR_LSERDY_BIT 1 -#define RCC_BDCR_LSEON_BIT 0 - -#define RCC_BDCR_BDRST (1U << RCC_BDCR_BDRST_BIT) -#define RCC_BDCR_RTCEN (1U << RCC_BDCR_RTC_BIT) -#define RCC_BDCR_RTCSEL (0x3 << 8) -#define RCC_BDCR_RTCSEL_NONE (0x0 << 8) -#define RCC_BDCR_RTCSEL_LSE (0x1 << 8) -#define RCC_BDCR_RTCSEL_LSI (0x2 << 8) // added to support RTClock -#define RCC_BDCR_RTCSEL_HSE (0x3 << 8) -#define RCC_BDCR_LSEBYP (1U << RCC_BDCR_LSEBYP_BIT) -#define RCC_BDCR_LSERDY (1U << RCC_BDCR_LSERDY_BIT) -#define RCC_BDCR_LSEON (1U << RCC_BDCR_LSEON_BIT) - -/* Control/status register */ - -#define RCC_CSR_LPWRRSTF_BIT 31 -#define RCC_CSR_WWDGRSTF_BIT 30 -#define RCC_CSR_IWDGRSTF_BIT 29 -#define RCC_CSR_SFTRSTF_BIT 28 -#define RCC_CSR_PORRSTF_BIT 27 -#define RCC_CSR_PINRSTF_BIT 26 -#define RCC_CSR_RMVF_BIT 24 -#define RCC_CSR_LSIRDY_BIT 1 -#define RCC_CSR_LSION_BIT 0 - -#define RCC_CSR_LPWRRSTF (1U << RCC_CSR_LPWRRSTF_BIT) -#define RCC_CSR_WWDGRSTF (1U << RCC_CSR_WWDGRSTF_BIT) -#define RCC_CSR_IWDGRSTF (1U << RCC_CSR_IWDGRSTF_BIT) -#define RCC_CSR_SFTRSTF (1U << RCC_CSR_SFTRSTF_BIT) -#define RCC_CSR_PORRSTF (1U << RCC_CSR_PORRSTF_BIT) -#define RCC_CSR_PINRSTF (1U << RCC_CSR_PINRSTF_BIT) -#define RCC_CSR_RMVF (1U << RCC_CSR_RMVF_BIT) -#define RCC_CSR_LSIRDY (1U << RCC_CSR_LSIRDY_BIT) -#define RCC_CSR_LSION (1U << RCC_CSR_LSION_BIT) - -/* - * libmaple-mandated enumeration types. - */ - -/** - * @brief STM32F1 rcc_clk_id. - */ -typedef enum rcc_clk_id { - RCC_ADC1, - RCC_ADC2, - RCC_ADC3, - RCC_AFIO, - RCC_BKP, - RCC_CRC, - RCC_DAC, - RCC_DMA1, - RCC_DMA2, - RCC_FLITF, - RCC_FSMC, - RCC_GPIOA, - RCC_GPIOB, - RCC_GPIOC, - RCC_GPIOD, - RCC_GPIOE, - RCC_GPIOF, - RCC_GPIOG, - RCC_I2C1, - RCC_I2C2, - RCC_PWR, - RCC_SDIO, - RCC_SPI1, - RCC_SPI2, - RCC_SPI3, - RCC_SRAM, - RCC_TIMER1, - RCC_TIMER2, - RCC_TIMER3, - RCC_TIMER4, - RCC_TIMER5, - RCC_TIMER6, - RCC_TIMER7, - RCC_TIMER8, - RCC_TIMER9, - RCC_TIMER10, - RCC_TIMER11, - RCC_TIMER12, - RCC_TIMER13, - RCC_TIMER14, - RCC_USART1, - RCC_USART2, - RCC_USART3, - RCC_UART4, - RCC_UART5, - RCC_USB, -} rcc_clk_id; - -/** - * @brief STM32F1 PLL clock sources. - * @see rcc_configure_pll() - */ -typedef enum rcc_pllsrc { - RCC_PLLSRC_HSE = (0x1 << 16), - RCC_PLLSRC_HSI_DIV_2 = (0x0 << 16) -} rcc_pllsrc; - -/** - * @brief STM32F1 clock domains. - * @see rcc_dev_clk() - */ -typedef enum rcc_clk_domain { - RCC_APB1, - RCC_APB2, - RCC_AHB -} rcc_clk_domain; - -/** - * @brief STM32F1 Prescaler identifiers - * @see rcc_set_prescaler() - */ -typedef enum rcc_prescaler { - RCC_PRESCALER_AHB, - RCC_PRESCALER_APB1, - RCC_PRESCALER_APB2, - RCC_PRESCALER_USB, - RCC_PRESCALER_ADC -} rcc_prescaler; - -/** - * @brief STM32F1 ADC prescaler dividers - * @see rcc_set_prescaler() - */ -typedef enum rcc_adc_divider { - RCC_ADCPRE_PCLK_DIV_2 = 0x0 << 14, - RCC_ADCPRE_PCLK_DIV_4 = 0x1 << 14, - RCC_ADCPRE_PCLK_DIV_6 = 0x2 << 14, - RCC_ADCPRE_PCLK_DIV_8 = 0x3 << 14, -} rcc_adc_divider; - -/** - * @brief STM32F1 APB1 prescaler dividers - * @see rcc_set_prescaler() - */ -typedef enum rcc_apb1_divider { - RCC_APB1_HCLK_DIV_1 = 0x0 << 8, - RCC_APB1_HCLK_DIV_2 = 0x4 << 8, - RCC_APB1_HCLK_DIV_4 = 0x5 << 8, - RCC_APB1_HCLK_DIV_8 = 0x6 << 8, - RCC_APB1_HCLK_DIV_16 = 0x7 << 8, -} rcc_apb1_divider; - -/** - * @brief STM32F1 APB2 prescaler dividers - * @see rcc_set_prescaler() - */ -typedef enum rcc_apb2_divider { - RCC_APB2_HCLK_DIV_1 = 0x0 << 11, - RCC_APB2_HCLK_DIV_2 = 0x4 << 11, - RCC_APB2_HCLK_DIV_4 = 0x5 << 11, - RCC_APB2_HCLK_DIV_8 = 0x6 << 11, - RCC_APB2_HCLK_DIV_16 = 0x7 << 11, -} rcc_apb2_divider; - -/** - * @brief STM32F1 AHB prescaler dividers - * @see rcc_set_prescaler() - */ -typedef enum rcc_ahb_divider { - RCC_AHB_SYSCLK_DIV_1 = 0x0 << 4, - RCC_AHB_SYSCLK_DIV_2 = 0x8 << 4, - RCC_AHB_SYSCLK_DIV_4 = 0x9 << 4, - RCC_AHB_SYSCLK_DIV_8 = 0xA << 4, - RCC_AHB_SYSCLK_DIV_16 = 0xB << 4, - RCC_AHB_SYSCLK_DIV_32 = 0xC << 4, - RCC_AHB_SYSCLK_DIV_64 = 0xD << 4, - RCC_AHB_SYSCLK_DIV_128 = 0xD << 4, - RCC_AHB_SYSCLK_DIV_256 = 0xE << 4, - RCC_AHB_SYSCLK_DIV_512 = 0xF << 4, -} rcc_ahb_divider; - -/** - * @brief STM32F1 USB prescaler dividers - * @see rcc_set_prescaler() - */ - /* - Set and reset by software to control the USB clock prescaler value. The USB clock -must be 48MHz. These bits can’t be reset if the USB clock is enabled. -00: (CK_PLL / 1.5) selected -01: CK_PLL selected -10: (CK_PLL / 2.5) selected -11: (CK_PLL / 2) selected - */ - -typedef enum rcc_usb_divider { - RCC_USB_SYSCLK_DIV_1 = 0x1 << 22, - RCC_USB_SYSCLK_DIV_1_5 = 0x0 << 22, - RCC_USB_SYSCLK_DIV_2 = 0x3 << 22, - RCC_USB_SYSCLK_DIV_2_5 = 0x2 << 22, -} rcc_usb_divider; - - -/** - * @brief Start the low speed internal oscillator - */ -static inline void rcc_start_lsi(void) { - *bb_perip(&RCC_BASE->CSR, RCC_CSR_LSION_BIT) = 1; - while (*bb_perip(&RCC_BASE->CSR, RCC_CSR_LSIRDY_BIT) == 0); -} - -/** - * @brief STM32F1 clock sources. - */ -typedef enum rcc_clk { - RCC_CLK_PLL = (uint16)((offsetof(struct rcc_reg_map, CR) << 8) | - RCC_CR_PLLON_BIT), /**< Main PLL, clocked by - HSI or HSE. */ - RCC_CLK_HSE = (uint16)((offsetof(struct rcc_reg_map, CR) << 8) | - RCC_CR_HSEON_BIT), /**< High speed external. */ - RCC_CLK_HSI = (uint16)((offsetof(struct rcc_reg_map, CR) << 8) | - RCC_CR_HSION_BIT), /**< High speed internal. */ - RCC_CLK_LSE = (uint16)((offsetof(struct rcc_reg_map, BDCR) << 8) | - RCC_BDCR_LSEON_BIT), /**< Low-speed external - * (32.768 KHz). */ - RCC_CLK_LSI = (uint16)((offsetof(struct rcc_reg_map, CSR) << 8) | - RCC_CSR_LSION_BIT), /**< Low-speed internal - * (approximately 32 KHz). */ -} rcc_clk; - -/** - * @brief STM32F1 PLL multipliers. - */ -typedef enum rcc_pll_multiplier { - RCC_PLLMUL_2 = (0x0 << 18), - RCC_PLLMUL_3 = (0x1 << 18), - RCC_PLLMUL_4 = (0x2 << 18), - RCC_PLLMUL_5 = (0x3 << 18), - RCC_PLLMUL_6 = (0x4 << 18), - RCC_PLLMUL_7 = (0x5 << 18), - RCC_PLLMUL_8 = (0x6 << 18), - RCC_PLLMUL_9 = (0x7 << 18), - RCC_PLLMUL_10 = (0x8 << 18), - RCC_PLLMUL_11 = (0x9 << 18), - RCC_PLLMUL_12 = (0xA << 18), - RCC_PLLMUL_13 = (0xB << 18), - RCC_PLLMUL_14 = (0xC << 18), - RCC_PLLMUL_15 = (0xD << 18), - RCC_PLLMUL_16 = (0xE << 18), -} rcc_pll_multiplier; - -/* FIXME [0.0.13] Just have data point to an rcc_pll_multiplier! */ -/** - * @brief Start the low speed external oscillatior - */ -static inline void rcc_start_lse(void) { - bb_peri_set_bit(&RCC_BASE->BDCR, RCC_BDCR_LSEBYP_BIT, 0); - bb_peri_set_bit(&RCC_BASE->BDCR, RCC_BDCR_LSEON_BIT, 1); - while (bb_peri_get_bit(&RCC_BASE->BDCR, RCC_BDCR_LSERDY_BIT ) == 0); -} - -/** - * @brief STM32F1 PLL configuration values. - * Point to one of these with the "data" field in a struct rcc_pll_cfg. - * @see struct rcc_pll_cfg. - */ -typedef struct stm32f1_rcc_pll_data { - rcc_pll_multiplier pll_mul; /**< PLL multiplication factor. */ -} stm32f1_rcc_pll_data; - -/* - * Deprecated bits. - */ -static inline void rcc_start_hse(void) { // Added to support RTClock -// *bb_perip(&RCC_BASE->CR, RCC_CR_HSEON_BIT) = 1; - while (bb_peri_get_bit(&RCC_BASE->CR, RCC_CR_HSERDY_BIT) == 0); -} - -/** - * @brief Deprecated; STM32F1 only. - * - * Initialize the clock control system. Initializes the system - * clock source to use the PLL driven by an external oscillator. - * - * @param sysclk_src system clock source, must be PLL - * @param pll_src pll clock source, must be HSE - * @param pll_mul pll multiplier - */ -__deprecated -void rcc_clk_init(rcc_sysclk_src sysclk_src, - rcc_pllsrc pll_src, - rcc_pll_multiplier pll_mul); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/spi.h b/GD32F1/system/libmaple/stm32f1/include/series/spi.h deleted file mode 100644 index d288a0c..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/spi.h +++ /dev/null @@ -1,99 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/spi.h - * @author Marti Bolivar - * @brief STM32F1 SPI/I2S series header. - */ - -#ifndef _LIBMAPLE_STM32F1_SPI_H_ -#define _LIBMAPLE_STM32F1_SPI_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Register map base pointers - */ - -struct spi_reg_map; - -#define SPI1_BASE ((struct spi_reg_map*)0x40013000) -#define SPI2_BASE ((struct spi_reg_map*)0x40003800) -#define SPI3_BASE ((struct spi_reg_map*)0x40003C00) - -/* - * Device pointers - */ - -struct spi_dev; - -extern struct spi_dev *SPI1; -extern struct spi_dev *SPI2; -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -extern struct spi_dev *SPI3; -#endif - -/* - * Routines - */ - -/* spi_gpio_cfg(): Backwards compatibility shim to spi_config_gpios() */ -struct gpio_dev; -extern void spi_config_gpios(struct spi_dev*, uint8, - struct gpio_dev*, uint8, - struct gpio_dev*, uint8, uint8, uint8); -/** - * @brief Deprecated. Use spi_config_gpios() instead. - * @see spi_config_gpios() - */ -static __always_inline void spi_gpio_cfg(uint8 as_master, - struct gpio_dev *nss_dev, - uint8 nss_bit, - struct gpio_dev *comm_dev, - uint8 sck_bit, - uint8 miso_bit, - uint8 mosi_bit) { - /* We switched style globally to foo_config_gpios() and always - * taking a foo_dev* argument (that last bit is the important - * part) after this function was written. - * - * However, spi_config_gpios() just ignores the spi_dev* on F1, so - * we can still keep this around for older code. */ - spi_config_gpios(NULL, as_master, nss_dev, nss_bit, - comm_dev, sck_bit, miso_bit, mosi_bit); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/stm32.h b/GD32F1/system/libmaple/stm32f1/include/series/stm32.h deleted file mode 100644 index 8f78925..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/stm32.h +++ /dev/null @@ -1,266 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010, 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/stm32.h - * @brief STM32F1 chip- and series-specific definitions. - */ - /* - * Modified by Roger Clark. 20141111. Wrapped #define STM32_MEDIUM_DENSITY in #ifndef - * to prevent redefinition warnings as SSTM32_MEDIUM_DENSITY is defined in boards.txt as a compilor define. - */ - -#ifndef _LIBMAPLE_STM32F1_H_ -#define _LIBMAPLE_STM32F1_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#define STM32_MCU_SERIES STM32_SERIES_F1 - -/* The STM32F1 series is subdivided into "lines". libmaple currently - * officially supports STM32F103 performance line MCUs (see the - * MCU-specific value section below). - * - * You can use these F1 line defines if porting libmaple to support - * MCUs on other lines. */ -/** STM32F1 value line (STM32F100 MCUs). */ -#define STM32_F1_LINE_VALUE 0 -/** STM32F1 access line (STM32F101 MCUs). */ -#define STM32_F1_LINE_ACCESS 1 -/** STM32F1 USB access line (STM32F102 MCUs). */ -#define STM32_F1_LINE_USB_ACCESS 2 -/** STM32F1 performance line (STM32F103 MCUs). */ -#define STM32_F1_LINE_PERFORMANCE 3 -/** STM32F1 connectivity line (STM32F105/F107 MCUs). */ -#define STM32_F1_LINE_CONNECTIVITY 5 - -/* - * MCU-specific values. - * - * You can use this section to override any of the below settings on a - * per-MCU basis. For example, if your MCU has different STM32_PCLK1 - * or STM32_PCLK2 values, you can set them here and the values for - * STM32F103 microcontrollers set below won't take effect. - */ - -#if defined(MCU_STM32F103T8) -# define STM32_NR_GPIO_PORTS 2 -# define STM32_SRAM_END ((void*)0x20005000) -# define NR_GPIO_PORTS STM32_NR_GPIO_PORTS -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_MEDIUM_DENSITY - -#elif defined(MCU_STM32F103TB) -# define STM32_NR_GPIO_PORTS 2 -# define STM32_SRAM_END ((void*)0x20005000) -# define NR_GPIO_PORTS STM32_NR_GPIO_PORTS -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_MEDIUM_DENSITY - -#elif defined(MCU_STM32F103C8) -# define STM32_NR_GPIO_PORTS 3 -# define STM32_SRAM_END ((void*)0x20005000) -# define NR_GPIO_PORTS STM32_NR_GPIO_PORTS -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_MEDIUM_DENSITY - -#elif defined(MCU_STM32F103CB) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE - /* This STM32_NR_GPIO_PORTS is not true, but only pins 0 and - * exist, and they're used for OSC (e.g. on LeafLabs' Maple Mini), - * so we'll live with this for now. */ -# define STM32_NR_GPIO_PORTS 3 -# define STM32_SRAM_END ((void*)0x20005000) -# define STM32_MEDIUM_DENSITY - -#elif defined(MCU_STM32F103R8) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 4 -# define STM32_SRAM_END ((void*)0x20005000) -# define STM32_MEDIUM_DENSITY - -#elif defined(MCU_STM32F103RB) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 4 -# define STM32_SRAM_END ((void*)0x20005000) -# define STM32_MEDIUM_DENSITY - -#elif defined(MCU_STM32F103RC) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 4 -# define STM32_SRAM_END ((void*)0x2000C000) -# define STM32_HIGH_DENSITY - -#elif defined(MCU_STM32F103RD) || defined(MCU_STM32F103RE) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 4 -# define STM32_SRAM_END ((void*)0x20010000) -# define STM32_HIGH_DENSITY - -#elif defined(MCU_STM32F103V8) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 5 -# define STM32_SRAM_END ((void*)0x20005000) -# define STM32_MEDIUM_DENSITY - -#elif defined(MCU_STM32F103VB) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 5 -# define STM32_SRAM_END ((void*)0x20005000) -# define STM32_MEDIUM_DENSITY - -#elif defined(MCU_STM32F103VC) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 5 -# define STM32_SRAM_END ((void*)0x2000C000) -# define STM32_HIGH_DENSITY - -#elif defined(MCU_STM32F103VD) || defined(MCU_STM32F103VE) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 5 -# define STM32_SRAM_END ((void*)0x20010000) -# define STM32_HIGH_DENSITY - -#elif defined(MCU_STM32F103ZC) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 7 -# define STM32_SRAM_END ((void*)0x2000C000) -# define STM32_HIGH_DENSITY - -#elif defined(MCU_STM32F103ZD) || defined(MCU_STM32F103ZE) -# define STM32_F1_LINE STM32_F1_LINE_PERFORMANCE -# define STM32_NR_GPIO_PORTS 7 -# define STM32_SRAM_END ((void*)0x20010000) -# define STM32_HIGH_DENSITY - -#elif defined(MCU_STM32F100RB) -# define STM32_F1_LINE STM32_F1_LINE_VALUE -# define STM32_NR_GPIO_PORTS 4 -# define STM32_TIMER_MASK 0x380DE /* Timers: 1-4, 6, 7, 15-17. */ -# define STM32_SRAM_END ((void*)0x20002000) -# define STM32_MEDIUM_DENSITY - -#else -#warning "Unsupported or unspecified STM32F1 MCU." -#endif - -/* - * Derived values. - */ - -#if STM32_F1_LINE == STM32_F1_LINE_PERFORMANCE - /* All supported performance line MCUs have a USB peripheral */ -# define STM32_HAVE_USB 1 - -# ifdef STM32_MEDIUM_DENSITY -# define STM32_NR_INTERRUPTS 43 -# define STM32_TIMER_MASK 0x1E /* TIMER1--TIMER4 */ -# define STM32_HAVE_FSMC 0 -# define STM32_HAVE_DAC 0 -# elif defined(STM32_HIGH_DENSITY) -# define STM32_NR_INTERRUPTS 60 -# define STM32_TIMER_MASK 0x1FE /* TIMER1--TIMER8 */ -# define STM32_HAVE_FSMC 1 -# define STM32_HAVE_DAC 1 -# elif defined(STM32_XL_DENSITY) -# define STM32_NR_INTERRUPTS 60 -# define STM32_TIMER_MASK 0x7FFE /* TIMER1--TIMER14 */ -# define STM32_HAVE_FSMC 1 -# define STM32_HAVE_DAC 1 -# endif - -#elif STM32_F1_LINE == STM32_F1_LINE_VALUE - /* Value line MCUs don't have USB peripherals. */ -# define STM32_HAVE_USB 0 - -# ifdef STM32_MEDIUM_DENSITY -# define STM32_NR_INTERRUPTS 56 -# define STM32_HAVE_FSMC 0 -# define STM32_HAVE_DAC 1 -# elif defined(STM32_HIGH_DENSITY) - /* 61 interrupts here counts the possibility for a remapped - * DMA2 channel 5 IRQ occurring at NVIC index 60. */ -# define STM32_NR_INTERRUPTS 61 -# define STM32_HAVE_FSMC 1 -# define STM32_HAVE_DAC 1 -# endif - -#endif - -/* - * Clock configuration. - * - * You can patch these for your line, MCU, clock configuration, - * etc. here or by setting cflags when compiling libmaple. - */ - -#if STM32_F1_LINE == STM32_F1_LINE_PERFORMANCE -# ifndef STM32_PCLK1 -# define STM32_PCLK1 F_CPU/2 -# endif -# ifndef STM32_PCLK2 -# define STM32_PCLK2 F_CPU -# endif -# ifndef STM32_DELAY_US_MULT -# define STM32_DELAY_US_MULT (F_CPU / 3000000L) -# endif -#endif - -/* - * Sanity checks. - * - * Make sure we have the F1-specific defines we need. - * will check that we've defined everything it needs. - */ - -#if !defined(STM32_F1_LINE) -#error "Bad STM32F1 configuration. Check STM32F1 header." -#endif - -/* - * Doxygen - */ - -#ifdef __DOXYGEN__ - -/** - * @brief STM32 line value for the STM32F1 MCU being targeted. - * - * At time of writing, allowed values are: STM32_F1_LINE_PERFORMANCE, - * STM32_F1_LINE_VALUE. This set of values may expand as libmaple adds - * support for more STM32F1 lines. - */ -#define STM32_F1_LINE - -#endif /* __DOXYGEN__ */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/timer.h b/GD32F1/system/libmaple/stm32f1/include/series/timer.h deleted file mode 100644 index 8c1f8f4..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/timer.h +++ /dev/null @@ -1,128 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/timer.h - * @author Marti Bolivar - * @brief STM32F1 timer support. - */ - -#ifndef _LIBMAPLE_STM32F1_TIMER_H_ -#define _LIBMAPLE_STM32F1_TIMER_H_ - -#include - -/* - * Register maps and base pointers - */ - -/** STM32F1 general purpose timer register map type */ -typedef struct timer_gen_reg_map { - __io uint32 CR1; /**< Control register 1 */ - __io uint32 CR2; /**< Control register 2 */ - __io uint32 SMCR; /**< Slave mode control register */ - __io uint32 DIER; /**< DMA/Interrupt enable register */ - __io uint32 SR; /**< Status register */ - __io uint32 EGR; /**< Event generation register */ - __io uint32 CCMR1; /**< Capture/compare mode register 1 */ - __io uint32 CCMR2; /**< Capture/compare mode register 2 */ - __io uint32 CCER; /**< Capture/compare enable register */ - __io uint32 CNT; /**< Counter */ - __io uint32 PSC; /**< Prescaler */ - __io uint32 ARR; /**< Auto-reload register */ - const uint32 RESERVED1; /**< Reserved */ - __io uint32 CCR1; /**< Capture/compare register 1 */ - __io uint32 CCR2; /**< Capture/compare register 2 */ - __io uint32 CCR3; /**< Capture/compare register 3 */ - __io uint32 CCR4; /**< Capture/compare register 4 */ - const uint32 RESERVED2; /**< Reserved */ - __io uint32 DCR; /**< DMA control register */ - __io uint32 DMAR; /**< DMA address for full transfer */ -} timer_gen_reg_map; - -struct timer_adv_reg_map; -struct timer_bas_reg_map; - -/** Timer 1 register map base pointer */ -#define TIMER1_BASE ((struct timer_adv_reg_map*)0x40012C00) -/** Timer 2 register map base pointer */ -#define TIMER2_BASE ((struct timer_gen_reg_map*)0x40000000) -/** Timer 3 register map base pointer */ -#define TIMER3_BASE ((struct timer_gen_reg_map*)0x40000400) -/** Timer 4 register map base pointer */ -#define TIMER4_BASE ((struct timer_gen_reg_map*)0x40000800) -/** Timer 5 register map base pointer */ -#define TIMER5_BASE ((struct timer_gen_reg_map*)0x40000C00) -/** Timer 6 register map base pointer */ -#define TIMER6_BASE ((struct timer_bas_reg_map*)0x40001000) -/** Timer 7 register map base pointer */ -#define TIMER7_BASE ((struct timer_bas_reg_map*)0x40001400) -/** Timer 8 register map base pointer */ -#define TIMER8_BASE ((struct timer_adv_reg_map*)0x40013400) -/** Timer 9 register map base pointer */ -#define TIMER9_BASE ((struct timer_gen_reg_map*)0x40014C00) -/** Timer 10 register map base pointer */ -#define TIMER10_BASE ((struct timer_gen_reg_map*)0x40015000) -/** Timer 11 register map base pointer */ -#define TIMER11_BASE ((struct timer_gen_reg_map*)0x40015400) -/** Timer 12 register map base pointer */ -#define TIMER12_BASE ((struct timer_gen_reg_map*)0x40001800) -/** Timer 13 register map base pointer */ -#define TIMER13_BASE ((struct timer_gen_reg_map*)0x40001C00) -/** Timer 14 register map base pointer */ -#define TIMER14_BASE ((struct timer_gen_reg_map*)0x40002000) - -/* - * Device pointers - * - * We only declare device pointers to timers which actually exist on - * the target MCU. This helps when porting programs to STM32F1 (or - * within F1 to a lower density MCU), as attempts to use nonexistent - * timers cause build errors instead of undefined behavior. - */ - -struct timer_dev; - -extern struct timer_dev *const TIMER1; -extern struct timer_dev *const TIMER2; -extern struct timer_dev *const TIMER3; -extern struct timer_dev *const TIMER4; -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -extern struct timer_dev *const TIMER5; -extern struct timer_dev *const TIMER6; -extern struct timer_dev *const TIMER7; -extern struct timer_dev *const TIMER8; -#endif -#ifdef STM32_XL_DENSITY -extern struct timer_dev *const TIMER9; -extern struct timer_dev *const TIMER10; -extern struct timer_dev *const TIMER11; -extern struct timer_dev *const TIMER12; -extern struct timer_dev *const TIMER13; -extern struct timer_dev *const TIMER14; -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/include/series/usart.h b/GD32F1/system/libmaple/stm32f1/include/series/usart.h deleted file mode 100644 index d12a3e2..0000000 --- a/GD32F1/system/libmaple/stm32f1/include/series/usart.h +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/stm32f1/include/series/usart.h - * @author Marti Bolivar - * @brief STM32F1 USART support. - */ - -#ifndef _LIBMAPLE_STM32F1_USART_H_ -#define _LIBMAPLE_STM32F1_USART_H_ - -#ifdef __cplusplus -extern "C"{ -#endif - -/* - * Register map base pointers - */ - -struct usart_reg_map; - -/** USART1 register map base pointer */ -#define USART1_BASE ((struct usart_reg_map*)0x40013800) -/** USART2 register map base pointer */ -#define USART2_BASE ((struct usart_reg_map*)0x40004400) -/** USART3 register map base pointer */ -#define USART3_BASE ((struct usart_reg_map*)0x40004800) -#ifdef STM32_HIGH_DENSITY -/** UART4 register map base pointer */ -#define UART4_BASE ((struct usart_reg_map*)0x40004C00) -/** UART5 register map base pointer */ -#define UART5_BASE ((struct usart_reg_map*)0x40005000) -#endif - -/* - * Devices - */ - -struct usart_dev; -extern struct usart_dev *USART1; -extern struct usart_dev *USART2; -extern struct usart_dev *USART3; -#ifdef STM32_HIGH_DENSITY -extern struct usart_dev *UART4; -extern struct usart_dev *UART5; -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/stm32f1/rules.mk b/GD32F1/system/libmaple/stm32f1/rules.mk deleted file mode 100644 index f1cc23e..0000000 --- a/GD32F1/system/libmaple/stm32f1/rules.mk +++ /dev/null @@ -1,45 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -# Local flags -CFLAGS_$(d) = -I$(d) $(LIBMAPLE_PRIVATE_INCLUDES) $(LIBMAPLE_INCLUDES) -Wall -Werror -ASFLAGS_$(d) = -I$(d) $(LIBMAPLE_PRIVATE_INCLUDES) $(LIBMAPLE_INCLUDES) -Wall -Werror - -# Extra BUILDDIRS -BUILDDIRS += $(BUILD_PATH)/$(d)/$(MCU_F1_LINE) - -# Local rules and targets -sSRCS_$(d) := $(MCU_F1_LINE)/isrs.S -sSRCS_$(d) += $(MCU_F1_LINE)/vector_table.S - -cSRCS_$(d) := adc.c -cSRCS_$(d) += bkp.c -cSRCS_$(d) += dma.c -cSRCS_$(d) += exti.c -cSRCS_$(d) += fsmc.c -cSRCS_$(d) += gpio.c -cSRCS_$(d) += i2c.c -cSRCS_$(d) += rcc.c -cSRCS_$(d) += spi.c -cSRCS_$(d) += timer.c -cSRCS_$(d) += usart.c - -sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \ - $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_ASFLAGS := $(ASFLAGS_$(d)) -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) diff --git a/GD32F1/system/libmaple/timer_private.h b/GD32F1/system/libmaple/timer_private.h deleted file mode 100644 index 320c636..0000000 --- a/GD32F1/system/libmaple/timer_private.h +++ /dev/null @@ -1,235 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/timer_private.h - * @author Marti Bolivar - * @brief Private, internal timer APIs. - */ - -#ifndef _LIBMAPLE_TIMER_PRIVATE_H_ -#define _LIBMAPLE_TIMER_PRIVATE_H_ - -/* - * Helper macros for declaring timer_devs of various timer_types - */ - -/* The indexes of user handlers in a timer_dev.handlers are just like - * the corresponding DIER bits, as follows: */ - -/* Advanced timers: - * [0] = Update handler; - * [1,2,3,4] = capture/compare 1,2,3,4 handlers, respectively; - * [5] = COM; - * [6] = TRG; - * [7] = BRK. */ -#define NR_ADV_HANDLERS 8 -/* General purpose timers: - * [0] = update; - * [1,2,3,4] = capture/compare 1,2,3,4; - * [5] = ; - * [6] = trigger. */ -#define NR_GEN_HANDLERS 7 -/* Basic timers: - * [0] = update. */ -#define NR_BAS_HANDLERS 1 - -/* For declaring advanced timers. */ -#define ADVANCED_TIMER(num) \ - { \ - .regs = { .adv = TIMER##num##_BASE }, \ - .clk_id = RCC_TIMER##num, \ - .type = TIMER_ADVANCED, \ - .handlers = { [NR_ADV_HANDLERS - 1] = 0 }, \ - } - -/* For declaring full-featured general purpose timers. */ -#define GENERAL_TIMER(num) \ - { \ - .regs = { .gen = TIMER##num##_BASE }, \ - .clk_id = RCC_TIMER##num, \ - .type = TIMER_GENERAL, \ - .handlers = { [NR_GEN_HANDLERS - 1] = 0 }, \ - } - -/* For declaring general purpose timers with limited interrupt - * capability (e.g. timers 9 through 14 on STM32F2 and XL-density - * STM32F1). */ -#define RESTRICTED_GENERAL_TIMER(num, max_dier_bit) \ - { \ - .regs = { .gen = TIMER##num##_BASE }, \ - .clk_id = RCC_TIMER##num, \ - .type = TIMER_GENERAL, \ - .handlers = { [max_dier_bit] = 0 }, \ - } - -/* For declaring basic timers (e.g. TIM6 and TIM7). */ -#define BASIC_TIMER(num) \ - { \ - .regs = { .bas = TIMER##num##_BASE }, \ - .clk_id = RCC_TIMER##num, \ - .type = TIMER_BASIC, \ - .handlers = { [NR_BAS_HANDLERS - 1] = 0 }, \ - } - -/* - * IRQ handlers - * - * These decode TIMx_DIER and TIMx_SR, then dispatch to the user-level - * IRQ handlers. They also clean up TIMx_SR afterwards, so the user - * doesn't have to deal with register details. - * - * Notes: - * - * - These dispatch routines make use of the fact that DIER interrupt - * enable bits and SR interrupt flags have common bit positions. - * Thus, ANDing DIER and SR lets us check if an interrupt is enabled - * and if it has occurred simultaneously. - * - * - We force these routines to inline to avoid call overhead, but - * there aren't any measurements to prove that this is actually a - * good idea. Profile-directed optimizations are definitely wanted. */ - -/* A special-case dispatch routine for timers which only serve a - * single interrupt on a given IRQ line. - * - * This function still checks DIER & SR, as in some cases, a timer may - * only serve a single interrupt on a particular NVIC line, but that - * line may be shared with another timer. For example, the timer 1 - * update interrupt shares an IRQ line with the timer 10 interrupt on - * STM32F1 (XL-density), STM32F2, and STM32F4. */ -static __always_inline void dispatch_single_irq(timer_dev *dev, - timer_interrupt_id iid, - uint32 irq_mask) { - timer_bas_reg_map *regs = (dev->regs).bas; - if (regs->DIER & regs->SR & irq_mask) { - void (*handler)(void) = dev->handlers[iid]; - if (handler) { - handler(); - regs->SR &= ~irq_mask; - } - } -} - -/* Helper macro for dispatch routines which service multiple interrupts. */ -#define handle_irq(dier_sr, irq_mask, handlers, iid, handled_irq) do { \ - if ((dier_sr) & (irq_mask)) { \ - void (*__handler)(void) = (handlers)[iid]; \ - if (__handler) { \ - __handler(); \ - handled_irq |= (irq_mask); \ - } \ - } \ - } while (0) - -static __always_inline void dispatch_adv_brk(timer_dev *dev) { - dispatch_single_irq(dev, TIMER_BREAK_INTERRUPT, TIMER_SR_BIF); -} - -static __always_inline void dispatch_adv_up(timer_dev *dev) { - dispatch_single_irq(dev, TIMER_UPDATE_INTERRUPT, TIMER_SR_UIF); -} - -static __always_inline void dispatch_adv_trg_com(timer_dev *dev) { - timer_adv_reg_map *regs = (dev->regs).adv; - uint32 dsr = regs->DIER & regs->SR; - void (**hs)(void) = dev->handlers; - uint32 handled = 0; /* Logical OR of SR interrupt flags we end up - * handling. We clear these. User handlers - * must clear overcapture flags, to avoid - * wasting time in output mode. */ - - handle_irq(dsr, TIMER_SR_TIF, hs, TIMER_TRG_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_COMIF, hs, TIMER_COM_INTERRUPT, handled); - - regs->SR &= ~handled; -} - -static __always_inline void dispatch_adv_cc(timer_dev *dev) { - timer_adv_reg_map *regs = (dev->regs).adv; - uint32 dsr = regs->DIER & regs->SR; - void (**hs)(void) = dev->handlers; - uint32 handled = 0; - - handle_irq(dsr, TIMER_SR_CC4IF, hs, TIMER_CC4_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC3IF, hs, TIMER_CC3_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC2IF, hs, TIMER_CC2_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC1IF, hs, TIMER_CC1_INTERRUPT, handled); - - regs->SR &= ~handled; -} - -static __always_inline void dispatch_general(timer_dev *dev) { - timer_gen_reg_map *regs = (dev->regs).gen; - uint32 dsr = regs->DIER & regs->SR; - void (**hs)(void) = dev->handlers; - uint32 handled = 0; - - handle_irq(dsr, TIMER_SR_TIF, hs, TIMER_TRG_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC4IF, hs, TIMER_CC4_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC3IF, hs, TIMER_CC3_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC2IF, hs, TIMER_CC2_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC1IF, hs, TIMER_CC1_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_UIF, hs, TIMER_UPDATE_INTERRUPT, handled); - - regs->SR &= ~handled; -} - -/* On F1 (XL-density), F2, and F4, TIM9 and TIM12 are restricted - * general-purpose timers with update, CC1, CC2, and TRG interrupts. */ -static __always_inline void dispatch_tim_9_12(timer_dev *dev) { - timer_gen_reg_map *regs = (dev->regs).gen; - uint32 dsr = regs->DIER & regs->SR; - void (**hs)(void) = dev->handlers; - uint32 handled = 0; - - handle_irq(dsr, TIMER_SR_TIF, hs, TIMER_TRG_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC2IF, hs, TIMER_CC2_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_CC1IF, hs, TIMER_CC1_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_UIF, hs, TIMER_UPDATE_INTERRUPT, handled); - - regs->SR &= ~handled; -} - -/* On F1 (XL-density), F2, and F4, timers 10, 11, 13, and 14 are - * restricted general-purpose timers with update and CC1 interrupts. */ -static __always_inline void dispatch_tim_10_11_13_14(timer_dev *dev) { - timer_gen_reg_map *regs = (dev->regs).gen; - uint32 dsr = regs->DIER & regs->SR; - void (**hs)(void) = dev->handlers; - uint32 handled = 0; - - handle_irq(dsr, TIMER_SR_CC1IF, hs, TIMER_CC1_INTERRUPT, handled); - handle_irq(dsr, TIMER_SR_UIF, hs, TIMER_UPDATE_INTERRUPT, handled); - - regs->SR &= ~handled; -} - -static __always_inline void dispatch_basic(timer_dev *dev) { - dispatch_single_irq(dev, TIMER_UPDATE_INTERRUPT, TIMER_SR_UIF); -} - -#endif diff --git a/GD32F1/system/libmaple/usart_private.h b/GD32F1/system/libmaple/usart_private.h deleted file mode 100644 index 9bc0527..0000000 --- a/GD32F1/system/libmaple/usart_private.h +++ /dev/null @@ -1,60 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file libmaple/usart_private.h - * @author Marti Bolivar - * @brief Private USART header. - */ - -#ifndef _LIBMAPLE_USART_PRIVATE_H_ -#define _LIBMAPLE_USART_PRIVATE_H_ - -#include -#include - -static __always_inline void usart_irq(ring_buffer *rb, usart_reg_map *regs) { - /* We can get RXNE and ORE interrupts here. Only RXNE signifies - * availability of a byte in DR. - * - * See table 198 (sec 27.4, p809) in STM document RM0008 rev 15. - * We enable RXNEIE. */ - if (regs->SR & USART_SR_RXNE) { -#ifdef USART_SAFE_INSERT - /* If the buffer is full and the user defines USART_SAFE_INSERT, - * ignore new bytes. */ - rb_safe_insert(rb, (uint8)regs->DR); -#else - /* By default, push bytes around in the ring buffer. */ - rb_push_insert(rb, (uint8)regs->DR); -#endif - } -} - -uint32 _usart_clock_freq(usart_dev *dev); - -#endif diff --git a/GD32F1/system/libmaple/usb/README b/GD32F1/system/libmaple/usb/README deleted file mode 100644 index d0fca8d..0000000 --- a/GD32F1/system/libmaple/usb/README +++ /dev/null @@ -1,63 +0,0 @@ -The USB submodule of libmaple is a separate piece of the codebase for -reasons that are largely historical. - -Current Status: - - There's only support for the USB device peripheral found on - STM32F103s. - - We rely on the low level core library provided by ST to implement - the USB transfer protocol for control endpoint transfers. - - The virtual com port (which is exposed via - ) serves two important purposes. - - 1) It allows serial data transfers between user sketches an a - host computer. - - 2) It allows the host PC to issue a system reset into the DFU - bootloader with the DTR + RTS + "1EAF" sequence (see - leaflabs.com/docs/bootloader.html for more information on - this). - - After reset, Maple will run the DFU bootloader for a few seconds, - during which the user can begin a DFU upload operation (uploads - application binary into RAM/FLASH). Thus, without this virtual com - port, it would be necessary to find an alternative means to reset - the chip in order to enable the bootloader. - - If you would like to develop your own USB application for whatever - reason (e.g. to use faster isochronous enpoints for streaming - audio, or implement the USB HID or Mass Storage specs), then - ensure that you leave some hook for resetting Maple remotely in - order to spin up the DFU bootloader. Please make sure to get - yourself a unique vendor/product ID pair for your application, as - some operating systems will assign a host-side driver based on - these tags. - - It would be possible to build a compound USB device, that - implements endpoints for both the virtual COM port as well as some - other components (mass storage etc.). However, this turns out to - be a burden from the host driver side, as Windows and *nix handle - compound USB devices quite differently. - - Be mindful that enabling the USB peripheral isn't "free." The - device must respond to periodic bus activity (every few - milliseconds) by servicing an ISR. Therefore, the USB application - should be disabled inside of timing critical applications. - - In order to disconnect the device from the host, a USB_DISC pin is - asserted (e.g. on Maple, this is PC12). Alternatively, the NVIC - can be directly configured to disable the USB LP/HP IRQ's. - - The files inside of usb_lib were provided by ST and are subject to - their own license, all other files were written by the LeafLabs - team and fall under the MIT license. - -TODO: - - - Generic USB driver core with series-provided backends, like - libopencm3 has. - - Strip out ST code. - - Integration with a high level USB library (like LUFA/MyUSB) to - allow users to write custom USB applications. diff --git a/GD32F1/system/libmaple/usb/rules.mk b/GD32F1/system/libmaple/usb/rules.mk deleted file mode 100644 index e8ccc15..0000000 --- a/GD32F1/system/libmaple/usb/rules.mk +++ /dev/null @@ -1,45 +0,0 @@ -# Standard things -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) - -# Local flags -CFLAGS_$(d) = -I$(d) -I$(d)/$(MCU_SERIES) -I$(d)/usb_lib $(LIBMAPLE_INCLUDES) $(LIBMAPLE_PRIVATE_INCLUDES) -Wall - -# Add usblib and series subdirectory to BUILDDIRS. -BUILDDIRS += $(BUILD_PATH)/$(d)/$(MCU_SERIES) -BUILDDIRS += $(BUILD_PATH)/$(d)/usb_lib - -# Local rules and targets -sSRCS_$(d) := -cSRCS_$(d) := -# We currently only have F1 performance line support. Sigh. -ifeq ($(MCU_SERIES), stm32f1) -ifeq ($(MCU_F1_LINE), performance) -cSRCS_$(d) += $(MCU_SERIES)/usb.c -cSRCS_$(d) += $(MCU_SERIES)/usb_reg_map.c -cSRCS_$(d) += $(MCU_SERIES)/usb_cdcacm.c -cSRCS_$(d) += usb_lib/usb_core.c -cSRCS_$(d) += usb_lib/usb_init.c -cSRCS_$(d) += usb_lib/usb_mem.c -cSRCS_$(d) += usb_lib/usb_regs.c -endif -endif - -sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \ - $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) -$(OBJS_$(d)): TGT_ASFLAGS := - -TGT_BIN += $(OBJS_$(d)) - -# Standard things --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) diff --git a/GD32F1/system/libmaple/usb/stm32f1/usb_lib_globals.h b/GD32F1/system/libmaple/usb/stm32f1/usb_lib_globals.h deleted file mode 100644 index 1cd2754..0000000 --- a/GD32F1/system/libmaple/usb/stm32f1/usb_lib_globals.h +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#ifndef _USB_LIB_GLOBALS_H_ -#define _USB_LIB_GLOBALS_H_ - -/* usb_lib headers */ -#include "usb_type.h" -#include "usb_core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern USER_STANDARD_REQUESTS User_Standard_Requests; -extern USER_STANDARD_REQUESTS *pUser_Standard_Requests; - -extern DEVICE_PROP Device_Property; -extern DEVICE_PROP *pProperty; - -extern DEVICE_INFO Device_Info; -extern DEVICE_INFO *pInformation; - -extern DEVICE Device_Table; -extern u16 SaveRState; -extern u16 SaveTState; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/GD32F1/system/libmaple/usb/stm32f1/usb_reg_map.h b/GD32F1/system/libmaple/usb/stm32f1/usb_reg_map.h deleted file mode 100644 index 2e3f6bc..0000000 --- a/GD32F1/system/libmaple/usb/stm32f1/usb_reg_map.h +++ /dev/null @@ -1,617 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -#include -#include - -#ifndef _USB_REG_MAP_H_ -#define _USB_REG_MAP_H_ - -/* TODO: - * - Pick one of "endp", "ep" "endpt" - */ - -/* - * Register map and base pointer - */ - -#define USB_NR_EP_REGS 8 - -/** USB register map type */ -typedef struct usb_reg_map { - __io uint32 EP[USB_NR_EP_REGS]; /**< Endpoint registers */ - const uint32 RESERVED[8]; /**< Reserved */ - __io uint32 CNTR; /**< Control register */ - __io uint32 ISTR; /**< Interrupt status register */ - __io uint32 FNR; /**< Frame number register */ - __io uint32 DADDR; /**< Device address */ - __io uint32 BTABLE; /**< @brief Buffer table address - * - * Address offset within the USB - * packet memory area which points - * to the base of the buffer - * descriptor table. Must be - * aligned to an 8 byte boundary. - */ -} usb_reg_map; - -/** USB register map base pointer */ -#define USB_BASE ((struct usb_reg_map*)0x40005C00) - -/* - * Register bit definitions - */ - -/* Endpoint registers (USB_EPnR) */ - -#define USB_EP_CTR_RX_BIT 15 -#define USB_EP_DTOG_RX_BIT 14 -#define USB_EP_SETUP_BIT 11 -#define USB_EP_EP_KIND_BIT 8 -#define USB_EP_CTR_TX_BIT 7 -#define USB_EP_DTOG_TX_BIT 6 - -#define USB_EP_CTR_RX BIT(USB_EP_CTR_RX_BIT) -#define USB_EP_DTOG_RX BIT(USB_EP_DTOG_RX_BIT) -#define USB_EP_STAT_RX (0x3 << 12) -#define USB_EP_STAT_RX_DISABLED (0x0 << 12) -#define USB_EP_STAT_RX_STALL (0x1 << 12) -#define USB_EP_STAT_RX_NAK (0x2 << 12) -#define USB_EP_STAT_RX_VALID (0x3 << 12) -#define USB_EP_SETUP BIT(USB_EP_SETUP_BIT) -#define USB_EP_EP_TYPE (0x3 << 9) -#define USB_EP_EP_TYPE_BULK (0x0 << 9) -#define USB_EP_EP_TYPE_CONTROL (0x1 << 9) -#define USB_EP_EP_TYPE_ISO (0x2 << 9) -#define USB_EP_EP_TYPE_INTERRUPT (0x3 << 9) -#define USB_EP_EP_KIND BIT(USB_EP_EP_KIND_BIT) -#define USB_EP_EP_KIND_DBL_BUF (0x1 << USB_EP_EP_KIND_BIT) -#define USB_EP_CTR_TX BIT(USB_EP_CTR_TX_BIT) -#define USB_EP_DTOG_TX BIT(USB_EP_DTOG_TX_BIT) -#define USB_EP_STAT_TX (0x3 << 4) -#define USB_EP_STAT_TX_DISABLED (0x0 << 4) -#define USB_EP_STAT_TX_STALL (0x1 << 4) -#define USB_EP_STAT_TX_NAK (0x2 << 4) -#define USB_EP_STAT_TX_VALID (0x3 << 4) -#define USB_EP_EA 0xF - -/* Control register (USB_CNTR) */ - -#define USB_CNTR_CTRM_BIT 15 -#define USB_CNTR_PMAOVERM_BIT 14 -#define USB_CNTR_ERRM_BIT 13 -#define USB_CNTR_WKUPM_BIT 12 -#define USB_CNTR_SUSPM_BIT 11 -#define USB_CNTR_RESETM_BIT 10 -#define USB_CNTR_SOFM_BIT 9 -#define USB_CNTR_ESOFM_BIT 8 -#define USB_CNTR_RESUME_BIT 4 -#define USB_CNTR_FSUSP_BIT 3 -#define USB_CNTR_LP_MODE_BIT 2 -#define USB_CNTR_PDWN_BIT 1 -#define USB_CNTR_FRES_BIT 0 - -#define USB_CNTR_CTRM BIT(USB_CNTR_CTRM_BIT) -#define USB_CNTR_PMAOVERM BIT(USB_CNTR_PMAOVERM_BIT) -#define USB_CNTR_ERRM BIT(USB_CNTR_ERRM_BIT) -#define USB_CNTR_WKUPM BIT(USB_CNTR_WKUPM_BIT) -#define USB_CNTR_SUSPM BIT(USB_CNTR_SUSPM_BIT) -#define USB_CNTR_RESETM BIT(USB_CNTR_RESETM_BIT) -#define USB_CNTR_SOFM BIT(USB_CNTR_SOFM_BIT) -#define USB_CNTR_ESOFM BIT(USB_CNTR_ESOFM_BIT) -#define USB_CNTR_RESUME BIT(USB_CNTR_RESUME_BIT) -#define USB_CNTR_FSUSP BIT(USB_CNTR_FSUSP_BIT) -#define USB_CNTR_LP_MODE BIT(USB_CNTR_LP_MODE_BIT) -#define USB_CNTR_PDWN BIT(USB_CNTR_PDWN_BIT) -#define USB_CNTR_FRES BIT(USB_CNTR_FRES_BIT) - -/* Interrupt status register (USB_ISTR) */ - -#define USB_ISTR_CTR_BIT 15 -#define USB_ISTR_PMAOVR_BIT 14 -#define USB_ISTR_ERR_BIT 13 -#define USB_ISTR_WKUP_BIT 12 -#define USB_ISTR_SUSP_BIT 11 -#define USB_ISTR_RESET_BIT 10 -#define USB_ISTR_SOF_BIT 9 -#define USB_ISTR_ESOF_BIT 8 -#define USB_ISTR_DIR_BIT 4 - -#define USB_ISTR_CTR BIT(USB_ISTR_CTR_BIT) -#define USB_ISTR_PMAOVR BIT(USB_ISTR_PMAOVR_BIT) -#define USB_ISTR_ERR BIT(USB_ISTR_ERR_BIT) -#define USB_ISTR_WKUP BIT(USB_ISTR_WKUP_BIT) -#define USB_ISTR_SUSP BIT(USB_ISTR_SUSP_BIT) -#define USB_ISTR_RESET BIT(USB_ISTR_RESET_BIT) -#define USB_ISTR_SOF BIT(USB_ISTR_SOF_BIT) -#define USB_ISTR_ESOF BIT(USB_ISTR_ESOF_BIT) -#define USB_ISTR_DIR BIT(USB_ISTR_DIR_BIT) -#define USB_ISTR_EP_ID 0xF - -/* Frame number register (USB_FNR) */ - -#define USB_FNR_RXDP_BIT 15 -#define USB_FNR_RXDM_BIT 14 -#define USB_FNR_LCK_BIT 13 - -#define USB_FNR_RXDP BIT(USB_FNR_RXDP_BIT) -#define USB_FNR_RXDM BIT(USB_FNR_RXDM_BIT) -#define USB_FNR_LCK BIT(USB_FNR_LCK_BIT) -#define USB_FNR_LSOF (0x3 << 11) -#define USB_FNR_FN 0x7FF - -/* Device address (USB_DADDR) */ - -#define USB_DADDR_EF_BIT 7 -#define USB_DADDR_ADD6_BIT 6 -#define USB_DADDR_ADD5_BIT 5 -#define USB_DADDR_ADD4_BIT 4 -#define USB_DADDR_ADD3_BIT 3 -#define USB_DADDR_ADD2_BIT 2 -#define USB_DADDR_ADD1_BIT 1 -#define USB_DADDR_ADD0_BIT 0 - -#define USB_DADDR_EF BIT(USB_DADDR_EF_BIT) -#define USB_DADDR_ADD6 BIT(USB_DADDR_ADD6_BIT) -#define USB_DADDR_ADD5 BIT(USB_DADDR_ADD5_BIT) -#define USB_DADDR_ADD4 BIT(USB_DADDR_ADD4_BIT) -#define USB_DADDR_ADD3 BIT(USB_DADDR_ADD3_BIT) -#define USB_DADDR_ADD2 BIT(USB_DADDR_ADD2_BIT) -#define USB_DADDR_ADD1 BIT(USB_DADDR_ADD1_BIT) -#define USB_DADDR_ADD0 BIT(USB_DADDR_ADD0_BIT) - -/* Buffer table address (USB_BTABLE) */ - -#define USB_BTABLE_BTABLE (0x1FFF << 3) - -/* - * Register convenience routines - */ - -#define __EP_CTR_NOP (USB_EP_CTR_RX | USB_EP_CTR_TX) -#define __EP_NONTOGGLE (USB_EP_CTR_RX | USB_EP_SETUP | \ - USB_EP_EP_TYPE | USB_EP_EP_KIND | \ - USB_EP_CTR_TX | USB_EP_EA) - -static inline void usb_clear_ctr_rx(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - USB_BASE->EP[ep] = epr & ~USB_EP_CTR_RX & __EP_NONTOGGLE; -} - -static inline void usb_clear_ctr_tx(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - USB_BASE->EP[ep] = epr & ~USB_EP_CTR_TX & __EP_NONTOGGLE; -} - -static inline uint32 usb_get_ep_dtog_tx(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - return epr & USB_EP_DTOG_TX; -} - -static inline uint32 usb_get_ep_dtog_rx(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - return epr & USB_EP_DTOG_RX; -} - -static inline uint32 usb_get_ep_tx_sw_buf(uint8 ep) { - return usb_get_ep_dtog_rx(ep); -} - -static inline uint32 usb_get_ep_rx_sw_buf(uint8 ep) { - return usb_get_ep_dtog_tx(ep); -} - -static inline void usb_toggle_ep_dtog_tx(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - epr &= __EP_NONTOGGLE; - epr |= USB_EP_DTOG_TX; - USB_BASE->EP[ep] = epr; -} - -static inline void usb_toggle_ep_dtog_rx(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - epr &= __EP_NONTOGGLE; - epr |= USB_EP_DTOG_RX; - USB_BASE->EP[ep] = epr; -} - -static inline void usb_clear_ep_dtog_tx(uint8 ep) { - if (usb_get_ep_dtog_tx(ep) != 0) { - usb_toggle_ep_dtog_tx(ep); - } -} - -static inline void usb_clear_ep_dtog_rx(uint8 ep) { - if (usb_get_ep_dtog_rx(ep) != 0) { - usb_toggle_ep_dtog_rx(ep); - } -} - -static inline void usb_set_ep_dtog_tx(uint8 ep) { - if (usb_get_ep_dtog_tx(ep) == 0) { - usb_toggle_ep_dtog_tx(ep); - } -} - -static inline void usb_set_ep_dtog_rx(uint8 ep) { - if (usb_get_ep_dtog_rx(ep) == 0) { - usb_toggle_ep_dtog_rx(ep); - } -} - -static inline void usb_toggle_ep_rx_sw_buf(uint8 ep) { - usb_toggle_ep_dtog_tx(ep); -} - -static inline void usb_toggle_ep_tx_sw_buf(uint8 ep) { - usb_toggle_ep_dtog_rx(ep); -} - -static inline void usb_clear_ep_rx_sw_buf(uint8 ep) { - usb_clear_ep_dtog_tx(ep); -} - -static inline void usb_clear_ep_tx_sw_buf(uint8 ep) { - usb_clear_ep_dtog_rx(ep); -} - -static inline void usb_set_ep_rx_sw_buf(uint8 ep) { - usb_set_ep_dtog_tx(ep); -} - -static inline void usb_set_ep_tx_sw_buf(uint8 ep) { - usb_set_ep_dtog_rx(ep); -} - -static inline void usb_set_ep_rx_stat(uint8 ep, uint32 status) { - uint32 epr = USB_BASE->EP[ep]; - epr &= ~(USB_EP_STAT_TX | USB_EP_DTOG_RX | USB_EP_DTOG_TX); - epr |= __EP_CTR_NOP; - epr ^= status; - USB_BASE->EP[ep] = epr; -} - -static inline void usb_set_ep_tx_stat(uint8 ep, uint32 status) { - uint32 epr = USB_BASE->EP[ep]; - epr &= ~(USB_EP_STAT_RX | USB_EP_DTOG_RX | USB_EP_DTOG_TX); - epr |= __EP_CTR_NOP; - epr ^= status; - USB_BASE->EP[ep] = epr; -} - -static inline void usb_set_ep_type(uint8 ep, uint32 type) { - uint32 epr = USB_BASE->EP[ep]; - epr &= ~USB_EP_EP_TYPE & __EP_NONTOGGLE; - epr |= type; - USB_BASE->EP[ep] = epr; -} - -static inline void usb_set_ep_kind(uint8 ep, uint32 kind) { - uint32 epr = USB_BASE->EP[ep]; - epr &= ~USB_EP_EP_KIND & __EP_NONTOGGLE; - epr |= kind; - USB_BASE->EP[ep] = epr; -} - -static inline uint32 usb_get_ep_type(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - return epr & USB_EP_EP_TYPE; -} - -static inline uint32 usb_get_ep_kind(uint8 ep) { - uint32 epr = USB_BASE->EP[ep]; - return epr & USB_EP_EP_TYPE; -} - - -static inline void usb_clear_status_out(uint8 ep) { - usb_set_ep_kind(ep, 0); -} - -/* - * Packet memory area (PMA) base pointer - */ - -/** - * @brief USB packet memory area (PMA) base pointer. - * - * The USB PMA is SRAM shared between USB and CAN. The USB peripheral - * accesses this memory directly via the packet buffer interface. */ -#define USB_PMA_BASE ((__io void*)0x40006000) - -/* - * PMA conveniences - */ - -void usb_copy_to_pma(const uint8 *buf, uint16 len, uint16 pma_offset); -void usb_copy_from_pma(uint8 *buf, uint16 len, uint16 pma_offset); - -static inline void* usb_pma_ptr(uint32 offset) { - return (void*)(USB_PMA_BASE + 2 * offset); -} - -/* - * BTABLE - */ - -/* (Forward-declared) BTABLE entry. - * - * The BTABLE can be viewed as an array of usb_btable_ent values; - * these vary in structure according to the configuration of the - * endpoint. - */ -union usb_btable_ent; - -/* Bidirectional endpoint BTABLE entry */ -typedef struct usb_btable_bidi { - __io uint16 addr_tx; const uint16 PAD1; - __io uint16 count_tx; const uint16 PAD2; - __io uint16 addr_rx; const uint16 PAD3; - __io uint16 count_rx; const uint16 PAD4; -} usb_btable_bidi; - -/* Unidirectional receive-only endpoint BTABLE entry */ -typedef struct usb_btable_uni_rx { - __io uint16 empty1; const uint16 PAD1; - __io uint16 empty2; const uint16 PAD2; - __io uint16 addr_rx; const uint16 PAD3; - __io uint16 count_rx; const uint16 PAD4; -} usb_btable_uni_rx; - -/* Unidirectional transmit-only endpoint BTABLE entry */ -typedef struct usb_btable_uni_tx { - __io uint16 addr_tx; const uint16 PAD1; - __io uint16 count_tx; const uint16 PAD2; - __io uint16 empty1; const uint16 PAD3; - __io uint16 empty2; const uint16 PAD4; -} usb_btable_uni_tx; - -/* Double-buffered transmission endpoint BTABLE entry */ -typedef struct usb_btable_dbl_tx { - __io uint16 addr_tx0; const uint16 PAD1; - __io uint16 count_tx0; const uint16 PAD2; - __io uint16 addr_tx1; const uint16 PAD3; - __io uint16 count_tx1; const uint16 PAD4; -} usb_btable_dbl_tx; - -/* Double-buffered reception endpoint BTABLE entry */ -typedef struct usb_btable_dbl_rx { - __io uint16 addr_rx0; const uint16 PAD1; - __io uint16 count_rx0; const uint16 PAD2; - __io uint16 addr_rx1; const uint16 PAD3; - __io uint16 count_rx1; const uint16 PAD4; -} usb_btable_dbl_rx; - -/* TODO isochronous endpoint entries */ - -/* Definition for above forward-declared BTABLE entry. */ -typedef union usb_btable_ent { - usb_btable_bidi bidi; - usb_btable_uni_rx u_rx; - usb_btable_uni_tx u_tx; - usb_btable_dbl_tx d_tx; - usb_btable_dbl_rx d_rx; -} usb_btable_ent; - -/* - * BTABLE conveniences - */ - -/* TODO (?) Convert usages of the many (and lengthily-named) - * accessors/mutators below to just manipulating usb_btable_entry - * values. */ - -static inline uint32* usb_btable_ptr(uint32 offset) { - return (uint32*)usb_pma_ptr(USB_BASE->BTABLE + offset); -} - -/* TX address */ - -static inline uint32* usb_ep_tx_addr_ptr(uint8 ep) { - return usb_btable_ptr(ep * 8); -} - -static inline uint16 usb_get_ep_tx_addr(uint8 ep) { - return (uint16)*usb_ep_tx_addr_ptr(ep); -} - -static inline void usb_set_ep_tx_addr(uint8 ep, uint16 addr) { - uint32 *tx_addr = usb_ep_tx_addr_ptr(ep); - *tx_addr = addr & ~0x1; -} - -/* RX address */ - -static inline uint32* usb_ep_rx_addr_ptr(uint8 ep) { - return usb_btable_ptr(ep * 8 + 4); -} - -static inline uint16 usb_get_ep_rx_addr(uint8 ep) { - return (uint16)*usb_ep_rx_addr_ptr(ep); -} - -static inline void usb_set_ep_rx_addr(uint8 ep, uint16 addr) { - uint32 *rx_addr = usb_ep_rx_addr_ptr(ep); - *rx_addr = addr & ~0x1; -} - -/* TX count (doesn't cover double-buffered and isochronous in) */ - -static inline uint32* usb_ep_tx_count_ptr(uint8 ep) { - return usb_btable_ptr(ep * 8 + 2); -} - -static inline uint16 usb_get_ep_tx_count(uint8 ep) { - /* FIXME: this is broken somehow; calling it seems to - * confuse/crash the chip. */ - return (uint16)(*usb_ep_tx_count_ptr(ep) & 0x3FF); -} - -static inline void usb_set_ep_tx_count(uint8 ep, uint16 count) { - uint32 *txc = usb_ep_tx_count_ptr(ep); - *txc = count; -} - -/* RX count */ - -static inline uint32* usb_ep_rx_count_ptr(uint8 ep) { - return usb_btable_ptr(ep * 8 + 6); -} - -static inline uint16 usb_get_ep_rx_count(uint8 ep) { - return (uint16)*usb_ep_rx_count_ptr(ep) & 0x3FF; -} - -void usb_set_ep_rx_count(uint8 ep, uint16 count); - -/* double buffer definitions */ -static inline uint32* usb_get_ep_tx_buf0_addr_ptr(uint8 ep) { - return usb_ep_tx_addr_ptr(ep); -} - -static inline uint16 usb_get_ep_tx_buf0_addr(uint8 ep) { - return usb_get_ep_tx_addr(ep); -} - -static inline void usb_set_ep_tx_buf0_addr(uint8 ep, uint16 addr) { - usb_set_ep_tx_addr(ep, addr); -} - -static inline uint32* usb_get_ep_tx_buf1_addr_ptr(uint8 ep) { - return usb_ep_rx_addr_ptr(ep); -} - -static inline uint16 usb_get_ep_tx_buf1_addr(uint8 ep) { - return usb_get_ep_rx_addr(ep); -} - -static inline void usb_set_ep_tx_buf1_addr(uint8 ep, uint16 addr) { - usb_set_ep_rx_addr(ep, addr); -} - -static inline uint32* usb_ep_tx_buf0_count_ptr(uint8 ep) { - return usb_ep_tx_count_ptr(ep); -} - -static inline uint16 usb_get_ep_tx_buf0_count(uint8 ep) { - return usb_get_ep_tx_count(ep); -} - -static inline void usb_set_ep_tx_buf0_count(uint8 ep, uint16 count) { - usb_set_ep_tx_count(ep, count); -} - -static inline uint32* usb_ep_tx_buf1_count_ptr(uint8 ep) { - return usb_ep_rx_count_ptr(ep); -} - -static inline uint16 usb_get_ep_tx_buf1_count(uint8 ep) { - return usb_get_ep_rx_count(ep); -} - -static inline void usb_set_ep_tx_buf1_count(uint8 ep, uint16 count) { - usb_set_ep_rx_count(ep, count); -} -static inline uint32* usb_get_ep_rx_buf0_addr_ptr(uint8 ep) { - return usb_ep_tx_addr_ptr(ep); -} - -static inline uint16 usb_get_ep_rx_buf0_addr(uint8 ep) { - return usb_get_ep_tx_addr(ep); -} - -static inline void usb_set_ep_rx_buf0_addr(uint8 ep, uint16 addr) { - usb_set_ep_tx_addr(ep, addr); -} - -static inline uint32* usb_get_ep_rx_buf1_addr_ptr(uint8 ep) { - return usb_ep_rx_addr_ptr(ep); -} - -static inline uint16 usb_get_ep_rx_buf1_addr(uint8 ep) { - return usb_get_ep_rx_addr(ep); -} - -static inline void usb_set_ep_rx_buf1_addr(uint8 ep, uint16 addr) { - usb_set_ep_rx_addr(ep, addr); -} - -static inline uint32* usb_ep_rx_buf0_count_ptr(uint8 ep) { - return usb_ep_tx_count_ptr(ep); -} - -static inline uint16 usb_get_ep_rx_buf0_count(uint8 ep) { - return usb_get_ep_tx_count(ep); -} - -void usb_set_ep_rx_buf0_count(uint8 ep, uint16 count); - -static inline uint32* usb_ep_rx_buf1_count_ptr(uint8 ep) { - return usb_ep_rx_count_ptr(ep); -} - -static inline uint16 usb_get_ep_rx_buf1_count(uint8 ep) { - return usb_get_ep_rx_count(ep); -} - -static inline void usb_set_ep_rx_buf1_count(uint8 ep, uint16 count) { - usb_set_ep_rx_count(ep, count); -} - -/* - * Misc. types - */ - -typedef enum usb_ep { - USB_EP0, - USB_EP1, - USB_EP2, - USB_EP3, - USB_EP4, - USB_EP5, - USB_EP6, - USB_EP7, -} usb_ep; - -typedef enum usb_ep_type { - USB_EP_T_CTL = USB_EP_EP_TYPE_CONTROL, - USB_EP_T_BULK = USB_EP_EP_TYPE_BULK, - USB_EP_T_INT = USB_EP_EP_TYPE_INTERRUPT, - USB_EP_T_ISO = USB_EP_EP_TYPE_ISO -} usb_ep_type; - -typedef enum usb_ep_stat { - USB_EP_ST_RX_DIS = USB_EP_STAT_RX_DISABLED, - USB_EP_ST_RX_STL = USB_EP_STAT_RX_STALL, - USB_EP_ST_RX_NAK = USB_EP_STAT_RX_NAK, - USB_EP_ST_RX_VAL = USB_EP_STAT_RX_VALID, - USB_EP_ST_TX_DIS = USB_EP_STAT_TX_DISABLED, - USB_EP_ST_TX_STL = USB_EP_STAT_TX_STALL, - USB_EP_ST_TX_NAK = USB_EP_STAT_TX_NAK, - USB_EP_ST_TX_VAL = USB_EP_STAT_TX_VALID -} usb_ep_stat; - -#endif diff --git a/GD32F1/system/libmaple/usb/usb_lib/usb_core.h b/GD32F1/system/libmaple/usb/usb_lib/usb_core.h deleted file mode 100644 index fa29a18..0000000 --- a/GD32F1/system/libmaple/usb/usb_lib/usb_core.h +++ /dev/null @@ -1,251 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_core.h -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Standard protocol processing functions prototypes -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_CORE_H -#define __USB_CORE_H - -#if defined(__cplusplus) -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Exported types ------------------------------------------------------------*/ -typedef enum _CONTROL_STATE -{ - WAIT_SETUP, /* 0 */ - SETTING_UP, /* 1 */ - IN_DATA, /* 2 */ - OUT_DATA, /* 3 */ - LAST_IN_DATA, /* 4 */ - LAST_OUT_DATA, /* 5 */ - WAIT_STATUS_IN, /* 7 */ - WAIT_STATUS_OUT, /* 8 */ - STALLED, /* 9 */ - PAUSE /* 10 */ -} CONTROL_STATE; /* The state machine states of a control pipe */ - -typedef struct OneDescriptor -{ - u8 *Descriptor; - u16 Descriptor_Size; -} -ONE_DESCRIPTOR, *PONE_DESCRIPTOR; -/* All the request process routines return a value of this type - If the return value is not SUCCESS or NOT_READY, - the software will STALL the correspond endpoint */ -typedef enum _RESULT -{ - USB_SUCCESS = 0, /* Process sucessfully */ - USB_ERROR, - USB_UNSUPPORT, - USB_NOT_READY /* The process has not been finished, endpoint will be - NAK to further rquest */ -} RESULT; - - -/*-*-*-*-*-*-*-*-*-*-* Definitions for endpoint level -*-*-*-*-*-*-*-*-*-*-*-*/ -typedef struct _ENDPOINT_INFO -{ - /* When send data out of the device, - CopyData() is used to get data buffer 'Length' bytes data - if Length is 0, - CopyData() returns the total length of the data - if the request is not supported, returns 0 - (NEW Feature ) - if CopyData() returns -1, the calling routine should not proceed - further and will resume the SETUP process by the class device - if Length is not 0, - CopyData() returns a pointer to indicate the data location - Usb_wLength is the data remain to be sent, - Usb_wOffset is the Offset of original data - When receive data from the host, - CopyData() is used to get user data buffer which is capable - of Length bytes data to copy data from the endpoint buffer. - if Length is 0, - CopyData() returns the available data length, - if Length is not 0, - CopyData() returns user buffer address - Usb_rLength is the data remain to be received, - Usb_rPointer is the Offset of data buffer - */ - u16 Usb_wLength; - u16 Usb_wOffset; - u16 PacketSize; - u8 *(*CopyData)(u16 Length); -}ENDPOINT_INFO; - -/*-*-*-*-*-*-*-*-*-*-*-* Definitions for device level -*-*-*-*-*-*-*-*-*-*-*-*/ - -typedef struct _DEVICE -{ - u8 Total_Endpoint; /* Number of endpoints that are used */ - u8 Total_Configuration;/* Number of configuration available */ -} -DEVICE; - -typedef union -{ - u16 w; - struct BW - { - u8 bb1; - u8 bb0; - } - bw; -} u16_u8; - -typedef struct _DEVICE_INFO -{ - u8 USBbmRequestType; /* bmRequestType */ - u8 USBbRequest; /* bRequest */ - u16_u8 USBwValues; /* wValue */ - u16_u8 USBwIndexs; /* wIndex */ - u16_u8 USBwLengths; /* wLength */ - - u8 ControlState; /* of type CONTROL_STATE */ - u8 Current_Feature; - u8 Current_Configuration; /* Selected configuration */ - u8 Current_Interface; /* Selected interface of current configuration */ - u8 Current_AlternateSetting;/* Selected Alternate Setting of current - interface*/ - - ENDPOINT_INFO Ctrl_Info; -}DEVICE_INFO; - -typedef struct _DEVICE_PROP -{ - void (*Init)(void); /* Initialize the device */ - void (*Reset)(void); /* Reset routine of this device */ - - /* Device dependent process after the status stage */ - void (*Process_Status_IN)(void); - void (*Process_Status_OUT)(void); - - /* Procedure of process on setup stage of a class specified request with data stage */ - /* All class specified requests with data stage are processed in Class_Data_Setup - Class_Data_Setup() - responses to check all special requests and fills ENDPOINT_INFO - according to the request - If IN tokens are expected, then wLength & wOffset will be filled - with the total transferring bytes and the starting position - If OUT tokens are expected, then rLength & rOffset will be filled - with the total expected bytes and the starting position in the buffer - - If the request is valid, Class_Data_Setup returns SUCCESS, else UNSUPPORT - - CAUTION: - Since GET_CONFIGURATION & GET_INTERFACE are highly related to - the individual classes, they will be checked and processed here. - */ - RESULT (*Class_Data_Setup)(u8 RequestNo); - - /* Procedure of process on setup stage of a class specified request without data stage */ - /* All class specified requests without data stage are processed in Class_NoData_Setup - Class_NoData_Setup - responses to check all special requests and perform the request - - CAUTION: - Since SET_CONFIGURATION & SET_INTERFACE are highly related to - the individual classes, they will be checked and processed here. - */ - RESULT (*Class_NoData_Setup)(u8 RequestNo); - - /*Class_Get_Interface_Setting - This function is used by the file usb_core.c to test if the selected Interface - and Alternate Setting (u8 Interface, u8 AlternateSetting) are supported by - the application. - This function is writing by user. It should return "SUCCESS" if the Interface - and Alternate Setting are supported by the application or "UNSUPPORT" if they - are not supported. */ - - RESULT (*Class_Get_Interface_Setting)(u8 Interface, u8 AlternateSetting); - - u8* (*GetDeviceDescriptor)(u16 Length); - u8* (*GetConfigDescriptor)(u16 Length); - u8* (*GetStringDescriptor)(u16 Length); - - u8* RxEP_buffer; - u8 MaxPacketSize; - -}DEVICE_PROP; - -typedef struct _USER_STANDARD_REQUESTS -{ - void (*User_GetConfiguration)(void); /* Get Configuration */ - void (*User_SetConfiguration)(void); /* Set Configuration */ - void (*User_GetInterface)(void); /* Get Interface */ - void (*User_SetInterface)(void); /* Set Interface */ - void (*User_GetStatus)(void); /* Get Status */ - void (*User_ClearFeature)(void); /* Clear Feature */ - void (*User_SetEndPointFeature)(void); /* Set Endpoint Feature */ - void (*User_SetDeviceFeature)(void); /* Set Device Feature */ - void (*User_SetDeviceAddress)(void); /* Set Device Address */ -} -USER_STANDARD_REQUESTS; - -/* Exported constants --------------------------------------------------------*/ -#define Type_Recipient (pInformation->USBbmRequestType & (REQUEST_TYPE | RECIPIENT)) - -#define Usb_rLength Usb_wLength -#define Usb_rOffset Usb_wOffset - -#define USBwValue USBwValues.w -#define USBwValue0 USBwValues.bw.bb0 -#define USBwValue1 USBwValues.bw.bb1 -#define USBwIndex USBwIndexs.w -#define USBwIndex0 USBwIndexs.bw.bb0 -#define USBwIndex1 USBwIndexs.bw.bb1 -#define USBwLength USBwLengths.w -#define USBwLength0 USBwLengths.bw.bb0 -#define USBwLength1 USBwLengths.bw.bb1 - -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ -u8 Setup0_Process(void); -u8 Post0_Process(void); -u8 Out0_Process(void); -u8 In0_Process(void); - -RESULT Standard_SetEndPointFeature(void); -RESULT Standard_SetDeviceFeature(void); - -u8 *Standard_GetConfiguration(u16 Length); -RESULT Standard_SetConfiguration(void); -u8 *Standard_GetInterface(u16 Length); -RESULT Standard_SetInterface(void); -u8 *Standard_GetDescriptorData(u16 Length, PONE_DESCRIPTOR pDesc); - -u8 *Standard_GetStatus(u16 Length); -RESULT Standard_ClearFeature(void); -void SetDeviceAddress(u8); -void NOP_Process(void); - -extern DEVICE_PROP Device_Property; -extern USER_STANDARD_REQUESTS User_Standard_Requests; -extern DEVICE Device_Table; -extern DEVICE_INFO Device_Info; - -/* cells saving status during interrupt servicing */ -extern u16 SaveRState; -extern u16 SaveTState; - -#if defined(__cplusplus) -} -#endif - -#endif /* __USB_CORE_H */ - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/system/libmaple/usb/usb_lib/usb_def.h b/GD32F1/system/libmaple/usb/usb_lib/usb_def.h deleted file mode 100644 index 80aa303..0000000 --- a/GD32F1/system/libmaple/usb/usb_lib/usb_def.h +++ /dev/null @@ -1,88 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_def.h -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Definitions related to USB Core -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_DEF_H -#define __USB_DEF_H - -#if defined(__cplusplus) -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Exported types ------------------------------------------------------------*/ -typedef enum _RECIPIENT_TYPE -{ - DEVICE_RECIPIENT, /* Recipient device */ - INTERFACE_RECIPIENT, /* Recipient interface */ - ENDPOINT_RECIPIENT, /* Recipient endpoint */ - OTHER_RECIPIENT -} RECIPIENT_TYPE; - - -typedef enum _STANDARD_REQUESTS -{ - GET_STATUS = 0, - CLEAR_FEATURE, - RESERVED1, - SET_FEATURE, - RESERVED2, - SET_ADDRESS, - GET_DESCRIPTOR, - SET_DESCRIPTOR, - GET_CONFIGURATION, - SET_CONFIGURATION, - GET_INTERFACE, - SET_INTERFACE, - TOTAL_sREQUEST, /* Total number of Standard request */ - SYNCH_FRAME = 12 -} STANDARD_REQUESTS; - -/* Definition of "USBwValue" */ -typedef enum _DESCRIPTOR_TYPE -{ - DEVICE_DESCRIPTOR = 1, - CONFIG_DESCRIPTOR, - STRING_DESCRIPTOR, - INTERFACE_DESCRIPTOR, - ENDPOINT_DESCRIPTOR -} DESCRIPTOR_TYPE; - -/* Feature selector of a SET_FEATURE or CLEAR_FEATURE */ -typedef enum _FEATURE_SELECTOR -{ - ENDPOINT_STALL, - DEVICE_REMOTE_WAKEUP -} FEATURE_SELECTOR; - -/* Exported constants --------------------------------------------------------*/ -/* Definition of "USBbmRequestType" */ -#define REQUEST_TYPE 0x60 /* Mask to get request type */ -#define STANDARD_REQUEST 0x00 /* Standard request */ -#define CLASS_REQUEST 0x20 /* Class request */ -#define VENDOR_REQUEST 0x40 /* Vendor request */ - -#define RECIPIENT 0x1F /* Mask to get recipient */ - -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ - -#if defined(__cplusplus) -} -#endif - -#endif /* __USB_DEF_H */ - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/system/libmaple/usb/usb_lib/usb_init.h b/GD32F1/system/libmaple/usb/usb_lib/usb_init.h deleted file mode 100644 index 80ee2fb..0000000 --- a/GD32F1/system/libmaple/usb/usb_lib/usb_init.h +++ /dev/null @@ -1,57 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_init.h -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Initialization routines & global variables -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_INIT_H -#define __USB_INIT_H - -#if defined(__cplusplus) -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ -void USB_Init(void); - -/* External variables --------------------------------------------------------*/ -/* The number of current endpoint, it will be used to specify an endpoint */ -extern u8 EPindex; -/* The number of current device, it is an index to the Device_Table */ -/*extern u8 Device_no; */ -/* Points to the DEVICE_INFO structure of current device */ -/* The purpose of this register is to speed up the execution */ -extern DEVICE_INFO* pInformation; -/* Points to the DEVICE_PROP structure of current device */ -/* The purpose of this register is to speed up the execution */ -extern DEVICE_PROP* pProperty; -/* Temporary save the state of Rx & Tx status. */ -/* Whenever the Rx or Tx state is changed, its value is saved */ -/* in this variable first and will be set to the EPRB or EPRA */ -/* at the end of interrupt process */ -extern USER_STANDARD_REQUESTS *pUser_Standard_Requests; - -extern u16 SaveState ; -extern u16 wInterrupt_Mask; - -#if defined(__cplusplus) -} -#endif - -#endif /* __USB_INIT_H */ - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/system/libmaple/usb/usb_lib/usb_lib.h b/GD32F1/system/libmaple/usb/usb_lib/usb_lib.h deleted file mode 100644 index 85f94ab..0000000 --- a/GD32F1/system/libmaple/usb/usb_lib/usb_lib.h +++ /dev/null @@ -1,36 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_lib.h -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : USB library include files -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_LIB_H -#define __USB_LIB_H - -/* Includes ------------------------------------------------------------------*/ -#include "usb_type.h" -#include "usb_regs.h" -#include "usb_def.h" -#include "usb_core.h" -#include "usb_init.h" -#include "usb_mem.h" - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ -/* External variables --------------------------------------------------------*/ - -#endif /* __USB_LIB_H */ - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/system/libmaple/usb/usb_lib/usb_mem.h b/GD32F1/system/libmaple/usb/usb_lib/usb_mem.h deleted file mode 100644 index b0e0474..0000000 --- a/GD32F1/system/libmaple/usb/usb_lib/usb_mem.h +++ /dev/null @@ -1,40 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_mem.h -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Utility prototypes functions for memory/PMA transfers -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_MEM_H -#define __USB_MEM_H - -/* Includes ------------------------------------------------------------------*/ -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ -#if defined(__cplusplus) -extern "C" { -#endif - -void UserToPMABufferCopy(const u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes); -void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes); - -#if defined(__cplusplus) -} -#endif - -/* External variables --------------------------------------------------------*/ - -#endif /*__USB_MEM_H*/ - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/system/libmaple/usb/usb_lib/usb_regs.h b/GD32F1/system/libmaple/usb/usb_lib/usb_regs.h deleted file mode 100644 index b63cc5f..0000000 --- a/GD32F1/system/libmaple/usb/usb_lib/usb_regs.h +++ /dev/null @@ -1,627 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_regs.h -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Interface prototype functions to USB cell registers -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_REGS_H -#define __USB_REGS_H - -/* Includes ------------------------------------------------------------------*/ -/* Exported types ------------------------------------------------------------*/ -#if defined(__cplusplus) -extern "C" { -#endif - -typedef enum _EP_DBUF_DIR -{ - /* double buffered endpoint direction */ - EP_DBUF_ERR, - EP_DBUF_OUT, - EP_DBUF_IN -}EP_DBUF_DIR; - -/* endpoint buffer number */ -enum EP_BUF_NUM -{ - EP_NOBUF, - EP_BUF0, - EP_BUF1 -}; - -/* Exported constants --------------------------------------------------------*/ -#define RegBase (0x40005C00L) /* USB_IP Peripheral Registers base address */ -#define PMAAddr (0x40006000L) /* USB_IP Packet Memory Area base address */ - -/******************************************************************************/ -/* General registers */ -/******************************************************************************/ - -/* Control register */ -#define CNTR ((volatile unsigned *)(RegBase + 0x40)) -/* Interrupt status register */ -#define ISTR ((volatile unsigned *)(RegBase + 0x44)) -/* Frame number register */ -#define FNR ((volatile unsigned *)(RegBase + 0x48)) -/* Device address register */ -#define DADDR ((volatile unsigned *)(RegBase + 0x4C)) -/* Buffer Table address register */ -#define BTABLE ((volatile unsigned *)(RegBase + 0x50)) -/******************************************************************************/ -/* Endpoint registers */ -/******************************************************************************/ -#define EP0REG ((volatile unsigned *)(RegBase)) /* endpoint 0 register address */ - -/* endpoints enumeration */ -#define ENDP0 ((u8)0) -#define ENDP1 ((u8)1) -#define ENDP2 ((u8)2) -#define ENDP3 ((u8)3) -#define ENDP4 ((u8)4) -#define ENDP5 ((u8)5) -#define ENDP6 ((u8)6) -#define ENDP7 ((u8)7) -/******************************************************************************/ -/* ISTR interrupt events */ -/******************************************************************************/ -#define ISTR_CTR (0x8000) /* Correct TRansfer (clear-only bit) */ -#define ISTR_DOVR (0x4000) /* DMA OVeR/underrun (clear-only bit) */ -#define ISTR_ERR (0x2000) /* ERRor (clear-only bit) */ -#define ISTR_WKUP (0x1000) /* WaKe UP (clear-only bit) */ -#define ISTR_SUSP (0x0800) /* SUSPend (clear-only bit) */ -#define ISTR_RESET (0x0400) /* RESET (clear-only bit) */ -#define ISTR_SOF (0x0200) /* Start Of Frame (clear-only bit) */ -#define ISTR_ESOF (0x0100) /* Expected Start Of Frame (clear-only bit) */ - - -#define ISTR_DIR (0x0010) /* DIRection of transaction (read-only bit) */ -#define ISTR_EP_ID (0x000F) /* EndPoint IDentifier (read-only bit) */ - -#define CLR_CTR (~ISTR_CTR) /* clear Correct TRansfer bit */ -#define CLR_DOVR (~ISTR_DOVR) /* clear DMA OVeR/underrun bit*/ -#define CLR_ERR (~ISTR_ERR) /* clear ERRor bit */ -#define CLR_WKUP (~ISTR_WKUP) /* clear WaKe UP bit */ -#define CLR_SUSP (~ISTR_SUSP) /* clear SUSPend bit */ -#define CLR_RESET (~ISTR_RESET) /* clear RESET bit */ -#define CLR_SOF (~ISTR_SOF) /* clear Start Of Frame bit */ -#define CLR_ESOF (~ISTR_ESOF) /* clear Expected Start Of Frame bit */ - -/******************************************************************************/ -/* CNTR control register bits definitions */ -/******************************************************************************/ -#define CNTR_CTRM (0x8000) /* Correct TRansfer Mask */ -#define CNTR_DOVRM (0x4000) /* DMA OVeR/underrun Mask */ -#define CNTR_ERRM (0x2000) /* ERRor Mask */ -#define CNTR_WKUPM (0x1000) /* WaKe UP Mask */ -#define CNTR_SUSPM (0x0800) /* SUSPend Mask */ -#define CNTR_RESETM (0x0400) /* RESET Mask */ -#define CNTR_SOFM (0x0200) /* Start Of Frame Mask */ -#define CNTR_ESOFM (0x0100) /* Expected Start Of Frame Mask */ - - -#define CNTR_RESUME (0x0010) /* RESUME request */ -#define CNTR_FSUSP (0x0008) /* Force SUSPend */ -#define CNTR_LPMODE (0x0004) /* Low-power MODE */ -#define CNTR_PDWN (0x0002) /* Power DoWN */ -#define CNTR_FRES (0x0001) /* Force USB RESet */ - -/******************************************************************************/ -/* FNR Frame Number Register bit definitions */ -/******************************************************************************/ -#define FNR_RXDP (0x8000) /* status of D+ data line */ -#define FNR_RXDM (0x4000) /* status of D- data line */ -#define FNR_LCK (0x2000) /* LoCKed */ -#define FNR_LSOF (0x1800) /* Lost SOF */ -#define FNR_FN (0x07FF) /* Frame Number */ -/******************************************************************************/ -/* DADDR Device ADDRess bit definitions */ -/******************************************************************************/ -#define DADDR_EF (0x80) -#define DADDR_ADD (0x7F) -/******************************************************************************/ -/* Endpoint register */ -/******************************************************************************/ -/* bit positions */ -#define EP_CTR_RX (0x8000) /* EndPoint Correct TRansfer RX */ -#define EP_DTOG_RX (0x4000) /* EndPoint Data TOGGLE RX */ -#define EPRX_STAT (0x3000) /* EndPoint RX STATus bit field */ -#define EP_SETUP (0x0800) /* EndPoint SETUP */ -#define EP_T_FIELD (0x0600) /* EndPoint TYPE */ -#define EP_KIND (0x0100) /* EndPoint KIND */ -#define EP_CTR_TX (0x0080) /* EndPoint Correct TRansfer TX */ -#define EP_DTOG_TX (0x0040) /* EndPoint Data TOGGLE TX */ -#define EPTX_STAT (0x0030) /* EndPoint TX STATus bit field */ -#define EPADDR_FIELD (0x000F) /* EndPoint ADDRess FIELD */ - -/* EndPoint REGister MASK (no toggle fields) */ -#define EPREG_MASK (EP_CTR_RX|EP_SETUP|EP_T_FIELD|EP_KIND|EP_CTR_TX|EPADDR_FIELD) - -/* EP_TYPE[1:0] EndPoint TYPE */ -#define EP_TYPE_MASK (0x0600) /* EndPoint TYPE Mask */ -#define EP_BULK (0x0000) /* EndPoint BULK */ -#define EP_CONTROL (0x0200) /* EndPoint CONTROL */ -#define EP_ISOCHRONOUS (0x0400) /* EndPoint ISOCHRONOUS */ -#define EP_INTERRUPT (0x0600) /* EndPoint INTERRUPT */ -#define EP_T_MASK (~EP_T_FIELD & EPREG_MASK) - - -/* EP_KIND EndPoint KIND */ -#define EPKIND_MASK (~EP_KIND & EPREG_MASK) - -/* STAT_TX[1:0] STATus for TX transfer */ -#define EP_TX_DIS (0x0000) /* EndPoint TX DISabled */ -#define EP_TX_STALL (0x0010) /* EndPoint TX STALLed */ -#define EP_TX_NAK (0x0020) /* EndPoint TX NAKed */ -#define EP_TX_VALID (0x0030) /* EndPoint TX VALID */ -#define EPTX_DTOG1 (0x0010) /* EndPoint TX Data TOGgle bit1 */ -#define EPTX_DTOG2 (0x0020) /* EndPoint TX Data TOGgle bit2 */ -#define EPTX_DTOGMASK (EPTX_STAT|EPREG_MASK) - -/* STAT_RX[1:0] STATus for RX transfer */ -#define EP_RX_DIS (0x0000) /* EndPoint RX DISabled */ -#define EP_RX_STALL (0x1000) /* EndPoint RX STALLed */ -#define EP_RX_NAK (0x2000) /* EndPoint RX NAKed */ -#define EP_RX_VALID (0x3000) /* EndPoint RX VALID */ -#define EPRX_DTOG1 (0x1000) /* EndPoint RX Data TOGgle bit1 */ -#define EPRX_DTOG2 (0x2000) /* EndPoint RX Data TOGgle bit1 */ -#define EPRX_DTOGMASK (EPRX_STAT|EPREG_MASK) -/* Exported macro ------------------------------------------------------------*/ -/* SetCNTR */ -#define _SetCNTR(wRegValue) (*CNTR = (u16)wRegValue) - -/* SetISTR */ -#define _SetISTR(wRegValue) (*ISTR = (u16)wRegValue) - -/* SetDADDR */ -#define _SetDADDR(wRegValue) (*DADDR = (u16)wRegValue) - -/* SetBTABLE */ -#define _SetBTABLE(wRegValue)(*BTABLE = (u16)(wRegValue & 0xFFF8)) - -/* GetCNTR */ -#define _GetCNTR() ((u16) *CNTR) - -/* GetISTR */ -#define _GetISTR() ((u16) *ISTR) - -/* GetFNR */ -#define _GetFNR() ((u16) *FNR) - -/* GetDADDR */ -#define _GetDADDR() ((u16) *DADDR) - -/* GetBTABLE */ -#define _GetBTABLE() ((u16) *BTABLE) - -/* SetENDPOINT */ -#define _SetENDPOINT(bEpNum,wRegValue) (*(EP0REG + bEpNum)= \ - (u16)wRegValue) - -/* GetENDPOINT */ -#define _GetENDPOINT(bEpNum) ((u16)(*(EP0REG + bEpNum))) - -/******************************************************************************* -* Macro Name : SetEPType -* Description : sets the type in the endpoint register(bits EP_TYPE[1:0]) -* Input : bEpNum: Endpoint Number. -* wType -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPType(bEpNum,wType) (_SetENDPOINT(bEpNum,\ - ((_GetENDPOINT(bEpNum) & EP_T_MASK) | wType))) - -/******************************************************************************* -* Macro Name : GetEPType -* Description : gets the type in the endpoint register(bits EP_TYPE[1:0]) -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : Endpoint Type -*******************************************************************************/ -#define _GetEPType(bEpNum) (_GetENDPOINT(bEpNum) & EP_T_FIELD) - -/******************************************************************************* -* Macro Name : SetEPTxStatus -* Description : sets the status for tx transfer (bits STAT_TX[1:0]). -* Input : bEpNum: Endpoint Number. -* wState: new state -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPTxStatus(bEpNum,wState) {\ - register u16 _wRegVal; \ - _wRegVal = _GetENDPOINT(bEpNum) & EPTX_DTOGMASK;\ - /* toggle first bit ? */ \ - if((EPTX_DTOG1 & wState)!= 0) \ - _wRegVal ^= EPTX_DTOG1; \ - /* toggle second bit ? */ \ - if((EPTX_DTOG2 & wState)!= 0) \ - _wRegVal ^= EPTX_DTOG2; \ - _SetENDPOINT(bEpNum, _wRegVal); \ - } /* _SetEPTxStatus */ - -/******************************************************************************* -* Macro Name : SetEPRxStatus -* Description : sets the status for rx transfer (bits STAT_TX[1:0]) -* Input : bEpNum: Endpoint Number. -* wState: new state. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPRxStatus(bEpNum,wState) {\ - register u16 _wRegVal; \ - \ - _wRegVal = _GetENDPOINT(bEpNum) & EPRX_DTOGMASK;\ - /* toggle first bit ? */ \ - if((EPRX_DTOG1 & wState)!= 0) \ - _wRegVal ^= EPRX_DTOG1; \ - /* toggle second bit ? */ \ - if((EPRX_DTOG2 & wState)!= 0) \ - _wRegVal ^= EPRX_DTOG2; \ - _SetENDPOINT(bEpNum, _wRegVal); \ - } /* _SetEPRxStatus */ -/******************************************************************************* -* Macro Name : GetEPTxStatus / GetEPRxStatus -* Description : gets the status for tx/rx transfer (bits STAT_TX[1:0] -* /STAT_RX[1:0]) -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : status . -*******************************************************************************/ -#define _GetEPTxStatus(bEpNum) ((u16)_GetENDPOINT(bEpNum) & EPTX_STAT) - -#define _GetEPRxStatus(bEpNum) ((u16)_GetENDPOINT(bEpNum) & EPRX_STAT) - -/******************************************************************************* -* Macro Name : SetEPTxValid / SetEPRxValid -* Description : sets directly the VALID tx/rx-status into the enpoint register -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPTxValid(bEpNum) (_SetEPTxStatus(bEpNum, EP_TX_VALID)) - -#define _SetEPRxValid(bEpNum) (_SetEPRxStatus(bEpNum, EP_RX_VALID)) - -/******************************************************************************* -* Macro Name : GetTxStallStatus / GetRxStallStatus. -* Description : checks stall condition in an endpoint. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : TRUE = endpoint in stall condition. -*******************************************************************************/ -#define _GetTxStallStatus(bEpNum) (_GetEPTxStatus(bEpNum) \ - == EP_TX_STALL) -#define _GetRxStallStatus(bEpNum) (_GetEPRxStatus(bEpNum) \ - == EP_RX_STALL) - -/******************************************************************************* -* Macro Name : SetEP_KIND / ClearEP_KIND. -* Description : set & clear EP_KIND bit. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEP_KIND(bEpNum) (_SetENDPOINT(bEpNum, \ - (_GetENDPOINT(bEpNum) | EP_KIND) & EPREG_MASK)) -#define _ClearEP_KIND(bEpNum) (_SetENDPOINT(bEpNum, \ - (_GetENDPOINT(bEpNum) & EPKIND_MASK))) - -/******************************************************************************* -* Macro Name : Set_Status_Out / Clear_Status_Out. -* Description : Sets/clears directly STATUS_OUT bit in the endpoint register. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _Set_Status_Out(bEpNum) _SetEP_KIND(bEpNum) -#define _Clear_Status_Out(bEpNum) _ClearEP_KIND(bEpNum) - -/******************************************************************************* -* Macro Name : SetEPDoubleBuff / ClearEPDoubleBuff. -* Description : Sets/clears directly EP_KIND bit in the endpoint register. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPDoubleBuff(bEpNum) _SetEP_KIND(bEpNum) -#define _ClearEPDoubleBuff(bEpNum) _ClearEP_KIND(bEpNum) - -/******************************************************************************* -* Macro Name : ClearEP_CTR_RX / ClearEP_CTR_TX. -* Description : Clears bit CTR_RX / CTR_TX in the endpoint register. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _ClearEP_CTR_RX(bEpNum) (_SetENDPOINT(bEpNum,\ - _GetENDPOINT(bEpNum) & 0x7FFF & EPREG_MASK)) -#define _ClearEP_CTR_TX(bEpNum) (_SetENDPOINT(bEpNum,\ - _GetENDPOINT(bEpNum) & 0xFF7F & EPREG_MASK)) - -/******************************************************************************* -* Macro Name : ToggleDTOG_RX / ToggleDTOG_TX . -* Description : Toggles DTOG_RX / DTOG_TX bit in the endpoint register. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _ToggleDTOG_RX(bEpNum) (_SetENDPOINT(bEpNum, \ - EP_DTOG_RX | (_GetENDPOINT(bEpNum) & EPREG_MASK))) -#define _ToggleDTOG_TX(bEpNum) (_SetENDPOINT(bEpNum, \ - EP_DTOG_TX | (_GetENDPOINT(bEpNum) & EPREG_MASK))) - -/******************************************************************************* -* Macro Name : ClearDTOG_RX / ClearDTOG_TX. -* Description : Clears DTOG_RX / DTOG_TX bit in the endpoint register. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _ClearDTOG_RX(bEpNum) if((_GetENDPOINT(bEpNum) & EP_DTOG_RX) != 0)\ - _ToggleDTOG_RX(bEpNum) -#define _ClearDTOG_TX(bEpNum) if((_GetENDPOINT(bEpNum) & EP_DTOG_TX) != 0)\ - _ToggleDTOG_TX(bEpNum) -/******************************************************************************* -* Macro Name : SetEPAddress. -* Description : Sets address in an endpoint register. -* Input : bEpNum: Endpoint Number. -* bAddr: Address. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPAddress(bEpNum,bAddr) _SetENDPOINT(bEpNum,\ - (_GetENDPOINT(bEpNum) & EPREG_MASK) | bAddr) - -/******************************************************************************* -* Macro Name : GetEPAddress. -* Description : Gets address in an endpoint register. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _GetEPAddress(bEpNum) ((u8)(_GetENDPOINT(bEpNum) & EPADDR_FIELD)) - -#define _pEPTxAddr(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8 )*2 + PMAAddr)) -#define _pEPTxCount(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+2)*2 + PMAAddr)) -#define _pEPRxAddr(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+4)*2 + PMAAddr)) -#define _pEPRxCount(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+6)*2 + PMAAddr)) - -/******************************************************************************* -* Macro Name : SetEPTxAddr / SetEPRxAddr. -* Description : sets address of the tx/rx buffer. -* Input : bEpNum: Endpoint Number. -* wAddr: address to be set (must be word aligned). -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPTxAddr(bEpNum,wAddr) (*_pEPTxAddr(bEpNum) = ((wAddr >> 1) << 1)) -#define _SetEPRxAddr(bEpNum,wAddr) (*_pEPRxAddr(bEpNum) = ((wAddr >> 1) << 1)) - -/******************************************************************************* -* Macro Name : GetEPTxAddr / GetEPRxAddr. -* Description : Gets address of the tx/rx buffer. -* Input : bEpNum: Endpoint Number. -* Output : None. -* Return : address of the buffer. -*******************************************************************************/ -#define _GetEPTxAddr(bEpNum) ((u16)*_pEPTxAddr(bEpNum)) -#define _GetEPRxAddr(bEpNum) ((u16)*_pEPRxAddr(bEpNum)) - -/******************************************************************************* -* Macro Name : SetEPCountRxReg. -* Description : Sets counter of rx buffer with no. of blocks. -* Input : pdwReg: pointer to counter. -* wCount: Counter. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _BlocksOf32(dwReg,wCount,wNBlocks) {\ - wNBlocks = wCount >> 5;\ - if((wCount & 0x1f) == 0)\ - wNBlocks--;\ - *pdwReg = (u32)((wNBlocks << 10) | 0x8000);\ - }/* _BlocksOf32 */ - -#define _BlocksOf2(dwReg,wCount,wNBlocks) {\ - wNBlocks = wCount >> 1;\ - if((wCount & 0x1) != 0)\ - wNBlocks++;\ - *pdwReg = (u32)(wNBlocks << 10);\ - }/* _BlocksOf2 */ - -#define _SetEPCountRxReg(dwReg,wCount) {\ - u16 wNBlocks;\ - if(wCount > 62){_BlocksOf32(dwReg,wCount,wNBlocks);}\ - else {_BlocksOf2(dwReg,wCount,wNBlocks);}\ - }/* _SetEPCountRxReg */ - - - -#define _SetEPRxDblBuf0Count(bEpNum,wCount) {\ - u32 *pdwReg = _pEPTxCount(bEpNum); \ - _SetEPCountRxReg(pdwReg, wCount);\ - } -/******************************************************************************* -* Macro Name : SetEPTxCount / SetEPRxCount. -* Description : sets counter for the tx/rx buffer. -* Input : bEpNum: endpoint number. -* wCount: Counter value. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPTxCount(bEpNum,wCount) (*_pEPTxCount(bEpNum) = wCount) -#define _SetEPRxCount(bEpNum,wCount) {\ - u32 *pdwReg = _pEPRxCount(bEpNum); \ - _SetEPCountRxReg(pdwReg, wCount);\ - } -/******************************************************************************* -* Macro Name : GetEPTxCount / GetEPRxCount. -* Description : gets counter of the tx buffer. -* Input : bEpNum: endpoint number. -* Output : None. -* Return : Counter value. -*******************************************************************************/ -#define _GetEPTxCount(bEpNum)((u16)(*_pEPTxCount(bEpNum)) & 0x3ff) -#define _GetEPRxCount(bEpNum)((u16)(*_pEPRxCount(bEpNum)) & 0x3ff) - -/******************************************************************************* -* Macro Name : SetEPDblBuf0Addr / SetEPDblBuf1Addr. -* Description : Sets buffer 0/1 address in a double buffer endpoint. -* Input : bEpNum: endpoint number. -* : wBuf0Addr: buffer 0 address. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPDblBuf0Addr(bEpNum,wBuf0Addr) {_SetEPTxAddr(bEpNum, wBuf0Addr);} -#define _SetEPDblBuf1Addr(bEpNum,wBuf1Addr) {_SetEPRxAddr(bEpNum, wBuf1Addr);} - -/******************************************************************************* -* Macro Name : SetEPDblBuffAddr. -* Description : Sets addresses in a double buffer endpoint. -* Input : bEpNum: endpoint number. -* : wBuf0Addr: buffer 0 address. -* : wBuf1Addr = buffer 1 address. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPDblBuffAddr(bEpNum,wBuf0Addr,wBuf1Addr) { \ - _SetEPDblBuf0Addr(bEpNum, wBuf0Addr);\ - _SetEPDblBuf1Addr(bEpNum, wBuf1Addr);\ - } /* _SetEPDblBuffAddr */ - -/******************************************************************************* -* Macro Name : GetEPDblBuf0Addr / GetEPDblBuf1Addr. -* Description : Gets buffer 0/1 address of a double buffer endpoint. -* Input : bEpNum: endpoint number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _GetEPDblBuf0Addr(bEpNum) (_GetEPTxAddr(bEpNum)) -#define _GetEPDblBuf1Addr(bEpNum) (_GetEPRxAddr(bEpNum)) - -/******************************************************************************* -* Macro Name : SetEPDblBuffCount / SetEPDblBuf0Count / SetEPDblBuf1Count. -* Description : Gets buffer 0/1 address of a double buffer endpoint. -* Input : bEpNum: endpoint number. -* : bDir: endpoint dir EP_DBUF_OUT = OUT -* EP_DBUF_IN = IN -* : wCount: Counter value -* Output : None. -* Return : None. -*******************************************************************************/ -#define _SetEPDblBuf0Count(bEpNum, bDir, wCount) { \ - if(bDir == EP_DBUF_OUT)\ - /* OUT endpoint */ \ - {_SetEPRxDblBuf0Count(bEpNum,wCount);} \ - else if(bDir == EP_DBUF_IN)\ - /* IN endpoint */ \ - *_pEPTxCount(bEpNum) = (u32)wCount; \ - } /* SetEPDblBuf0Count*/ - -#define _SetEPDblBuf1Count(bEpNum, bDir, wCount) { \ - if(bDir == EP_DBUF_OUT)\ - /* OUT endpoint */ \ - {_SetEPRxCount(bEpNum,wCount);}\ - else if(bDir == EP_DBUF_IN)\ - /* IN endpoint */\ - *_pEPRxCount(bEpNum) = (u32)wCount; \ - } /* SetEPDblBuf1Count */ - -#define _SetEPDblBuffCount(bEpNum, bDir, wCount) {\ - _SetEPDblBuf0Count(bEpNum, bDir, wCount); \ - _SetEPDblBuf1Count(bEpNum, bDir, wCount); \ - } /* _SetEPDblBuffCount */ - -/******************************************************************************* -* Macro Name : GetEPDblBuf0Count / GetEPDblBuf1Count. -* Description : Gets buffer 0/1 rx/tx counter for double buffering. -* Input : bEpNum: endpoint number. -* Output : None. -* Return : None. -*******************************************************************************/ -#define _GetEPDblBuf0Count(bEpNum) (_GetEPTxCount(bEpNum)) -#define _GetEPDblBuf1Count(bEpNum) (_GetEPRxCount(bEpNum)) - - -/* External variables --------------------------------------------------------*/ -extern volatile u16 wIstr; /* ISTR register last read value */ - -/* Exported functions ------------------------------------------------------- */ -void SetCNTR(u16 /*wRegValue*/); -void SetISTR(u16 /*wRegValue*/); -void SetDADDR(u16 /*wRegValue*/); -void SetBTABLE(u16 /*wRegValue*/); -u16 GetCNTR(void); -u16 GetISTR(void); -u16 GetFNR(void); -u16 GetDADDR(void); -u16 GetBTABLE(void); -void SetENDPOINT(u8 /*bEpNum*/, u16 /*wRegValue*/); -u16 GetENDPOINT(u8 /*bEpNum*/); -void SetEPType(u8 /*bEpNum*/, u16 /*wType*/); -u16 GetEPType(u8 /*bEpNum*/); -void SetEPTxStatus(u8 /*bEpNum*/, u16 /*wState*/); -void SetEPRxStatus(u8 /*bEpNum*/, u16 /*wState*/); -void SetDouBleBuffEPStall(u8 /*bEpNum*/, u8 bDir); -u16 GetEPTxStatus(u8 /*bEpNum*/); -u16 GetEPRxStatus(u8 /*bEpNum*/); -void SetEPTxValid(u8 /*bEpNum*/); -void SetEPRxValid(u8 /*bEpNum*/); -u16 GetTxStallStatus(u8 /*bEpNum*/); -u16 GetRxStallStatus(u8 /*bEpNum*/); -void SetEP_KIND(u8 /*bEpNum*/); -void ClearEP_KIND(u8 /*bEpNum*/); -void Set_Status_Out(u8 /*bEpNum*/); -void Clear_Status_Out(u8 /*bEpNum*/); -void SetEPDoubleBuff(u8 /*bEpNum*/); -void ClearEPDoubleBuff(u8 /*bEpNum*/); -void ClearEP_CTR_RX(u8 /*bEpNum*/); -void ClearEP_CTR_TX(u8 /*bEpNum*/); -void ToggleDTOG_RX(u8 /*bEpNum*/); -void ToggleDTOG_TX(u8 /*bEpNum*/); -void ClearDTOG_RX(u8 /*bEpNum*/); -void ClearDTOG_TX(u8 /*bEpNum*/); -void SetEPAddress(u8 /*bEpNum*/, u8 /*bAddr*/); -u8 GetEPAddress(u8 /*bEpNum*/); -void SetEPTxAddr(u8 /*bEpNum*/, u16 /*wAddr*/); -void SetEPRxAddr(u8 /*bEpNum*/, u16 /*wAddr*/); -u16 GetEPTxAddr(u8 /*bEpNum*/); -u16 GetEPRxAddr(u8 /*bEpNum*/); -void SetEPCountRxReg(u32 * /*pdwReg*/, u16 /*wCount*/); -void SetEPTxCount(u8 /*bEpNum*/, u16 /*wCount*/); -void SetEPRxCount(u8 /*bEpNum*/, u16 /*wCount*/); -u16 GetEPTxCount(u8 /*bEpNum*/); -u16 GetEPRxCount(u8 /*bEpNum*/); -void SetEPDblBuf0Addr(u8 /*bEpNum*/, u16 /*wBuf0Addr*/); -void SetEPDblBuf1Addr(u8 /*bEpNum*/, u16 /*wBuf1Addr*/); -void SetEPDblBuffAddr(u8 /*bEpNum*/, u16 /*wBuf0Addr*/, u16 /*wBuf1Addr*/); -u16 GetEPDblBuf0Addr(u8 /*bEpNum*/); -u16 GetEPDblBuf1Addr(u8 /*bEpNum*/); -void SetEPDblBuffCount(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/); -void SetEPDblBuf0Count(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/); -void SetEPDblBuf1Count(u8 /*bEpNum*/, u8 /*bDir*/, u16 /*wCount*/); -u16 GetEPDblBuf0Count(u8 /*bEpNum*/); -u16 GetEPDblBuf1Count(u8 /*bEpNum*/); -EP_DBUF_DIR GetEPDblBufDir(u8 /*bEpNum*/); -void FreeUserBuffer(u8 bEpNum/*bEpNum*/, u8 bDir); -u16 ToWord(u8, u8); -u16 ByteSwap(u16); - -#if defined(__cplusplus) -} -#endif - -#endif /* __USB_REGS_H */ - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/system/libmaple/usb/usb_lib/usb_type.h b/GD32F1/system/libmaple/usb/usb_lib/usb_type.h deleted file mode 100644 index 34b3bf5..0000000 --- a/GD32F1/system/libmaple/usb/usb_lib/usb_type.h +++ /dev/null @@ -1,77 +0,0 @@ -/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** -* File Name : usb_type.h -* Author : MCD Application Team -* Version : V2.2.1 -* Date : 09/22/2008 -* Description : Type definitions used by the USB Library -******************************************************************************** -* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS -* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_TYPE_H -#define __USB_TYPE_H - -#if defined(__cplusplus) -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -#ifndef NULL -#define NULL ((void *)0) -#endif - -typedef signed long s32; -typedef signed short s16; -typedef signed char s8; - -typedef volatile signed long vs32; -typedef volatile signed short vs16; -typedef volatile signed char vs8; - -typedef unsigned long u32; -typedef unsigned short u16; -typedef unsigned char u8; - -typedef unsigned long const uc32; /* Read Only */ -typedef unsigned short const uc16; /* Read Only */ -typedef unsigned char const uc8; /* Read Only */ - -typedef volatile unsigned long vu32; -typedef volatile unsigned short vu16; -typedef volatile unsigned char vu8; - -typedef volatile unsigned long const vuc32; /* Read Only */ -typedef volatile unsigned short const vuc16; /* Read Only */ -typedef volatile unsigned char const vuc8; /* Read Only */ - - -typedef enum -{ - FALSE = 0, TRUE = !FALSE -} -USB_Bool; - -typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus; - -typedef enum { DISABLE = 0, ENABLE = !DISABLE} FunctionalState; - -typedef enum { ERROR = 0, SUCCESS = !ERROR} ErrorStatus; - -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ -/* External variables --------------------------------------------------------*/ - -#if defined(__cplusplus) -} -#endif - -#endif /* __USB_TYPE_H */ - -/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ diff --git a/GD32F1/system/support/doxygen/Doxyfile b/GD32F1/system/support/doxygen/Doxyfile deleted file mode 100644 index 170cff4..0000000 --- a/GD32F1/system/support/doxygen/Doxyfile +++ /dev/null @@ -1,1648 +0,0 @@ -# Doxyfile 1.7.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libmaple - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = custom-build - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ./doxygen - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = YES - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = "sideeffect=\par Side Effects:\n" - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = YES - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penality. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will rougly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = YES - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = NO - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = NO - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = NO - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ./libmaple/ \ - ./wirish/ \ - ./libraries/ - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 - -FILE_PATTERNS = *.h *.c - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -# We include the FreeRTOS sources. That's probably a mistake. Oh well. -EXCLUDE = ./libraries/FreeRTOS/ - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -# Trick Doxygen into thinking series headers are in separate -# namespaces; see the Evil Mangler source for more information. -FILTER_PATTERNS = */libmaple/stm32*/include/series/*.h=./support/doxygen/evil_mangler.awk - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the stylesheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvances is that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = YES - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = YES - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = NO - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = __attribute__()= \ - __deprecated= \ - __always_inline= \ - __packed = \ - __weak = \ - __cplusplus \ - STM32_MEDIUM_DENSITY \ - STM32_HIGH_DENSITY \ - STM32_XL_DENSITY \ - PCLK1=0 STM32_PCLK1=0 \ - PCLK2=0 STM32_PCLK2=0 \ - STM32_HAVE_TIMER(x)=1 \ - __DOXYGEN__ - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = NO - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. - -DOT_FONTNAME = FreeSans.ttf - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = NO - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = NO - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = NO - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/GD32F1/system/support/doxygen/evil_mangler.awk b/GD32F1/system/support/doxygen/evil_mangler.awk deleted file mode 100644 index b07da72..0000000 --- a/GD32F1/system/support/doxygen/evil_mangler.awk +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/awk -f - -# libmaple's own Evil Mangler -# -# Input filter hack to trick Doxygen into thinking that a series -# header is in a separate namespace. This is necessary because Doxygen -# doesn't know how to cope with two data structures with the same name -# in different places in the project. (We do that all the time, -# e.g. for foo_reg_map structs.) -# -# E.g., an STM32F1 header gets transformed into: -# -# namespace stm32f1 { -# -# } - -BEGIN { - # For extracting series component from header FILENAME. - series_regex = "/stm32[flw][0-9]*/"; - # Holds header FILENAME. Cargo-culted; not sure why it's necessary. - f = ""; - # Holds series component. - series = ""; -} -{ - if (f != FILENAME) { - f = FILENAME; - match(f, series_regex); - series = substr(f, RSTART + 1, RLENGTH - 2); - printf("namespace %s {\n", series); - } - print; -} -END { - if (series != "") { - print "}" - } -} diff --git a/GD32F1/system/support/gdb/gpio/gpio.gdb b/GD32F1/system/support/gdb/gpio/gpio.gdb deleted file mode 100644 index 4376cfd..0000000 --- a/GD32F1/system/support/gdb/gpio/gpio.gdb +++ /dev/null @@ -1,12 +0,0 @@ -set print pretty on - -print "GPIOA registers:" -p/x *GPIOA->regs -print "GPIOB registers:" -p/x *GPIOB->regs -print "GPIOC registers:" -p/x *GPIOC->regs -print "GPIOD registers:" -p/x *GPIOD->regs -print "AFIO registers:" -p/x *(struct afio_reg_map*)0x40010000 diff --git a/GD32F1/system/support/gdb/i2c/test.gdb b/GD32F1/system/support/gdb/i2c/test.gdb deleted file mode 100644 index 8b71320..0000000 --- a/GD32F1/system/support/gdb/i2c/test.gdb +++ /dev/null @@ -1,112 +0,0 @@ -define i2c_sr1_flags -set $s = $arg0 -printf "SR1: " - -if (($s & (1 << 15))) - printf "SMBALERT " -end - -if (($s & (1 << 14))) - printf "TIMEOUT " -end - -if (($s & (1 << 12))) - printf "PECERR " -end - -if (($s & (1 << 11))) - printf "OVR " -end - -if (($s & (1 << 10))) - printf "AF " -end - -if (($s & (1 << 9))) - printf "ARLO " -end - -if (($s & (1 << 8))) - printf "BERR " -end - -if (($s & (1 << 7))) - printf "TXE " -end - -if (($s & (1 << 6))) - printf "RXNE " -end - -if (($s & (1 << 4))) - printf "STOPF " -end - -if (($s & (1 << 3))) - printf "ADD10 " -end - -if (($s & (1 << 2))) - printf "BTF " -end - -if (($s & (1 << 1))) - printf "ADDR " -end - -if (($s & (1 << 0))) - printf "SB " -end -end - -define i2c_sr2_flags -set $s = $arg0 -printf "SR2: " - -if (($s & (1 << 7))) - printf "DUALF " -end - -if (($s & (1 << 6))) - printf "SMBHOST " -end - -if (($s & (1 << 5))) - printf "SMBDEFAULT " -end - -if (($s & (1 << 4))) - printf "GENCALL " -end - - -if (($s & (1 << 2))) - printf "TRA " -end - -if (($s & (1 << 1))) - printf "BUSY " -end - -if (($s & (1 << 0))) - printf "MSL " -end - -end - -define pbc -set $c = crumbs -while ($c->event) - if ($c->event != 0) - printf "Event: %d ", $c->event - if ($c->event == 1) - i2c_sr1_flags $c->sr1 - printf "\t" - i2c_sr2_flags $c->sr2 - end - printf "\n" - end - set $c = $c + 1 -end - - diff --git a/GD32F1/system/support/ld/common.inc b/GD32F1/system/support/ld/common.inc deleted file mode 100644 index f5a0f5b..0000000 --- a/GD32F1/system/support/ld/common.inc +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Linker script for libmaple. - * - * Original author "lanchon" from ST forums, with modifications by LeafLabs. - */ - -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") - -/* - * Configure other libraries we want in the link. - * - * libgcc, libc, and libm are common across supported toolchains. - * However, some toolchains require additional archives which aren't - * present everywhere (e.g. ARM's gcc-arm-embedded releases). - * - * To hack around this, we let the build system specify additional - * archives by putting the right extra_libs.inc (in a directory under - * toolchains/) in our search path. - */ -GROUP(libgcc.a libc.a libm.a) -INCLUDE extra_libs.inc - -/* - * These force the linker to search for vector table symbols. - * - * These symbols vary by STM32 family (and also within families). - * It's up to the build system to configure the link's search path - * properly for the target MCU. - */ -INCLUDE vector_symbols.inc - -/* STM32 vector table. */ -EXTERN(__stm32_vector_table) - -/* C runtime initialization function. */ -EXTERN(start_c) - -/* main entry point */ -EXTERN(main) - -/* Initial stack pointer value. */ -EXTERN(__msp_init) -PROVIDE(__msp_init = ORIGIN(ram) + LENGTH(ram)); - -/* Reset vector and chip reset entry point */ -EXTERN(__start__) -ENTRY(__start__) -PROVIDE(__exc_reset = __start__); - -/* Heap boundaries, for libmaple */ -EXTERN(_lm_heap_start); -EXTERN(_lm_heap_end); - -SECTIONS -{ - .text : - { - __text_start__ = .; - /* - * STM32 vector table. Leave this here. Yes, really. - */ - *(.stm32.interrupt_vector) - - /* - * Program code and vague linking - */ - *(.text .text.* .gnu.linkonce.t.*) - *(.plt) - *(.gnu.warning) - *(.glue_7t) *(.glue_7) *(.vfp11_veneer) - - *(.ARM.extab* .gnu.linkonce.armextab.*) - *(.gcc_except_table) - *(.eh_frame_hdr) - *(.eh_frame) - - . = ALIGN(4); - KEEP(*(.init)) - - . = ALIGN(4); - __preinit_array_start = .; - KEEP (*(.preinit_array)) - __preinit_array_end = .; - - . = ALIGN(4); - __init_array_start = .; - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array)) - __init_array_end = .; - - . = ALIGN(0x4); - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*crtend.o(.ctors)) - - . = ALIGN(4); - KEEP(*(.fini)) - - . = ALIGN(4); - __fini_array_start = .; - KEEP (*(.fini_array)) - KEEP (*(SORT(.fini_array.*))) - __fini_array_end = .; - - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*crtend.o(.dtors)) - } > REGION_TEXT - - /* - * End of text - */ - .text.align : - { - . = ALIGN(8); - __text_end__ = .; - } > REGION_TEXT - - /* - * .ARM.exidx exception unwinding; mandated by ARM's C++ ABI - */ - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > REGION_RODATA - __exidx_end = .; - - /* - * .data - */ - .data : - { - . = ALIGN(8); - __data_start__ = .; - - *(.got.plt) *(.got) - *(.data .data.* .gnu.linkonce.d.*) - - . = ALIGN(8); - __data_end__ = .; - } > REGION_DATA AT> REGION_RODATA - - /* - * Read-only data - */ - .rodata : - { - *(.rodata .rodata.* .gnu.linkonce.r.*) - /* .USER_FLASH: We allow users to allocate into Flash here */ - *(.USER_FLASH) - /* ROM image configuration; for C startup */ - . = ALIGN(4); - _lm_rom_img_cfgp = .; - LONG(LOADADDR(.data)); - /* - * Heap: Linker scripts may choose a custom heap by overriding - * _lm_heap_start and _lm_heap_end. Otherwise, the heap is in - * internal SRAM, beginning after .bss, and growing towards - * the stack. - * - * I'm shoving these here naively; there's probably a cleaner way - * to go about this. [mbolivar] - */ - _lm_heap_start = DEFINED(_lm_heap_start) ? _lm_heap_start : _end; - _lm_heap_end = DEFINED(_lm_heap_end) ? _lm_heap_end : __msp_init; - } > REGION_RODATA - - /* - * .bss - */ - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - *(.bss .bss.* .gnu.linkonce.b.*) - *(COMMON) - . = ALIGN (8); - __bss_end__ = .; - _end = __bss_end__; - } > REGION_BSS - - /* - * Debugging sections - */ - .stab 0 (NOLOAD) : { *(.stab) } - .stabstr 0 (NOLOAD) : { *(.stabstr) } - /* DWARF debug sections. - * Symbols in the DWARF debugging sections are relative to the beginning - * of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - - .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } - .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) } - /DISCARD/ : { *(.note.GNU-stack) } -} diff --git a/GD32F1/system/support/ld/flash.ld b/GD32F1/system/support/ld/flash.ld deleted file mode 100644 index 9e250cd..0000000 --- a/GD32F1/system/support/ld/flash.ld +++ /dev/null @@ -1,26 +0,0 @@ -/* - * libmaple linker script for "Flash" builds. - * - * A Flash build puts .text (and .rodata) in Flash, and - * .data/.bss/heap (of course) in SRAM, but offsets the sections by - * enough space to store the Maple bootloader, which lives in low - * Flash and uses low memory. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -INCLUDE mem-flash.inc - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/system/support/ld/jtag.ld b/GD32F1/system/support/ld/jtag.ld deleted file mode 100644 index 0612f95..0000000 --- a/GD32F1/system/support/ld/jtag.ld +++ /dev/null @@ -1,31 +0,0 @@ -/* - * libmaple linker script for "JTAG" builds. - * - * A "JTAG" build puts .text (and .rodata) in Flash, and - * .data/.bss/heap (of course) in SRAM, but links starting at the - * Flash and SRAM starting addresses (0x08000000 and 0x20000000 - * respectively). This will wipe out a Maple bootloader if there's one - * on the board, so only use this if you know what you're doing. - * - * Of course, a "JTAG" build is perfectly usable for upload over SWD, - * the system memory bootloader, etc. The name is just a historical - * artifact. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -INCLUDE mem-jtag.inc - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/system/support/ld/ram.ld b/GD32F1/system/support/ld/ram.ld deleted file mode 100644 index 34b468e..0000000 --- a/GD32F1/system/support/ld/ram.ld +++ /dev/null @@ -1,25 +0,0 @@ -/* - * libmaple linker script for RAM builds. - * - * A Flash build puts .text, .rodata, and .data/.bss/heap (of course) - * in SRAM, but offsets the sections by enough space to store the - * Maple bootloader, which uses low memory. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -INCLUDE mem-ram.inc - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", ram); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", ram); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/system/support/ld/stm32/mem/maple_native/maple_native_heap.inc b/GD32F1/system/support/ld/stm32/mem/maple_native/maple_native_heap.inc deleted file mode 100644 index 34b5a2d..0000000 --- a/GD32F1/system/support/ld/stm32/mem/maple_native/maple_native_heap.inc +++ /dev/null @@ -1,3 +0,0 @@ -/* Specify heap boundary addresses on the external SRAM chip */ -_lm_heap_start = 0x60000000; -_lm_heap_end = 0x60100000; diff --git a/GD32F1/system/support/ld/stm32/mem/maple_native/mem-flash.inc b/GD32F1/system/support/ld/stm32/mem/maple_native/mem-flash.inc deleted file mode 100644 index bae4f39..0000000 --- a/GD32F1/system/support/ld/stm32/mem/maple_native/mem-flash.inc +++ /dev/null @@ -1,7 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K -} - -INCLUDE maple_native_heap.inc diff --git a/GD32F1/system/support/ld/stm32/mem/maple_native/mem-jtag.inc b/GD32F1/system/support/ld/stm32/mem/maple_native/mem-jtag.inc deleted file mode 100644 index 508ed44..0000000 --- a/GD32F1/system/support/ld/stm32/mem/maple_native/mem-jtag.inc +++ /dev/null @@ -1,7 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K -} - -INCLUDE maple_native_heap.inc diff --git a/GD32F1/system/support/ld/stm32/mem/maple_native/mem-ram.inc b/GD32F1/system/support/ld/stm32/mem/maple_native/mem-ram.inc deleted file mode 100644 index 6ae11ef..0000000 --- a/GD32F1/system/support/ld/stm32/mem/maple_native/mem-ram.inc +++ /dev/null @@ -1,7 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} - -INCLUDE maple_native_heap.inc diff --git a/GD32F1/system/support/ld/stm32/mem/sram_112k_flash_1024k/mem-jtag.inc b/GD32F1/system/support/ld/stm32/mem/sram_112k_flash_1024k/mem-jtag.inc deleted file mode 100644 index e0d2da1..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_112k_flash_1024k/mem-jtag.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc b/GD32F1/system/support/ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc deleted file mode 100644 index d21f17c..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 0K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc b/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc deleted file mode 100644 index a9091ca..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc b/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc deleted file mode 100644 index 20fbec0..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc b/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc deleted file mode 100644 index f02453b..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-flash.inc b/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-flash.inc deleted file mode 100644 index 2c03ea9..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-flash.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08003000, LENGTH = 108K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-jtag.inc b/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-jtag.inc deleted file mode 100644 index 20fbec0..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-jtag.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-ram.inc b/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-ram.inc deleted file mode 100644 index f02453b..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-ram.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc b/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc deleted file mode 100644 index ddb8876..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc b/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc deleted file mode 100644 index d3ed992..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc b/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc deleted file mode 100644 index 360beaf..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc b/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc deleted file mode 100644 index 19372b7..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc b/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc deleted file mode 100644 index 19372b7..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} diff --git a/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc b/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc deleted file mode 100644 index 4063ab4..0000000 --- a/GD32F1/system/support/ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 0K -} diff --git a/GD32F1/system/support/ld/stm32/series/stm32f1/performance/vector_symbols.inc b/GD32F1/system/support/ld/stm32/series/stm32f1/performance/vector_symbols.inc deleted file mode 100644 index f8519bb..0000000 --- a/GD32F1/system/support/ld/stm32/series/stm32f1/performance/vector_symbols.inc +++ /dev/null @@ -1,78 +0,0 @@ -EXTERN(__msp_init) -EXTERN(__exc_reset) -EXTERN(__exc_nmi) -EXTERN(__exc_hardfault) -EXTERN(__exc_memmanage) -EXTERN(__exc_busfault) -EXTERN(__exc_usagefault) -EXTERN(__stm32reservedexception7) -EXTERN(__stm32reservedexception8) -EXTERN(__stm32reservedexception9) -EXTERN(__stm32reservedexception10) -EXTERN(__exc_svc) -EXTERN(__exc_debug_monitor) -EXTERN(__stm32reservedexception13) -EXTERN(__exc_pendsv) -EXTERN(__exc_systick) - -EXTERN(__irq_wwdg) -EXTERN(__irq_pvd) -EXTERN(__irq_tamper) -EXTERN(__irq_rtc) -EXTERN(__irq_flash) -EXTERN(__irq_rcc) -EXTERN(__irq_exti0) -EXTERN(__irq_exti1) -EXTERN(__irq_exti2) -EXTERN(__irq_exti3) -EXTERN(__irq_exti4) -EXTERN(__irq_dma1_channel1) -EXTERN(__irq_dma1_channel2) -EXTERN(__irq_dma1_channel3) -EXTERN(__irq_dma1_channel4) -EXTERN(__irq_dma1_channel5) -EXTERN(__irq_dma1_channel6) -EXTERN(__irq_dma1_channel7) -EXTERN(__irq_adc) -EXTERN(__irq_usb_hp_can_tx) -EXTERN(__irq_usb_lp_can_rx0) -EXTERN(__irq_can_rx1) -EXTERN(__irq_can_sce) -EXTERN(__irq_exti9_5) -EXTERN(__irq_tim1_brk) -EXTERN(__irq_tim1_up) -EXTERN(__irq_tim1_trg_com) -EXTERN(__irq_tim1_cc) -EXTERN(__irq_tim2) -EXTERN(__irq_tim3) -EXTERN(__irq_tim4) -EXTERN(__irq_i2c1_ev) -EXTERN(__irq_i2c1_er) -EXTERN(__irq_i2c2_ev) -EXTERN(__irq_i2c2_er) -EXTERN(__irq_spi1) -EXTERN(__irq_spi2) -EXTERN(__irq_usart1) -EXTERN(__irq_usart2) -EXTERN(__irq_usart3) -EXTERN(__irq_exti15_10) -EXTERN(__irq_rtcalarm) -EXTERN(__irq_usbwakeup) - -EXTERN(__irq_tim8_brk) -EXTERN(__irq_tim8_up) -EXTERN(__irq_tim8_trg_com) -EXTERN(__irq_tim8_cc) -EXTERN(__irq_adc3) -EXTERN(__irq_fsmc) -EXTERN(__irq_sdio) -EXTERN(__irq_tim5) -EXTERN(__irq_spi3) -EXTERN(__irq_uart4) -EXTERN(__irq_uart5) -EXTERN(__irq_tim6) -EXTERN(__irq_tim7) -EXTERN(__irq_dma2_channel1) -EXTERN(__irq_dma2_channel2) -EXTERN(__irq_dma2_channel3) -EXTERN(__irq_dma2_channel4_5) diff --git a/GD32F1/system/support/ld/stm32/series/stm32f1/value/vector_symbols.inc b/GD32F1/system/support/ld/stm32/series/stm32f1/value/vector_symbols.inc deleted file mode 100644 index f8726f9..0000000 --- a/GD32F1/system/support/ld/stm32/series/stm32f1/value/vector_symbols.inc +++ /dev/null @@ -1,78 +0,0 @@ -EXTERN(__msp_init) -EXTERN(__exc_reset) -EXTERN(__exc_nmi) -EXTERN(__exc_hardfault) -EXTERN(__exc_memmanage) -EXTERN(__exc_busfault) -EXTERN(__exc_usagefault) -EXTERN(__stm32reservedexception7) -EXTERN(__stm32reservedexception8) -EXTERN(__stm32reservedexception9) -EXTERN(__stm32reservedexception10) -EXTERN(__exc_svc) -EXTERN(__exc_debug_monitor) -EXTERN(__stm32reservedexception13) -EXTERN(__exc_pendsv) -EXTERN(__exc_systick) - -EXTERN(__irq_wwdg) -EXTERN(__irq_pvd) -EXTERN(__irq_tamper) -EXTERN(__irq_rtc) -EXTERN(__irq_flash) -EXTERN(__irq_rcc) -EXTERN(__irq_exti0) -EXTERN(__irq_exti1) -EXTERN(__irq_exti2) -EXTERN(__irq_exti3) -EXTERN(__irq_exti4) -EXTERN(__irq_dma1_channel1) -EXTERN(__irq_dma1_channel2) -EXTERN(__irq_dma1_channel3) -EXTERN(__irq_dma1_channel4) -EXTERN(__irq_dma1_channel5) -EXTERN(__irq_dma1_channel6) -EXTERN(__irq_dma1_channel7) -EXTERN(__irq_adc1) -EXTERN(__stm32reservedexception14) -EXTERN(__stm32reservedexception15) -EXTERN(__stm32reservedexception16) -EXTERN(__stm32reservedexception17) -EXTERN(__irq_exti9_5) -EXTERN(__irq_tim1_brk) -EXTERN(__irq_tim1_up) -EXTERN(__irq_tim1_trg_com) -EXTERN(__irq_tim1_cc) -EXTERN(__irq_tim2) -EXTERN(__irq_tim3) -EXTERN(__irq_tim4) -EXTERN(__irq_i2c1_ev) -EXTERN(__irq_i2c1_er) -EXTERN(__irq_i2c2_ev) -EXTERN(__irq_i2c2_er) -EXTERN(__irq_spi1) -EXTERN(__irq_spi2) -EXTERN(__irq_usart1) -EXTERN(__irq_usart2) -EXTERN(__irq_usart3) -EXTERN(__irq_exti15_10) -EXTERN(__irq_rtcalarm) -EXTERN(__irq_cec) -EXTERN(__irq_tim12) -EXTERN(__irq_tim13) -EXTERN(__irq_tim14) -EXTERN(__stm32reservedexception18) -EXTERN(__stm32reservedexception19) -EXTERN(__irq_fsmc) -EXTERN(__stm32reservedexception20) -EXTERN(__irq_tim5) -EXTERN(__irq_spi3) -EXTERN(__irq_uart4) -EXTERN(__irq_uart5) -EXTERN(__irq_tim6) -EXTERN(__irq_tim7) -EXTERN(__irq_dma2_channel1) -EXTERN(__irq_dma2_channel2) -EXTERN(__irq_dma2_channel3) -EXTERN(__irq_dma2_channel4_5) -EXTERN(__irq_dma2_channel5) /* on remap only */ diff --git a/GD32F1/system/support/ld/stm32/series/stm32f2/vector_symbols.inc b/GD32F1/system/support/ld/stm32/series/stm32f2/vector_symbols.inc deleted file mode 100644 index d275ec3..0000000 --- a/GD32F1/system/support/ld/stm32/series/stm32f2/vector_symbols.inc +++ /dev/null @@ -1,98 +0,0 @@ -EXTERN(__msp_init) -EXTERN(__exc_reset) -EXTERN(__exc_nmi) -EXTERN(__exc_hardfault) -EXTERN(__exc_memmanage) -EXTERN(__exc_busfault) -EXTERN(__exc_usagefault) -EXTERN(__stm32reservedexception7) -EXTERN(__stm32reservedexception8) -EXTERN(__stm32reservedexception9) -EXTERN(__stm32reservedexception10) -EXTERN(__exc_svc) -EXTERN(__exc_debug_monitor) -EXTERN(__stm32reservedexception13) -EXTERN(__exc_pendsv) -EXTERN(__exc_systick) - -EXTERN(__irq_wwdg) -EXTERN(__irq_pvd) -EXTERN(__irq_tamp_stamp) -EXTERN(__irq_rtc_wkup) -EXTERN(__irq_flash) -EXTERN(__irq_rcc) -EXTERN(__irq_exti0) -EXTERN(__irq_exti1) -EXTERN(__irq_exti2) -EXTERN(__irq_exti3) -EXTERN(__irq_exti4) -EXTERN(__irq_dma1_stream0) -EXTERN(__irq_dma1_stream1) -EXTERN(__irq_dma1_stream2) -EXTERN(__irq_dma1_stream3) -EXTERN(__irq_dma1_stream4) -EXTERN(__irq_dma1_stream5) -EXTERN(__irq_dma1_stream6) -EXTERN(__irq_adc) -EXTERN(__irq_can1_tx) -EXTERN(__irq_can1_rx0) -EXTERN(__irq_can1_rx1) -EXTERN(__irq_can1_sce) -EXTERN(__irq_exti9_5) -EXTERN(__irq_tim1_brk_tim9) -EXTERN(__irq_tim1_up_tim10) -EXTERN(__irq_tim1_trg_com_tim11) -EXTERN(__irq_tim1_cc) -EXTERN(__irq_tim2) -EXTERN(__irq_tim3) -EXTERN(__irq_tim4) -EXTERN(__irq_i2c1_ev) -EXTERN(__irq_i2c1_er) -EXTERN(__irq_i2c2_ev) -EXTERN(__irq_i2c2_er) -EXTERN(__irq_spi1) -EXTERN(__irq_spi2) -EXTERN(__irq_usart1) -EXTERN(__irq_usart2) -EXTERN(__irq_usart3) -EXTERN(__irq_exti15_10) -EXTERN(__irq_rtc_alarm) -EXTERN(__irq_otg_fs_wkup) -EXTERN(__irq_tim8_brk_tim12) -EXTERN(__irq_tim8_up_tim13) -EXTERN(__irq_tim8_trg_com_tim14) -EXTERN(__irq_tim8_cc) -EXTERN(__irq_dma1_stream7) -EXTERN(__irq_fsmc) -EXTERN(__irq_sdio) -EXTERN(__irq_tim5) -EXTERN(__irq_spi3) -EXTERN(__irq_uart4) -EXTERN(__irq_uart5) -EXTERN(__irq_tim6_dac) -EXTERN(__irq_tim7) -EXTERN(__irq_dma2_stream0) -EXTERN(__irq_dma2_stream1) -EXTERN(__irq_dma2_stream2) -EXTERN(__irq_dma2_stream3) -EXTERN(__irq_dma2_stream4) -EXTERN(__irq_eth) -EXTERN(__irq_eth_wkup) -EXTERN(__irq_can2_tx) -EXTERN(__irq_can2_rx0) -EXTERN(__irq_can2_rx1) -EXTERN(__irq_can2_sce) -EXTERN(__irq_otg_fs) -EXTERN(__irq_dma2_stream5) -EXTERN(__irq_dma2_stream6) -EXTERN(__irq_dma2_stream7) -EXTERN(__irq_usart6) -EXTERN(__irq_i2c3_ev) -EXTERN(__irq_i2c3_er) -EXTERN(__irq_otg_hs_ep1_out) -EXTERN(__irq_otg_hs_ep1_in) -EXTERN(__irq_otg_hs_wkup) -EXTERN(__irq_otg_hs) -EXTERN(__irq_dcmi) -EXTERN(__irq_cryp) -EXTERN(__irq_hash_rng) diff --git a/GD32F1/system/support/ld/toolchains/gcc-arm-embedded/extra_libs.inc b/GD32F1/system/support/ld/toolchains/gcc-arm-embedded/extra_libs.inc deleted file mode 100644 index dd2c84f..0000000 --- a/GD32F1/system/support/ld/toolchains/gcc-arm-embedded/extra_libs.inc +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Extra archives needed by ARM's GCC ARM Embedded arm-none-eabi- - * releases (https://launchpad.net/gcc-arm-embedded/). - */ - -/* This is for the provided newlib. */ -GROUP(libnosys.a) diff --git a/GD32F1/system/support/ld/toolchains/generic/extra_libs.inc b/GD32F1/system/support/ld/toolchains/generic/extra_libs.inc deleted file mode 100644 index e69de29..0000000 diff --git a/GD32F1/system/support/make/board-includes/VLDiscovery.mk b/GD32F1/system/support/make/board-includes/VLDiscovery.mk deleted file mode 100644 index 76cd85a..0000000 --- a/GD32F1/system/support/make/board-includes/VLDiscovery.mk +++ /dev/null @@ -1,7 +0,0 @@ -MCU := STM32F100RB -PRODUCT_ID := 0003 -ERROR_LED_PORT := GPIOC -ERROR_LED_PIN := 9 -MCU_SERIES := stm32f1 -MCU_F1_LINE := value -LD_MEM_DIR := sram_8k_flash_128k diff --git a/GD32F1/system/support/make/board-includes/cm900.mk b/GD32F1/system/support/make/board-includes/cm900.mk deleted file mode 100644 index 9f70a1b..0000000 --- a/GD32F1/system/support/make/board-includes/cm900.mk +++ /dev/null @@ -1,15 +0,0 @@ -MCU := STM32F103C8 -PRODUCT_ID := 0003 -ERROR_LED_PORT := GPIOB -ERROR_LED_PIN := 2 -MCU_SERIES := stm32f1 -MCU_F1_LINE := performance -# This crap is due to ld-script limitations. If you know of a better -# way to go about this (like some magic ld switches to specify MEMORY -# at the command line), please tell us! -ifeq ($(BOOTLOADER),maple) -LD_MEM_DIR := sram_20k_flash_128k -endif -ifeq ($(BOOTLOADER),robotis) -LD_MEM_DIR := sram_20k_flash_128k_robotis -endif diff --git a/GD32F1/system/support/make/board-includes/maple.mk b/GD32F1/system/support/make/board-includes/maple.mk deleted file mode 100644 index a2943ce..0000000 --- a/GD32F1/system/support/make/board-includes/maple.mk +++ /dev/null @@ -1,10 +0,0 @@ -MCU := STM32F103RB -PRODUCT_ID := 0003 -ERROR_LED_PORT := GPIOA -ERROR_LED_PIN := 5 -MCU_SERIES := stm32f1 -MCU_F1_LINE := performance -# This crap is due to ld-script limitations. If you know of a better -# way to go about this (like some magic ld switches to specify MEMORY -# at the command line), please tell us! -LD_MEM_DIR := sram_20k_flash_128k diff --git a/GD32F1/system/support/make/board-includes/maple_RET6.mk b/GD32F1/system/support/make/board-includes/maple_RET6.mk deleted file mode 100644 index 138722f..0000000 --- a/GD32F1/system/support/make/board-includes/maple_RET6.mk +++ /dev/null @@ -1,7 +0,0 @@ -MCU := STM32F103RE -PRODUCT_ID := 0003 -ERROR_LED_PORT := GPIOA -ERROR_LED_PIN := 5 -MCU_SERIES := stm32f1 -MCU_F1_LINE := performance -LD_MEM_DIR := sram_64k_flash_512k diff --git a/GD32F1/system/support/make/board-includes/maple_mini.mk b/GD32F1/system/support/make/board-includes/maple_mini.mk deleted file mode 100644 index b022537..0000000 --- a/GD32F1/system/support/make/board-includes/maple_mini.mk +++ /dev/null @@ -1,7 +0,0 @@ -MCU := STM32F103CB -PRODUCT_ID := 0003 -ERROR_LED_PORT := GPIOB -ERROR_LED_PIN := 1 -MCU_SERIES := stm32f1 -MCU_F1_LINE := performance -LD_MEM_DIR := sram_20k_flash_128k diff --git a/GD32F1/system/support/make/board-includes/maple_native.mk b/GD32F1/system/support/make/board-includes/maple_native.mk deleted file mode 100644 index 87e58e3..0000000 --- a/GD32F1/system/support/make/board-includes/maple_native.mk +++ /dev/null @@ -1,7 +0,0 @@ -MCU := STM32F103ZE -PRODUCT_ID := 0003 -ERROR_LED_PORT := GPIOC -ERROR_LED_PIN := 15 -MCU_SERIES := stm32f1 -MCU_F1_LINE := performance -LD_MEM_DIR := maple_native # The SRAM chip makes this board special diff --git a/GD32F1/system/support/make/board-includes/olimex_stm32_h103.mk b/GD32F1/system/support/make/board-includes/olimex_stm32_h103.mk deleted file mode 100644 index a3304a1..0000000 --- a/GD32F1/system/support/make/board-includes/olimex_stm32_h103.mk +++ /dev/null @@ -1,7 +0,0 @@ -MCU := STM32F103RB -PRODUCT_ID := 0003 -ERROR_LED_PORT := GPIOC -ERROR_LED_PIN := 12 -MCU_SERIES := stm32f1 -MCU_F1_LINE := performance -LD_MEM_DIR := sram_20k_flash_128k diff --git a/GD32F1/system/support/make/board-includes/opencm904.mk b/GD32F1/system/support/make/board-includes/opencm904.mk deleted file mode 100644 index 64d3351..0000000 --- a/GD32F1/system/support/make/board-includes/opencm904.mk +++ /dev/null @@ -1,15 +0,0 @@ -MCU := STM32F103CB -PRODUCT_ID := 0003 -ERROR_LED_PORT := GPIOB -ERROR_LED_PIN := 9 -MCU_SERIES := stm32f1 -MCU_F1_LINE := performance -# This crap is due to ld-script limitations. If you know of a better -# way to go about this (like some magic ld switches to specify MEMORY -# at the command line), please tell us! -ifeq ($(BOOTLOADER),maple) -LD_MEM_DIR := sram_20k_flash_128k -endif -ifeq ($(BOOTLOADER),robotis) -LD_MEM_DIR := sram_20k_flash_128k_robotis -endif diff --git a/GD32F1/system/support/make/board-includes/st_stm3220g_eval.mk b/GD32F1/system/support/make/board-includes/st_stm3220g_eval.mk deleted file mode 100644 index 8aaefc9..0000000 --- a/GD32F1/system/support/make/board-includes/st_stm3220g_eval.mk +++ /dev/null @@ -1,5 +0,0 @@ -MCU := STM32F207IG -ERROR_LED_PORT := GPIOG -ERROR_LED_PIN := 6 -MCU_SERIES := stm32f2 -LD_MEM_DIR := sram_112k_flash_1024k diff --git a/GD32F1/system/support/make/build-rules.mk b/GD32F1/system/support/make/build-rules.mk deleted file mode 100644 index 7c918d8..0000000 --- a/GD32F1/system/support/make/build-rules.mk +++ /dev/null @@ -1,59 +0,0 @@ -# Useful tools -CROSS_COMPILE ?= arm-none-eabi- - -CC := $(CROSS_COMPILE)gcc -CXX := $(CROSS_COMPILE)g++ -LD := $(CROSS_COMPILE)ld -v -AR := $(CROSS_COMPILE)ar -AS := $(CROSS_COMPILE)gcc -OBJCOPY := $(CROSS_COMPILE)objcopy -DISAS := $(CROSS_COMPILE)objdump -OBJDUMP := $(CROSS_COMPILE)objdump -SIZE := $(CROSS_COMPILE)size -DFU ?= dfu-util - -# Suppress annoying output unless V is set -ifndef V - SILENT_CC = @echo ' [CC] ' $(@:$(BUILD_PATH)/%.o=%.c); - SILENT_AS = @echo ' [AS] ' $(@:$(BUILD_PATH)/%.o=%.S); - SILENT_CXX = @echo ' [CXX] ' $(@:$(BUILD_PATH)/%.o=%.cpp); - SILENT_LD = @echo ' [LD] ' $(@F); - SILENT_AR = @echo ' [AR] ' - SILENT_OBJCOPY = @echo ' [OBJCOPY] ' $(@F); - SILENT_DISAS = @echo ' [DISAS] ' $(@:$(BUILD_PATH)/%.bin=%).disas; - SILENT_OBJDUMP = @echo ' [OBJDUMP] ' $(OBJDUMP); -endif - -# Extra build configuration - -BUILDDIRS := -TGT_BIN := - -CFLAGS = $(GLOBAL_CFLAGS) $(TGT_CFLAGS) -CXXFLAGS = $(GLOBAL_CXXFLAGS) $(TGT_CXXFLAGS) -ASFLAGS = $(GLOBAL_ASFLAGS) $(TGT_ASFLAGS) - -# Hacks to determine extra libraries we need to link against based on -# the toolchain. The default specifies no extra libraries, but it can -# be overridden. -LD_TOOLCHAIN_PATH := $(LDDIR)/toolchains/generic -ifneq ($(findstring ARM/embedded,$(shell $(CC) --version)),) -# GCC ARM Embedded, https://launchpad.net/gcc-arm-embedded/ -LD_TOOLCHAIN_PATH := $(LDDIR)/toolchains/gcc-arm-embedded -endif -ifneq ($(findstring Linaro GCC,$(shell $(CC) --version)),) -# Summon/Linaro GCC ARM Embedded, https://github.com/esden/summon-arm-toolchain -LD_TOOLCHAIN_PATH := $(LDDIR)/toolchains/gcc-arm-embedded -endif -# Add toolchain directory to LD search path -TOOLCHAIN_LDFLAGS := -L $(LD_TOOLCHAIN_PATH) - -# General directory independent build rules, generate dependency information -$(BUILD_PATH)/%.o: %.c - $(SILENT_CC) $(CC) $(CFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $< - -$(BUILD_PATH)/%.o: %.cpp - $(SILENT_CXX) $(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $< - -$(BUILD_PATH)/%.o: %.S - $(SILENT_AS) $(AS) $(ASFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $< diff --git a/GD32F1/system/support/make/build-templates.mk b/GD32F1/system/support/make/build-templates.mk deleted file mode 100644 index 4371f13..0000000 --- a/GD32F1/system/support/make/build-templates.mk +++ /dev/null @@ -1,5 +0,0 @@ -define LIBMAPLE_MODULE_template -dir := $(1) -include $$(dir)/rules.mk -endef - diff --git a/GD32F1/system/support/make/footer.mk b/GD32F1/system/support/make/footer.mk deleted file mode 100644 index 2242416..0000000 --- a/GD32F1/system/support/make/footer.mk +++ /dev/null @@ -1,18 +0,0 @@ -sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) -cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) -cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) - -OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \ - $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ - $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) -DEPS_$(d) := $(OBJS_$(d):%.o=%.d) - -$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) -$(OBJS_$(d)): TGT_CXXFLAGS := $(CXXFLAGS_$(d)) -$(OBJS_$(d)): TGT_ASFLAGS := $(ASFLAGS_$(d)) - -TGT_BIN += $(OBJS_$(d)) - --include $(DEPS_$(d)) -d := $(dirstack_$(sp)) -sp := $(basename $(sp)) diff --git a/GD32F1/system/support/make/header.mk b/GD32F1/system/support/make/header.mk deleted file mode 100644 index c85594a..0000000 --- a/GD32F1/system/support/make/header.mk +++ /dev/null @@ -1,4 +0,0 @@ -sp := $(sp).x -dirstack_$(sp) := $(d) -d := $(dir) -BUILDDIRS += $(BUILD_PATH)/$(d) diff --git a/GD32F1/system/support/make/target-config.mk b/GD32F1/system/support/make/target-config.mk deleted file mode 100644 index 0e3a2c2..0000000 --- a/GD32F1/system/support/make/target-config.mk +++ /dev/null @@ -1,54 +0,0 @@ -# TARGET_FLAGS are to be passed while compiling, assembling, linking. -TARGET_FLAGS := -# TARGET_LDFLAGS go to the linker -TARGET_LDFLAGS := - -# Configuration derived from $(MEMORY_TARGET) - -LD_SCRIPT_PATH := $(LDDIR)/$(MEMORY_TARGET).ld - -ifeq ($(MEMORY_TARGET), ram) -VECT_BASE_ADDR := VECT_TAB_RAM -endif -ifeq ($(MEMORY_TARGET), flash) -VECT_BASE_ADDR := VECT_TAB_FLASH -endif -ifeq ($(MEMORY_TARGET), jtag) -VECT_BASE_ADDR := VECT_TAB_BASE -endif - -# Pull in the board configuration file here, so it can override the -# above. - -include $(BOARD_INCLUDE_DIR)/$(BOARD).mk - -# Configuration derived from $(BOARD).mk - -LD_SERIES_PATH := $(LDDIR)/stm32/series/$(MCU_SERIES) -LD_MEM_PATH := $(LDDIR)/stm32/mem/$(LD_MEM_DIR) -ifeq ($(MCU_SERIES), stm32f1) -# Due to the Balkanization on F1, we need to specify the line when -# making linker decisions. -LD_SERIES_PATH := $(LD_SERIES_PATH)/$(MCU_F1_LINE) -endif - -ifeq ($(MCU_SERIES), stm32f1) -TARGET_FLAGS += -mcpu=cortex-m3 -march=armv7-m -endif -ifeq ($(MCU_SERIES), stm32f2) -TARGET_FLAGS += -mcpu=cortex-m3 -march=armv7-m -endif -ifeq ($(MCU_SERIES), stm32f4) -TARGET_FLAGS += -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -endif - -TARGET_LDFLAGS += -Xlinker -T$(LD_SCRIPT_PATH) \ - -L $(LD_SERIES_PATH) \ - -L $(LD_MEM_PATH) \ - -L $(LDDIR) -TARGET_FLAGS += -mthumb -DBOARD_$(BOARD) -DMCU_$(MCU) \ - -DERROR_LED_PORT=$(ERROR_LED_PORT) \ - -DERROR_LED_PIN=$(ERROR_LED_PIN) \ - -D$(VECT_BASE_ADDR) - -LIBMAPLE_MODULE_SERIES := $(LIBMAPLE_PATH)/$(MCU_SERIES) diff --git a/GD32F1/system/support/scripts/45-maple.rules b/GD32F1/system/support/scripts/45-maple.rules deleted file mode 100644 index d1bda5f..0000000 --- a/GD32F1/system/support/scripts/45-maple.rules +++ /dev/null @@ -1,5 +0,0 @@ -ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev" -ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev" -ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple" -ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple" - diff --git a/GD32F1/system/support/scripts/copy-to-ide b/GD32F1/system/support/scripts/copy-to-ide deleted file mode 100644 index e68abca..0000000 --- a/GD32F1/system/support/scripts/copy-to-ide +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh - -# This hack copies libmaple's source, linker scripts, and support -# libraries into the Maple IDE repository (which is expected as its -# first argument). - -DEST=$1 - -DEST_CORES=$DEST/hardware/leaflabs/cores/maple -DEST_LIBS=$DEST/libraries - -LMAPLE_SRC="LICENSE - ./libmaple/*.h - ./libmaple/*.c - ./libmaple/*.S - ./libmaple/usb/*.h - ./libmaple/usb/*.c - ./libmaple/usb/usb_lib/*.h - ./libmaple/usb/usb_lib/*.c - ./wirish/*.h - ./wirish/main.cxx - ./wirish/*.cpp - ./wirish/comm/*.cpp - ./wirish/comm/*.h - ./wirish/boards/*.h - ./wirish/boards/*.cpp - ./support/ld/common.inc - ./support/ld/maple - ./support/ld/maple_mini - ./support/ld/maple_native - ./support/ld/maple_RET6 - ./support/ld/names.inc" - -echo "First make sure DEST exists: $DEST" -if !(test -d $DEST) -then - echo "Nope! Make sure you're doing this right?" - exit -1 -fi - -# source -echo Copying libmaple source -rm -rf $DEST_CORES/*.c $DEST_CORES/*.cpp $DEST_CORES/*.h $DEST_CORES/*.cxx $DEST_CORES/*.S -rm -rf $DEST_CORES/*.inc $DEST_CORES/*.a $DEST_CORES/maple $DEST_CORES/maple_* -cp -R $LMAPLE_SRC $DEST_CORES - -echo Copying over libraries -cp -R libraries/* $DEST_LIBS - -# libmaple version -echo Creating libmaple-version.txt -git show-ref HEAD | cut -c 1-10 > $DEST/libmaple-version.txt - -echo Done. diff --git a/GD32F1/system/support/scripts/reset.py b/GD32F1/system/support/scripts/reset.py deleted file mode 100644 index 67a72c1..0000000 --- a/GD32F1/system/support/scripts/reset.py +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function - -import serial -import os -import platform -import sys -import time -from struct import pack - -def unix_get_maple_path(file_prefix, dev_is_maple=lambda dev: True): - """Try to find the device file for the Maple on *nix. - - This function works assuming that the device file globs like - '/dev/*'. The caller may pass an additional - dev_is_maple predicate if the platform supports additional tests - to determine if a device is a Maple. - - If there are multiple possibilities, ask the user what to do. If - the user chooses not to say, returns None.""" - possible_paths = [os.path.join('/dev', x) for x in os.listdir('/dev') \ - if x.startswith(file_prefix) and dev_is_maple(x)] - return choose_path(possible_paths) - -def linux_get_maple_path(file_prefix='ttyACM'): - """Specialized unix_get_maple_path() for Linux. - - Attempts to check that a candidate device has the correct ID in - the /sys tree when deciding if it's a Maple.""" - return unix_get_maple_path(file_prefix, linux_tty_is_maple) - -def linux_tty_is_maple(device): - try: - sysfile = open("/sys/class/tty/%s/device/uevent" % device, "r") - text = "".join(sysfile.readlines()) - return "PRODUCT=1eaf/4" in text - except IOError: # no udev info available - return True - -def windows_get_maple_path(): - """Similar to unix_get_maple_path(), but on Windows.""" - import _winreg as reg - p = 'HARDWARE\\DEVICEMAP\\SERIALCOMM' - k = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, p) - possible_paths = [] - i = 0 - while True: - try: - possible_paths.append(reg.EnumValue(k, i)[1]) - i += 1 - except WindowsError: - break - return choose_path(possible_paths) - -def choose_path(possible_paths): - if len(possible_paths) == 0: - return None - elif len(possible_paths) == 1: - return possible_paths[0] - else: - print('Found multiple candidates for the Maple device:') - return choose_among_options(possible_paths) - -def choose_among_options(options): - for (i,p) in enumerate(options): - print('\t%d. %s' % (i+1, p)) - - prompt = 'Enter a number to select one, or q to quit: ' - while True: - resp = raw_input(prompt).strip().lower() - if resp == 'q': sys.exit() - - try: - i = int(resp, 10) - except ValueError: - pass - else: - if 0 <= i-1 < len(options): - return options[i-1] - - prompt = 'Please enter a number from the list, or q to quit: ' - -plat_sys = platform.system() -plat_bits = platform.architecture()[0] -if plat_sys == 'Linux': - maple_path = linux_get_maple_path() - # fall back on /dev/maple if that doesn't work - if maple_path is None: - maple_path = '/dev/maple' - print('Could not find Maple serial port; defaulting to /dev/maple.') -elif plat_sys == 'Darwin': - maple_path = unix_get_maple_path('tty.usbmodem') -elif plat_sys == 'Windows': - maple_path = windows_get_maple_path() -else: - maple_path = raw_input('Unrecognized platform. Please enter ' - "the path to the Maple's serial port device file:") - -if maple_path is None: - print('Could not find the Maple serial port for reset.', - 'Perhaps this is your first upload, or the board is already', - 'in bootloader mode.') - print() - print("If your sketch doesn't upload, try putting your Maple", - 'into bootloader mode manually by pressing the RESET button', - 'then letting it go and quickly pressing button BUT', - '(hold for several seconds).') - sys.exit() - -print('Using %s as Maple serial port' % maple_path) - -try: - ser = serial.Serial(maple_path, baudrate=115200, xonxoff=1) - - try: - # try to toggle DTR/RTS (old scheme) - ser.setRTS(0) - time.sleep(0.01) - ser.setDTR(0) - time.sleep(0.01) - ser.setDTR(1) - time.sleep(0.01) - ser.setDTR(0) - - # try magic number - ser.setRTS(1) - time.sleep(0.01) - ser.setDTR(1) - time.sleep(0.01) - ser.setDTR(0) - time.sleep(0.01) - ser.write("1EAF".encode("ascii")) - ser.flush() - - # Delay a bit before proceeding - time.sleep(0.1) - finally: - # ok we're done here - ser.close() - -except Exception as e: - print('Failed to open serial port %s for reset' % maple_path) - sys.exit() - diff --git a/GD32F1/system/support/scripts/robotis-loader.py b/GD32F1/system/support/scripts/robotis-loader.py deleted file mode 100644 index 95d4e71..0000000 --- a/GD32F1/system/support/scripts/robotis-loader.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/python - -# This script sends a program on a robotis board (OpenCM9.04 or CM900) -# using the robotis bootloader (used in OpenCM IDE) -# -# Usage: -# python robotis-loader.py -# -# Example: -# python robotis-loader.py /dev/ttyACM0 firmware.bin -# -# https://github.com/Gregwar/robotis-loader - -import serial, sys, os, time - -print('~~ Robotis loader ~~') -print('') - -# Reading command line -if len(sys.argv) != 3: - exit('! Usage: robotis-loader.py ') -pgm, port, binary = sys.argv - -# Helper to prints a progress bar -def progressBar(percent, precision=65): - threshold=precision*percent/100.0 - sys.stdout.write('[ ') - for x in xrange(0, precision): - if x < threshold: sys.stdout.write('#') - else: sys.stdout.write(' ') - sys.stdout.write(' ] ') - sys.stdout.flush() - -# Opening the firmware file -try: - stat = os.stat(binary) - size = stat.st_size - firmware = file(binary, 'rb') - print('* Opening %s, size=%d' % (binary, size)) -except: - exit('! Unable to open file %s' % binary) - -# Opening serial port -try: - s = serial.Serial(port, baudrate=115200) -except: - exit('! Unable to open serial port %s' % port) - -print('* Resetting the board') -s.setRTS(True) -s.setDTR(False) -time.sleep(0.1) -s.setRTS(False) -s.write('CM9X') -s.close() -time.sleep(1.0); - -print('* Connecting...') -s = serial.Serial(port, baudrate=115200) -s.write('AT&LD') -print('* Download signal transmitted, waiting...') - -# Entering bootloader sequence -while True: - line = s.readline().strip() - if line.endswith('Ready..'): - print('* Board ready, sending data') - cs = 0 - pos = 0 - while True: - c = firmware.read(2048) - if len(c): - pos += len(c) - sys.stdout.write("\r") - progressBar(100*float(pos)/float(size)) - s.write(c) - for k in range(0,len(c)): - cs = (cs+ord(c[k]))%256 - else: - break - print('') - s.setDTR(True) - print('* Checksum: %d' % (cs)) - s.write(chr(cs)) - print('* Firmware was sent') - else: - if line == 'Success..': - print('* Success, running the code') - print('') - s.write('AT&RST') - s.close() - exit() - else: - print('Board -> '+line) diff --git a/GD32F1/system/support/scripts/win-list-com-ports.py b/GD32F1/system/support/scripts/win-list-com-ports.py deleted file mode 100644 index 3e6ecb8..0000000 --- a/GD32F1/system/support/scripts/win-list-com-ports.py +++ /dev/null @@ -1,29 +0,0 @@ -# Windows program for listing COM (serial) ports. -# -# enumerate_serial_ports() is by Eli Bendersky: -# -# http://eli.thegreenplace.net/2009/07/31/listing-all-serial-ports-on-windows-with-python/ - -import _winreg as winreg -import itertools - -def enumerate_serial_ports(): - """ Uses the Win32 registry to return an - iterator of serial (COM) ports - existing on this computer. - """ - path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM' - try: - key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path) - except WindowsError: - raise IterationError - - for i in itertools.count(): - try: - val = winreg.EnumValue(key, i) - yield str(val[1]) - except EnvironmentError: - break - -for com in enumerate_serial_ports(): - print com diff --git a/GD32F1/system/support/stm32loader.py b/GD32F1/system/support/stm32loader.py deleted file mode 100644 index 50686bf..0000000 --- a/GD32F1/system/support/stm32loader.py +++ /dev/null @@ -1,532 +0,0 @@ -#!/usr/bin/env python - -# -*- coding: utf-8 -*- -# vim: sw=4:ts=4:si:et:enc=utf-8 - -# Author: Ivan A-R -# Project page: http://tuxotronic.org/wiki/projects/stm32loader -# -# This file is part of stm32loader. -# -# stm32loader is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 3, or (at your option) any later -# version. -# -# stm32loader is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with stm32loader; see the file COPYING3. If not see -# . - -from __future__ import print_function - -import sys, getopt -import serial -import time -import glob -import time -import tempfile -import os -import subprocess - -try: - from progressbar import * - usepbar = 1 -except: - usepbar = 0 - -# Verbose level -QUIET = 5 - -def mdebug(level, message): - if QUIET >= level: - print(message, file=sys.stderr) - -# Takes chip IDs (obtained via Get ID command) to human-readable names -CHIP_ID_STRS = {0x410: 'STM32F1, performance, medium-density', - 0x411: 'STM32F2', - 0x412: 'STM32F1, performance, low-density', - 0x413: 'STM32F4', - 0x414: 'STM32F1, performance, high-density', - 0x416: 'STM32L1, performance, medium-density', - 0x418: 'STM32F1, connectivity', - 0x420: 'STM32F1, value, medium-density', - 0x428: 'STM32F1, value, high-density', - 0x430: 'STM32F1, performance, XL-density'} - -class CmdException(Exception): - pass - -class CommandInterface(object): - def open(self, aport='/dev/tty.usbserial-FTD3TMCH', abaudrate=115200) : - self.sp = serial.Serial( - port=aport, - baudrate=abaudrate, # baudrate - bytesize=8, # number of databits - parity=serial.PARITY_EVEN, - stopbits=1, - xonxoff=0, # enable software flow control - rtscts=0, # disable RTS/CTS flow control - timeout=0.5 # set a timeout value, None for waiting forever - ) - - - def _wait_for_ack(self, info="", timeout=0): - stop = time.time() + timeout - got = None - while not got: - got = self.sp.read(1) - if time.time() > stop: - break - - if not got: - raise CmdException("No response to %s" % info) - - # wait for ask - ask = ord(got) - - if ask == 0x79: - # ACK - return 1 - elif ask == 0x1F: - # NACK - raise CmdException("Chip replied with a NACK during %s" % info) - - # Unknown response - raise CmdException("Unrecognised response 0x%x to %s" % (ask, info)) - - def reset(self): - self.sp.setDTR(0) - time.sleep(0.1) - self.sp.setDTR(1) - time.sleep(0.5) - - def initChip(self): - # Set boot - self.sp.setRTS(0) - self.reset() - - # Be a bit more persistent when trying to initialise the chip - stop = time.time() + 5.0 - - while time.time() <= stop: - self.sp.write('\x7f') - - got = self.sp.read() - - # The chip will ACK a sync the very first time and - # NACK it every time afterwards - if got and got in '\x79\x1f': - # Synced up - return - - raise CmdException('No response while trying to sync') - - def releaseChip(self): - self.sp.setRTS(1) - self.reset() - - def cmdGeneric(self, cmd): - self.sp.write(chr(cmd)) - self.sp.write(chr(cmd ^ 0xFF)) # Control byte - return self._wait_for_ack(hex(cmd)) - - def cmdGet(self): - if self.cmdGeneric(0x00): - mdebug(10, "*** Get command"); - len = ord(self.sp.read()) - version = ord(self.sp.read()) - mdebug(10, " Bootloader version: "+hex(version)) - dat = map(lambda c: hex(ord(c)), self.sp.read(len)) - mdebug(10, " Available commands: "+str(dat)) - self._wait_for_ack("0x00 end") - return version - else: - raise CmdException("Get (0x00) failed") - - def cmdGetVersion(self): - if self.cmdGeneric(0x01): - mdebug(10, "*** GetVersion command") - version = ord(self.sp.read()) - self.sp.read(2) - self._wait_for_ack("0x01 end") - mdebug(10, " Bootloader version: "+hex(version)) - return version - else: - raise CmdException("GetVersion (0x01) failed") - - def cmdGetID(self): - if self.cmdGeneric(0x02): - mdebug(10, "*** GetID command") - len = ord(self.sp.read()) - id = self.sp.read(len+1) - self._wait_for_ack("0x02 end") - return id - else: - raise CmdException("GetID (0x02) failed") - - - def _encode_addr(self, addr): - byte3 = (addr >> 0) & 0xFF - byte2 = (addr >> 8) & 0xFF - byte1 = (addr >> 16) & 0xFF - byte0 = (addr >> 24) & 0xFF - crc = byte0 ^ byte1 ^ byte2 ^ byte3 - return (chr(byte0) + chr(byte1) + chr(byte2) + chr(byte3) + chr(crc)) - - - def cmdReadMemory(self, addr, lng): - assert(lng <= 256) - if self.cmdGeneric(0x11): - mdebug(10, "*** ReadMemory command") - self.sp.write(self._encode_addr(addr)) - self._wait_for_ack("0x11 address failed") - N = (lng - 1) & 0xFF - crc = N ^ 0xFF - self.sp.write(chr(N) + chr(crc)) - self._wait_for_ack("0x11 length failed") - return map(lambda c: ord(c), self.sp.read(lng)) - else: - raise CmdException("ReadMemory (0x11) failed") - - - def cmdGo(self, addr): - if self.cmdGeneric(0x21): - mdebug(10, "*** Go command") - self.sp.write(self._encode_addr(addr)) - self._wait_for_ack("0x21 go failed") - else: - raise CmdException("Go (0x21) failed") - - - def cmdWriteMemory(self, addr, data): - assert(len(data) <= 256) - if self.cmdGeneric(0x31): - mdebug(10, "*** Write memory command") - self.sp.write(self._encode_addr(addr)) - self._wait_for_ack("0x31 address failed") - #map(lambda c: hex(ord(c)), data) - lng = (len(data)-1) & 0xFF - mdebug(10, " %s bytes to write" % [lng+1]); - self.sp.write(chr(lng)) # len really - crc = 0xFF - for c in data: - crc = crc ^ c - self.sp.write(chr(c)) - self.sp.write(chr(crc)) - self._wait_for_ack("0x31 programming failed") - mdebug(10, " Write memory done") - else: - raise CmdException("Write memory (0x31) failed") - - - def cmdEraseMemory(self, sectors = None): - if self.cmdGeneric(0x43): - mdebug(10, "*** Erase memory command") - if sectors is None: - # Global erase - self.sp.write(chr(0xFF)) - self.sp.write(chr(0x00)) - else: - # Sectors erase - self.sp.write(chr((len(sectors)-1) & 0xFF)) - crc = 0xFF - for c in sectors: - crc = crc ^ c - self.sp.write(chr(c)) - self.sp.write(chr(crc)) - self._wait_for_ack("0x43 erasing failed") - mdebug(10, " Erase memory done") - else: - raise CmdException("Erase memory (0x43) failed") - - - # TODO support for non-global mass erase - GLOBAL_ERASE_TIMEOUT_SECONDS = 20 # This takes a while - def cmdExtendedEraseMemory(self): - if self.cmdGeneric(0x44): - mdebug(10, "*** Extended erase memory command") - # Global mass erase - mdebug(5, "Global mass erase; this may take a while") - self.sp.write(chr(0xFF)) - self.sp.write(chr(0xFF)) - # Checksum - self.sp.write(chr(0x00)) - self._wait_for_ack("0x44 extended erase failed", - timeout=self.GLOBAL_ERASE_TIMEOUT_SECONDS) - mdebug(10, " Extended erase memory done") - else: - raise CmdException("Extended erase memory (0x44) failed") - - - def cmdWriteProtect(self, sectors): - if self.cmdGeneric(0x63): - mdebug(10, "*** Write protect command") - self.sp.write(chr((len(sectors)-1) & 0xFF)) - crc = 0xFF - for c in sectors: - crc = crc ^ c - self.sp.write(chr(c)) - self.sp.write(chr(crc)) - self._wait_for_ack("0x63 write protect failed") - mdebug(10, " Write protect done") - else: - raise CmdException("Write Protect memory (0x63) failed") - - def cmdWriteUnprotect(self): - if self.cmdGeneric(0x73): - mdebug(10, "*** Write Unprotect command") - self._wait_for_ack("0x73 write unprotect failed") - self._wait_for_ack("0x73 write unprotect 2 failed") - mdebug(10, " Write Unprotect done") - else: - raise CmdException("Write Unprotect (0x73) failed") - - def cmdReadoutProtect(self): - if self.cmdGeneric(0x82): - mdebug(10, "*** Readout protect command") - self._wait_for_ack("0x82 readout protect failed") - self._wait_for_ack("0x82 readout protect 2 failed") - mdebug(10, " Read protect done") - else: - raise CmdException("Readout protect (0x82) failed") - - def cmdReadoutUnprotect(self): - if self.cmdGeneric(0x92): - mdebug(10, "*** Readout Unprotect command") - self._wait_for_ack("0x92 readout unprotect failed") - self._wait_for_ack("0x92 readout unprotect 2 failed") - mdebug(10, " Read Unprotect done") - else: - raise CmdException("Readout unprotect (0x92) failed") - - -# Complex commands section - - def readMemory(self, addr, lng): - data = [] - if usepbar: - widgets = ['Reading: ', Percentage(),', ', ETA(), ' ', Bar()] - pbar = ProgressBar(widgets=widgets,maxval=lng, term_width=79).start() - - while lng > 256: - if usepbar: - pbar.update(pbar.maxval-lng) - else: - mdebug(5, "Read %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) - data = data + self.cmdReadMemory(addr, 256) - addr = addr + 256 - lng = lng - 256 - if usepbar: - pbar.update(pbar.maxval-lng) - pbar.finish() - else: - mdebug(5, "Read %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) - data = data + self.cmdReadMemory(addr, lng) - return data - - def writeMemory(self, addr, data): - lng = len(data) - - mdebug(5, "Writing %(lng)d bytes to start address 0x%(addr)X" % - { 'lng': lng, 'addr': addr}) - - if usepbar: - widgets = ['Writing: ', Percentage(),' ', ETA(), ' ', Bar()] - pbar = ProgressBar(widgets=widgets, maxval=lng, term_width=79).start() - - offs = 0 - while lng > 256: - if usepbar: - pbar.update(pbar.maxval-lng) - else: - mdebug(5, "Write %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) - self.cmdWriteMemory(addr, data[offs:offs+256]) - offs = offs + 256 - addr = addr + 256 - lng = lng - 256 - if usepbar: - pbar.update(pbar.maxval-lng) - pbar.finish() - else: - mdebug(5, "Write %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) - self.cmdWriteMemory(addr, data[offs:offs+lng] + ([0xFF] * (256-lng)) ) - - -def usage(): - print("""Usage: %s [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin] - -h This help - -q Quiet - -V Verbose - -e Erase - -w Write - -v Verify - -r Read - -l length Length of read - -p port Serial port (default: first USB-like port in /dev) - -b baud Baud speed (default: 115200) - -a addr Target address - - ./stm32loader.py -e -w -v example/main.bin - - """ % sys.argv[0]) - -def read(filename): - """Read the file to be programmed and turn it into a binary""" - with open(filename, 'rb') as f: - bytes = f.read() - - if bytes.startswith('\x7FELF'): - # Actually an ELF file. Convert to binary - handle, path = tempfile.mkstemp(suffix='.bin', prefix='stm32loader') - - try: - os.close(handle) - - # Try a couple of options for objcopy - for name in ['arm-none-eabi-objcopy', 'arm-linux-gnueabi-objcopy']: - try: - code = subprocess.call([name, '-Obinary', filename, path]) - - if code == 0: - return read(path) - except OSError: - pass - else: - raise Exception('Error %d while converting to a binary file' % code) - finally: - # Remove the temporary file - os.unlink(path) - else: - return [ord(x) for x in bytes] - -if __name__ == "__main__": - - conf = { - 'port': 'auto', - 'baud': 115200, - 'address': 0x08000000, - 'erase': 0, - 'write': 0, - 'verify': 0, - 'read': 0, - 'len': 1000, - 'fname':'', - } - -# http://www.python.org/doc/2.5.2/lib/module-getopt.html - - try: - opts, args = getopt.getopt(sys.argv[1:], "hqVewvrp:b:a:l:") - except getopt.GetoptError as err: - # print help information and exit: - print(str(err)) # will print something like "option -a not recognized" - usage() - sys.exit(2) - - for o, a in opts: - if o == '-V': - QUIET = 10 - elif o == '-q': - QUIET = 0 - elif o == '-h': - usage() - sys.exit(0) - elif o == '-e': - conf['erase'] = 1 - elif o == '-w': - conf['write'] = 1 - elif o == '-v': - conf['verify'] = 1 - elif o == '-r': - conf['read'] = 1 - elif o == '-p': - conf['port'] = a - elif o == '-b': - conf['baud'] = eval(a) - elif o == '-a': - conf['address'] = eval(a) - elif o == '-l': - conf['len'] = eval(a) - else: - assert False, "unhandled option" - - # Try and find the port automatically - if conf['port'] == 'auto': - ports = [] - - # Get a list of all USB-like names in /dev - for name in ['tty.usbserial', 'ttyUSB']: - ports.extend(glob.glob('/dev/%s*' % name)) - - ports = sorted(ports) - - if ports: - # Found something - take it - conf['port'] = ports[0] - - cmd = CommandInterface() - cmd.open(conf['port'], conf['baud']) - mdebug(10, "Open port %(port)s, baud %(baud)d" % {'port':conf['port'], - 'baud':conf['baud']}) - try: - if (conf['write'] or conf['verify']): - mdebug(5, "Reading data from %s" % args[0]) - data = read(args[0]) - - try: - cmd.initChip() - except CmdException: - print("Can't init. Ensure BOOT0=1, BOOT1=0, and reset device") - - bootversion = cmd.cmdGet() - - mdebug(0, "Bootloader version 0x%X" % bootversion) - - if bootversion < 20 or bootversion >= 100: - raise Exception('Unreasonable bootloader version %d' % bootversion) - - chip_id = cmd.cmdGetID() - assert len(chip_id) == 2, "Unreasonable chip id: %s" % repr(chip_id) - chip_id_num = (ord(chip_id[0]) << 8) | ord(chip_id[1]) - chip_id_str = CHIP_ID_STRS.get(chip_id_num, None) - - if chip_id_str is None: - mdebug(0, 'Warning: unrecognised chip ID 0x%x' % chip_id_num) - else: - mdebug(0, "Chip id 0x%x, %s" % (chip_id_num, chip_id_str)) - - if conf['erase']: - # Pre-3.0 bootloaders use the erase memory - # command. Starting with 3.0, extended erase memory - # replaced this command. - if bootversion < 0x30: - cmd.cmdEraseMemory() - else: - cmd.cmdExtendedEraseMemory() - - if conf['write']: - cmd.writeMemory(conf['address'], data) - - if conf['verify']: - verify = cmd.readMemory(conf['address'], len(data)) - if(data == verify): - print("Verification OK") - else: - print("Verification FAILED") - print(str(len(data)) + ' vs ' + str(len(verify))) - for i in xrange(0, len(data)): - if data[i] != verify[i]: - print(hex(i) + ': ' + hex(data[i]) + ' vs ' + hex(verify[i])) - - if not conf['write'] and conf['read']: - rdata = cmd.readMemory(conf['address'], conf['len']) - file(args[0], 'wb').write(''.join(map(chr,rdata))) - - finally: - cmd.releaseChip() - diff --git a/GD32F1/variants/generic_gd32f103c/board.cpp b/GD32F1/variants/generic_gd32f103c/board.cpp deleted file mode 100644 index 7102adb..0000000 --- a/GD32F1/variants/generic_gd32f103c/board.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * &file wirish/boards/maple_mini/board.cpp - * &author Marti Bolivar - * &brief Maple Mini board file. - */ - -#include - -#include -#include - -/* Roger Clark. Added next to includes for changes to Serial */ -#include -#include - -#include -#include - -/* Since we want the Serial Wire/JTAG pins as GPIOs, disable both SW - * and JTAG debug support, unless configured otherwise. */ -void boardInit(void) { -#ifndef CONFIG_MAPLE_MINI_NO_DISABLE_DEBUG - disableDebugPorts(); -#endif -} - -// Note. See the enum of pin names in board.h - -extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { - - - {&gpioa, &timer2, &adc1, 0, 1, 0}, /* PA0 */ - {&gpioa, &timer2, &adc1, 1, 2, 1}, /* PA1 */ - {&gpioa, &timer2, &adc1, 2, 3, 2}, /* PA2 */ - {&gpioa, &timer2, &adc1, 3, 4, 3}, /* PA3 */ - {&gpioa, NULL, &adc1, 4, 0, 4}, /* PA4 */ - {&gpioa, NULL, &adc1, 5, 0, 5}, /* PA5 */ - {&gpioa, &timer3, &adc1, 6, 1, 6}, /* PA6 */ - {&gpioa, &timer3, &adc1, 7, 2, 7}, /* PA7 */ - {&gpioa, &timer1, NULL, 8, 1, ADCx}, /* PA8 */ - {&gpioa, &timer1, NULL, 9, 2, ADCx}, /* PA9 */ - {&gpioa, &timer1, NULL, 10, 3, ADCx}, /* PA10 */ - {&gpioa, &timer1, NULL, 11, 4, ADCx}, /* PA11 */ - {&gpioa, NULL, NULL, 12, 0, ADCx}, /* PA12 */ - {&gpioa, NULL, NULL, 13, 0, ADCx}, /* PA13 */ - {&gpioa, NULL, NULL, 14, 0, ADCx}, /* PA14 */ - {&gpioa, NULL, NULL, 15, 0, ADCx}, /* PA15 */ - - {&gpiob, &timer3, &adc1, 0, 3, 8}, /* PB0 */ - {&gpiob, &timer3, &adc1, 1, 4, 9}, /* PB1 */ - {&gpiob, NULL, NULL, 2, 0, ADCx}, /* PB2 */ - {&gpiob, NULL, NULL, 3, 0, ADCx}, /* PB3 */ - {&gpiob, NULL, NULL, 4, 0, ADCx}, /* PB4 */ - {&gpiob, NULL, NULL, 5, 0, ADCx}, /* PB5 */ - {&gpiob, &timer4, NULL, 6, 1, ADCx}, /* PB6 */ - {&gpiob, &timer4, NULL, 7, 2, ADCx}, /* PB7 */ - {&gpiob, &timer4, NULL, 8, 3, ADCx}, /* PB8 */ - {&gpiob, &timer4, NULL, 9, 4, ADCx}, /* PB9 */ - {&gpiob, NULL, NULL, 10, 0, ADCx}, /* PB10 */ - {&gpiob, NULL, NULL, 11, 0, ADCx}, /* PB11 */ - {&gpiob, NULL, NULL, 12, 0, ADCx}, /* PB12 */ - {&gpiob, NULL, NULL, 13, 0, ADCx}, /* PB13 */ - {&gpiob, NULL, NULL, 14, 0, ADCx}, /* PB14 */ - {&gpiob, NULL, NULL, 15, 0, ADCx}, /* PB15 */ - - {&gpioc, NULL, NULL, 13, 0, ADCx}, /* PC13 */ - {&gpioc, NULL, NULL, 14, 0, ADCx}, /* PC14 */ - {&gpioc, NULL, NULL, 15, 0, ADCx}, /* PC15 */ - - - -}; - -extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = { - PB0, PA7, PA6, PA3, PA2, PA1, PA0, PB7, PB6, PA10, PA9, PA8 -}; - -extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = { - PB0, PA7, PA6 , PA5 , PA4 , PA3 , PA2 , PA1 , PA0 -}; - -// Note. These defines are not really used by generic boards. They are for Maple Serial USB -#define USB_DP PA12 -#define USB_DM PA11 - -// NOte. These definitions are not really used for generic boards, they only relate to boards modified to behave like Maple boards -extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { - USB_DP, USB_DM -}; - - -/* - * Roger Clark - * - * 2015/05/28 - * - * Moved definitions for Hardware Serial devices from HardwareSerial.cpp so that each board can define which Arduino "Serial" instance - * Maps to which hardware serial port on the microprocessor - */ - -#ifdef SERIAL_USB - DEFINE_HWSERIAL(Serial1, 1); - - DEFINE_HWSERIAL(Serial2, 2); - - DEFINE_HWSERIAL(Serial3, 3); -#else - DEFINE_HWSERIAL(Serial, 1); - - DEFINE_HWSERIAL(Serial1, 2); - - DEFINE_HWSERIAL(Serial2, 3); -#endif diff --git a/GD32F1/variants/generic_gd32f103c/board/board.h b/GD32F1/variants/generic_gd32f103c/board/board.h deleted file mode 100644 index 9e6f8ea..0000000 --- a/GD32F1/variants/generic_gd32f103c/board/board.h +++ /dev/null @@ -1,83 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/boards/maple_mini/include/board/board.h - * @author Marti Bolivar - * @brief Maple Mini board header. - * - * See wirish/boards/maple/include/board/board.h for more information - * on these definitions. - */ - -#ifndef _BOARD_GENERIC_STM32F103C_H_ -#define _BOARD_GENERIC_STM32F103C_H_ - -#define CYCLES_PER_MICROSECOND 120 -#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */ - -#define BOARD_NR_USARTS 3 -#define BOARD_USART1_TX_PIN PA9 -#define BOARD_USART1_RX_PIN PA10 -#define BOARD_USART2_TX_PIN PA2 -#define BOARD_USART2_RX_PIN PA3 -#define BOARD_USART3_TX_PIN PB10 -#define BOARD_USART3_RX_PIN PB11 - -#define BOARD_NR_SPI 2 -#define BOARD_SPI1_NSS_PIN PA4 -#define BOARD_SPI1_MOSI_PIN PA7 -#define BOARD_SPI1_MISO_PIN PA6 -#define BOARD_SPI1_SCK_PIN PA5 - -#define BOARD_SPI2_NSS_PIN PB12 -#define BOARD_SPI2_MOSI_PIN PB15 -#define BOARD_SPI2_MISO_PIN PB14 -#define BOARD_SPI2_SCK_PIN PB13 - -#define BOARD_NR_GPIO_PINS 35 -#define BOARD_NR_PWM_PINS 12 -#define BOARD_NR_ADC_PINS 9 -#define BOARD_NR_USED_PINS 4 - - -#define BOARD_JTMS_SWDIO_PIN 22 -#define BOARD_JTCK_SWCLK_PIN 21 -#define BOARD_JTDI_PIN 20 -#define BOARD_JTDO_PIN 19 -#define BOARD_NJTRST_PIN 18 - -#define BOARD_USB_DISC_DEV GPIOB -#define BOARD_USB_DISC_BIT 10 - -// Note this needs to match with the PIN_MAP array in board.cpp -enum { - PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13,PA14,PA15, - PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13,PB14,PB15, - PC13, PC14,PC15 -}; - -#endif diff --git a/GD32F1/variants/generic_gd32f103c/ld/bootloader_20.ld b/GD32F1/variants/generic_gd32f103c/ld/bootloader_20.ld deleted file mode 100644 index 4de3a08..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/bootloader_20.ld +++ /dev/null @@ -1,30 +0,0 @@ -/* - * libmaple linker script for "Flash" builds. - * - * A Flash build puts .text (and .rodata) in Flash, and - * .data/.bss/heap (of course) in SRAM, but offsets the sections by - * enough space to store the Maple bootloader, which lives in low - * Flash and uses low memory. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K - rom (rx) : ORIGIN = 0x08002000, LENGTH = 120K -} - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/variants/generic_gd32f103c/ld/common.inc b/GD32F1/variants/generic_gd32f103c/ld/common.inc deleted file mode 100644 index 0c2b6a4..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/common.inc +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Linker script for libmaple. - * - * Original author "lanchon" from ST forums, with modifications by LeafLabs. - */ - -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") - -/* - * Configure other libraries we want in the link. - * - * libgcc, libc, and libm are common across supported toolchains. - * However, some toolchains require additional archives which aren't - * present everywhere (e.g. ARM's gcc-arm-embedded releases). - * - * To hack around this, we let the build system specify additional - * archives by putting the right extra_libs.inc (in a directory under - * toolchains/) in our search path. - */ -GROUP(libgcc.a libc.a libm.a) -INCLUDE extra_libs.inc - -/* - * These force the linker to search for vector table symbols. - * - * These symbols vary by STM32 family (and also within families). - * It's up to the build system to configure the link's search path - * properly for the target MCU. - */ -INCLUDE vector_symbols.inc - -/* STM32 vector table. */ -EXTERN(__stm32_vector_table) - -/* C runtime initialization function. */ -EXTERN(start_c) - -/* main entry point */ -EXTERN(main) - -/* Initial stack pointer value. */ -EXTERN(__msp_init) -PROVIDE(__msp_init = ORIGIN(ram) + LENGTH(ram)); - -/* Reset vector and chip reset entry point */ -EXTERN(__start__) -ENTRY(__start__) -PROVIDE(__exc_reset = __start__); - -/* Heap boundaries, for libmaple */ -EXTERN(_lm_heap_start); -EXTERN(_lm_heap_end); - -SECTIONS -{ - .text : - { - __text_start__ = .; - /* - * STM32 vector table. Leave this here. Yes, really. - */ - *(.stm32.interrupt_vector) - - /* - * Program code and vague linking - */ - *(.text .text.* .gnu.linkonce.t.*) - *(.plt) - *(.gnu.warning) - *(.glue_7t) *(.glue_7) *(.vfp11_veneer) - - *(.ARM.extab* .gnu.linkonce.armextab.*) - *(.gcc_except_table) - *(.eh_frame_hdr) - *(.eh_frame) - - . = ALIGN(4); - KEEP(*(.init)) - - . = ALIGN(4); - __preinit_array_start = .; - KEEP (*(.preinit_array)) - __preinit_array_end = .; - - . = ALIGN(4); - __init_array_start = .; - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array)) - __init_array_end = .; - - . = ALIGN(0x4); - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*crtend.o(.ctors)) - - . = ALIGN(4); - KEEP(*(.fini)) - - . = ALIGN(4); - __fini_array_start = .; - KEEP (*(.fini_array)) - KEEP (*(SORT(.fini_array.*))) - __fini_array_end = .; - - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*crtend.o(.dtors)) - } > REGION_TEXT - - /* - * End of text - */ - .text.align : - { - . = ALIGN(8); - __text_end__ = .; - } > REGION_TEXT - - /* - * .ARM.exidx exception unwinding; mandated by ARM's C++ ABI - */ - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > REGION_RODATA - __exidx_end = .; - - /* - * .data - */ - .data : - { - __data_start__ = .; - LONG(0) - . = ALIGN(8); - - *(.got.plt) *(.got) - *(.data .data.* .gnu.linkonce.d.*) - - . = ALIGN(8); - __data_end__ = .; - } > REGION_DATA AT> REGION_RODATA - - /* - * Read-only data - */ - .rodata : - { - *(.rodata .rodata.* .gnu.linkonce.r.*) - /* .USER_FLASH: We allow users to allocate into Flash here */ - *(.USER_FLASH) - /* ROM image configuration; for C startup */ - . = ALIGN(4); - _lm_rom_img_cfgp = .; - LONG(LOADADDR(.data)); - /* - * Heap: Linker scripts may choose a custom heap by overriding - * _lm_heap_start and _lm_heap_end. Otherwise, the heap is in - * internal SRAM, beginning after .bss, and growing towards - * the stack. - * - * I'm shoving these here naively; there's probably a cleaner way - * to go about this. [mbolivar] - */ - _lm_heap_start = DEFINED(_lm_heap_start) ? _lm_heap_start : _end; - _lm_heap_end = DEFINED(_lm_heap_end) ? _lm_heap_end : __msp_init; - } > REGION_RODATA - - /* - * .bss - */ - .bss : - { - . = ALIGN(8); - __bss_start__ = .; - *(.bss .bss.* .gnu.linkonce.b.*) - *(COMMON) - . = ALIGN (8); - __bss_end__ = .; - _end = __bss_end__; - } > REGION_BSS - - /* - * Debugging sections - */ - .stab 0 (NOLOAD) : { *(.stab) } - .stabstr 0 (NOLOAD) : { *(.stabstr) } - /* DWARF debug sections. - * Symbols in the DWARF debugging sections are relative to the beginning - * of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - - .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } - .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) } - /DISCARD/ : { *(.note.GNU-stack) } -} diff --git a/GD32F1/variants/generic_gd32f103c/ld/extra_libs.inc b/GD32F1/variants/generic_gd32f103c/ld/extra_libs.inc deleted file mode 100644 index 4413a53..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/extra_libs.inc +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Extra archives needed by ARM's GCC ARM Embedded arm-none-eabi- - * releases (https://launchpad.net/gcc-arm-embedded/). - */ - -/* This is for the provided newlib. */ -GROUP(libnosys.a) diff --git a/GD32F1/variants/generic_gd32f103c/ld/flash.ld b/GD32F1/variants/generic_gd32f103c/ld/flash.ld deleted file mode 100644 index 38a3023..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/flash.ld +++ /dev/null @@ -1,26 +0,0 @@ -/* - * libmaple linker script for "Flash" builds. - * - * A Flash build puts .text (and .rodata) in Flash, and - * .data/.bss/heap (of course) in SRAM, but offsets the sections by - * enough space to store the Maple bootloader, which lives in low - * Flash and uses low memory. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -INCLUDE mem-flash.inc - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/variants/generic_gd32f103c/ld/flash_c8.ld b/GD32F1/variants/generic_gd32f103c/ld/flash_c8.ld deleted file mode 100644 index 2a35550..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/flash_c8.ld +++ /dev/null @@ -1,33 +0,0 @@ -/* - * libmaple linker script for "Flash" builds. - * - * A Flash build puts .text (and .rodata) in Flash, and - * .data/.bss/heap (of course) in SRAM, but offsets the sections by - * enough space to store the Maple bootloader, which lives in low - * Flash and uses low memory. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -/*INCLUDE mem-flash.inc*/ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 44K -} - - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/variants/generic_gd32f103c/ld/jtag.ld b/GD32F1/variants/generic_gd32f103c/ld/jtag.ld deleted file mode 100644 index 62ae052..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/jtag.ld +++ /dev/null @@ -1,31 +0,0 @@ -/* - * libmaple linker script for "JTAG" builds. - * - * A "JTAG" build puts .text (and .rodata) in Flash, and - * .data/.bss/heap (of course) in SRAM, but links starting at the - * Flash and SRAM starting addresses (0x08000000 and 0x20000000 - * respectively). This will wipe out a Maple bootloader if there's one - * on the board, so only use this if you know what you're doing. - * - * Of course, a "JTAG" build is perfectly usable for upload over SWD, - * the system memory bootloader, etc. The name is just a historical - * artifact. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -INCLUDE mem-jtag.inc - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/variants/generic_gd32f103c/ld/jtag_c8.ld b/GD32F1/variants/generic_gd32f103c/ld/jtag_c8.ld deleted file mode 100644 index 2e01979..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/jtag_c8.ld +++ /dev/null @@ -1,36 +0,0 @@ -/* - * libmaple linker script for "JTAG" builds. - * - * A "JTAG" build puts .text (and .rodata) in Flash, and - * .data/.bss/heap (of course) in SRAM, but links starting at the - * Flash and SRAM starting addresses (0x08000000 and 0x20000000 - * respectively). This will wipe out a Maple bootloader if there's one - * on the board, so only use this if you know what you're doing. - * - * Of course, a "JTAG" build is perfectly usable for upload over SWD, - * the system memory bootloader, etc. The name is just a historical - * artifact. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ - -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K -} - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", rom); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", rom); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/variants/generic_gd32f103c/ld/mem-flash.inc b/GD32F1/variants/generic_gd32f103c/ld/mem-flash.inc deleted file mode 100644 index fe97698..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/mem-flash.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K -} diff --git a/GD32F1/variants/generic_gd32f103c/ld/mem-jtag.inc b/GD32F1/variants/generic_gd32f103c/ld/mem-jtag.inc deleted file mode 100644 index 3db0940..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/mem-jtag.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K - rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K -} diff --git a/GD32F1/variants/generic_gd32f103c/ld/mem-ram.inc b/GD32F1/variants/generic_gd32f103c/ld/mem-ram.inc deleted file mode 100644 index dc6d329..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/mem-ram.inc +++ /dev/null @@ -1,5 +0,0 @@ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K -} diff --git a/GD32F1/variants/generic_gd32f103c/ld/ram.ld b/GD32F1/variants/generic_gd32f103c/ld/ram.ld deleted file mode 100644 index 1ea7598..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/ram.ld +++ /dev/null @@ -1,25 +0,0 @@ -/* - * libmaple linker script for RAM builds. - * - * A Flash build puts .text, .rodata, and .data/.bss/heap (of course) - * in SRAM, but offsets the sections by enough space to store the - * Maple bootloader, which uses low memory. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -INCLUDE mem-ram.inc - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", ram); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", ram); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/variants/generic_gd32f103c/ld/ram_c8.ld b/GD32F1/variants/generic_gd32f103c/ld/ram_c8.ld deleted file mode 100644 index 9f9f6bb..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/ram_c8.ld +++ /dev/null @@ -1,31 +0,0 @@ -/* - * libmaple linker script for RAM builds. - * - * A Flash build puts .text, .rodata, and .data/.bss/heap (of course) - * in SRAM, but offsets the sections by enough space to store the - * Maple bootloader, which uses low memory. - */ - -/* - * This pulls in the appropriate MEMORY declaration from the right - * subdirectory of stm32/mem/ (the environment must call ld with the - * right include directory flags to make this happen). Boards can also - * use this file to use any of libmaple's memory-related hooks (like - * where the heap should live). - */ -/*INCLUDE mem-ram.inc*/ -MEMORY -{ - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 0 -} - - -/* Provide memory region aliases for common.inc */ -REGION_ALIAS("REGION_TEXT", ram); -REGION_ALIAS("REGION_DATA", ram); -REGION_ALIAS("REGION_BSS", ram); -REGION_ALIAS("REGION_RODATA", ram); - -/* Let common.inc handle the real work. */ -INCLUDE common.inc diff --git a/GD32F1/variants/generic_gd32f103c/ld/vector_symbols.inc b/GD32F1/variants/generic_gd32f103c/ld/vector_symbols.inc deleted file mode 100644 index a40012a..0000000 --- a/GD32F1/variants/generic_gd32f103c/ld/vector_symbols.inc +++ /dev/null @@ -1,78 +0,0 @@ -EXTERN(__msp_init) -EXTERN(__exc_reset) -EXTERN(__exc_nmi) -EXTERN(__exc_hardfault) -EXTERN(__exc_memmanage) -EXTERN(__exc_busfault) -EXTERN(__exc_usagefault) -EXTERN(__stm32reservedexception7) -EXTERN(__stm32reservedexception8) -EXTERN(__stm32reservedexception9) -EXTERN(__stm32reservedexception10) -EXTERN(__exc_svc) -EXTERN(__exc_debug_monitor) -EXTERN(__stm32reservedexception13) -EXTERN(__exc_pendsv) -EXTERN(__exc_systick) - -EXTERN(__irq_wwdg) -EXTERN(__irq_pvd) -EXTERN(__irq_tamper) -EXTERN(__irq_rtc) -EXTERN(__irq_flash) -EXTERN(__irq_rcc) -EXTERN(__irq_exti0) -EXTERN(__irq_exti1) -EXTERN(__irq_exti2) -EXTERN(__irq_exti3) -EXTERN(__irq_exti4) -EXTERN(__irq_dma1_channel1) -EXTERN(__irq_dma1_channel2) -EXTERN(__irq_dma1_channel3) -EXTERN(__irq_dma1_channel4) -EXTERN(__irq_dma1_channel5) -EXTERN(__irq_dma1_channel6) -EXTERN(__irq_dma1_channel7) -EXTERN(__irq_adc) -EXTERN(__irq_usb_hp_can_tx) -EXTERN(__irq_usb_lp_can_rx0) -EXTERN(__irq_can_rx1) -EXTERN(__irq_can_sce) -EXTERN(__irq_exti9_5) -EXTERN(__irq_tim1_brk) -EXTERN(__irq_tim1_up) -EXTERN(__irq_tim1_trg_com) -EXTERN(__irq_tim1_cc) -EXTERN(__irq_tim2) -EXTERN(__irq_tim3) -EXTERN(__irq_tim4) -EXTERN(__irq_i2c1_ev) -EXTERN(__irq_i2c1_er) -EXTERN(__irq_i2c2_ev) -EXTERN(__irq_i2c2_er) -EXTERN(__irq_spi1) -EXTERN(__irq_spi2) -EXTERN(__irq_usart1) -EXTERN(__irq_usart2) -EXTERN(__irq_usart3) -EXTERN(__irq_exti15_10) -EXTERN(__irq_rtcalarm) -EXTERN(__irq_usbwakeup) - -EXTERN(__irq_tim8_brk) -EXTERN(__irq_tim8_up) -EXTERN(__irq_tim8_trg_com) -EXTERN(__irq_tim8_cc) -EXTERN(__irq_adc3) -EXTERN(__irq_fsmc) -EXTERN(__irq_sdio) -EXTERN(__irq_tim5) -EXTERN(__irq_spi3) -EXTERN(__irq_uart4) -EXTERN(__irq_uart5) -EXTERN(__irq_tim6) -EXTERN(__irq_tim7) -EXTERN(__irq_dma2_channel1) -EXTERN(__irq_dma2_channel2) -EXTERN(__irq_dma2_channel3) -EXTERN(__irq_dma2_channel4_5) diff --git a/GD32F1/variants/generic_gd32f103c/pins_arduino.h b/GD32F1/variants/generic_gd32f103c/pins_arduino.h deleted file mode 100644 index d7518e6..0000000 --- a/GD32F1/variants/generic_gd32f103c/pins_arduino.h +++ /dev/null @@ -1,6 +0,0 @@ - - - - -// API compatibility -#include "variant.h" \ No newline at end of file diff --git a/GD32F1/variants/generic_gd32f103c/variant.h b/GD32F1/variants/generic_gd32f103c/variant.h deleted file mode 100644 index 970dd96..0000000 --- a/GD32F1/variants/generic_gd32f103c/variant.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _VARIANT_ARDUINO_STM32_ -#define _VARIANT_ARDUINO_STM32_ - -#define digitalPinToPort(P) ( PIN_MAP[P].gpio_device ) -#define digitalPinToBitMask(P) ( BIT(PIN_MAP[P].gpio_bit) ) -#define portOutputRegister(port) ( &(port->regs->ODR) ) -#define portInputRegister(port) ( &(port->regs->IDR) ) - -#define portSetRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->BSRR) ) -#define portClearRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->BRR) ) - -#define portConfigRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->CRL) ) - -#endif /* _VARIANT_ARDUINO_STM32_ */ \ No newline at end of file diff --git a/GD32F1/variants/generic_gd32f103c/wirish/boards.cpp b/GD32F1/variants/generic_gd32f103c/wirish/boards.cpp deleted file mode 100644 index 0c018e8..0000000 --- a/GD32F1/variants/generic_gd32f103c/wirish/boards.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/boards.cpp - * @brief init() and board routines. - * - * This file is mostly interesting for the init() function, which - * configures Flash, the core clocks, and a variety of other available - * peripherals on the board so the rest of Wirish doesn't have to turn - * things on before using them. - * - * Prior to returning, init() calls boardInit(), which allows boards - * to perform any initialization they need to. This file includes a - * weak no-op definition of boardInit(), so boards that don't need any - * special initialization don't have to define their own. - * - * How init() works is chip-specific. See the boards_setup.cpp files - * under e.g. wirish/stm32f1/, wirish/stmf32f2 for the details, but be - * advised: their contents are unstable, and can/will change without - * notice. - */ - -#include -#include -#include -#include -#include -#include "boards_private.h" - -static void setup_flash(void); -static void setup_clocks(void); -static void setup_nvic(void); -static void setup_adcs(void); -static void setup_timers(void); - -/* - * Exported functions - */ - -void init(void) { - setup_flash(); - setup_clocks(); - setup_nvic(); - systick_init(SYSTICK_RELOAD_VAL); - wirish::priv::board_setup_gpio(); - setup_adcs(); - setup_timers(); - wirish::priv::board_setup_usb(); - wirish::priv::series_init(); - boardInit(); -} - -/* Provide a default no-op boardInit(). */ -__weak void boardInit(void) { -} - -/* You could farm this out to the files in boards/ if e.g. it takes - * too long to test on boards with lots of pins. */ -bool boardUsesPin(uint8 pin) { - for (int i = 0; i < BOARD_NR_USED_PINS; i++) { - if (pin == boardUsedPins[i]) { - return true; - } - } - return false; -} - -/* - * Auxiliary routines - */ - -static void setup_flash(void) { - // Turn on as many Flash "go faster" features as - // possible. flash_enable_features() just ignores any flags it - // can't support. - flash_enable_features(FLASH_PREFETCH | FLASH_ICACHE | FLASH_DCACHE); - // Configure the wait states, assuming we're operating at "close - // enough" to 3.3V. - flash_set_latency(FLASH_SAFE_WAIT_STATES); -} - -static void setup_clocks(void) { - // Turn on HSI. We'll switch to and run off of this while we're - // setting up the main PLL. - rcc_turn_on_clk(RCC_CLK_HSI); - - // Turn off and reset the clock subsystems we'll be using, as well - // as the clock security subsystem (CSS). Note that resetting CFGR - // to its default value of 0 implies a switch to HSI for SYSCLK. - RCC_BASE->CFGR = 0x00000000; - rcc_disable_css(); - rcc_turn_off_clk(RCC_CLK_PLL); - rcc_turn_off_clk(RCC_CLK_HSE); - wirish::priv::board_reset_pll(); - // Clear clock readiness interrupt flags and turn off clock - // readiness interrupts. - RCC_BASE->CIR = 0x00000000; - - // Enable HSE, and wait until it's ready. - rcc_turn_on_clk(RCC_CLK_HSE); - while (!rcc_is_clk_ready(RCC_CLK_HSE)) - ; - - // Configure AHBx, APBx, etc. prescalers and the main PLL. - wirish::priv::board_setup_clock_prescalers(); - rcc_configure_pll(&wirish::priv::w_board_pll_cfg); - - // Enable the PLL, and wait until it's ready. - rcc_turn_on_clk(RCC_CLK_PLL); - while(!rcc_is_clk_ready(RCC_CLK_PLL)) - ; - - // Finally, switch to the now-ready PLL as the main clock source. - rcc_switch_sysclk(RCC_CLKSRC_PLL); -} - -/* - * These addresses are where usercode starts when a bootloader is - * present. If no bootloader is present, the user NVIC usually starts - * at the Flash base address, 0x08000000. - */ -#if defined(BOOTLOADER_maple) - #define USER_ADDR_ROM 0x08005000 -#else - #if defined(BOOTLOADER_robotis) - #define USER_ADDR_ROM 0x08003000 - #else - #define USER_ADDR_ROM 0x08000000 - #endif -#endif -#define USER_ADDR_RAM 0x20000C00 -extern char __text_start__; - -static void setup_nvic(void) { - -nvic_init((uint32)VECT_TAB_ADDR, 0); - -/* Roger Clark. We now control nvic vector table in boards.txt using the build.vect paramater -#ifdef VECT_TAB_FLASH - nvic_init(USER_ADDR_ROM, 0); -#elif defined VECT_TAB_RAM - nvic_init(USER_ADDR_RAM, 0); -#elif defined VECT_TAB_BASE - nvic_init((uint32)0x08000000, 0); -#elif defined VECT_TAB_ADDR - // A numerically supplied value - nvic_init((uint32)VECT_TAB_ADDR, 0); -#else - // Use the __text_start__ value from the linker script; this - // should be the start of the vector table. - nvic_init((uint32)&__text_start__, 0); -#endif - -*/ -} - -static void adc_default_config(const adc_dev *dev) { - adc_enable_single_swstart(dev); - adc_set_sample_rate(dev, wirish::priv::w_adc_smp); -} - -static void setup_adcs(void) { - adc_set_prescaler(wirish::priv::w_adc_pre); - adc_foreach(adc_default_config); -} - -static void timer_default_config(timer_dev *dev) { - timer_adv_reg_map *regs = (dev->regs).adv; - const uint16 full_overflow = 0xFFFF; - const uint16 half_duty = 0x8FFF; - - timer_init(dev); - timer_pause(dev); - - regs->CR1 = TIMER_CR1_ARPE; - regs->PSC = 1; - regs->SR = 0; - regs->DIER = 0; - regs->EGR = TIMER_EGR_UG; - switch (dev->type) { - case TIMER_ADVANCED: - regs->BDTR = TIMER_BDTR_MOE | TIMER_BDTR_LOCK_OFF; - // fall-through - case TIMER_GENERAL: - timer_set_reload(dev, full_overflow); - for (uint8 channel = 1; channel <= 4; channel++) { - if (timer_has_cc_channel(dev, channel)) { - timer_set_compare(dev, channel, half_duty); - timer_oc_set_mode(dev, channel, TIMER_OC_MODE_PWM_1, - TIMER_OC_PE); - } - } - // fall-through - case TIMER_BASIC: - break; - } - - timer_generate_update(dev); - timer_resume(dev); -} - -static void setup_timers(void) { - timer_foreach(timer_default_config); -} diff --git a/GD32F1/variants/generic_gd32f103c/wirish/boards_setup.cpp b/GD32F1/variants/generic_gd32f103c/wirish/boards_setup.cpp deleted file mode 100644 index c23cff0..0000000 --- a/GD32F1/variants/generic_gd32f103c/wirish/boards_setup.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*****************************************************************************/ - -/** - * @file wirish/stm32f1/boards_setup.cpp - * @author Marti Bolivar - * @brief STM32F1 chip setup. - * - * This file controls how init() behaves on the STM32F1. Be very - * careful when changing anything here. Many of these values depend - * upon each other. - */ - -#include "boards_private.h" - -#include -#include - -#include -#include - -// Allow boards to provide a PLL multiplier. This is useful for -// e.g. STM32F100 value line MCUs, which use slower multipliers. -// (We're leaving the default to RCC_PLLMUL_9 for now, since that -// works for F103 performance line MCUs, which is all that LeafLabs -// currently officially supports). -#ifndef BOARD_RCC_PLLMUL -#if F_CPU==120000000 - #define BOARD_RCC_PLLMUL RCC_PLLMUL_10 -#elif F_CPU==96000000 - #define BOARD_RCC_PLLMUL RCC_PLLMUL_8 -#elif F_CPU==72000000 - #define BOARD_RCC_PLLMUL RCC_PLLMUL_6 - -// TEST FOR STM32 #define BOARD_RCC_PLLMUL RCC_PLLMUL_9 - - -#endif - -//#define BOARD_RCC_PLLMUL RCC_PLLMUL_6 -#endif - -namespace wirish { - namespace priv { - - static stm32f1_rcc_pll_data pll_data = {BOARD_RCC_PLLMUL}; - __weak rcc_pll_cfg w_board_pll_cfg = {RCC_PLLSRC_HSE, &pll_data}; - __weak adc_prescaler w_adc_pre = ADC_PRE_PCLK2_DIV_6; - __weak adc_smp_rate w_adc_smp = ADC_SMPR_55_5; - - __weak void board_reset_pll(void) { - // TODO - } - - __weak void board_setup_clock_prescalers(void) { - rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1); - rcc_set_prescaler(RCC_PRESCALER_APB1, RCC_APB1_HCLK_DIV_2); - rcc_set_prescaler(RCC_PRESCALER_APB2, RCC_APB2_HCLK_DIV_1); - rcc_clk_disable(RCC_USB); - #if F_CPU == 120000000 - rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_2_5); - #elif F_CPU == 96000000 - rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_2); - #elif F_CPU == 72000000 - rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5); - #elif F_CPU == 48000000 - rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5); - #endif - } - - __weak void board_setup_gpio(void) { - gpio_init_all(); - } - - __weak void board_setup_usb(void) { -#ifdef SERIAL_USB - -#ifdef GENERIC_BOOTLOADER -#define USB_RST_PIN PA12 - - //Reset the USB interface on generic boards - developed by Victor PV - gpio_set_mode(PIN_MAP[USB_RST_PIN].gpio_device, PIN_MAP[USB_RST_PIN].gpio_bit, GPIO_OUTPUT_PP); - gpio_write_bit(PIN_MAP[USB_RST_PIN].gpio_device, PIN_MAP[USB_RST_PIN].gpio_bit,0); - - for(volatile unsigned int i=0;i<512;i++);// Only small delay seems to be needed, and USB pins will get configured in Serial.begin - gpio_set_mode(PIN_MAP[USB_RST_PIN].gpio_device, PIN_MAP[USB_RST_PIN].gpio_bit, GPIO_INPUT_FLOATING); -#endif - Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility -#endif - } - - __weak void series_init(void) { - // Initialize AFIO here, too, so peripheral remaps and external - // interrupts work out of the box. - afio_init(); - } - - } -} diff --git a/GD32F1/variants/generic_gd32f103c/wirish/start.S b/GD32F1/variants/generic_gd32f103c/wirish/start.S deleted file mode 100644 index a04f222..0000000 --- a/GD32F1/variants/generic_gd32f103c/wirish/start.S +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* - * This file is a modified version of a file obtained from - * CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the - * following text appeared: - * - * The authors hereby grant permission to use, copy, modify, distribute, - * and license this software and its documentation for any purpose, provided - * that existing copyright notices are retained in all copies and that this - * notice is included verbatim in any distributions. No written agreement, - * license, or royalty fee is required for any of the authorized uses. - * Modifications to this software may be copyrighted by their authors - * and need not follow the licensing terms described here, provided that - * the new terms are clearly indicated on the first page of each file where - * they apply. - */ - - .text - .code 16 - .thumb_func - - .globl __start__ - .type __start__, %function -__start__: - .fnstart - ldr r1,=__msp_init - mov sp,r1 - ldr r1,=start_c - bx r1 - .pool - .cantunwind - .fnend diff --git a/GD32F1/variants/generic_gd32f103c/wirish/start_c.c b/GD32F1/variants/generic_gd32f103c/wirish/start_c.c deleted file mode 100644 index 05df060..0000000 --- a/GD32F1/variants/generic_gd32f103c/wirish/start_c.c +++ /dev/null @@ -1,95 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/* - * This file is a modified version of a file obtained from - * CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the - * following text appeared: - * - * Copyright (c) 2006, 2007 CodeSourcery Inc - * - * The authors hereby grant permission to use, copy, modify, distribute, - * and license this software and its documentation for any purpose, provided - * that existing copyright notices are retained in all copies and that this - * notice is included verbatim in any distributions. No written agreement, - * license, or royalty fee is required for any of the authorized uses. - * Modifications to this software may be copyrighted by their authors - * and need not follow the licensing terms described here, provided that - * the new terms are clearly indicated on the first page of each file where - * they apply. - */ - -#include - -extern void __libc_init_array(void); - -extern int main(int, char**, char**); - -extern void exit(int) __attribute__((noreturn, weak)); - -/* The linker must ensure that these are at least 4-byte aligned. */ -extern char __data_start__, __data_end__; -extern char __bss_start__, __bss_end__; - -struct rom_img_cfg { - int *img_start; -}; - -extern char _lm_rom_img_cfgp; - -void __attribute__((noreturn)) start_c(void) { - struct rom_img_cfg *img_cfg = (struct rom_img_cfg*)&_lm_rom_img_cfgp; - int *src = img_cfg->img_start; - int *dst = (int*)&__data_start__; - int exit_code; - - /* Initialize .data, if necessary. */ - if (src != dst) { - int *end = (int*)&__data_end__; - while (dst < end) { - *dst++ = *src++; - } - } - - /* Zero .bss. */ - dst = (int*)&__bss_start__; - while (dst < (int*)&__bss_end__) { - *dst++ = 0; - } - - /* Run initializers. */ - __libc_init_array(); - - /* Jump to main. */ - exit_code = main(0, 0, 0); - if (exit) { - exit(exit_code); - } - - /* If exit is NULL, make sure we don't return. */ - for (;;) - continue; -} diff --git a/GD32F1/variants/generic_gd32f103c/wirish/syscalls.c b/GD32F1/variants/generic_gd32f103c/wirish/syscalls.c deleted file mode 100644 index d42536c..0000000 --- a/GD32F1/variants/generic_gd32f103c/wirish/syscalls.c +++ /dev/null @@ -1,176 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * Copyright (c) 2011, 2012 LeafLabs, LLC. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - *****************************************************************************/ - -/** - * @file wirish/syscalls.c - * @brief newlib stubs - * - * Low level system routines used by newlib for basic I/O and memory - * allocation. You can override most of these. - */ - -#include - -#include -#include -#include - -/* If CONFIG_HEAP_START (or CONFIG_HEAP_END) isn't defined, then - * assume _lm_heap_start (resp. _lm_heap_end) is appropriately set by - * the linker */ -#ifndef CONFIG_HEAP_START -extern char _lm_heap_start; -#define CONFIG_HEAP_START ((void *)&_lm_heap_start) -#endif -#ifndef CONFIG_HEAP_END -extern char _lm_heap_end; -#define CONFIG_HEAP_END ((void *)&_lm_heap_end) -#endif - -/* - * _sbrk -- Increment the program break. - * - * Get incr bytes more RAM (for use by the heap). malloc() and - * friends call this function behind the scenes. - */ -void *_sbrk(int incr) { - static void * pbreak = NULL; /* current program break */ - void * ret; - - if (pbreak == NULL) { - pbreak = CONFIG_HEAP_START; - } - - if ((CONFIG_HEAP_END - pbreak < incr) || - (pbreak - CONFIG_HEAP_START < -incr)) { - errno = ENOMEM; - return (void *)-1; - } - - ret = pbreak; - pbreak += incr; - return ret; -} - -__weak int _open(const char *path, int flags, ...) { - return 1; -} - -__weak int _close(int fd) { - return 0; -} - -__weak int _fstat(int fd, struct stat *st) { - st->st_mode = S_IFCHR; - return 0; -} - -__weak int _isatty(int fd) { - return 1; -} - -__weak int isatty(int fd) { - return 1; -} - -__weak int _lseek(int fd, off_t pos, int whence) { - return -1; -} - -__weak unsigned char getch(void) { - return 0; -} - - -__weak int _read(int fd, char *buf, size_t cnt) { - *buf = getch(); - - return 1; -} - -__weak void putch(unsigned char c) { -} - -__weak void cgets(char *s, int bufsize) { - char *p; - int c; - int i; - - for (i = 0; i < bufsize; i++) { - *(s+i) = 0; - } -// memset(s, 0, bufsize); - - p = s; - - for (p = s; p < s + bufsize-1;) { - c = getch(); - switch (c) { - case '\r' : - case '\n' : - putch('\r'); - putch('\n'); - *p = '\n'; - return; - - case '\b' : - if (p > s) { - *p-- = 0; - putch('\b'); - putch(' '); - putch('\b'); - } - break; - - default : - putch(c); - *p++ = c; - break; - } - } - return; -} - -__weak int _write(int fd, const char *buf, size_t cnt) { - int i; - - for (i = 0; i < cnt; i++) - putch(buf[i]); - - return cnt; -} - -/* Override fgets() in newlib with a version that does line editing */ -__weak char *fgets(char *s, int bufsize, void *f) { - cgets(s, bufsize); - return s; -} - -__weak void _exit(int exitcode) { - while (1) - ; -} diff --git a/STM32duino-bootloader b/STM32duino-bootloader deleted file mode 160000 index f883a67..0000000 --- a/STM32duino-bootloader +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f883a676c42e2c264e00021173e7bbbf82772f95