├── .github └── FUNDING.yml ├── README.md ├── boards.txt ├── cores └── opencpu │ ├── Arduino.h │ ├── Client.h │ ├── DEV.cpp │ ├── DEV.h │ ├── HardwareSerial.cpp │ ├── HardwareSerial.h │ ├── IPAddress.cpp │ ├── IPAddress.h │ ├── PSM.cpp │ ├── PSM.h │ ├── Print.cpp │ ├── Print.h │ ├── Printable.h │ ├── RTC.cpp │ ├── RTC.h │ ├── RingBuffer.h │ ├── Server.h │ ├── Stream.cpp │ ├── Stream.h │ ├── Tone.h │ ├── Udp.h │ ├── WCharacter.h │ ├── WMath.cpp │ ├── WProgram.h │ ├── WString.cpp │ ├── WString.h │ ├── api │ ├── apI_lwm2m.h │ ├── api.h │ ├── api_fota.h │ ├── api_hal.h │ ├── api_http.h │ ├── api_json.h │ ├── api_mqtt.h │ ├── api_net.c │ ├── api_nvdm.h │ ├── api_ping.h │ ├── api_ril.h │ ├── api_ssl.h │ ├── api_tel.h │ ├── arch │ │ ├── bpstruct.h │ │ ├── cc.h │ │ ├── epstruct.h │ │ ├── perf.h │ │ └── sys_arch.h │ ├── cJson.c │ ├── freertos │ │ ├── FreeRTOS.h │ │ ├── FreeRTOSConfig.h │ │ ├── StackMacros.h │ │ ├── croutine.h │ │ ├── deprecated_definitions.h │ │ ├── event_groups.h │ │ ├── list.h │ │ ├── mpu_wrappers.h │ │ ├── portable.h │ │ ├── portmacro.h │ │ ├── projdefs.h │ │ ├── queue.h │ │ ├── semphr.h │ │ ├── task.h │ │ └── timers.h │ ├── lwip │ │ ├── api.h │ │ ├── api_msg.h │ │ ├── arch.h │ │ ├── autoip.h │ │ ├── debug.h │ │ ├── def.h │ │ ├── dhcp.h │ │ ├── dhcp6.h │ │ ├── dns.h │ │ ├── err.h │ │ ├── ethip6.h │ │ ├── icmp.h │ │ ├── icmp6.h │ │ ├── igmp.h │ │ ├── inet.h │ │ ├── inet_chksum.h │ │ ├── init.h │ │ ├── ip.h │ │ ├── ip4.h │ │ ├── ip4_addr.h │ │ ├── ip6.h │ │ ├── ip6_addr.h │ │ ├── ip6_frag.h │ │ ├── ip_addr.h │ │ ├── ip_frag.h │ │ ├── lwipopts.h │ │ ├── mem.h │ │ ├── memp.h │ │ ├── memp_std.h │ │ ├── mld6.h │ │ ├── nd6.h │ │ ├── netbuf.h │ │ ├── netdb.h │ │ ├── netif.h │ │ ├── netifapi.h │ │ ├── opt.h │ │ ├── pbuf.h │ │ ├── pppapi.h │ │ ├── raw.h │ │ ├── sio.h │ │ ├── snmp.h │ │ ├── snmp_asn1.h │ │ ├── snmp_msg.h │ │ ├── snmp_structs.h │ │ ├── sockets.h │ │ ├── stats.h │ │ ├── sys.h │ │ ├── tcp.h │ │ ├── tcp_impl.h │ │ ├── tcpip.h │ │ ├── timers.h │ │ └── udp.h │ └── ssl.c │ ├── arduino_main.cpp │ ├── binary.h │ ├── cbuf.cpp │ ├── cbuf.h │ ├── constants.h │ ├── cpp_bc66.ld │ ├── custom_config.c │ ├── custom_feature_def.h │ ├── custom_gpio_cfg.h │ ├── custom_heap_cfg.h │ ├── custom_sys_cfg.c │ ├── custom_task_cfg.h │ ├── dbg.c │ ├── dbg.h │ ├── dtostrf.c │ ├── dtostrf.h │ ├── include │ ├── ql_adc.h │ ├── ql_common.h │ ├── ql_eint.h │ ├── ql_error.h │ ├── ql_gpio.h │ ├── ql_iic.h │ ├── ql_memory.h │ ├── ql_power.h │ ├── ql_pwm.h │ ├── ql_rtc.h │ ├── ql_spi.h │ ├── ql_stdlib.h │ ├── ql_system.h │ ├── ql_time.h │ ├── ql_timer.h │ ├── ql_trace.h │ ├── ql_type.h │ └── ql_uart.h │ ├── interface.c │ ├── interface.h │ ├── lib_BC66R01A04V01.a │ ├── lib_BC66R01A05V01.a │ ├── lib_app_start_bc66.a │ ├── new.cpp │ ├── new.h │ ├── pgmspace.h │ ├── ril │ ├── inc │ │ ├── ril.h │ │ ├── ril_lwm2m.h │ │ ├── ril_network.h │ │ ├── ril_socket.h │ │ ├── ril_system.h │ │ └── ril_util.h │ └── src │ │ ├── ril_atResponse.c │ │ ├── ril_init.c │ │ ├── ril_lwm2m.c │ │ ├── ril_network.c │ │ ├── ril_socket.c │ │ ├── ril_system.c │ │ ├── ril_urc.c │ │ └── ril_util.c │ ├── std.c │ ├── wiring.c │ ├── wiring_analog.c │ ├── wiring_digital.c │ ├── wiring_pulse.c │ ├── wiring_shift.c │ └── wizio_lib.c ├── examples ├── info │ └── info.ino └── pubsub_mqtt │ └── pubsub_mqtt.ino ├── firmwares └── Firmware_BC66NBR01A04V01.zip ├── images ├── ARDUINO_BC66.png ├── arduino.png ├── arduino_hardware.png ├── gcc_bin.png └── tool.png ├── libraries ├── EEPROM │ ├── library.properties │ └── src │ │ ├── EEPROM.cpp │ │ ├── EEPROM.h │ │ ├── SYS_EEPROM.cpp │ │ └── SYS_EEPROM.h ├── Ethernet │ ├── examples │ │ └── tcp_http │ │ │ └── tcp_http.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── nbClient.cpp │ │ ├── nbClient.h │ │ ├── nbClientSecure.cpp │ │ ├── nbClientSecure.h │ │ ├── nbFota.h │ │ ├── nbGenericClass.h │ │ ├── nbHttpClient.cpp │ │ ├── nbHttpClient.h │ │ ├── nbMqtt.h │ │ ├── nbSSL.cpp │ │ ├── nbSSL.h │ │ ├── nbUdp.cpp │ │ └── nbUdp.h ├── NVDM │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── NVDM.cpp │ │ └── NVDM.h ├── SPI │ ├── library.properties │ └── src │ │ ├── LICENSE │ │ ├── SPI.cpp │ │ └── SPI.h ├── Timer │ ├── example │ │ └── basic │ │ │ └── basic.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── GPTimer.cpp │ │ ├── GPTimer.h │ │ └── RTTimer.h └── Wire │ ├── library.properties │ └── src │ ├── Wire.cpp │ └── Wire.h ├── platform.txt ├── programmers.txt └── variants └── bc66 ├── variant.cpp ├── variant.h └── variant_pins.c /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ESUP9LCZMZTD6 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino for Quectel BC66 LTE Narow Band modules 2 | ... and [Quectel development platform for PlatformIO](https://github.com/Wiz-IO/platform-quectel) v 2.0.0 3 | (must be full Arduino compatible) 4 | 5 | **A few words in the beginning** 6 | * **Version 2.0.0** ... beta, not everything tested... 7 | * This project not an official product of Quectel / Mediatek 8 | * The project is based on Quectel OpenCPU and **reverse engineering** 9 | 10 | **ATT: work only with firmwares BC66NBR01A04 or BC66NBR01A05** 11 | 12 | ![IMG](https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/master/images/ARDUINO_BC66.png) 13 | 14 | **Chipset Mediatek MT2625 SoC** 15 | Ultra-low power, 3GPP Release-14 enabled NB-IoT platform for wide-ranging home, civic, industrial or mobile applications 16 | https://www.mediatek.com/products/nbIot/mt2625 17 | 18 | 19 | **Module: Quectel BC66** 20 | is a high-performance, multi-band NB-IoT module... 21 | https://www.quectel.com/product/bc66.htm 22 | * Test Board for the project: BC66-TE-B ( it is shield Arduino, unfortunately... ) 23 | * API: OpenCPU, native C, EAT (Embedded AT) oriented 24 | * User Application Size: ROM (BIN) 200k, RAM 100k 25 | * you need firmware **BC66NBR01A04 or BC66NBR01A05** 26 | 27 | ![ScreenShot](https://raw.githubusercontent.com/Wiz-IO/Arduino_MT2625_BC66/master/board.jpg) 28 | 29 | **Tools** 30 | * Arduino IDE (Windows) 31 | https://www.arduino.cc/ 32 | * Firmware, USB Drivers, Quectel IoT Flash Tool 33 | https://app.box.com/s/3wrkh1yzn09yuyb5f8v5vllmlir0571s 34 | 35 | ![ScreenShot](https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/master/images/arduino.png) 36 | 37 | Videos: 38 | 39 | https://youtu.be/njaAHkIkIx0 40 | 41 | https://www.youtube.com/channel/UCNOuJcC5qgU-SrtUwyqmtJQ?view_as=subscriber 42 | 43 | **ATTENTION: Before start exeriments:** 44 | * Update firmware version **BC66NBR01A04 or BC66NBR01A05** 45 | * Make Backup of NVDM Fields (module "eeprom") 46 | * IoT Flash Tool, [Backup] button, check-box "Backup", select file for backup (use IMEI as name), [Start] and keep the file 47 | * Now you can start all and you can restore the module if need 48 | * ATTENTION: if you upload application to module you lose standart AT command via uarts 49 | * Restore AT interface: send "AT+EPORT=1,connl,0", then remove application 50 | * [SEE THIS](https://github.com/Wiz-IO/platform-quectel/wiki/Framework-OpenCPU#how-to-restore-at-command-interface) 51 | * [Other examples](https://github.com/Wiz-IO/platformio-quectel-examples) 52 | 53 | 54 | ## Install 55 | 56 | * Add json link to Arduino - Preferences 57 | 58 | http://wizio.eu/arduino/bc66/package_wizio.bc66_index.json 59 | 60 | * Open Borad Manager, Find WizIO, Install OR Update (remove old versions) 61 | * Select Board 62 | * Select Firmware 63 | * Click [Compile] or [Upload] 64 | 65 | **Thanks to** 66 | 67 | * Radu Igret ( Quectel ) 68 | * [comet.bg](https://www.comet.bg/?cid=92) 69 | 70 | 71 | 72 | >If you want to help / support: 73 | [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ESUP9LCZMZTD6) 74 | -------------------------------------------------------------------------------- /boards.txt: -------------------------------------------------------------------------------- 1 | # WizIO 2018 Georgi Angelov 2 | # https://github.com/Wiz-IO/Arduino-Quectel-BC66 3 | # the.wizarda@gmail.com 4 | # 5 | # Arduino Core and platform. 6 | # For more info: 7 | # https:\\github.com\arduino\Arduino\wiki\Arduino-IDE-1.5---3rd-party-Hardware-specification 8 | 9 | menu.firmware=Firmware 10 | 11 | BC66.build.core=opencpu 12 | BC66.build.variant=bc66 13 | BC66.name=Quectel BC66 Module 14 | BC66.build.board=Quectel BC66 15 | BC66.build.compiler_path={runtime.tools.bc66_gcc.path}\bin\ 16 | BC66.build.mcu=-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -mlittle-endian -mthumb -mthumb-interwork 17 | BC66.build.extra_flags= 18 | BC66.build.f_cpu=78000000L 19 | 20 | BC66.menu.firmware.V4=BC66R01A04V01 21 | BC66.menu.firmware.V4.build.firmware=BC66R01A04V01 22 | BC66.menu.firmware.V5=BC66R01A05V01 23 | BC66.menu.firmware.V5.build.firmware=BC66R01A05V01 24 | 25 | BC66.upload.maximum_size=200000 26 | BC66.upload.maximum_data_size=100000 27 | BC66.upload.tool=bc66 28 | BC66.upload.protocol=quectel 29 | BC66.upload.use_1200bps_touch=false 30 | BC66.upload.wait_for_upload_port=false 31 | BC66.upload.native_usb=false 32 | BC66.upload.via_ssh=false 33 | 34 | -------------------------------------------------------------------------------- /cores/opencpu/Arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino.h - Main include file for the Arduino SDK 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 28 September 2018 by Georgi Angelov 20 | */ 21 | 22 | #ifndef Arduino_h 23 | #define Arduino_h 24 | 25 | #include 26 | #include 27 | 28 | #ifdef __cplusplus 29 | extern "C" 30 | { 31 | #endif 32 | 33 | #include "pgmspace.h" 34 | #include "binary.h" 35 | #include "constants.h" 36 | 37 | unsigned int seconds(void); 38 | unsigned int millis(void); 39 | unsigned int micros(void); 40 | void delay(unsigned int); 41 | void delayMicroseconds(unsigned int us); 42 | 43 | void pinMode(uint8_t, uint8_t); 44 | void digitalWrite(uint8_t, uint8_t); 45 | int digitalRead(uint8_t); 46 | 47 | void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); 48 | uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); 49 | 50 | unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) __attribute__((weak)); 51 | unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) __attribute__((weak)); 52 | 53 | void yield(void) __attribute__((weak)); 54 | void interrupts(void) __attribute__((weak)); 55 | void noInterrupts(void) __attribute__((weak)); 56 | void attachInterrupt(uint8_t, void (*)(void), int mode) __attribute__((weak)); 57 | void detachInterrupt(uint8_t) __attribute__((weak)); 58 | 59 | #ifdef __cplusplus 60 | } // extern "C" 61 | 62 | //////////////////////////////////////////////////////////////////////////////////////////////// 63 | 64 | #include "WCharacter.h" 65 | #include "WString.h" 66 | 67 | long random(long); 68 | long random(long howsmall, long howbig); 69 | void randomSeed(unsigned long seed); 70 | long map(long x, long in_min, long in_max, long out_min, long out_max); 71 | unsigned int makeWord(unsigned int w); 72 | unsigned int makeWord(unsigned char h, unsigned char l); 73 | 74 | void noTone(uint8_t _pin) __attribute__((weak)); 75 | void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0) __attribute__((weak)); 76 | 77 | #endif //__cplusplus 78 | 79 | #endif //Arduino_h 80 | -------------------------------------------------------------------------------- /cores/opencpu/Client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client.h - Base class that provides Client 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef client_h 21 | #define client_h 22 | #include "Print.h" 23 | #include "Stream.h" 24 | #include "IPAddress.h" 25 | 26 | class Client : public Stream { 27 | 28 | public: 29 | virtual int connect(IPAddress ip, uint16_t port) =0; 30 | virtual int connect(const char *host, uint16_t port) =0; 31 | virtual size_t write(uint8_t) =0; 32 | virtual size_t write(const uint8_t *buf, size_t size) =0; 33 | virtual int available() = 0; 34 | virtual int read() = 0; 35 | virtual int read(uint8_t *buf, size_t size) = 0; 36 | virtual int peek() = 0; 37 | virtual void flush() = 0; 38 | virtual void stop() = 0; 39 | virtual uint8_t connected() = 0; 40 | virtual operator bool() = 0; 41 | protected: 42 | uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /cores/opencpu/DEV.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - device 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef __DEV_H__ 22 | #define __DEV_H__ 23 | 24 | #include 25 | #include "WString.h" 26 | #include "IPAddress.h" 27 | 28 | #define DEBUG_DEV DBG 29 | 30 | int getHostByName(const char *host, IPAddress &aResult); 31 | 32 | typedef void (*vCallback)(void); 33 | typedef void (*uCallback)(u32, u32); 34 | typedef void (*mCallback)(ST_MSG *msg); 35 | 36 | #define DEFAULT_AT_TIMEOUT 1000 37 | 38 | class DeviceClass 39 | { 40 | 41 | public: 42 | DeviceClass(); 43 | 44 | mCallback onMessage; 45 | void m_Message(ST_MSG *m) 46 | { 47 | if (onMessage) 48 | onMessage(m); 49 | } 50 | 51 | uCallback onUrc; 52 | void m_Urc(u32 urc, u32 data) 53 | { 54 | if (onUrc) 55 | onUrc(urc, data); 56 | } 57 | 58 | const char *getVersion() { return api_get_version(); } 59 | void getVersion(String &s) {s = api_get_version();} 60 | inline bool getUid(uint8_t *buffer, uint32_t size) { return api_get_uid(buffer, size); } 61 | void getUid(String &s); 62 | bool getImsi(char *buffer, uint32_t size); 63 | void getImsi(String &s); 64 | bool getIccid(char *buffer, uint32_t size); 65 | void getIccid(String &s); 66 | void getMccMnc(char *imsi, uint32_t size); 67 | void getMccMnc(String &s); 68 | void getImei(char *imei, uint32_t size); 69 | void getImei(String &s); 70 | 71 | inline int getSimStatus() { return api_get_sim_status(); } 72 | inline bool isSimReady() { return api_get_sim_status() == SIM_READY; } 73 | bool enterPin(const char *pin); 74 | void waitSimReady(const char *pin = NULL); 75 | 76 | inline int getCreg() { return api_get_creg(); } 77 | void waitCreg(); 78 | inline int getCereg() { return api_get_cereg(); } 79 | void waitCereg(); 80 | 81 | inline int getReceiveLevel() { return api_get_receive_level(); } 82 | inline int getQuality() { return api_get_quality(); } 83 | inline int getAccess() { return api_get_access(); } 84 | inline uint16_t getTac() { return api_get_cell_tac(); } 85 | inline uint32_t getCid() { return api_get_cell_cid(); } 86 | void getLocalIP(IPAddress &IP, unsigned int index = 1); 87 | 88 | //"19/03/14,07:20:05+02",,"A1 BG",0,"A1 BG",0,"+02" 89 | void getMlts(char *buf, unsigned int size) { api_get_mlts_string(buf, size); } 90 | 91 | inline void reset() { Ql_Reset(0); } 92 | void powerOff() 93 | { 94 | int irq = api_SaveAndSetIRQMask(); 95 | hal_rtc_enter_forced_shut_down_mode(irq, 1); 96 | } 97 | inline int powerReason() { return Ql_GetPowerOnReason(); } 98 | 99 | inline void Sleep() { Ql_SleepEnable(); } 100 | inline void noSleep() { Ql_SleepDisable(); } 101 | 102 | bool getDefaultApnType(char *type); 103 | bool saveDefaultApn(const char *type, const char *apn, const char *user, const char *pass); 104 | bool setBand(int band); 105 | 106 | bool send(const char *cmd, u32 timeout = DEFAULT_AT_TIMEOUT, Callback_ATResponse callback = NULL, void *user = NULL); 107 | bool send(String cmd, u32 timeout = DEFAULT_AT_TIMEOUT, Callback_ATResponse callback = NULL, void *user = NULL); 108 | 109 | time_t now(); 110 | }; 111 | 112 | extern DeviceClass Dev; 113 | 114 | #endif //__DEV_H__ -------------------------------------------------------------------------------- /cores/opencpu/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - uart 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef HardwareSerial_h 22 | #define HardwareSerial_h 23 | 24 | #include 25 | #include "Stream.h" 26 | #include 27 | 28 | class HardwareSerial : public Stream 29 | { 30 | protected: 31 | static void callback(Enum_SerialPort port, Enum_UARTEventType event, bool pinLevel, void *serial); 32 | Enum_SerialPort port; 33 | // BC66 34 | QueueHandle_t queue, mutex; 35 | void MUTEX_LOCK(); 36 | void MUTEX_UNLOCK(); 37 | 38 | public: 39 | int save(uint8_t c); 40 | HardwareSerial(uint32_t id); 41 | void debug(void); 42 | void nodebug(void); 43 | void begin(unsigned long baud, void *user); 44 | void begin(unsigned long baud); 45 | void end(); 46 | size_t setRxBufferSize(size_t new_size); 47 | virtual int available(void); 48 | virtual int peek(void); 49 | virtual int read(void); 50 | virtual void flush(void); 51 | virtual size_t write(uint8_t); 52 | inline size_t write(unsigned long n) { return write((uint8_t)n); } 53 | inline size_t write(long n) { return write((uint8_t)n); } 54 | inline size_t write(unsigned int n) { return write((uint8_t)n); } 55 | inline size_t write(int n) { return write((uint8_t)n); } 56 | size_t write(const char *buf); 57 | size_t write(const uint8_t *buf, size_t size); 58 | using Print::write; 59 | operator bool() { return true; } 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /cores/opencpu/IPAddress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | IPAddress.cpp - Base class that provides IPAddress 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | IPAddress::IPAddress() 24 | { 25 | _address.dword = 0; 26 | } 27 | 28 | IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) 29 | { 30 | _address.bytes[0] = first_octet; 31 | _address.bytes[1] = second_octet; 32 | _address.bytes[2] = third_octet; 33 | _address.bytes[3] = fourth_octet; 34 | } 35 | 36 | IPAddress::IPAddress(uint32_t address) 37 | { 38 | _address.dword = address; 39 | } 40 | 41 | IPAddress::IPAddress(const uint8_t *address) 42 | { 43 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 44 | } 45 | 46 | bool IPAddress::fromString(const char *address) 47 | { 48 | uint16_t acc = 0; // Accumulator 49 | uint8_t dots = 0; 50 | 51 | while (*address) 52 | { 53 | char c = *address++; 54 | if (c >= '0' && c <= '9') 55 | { 56 | acc = acc * 10 + (c - '0'); 57 | if (acc > 255) 58 | { 59 | // Value out of [0..255] range 60 | return false; 61 | } 62 | } 63 | else if (c == '.') 64 | { 65 | if (dots == 3) 66 | { 67 | // Too much dots (there must be 3 dots) 68 | return false; 69 | } 70 | _address.bytes[dots++] = acc; 71 | acc = 0; 72 | } 73 | else 74 | { 75 | // Invalid char 76 | return false; 77 | } 78 | } 79 | 80 | if (dots != 3) 81 | { 82 | // Too few dots (there must be 3 dots) 83 | return false; 84 | } 85 | _address.bytes[3] = acc; 86 | return true; 87 | } 88 | 89 | IPAddress &IPAddress::operator=(const uint8_t *address) 90 | { 91 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 92 | return *this; 93 | } 94 | 95 | IPAddress &IPAddress::operator=(uint32_t address) 96 | { 97 | _address.dword = address; 98 | return *this; 99 | } 100 | 101 | bool IPAddress::operator==(const uint8_t *addr) const 102 | { 103 | return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0; 104 | } 105 | 106 | size_t IPAddress::printTo(Print &p) const 107 | { 108 | size_t n = 0; 109 | for (int i = 0; i < 3; i++) 110 | { 111 | n += p.print(_address.bytes[i], DEC); 112 | n += p.print('.'); 113 | } 114 | n += p.print(_address.bytes[3], DEC); 115 | return n; 116 | } 117 | 118 | String IPAddress::toString() const 119 | { 120 | char szRet[16]; 121 | sprintf(szRet,"%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]); 122 | return String(szRet); 123 | } -------------------------------------------------------------------------------- /cores/opencpu/IPAddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | IPAddress.h - Base class that provides IPAddress 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef IPAddress_h 21 | #define IPAddress_h 22 | 23 | #include 24 | #include "Printable.h" 25 | #include "WString.h" 26 | 27 | // A class to make it easier to handle and pass around IP addresses 28 | 29 | class IPAddress : public Printable { 30 | private: 31 | union { 32 | uint8_t bytes[4]; // IPv4 address 33 | uint32_t dword; 34 | } _address; 35 | 36 | // Access the raw byte array containing the address. Because this returns a pointer 37 | // to the internal structure rather than a copy of the address this function should only 38 | // be used when you know that the usage of the returned uint8_t* will be transient and not 39 | // stored. 40 | uint8_t* raw_address() { return _address.bytes; }; 41 | 42 | public: 43 | // Constructors 44 | IPAddress(); 45 | IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); 46 | IPAddress(uint32_t address); 47 | IPAddress(const uint8_t *address); 48 | 49 | bool fromString(const char *address); 50 | bool fromString(const String &address) { return fromString(address.c_str()); } 51 | 52 | // Overloaded cast operator to allow IPAddress objects to be used where a pointer 53 | // to a four-byte uint8_t array is expected 54 | operator uint32_t() const { return _address.dword; }; 55 | bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; }; 56 | bool operator==(const uint8_t* addr) const; 57 | 58 | // Overloaded index operator to allow getting and setting individual octets of the address 59 | uint8_t operator[](int index) const { return _address.bytes[index]; }; 60 | uint8_t& operator[](int index) { return _address.bytes[index]; }; 61 | 62 | // Overloaded copy operators to allow initialisation of IPAddress objects from other types 63 | IPAddress& operator=(const uint8_t *address); 64 | IPAddress& operator=(uint32_t address); 65 | 66 | virtual size_t printTo(Print& p) const; 67 | String toString() const; 68 | 69 | friend class EthernetClass; 70 | friend class UDP; 71 | friend class Client; 72 | friend class Server; 73 | friend class DhcpClass; 74 | friend class DNSClient; 75 | }; 76 | 77 | //const IPAddress INADDR_NONE(0,0,0,0); 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /cores/opencpu/PSM.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - psm 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef __PSM_H__ 22 | #define __PSM_H__ 23 | 24 | #include 25 | 26 | #define DEBUG_PSM DBG 27 | 28 | typedef void (*sleep_callback_t)(void *, uint32_t); 29 | 30 | typedef struct 31 | { 32 | int periodic; 33 | int active; 34 | int mode; 35 | } cpsms_t; 36 | 37 | class PSMClass 38 | { 39 | private: 40 | uint32_t m_wakeup_interval; 41 | static void onLimitCB(TimerHandle_t xTimer); 42 | static void onSleepCB(void *psm, uint32_t id); 43 | 44 | public: 45 | PSMClass() 46 | { 47 | m_wakeup_interval = 0; 48 | } 49 | 50 | ///Enable/Disable auto deep sleep mode 51 | inline void Sleep() { Ql_SleepEnable(); } 52 | inline void noSleep() { Ql_SleepDisable(); } 53 | 54 | ///Register onPin wakeup 55 | bool pin(Callback_Psm_Eint_Func onPsm, void *param); 56 | 57 | ///Get timers from cell 58 | int getCellPsmPeriodicTime(); 59 | int getCellPsmActiveTime(); 60 | 61 | ///get/set user times, can be ignored form cell 62 | bool get(int *period, int *active); 63 | bool set(int periode, int active, int mode = 1); 64 | 65 | ///Register onSleep event - RTC wakeup timer 66 | bool wakeup(uint32_t interval, sleep_callback_t cb = NULL); 67 | 68 | ///Emergency Reset, default 5 minutes 69 | bool limit(uint32_t seconds = 300); 70 | }; 71 | 72 | extern PSMClass Psm; 73 | #endif -------------------------------------------------------------------------------- /cores/opencpu/Print.h: -------------------------------------------------------------------------------- 1 | /* 2 | Print.h - Base class that provides print() and println() 3 | Copyright (c) 2008 David A. Mellis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Print_h 21 | #define Print_h 22 | 23 | #include 24 | #include // for size_t 25 | 26 | #include "WString.h" 27 | #include "Printable.h" 28 | 29 | #define DEC 10 30 | #define HEX 16 31 | #define OCT 8 32 | #ifdef BIN // Prevent warnings if BIN is previously defined in "iotnx4.h" or similar 33 | #undef BIN 34 | #endif 35 | #define BIN 2 36 | 37 | class Print 38 | { 39 | private: 40 | int write_error; 41 | size_t printNumber(unsigned long, uint8_t); 42 | size_t printFloat(double, uint8_t); 43 | protected: 44 | void setWriteError(int err = 1) { write_error = err; } 45 | public: 46 | Print() : write_error(0) {} 47 | 48 | int getWriteError() { return write_error; } 49 | void clearWriteError() { setWriteError(0); } 50 | 51 | virtual size_t write(uint8_t) = 0; 52 | size_t write(const char *str) { 53 | if (str == NULL) return 0; 54 | return write((const uint8_t *)str, strlen(str)); 55 | } 56 | virtual size_t write(const uint8_t *buffer, size_t size); 57 | size_t write(const char *buffer, size_t size) { 58 | return write((const uint8_t *)buffer, size); 59 | } 60 | 61 | // default to zero, meaning "a single write may block" 62 | // should be overriden by subclasses with buffering 63 | virtual int availableForWrite() { return 0; } 64 | 65 | size_t print(const __FlashStringHelper *); 66 | size_t print(const String &); 67 | size_t print(const char[]); 68 | size_t print(char); 69 | size_t print(unsigned char, int = DEC); 70 | size_t print(int, int = DEC); 71 | size_t print(unsigned int, int = DEC); 72 | size_t print(long, int = DEC); 73 | size_t print(unsigned long, int = DEC); 74 | size_t print(double, int = 2); 75 | size_t print(const Printable&); 76 | 77 | size_t println(const __FlashStringHelper *); 78 | size_t println(const String &s); 79 | size_t println(const char[]); 80 | size_t println(char); 81 | size_t println(unsigned char, int = DEC); 82 | size_t println(int, int = DEC); 83 | size_t println(unsigned int, int = DEC); 84 | size_t println(long, int = DEC); 85 | size_t println(unsigned long, int = DEC); 86 | size_t println(double, int = 2); 87 | size_t println(const Printable&); 88 | size_t println(void); 89 | 90 | size_t printf(const char *format, ...); 91 | 92 | virtual void flush() { /* Empty implementation for backward compatibility */ } 93 | }; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /cores/opencpu/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /cores/opencpu/RTC.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - rtc 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include "RTC.h" 23 | 24 | #define DEBUG_RTC DBG 25 | 26 | RTCClass RTC; 27 | 28 | unsigned long long rtc_seconds(void) 29 | { 30 | unsigned long long seconds = 0; 31 | ST_Time T; 32 | if (Ql_GetLocalTime(&T)) 33 | seconds = Ql_Mktime(&T); 34 | return seconds; 35 | } 36 | 37 | unsigned long long RTCClass::get() 38 | { 39 | unsigned long long seconds = 0; 40 | ST_Time T; 41 | if (Ql_GetLocalTime(&T)) 42 | { 43 | m_year = T.year; 44 | m_month = T.month; 45 | m_day = T.day; 46 | m_hour = T.hour; 47 | m_minute = T.minute; 48 | m_second = T.second; 49 | m_timezone = T.timezone; 50 | seconds = Ql_Mktime(&T); 51 | } 52 | return seconds; 53 | } 54 | 55 | int RTCClass::timezone() 56 | { 57 | return m_timezone; 58 | } 59 | 60 | int RTCClass::year() 61 | { 62 | return m_year; 63 | } 64 | 65 | int RTCClass::month() 66 | { 67 | return m_month; 68 | } 69 | 70 | int RTCClass::day() 71 | { 72 | return m_day; 73 | } 74 | 75 | int RTCClass::hour() 76 | { 77 | return m_hour; 78 | } 79 | 80 | int RTCClass::minute() 81 | { 82 | return m_minute; 83 | } 84 | 85 | int RTCClass::second() 86 | { 87 | return m_second; 88 | } 89 | 90 | ///result: Wed Feb 13 08:27:10 2019 91 | extern "C" char *asctime(const struct tm *timeptr); 92 | char *RTCClass::m_asctime(char *buffer, u32 size) 93 | { 94 | time_t rawtime = rtc_seconds(); 95 | struct tm *t = localtime(&rawtime); 96 | char *p = asctime(t); 97 | if (p && size) 98 | { 99 | Ql_memset(buffer, 0, size); 100 | Ql_strncpy(buffer, p, size); 101 | return buffer; 102 | } 103 | return NULL; 104 | } 105 | 106 | char *RTCClass::ascTime(char *buffer, u32 size) 107 | { 108 | return m_asctime(buffer, size); 109 | } 110 | 111 | size_t RTCClass::printTo(Print &p) const 112 | { 113 | char b[32]; 114 | const char *c = (const char *)m_asctime(b, 32); 115 | return p.print(c); 116 | } 117 | -------------------------------------------------------------------------------- /cores/opencpu/RTC.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - rtc 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef __RTC_H__ 22 | #define __RTC_H__ 23 | 24 | #include 25 | #include 26 | 27 | #define RTC_TIMER_ID 0x202 28 | 29 | class RTCClass : public Printable 30 | { 31 | public: 32 | RTCClass() 33 | { 34 | m_id = 0; 35 | timer_started = 0; 36 | }; 37 | int timezone(); 38 | int year(); 39 | int month(); 40 | int day(); 41 | int hour(); 42 | int minute(); 43 | int second(); 44 | unsigned long long get(); 45 | void set(int year, int month, int day, int hour, int minute, int second){}; 46 | 47 | char *ascTime(char *buffer, u32 size); 48 | virtual size_t printTo(Print &p) const; 49 | 50 | bool timer_started; 51 | bool timer_begin(Callback_Rtc_Func callback, void *param = NULL) 52 | { 53 | if (callback) 54 | m_id = (Ql_Rtc_RegisterFast(RTC_TIMER_ID, callback, param) == 0) ? RTC_TIMER_ID : 0; 55 | else 56 | m_id = 0; 57 | return m_id > 0; 58 | } 59 | 60 | bool timer_stop() 61 | { 62 | bool res = false; 63 | if (m_id) 64 | { 65 | res = Ql_Rtc_Stop(m_id) == QL_RET_OK; 66 | timer_started = res ? 0 : 1; 67 | } 68 | return res; 69 | } 70 | 71 | bool timer_start(uint32_t interval, bool autoRepeat = false) 72 | { 73 | bool res = false; 74 | if (m_id) 75 | { 76 | if (timer_started) 77 | timer_stop(); 78 | res = Ql_Rtc_Start(m_id, interval, autoRepeat) == QL_RET_OK; 79 | timer_started = res; 80 | } 81 | return res; 82 | } 83 | 84 | operator bool() { return timer_started; } 85 | 86 | private: 87 | int m_year; 88 | int m_month; 89 | int m_day; 90 | int m_hour; 91 | int m_minute; 92 | int m_second; 93 | int m_timezone; 94 | static char *m_asctime(char *buffer, u32 size); 95 | uint32_t m_id; 96 | }; 97 | 98 | extern RTCClass RTC; 99 | 100 | #endif -------------------------------------------------------------------------------- /cores/opencpu/RingBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifdef __cplusplus 20 | 21 | #ifndef _RING_BUFFER_ 22 | #define _RING_BUFFER_ 23 | 24 | #include 25 | 26 | // Define constants and variables for buffering incoming serial data. We're 27 | // using a ring buffer (I think), in which head is the index of the location 28 | // to which to write the next incoming character and tail is the index of the 29 | // location from which to read. 30 | // defined in interface.h 31 | #ifndef SERIAL_BUFFER_SIZE 32 | #define SERIAL_BUFFER_SIZE 256 33 | #endif 34 | 35 | template 36 | class RingBufferN 37 | { 38 | public: 39 | uint8_t _aucBuffer[N]; 40 | volatile int _iHead; 41 | volatile int _iTail; 42 | 43 | public: 44 | RingBufferN(void); 45 | void store_char(uint8_t c); 46 | void clear(); 47 | int read_char(); 48 | int available(); 49 | int availableForStore(); 50 | int peek(); 51 | bool isFull(); 52 | 53 | private: 54 | int nextIndex(int index); 55 | }; 56 | 57 | typedef RingBufferN RingBuffer; 58 | 59 | template RingBufferN::RingBufferN(void) 60 | { 61 | memset(_aucBuffer, 0, N); 62 | clear(); 63 | } 64 | 65 | template 66 | void RingBufferN::store_char(uint8_t c) 67 | { 68 | int i = nextIndex(_iHead); 69 | 70 | // if we should be storing the received character into the location 71 | // just before the tail (meaning that the head would advance to the 72 | // current location of the tail), we're about to overflow the buffer 73 | // and so we don't write the character or advance the head. 74 | if (i != _iTail) 75 | { 76 | _aucBuffer[_iHead] = c; 77 | _iHead = i; 78 | } 79 | } 80 | 81 | template 82 | void RingBufferN::clear() 83 | { 84 | _iHead = 0; 85 | _iTail = 0; 86 | } 87 | 88 | template 89 | int RingBufferN::read_char() 90 | { 91 | if (_iTail == _iHead) 92 | return -1; 93 | 94 | uint8_t value = _aucBuffer[_iTail]; 95 | _iTail = nextIndex(_iTail); 96 | 97 | return value; 98 | } 99 | 100 | template 101 | int RingBufferN::available() 102 | { 103 | int delta = _iHead - _iTail; 104 | 105 | if (delta < 0) 106 | return N + delta; 107 | else 108 | return delta; 109 | } 110 | 111 | template 112 | int RingBufferN::availableForStore() 113 | { 114 | if (_iHead >= _iTail) 115 | return N - 1 - _iHead + _iTail; 116 | else 117 | return _iTail - _iHead - 1; 118 | } 119 | 120 | template 121 | int RingBufferN::peek() 122 | { 123 | if (_iTail == _iHead) 124 | return -1; 125 | 126 | return _aucBuffer[_iTail]; 127 | } 128 | 129 | template 130 | int RingBufferN::nextIndex(int index) 131 | { 132 | return (uint32_t)(index + 1) % N; 133 | } 134 | 135 | template 136 | bool RingBufferN::isFull() 137 | { 138 | return (nextIndex(_iHead) == _iTail); 139 | } 140 | 141 | #endif /* _RING_BUFFER_ */ 142 | 143 | #endif /* __cplusplus */ 144 | -------------------------------------------------------------------------------- /cores/opencpu/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Base class that provides Server 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef server_h 21 | #define server_h 22 | 23 | #include "Print.h" 24 | 25 | class Server : public Print { 26 | public: 27 | virtual void begin() =0; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /cores/opencpu/Tone.h: -------------------------------------------------------------------------------- 1 | #ifndef __TONE_H__ 2 | #define __TONE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | extern void tone(uint8_t pin, unsigned int frequency, unsigned long duration = 0); 15 | extern void noTone(uint8_t pin); 16 | 17 | #endif //Tone.h -------------------------------------------------------------------------------- /cores/opencpu/WMath.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void randomSeed(unsigned long seed) 4 | { 5 | if (seed != 0) 6 | { 7 | srand(seed); 8 | } 9 | } 10 | 11 | long random(long howbig) 12 | { 13 | if (howbig == 0) 14 | { 15 | return 0; 16 | } 17 | return rand() % howbig; 18 | } 19 | 20 | long random(long howsmall, long howbig) 21 | { 22 | if (howsmall >= howbig) 23 | { 24 | return howsmall; 25 | } 26 | long diff = howbig - howsmall; 27 | return random(diff) + howsmall; 28 | } 29 | 30 | long map(long x, long in_min, long in_max, long out_min, long out_max) 31 | { 32 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 33 | } 34 | 35 | unsigned int makeWord(unsigned int w) 36 | { 37 | return w; 38 | } 39 | 40 | unsigned int makeWord(unsigned char h, unsigned char l) 41 | { 42 | return (h << 8) | l; 43 | } 44 | -------------------------------------------------------------------------------- /cores/opencpu/WProgram.h: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" -------------------------------------------------------------------------------- /cores/opencpu/api/api.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - API 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef API_H_ 22 | #define API_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "freertos/FreeRTOS.h" 31 | #include "freertos/task.h" 32 | #include "freertos/queue.h" 33 | #include "freertos/semphr.h" 34 | #include "freertos/timers.h" 35 | 36 | #include "lwip/lwipopts.h" 37 | #include "lwip/sockets.h" 38 | #include "lwip/netdb.h" 39 | 40 | #include "api_hal.h" 41 | #include "api_tel.h" 42 | #include "api_ssl.h" 43 | #include "api_http.h" 44 | #include "api_ping.h" 45 | #include "api_json.h" 46 | #include "api_ril.h" 47 | #include "api_nvdm.h" 48 | #include "api_lwm2m.h" 49 | #include "api_mqtt.h" 50 | #include "api_fota.h" 51 | 52 | int api_check_api(void); 53 | const char *api_get_version(void); 54 | 55 | void api_delay_us(uint32_t us); 56 | uint32_t api_get_micro(void); 57 | uint32_t api_get_cpu_speed(void); 58 | int api_set_cpu_speed(uint32_t kHz); 59 | 60 | uint32_t api_get_random(void); 61 | 62 | void api_get_imei(char *imei, unsigned int size); // must [16] 63 | bool api_get_uid(uint8_t *uid, uint32_t len); 64 | 65 | typedef enum 66 | { 67 | SIM_NOT_READY = 0x0, 68 | SIM_PIN = 0x1, 69 | SIM_PUK = 0x2, 70 | SIM_READY = 0x3, 71 | SIM_PIN2 = 0x4, 72 | SIM_PUK2 = 0x5, 73 | SIM_UPIN = 0x6, 74 | SIM_UPUK = 0x7, 75 | NUM_OF_SIM_STATES = 0x8, 76 | } SimState_e; 77 | 78 | int api_get_sim_status(void); 79 | uint32_t api_get_mcc_mnc(void); //0001.0284 - MTEL = 284.01 80 | void api_get_imsi(char *buffer); //len = 9 81 | void api_get_iccid(char *buffer); //len = 10 82 | 83 | int api_get_creg(void); 84 | int api_get_cereg(void); 85 | int api_get_receive_level(void); 86 | int api_get_quality(void); 87 | int api_get_access(void); 88 | void api_get_mlts_string(char *buf, unsigned int size); // [322] 89 | uint32_t api_get_local_ip(unsigned int index); 90 | 91 | uint16_t api_get_cell_tac(void); 92 | uint32_t api_get_cell_cid(void); 93 | 94 | uint8_t api_get_psm_active(void); 95 | uint8_t api_get_psm_periodic(void); 96 | 97 | int api_rtc_register(void (*callback)(unsigned int, void *), void *param); 98 | int api_rtc_start(unsigned int interval, uint8_t autoRepeat); 99 | int api_rtc_stop(void); 100 | 101 | int api_SaveAndSetIRQMask(void) __attribute__((weak)); 102 | void api_RestoreIRQMask(int) __attribute__((weak)); 103 | 104 | //////////////////////////////////////////////////////////////////////////// 105 | // NETWORK 106 | //////////////////////////////////////////////////////////////////////////// 107 | 108 | //char *bzero(char *result, int a2); 109 | uint16_t lwip_htons(uint16_t n); 110 | uint16_t lwip_ntohs(uint16_t n); 111 | uint32_t lwip_htonl(uint32_t n); 112 | uint32_t lwip_ntohl(uint32_t n); 113 | 114 | int lwip_getaddrinfo(const char *host, const char *server, const struct addrinfo *hints, struct addrinfo **res); 115 | void lwip_freeaddrinfo(struct addrinfo *ai); 116 | int resolveAddress(const char *server, struct sockaddr_in *addr); 117 | 118 | #endif /* API_H_ */ 119 | -------------------------------------------------------------------------------- /cores/opencpu/api/api_http.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - API 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef API_HTTP_H_ 22 | #define API_HTTP_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | typedef enum 30 | { 31 | HTTPCLIENT_GET, 32 | HTTPCLIENT_POST, 33 | HTTPCLIENT_PUT, 34 | HTTPCLIENT_DELETE, 35 | HTTPCLIENT_HEAD 36 | } HTTPCLIENT_REQUEST_TYPE; 37 | 38 | typedef struct 39 | { 40 | int socket; 41 | int remote_port; 42 | int response_code; 43 | char *header; 44 | char *auth_user; 45 | char *auth_password; 46 | uint8_t is_http; 47 | int method; 48 | unsigned int timeout_in_sec; 49 | int start_pos; 50 | int total_len; 51 | int retry_cnt; 52 | const char *server_cert; 53 | const char *client_cert; 54 | const char *client_pk; 55 | int server_cert_len; 56 | int client_cert_len; 57 | int client_pk_len; 58 | void *ssl; 59 | } httpclient_t; 60 | 61 | typedef struct 62 | { 63 | uint8_t is_more; 64 | uint8_t is_chunked; 65 | int retrieve_len; 66 | int response_content_len; 67 | int content_block_len; 68 | int post_buf_len; 69 | int response_buf_len; 70 | int header_buf_len; 71 | char *post_content_type; 72 | char *post_buf; 73 | char *response_buf; 74 | char *header_buf; 75 | } httpclient_data_t; 76 | 77 | int httpclient_connect(httpclient_t *client, char *url); 78 | int httpclient_close(httpclient_t *client); 79 | int httpclient_send_auth(httpclient_t *client, char *send_buf, int *send_idx); 80 | int httpclient_send_header(httpclient_t *client, char *url, int method, httpclient_data_t *client_data); 81 | int httpclient_send_userdata(httpclient_t *client, httpclient_data_t *client_data); 82 | int httpclient_send_request(httpclient_t *client, char *url, int method, httpclient_data_t *client_data); 83 | int httpclient_recv_response(httpclient_t *client, httpclient_data_t *client_data); 84 | int httpclient_get_response_code(httpclient_t *client); 85 | int httpclient_common(httpclient_t *client, char *url, int method, httpclient_data_t *client_data); 86 | int httpclient_post(httpclient_t *client, char *url, httpclient_data_t *client_data); 87 | 88 | #endif /* API_HTTP_H_ */ 89 | -------------------------------------------------------------------------------- /cores/opencpu/api/api_net.c: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - API 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "api.h" 22 | 23 | int resolveAddress(const char *server, struct sockaddr_in *addr) 24 | { 25 | if (!server || !addr) 26 | return -1; 27 | struct addrinfo *ai; 28 | struct addrinfo hints; 29 | memset(&hints, 0, sizeof(hints)); 30 | hints.ai_socktype = 1; 31 | hints.ai_protocol = 6; 32 | int rc; 33 | uint32_t *p; 34 | if (lwip_getaddrinfo(server, 0, &hints, &ai)) 35 | { 36 | return -1; 37 | } 38 | else 39 | { 40 | rc = -1; 41 | while (ai && rc < 0) 42 | { 43 | if (ai->ai_family == 2) 44 | { 45 | rc = ai->ai_addrlen; 46 | addr->sin_family = 2; 47 | p = (uint32_t *)&ai->ai_addr->sa_data[2]; 48 | addr->sin_addr.s_addr = *p; 49 | } 50 | ai = ai->ai_next; 51 | } 52 | lwip_freeaddrinfo(ai); 53 | } 54 | return rc; 55 | } 56 | -------------------------------------------------------------------------------- /cores/opencpu/api/api_nvdm.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - API 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef API_NVDM_H_ 22 | #define API_NVDM_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | typedef enum 30 | { 31 | NVDM_STATUS_INVALID_PARAMETER = 0xFB, 32 | NVDM_STATUS_ITEM_NOT_FOUND = 0xFC, 33 | NVDM_STATUS_INSUFFICIENT_SPACE = 0xFD, 34 | NVDM_STATUS_INCORRECT_CHECKSUM = 0xFE, 35 | NVDM_STATUS_ERROR = 0xFF, 36 | NVDM_STATUS_OK = 0x0, 37 | } nvdm_status_t; 38 | 39 | typedef enum 40 | { 41 | NVDM_DATA_ITEM_TYPE_RAW_DATA = 0x1, 42 | NVDM_DATA_ITEM_TYPE_STRING = 0x2, 43 | } nvdm_data_item_type_t; 44 | 45 | nvdm_status_t nvdm_read_data_item(const char *group_name, const char *data_item_name, uint8_t *buffer, uint32_t *size); 46 | nvdm_status_t nvdm_write_data_item(const char *group_name, const char *data_item_name, nvdm_data_item_type_t type, const uint8_t *buffer, uint32_t size); 47 | 48 | #endif /* API_NVDM_H_ */ -------------------------------------------------------------------------------- /cores/opencpu/api/api_ping.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - API 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef API_PING_H_ 22 | #define API_PING_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | typedef enum { 30 | PING_OK = 0x0, PING_ERROR = 0x1, PING_RUNNING = 0x2, 31 | } ping_status_t; 32 | 33 | typedef enum { 34 | PING_PACKET_RESULT = 0x0, PING_TOTAL_RESULT = 0x1, 35 | } ping_result_type_t; 36 | 37 | typedef void (*ping_request_result_t)(ping_result_type_t, void *); 38 | 39 | typedef struct { 40 | uint32_t count; 41 | uint32_t size; 42 | uint32_t recv_timeout; 43 | uint32_t interval; 44 | ping_request_result_t callback; 45 | uint8_t *addr; 46 | } ping_para_t; 47 | 48 | ping_status_t ping_request_ex(uint8_t addr_type, ping_para_t *para); 49 | 50 | #endif /* API_PING_H_ */ 51 | -------------------------------------------------------------------------------- /cores/opencpu/api/api_tel.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - API 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef API_TEL_H_ 22 | #define API_TEL_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | typedef enum { 29 | TEL_CONN_MGR_RET_OK = 0x0, 30 | TEL_CONN_MGR_RET_ERROR = 0xFF, 31 | TEL_CONN_MGR_RET_WOULDBLOCK = 0xFE, 32 | TEL_CONN_MGR_RET_IS_HOLD = 0xFD, 33 | TEL_CONN_MGR_RET_DUPLICATION = 0xFC, 34 | TEL_CONN_MGR_RET_NOT_FOUND = 0xFB, 35 | TEL_CONN_MGR_RET_INVALID_PARAM = 0xFA, 36 | TEL_CONN_MGR_RET_LIMIT_RESOURCE = 0xF9, 37 | TEL_CONN_MGR_RET_NOT_ENOUGH_MEMORY = 0xF8, 38 | TEL_CONN_MGR_RET_INCOMPATIBLE = 0xF7, 39 | TEL_CONN_MGR_RET_WRONG_STATE = 0xF6, 40 | TEL_CONN_MGR_RET_UNKNOWN = 0xF5, 41 | TEL_CONN_MGR_RET_CANCELED = 0xF4, 42 | } tel_conn_mgr_ret_enum; 43 | 44 | typedef enum { 45 | TEL_CONN_MGR_BEARER_TYPE_NONE = 0x0, 46 | TEL_CONN_MGR_BEARER_TYPE_NBIOT = 0x1, 47 | TEL_CONN_MGR_BEARER_TYPE_MAX = 0x2, 48 | } tel_conn_mgr_bearer_type_enum; 49 | 50 | typedef enum { 51 | TEL_CONN_MGR_SIM_ID_NONE = 0x0, 52 | TEL_CONN_MGR_SIM_ID_1 = 0x1, 53 | TEL_CONN_MGR_SIM_ID_MAX = 0x2, 54 | } tel_conn_mgr_sim_id_enum; 55 | 56 | typedef enum { 57 | TEL_CONN_MGR_PDP_TYPE_NONE = 0x0, 58 | TEL_CONN_MGR_PDP_TYPE_IP = 0x1, 59 | TEL_CONN_MGR_PDP_TYPE_IPV6 = 0x2, 60 | TEL_CONN_MGR_PDP_TYPE_IPV4V6 = 0x3, 61 | TEL_CONN_MGR_PDP_TYPE_NIDD = 0x4, 62 | TEL_CONN_MGR_PDP_TYPE_MAX = 0x5, 63 | } tel_conn_mgr_pdp_type_enum; 64 | 65 | typedef enum { 66 | TEL_CONN_MGR_INFO_TYPE_NONE = 0x0, 67 | TEL_CONN_MGR_INFO_TYPE_ACTIVATION = 0x1, 68 | TEL_CONN_MGR_INFO_TYPE_ACTIVE_DEACTIVATION = 0x2, 69 | TEL_CONN_MGR_INFO_TYPE_PASSIVE_DEACTIVATION = 0x3, 70 | TEL_CONN_MGR_INFO_TYPE_MAX = 0x4, 71 | } tel_conn_mgr_info_type_enum; 72 | 73 | typedef enum { 74 | TEL_CONN_MGR_ERR_CAUSE_NONE = 0x0, 75 | TEL_CONN_MGR_ERR_CAUSE_UNKNOWN = 0x1, 76 | TEL_CONN_MGR_ERR_CAUSE_INIT_FAILED = 0x2, 77 | TEL_CONN_MGR_ERR_CAUSE_MODEM_EXCEPTION = 0x3, 78 | TEL_CONN_MGR_ERR_CAUSE_AT_CMD_EXCEPTION = 0x4, 79 | TEL_CONN_MGR_ERR_CAUSE_NW_DETACH = 0x5, 80 | TEL_CONN_MGR_ERR_CAUSE_ME_DETACH = 0x6, 81 | TEL_CONN_MGR_ERR_CAUSE_NW_DEACT = 0x7, 82 | TEL_CONN_MGR_ERR_CAUSE_ME_DEACT = 0x8, 83 | TEL_CONN_MGR_ERR_CAUSE_NW_REGISTRATION_FAILED = 0x9, 84 | TEL_CONN_MGR_ERR_CAUSE_DEACT_REQ = 0xA, 85 | TEL_CONN_MGR_ERR_CAUSE_ACT_REQ = 0xB, 86 | TEL_CONN_MGR_ERR_CAUSE_TIMEOUT = 0xC, 87 | TEL_CONN_MGR_ERR_CAUSE_PDP_TYPE_NOT_SUPPORTED = 0xD, 88 | TEL_CONN_MGR_ERR_CAUSE_PDP_TYPE_NOT_COMPATIBLE = 0xE, 89 | TEL_CONN_MGR_ERR_CAUSE_MAX = 0xF, 90 | } tel_conn_mgr_err_cause_enum; 91 | 92 | typedef uint8_t tel_conn_mgr_bool; 93 | typedef int * tel_conn_mgr_register_handle_t; 94 | typedef void * tel_conn_mgr_queue_hdl_t; 95 | typedef void (*tel_conn_mgr_cb)(unsigned int, tel_conn_mgr_info_type_enum, tel_conn_mgr_bool, tel_conn_mgr_err_cause_enum, tel_conn_mgr_pdp_type_enum); 96 | 97 | tel_conn_mgr_register_handle_t tel_conn_mgr_register_callback(tel_conn_mgr_cb callback); 98 | tel_conn_mgr_ret_enum tel_conn_mgr_deactivate(unsigned int app_id); 99 | tel_conn_mgr_ret_enum tel_conn_mgr_activate_int( 100 | tel_conn_mgr_bearer_type_enum bearer_type, 101 | tel_conn_mgr_sim_id_enum sim_id, 102 | tel_conn_mgr_pdp_type_enum pdp_type, 103 | char *apn, 104 | char *username, 105 | char *password, 106 | tel_conn_mgr_queue_hdl_t queue_hdl, 107 | void *reg_hdl, 108 | unsigned int *app_id, 109 | tel_conn_mgr_pdp_type_enum *activated_pdp_type 110 | ); 111 | 112 | #endif /* API_TEL_H_ */ 113 | -------------------------------------------------------------------------------- /cores/opencpu/api/arch/bpstruct.h: -------------------------------------------------------------------------------- 1 | /* Copyright Statement: 2 | * 3 | * (C) 2005-2016 MediaTek Inc. All rights reserved. 4 | * 5 | * This software/firmware and related documentation ("MediaTek Software") are 6 | * protected under relevant copyright laws. The information contained herein 7 | * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors. 8 | * Without the prior written permission of MediaTek and/or its licensors, 9 | * any reproduction, modification, use or disclosure of MediaTek Software, 10 | * and information contained herein, in whole or in part, shall be strictly prohibited. 11 | * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software 12 | * if you have agreed to and been bound by the applicable license agreement with 13 | * MediaTek ("License Agreement") and been granted explicit permission to do so within 14 | * the License Agreement ("Permitted User"). If you are not a Permitted User, 15 | * please cease any access or use of MediaTek Software immediately. 16 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES 17 | * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES 18 | * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL 19 | * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. 21 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE 22 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR 23 | * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH 24 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES 25 | * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES 26 | * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK 27 | * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR 28 | * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND 29 | * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, 30 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE, 31 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO 32 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 33 | */ 34 | 35 | #pragma pack(push,1) 36 | -------------------------------------------------------------------------------- /cores/opencpu/api/arch/epstruct.h: -------------------------------------------------------------------------------- 1 | /* Copyright Statement: 2 | * 3 | * (C) 2005-2016 MediaTek Inc. All rights reserved. 4 | * 5 | * This software/firmware and related documentation ("MediaTek Software") are 6 | * protected under relevant copyright laws. The information contained herein 7 | * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors. 8 | * Without the prior written permission of MediaTek and/or its licensors, 9 | * any reproduction, modification, use or disclosure of MediaTek Software, 10 | * and information contained herein, in whole or in part, shall be strictly prohibited. 11 | * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software 12 | * if you have agreed to and been bound by the applicable license agreement with 13 | * MediaTek ("License Agreement") and been granted explicit permission to do so within 14 | * the License Agreement ("Permitted User"). If you are not a Permitted User, 15 | * please cease any access or use of MediaTek Software immediately. 16 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES 17 | * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES 18 | * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL 19 | * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. 21 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE 22 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR 23 | * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH 24 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES 25 | * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES 26 | * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK 27 | * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR 28 | * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND 29 | * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, 30 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE, 31 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO 32 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 33 | */ 34 | 35 | #pragma pack(pop) 36 | -------------------------------------------------------------------------------- /cores/opencpu/api/arch/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef __PERF_H__ 35 | #define __PERF_H__ 36 | 37 | #define PERF_START /* null definition */ 38 | #define PERF_STOP(x) /* null definition */ 39 | 40 | #endif /* __PERF_H__ */ 41 | -------------------------------------------------------------------------------- /cores/opencpu/api/arch/sys_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __ARCH_SYS_ARCH_H__ 33 | #define __ARCH_SYS_ARCH_H__ 34 | 35 | #include "FreeRTOS.h" 36 | #include "task.h" 37 | #include "queue.h" 38 | #include "semphr.h" 39 | 40 | #define SYS_MBOX_NULL ( ( QueueHandle_t ) NULL ) 41 | #define SYS_SEM_NULL ( ( SemaphoreHandle_t ) NULL ) 42 | #define SYS_DEFAULT_THREAD_STACK_DEPTH configMINIMAL_STACK_SIZE 43 | 44 | typedef SemaphoreHandle_t sys_sem_t; 45 | typedef SemaphoreHandle_t sys_mutex_t; 46 | typedef QueueHandle_t sys_mbox_t; 47 | typedef TaskHandle_t sys_thread_t; 48 | 49 | #define sys_mbox_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) 50 | #define sys_mbox_set_invalid( x ) ( ( *x ) = NULL ) 51 | #define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) 52 | #define sys_sem_set_invalid( x ) ( ( *x ) = NULL ) 53 | 54 | 55 | #endif /* __ARCH_SYS_ARCH_H__ */ 56 | 57 | -------------------------------------------------------------------------------- /cores/opencpu/api/lwip/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_HDR_DEBUG_H 33 | #define LWIP_HDR_DEBUG_H 34 | 35 | #include "lwip/arch.h" 36 | #include "lwip/opt.h" 37 | 38 | /** lower two bits indicate debug level 39 | * - 0 all 40 | * - 1 warning 41 | * - 2 serious 42 | * - 3 severe 43 | */ 44 | #define LWIP_DBG_LEVEL_ALL 0x00 45 | #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ 46 | #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ 47 | #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ 48 | #define LWIP_DBG_LEVEL_SEVERE 0x03 49 | #define LWIP_DBG_MASK_LEVEL 0x03 50 | 51 | /** flag for LWIP_DEBUGF to enable that debug message */ 52 | #define LWIP_DBG_ON 0x80U 53 | /** flag for LWIP_DEBUGF to disable that debug message */ 54 | #define LWIP_DBG_OFF 0x00U 55 | 56 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 57 | #define LWIP_DBG_TRACE 0x40U 58 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 59 | #define LWIP_DBG_STATE 0x20U 60 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 61 | #define LWIP_DBG_FRESH 0x10U 62 | /** flag for LWIP_DEBUGF to halt after printing this debug message */ 63 | #define LWIP_DBG_HALT 0x08U 64 | 65 | /** 66 | * LWIP_NOASSERT: Disable LWIP_ASSERT checks. 67 | * -- To disable assertions define LWIP_NOASSERT in arch/cc.h. 68 | */ 69 | 70 | #endif /* LWIP_HDR_DEBUG_H */ 71 | 72 | -------------------------------------------------------------------------------- /cores/opencpu/api/lwip/dhcp6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * IPv6 address autoconfiguration as per RFC 4862. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * IPv6 address autoconfiguration as per RFC 4862. 38 | * 39 | * Please coordinate changes and requests with Ivan Delamer 40 | * 41 | */ 42 | 43 | #ifndef LWIP_HDR_IP6_DHCP6_H 44 | #define LWIP_HDR_IP6_DHCP6_H 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_IPV6_DHCP6 /* don't build if not configured for use in lwipopts.h */ 49 | 50 | 51 | struct dhcp6 52 | { 53 | /*TODO: implement DHCP6*/ 54 | }; 55 | 56 | #endif /* LWIP_IPV6_DHCP6 */ 57 | 58 | #endif /* LWIP_HDR_IP6_DHCP6_H */ 59 | -------------------------------------------------------------------------------- /cores/opencpu/api/lwip/err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_HDR_ERR_H 33 | #define LWIP_HDR_ERR_H 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/arch.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** Define LWIP_ERR_T in cc.h if you want to use 43 | * a different type for your platform (must be signed). */ 44 | #ifdef LWIP_ERR_T 45 | typedef LWIP_ERR_T err_t; 46 | #else /* LWIP_ERR_T */ 47 | typedef s8_t err_t; 48 | #endif /* LWIP_ERR_T*/ 49 | 50 | /* Definitions for error constants. */ 51 | 52 | #define ERR_OK 0 /* No error, everything OK. */ 53 | #define ERR_MEM -1 /* Out of memory error. */ 54 | #define ERR_BUF -2 /* Buffer error. */ 55 | #define ERR_TIMEOUT -3 /* Timeout. */ 56 | #define ERR_RTE -4 /* Routing problem. */ 57 | #define ERR_INPROGRESS -5 /* Operation in progress */ 58 | #define ERR_VAL -6 /* Illegal value. */ 59 | #define ERR_WOULDBLOCK -7 /* Operation would block. */ 60 | #define ERR_USE -8 /* Address in use. */ 61 | #define ERR_ALREADY -9 /* Already connecting. */ 62 | #define ERR_ISCONN -10 /* Conn already established.*/ 63 | 64 | #define ERR_CONN -11 /* Not connected. */ 65 | #define ERR_IS_FATAL(e) ((e) < ERR_CONN) 66 | 67 | #define ERR_ABRT -12 /* Connection aborted. */ 68 | #define ERR_RST -13 /* Connection reset. */ 69 | #define ERR_CLSD -14 /* Connection closed. */ 70 | 71 | #define ERR_ARG -15 /* Illegal argument. */ 72 | 73 | #define ERR_IF -16 /* Low-level netif error */ 74 | 75 | 76 | #ifdef LWIP_DEBUG 77 | extern const char *lwip_strerr(err_t err); 78 | #else 79 | #define lwip_strerr(x) "" 80 | #endif /* LWIP_DEBUG */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* LWIP_HDR_ERR_H */ 87 | -------------------------------------------------------------------------------- /cores/opencpu/api/lwip/ethip6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Ethernet output for IPv6. Uses ND tables for link-layer addressing. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_ETHIP6_H 43 | #define LWIP_HDR_ETHIP6_H 44 | 45 | #include "lwip/opt.h" 46 | 47 | #if LWIP_IPV6 && LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ 48 | 49 | #include "lwip/pbuf.h" 50 | #include "lwip/ip6.h" 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/netif.h" 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | 60 | err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* LWIP_IPV6 && LWIP_ETHERNET */ 67 | 68 | #endif /* LWIP_HDR_ETHIP6_H */ 69 | -------------------------------------------------------------------------------- /cores/opencpu/api/lwip/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_HDR_INIT_H 33 | #define LWIP_HDR_INIT_H 34 | 35 | #include "lwip/opt.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** X.x.x: Major version of the stack */ 42 | #define LWIP_VERSION_MAJOR 1U 43 | /** x.X.x: Minor version of the stack */ 44 | #define LWIP_VERSION_MINOR 5U 45 | /** x.x.X: Revision of the stack */ 46 | #define LWIP_VERSION_REVISION 0U 47 | /** For release candidates, this is set to 1..254 48 | * For official releases, this is set to 255 (LWIP_RC_RELEASE) 49 | * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ 50 | #define LWIP_VERSION_RC 0U 51 | 52 | /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ 53 | #define LWIP_RC_RELEASE 255U 54 | /** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for Git versions */ 55 | #define LWIP_RC_DEVELOPMENT 0U 56 | 57 | #define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) 58 | #define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) 59 | #define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) 60 | 61 | /** Provides the version of the stack */ 62 | #define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ 63 | LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) 64 | 65 | /* Modules initialization */ 66 | void lwip_init(void); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* LWIP_HDR_INIT_H */ 73 | -------------------------------------------------------------------------------- /cores/opencpu/api/lwip/ip_frag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Jani Monoses 30 | * 31 | */ 32 | 33 | #ifndef LWIP_HDR_IP_FRAG_H 34 | #define LWIP_HDR_IP_FRAG_H 35 | 36 | #include "lwip/opt.h" 37 | #include "lwip/err.h" 38 | #include "lwip/pbuf.h" 39 | #include "lwip/netif.h" 40 | #include "lwip/ip_addr.h" 41 | #include "lwip/ip.h" 42 | 43 | #if LWIP_IPV4 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #if IP_REASSEMBLY 50 | /* The IP reassembly timer interval in milliseconds. */ 51 | #define IP_TMR_INTERVAL 1000 52 | 53 | /* IP reassembly helper struct. 54 | * This is exported because memp needs to know the size. 55 | */ 56 | struct ip_reassdata { 57 | struct ip_reassdata *next; 58 | struct pbuf *p; 59 | struct ip_hdr iphdr; 60 | u16_t datagram_len; 61 | u8_t flags; 62 | u8_t timer; 63 | }; 64 | 65 | void ip_reass_init(void); 66 | void ip_reass_tmr(void); 67 | struct pbuf * ip4_reass(struct pbuf *p); 68 | #endif /* IP_REASSEMBLY */ 69 | 70 | #if IP_FRAG 71 | #if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF 72 | /** A custom pbuf that holds a reference to another pbuf, which is freed 73 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 74 | * that points into the original pbuf. */ 75 | #ifndef LWIP_PBUF_CUSTOM_REF_DEFINED 76 | #define LWIP_PBUF_CUSTOM_REF_DEFINED 77 | struct pbuf_custom_ref { 78 | /** 'base class' */ 79 | struct pbuf_custom pc; 80 | /** pointer to the original pbuf that is referenced */ 81 | struct pbuf *original; 82 | }; 83 | #endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */ 84 | #endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ 85 | 86 | err_t ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest); 87 | #endif /* IP_FRAG */ 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif /* LWIP_IPV4 */ 94 | 95 | #endif /* LWIP_HDR_IP_FRAG_H */ 96 | -------------------------------------------------------------------------------- /cores/opencpu/api/lwip/mld6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Multicast listener discovery for IPv6. Aims to be compliant with RFC 2710. 5 | * No support for MLDv2. 6 | */ 7 | 8 | /* 9 | * Copyright (c) 2010 Inico Technologies Ltd. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. The name of the author may not be used to endorse or promote products 21 | * derived from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | * 34 | * This file is part of the lwIP TCP/IP stack. 35 | * 36 | * Author: Ivan Delamer 37 | * 38 | * 39 | * Please coordinate changes and requests with Ivan Delamer 40 | * 41 | */ 42 | 43 | #ifndef LWIP_HDR_MLD6_H 44 | #define LWIP_HDR_MLD6_H 45 | 46 | #include "lwip/opt.h" 47 | 48 | #if LWIP_IPV6_MLD && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 49 | 50 | #include "lwip/pbuf.h" 51 | #include "lwip/netif.h" 52 | 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | struct mld_group { 59 | /** next link */ 60 | struct mld_group *next; 61 | /** interface on which the group is active */ 62 | struct netif *netif; 63 | /** multicast address */ 64 | ip6_addr_t group_address; 65 | /** signifies we were the last person to report */ 66 | u8_t last_reporter_flag; 67 | /** current state of the group */ 68 | u8_t group_state; 69 | /** timer for reporting */ 70 | u16_t timer; 71 | /** counter of simultaneous uses */ 72 | u8_t use; 73 | }; 74 | 75 | /** Multicast listener report/query/done message header. */ 76 | #ifdef PACK_STRUCT_USE_INCLUDES 77 | # include "arch/bpstruct.h" 78 | #endif 79 | PACK_STRUCT_BEGIN 80 | struct mld_header { 81 | PACK_STRUCT_FLD_8(u8_t type); 82 | PACK_STRUCT_FLD_8(u8_t code); 83 | PACK_STRUCT_FIELD(u16_t chksum); 84 | PACK_STRUCT_FIELD(u16_t max_resp_delay); 85 | PACK_STRUCT_FIELD(u16_t reserved); 86 | PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address); 87 | /* Options follow. */ 88 | } PACK_STRUCT_STRUCT; 89 | PACK_STRUCT_END 90 | #ifdef PACK_STRUCT_USE_INCLUDES 91 | # include "arch/epstruct.h" 92 | #endif 93 | 94 | #define MLD6_TMR_INTERVAL 100 /* Milliseconds */ 95 | 96 | /* MAC Filter Actions, these are passed to a netif's 97 | * mld_mac_filter callback function. */ 98 | #define MLD6_DEL_MAC_FILTER 0 99 | #define MLD6_ADD_MAC_FILTER 1 100 | 101 | 102 | err_t mld6_stop(struct netif *netif); 103 | void mld6_report_groups(struct netif *netif); 104 | void mld6_tmr(void); 105 | struct mld_group *mld6_lookfor_group(struct netif *ifp, const ip6_addr_t *addr); 106 | void mld6_input(struct pbuf *p, struct netif *inp); 107 | err_t mld6_joingroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); 108 | err_t mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); 109 | 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* LWIP_IPV6_MLD && LWIP_IPV6 */ 116 | 117 | #endif /* LWIP_HDR_MLD6_H */ 118 | -------------------------------------------------------------------------------- /cores/opencpu/api/lwip/timers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * Simon Goldschmidt 31 | * 32 | */ 33 | #ifndef LWIP_HDR_TIMERS_H 34 | #define LWIP_HDR_TIMERS_H 35 | 36 | #include "lwip/opt.h" 37 | 38 | /* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */ 39 | #define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) 40 | 41 | #if LWIP_TIMERS 42 | 43 | #include "lwip/err.h" 44 | #if !NO_SYS 45 | #include "lwip/sys.h" 46 | #endif 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | #ifndef LWIP_DEBUG_TIMERNAMES 53 | #ifdef LWIP_DEBUG 54 | #define LWIP_DEBUG_TIMERNAMES SYS_DEBUG 55 | #else /* LWIP_DEBUG */ 56 | #define LWIP_DEBUG_TIMERNAMES 0 57 | #endif /* LWIP_DEBUG*/ 58 | #endif 59 | 60 | /** Function prototype for a timeout callback function. Register such a function 61 | * using sys_timeout(). 62 | * 63 | * @param arg Additional argument to pass to the function - set up by sys_timeout() 64 | */ 65 | typedef void (* sys_timeout_handler)(void *arg); 66 | 67 | struct sys_timeo { 68 | struct sys_timeo *next; 69 | u32_t time; 70 | sys_timeout_handler h; 71 | void *arg; 72 | #if LWIP_DEBUG_TIMERNAMES 73 | const char* handler_name; 74 | #endif /* LWIP_DEBUG_TIMERNAMES */ 75 | }; 76 | 77 | void sys_timeouts_init(void); 78 | 79 | #if LWIP_DEBUG_TIMERNAMES 80 | void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); 81 | #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) 82 | #else /* LWIP_DEBUG_TIMERNAMES */ 83 | void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); 84 | #endif /* LWIP_DEBUG_TIMERNAMES */ 85 | 86 | void sys_untimeout(sys_timeout_handler handler, void *arg); 87 | #if NO_SYS 88 | void sys_check_timeouts(void); 89 | void sys_restart_timeouts(void); 90 | u32_t sys_timeouts_sleeptime(void); 91 | #else /* NO_SYS */ 92 | void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); 93 | #endif /* NO_SYS */ 94 | void sys_timeout_add(struct sys_timeo *timeout); 95 | 96 | void ip_reass_timer_needed(void); 97 | 98 | #if LWIP_IPV6 99 | void ip6_nd_timer_needed(void); 100 | #if LWIP_IPV6_REASS 101 | void ip6_reass_timer_needed(void); 102 | #endif 103 | #endif 104 | 105 | void dns_timer_needed(void); 106 | 107 | void dhcp_timer_needed(void); 108 | 109 | void arp_timer_needed(void); 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* LWIP_TIMERS */ 116 | #endif /* LWIP_HDR_TIMERS_H */ 117 | -------------------------------------------------------------------------------- /cores/opencpu/arduino_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - arduino_main 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | extern void initVariant(); 25 | extern void setup(); 26 | extern void loop(); 27 | 28 | static struct 29 | { 30 | uint32_t wait; 31 | TaskHandle_t taskHandle; 32 | ST_MSG msg; 33 | } arduino = {10 /* default task wait */, 0, {0, 0, 0, 0}}; 34 | 35 | void arduinoSetWait(u32 wait) 36 | { 37 | arduino.wait = wait == 0 ? 1 : wait; 38 | } 39 | 40 | static inline void arduinoDispatchMessages(void) 41 | { 42 | switch (arduino.msg.message) 43 | { 44 | case MSG_ID_URC_INDICATION: 45 | Dev.m_Urc(arduino.msg.param1, arduino.msg.param2); 46 | break; 47 | default: 48 | Dev.m_Message(&arduino.msg); 49 | break; 50 | } 51 | } 52 | 53 | extern "C" int api_get_message(ST_MSG *msg); 54 | void arduinoProcessMessages(unsigned int wait) 55 | { 56 | u32 id = Ql_OS_GetActiveTaskId(); 57 | if (ARDUINO_TASK_ID == id) 58 | { 59 | #if 0 60 | Ql_OS_GetMessage(&arduino.msg); // there is always more than zero 61 | Ql_OS_SendMessage(id, MSG_PROCESS_MESSAGES, 0, 0); // send one message 62 | #else 63 | if (0 == api_get_message(&arduino.msg)) // Plan B, get without wait 64 | #endif 65 | arduinoDispatchMessages(); 66 | } 67 | Ql_Sleep(wait); 68 | } 69 | 70 | void delayEx(unsigned int ms) 71 | { 72 | #define BLOCK_TIME 100 73 | unsigned int count = ms / BLOCK_TIME; 74 | while (count--) 75 | arduinoProcessMessages(BLOCK_TIME); // step 76 | arduinoProcessMessages(ms % BLOCK_TIME); // remain 77 | } 78 | 79 | /// Arduino Task 80 | extern "C" void proc_arduino(int taskId) 81 | { 82 | arduino.taskHandle = xTaskGetCurrentTaskHandle(); 83 | vTaskSuspend(arduino.taskHandle); // wait ril ready 84 | initVariant(); 85 | #if 0 86 | Ql_OS_SendMessage(taskId, MSG_PROCESS_MESSAGES, 0, 0); // dont touch 87 | #endif 88 | arduinoProcessMessages(arduino.wait); 89 | setup(); 90 | while (true) 91 | { 92 | arduinoProcessMessages(arduino.wait); 93 | loop(); 94 | } 95 | } 96 | 97 | /// Main Task 98 | extern "C" void proc_main_task(int taskId) 99 | { 100 | if (api_check_api()) 101 | { 102 | Ql_Debug_Trace("[M] ERROR Firmware not support\n"); 103 | abort(); 104 | } 105 | __libc_init_array(); 106 | entry_main(taskId); // if function exist - OpenCPU style 107 | ST_MSG m; 108 | while (true) 109 | { 110 | Ql_OS_GetMessage(&m); 111 | switch (m.message) 112 | { 113 | case MSG_ID_RIL_READY: 114 | Ql_RIL_Initialize(); 115 | vTaskResume(arduino.taskHandle); // enable arduino 116 | break; 117 | case MSG_ID_URC_INDICATION: 118 | if (m.message > URC_CFUN_STATE_IND) // ignore first urc-s 119 | Ql_OS_SendMessage(ARDUINO_TASK_ID, m.message, m.param1, m.param2); // re-send to arduino task 120 | break; 121 | default: 122 | Ql_OS_SendMessage(ARDUINO_TASK_ID, m.message, m.param1, m.param2); // re-send to arduino task 123 | break; 124 | } 125 | } 126 | } 127 | 128 | -------------------------------------------------------------------------------- /cores/opencpu/cbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | cbuf.h - Circular buffer implementation 3 | Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. 4 | This file is part of the esp8266 core for Arduino environment. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef __cbuf_h 22 | #define __cbuf_h 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | class cbuf 29 | { 30 | public: 31 | cbuf(size_t size); 32 | ~cbuf(); 33 | 34 | size_t resizeAdd(size_t addSize); 35 | size_t resize(size_t newSize); 36 | size_t available() const; 37 | size_t size(); 38 | 39 | size_t room() const; 40 | 41 | inline bool empty() const 42 | { 43 | return _begin == _end; 44 | } 45 | 46 | inline bool full() const 47 | { 48 | return wrap_if_bufend(_end + 1) == _begin; 49 | } 50 | 51 | int peek(); 52 | size_t peek(char *dst, size_t size); 53 | 54 | int read(); 55 | size_t read(char* dst, size_t size); 56 | 57 | size_t write(char c); 58 | size_t write(const char* src, size_t size); 59 | 60 | void flush(); 61 | size_t remove(size_t size); 62 | 63 | cbuf *next; 64 | 65 | private: 66 | inline char* wrap_if_bufend(char* ptr) const 67 | { 68 | return (ptr == _bufend) ? _buf : ptr; 69 | } 70 | 71 | size_t _size; 72 | char* _buf; 73 | const char* _bufend; 74 | char* _begin; 75 | char* _end; 76 | 77 | }; 78 | 79 | #endif//__cbuf_h -------------------------------------------------------------------------------- /cores/opencpu/constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_CONSTANTS_ 20 | #define _WIRING_CONSTANTS_ 21 | 22 | #ifdef __cplusplus 23 | extern "C"{ 24 | #endif // __cplusplus 25 | 26 | #include 27 | 28 | #define LOW (0x0) 29 | #define HIGH (0x1) 30 | 31 | #define CLOSE (0xFF) 32 | #define INPUT (0) 33 | #define INPUT_PULLUP (1<<1) 34 | #define INPUT_PULLDOWN (1<<2) 35 | #define OUTPUT (1<<3) 36 | #define OUTPUT_LO (1<<4) 37 | #define OUTPUT_HI (1<<5) 38 | 39 | #define CHANGE (0x2) 40 | #define FALLING (0x3) 41 | #define RISING (0x4) 42 | 43 | #define DEFAULT (0x1) 44 | #define EXTERNAL (0x0) 45 | 46 | enum BitOrder { 47 | LSBFIRST = 0, 48 | MSBFIRST = 1 49 | }; 50 | 51 | typedef bool boolean; 52 | typedef uint8_t byte; 53 | typedef uint16_t word; 54 | 55 | #define PI 3.1415926535897932384626433832795 56 | #define HALF_PI 1.5707963267948966192313216916398 57 | #define TWO_PI 6.283185307179586476925286766559 58 | #define DEG_TO_RAD 0.017453292519943295769236907684886 59 | #define RAD_TO_DEG 57.295779513082320876798154814105 60 | #define EULER 2.718281828459045235360287471352 61 | 62 | 63 | #ifdef abs 64 | #undef abs 65 | #endif 66 | #define abs(x) ((x)>0?(x):-(x)) 67 | 68 | #define min(a,b) ((a)<(b)?(a):(b)) 69 | #define max(a,b) ((a)>(b)?(a):(b)) 70 | 71 | #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) 72 | 73 | //#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) 74 | #define radians(deg) ((deg)*DEG_TO_RAD) 75 | #define degrees(rad) ((rad)*RAD_TO_DEG) 76 | #define sq(x) ((x)*(x)) 77 | 78 | 79 | #define lowByte(w) ((uint8_t) ((w) & 0xff)) 80 | #define highByte(w) ((uint8_t) ((w) >> 8)) 81 | 82 | #define bit(b) (1UL << (b)) 83 | 84 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01) 85 | #define bitSet(value, bit) ((value) |= (1UL << (bit))) 86 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) 87 | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) 88 | 89 | #ifndef _NOP 90 | #define _NOP() do { __asm__ volatile ("nop"); } while (0) 91 | #endif 92 | 93 | #ifdef __cplusplus 94 | } // extern "C" 95 | #endif // __cplusplus 96 | 97 | #endif /* _WIRING_CONSTANTS_ */ -------------------------------------------------------------------------------- /cores/opencpu/cpp_bc66.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | ROM (rx) : ORIGIN = 0x08292040, LENGTH = 0x00032000 4 | RAM (rwx) : ORIGIN = 0x001E7000, LENGTH = 0x00019000 5 | RETSRAM (rwx) : ORIGIN = 0x4301F00, LENGTH = 256 6 | } 7 | 8 | SECTIONS 9 | { 10 | . = 0x08292040; 11 | .initdata : 12 | { 13 | . = ALIGN(4); 14 | KEEP(*(.initdata)); 15 | }AT > ROM 16 | 17 | text : 18 | { 19 | . = ALIGN(4); 20 | PROVIDE_HIDDEN (__preinit_array_start = .); 21 | KEEP( *(SORT(.preinit_array.*)) ) 22 | KEEP( *(.preinit_init_array*) ) 23 | PROVIDE_HIDDEN (__preinit_array_end = .); 24 | 25 | PROVIDE_HIDDEN (__init_array_start = .); 26 | KEEP( *(SORT(.init_array.*)) ) 27 | KEEP( *(.init_array*) ) 28 | PROVIDE_HIDDEN (__init_array_end = .); 29 | 30 | PROVIDE_HIDDEN (__fini_array_start = .); 31 | KEEP( *(SORT(.fini_array.*)) ) 32 | KEEP( *(.fini_array*) ) 33 | PROVIDE_HIDDEN (__fini_array_end = .); 34 | 35 | . = ALIGN(4); 36 | *( .text .text.* i.* ) 37 | *( .glue_7t ) 38 | *( .glue_7 ) 39 | *( .ctors ) 40 | *( .dtors ) 41 | *( .gnu.linkonce.t.* ) 42 | *( .gnu.linkonce.r.* ) 43 | *( .gcc_except_table ) 44 | *( .rodata .rodata* .constdata* .conststring* ) 45 | *(.note.gnu.build-id) 46 | 47 | } AT > ROM 48 | .ARM.exidx : 49 | { 50 | __exidx_start = .; 51 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 52 | __exidx_end = .; 53 | } AT > ROM 54 | 55 | .rodata : 56 | { 57 | . = ALIGN(4); 58 | *(.rodata) 59 | }AT > ROM 60 | __data_load = LOADADDR(.data); 61 | .data : 62 | { 63 | __data_start = .; 64 | . = ALIGN(4); 65 | *(.data.*) 66 | *(.data) 67 | _edata = .; 68 | } > RAM AT > ROM 69 | .bss : 70 | { 71 | __bss_start__ = .; 72 | . = ALIGN(4); 73 | *(.bss) 74 | *(.bss.*) 75 | __bss_end__ = .; 76 | } > RAM 77 | 78 | .sram (NOLOAD) : { *(.sram) } > RETSRAM 79 | } -------------------------------------------------------------------------------- /cores/opencpu/custom_config.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * sys_config.c 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * The file is for some common system definition. Developer don't have to 23 | * care. 24 | * 25 | * Author: 26 | * ------- 27 | * ------- 28 | * 29 | *============================================================================ 30 | * HISTORY 31 | *---------------------------------------------------------------------------- 32 | * 33 | ****************************************************************************/ 34 | #include "custom_feature_def.h" 35 | #include "ql_type.h" 36 | #include "ril.h" 37 | #include "ql_system.h" 38 | #include "custom_heap_cfg.h" 39 | 40 | #define DEFAULT_VALUE1 (200) 41 | #define DEFAULT_VALUE2 (30) 42 | 43 | 44 | //const u32 HeapMemSize = HEAP_MEMSIZE; 45 | //u8 OpenCPUHeapSpace[HEAP_MEMSIZE]; 46 | 47 | 48 | /* 49 | *-------------------------- 50 | * Task Configuration 51 | *-------------------------- 52 | * TaskStackSize: 53 | * The stack size of task. Range from 1K to 10K. 54 | * If there are any file operations to do in task, 55 | * the stack size of this task must be set to at least 4K. 56 | *****************************************************************/ 57 | 58 | #ifdef TASK_ID_DEF 59 | #undef TASK_ID_DEF 60 | #endif 61 | #ifdef TASK_DEFINITION 62 | #undef TASK_DEFINITION 63 | #endif 64 | #define TASK_FUNC_DECLARATION 65 | #include "ql_common.h" 66 | TASK_DEFINITION_BEGIN 67 | #include "custom_task_cfg.h" 68 | TASK_DEFINITION_END 69 | #undef TASK_FUNC_DECLARATION 70 | 71 | 72 | 73 | #ifdef TASK_FUNC_DECLARATION 74 | #undef TASK_FUNC_DECLARATION 75 | #endif 76 | #ifdef TASK_ID_DEF 77 | #undef TASK_ID_DEF 78 | #endif 79 | #define TASK_DEFINITION 80 | #include "ql_common.h" 81 | TASK_DEFINITION_BEGIN 82 | #include "custom_task_cfg.h" 83 | TASK_DEFINITION_END 84 | #undef TASK_DEFINITION 85 | 86 | 87 | 88 | #define GPIO_DEFINITION 89 | #include "ql_common.h" 90 | GPIO_DEFINITION_BEGIN 91 | #include "custom_gpio_cfg.h" 92 | GPIO_DEFINITION_END 93 | #undef GPIO_DEFINITION 94 | -------------------------------------------------------------------------------- /cores/opencpu/custom_feature_def.h: -------------------------------------------------------------------------------- 1 | #ifndef __CUSTOM_FEATURE_DEF_H__ 2 | #define __CUSTOM_FEATURE_DEF_H__ 3 | 4 | /************************************************************************ 5 | * RIL Function on/off 6 | ************************************************************************/ 7 | #define __OCPU_RIL_SUPPORT__ 8 | 9 | 10 | #endif //__CUSTOM_FEATURE_DEF_H__ 11 | -------------------------------------------------------------------------------- /cores/opencpu/custom_gpio_cfg.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * custom_gpio_cfg.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * The file intends for GPIO initialization definition. 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | #ifndef __CUSTOM_GPIO_CFG_H__ 34 | #define __CUSTOM_GPIO_CFG_H__ 35 | 36 | /*======================================================================== 37 | | 38 | | GPIO initialization configurations. 39 | |------------------------------------ 40 | | IMPORTANT NOTES: 41 | |------------------ 42 | | 43 | | This is the initialization list for GPIOs at the early of module booting. 44 | | Developer can do configuring here if some GPIOs need to be initialized at 45 | | the early booting. For example, some GPIO is used to control the power 46 | | supply of peripheral. 47 | | 48 | | Besides this config list, developer may call Ql_GPIO_Init() to initialize 49 | | the parameters of I/O interfaces dynamically. But it's later than the 50 | | previous method on time sequence. 51 | \=========================================================================*/ 52 | /*---------------------------------------------------------------------------------------------- 53 | { Pin Name | Direction | Level | Pull Selection } 54 | *---------------------------------------------------------------------------------------------*/ 55 | 56 | 57 | 58 | 59 | #if 0 // If needed, config GPIOs here 60 | GPIO_ITEM(PINNAME_SPI_MISO, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 61 | GPIO_ITEM(PINNAME_SPI_MOSI, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 62 | GPIO_ITEM(PINNAME_SPI_SCLK, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 63 | GPIO_ITEM(PINNAME_SPI_CS, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 64 | GPIO_ITEM(PINNAME_NETLIGHT, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 65 | GPIO_ITEM(PINNAME_RI, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 66 | GPIO_ITEM(PINNAME_DCD, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 67 | GPIO_ITEM(PINNAME_CTS_AUX, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 68 | GPIO_ITEM(PINNAME_RTS_AUX, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 69 | GPIO_ITEM(PINNAME_GPIO1, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 70 | GPIO_ITEM(PINNAME_RXD_AUX, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 71 | GPIO_ITEM(PINNAME_TXD_AUX, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 72 | GPIO_ITEM(PINNAME_GPIO2, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 73 | GPIO_ITEM(PINNAME_GPIO3, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 74 | GPIO_ITEM(PINNAME_GPIO4, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 75 | GPIO_ITEM(PINNAME_GPIO5, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 76 | GPIO_ITEM(PINNAME_RXD_DBG, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 77 | GPIO_ITEM(PINNAME_TXD_DBG, PINDIRECTION_OUT, PINLEVEL_LOW, PINPULLSEL_PULLUP) 78 | 79 | #endif 80 | 81 | #endif //__CUSTOM_GPIO_CFG_H__ 82 | -------------------------------------------------------------------------------- /cores/opencpu/custom_heap_cfg.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * custom_heap_cfg.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * The file intends for heap space definition of OpenCPU application. 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | #ifndef __CUSTOM_HEAP_CFG_H__ 34 | #define __CUSTOM_HEAP_CFG_H__ 35 | 36 | /*======================================================================== 37 | | 38 | | Heap Configuration. 39 | |------------------ 40 | | Predefine a block of memory, and the o.s will allocate the memory from 41 | | the predefined memory when calling Ql_MEM_Alloc(). 42 | | Min value is 1, and max value depends one the max memory available. 43 | | Unit in byte. 44 | \=========================================================================*/ 45 | /*======================================================================== 46 | | 47 | | Note. 48 | |------------------ 49 | | This method is no longer used On the new platform,the o.s will allocate 50 | | the memory from the system memory when calling Ql_MEM_Alloc(). 51 | | The size of the "system memory about 300KB. 52 | | Unit in byte. 53 | \=========================================================================*/ 54 | 55 | //#define HEAP_MEMSIZE (300 * 1024) 56 | 57 | #endif //__CUSTOM_HEAP_CFG_H__ 58 | -------------------------------------------------------------------------------- /cores/opencpu/custom_task_cfg.h: -------------------------------------------------------------------------------- 1 | 2 | TASK_ITEM(proc_main_task, main_task_id, 10*1024, DEFAULT_VALUE1, DEFAULT_VALUE2) 3 | TASK_ITEM(proc_reserved1, reserved1_id, 5*1024, DEFAULT_VALUE1, DEFAULT_VALUE2) 4 | TASK_ITEM(proc_reserved2, reserved2_id, 5*1024, DEFAULT_VALUE1, DEFAULT_VALUE2) 5 | TASK_ITEM(proc_arduino, subtask1_id, 10*1024, DEFAULT_VALUE1, DEFAULT_VALUE2) 6 | 7 | -------------------------------------------------------------------------------- /cores/opencpu/dbg.c: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - debug 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "ql_stdlib.h" 22 | #include "ql_uart.h" 23 | #include "dbg.h" 24 | #include "api.h" 25 | 26 | static Enum_SerialPort debugPort = UART_PORT_END; 27 | static u32 debugMutex = 0; 28 | 29 | void debug_enable(unsigned long port) 30 | { 31 | if (0 == debugMutex) 32 | debugMutex = Ql_OS_CreateMutex(); 33 | debugPort = (Enum_SerialPort)port; 34 | } 35 | 36 | void debug_disable(void) 37 | { 38 | debugPort = (Enum_SerialPort)UART_PORT_END; 39 | } 40 | 41 | #ifdef ENABLE_DEBUG 42 | 43 | static char bufferDebug[1024]; 44 | 45 | int log_printf(const char *frm, ...) 46 | { 47 | if (0 == debugMutex || debugPort > UART_PORT2) 48 | return 0; 49 | va_list arg; 50 | va_start(arg, frm); 51 | if (debugMutex) 52 | Ql_OS_TakeMutex(debugMutex, -1); 53 | int n = vsnprintf(bufferDebug, sizeof(bufferDebug), frm, arg); 54 | va_end(arg); 55 | if (n > 0) 56 | n = Ql_UART_Write(debugPort, (u8 *)bufferDebug, n); 57 | if (debugMutex) 58 | Ql_OS_GiveMutex(debugMutex); 59 | return n; 60 | } 61 | 62 | void log_buf(const char *text, const unsigned char *buf, unsigned int len) 63 | { 64 | if (len > 512) 65 | len = 512; 66 | char bufferChar[17]; 67 | char bufferDump[512]; 68 | unsigned int i, idx = 0; 69 | memset(bufferDump, 0, sizeof(bufferDump)); 70 | Ql_snprintf(bufferDump + idx, sizeof(bufferDump) - idx, "[DMP] %s (%u bytes)\n", text, len); 71 | log_printf(bufferDump); 72 | idx = 0; 73 | Ql_memset(bufferChar, 0, sizeof(bufferChar)); 74 | for (i = 0; i < len; i++) 75 | { 76 | if (i >= 4096) 77 | break; 78 | if (i % 16 == 0) 79 | { 80 | if (i > 0) 81 | { 82 | Ql_snprintf(bufferDump + idx, sizeof(bufferDump) - idx, " %s\n", bufferChar); 83 | log_printf(bufferDump); 84 | idx = 0; 85 | Ql_memset(bufferChar, 0, sizeof(bufferChar)); 86 | } 87 | idx += Ql_snprintf(bufferDump + idx, sizeof(bufferDump) - idx, "%04X: ", (unsigned int)i); 88 | } 89 | idx += Ql_snprintf(bufferDump + idx, sizeof(bufferDump) - idx, " %02X", (unsigned int)buf[i]); 90 | bufferChar[i % 16] = (buf[i] > 31 && buf[i] < 127) ? buf[i] : '.'; 91 | } 92 | if (len > 0) 93 | { 94 | for (/* i = i */; i % 16 != 0; i++) 95 | idx += Ql_snprintf(bufferDump + idx, sizeof(bufferDump) - idx, " "); 96 | Ql_snprintf(bufferDump + idx, sizeof(bufferDump) - idx, " %s\n", bufferChar); 97 | log_printf(bufferDump); 98 | } 99 | } 100 | 101 | #endif -------------------------------------------------------------------------------- /cores/opencpu/dbg.h: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - debug 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef DBG_H_ 22 | #define DBG_H_ 23 | 24 | #define ENABLE_DEBUG 25 | #define ENABLE_TRACE 26 | 27 | void debug_enable(unsigned long port); 28 | void debug_disable(void); 29 | 30 | int log_printf(const char *frm, ...) __attribute__((weak)); 31 | void log_buf(const char *text, const unsigned char *buf, unsigned int len) __attribute__((weak)); 32 | 33 | #ifdef ENABLE_DEBUG 34 | # include "ql_trace.h" 35 | # define DBG(FORMAT, ...) log_printf(FORMAT, ##__VA_ARGS__) 36 | # define DMP(TEXT, BUFFER, LEN) log_buf(TEXT, (unsigned char *)BUFFER, LEN) 37 | 38 | # define LOG_E(FORMAT, ...) log_printf("[ERROR] " FORMAT "\n", ##__VA_ARGS__) 39 | # define LOG_V(FORMAT, ...) log_printf("[V] " FORMAT "\n", ##__VA_ARGS__) 40 | # define LOG_D(FORMAT, ...) log_printf("[D] " FORMAT "\n", ##__VA_ARGS__) 41 | # define LOG_I(FORMAT, ...) log_printf("[I] " FORMAT "\n", ##__VA_ARGS__) 42 | # define LOG_W(FORMAT, ...) log_printf("[W] " FORMAT "\n", ##__VA_ARGS__) 43 | 44 | #else 45 | # define DBG(FORMAT, ...) 46 | # define DMP(TEXT, BUFFER, LEN) 47 | 48 | # define LOG_E(FORMAT, ...) 49 | # define LOG_V(FORMAT, ...) 50 | # define LOG_D(FORMAT, ...) 51 | # define LOG_I(FORMAT, ...) 52 | # define LOG_W(FORMAT, ...) 53 | #endif 54 | 55 | #endif /* DBG_H_ */ 56 | -------------------------------------------------------------------------------- /cores/opencpu/dtostrf.c: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | 23 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { 24 | char fmt[20]; 25 | sprintf(fmt, "%%%d.%df", width, prec); 26 | sprintf(sout, fmt, val); 27 | return sout; 28 | } 29 | -------------------------------------------------------------------------------- /cores/opencpu/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef __DTOSTRF__ 22 | #define __DTOSTRF__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /cores/opencpu/include/ql_memory.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * ql_memory.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * Memory APIs defines. 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | 34 | 35 | #ifndef __QL_MEMORY_H__ 36 | #define __QL_MEMORY_H__ 37 | 38 | 39 | /***************************************************************** 40 | * Function: Ql_MEM_Alloc 41 | * 42 | * Description: 43 | * Allocates memory with the specified size in the memory heap. 44 | * Parameters: 45 | * Size: 46 | * [in]Number of bytes of memory to be allocated. 47 | * Return: 48 | * A pointer of void type to the allocated space. 49 | *****************************************************************/ 50 | void* Ql_MEM_Alloc (u32 size); 51 | 52 | /***************************************************************** 53 | * Function: Ql_MEM_Free 54 | * 55 | * Description: 56 | * Free memory 57 | * Parameters: 58 | * Ptr: 59 | * [in]Previously allocated memory block to be freed. 60 | * Return: 61 | * none 62 | * 63 | *****************************************************************/ 64 | void Ql_MEM_Free (void *ptr); 65 | 66 | #endif // End-of __QL_MEMORY_H__ 67 | 68 | -------------------------------------------------------------------------------- /cores/opencpu/include/ql_power.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * ql_power.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * Power APIs defines. 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | 34 | 35 | #ifndef __POWER_H__ 36 | #define __POWER_H__ 37 | #include "ql_type.h" 38 | 39 | /** @brief This enum defines the power on result. */ 40 | typedef enum { 41 | QL_DEEP_SLEEP = 1, /* deep sleep */ 42 | QL_SYS_RESET = 2, /* sys_reset */ 43 | QL_FORCED_SHUT_DOWN = 3, /* forced shut down */ 44 | QL_POWER_ON_RESULT_MAX = 3 45 | } Enum_Ql_Power_On_Result_t; 46 | 47 | /***************************************************************** 48 | * Function: Ql_SleepEnable 49 | * 50 | * Description: 51 | * Enable the module into deep sleep mode. 52 | * 53 | * Return: 54 | * QL_RET_OK indicates this function successes. 55 | * Ql_RET_NOT_SUPPORT this function not support. 56 | *****************************************************************/ 57 | s32 Ql_SleepEnable(void); 58 | 59 | /***************************************************************** 60 | * Function: Ql_SleepDisable 61 | * 62 | * Description: 63 | * Disable the module into deep sleep mode. 64 | * 65 | * Return: 66 | * QL_RET_OK indicates this function successes. 67 | * Ql_RET_NOT_SUPPORT this function not support. 68 | *****************************************************************/ 69 | s32 Ql_SleepDisable(void); 70 | 71 | 72 | /***************************************************************** 73 | * Function: Ql_GetPowerOnReason 74 | * 75 | * Description: 76 | * This function gets a reason for power on. 77 | * 78 | * Parameters: 79 | * None 80 | * 81 | * Return: 82 | * The reason of the Power on, one value of Enum_Ql_Power_On_Result_t. 83 | *****************************************************************/ 84 | s32 Ql_GetPowerOnReason(void); 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /cores/opencpu/include/ql_stdlib.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * ql_stdlib.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * this file provides some Standard library APIs 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | 34 | 35 | #ifndef __QL_STDLIB_H__ 36 | #define __QL_STDLIB_H__ 37 | #include "ql_type.h" 38 | 39 | s32 Ql_atoi(const char* s); 40 | double Ql_atof(const char* s); 41 | void* Ql_memset(void* dest, u8 value, u32 size); 42 | void* Ql_memcpy(void* dest, const void* src, u32 size); 43 | s32 Ql_memcmp(const void* dest, const void*src, u32 size); 44 | void* Ql_memmove(void* dest, const void* src, u32 size); 45 | char* Ql_strcpy(char* dest, const char* src); 46 | char* Ql_strncpy(char* dest, const char* src, u32 size); 47 | char* Ql_strcat(char* s1, const char* s2); 48 | char* Ql_strncat(char* s1, const char* s2, u32 size); 49 | s32 Ql_strcmp(const char*s1, const char*s2); 50 | s32 Ql_strncmp(const char* s1, const char* s2, u32 size); 51 | char* Ql_strchr(const char* s1, s32 ch); 52 | u32 Ql_strlen(const char* str); 53 | char* Ql_strstr(const char* s1, const char* s2); 54 | s32 Ql_toupper(s32 c); 55 | s32 Ql_tolower(s32 c); 56 | s32 Ql_isdigit(char c); 57 | extern s32 (*Ql_sprintf)(char *, const char *, ...); 58 | extern s32 (*Ql_snprintf)(char *, u32, const char *, ...); 59 | extern s32 (*Ql_sscanf)(const char*, const char*, ...); 60 | #endif // __QL_STDLIB_H__ 61 | -------------------------------------------------------------------------------- /cores/opencpu/include/ql_trace.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * ql_trace.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * debug trace API 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | 34 | 35 | #ifndef __QL_TRACE_H__ 36 | #define __QL_TRACE_H__ 37 | #include "ql_type.h" 38 | 39 | typedef enum { 40 | BASIC_MODE, /* In basic mode, debug messages from application will be 41 | output to debug serial port as text. 42 | */ 43 | ADVANCE_MODE /* Default mode. 44 | In advance mode, debug messages from System and application 45 | will be output to debug serial port in special format. Only 46 | the Catcher Tool can capture and display these debug messages 47 | legibly. 48 | */ 49 | } Enum_DebugMode; 50 | 51 | typedef enum{ 52 | PORTNAME_UART0, 53 | PORTNAME_UART1, 54 | PORTNAME_UART2, 55 | PORTNAME_UART3, 56 | PORTNAME_USB1, 57 | PORTNAME_USB2 58 | }Enum_PortName; 59 | 60 | /***************************************************************** 61 | * Function: Ql_Debug_Trace 62 | * 63 | * Description: 64 | * This function prints formatted output to 65 | * debug serial port. Its function is same to 'sprintf'. 66 | * 67 | * Parameters: 68 | * fmt: 69 | * Pointer to a null-terminated multibyte string 70 | * specifying how to interpret the data. 71 | * The maximum string length is 512 bytes. 72 | * Return: 73 | * Number of characters printed 74 | *****************************************************************/ 75 | extern s32 (*Ql_Debug_Trace)(const char* fmt, ...); // WizIO 76 | 77 | #endif // #end-of __QL_TRACE_H__ 78 | -------------------------------------------------------------------------------- /cores/opencpu/include/ql_type.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * ql_type.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * OpenCPU Type Definitions 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | 34 | 35 | #ifndef __QL_TYPE_H__ 36 | #define __QL_TYPE_H__ 37 | 38 | #ifndef FALSE 39 | #define FALSE 0 40 | #endif 41 | 42 | #ifndef TRUE 43 | #define TRUE 1 44 | #endif 45 | 46 | #ifndef NULL 47 | #define NULL ((void *) 0) 48 | #endif 49 | 50 | 51 | /**************************************************************************** 52 | * Type Definitions 53 | ***************************************************************************/ 54 | //typedef unsigned char bool; 55 | #include 56 | 57 | typedef unsigned char u8; 58 | typedef signed char s8; 59 | typedef unsigned short u16; 60 | typedef short s16; 61 | typedef unsigned int u32; 62 | typedef int s32; 63 | typedef unsigned long long u64; 64 | typedef long long s64; 65 | typedef unsigned int ticks; 66 | 67 | #endif // End-of __QL_TYPE_H__ 68 | -------------------------------------------------------------------------------- /cores/opencpu/interface.c: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - interface 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "interface.h" 22 | 23 | //////////////////////////////////////////////////////////////////////////// 24 | // CPP 25 | //////////////////////////////////////////////////////////////////////////// 26 | 27 | extern void (*__preinit_array_start[])(void) __attribute__((weak)); 28 | extern void (*__preinit_array_end[])(void) __attribute__((weak)); 29 | extern void (*__init_array_start[])(void) __attribute__((weak)); 30 | extern void (*__init_array_end[])(void) __attribute__((weak)); 31 | extern void (*__fini_array_start[])(void) __attribute__((weak)); 32 | extern void (*__fini_array_end[])(void) __attribute__((weak)); 33 | 34 | extern void _init(void) __attribute__((weak)); 35 | extern void _fini(void) __attribute__((weak)); 36 | 37 | void __libc_init_array(void) 38 | { 39 | size_t count; 40 | size_t i; 41 | count = __preinit_array_end - __preinit_array_start; 42 | for (i = 0; i < count; i++) 43 | __preinit_array_start[i](); 44 | _init(); 45 | count = __init_array_end - __init_array_start; 46 | for (i = 0; i < count; i++) 47 | __init_array_start[i](); 48 | } 49 | 50 | void __libc_fini_array(void) 51 | { 52 | size_t count; 53 | size_t i; 54 | count = __fini_array_end - __fini_array_start; 55 | for (i = count; i > 0; i--) 56 | __fini_array_start[i - 1](); 57 | _fini(); 58 | } 59 | 60 | extern void abort(void) 61 | { 62 | while (1) { 63 | Ql_Sleep(1000); 64 | } 65 | } 66 | 67 | void __cxa_finalize(void *handle) {} 68 | void __cxa_pure_virtual(void) 69 | { 70 | abort(); 71 | } 72 | 73 | void __cxa_deleted_virtual(void) 74 | { 75 | abort(); 76 | } 77 | 78 | //////////////////////////////////////////////////////////////////////////// 79 | // MEMORY 80 | //////////////////////////////////////////////////////////////////////////// 81 | 82 | extern void *malloc(size_t size) 83 | { 84 | return pvPortMalloc(size); 85 | } 86 | 87 | extern void free(void *p) 88 | { 89 | vPortFree(p); 90 | } 91 | 92 | extern void *calloc(size_t nelem, size_t elsize) 93 | { 94 | return pvPortCalloc(nelem, elsize); 95 | } 96 | 97 | extern void *realloc(void *mem, size_t newsize) 98 | { 99 | return pvPortRealloc(mem, newsize); 100 | } 101 | 102 | //////////////////////////////////////////////////////////////////////////// 103 | // OTHER 104 | //////////////////////////////////////////////////////////////////////////// 105 | 106 | int isAtEnd(char *line, u32 len) 107 | { 108 | if (Ql_RIL_FindLine(line, len, (char *)"OK")) 109 | return RIL_ATRSP_SUCCESS; 110 | if (Ql_RIL_FindLine(line, len, (char *)"ERROR")) 111 | return RIL_ATRSP_FAILED; 112 | return RIL_ATRSP_CONTINUE; 113 | } 114 | -------------------------------------------------------------------------------- /cores/opencpu/lib_BC66R01A04V01.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/cores/opencpu/lib_BC66R01A04V01.a -------------------------------------------------------------------------------- /cores/opencpu/lib_BC66R01A05V01.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/cores/opencpu/lib_BC66R01A05V01.a -------------------------------------------------------------------------------- /cores/opencpu/lib_app_start_bc66.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/cores/opencpu/lib_app_start_bc66.a -------------------------------------------------------------------------------- /cores/opencpu/new.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include 20 | 21 | void * operator new(size_t size) 22 | { 23 | return malloc(size); 24 | } 25 | 26 | void * operator new[](size_t size) 27 | { 28 | return malloc(size); 29 | } 30 | 31 | void operator delete(void *ptr) 32 | { 33 | free(ptr); 34 | } 35 | 36 | void operator delete[](void *ptr) 37 | { 38 | free(ptr); 39 | } 40 | -------------------------------------------------------------------------------- /cores/opencpu/new.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef NEW_H 20 | #define NEW_H 21 | 22 | #include 23 | 24 | void * operator new(size_t size); 25 | void * operator new[](size_t size); 26 | void operator delete(void * ptr); 27 | void operator delete[](void * ptr); 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /cores/opencpu/pgmspace.h: -------------------------------------------------------------------------------- 1 | /* 2 | pgmspace.h - Definitions for compatibility with AVR pgmspace macros 3 | 4 | Copyright (c) 2015 Arduino LLC 5 | 6 | Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE 25 | */ 26 | 27 | #ifndef __PGMSPACE_H_ 28 | #define __PGMSPACE_H_ 1 29 | 30 | #include 31 | 32 | #define PROGMEM 33 | #define PGM_P const char * 34 | #define PSTR(str) (str) 35 | 36 | #define _SFR_BYTE(n) (n) 37 | 38 | typedef void prog_void; 39 | typedef char prog_char; 40 | typedef unsigned char prog_uchar; 41 | typedef int8_t prog_int8_t; 42 | typedef uint8_t prog_uint8_t; 43 | typedef int16_t prog_int16_t; 44 | typedef uint16_t prog_uint16_t; 45 | typedef int32_t prog_int32_t; 46 | typedef uint32_t prog_uint32_t; 47 | typedef int64_t prog_int64_t; 48 | typedef uint64_t prog_uint64_t; 49 | 50 | typedef const void* int_farptr_t; 51 | typedef const void* uint_farptr_t; 52 | 53 | #define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) 54 | #define strcpy_P(dest, src) strcpy((dest), (src)) 55 | #define strncpy_P strncpy 56 | #define strcat_P(dest, src) strcat((dest), (src)) 57 | #define strcmp_P(a, b) strcmp((a), (b)) 58 | #define strstr_P(a, b) strstr((a), (b)) 59 | #define strlen_P(a) strlen((a)) 60 | #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) 61 | 62 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 63 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 64 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 65 | #define pgm_read_float(addr) (*(const float *)(addr)) 66 | #define pgm_read_ptr(addr) (*(const void *)(addr)) 67 | 68 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) 69 | #define pgm_read_word_near(addr) pgm_read_word(addr) 70 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 71 | #define pgm_read_float_near(addr) pgm_read_float(addr) 72 | #define pgm_read_ptr_near(addr) pgm_read_ptr(addr) 73 | 74 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) 75 | #define pgm_read_word_far(addr) pgm_read_word(addr) 76 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) 77 | #define pgm_read_float_far(addr) pgm_read_float(addr) 78 | #define pgm_read_ptr_far(addr) pgm_read_ptr(addr) 79 | 80 | #define pgm_get_far_address(addr) (&(addr)) 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /cores/opencpu/ril/inc/ril_network.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * ril_network.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * The file declares some API functions, which are related to network, including 23 | * SIM state, GSM/GPRS network state and signal strength, and so forth. 24 | * 25 | * Author: 26 | * ------- 27 | * ------- 28 | * 29 | *============================================================================ 30 | * HISTORY 31 | *---------------------------------------------------------------------------- 32 | * 33 | ****************************************************************************/ 34 | #ifndef __RIL_NETWORK_H__ 35 | #define __RIL_NETWORK_H__ 36 | #include "ql_type.h" 37 | 38 | /**************************************************************************** 39 | * Definition for SIM Card State 40 | ***************************************************************************/ 41 | typedef enum { 42 | SIM_STAT_NOT_INSERTED = 0, 43 | SIM_STAT_READY, 44 | SIM_STAT_PIN_REQ, 45 | SIM_STAT_PUK_REQ, 46 | SIM_STAT_PH_PIN_REQ, 47 | SIM_STAT_PH_PUK_REQ, 48 | SIM_STAT_PIN2_REQ, 49 | SIM_STAT_PUK2_REQ, 50 | SIM_STAT_BUSY, 51 | SIM_STAT_NOT_READY, 52 | SIM_STAT_UNSPECIFIED 53 | }Enum_SIMState; 54 | 55 | /**************************************************************************** 56 | * Definition for network State 57 | ***************************************************************************/ 58 | typedef enum { 59 | NW_STAT_NOT_REGISTERED = 0, // Not register to network 60 | NW_STAT_REGISTERED, // The normal network state 61 | NW_STAT_SEARCHING, // Searching network 62 | NW_STAT_REG_DENIED, // The register request is denied 63 | NW_STAT_UNKNOWN, 64 | NW_STAT_REGISTERED_ROAMING //Registered and Roaming state 65 | }Enum_NetworkState; 66 | 67 | /****************************************************************************** 68 | * Function: RIL_NW_GetGPRSState 69 | * 70 | * Description: 71 | * This function gets the GPRS network register state. 72 | * 73 | * Parameters: 74 | * stat: 75 | * [out]GPRS State. 76 | * Return: 77 | * One value of Enum_NetworkState: network register state code. 78 | * -1 : fail to get the network state. 79 | ******************************************************************************/ 80 | s32 RIL_NW_GetEGPRSState(s32 *stat); 81 | 82 | #endif // __RIL_NETWORK_H__ 83 | -------------------------------------------------------------------------------- /cores/opencpu/ril/inc/ril_socket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/cores/opencpu/ril/inc/ril_socket.h -------------------------------------------------------------------------------- /cores/opencpu/ril/inc/ril_util.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * ril_tuil.h 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * The file is for some useful definitions and APIs in common. 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | #ifndef __RIL_UTIL_H__ 34 | #define __RIL_UTIL_H__ 35 | #include "ql_type.h" 36 | 37 | typedef enum { 38 | CHAR_0 = '0', 39 | CHAR_9 = '9', 40 | CHAR_A = 'A', 41 | CHAR_F = 'F', 42 | END_OF_STR = '\0' 43 | }Enum_Char; 44 | #define IS_NUMBER(alpha_char) \ 45 | (((alpha_char >= CHAR_0) && (alpha_char <= CHAR_9) ) ? 1 : 0) 46 | 47 | extern s32 Ql_StrPrefixMatch(const char* str, const char *prefix); 48 | extern bool Ql_HexStrToInt(u8 *str, u32 *val); 49 | extern char* Ql_StrToUpper(char* str); 50 | /****************************************************************************** 51 | * Function: Ql_RIL_FindString 52 | * 53 | * Description: 54 | * This function is used to match string within a specified length. 55 | * This function is very much like strstr. 56 | * 57 | * Parameters: 58 | * line: 59 | * [in]The address of the string. 60 | * len: 61 | * [in]The length of the string. 62 | * str: 63 | * [in]The specified item which you want to look for in the string. 64 | * 65 | * Return: 66 | The function returns a pointer to the located string, 67 | or a null pointer if the specified string is not found. 68 | ******************************************************************************/ 69 | extern char* Ql_RIL_FindString(char *line, u32 len,char *str); 70 | 71 | /****************************************************************************** 72 | * Function: Ql_RIL_FindLine 73 | * 74 | * Description: 75 | * This function is used to find the specified character line by line. 76 | * for example,if you want to find "OK", In fact, we think that you are 77 | * looking for OK,OK or OK. 78 | * 79 | * 80 | * Parameters: 81 | * line: 82 | * [in]The address of the string. 83 | * len: 84 | * [in]The length of the string. 85 | * str: 86 | * [in]The specified item which you want to look for in the string. 87 | * 88 | * Return: 89 | The function returns a pointer to the located string, 90 | or a null pointer if the specified string is not found. 91 | ******************************************************************************/ 92 | extern char* Ql_RIL_FindLine(char *line, u32 len,char *str); 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /cores/opencpu/ril/src/ril_init.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright Statement: 3 | * -------------------- 4 | * This software is protected by Copyright and the information contained 5 | * herein is confidential. The software may not be copied and the information 6 | * contained herein may not be used or disclosed except with the written 7 | * permission of Quectel Co., Ltd. 2013 8 | * 9 | *****************************************************************************/ 10 | /***************************************************************************** 11 | * 12 | * Filename: 13 | * --------- 14 | * ril_init.c 15 | * 16 | * Project: 17 | * -------- 18 | * OpenCPU 19 | * 20 | * Description: 21 | * ------------ 22 | * This file is used for customer to inital RIL interface. 23 | * 24 | * Author: 25 | * ------- 26 | * ------- 27 | * 28 | *============================================================================ 29 | * HISTORY 30 | *---------------------------------------------------------------------------- 31 | * 32 | ****************************************************************************/ 33 | #include "custom_feature_def.h" 34 | #include "ril.h" 35 | #include "ql_stdlib.h" 36 | #include "ql_trace.h" 37 | #include "ql_error.h" 38 | #include "ql_system.h" 39 | 40 | #ifdef __OCPU_RIL_SUPPORT__ 41 | 42 | /*********************************************************************** 43 | * Initial commands for RIL. g_InitCmds[] will be used by Ql_RIL_Initialize function. 44 | * Now RIL is implemented based on the following AT commands. 45 | ************************************************************************/ 46 | const char* g_InitCmds[] = { 47 | //"ATE0Q0V1\r", // verbose result codes 48 | "AT+CMEE=1\r", // Extended errors. This item is necessary. 49 | //"ATS0=0\r", // No auto-answer. If customer want auto answer the incoming call , must change this string as "ATS0=n\r" (n=1~255). 50 | "AT+CEREG=1\r", // NW registration events . 51 | //"AT+CGREG=1\r", // GPRS registration events 52 | //"AT+CSCON=1\r", // 53 | //"AT+COLP=0\r" // no connected line identification 54 | "AT+QICFG?\r" //query dataformat 55 | //...... More customization setting can add here 56 | }; 57 | 58 | u32 RIL_GetInitCmdCnt(void) 59 | { 60 | return NUM_ELEMS(g_InitCmds); 61 | } 62 | 63 | /*********************************************************************** 64 | * Limited commands for RIL. 65 | * Now RIL is implemented based on the opposite functions of the 66 | * following AT commands. 67 | ************************************************************************/ 68 | const char* g_LimitedCmds[] = { 69 | "AT+CMEE=0", 70 | //"AT+CLIP", 71 | }; 72 | u32 RIL_GetLimitedCmdCnt(void) 73 | { 74 | return NUM_ELEMS(g_LimitedCmds); 75 | } 76 | 77 | #endif //__OCPU_RIL_SUPPORT__ 78 | -------------------------------------------------------------------------------- /cores/opencpu/ril/src/ril_network.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/cores/opencpu/ril/src/ril_network.c -------------------------------------------------------------------------------- /cores/opencpu/wiring.c: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - wiring 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | inline void yield(void) 25 | { 26 | Ql_Sleep(10); 27 | } 28 | 29 | unsigned int millis() 30 | { 31 | return xTaskGetTickCount() * 10; 32 | } 33 | 34 | unsigned int seconds(void) 35 | { 36 | return millis() / 1000; 37 | } 38 | 39 | inline unsigned int micros() 40 | { 41 | return api_get_micro(); 42 | } 43 | 44 | inline void delayMicroseconds(unsigned int us) 45 | { 46 | api_delay_us(us); 47 | } 48 | 49 | void delay(unsigned int ms) 50 | { 51 | if (ms < 10) 52 | ms = 10; 53 | Ql_Sleep(ms); 54 | } 55 | 56 | uint32_t clockCyclesPerMicrosecond(void) 57 | { 58 | return api_get_cpu_speed(); 59 | } 60 | 61 | uint32_t clockCyclesToMicroseconds(uint32_t a) 62 | { 63 | return a / clockCyclesPerMicrosecond(); 64 | } 65 | 66 | uint32_t microsecondsToClockCycles(uint32_t a) 67 | { 68 | return a * clockCyclesPerMicrosecond(); 69 | } 70 | 71 | #define ARRAYLEN(x) (sizeof(x) / sizeof((x)[0])) 72 | PinDescription *getArduinoPin(uint8_t arduinoPin) 73 | { 74 | for (int i = 0; i < ARRAYLEN(pinsMap); i++) 75 | if (pinsMap[i].arduino == arduinoPin) 76 | return &pinsMap[i]; 77 | return NULL; 78 | } 79 | 80 | PinDescription *getDevicePin(uint8_t devicePin) 81 | { 82 | for (int i = 0; i < ARRAYLEN(pinsMap); i++) 83 | if (pinsMap[i].device == devicePin) 84 | return &pinsMap[i]; 85 | return NULL; 86 | } 87 | 88 | static void eint_callback(Enum_PinName eintPinName, Enum_PinLevel pinLevel, void *user) 89 | { 90 | Enum_PinName pin = (Enum_PinName)user; 91 | PinDescription *n = getDevicePin(pin); 92 | if (n && n->eint) 93 | { 94 | Ql_EINT_Mask(pin); 95 | eint_callback_t cb = (eint_callback_t)n->eint; 96 | cb(Ql_EINT_GetLevel(n->device)); 97 | Ql_EINT_Unmask(pin); 98 | } 99 | } 100 | 101 | void eintMode(uint8_t pin, Enum_EintType type, eint_callback_t cb, uint32_t hwDebounce, uint32_t swDebounce, bool automask) 102 | { 103 | PinDescription *n = getArduinoPin(pin); 104 | if (n) 105 | { 106 | if (type == END_OF_HAL_EINT) 107 | { 108 | Ql_EINT_Uninit(n->device); 109 | } 110 | else if (cb) 111 | { 112 | n->eint = cb; 113 | Ql_EINT_RegisterFast(n->device, eint_callback, (void *)((int)n->device)); 114 | Ql_EINT_Init(n->device, type, hwDebounce, swDebounce, automask); 115 | } 116 | } 117 | } 118 | 119 | static int _irq_; 120 | 121 | void interrupts(void) 122 | { 123 | api_RestoreIRQMask(_irq_); 124 | } 125 | 126 | void noInterrupts(void) 127 | { 128 | _irq_ = api_SaveAndSetIRQMask(); 129 | } -------------------------------------------------------------------------------- /cores/opencpu/wiring_analog.c: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - analog 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | 23 | #define PWM_MAX 8193 24 | int api_adc_init(int pin); 25 | 26 | int analogRead(uint8_t pin) 27 | { 28 | uint32_t val = -1; 29 | hal_adc_get_data_polling(0, &val); // * 1400 30 | return val; 31 | } 32 | 33 | void analogWrite(uint8_t pin, int val) 34 | { 35 | Ql_PWM_Output((Enum_PinName)pin, val); 36 | } 37 | 38 | void analogClose(uint8_t pin) 39 | { 40 | switch (pin) 41 | { 42 | //case ADC0: break; 43 | case PWM0: 44 | Ql_PWM_Uninit((Enum_PinName)pin); 45 | } 46 | } 47 | 48 | void analogOpen(uint8_t pin, /* val, src, div */...) 49 | { 50 | switch (pin) 51 | { 52 | case ADC0: 53 | api_adc_init(0); 54 | break; 55 | case PWM0: 56 | case PWM1: 57 | case PWM2: 58 | { 59 | va_list list; 60 | va_start(list, pin); 61 | uint32_t val = va_arg(list, uint32_t); 62 | uint32_t pwmSrcClk = va_arg(list, uint32_t); 63 | uint32_t pwmDiv = va_arg(list, uint32_t); 64 | Ql_GPIO_Uninit((Enum_PinName)pin); 65 | uint32_t PWM_lowPulseNum = PWM_MAX / 2; 66 | uint32_t PWM_highPulseNum = PWM_MAX / 2; 67 | Ql_PWM_Init((Enum_PinName)pin, (Enum_PwmSource)pwmSrcClk, (Enum_PwmSourceDiv)pwmDiv, PWM_lowPulseNum, PWM_highPulseNum); 68 | Ql_PWM_Output((Enum_PinName)pin, val); 69 | } 70 | break; 71 | } //switch 72 | } 73 | -------------------------------------------------------------------------------- /cores/opencpu/wiring_digital.c: -------------------------------------------------------------------------------- 1 | /* 2 | BC66 - digital 3 | Created on: 01.01.2019 4 | Author: Georgi Angelov 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | void pinMode(uint8_t pin, uint8_t mode) 25 | { 26 | PinDescription *n = getArduinoPin(pin); 27 | if (n) 28 | { 29 | if (mode == CLOSE) 30 | { 31 | Ql_GPIO_Uninit(n->device); 32 | n->device = PINNAME_END; 33 | } 34 | else 35 | { 36 | Enum_PinPullSel pull = PINPULLSEL_DISABLE; 37 | Enum_PinDirection dir = PINDIRECTION_IN; 38 | Enum_PinLevel level = PINLEVEL_LOW; 39 | if (mode & INPUT_PULLUP) 40 | pull = PINPULLSEL_PULLUP; 41 | if (mode & INPUT_PULLDOWN) 42 | pull = PINPULLSEL_PULLDOWN; 43 | if ((mode & OUTPUT) || (mode & OUTPUT_LO) || (mode & OUTPUT_HI)) 44 | dir = PINDIRECTION_OUT; 45 | if (mode & OUTPUT_HI) 46 | level = PINLEVEL_HIGH; 47 | Ql_GPIO_Init(n->device, dir, level, pull); 48 | } 49 | } 50 | } 51 | 52 | void digitalWrite(uint8_t pin, uint8_t val) 53 | { 54 | PinDescription *n = getArduinoPin(pin); 55 | if (n) 56 | Ql_GPIO_SetLevel(n->device, (Enum_PinLevel)val & 1); 57 | } 58 | 59 | int digitalRead(uint8_t pin) 60 | { 61 | PinDescription *n = getArduinoPin(pin); 62 | if (n) 63 | return Ql_GPIO_GetLevel(n->device); 64 | return -1; 65 | } 66 | -------------------------------------------------------------------------------- /cores/opencpu/wiring_pulse.c: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_pulse.c - pulseIn() function 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #include 24 | 25 | unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) 26 | { 27 | uint32_t init_time = micros(); 28 | uint32_t curr_time = init_time; 29 | uint32_t max_time = init_time + timeout; 30 | int pin_state = 0; 31 | 32 | /* read GPIO info */ 33 | pin_state = digitalRead(pin); 34 | 35 | // wait for any previous pulse to end 36 | while ((pin_state == state) && (curr_time < max_time)) 37 | { 38 | curr_time = micros(); 39 | pin_state = digitalRead(pin); 40 | } 41 | 42 | // wait for the pulse to start 43 | while ((pin_state != state) && (curr_time < max_time)) 44 | { 45 | curr_time = micros(); 46 | init_time = curr_time; 47 | pin_state = digitalRead(pin); 48 | } 49 | 50 | // wait for the pulse to stop 51 | while ((pin_state == state) && (curr_time < max_time)) 52 | { 53 | curr_time = micros(); 54 | pin_state = digitalRead(pin); 55 | } 56 | 57 | if (curr_time < max_time) 58 | { 59 | return (curr_time - init_time); 60 | } 61 | else 62 | { 63 | return 0; 64 | } 65 | } -------------------------------------------------------------------------------- /cores/opencpu/wiring_shift.c: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_shift.c - shiftOut() function 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #include 24 | 25 | uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) 26 | { 27 | uint8_t value = 0; 28 | uint8_t i; 29 | for (i = 0; i < 8; ++i) 30 | { 31 | digitalWrite(clockPin, HIGH); 32 | if (bitOrder == LSBFIRST) 33 | value |= digitalRead(dataPin) << i; 34 | else 35 | value |= digitalRead(dataPin) << (7 - i); 36 | digitalWrite(clockPin, LOW); 37 | } 38 | return value; 39 | } 40 | 41 | void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) 42 | { 43 | uint8_t i; 44 | for (i = 0; i < 8; i++) 45 | { 46 | if (bitOrder == LSBFIRST) 47 | digitalWrite(dataPin, !!(val & (1 << i))); 48 | else 49 | digitalWrite(dataPin, !!(val & (1 << (7 - i)))); 50 | 51 | digitalWrite(clockPin, HIGH); 52 | digitalWrite(clockPin, LOW); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /cores/opencpu/wizio_lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libraries 3 | * 4 | * Created on: 02.10.2018 5 | * Author: Georgi Angelov 6 | */ 7 | 8 | #include 9 | #include "ql_system.h" 10 | #include "ql_stdlib.h" 11 | 12 | /* need for quectel lib bss */ 13 | extern void *memset(void *dst, int c, size_t n) 14 | { 15 | if (n) 16 | { 17 | char *d = dst; 18 | do 19 | { 20 | *d++ = c; 21 | } while (--n); 22 | } 23 | return dst; 24 | } 25 | 26 | 27 | //https://opensource.apple.com/source/Libc/Libc-167/string.subproj/strtok.c.auto.html 28 | char *wiz_strtok(char *s, const char *delim) 29 | { 30 | char *spanp; 31 | int c, sc; 32 | char *tok; 33 | static char *last; 34 | if (s == NULL && (s = last) == NULL) 35 | return (NULL); 36 | 37 | /* 38 | * Skip (span) leading delimiters (s += strspn(s, delim), sort of). 39 | */ 40 | cont: 41 | c = *s++; 42 | for (spanp = (char *)delim; (sc = *spanp++) != 0;) 43 | { 44 | if (c == sc) 45 | goto cont; 46 | } 47 | 48 | if (c == 0) 49 | { /* no non-delimiter characters */ 50 | last = NULL; 51 | return (NULL); 52 | } 53 | tok = s - 1; 54 | /* 55 | * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). 56 | * Note that delim must have one NUL; we stop if we see that, too. 57 | */ 58 | for (;;) 59 | { 60 | c = *s++; 61 | spanp = (char *)delim; 62 | do 63 | { 64 | if ((sc = *spanp++) == c) 65 | { 66 | if (c == 0) 67 | s = NULL; 68 | else 69 | s[-1] = 0; 70 | last = s; 71 | return (tok); 72 | } 73 | } while (sc != 0); 74 | } 75 | /* NOTREACHED */ 76 | return 0; 77 | } 78 | 79 | //https://opensource.apple.com/source/xnu/xnu-1228.7.58/bsd/libkern/strsep.c 80 | char *wiz_strsep(char **stringp, const char *delim) 81 | { 82 | char *s; 83 | const char *spanp; 84 | int c, sc; 85 | char *tok; 86 | if ((s = *stringp) == NULL) 87 | return (NULL); 88 | for (tok = s;;) 89 | { 90 | c = *s++; 91 | spanp = delim; 92 | do 93 | { 94 | if ((sc = *spanp++) == c) 95 | { 96 | if (c == 0) 97 | s = NULL; 98 | else 99 | s[-1] = 0; 100 | *stringp = s; 101 | return (tok); 102 | } 103 | } while (sc != 0); 104 | } 105 | /* NOTREACHED */ 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /examples/info/info.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* APN 4 | is set/saved as default in NVDM (required once) 5 | AT*MCGDEFCONT="IP","apn_from_operator" 6 | 7 | Enable scrambling function (required once) 8 | AT+QSPCHSC=1 9 | */ 10 | 11 | void setup() 12 | { 13 | int t = millis(); 14 | String imei, mcc_mnc, sim_imsi, sim_iccid, uid; 15 | Dev.noSleep(); // disable PSM sleep 16 | 17 | Serial.begin(115200); 18 | Serial.debug(); // enable debug for this port, DBG( work as printf ) 19 | 20 | Serial.printf("Arduino %s\n", Dev.getVersion()); 21 | Dev.getImei(imei); 22 | Serial.printf("IMEI %s\n", imei.c_str()); 23 | Dev.getUid(uid); 24 | Serial.printf("UID %s\n", uid.c_str()); 25 | 26 | Dev.waitSimReady(); 27 | 28 | Dev.getMccMnc(mcc_mnc); 29 | Serial.printf("MCCMNC %s\n", mcc_mnc.c_str()); 30 | Dev.getImsi(sim_imsi); 31 | Serial.printf("IMSI %s\n", sim_imsi.c_str()); 32 | Dev.getIccid(sim_iccid); 33 | Serial.printf("ICCID %s\n", sim_iccid.c_str()); 34 | 35 | Dev.waitCereg(); 36 | delay(200); // must have some delay, afrer this time next values is available 37 | 38 | Serial.printf("Rx level %d dbm\n", Dev.getReceiveLevel()); 39 | Serial.printf("Rx quality %d\n", Dev.getQuality()); 40 | Serial.printf("Rx access %d\n", Dev.getAccess()); 41 | Serial.printf("Cell cid %d\n", Dev.getCid()); 42 | Serial.printf("Cell tac %d\n", Dev.getTac()); 43 | char mlts[322]; 44 | Dev.getMlts(mlts, 322); 45 | Serial.printf("Cell mlts %s\n", mlts); 46 | pinMode(LED, OUTPUT); 47 | digitalWrite(LED, 1); 48 | Serial.printf("Elapsed: %d mili seconds\n", millis() - t); 49 | } 50 | 51 | void loop() 52 | { 53 | static int led = 0; 54 | delay(500); 55 | Serial.print(">"); 56 | digitalWrite(LED, ++led & 1); 57 | /* loop must be state machine, dont make long delays */ 58 | } 59 | 60 | /** RESULT ************************************************************** 61 | * 62 | Arduino BC66NBR01A04 63 | IMEI 867997030026081 64 | UID 301C9C77F16D77679784E781D57CF751 65 | MCCMNC 28401 66 | IMSI 9284011911698783 67 | ICCID 89359011870169878300 68 | Rx level -68 dbm 69 | Rx quality 0 70 | Rx access 6 71 | Cell cid 9610698 72 | Cell tac 199 73 | Cell mlts "19/04/02,12:20:28+03", "DST +1 in use","A1 BG",0,"A1 BG",0,"+03" 74 | Elapsed: 2830 mili seconds 75 | 76 | ***************************************************************/ -------------------------------------------------------------------------------- /examples/pubsub_mqtt/pubsub_mqtt.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include // INSTALL LIBRARY 4 | 5 | nbClient tcp; 6 | IPAddress server(0, 0, 0, 0); // your mqtt broker 7 | 8 | void callback(char *topic, byte *payload, unsigned int length) 9 | { 10 | Serial.printf("[RECEIVE] (%s) %.*s\n", topic, length, payload); 11 | } 12 | 13 | PubSubClient client(server, 1883, callback, tcp); 14 | 15 | void mqtt_setup() 16 | { 17 | Serial.println("Test MQTT"); 18 | if (client.connect("arduinoClient", "user", "pass")) 19 | { 20 | client.publish("outTopic", "hello world"); 21 | Serial.println("publish..."); 22 | client.subscribe("inTopic"); 23 | Serial.println("subscribe..."); 24 | } 25 | } 26 | 27 | void setup() 28 | { 29 | String imei; 30 | Dev.noSleep(); 31 | Serial.begin(115200); 32 | Serial.printf("Arduino %s\n", Dev.getVersion()); 33 | pinMode(LED, OUTPUT); 34 | Dev.getImei(imei); 35 | Serial.printf("IMEI %s\n", imei.c_str()); 36 | Dev.waitSimReady(); 37 | Serial.println("Sim Ready"); 38 | Dev.waitCereg(); 39 | delay(200); // must 40 | Serial.println("Net Ready"); 41 | mqtt_setup(); 42 | } 43 | 44 | void loop() 45 | { 46 | static int led = 0, cnt = 0; 47 | if (++cnt % 50 == 0) 48 | { 49 | digitalWrite(LED, ++led & 1); 50 | //Serial.print("."); 51 | } 52 | client.loop(); 53 | } 54 | 55 | /* 56 | Arduino BC66NBR01A04 57 | IMEI 867997030026081 58 | Sim Ready 59 | Net Ready 60 | Test MQTT 61 | publish... 62 | subscribe... 63 | [RECEIVE] (inTopic) Hello World 64 | [RECEIVE] (inTopic) Test 1234 65 | */ 66 | -------------------------------------------------------------------------------- /firmwares/Firmware_BC66NBR01A04V01.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/firmwares/Firmware_BC66NBR01A04V01.zip -------------------------------------------------------------------------------- /images/ARDUINO_BC66.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/images/ARDUINO_BC66.png -------------------------------------------------------------------------------- /images/arduino.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/images/arduino.png -------------------------------------------------------------------------------- /images/arduino_hardware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/images/arduino_hardware.png -------------------------------------------------------------------------------- /images/gcc_bin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/images/gcc_bin.png -------------------------------------------------------------------------------- /images/tool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiz-IO/Arduino-Quectel-BC66/feccce870130fde77a475d422c18475bd630efc5/images/tool.png -------------------------------------------------------------------------------- /libraries/EEPROM/library.properties: -------------------------------------------------------------------------------- 1 | name=EEPROM 2 | sentence=EEPROM 3 | paragraph=EEPROM 4 | version=1.0 5 | author=WizIO 6 | maintainer=WizIO 7 | url=https://github.com/Wiz-IO/Arduino-Quectel-BC66 8 | architectures=bc66 9 | category=Communication 10 | core-dependencies=arduino (>=1.6.6) -------------------------------------------------------------------------------- /libraries/EEPROM/src/EEPROM.cpp: -------------------------------------------------------------------------------- 1 | /* for Quectel BC66 2 | * Created on: 01.01.2019 3 | * Author: Georgi Angelov 4 | */ 5 | 6 | #include "EEPROM.h" 7 | 8 | #ifdef __OCPU_RIL_SUPPORT__ 9 | 10 | EEPROMClass EEPROM; 11 | 12 | // cell from 1 & 2 13 | static void ql_eeprom_get_index(u32 address, u8 *cell, u32 *size, u32 *offset) 14 | { 15 | if (address < 50) 16 | { 17 | *cell = 1; 18 | *size = 50; 19 | *offset = 0; 20 | return; 21 | } 22 | else 23 | { 24 | *cell = 2; 25 | *size = 50; 26 | *offset = 50; 27 | } 28 | } 29 | 30 | uint8_t EERef::operator*() const 31 | { 32 | if (index < _EEPROM_SIZE) 33 | { 34 | u8 cell; 35 | u32 size, offset; 36 | ql_eeprom_get_index(index, &cell, &size, &offset); 37 | uint8_t data[size]; 38 | int res = Ql_SecureData_Read(cell, (u8 *)data, size); // RIL 39 | DEBUG_EEP("Read cell = %d, size = %d, res = %d", cell, size, res); 40 | if (size == res) 41 | { 42 | return data[index - offset]; 43 | } 44 | else 45 | { 46 | DEBUG_EEP("Read failed. Return 0 as value"); 47 | } 48 | } 49 | return 0; 50 | } 51 | 52 | EERef &EERef::operator=(uint8_t in) 53 | { 54 | if (index < _EEPROM_SIZE) 55 | { 56 | u8 cell; 57 | u32 size, offset; 58 | ql_eeprom_get_index(index, &cell, &size, &offset); 59 | uint8_t data[size]; 60 | int res = Ql_SecureData_Read(cell, (u8 *)data, size); // RIL 61 | DEBUG_EEP("Write cell = %d, size = %d, res = %d", cell, size, res); 62 | if (size == res) 63 | { 64 | data[index - offset] = in; 65 | Ql_SecureData_Store(cell, (u8 *)data, size); // RIL 66 | } 67 | else 68 | { 69 | DEBUG_EEP("Write failed ( %d )", res); 70 | } 71 | } 72 | return *this; 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /libraries/EEPROM/src/SYS_EEPROM.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define EEP_DBG 4 | 5 | #include "SYS_EEPROM.h" 6 | 7 | #ifdef MTK_NVDM_ENABLE 8 | 9 | EEPROMClass EEPROM; 10 | 11 | #define _SECTOR_SIZE (16) 12 | 13 | #define PROPERTY_NAME "ARDUINO" 14 | #define STRING_SIZE (8) 15 | 16 | #define GET_OFFSET(x) ((x) % _SECTOR_SIZE) 17 | 18 | void _get_entry_name(int index, char *buffer) 19 | { 20 | sprintf(buffer, "%d", index / _SECTOR_SIZE); 21 | } 22 | 23 | uint8_t EERef::operator*() const 24 | { 25 | nvdm_status_t ret; 26 | char name[STRING_SIZE]; 27 | 28 | if (index < _EEPROM_SIZE) 29 | { 30 | uint8_t data[_SECTOR_SIZE]; 31 | uint32_t data_size = _SECTOR_SIZE; 32 | 33 | _get_entry_name(index, name); 34 | 35 | ret = nvdm_read_data_item(PROPERTY_NAME, name, data, &data_size); 36 | 37 | if (ret == NVDM_STATUS_OK) 38 | { 39 | // only read the needed byte 40 | return data[GET_OFFSET(index)]; 41 | } 42 | else 43 | { 44 | EEP_DBG("EEPROM read failed. Return 0 as the read value\n"); 45 | } 46 | } 47 | 48 | return 0; 49 | } 50 | 51 | EERef &EERef::operator=(uint8_t in) 52 | { 53 | nvdm_status_t ret; 54 | char name[STRING_SIZE]; 55 | 56 | if (index < _EEPROM_SIZE) 57 | { 58 | uint8_t data[_SECTOR_SIZE]; 59 | uint32_t data_size = _SECTOR_SIZE; 60 | 61 | _get_entry_name(index, name); 62 | 63 | // read out the data first 64 | ret = nvdm_read_data_item(PROPERTY_NAME, name, data, &data_size); 65 | 66 | // reading a position not written before would cause a NOT_FOUND error 67 | if (ret == NVDM_STATUS_OK || ret == NVDM_STATUS_ITEM_NOT_FOUND) 68 | { 69 | // only modify the byte needs to be updated 70 | data[GET_OFFSET(index)] = in; 71 | 72 | nvdm_write_data_item(PROPERTY_NAME, name, NVDM_DATA_ITEM_TYPE_RAW_DATA, data, _SECTOR_SIZE); 73 | } 74 | else 75 | { 76 | EEP_DBG("EEPROM write failed (%d)\n", ret); 77 | } 78 | } 79 | 80 | return *this; 81 | } 82 | 83 | #endif -------------------------------------------------------------------------------- /libraries/Ethernet/examples/tcp_http/tcp_http.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | nbClient tcp; 4 | #define HOST "wizio.eu" 5 | 6 | void tcp_http() 7 | { 8 | int timeout = 0; 9 | int r = tcp.connect(HOST, 80); 10 | DBG("connect: %d\n", r); 11 | if (r == 1) 12 | { 13 | char data[] = "GET /iot.php HTTP/1.1\r\nHost:" HOST "\r\n\r\n"; 14 | r = tcp.write(data, strlen(data)); 15 | DBG("sent: %d\n", r); 16 | delay(100); 17 | do 18 | { 19 | while (tcp.available()) 20 | { 21 | r = tcp.read(); // read byte 22 | if (r > 0) { 23 | Serial.print((char)r); 24 | continue; 25 | } else 26 | goto end; 27 | } 28 | delay(100); 29 | } while (++timeout < 100); 30 | end: 31 | delay(10); 32 | } 33 | tcp.stop(); 34 | } 35 | 36 | void setup() { 37 | String imei; 38 | Dev.noSleep(); 39 | Serial.begin(115200); 40 | Serial.printf("Arduino %s\n", Dev.getVersion()); 41 | Dev.getImei(imei); 42 | Serial.printf("IMEI %s\n", imei.c_str()); 43 | Dev.waitSimReady(); 44 | Serial.println("Sim Ready"); 45 | Dev.waitCereg(); 46 | delay(200); // must 47 | Serial.println("Net Ready"); 48 | Serial.println("Test TCP\n"); 49 | tcp_http(); 50 | pinMode(LED, OUTPUT); 51 | } 52 | 53 | void loop() { 54 | static int state = 0; 55 | static int led = 0; 56 | if(200 % state == 0) 57 | digitalWrite(LED, ++led & 1); 58 | state++; 59 | } 60 | -------------------------------------------------------------------------------- /libraries/Ethernet/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Ethernet 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Ethernet KEYWORD1 Ethernet 10 | EthernetClient KEYWORD1 EthernetClient 11 | EthernetServer KEYWORD1 EthernetServer 12 | IPAddress KEYWORD1 EthernetIPAddress 13 | 14 | ####################################### 15 | # Methods and Functions (KEYWORD2) 16 | ####################################### 17 | 18 | status KEYWORD2 19 | connect KEYWORD2 20 | write KEYWORD2 21 | available KEYWORD2 22 | read KEYWORD2 23 | peek KEYWORD2 24 | flush KEYWORD2 25 | stop KEYWORD2 26 | connected KEYWORD2 27 | begin KEYWORD2 28 | beginPacket KEYWORD2 29 | endPacket KEYWORD2 30 | parsePacket KEYWORD2 31 | remoteIP KEYWORD2 32 | remotePort KEYWORD2 33 | getSocketNumber KEYWORD2 34 | localIP KEYWORD2 35 | maintain KEYWORD2 36 | 37 | ####################################### 38 | # Constants (LITERAL1) 39 | ####################################### 40 | 41 | -------------------------------------------------------------------------------- /libraries/Ethernet/library.properties: -------------------------------------------------------------------------------- 1 | name=NET 2 | version=1.0 3 | author=WizIO 4 | maintainer=WizIO 5 | sentence=NET 6 | paragraph=NET 7 | url=https://github.com/Wiz-IO/Arduino-Quectel-BC66 8 | architectures=bc66 9 | category=Communication 10 | core-dependencies=arduino (>=1.6.6) -------------------------------------------------------------------------------- /libraries/Ethernet/src/nbClient.h: -------------------------------------------------------------------------------- 1 | /* 2 | nbClient.cpp - Library 3 | Copyright (c) 2011-2014 Arduino. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef nbClient_h 21 | #define nbClient_h 22 | 23 | #include 24 | #include "Client.h" 25 | #include "IPAddress.h" 26 | 27 | class nbClient : public Client { 28 | 29 | public: 30 | nbClient(); 31 | 32 | // This constructor is designed for WiFiServer::available(). 33 | // The nbClient object returned from WiFiServer::available() should 34 | // persist its connection even when the returned client object goes out of scope; 35 | // The user should close it by calling client.stop(). 36 | nbClient(int sock); 37 | ~nbClient(); 38 | 39 | virtual int connect(IPAddress ip, uint16_t port); 40 | virtual int connect(const char *host, uint16_t port); 41 | virtual size_t write(uint8_t); 42 | virtual size_t write(const uint8_t *buf, size_t size); 43 | virtual int available(); 44 | virtual int read(); 45 | virtual int read(uint8_t *buf, size_t size); 46 | virtual int peek(); 47 | virtual void flush(){} 48 | virtual void stop(); 49 | virtual uint8_t connected(); 50 | virtual operator bool(); 51 | 52 | friend class WiFiServer; 53 | using Print::write; 54 | 55 | private: 56 | int m_socket; 57 | bool m_externalSocket; 58 | 59 | protected: 60 | bool _connected; 61 | }; 62 | 63 | #endif -------------------------------------------------------------------------------- /libraries/Ethernet/src/nbClientSecure.h: -------------------------------------------------------------------------------- 1 | /* 2 | nbClientSecure.h - Base class that provides Client SSL 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | Additions Copyright (C) 2017 Evandro Luis Copercini. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef nbClientSecure_h 22 | #define nbClientSecure_h 23 | 24 | #include "Arduino.h" 25 | #include "IPAddress.h" 26 | #include "nbSSL.h" 27 | #include "nbClient.h" 28 | 29 | class nbClientSecure : public nbClient 30 | { 31 | protected: 32 | sslclient_context *sslclient; 33 | 34 | int _lastError = 0; 35 | int _peek = -1; 36 | const char *_CA_cert; 37 | const char *_cert; 38 | const char *_private_key; 39 | const char *_pskIdent; // identity for PSK cipher suites 40 | const char *_psKey; // key in hex for PSK cipher suites 41 | bool is_started; 42 | 43 | public: 44 | nbClientSecure *next; 45 | nbClientSecure(); 46 | nbClientSecure(int socket); 47 | ~nbClientSecure(); 48 | int connect(IPAddress ip, uint16_t port); 49 | int connect(const char *host, uint16_t port); 50 | int connect(IPAddress ip, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key); 51 | int connect(const char *host, uint16_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key); 52 | int connect(IPAddress ip, uint16_t port, const char *pskIdent, const char *psKey); 53 | int connect(const char *host, uint16_t port, const char *pskIdent, const char *psKey); 54 | int peek(); 55 | size_t write(uint8_t data); 56 | size_t write(const uint8_t *buf, size_t size); 57 | int available(); 58 | int read(); 59 | int read(uint8_t *buf, size_t size); 60 | void flush() {} 61 | void stop(); 62 | uint8_t connected(); 63 | int lastError(char *buf, const size_t size); 64 | void setPreSharedKey(const char *pskIdent, const char *psKey); // psKey in Hex 65 | void setCACert(const char *rootCA); 66 | void setCertificate(const char *client_ca); 67 | void setPrivateKey (const char *private_key); 68 | bool loadCACert(Stream& stream, size_t size); 69 | bool loadCertificate(Stream& stream, size_t size); 70 | bool loadPrivateKey(Stream& stream, size_t size); 71 | bool verify(const char* fingerprint, const char* domain_name); 72 | void setHandshakeTimeout(unsigned long handshake_timeout); 73 | 74 | operator bool() 75 | { 76 | return connected(); 77 | } 78 | nbClientSecure &operator=(const nbClientSecure &other); 79 | bool operator==(const bool value) 80 | { 81 | return bool() == value; 82 | } 83 | bool operator!=(const bool value) 84 | { 85 | return bool() != value; 86 | } 87 | bool operator==(const nbClientSecure &); 88 | bool operator!=(const nbClientSecure &rhs) 89 | { 90 | return !this->operator==(rhs); 91 | }; 92 | 93 | int socket() 94 | { 95 | return sslclient->socket = -1; 96 | } 97 | 98 | private: 99 | char *_streamLoad(Stream& stream, size_t size); 100 | 101 | //friend class nbServer; 102 | using Print::write; 103 | }; 104 | 105 | #endif /* _nbCLIENT_H_ */ -------------------------------------------------------------------------------- /libraries/Ethernet/src/nbFota.h: -------------------------------------------------------------------------------- 1 | #ifndef FOTA_H_ 2 | #define FOTA_H_ 3 | 4 | // NOT READY 5 | 6 | #include 7 | 8 | typedef void (*fota_callback)(fota_msg_event_t, fota_msg_event_info_t *); 9 | extern "C" uint32_t fota_register_event(fota_callback call_back); 10 | extern "C" fota_result_t fota_download_image(fota_image_t image, char *image_uri); 11 | extern "C" fota_result_t fota_trigger_upgrade(fota_image_t image); 12 | extern "C" void fota_set_current_state(fota_state_t state); 13 | 14 | extern int g_fota_result; 15 | 16 | class FOTA 17 | { 18 | private: 19 | public: 20 | FOTA() {} 21 | 22 | bool begin(fota_callback userCallback) 23 | { 24 | return userCallback && fota_register_event(userCallback) != 0; 25 | } 26 | 27 | bool start(const char *url) 28 | { 29 | return url && fota_download_image(FOTA_MAIN_BIN, (char *)url) == FOTA_OK; 30 | } 31 | 32 | void cancel() 33 | { 34 | fota_set_current_state(FOTA_IDLE); 35 | } 36 | 37 | bool download(const char *url) 38 | { 39 | if (fota_register_event(m_download_cb)) 40 | return url && fota_download_image(FOTA_MAIN_BIN, (char *)url) == FOTA_OK; 41 | return false; 42 | } 43 | 44 | private: 45 | static void m_download_cb(fota_msg_event_t event, fota_msg_event_info_t *info) 46 | { 47 | if (event > FOTA_MSG_DOWNLOAD_PROGRESS_IND) 48 | { 49 | fota_set_current_state(FOTA_IDLE); // cancel 50 | g_fota_result = info->fota_result; 51 | } 52 | } 53 | }; 54 | 55 | #endif -------------------------------------------------------------------------------- /libraries/Ethernet/src/nbGenericClass.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "IPAddress.h" 4 | #include "api.h" 5 | 6 | class nbGenericClass 7 | { 8 | public: 9 | nbGenericClass(); 10 | static int hostByName(const char *aHostname, IPAddress &aResult) 11 | { 12 | struct sockaddr_in addr; 13 | int res = resolveAddress(aHostname, &addr); 14 | aResult = addr.sin_addr.s_addr; 15 | return res; 16 | } 17 | }; -------------------------------------------------------------------------------- /libraries/Ethernet/src/nbHttpClient.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPCLIENT_H_ 2 | #define HTTPCLIENT_H_ 3 | 4 | #include 5 | 6 | class nbHttpClient 7 | { 8 | public: 9 | nbHttpClient() { clean(); } 10 | ~nbHttpClient() { end(); } 11 | void clean(); 12 | void end(); 13 | int begin(const char *url); 14 | int begin(const char *url, size_t response_size); 15 | int begin(const char *url, size_t response_size, size_t header_size); 16 | 17 | uint32_t get(); 18 | uint32_t post(const char *post); 19 | uint32_t post(const char *post, size_t size); 20 | 21 | char *getResponse(); 22 | char *getHeader(); 23 | void setClientHeader(char *header); 24 | void setPostContent(char *content); 25 | void setTimeout(uint32_t seconds); 26 | 27 | private: 28 | char *m_url; 29 | httpclient_t client; 30 | httpclient_data_t data; 31 | size_t create_buffer(char **buf, size_t size); 32 | uint32_t execute(HTTPCLIENT_REQUEST_TYPE method); 33 | }; 34 | 35 | #endif /* HTTPCLIENT_H_ */ 36 | -------------------------------------------------------------------------------- /libraries/Ethernet/src/nbSSL.h: -------------------------------------------------------------------------------- 1 | /* Provide SSL/TLS functions to ESP32 with Arduino IDE 2 | * by Evandro Copercini - 2017 - Apache 2.0 License 3 | * https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFiClientSecure 4 | */ 5 | 6 | #ifndef ARD_SSL_H 7 | #define ARD_SSL_H 8 | 9 | #include "interface.h" 10 | 11 | #define LOG_SSL "SSL " 12 | 13 | #ifdef LOG_SSL 14 | # define log_e(FORMAT, ...) LOG_E(LOG_SSL FORMAT, ##__VA_ARGS__) 15 | # define log_v(FORMAT, ...) LOG_V(LOG_SSL FORMAT, ##__VA_ARGS__) 16 | # define log_d(FORMAT, ...) LOG_D(LOG_SSL FORMAT, ##__VA_ARGS__) 17 | # define log_i(FORMAT, ...) LOG_I(LOG_SSL FORMAT, ##__VA_ARGS__) 18 | # define log_w(FORMAT, ...) LOG_W(LOG_SSL FORMAT, ##__VA_ARGS__) 19 | #else 20 | # define log_e(FORMAT, ...) 21 | # define log_v(FORMAT, ...) 22 | # define log_d(FORMAT, ...) 23 | # define log_i(FORMAT, ...) 24 | # define log_w(FORMAT, ...) 25 | #endif 26 | 27 | 28 | typedef struct sslclient_context { 29 | int socket; 30 | mbedtls_ssl_context ssl_ctx; 31 | mbedtls_ssl_config ssl_conf; 32 | 33 | mbedtls_ctr_drbg_context drbg_ctx; 34 | mbedtls_entropy_context entropy_ctx; 35 | 36 | mbedtls_x509_crt ca_cert; 37 | mbedtls_x509_crt client_cert; 38 | mbedtls_pk_context client_key; 39 | 40 | unsigned long handshake_timeout; 41 | } sslclient_context; 42 | 43 | void ssl_init(sslclient_context *ssl_client); 44 | int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, const char *rootCABuff, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey); 45 | void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, const char *cli_cert, const char *cli_key); 46 | int data_to_read(sslclient_context *ssl_client); 47 | int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, uint16_t len); 48 | int get_ssl_receive(sslclient_context *ssl_client, uint8_t *data, int length); 49 | bool verify_ssl_fingerprint(sslclient_context *ssl_client, const char* fp, const char* domain_name); 50 | bool verify_ssl_dn(sslclient_context *ssl_client, const char* domain_name); 51 | 52 | #endif -------------------------------------------------------------------------------- /libraries/Ethernet/src/nbUdp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Udp.cpp: Library to send/receive UDP packets. 3 | * 4 | * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) 5 | * 1) UDP does not guarantee the order in which assembled UDP packets are received. This 6 | * might not happen often in practice, but in larger network topologies, a UDP 7 | * packet can be received out of sequence. 8 | * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being 9 | * aware of it. Again, this may not be a concern in practice on small local networks. 10 | * For more information, see http://www.cafeaulait.org/course/week12/35.html 11 | * 12 | * MIT License: 13 | * Copyright (c) 2008 Bjoern Hartmann 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to deal 16 | * in the Software without restriction, including without limitation the rights 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | * copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | * THE SOFTWARE. 31 | * 32 | * bjoern@cs.stanford.edu 12/30/2008 33 | */ 34 | 35 | #ifndef _NBUDP_H_ 36 | #define _NBUDP_H_ 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | class nbUDP : public UDP 43 | { 44 | private: 45 | int udp_server; 46 | IPAddress multicast_ip; 47 | IPAddress remote_ip; 48 | uint16_t server_port; 49 | uint16_t remote_port; 50 | char *tx_buffer; 51 | size_t tx_buffer_len; 52 | cbuf *rx_buffer; 53 | 54 | public: 55 | nbUDP(); 56 | ~nbUDP(); 57 | uint8_t begin(IPAddress a, uint16_t p); 58 | uint8_t begin(uint16_t p); 59 | void stop(); 60 | int beginPacket(); 61 | int beginPacket(IPAddress ip, uint16_t port); 62 | int beginPacket(const char *host, uint16_t port); 63 | int endPacket(); 64 | size_t write(uint8_t); 65 | size_t write(const uint8_t *buffer, size_t size); 66 | int parsePacket(); 67 | int available(); 68 | int read(); 69 | int read(unsigned char *buffer, size_t len); 70 | int read(char *buffer, size_t len); 71 | int peek(); 72 | void flush(); 73 | IPAddress remoteIP(); 74 | uint16_t remotePort(); 75 | }; 76 | 77 | #endif /* _NBUDP_H_ */ 78 | 79 | 80 | -------------------------------------------------------------------------------- /libraries/NVDM/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For LFlash 3 | ####################################### 4 | 5 | ####################################### 6 | # Library (KEYWORD1) 7 | ####################################### 8 | LFlash KEYWORD1 9 | 10 | ####################################### 11 | # Datatypes (KEYWORD1) 12 | ####################################### 13 | LFlashDataType KEYWORD1 14 | LFlashStatus KEYWORD1 15 | LTimerID KEYWORD1 16 | 17 | ####################################### 18 | # Methods and Functions (KEYWORD2) 19 | ####################################### 20 | 21 | write KEYWORD2 22 | begin KEYWORD2 23 | read KEYWORD2 24 | 25 | ####################################### 26 | # Constants (LITERAL1) 27 | ####################################### 28 | -------------------------------------------------------------------------------- /libraries/NVDM/library.properties: -------------------------------------------------------------------------------- 1 | name=NVDM 2 | version=1.0 3 | author=WizIO 4 | maintainer=WizIO 5 | sentence=NVDM 6 | paragraph=NVDM 7 | url=https://github.com/Wiz-IO/Arduino-Quectel-BC66 8 | architectures=bc66 9 | category=Communication 10 | core-dependencies=arduino (>=1.6.6) -------------------------------------------------------------------------------- /libraries/NVDM/src/NVDM.cpp: -------------------------------------------------------------------------------- 1 | #define MTK_NVDM_ENABLE 2 | #ifdef MTK_NVDM_ENABLE 3 | 4 | #include 5 | #include 6 | 7 | NVDMClass NVDM; 8 | 9 | static NVDMStatus _convert_status_code(nvdm_status_t code) 10 | { 11 | NVDMStatus result; 12 | 13 | switch (code) 14 | { 15 | case NVDM_STATUS_INVALID_PARAMETER: 16 | result = NVDM_INVALID_PARAMETER; 17 | break; 18 | case NVDM_STATUS_ITEM_NOT_FOUND: 19 | result = NVDM_ITEM_NOT_FOUND; 20 | break; 21 | case NVDM_STATUS_INSUFFICIENT_SPACE: 22 | result = NVDM_INSUFFICIENT_SPACE; 23 | break; 24 | case NVDM_STATUS_INCORRECT_CHECKSUM: 25 | result = NVDM_INCORRECT_CHECKSUM; 26 | break; 27 | case NVDM_STATUS_ERROR: 28 | result = NVDM_ERROR; 29 | break; 30 | case NVDM_STATUS_OK: 31 | result = NVDM_OK; 32 | break; 33 | default: 34 | result = NVDM_ERROR; 35 | } 36 | 37 | return result; 38 | } 39 | 40 | /* write data into the flash 41 | [IN] sectionName - The name of the data section 42 | [IN] propertyName - The name of the property inside the data section specified above 43 | [IN] dataType - The data type to be stored 44 | [IN] buffer - The buffer which contains the data 45 | [IN] data_size - The size of the data 46 | */ 47 | NVDMStatus NVDMClass::write(const char *sectionName, const char *propertyName, NVDMDataType dataType, const uint8_t *buffer, uint32_t data_size) 48 | { 49 | nvdm_status_t ret; 50 | 51 | ret = nvdm_write_data_item( 52 | sectionName, 53 | propertyName, 54 | (dataType == NVDM_RAW_DATA)? NVDM_DATA_ITEM_TYPE_RAW_DATA: NVDM_DATA_ITEM_TYPE_STRING, 55 | buffer, 56 | data_size); 57 | return _convert_status_code(ret); 58 | } 59 | 60 | /* read data from the flash 61 | [IN] sectionName - The name of the data section 62 | [IN] propertyName - The name of the property inside the data section specified above 63 | [IN] buffer - The buffer to contain the data 64 | [IN/OUT] data_size - as input: the size of the buffer. as output: the size of the read-out data 65 | */ 66 | NVDMStatus NVDMClass::read(const char *sectionName, const char *propertyName, uint8_t *buffer, uint32_t *size) 67 | { 68 | nvdm_status_t ret; 69 | ret = nvdm_read_data_item(sectionName, propertyName, buffer, size); 70 | return _convert_status_code(ret); 71 | } 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /libraries/NVDM/src/NVDM.h: -------------------------------------------------------------------------------- 1 | #ifndef __NVDM_H__ 2 | #define __NVDM_H__ 3 | 4 | #define MTK_NVDM_ENABLE 5 | #ifdef MTK_NVDM_ENABLE 6 | 7 | #include 8 | 9 | typedef enum 10 | { 11 | NVDM_RAW_DATA, 12 | NVDM_STRING_DATA 13 | } NVDMDataType; 14 | 15 | typedef enum 16 | { 17 | NVDM_INVALID_PARAMETER = -5, /**< The user parameter is invalid. */ 18 | NVDM_ITEM_NOT_FOUND = -4, /**< The data item wasn't found. */ 19 | NVDM_INSUFFICIENT_SPACE = -3, /**< No space is available in the flash. */ 20 | NVDM_INCORRECT_CHECKSUM = -2, /**< Found a checksum error when reading the data item. */ 21 | NVDM_ERROR = -1, /**< An unknown error occurred. */ 22 | NVDM_OK = 0 /**< The operation was successful. */ 23 | } NVDMStatus; 24 | 25 | class NVDMClass 26 | { 27 | public: 28 | NVDMClass(){}; 29 | 30 | /* write data into the flash 31 | [IN] sectionName - The name of the data section 32 | [IN] propertyName - The name of the property inside the data section specified above 33 | [IN] dataType - The data type to be stored 34 | [IN] buffer - The buffer which contains the data 35 | [IN] data_size - The size of the data 36 | */ 37 | NVDMStatus write( 38 | const char *sectionName, 39 | const char *propertyName, 40 | NVDMDataType dataType, 41 | const uint8_t *buffer, 42 | uint32_t dataSize); 43 | 44 | /* read data from the flash 45 | [IN] sectionName - The name of the data section 46 | [IN] propertyName - The name of the property inside the data section specified above 47 | [IN] buffer - The buffer to contain the data 48 | [IN/OUT] data_size - as input: the size of the buffer. as output: the size of the read-out data 49 | */ 50 | NVDMStatus read(const char *sectionName, const char *propertyName, uint8_t *buffer, uint32_t *size); 51 | 52 | private: 53 | }; 54 | 55 | extern NVDMClass NVDM; 56 | 57 | #else 58 | #error "MTK_NVDM_ENABLE not defined." 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libraries/SPI/library.properties: -------------------------------------------------------------------------------- 1 | name=SPI 2 | version=1.0 3 | author=WizIO 4 | maintainer=WizIO 5 | sentence=SPI 6 | paragraph=SPI 7 | url=https://github.com/Wiz-IO/Arduino-Quectel-BC66 8 | architectures=bc66 9 | category=Communication 10 | core-dependencies=arduino (>=1.6.6) -------------------------------------------------------------------------------- /libraries/SPI/src/LICENSE: -------------------------------------------------------------------------------- 1 | This software is Copyright (C) 2008 Mike McCauley. Use is subject to license 2 | conditions. The main licensing options available are GPL V2 or Commercial: 3 | 4 | Open Source Licensing GPL V2 5 | 6 | This is the appropriate option if you want to share the source code of your 7 | application with everyone you distribute it to, and you also want to give them 8 | the right to share who uses it. If you wish to use this software under Open 9 | Source Licensing, you must contribute all your source code to the open source 10 | community in accordance with the GPL Version 2 when your application is 11 | distributed. See http://www.gnu.org/copyleft/gpl.html 12 | 13 | Commercial Licensing 14 | 15 | This is the appropriate option if you are creating proprietary applications 16 | and you are not prepared to distribute and share the source code of your 17 | application. Contact info@open.com.au for details. 18 | -------------------------------------------------------------------------------- /libraries/SPI/src/SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on: 01.15.2019 3 | * Author: Georgi Angelov 4 | */ 5 | 6 | #ifndef __SPI_H__ 7 | #define __SPI_H__ 8 | 9 | #include 10 | 11 | /* 12 | 13 | QUECTEL OpenCPU 14 | 15 | typedef enum 16 | { 17 | HAL_SPI_MASTER_LSB_FIRST = 0x0, 18 | HAL_SPI_MASTER_MSB_FIRST = 0x1, 19 | } hal_spi_master_bit_order_t; 20 | 21 | spi_config.bit_order = HAL_SPI_MASTER_MSB_FIRST = 0x1; 22 | 23 | */ 24 | 25 | typedef enum 26 | { 27 | SPI_MODE0 = 0, 28 | SPI_MODE1, 29 | SPI_MODE2, 30 | SPI_MODE3, 31 | } SPIDataMode; 32 | 33 | class SPISettings 34 | { 35 | public: 36 | SPISettings(uint32_t clockFrequency, BitOrder bitOrder, SPIDataMode dataMode); 37 | SPISettings(); 38 | 39 | private: 40 | uint32_t clock; 41 | BitOrder order; 42 | SPIDataMode mode; 43 | friend class SPIClass; 44 | }; 45 | 46 | class SPIClass 47 | { 48 | public: 49 | SPIClass(); 50 | SPIClass(uint32_t chnnl); 51 | SPIClass(uint32_t chnnl, int miso, int mosi, int clk, int cs); 52 | void begin(); 53 | void end(); 54 | 55 | void setBitOrder(BitOrder order); 56 | void setDataMode(uint8_t mode); 57 | void setFrequency(uint32_t frequency); 58 | 59 | void beginTransaction(SPISettings settings); 60 | void endTransaction(void); 61 | uint8_t transfer(uint8_t data); 62 | uint16_t transfer16(uint16_t _data); 63 | int transfer(uint8_t *tx, uint32_t wLen); 64 | int transfer(uint8_t *tx, uint32_t wLen, uint8_t *rx, uint32_t rLen); 65 | void cs(int level); 66 | 67 | void setClockDivider(uint8_t){}; 68 | void setClockDivider(uint8_t, uint8_t) {} 69 | void attachInterrupt(){}; 70 | void detachInterrupt(){}; 71 | 72 | private: 73 | uint32_t _port; 74 | uint32_t _clock; 75 | 76 | bool _order; 77 | bool _cpol; 78 | bool _cpha; 79 | bool _type; 80 | 81 | Enum_PinName _miso; 82 | Enum_PinName _mosi; 83 | Enum_PinName _clk; 84 | Enum_PinName _cs; 85 | void set_hard_pins(); 86 | }; 87 | 88 | extern SPIClass SPI; 89 | 90 | #endif -------------------------------------------------------------------------------- /libraries/Timer/example/basic/basic.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | GPTimer T1 = GPTimer(TIMER_FAST); // this timer is independent of the task, only one for task 4 | void onTimerFast(u32 timerId, void *param) 5 | { 6 | static int state = 0; 7 | digitalWrite(LED, ++state ^ 1); 8 | } 9 | 10 | GPTimer T2 = GPTimer(TIMER_1); // for this timers loop() must be fast 11 | void onTimer(u32 timerId, void *param) 12 | { 13 | Serial.println("TIMER"); 14 | } 15 | 16 | void setup() 17 | { 18 | Dev.noSleep(); // disable PSM sleep 19 | Serial.begin(115200); 20 | Serial.debug(); // enable debug for this port, DBG( work as printf ) 21 | Serial.printf("Arduino %s\n", Dev.getVersion()); 22 | pinMode(LED, OUTPUT); 23 | digitalWrite(LED, 1); 24 | T1.start(200, 1, onTimerFast); 25 | T2.start(5000, 1, onTimer); 26 | } 27 | 28 | void loop() 29 | { 30 | // some fast code or state machine 31 | } -------------------------------------------------------------------------------- /libraries/Timer/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For LTimer 3 | ####################################### 4 | 5 | ####################################### 6 | # Library (KEYWORD1) 7 | ####################################### 8 | LTimer KEYWORD1 9 | 10 | ####################################### 11 | # Datatypes (KEYWORD1) 12 | ####################################### 13 | LTimerMode KEYWORD1 14 | LTimerStatus KEYWORD1 15 | LTimerID KEYWORD1 16 | 17 | ####################################### 18 | # Methods and Functions (KEYWORD2) 19 | ####################################### 20 | 21 | stop KEYWORD2 22 | begin KEYWORD2 23 | start KEYWORD2 24 | end KEYWORD2 25 | 26 | ####################################### 27 | # Constants (LITERAL1) 28 | ####################################### 29 | -------------------------------------------------------------------------------- /libraries/Timer/library.properties: -------------------------------------------------------------------------------- 1 | name=Timer 2 | version=1.0 3 | author=WizIO 4 | maintainer=WizIO 5 | sentence=Timer 6 | paragraph=Timer 7 | url=https://github.com/Wiz-IO/Arduino-Quectel-BC66 8 | architectures=bc66 9 | category=Communication 10 | core-dependencies=arduino (>=1.6.6) -------------------------------------------------------------------------------- /libraries/Timer/src/GPTimer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GPTimer.h" 3 | 4 | #define DEBUG_TMR 5 | //DBG 6 | 7 | GPTimer::GPTimer(TimerID id) 8 | { 9 | m_id = id; 10 | if (id < TIMER_FAST || id > TIMER_END) 11 | m_id = 0; 12 | } 13 | 14 | int GPTimer::start(uint32_t interval, bool mode, Callback_Timer_OnTimer callback, void *user) 15 | { 16 | int res = -1; 17 | if (callback && m_id) 18 | { 19 | if (TIMER_FAST == m_id) 20 | { 21 | res = Ql_Timer_RegisterFast(m_id, callback, user); 22 | } 23 | else 24 | { 25 | res = Ql_Timer_Register(m_id, callback, user); 26 | } 27 | DEBUG_TMR("Ql_Timer_Register( %X, %p ) = %d\n", (int)m_id, callback, res); 28 | if (QL_RET_OK == res) 29 | { 30 | res = Ql_Timer_Start(m_id, interval, mode == TIMER_REPEAT_MODE); 31 | DEBUG_TMR("Ql_Timer_Start( %X ) = %d\n", (int)m_id, res); 32 | } 33 | } 34 | return res == QL_RET_OK; 35 | } 36 | 37 | int GPTimer::stop() 38 | { 39 | int res = -1; 40 | if (m_id) 41 | res = Ql_Timer_Stop(m_id); 42 | return res == QL_RET_OK; 43 | } 44 | -------------------------------------------------------------------------------- /libraries/Timer/src/GPTimer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H__ 2 | #define __TIMER_H__ 3 | 4 | #include 5 | 6 | typedef enum 7 | { 8 | TIMER_FAST = 0x100, /* Fast Timer*/ 9 | /* Normal Timers */ 10 | TIMER_1, 11 | TIMER_2, 12 | TIMER_3, 13 | TIMER_4, 14 | TIMER_5, 15 | TIMER_6, 16 | TIMER_7, 17 | TIMER_8, 18 | TIMER_9, 19 | TIMER_END 20 | } TimerID; 21 | 22 | typedef enum 23 | { 24 | TIMER_ONESHOT_MODE = 0, 25 | TIMER_REPEAT_MODE 26 | } TimerMode; 27 | 28 | class GPTimer 29 | { 30 | public: 31 | GPTimer(TimerID id); 32 | int begin() { return m_id; } 33 | int end() { return 0; } 34 | int start(uint32_t interval, bool mode, Callback_Timer_OnTimer callbackFunc, void *user = NULL); 35 | int stop(); 36 | 37 | private: 38 | uint32_t m_id; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /libraries/Timer/src/RTTimer.h: -------------------------------------------------------------------------------- 1 | #ifndef RTTIMER_H_ 2 | #define RTTIMER_H_ 3 | 4 | #include 5 | 6 | class RTTimer 7 | { 8 | public: 9 | RTTimer() 10 | { 11 | handle = NULL; 12 | } 13 | 14 | ~RTTimer() 15 | { 16 | if (handle) 17 | free(handle); 18 | } 19 | 20 | int begin(uint32_t ms, int auto_reload, TimerCallbackFunction_t callback, void *user) 21 | { 22 | static int once = 0; 23 | if (0 == once) 24 | { 25 | ms /= 10; 26 | if (0 == ms) 27 | ms = 1; 28 | handle = xTimerCreate("A_TMR", ms, auto_reload, user, callback); 29 | once = (int)handle; 30 | } 31 | return handle != NULL; 32 | } 33 | 34 | int period(uint32_t ms, uint32_t wait = 0) 35 | { 36 | ms /= 10; 37 | if (0 == ms) 38 | ms = 1; 39 | if (handle) 40 | return xTimerChangePeriod(handle, ms, wait); 41 | return pdFAIL; 42 | } 43 | 44 | int reset(uint32_t wait = 0) 45 | { 46 | if (handle) 47 | return xTimerReset(handle, wait); 48 | return pdFAIL; 49 | } 50 | 51 | int start(uint32_t wait = 0) 52 | { 53 | if (handle) 54 | return xTimerStart(handle, wait); 55 | return pdFAIL; 56 | } 57 | 58 | int stop(uint32_t wait = 0) 59 | { 60 | if (handle) 61 | return xTimerStop(handle, wait); 62 | return pdFAIL; 63 | } 64 | 65 | private: 66 | TimerHandle_t handle; 67 | }; 68 | 69 | #endif /* RTTIMER_H_ */ -------------------------------------------------------------------------------- /libraries/Wire/library.properties: -------------------------------------------------------------------------------- 1 | name=Wire 2 | version=1.0 3 | author=WizIO 4 | maintainer=WizIO 5 | sentence=Wire 6 | paragraph=Wire 7 | url=https://github.com/Wiz-IO/Arduino-Quectel-BC66 8 | architectures=bc66 9 | category=Communication 10 | core-dependencies=arduino (>=1.6.6) -------------------------------------------------------------------------------- /libraries/Wire/src/Wire.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TWI/I2C library for Arduino Zero 3 | * Copyright (c) 2015 Arduino LLC. All rights reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef __WIRE_H__ 21 | #define __WIRE_H__ 22 | 23 | #include "interface.h" 24 | #include "Stream.h" 25 | #include "variant.h" 26 | #include "RingBuffer.h" 27 | 28 | #define BUFFER_LENGTH SERIAL_BUFFER_SIZE 29 | 30 | class TwoWire : public Stream 31 | { 32 | public: 33 | TwoWire(uint8_t port, uint8_t address, u32 brg = I2C_FREQUENCY_400K); 34 | 35 | void begin(); 36 | void end(); 37 | void setClock(uint32_t); 38 | void beginTransmission(uint8_t); 39 | uint8_t endTransmission(bool stopBit); 40 | uint8_t endTransmission(void); 41 | uint8_t requestFrom(uint8_t address, size_t quantity, bool stopBit); 42 | uint8_t requestFrom(uint8_t address, size_t quantity); 43 | size_t write(uint8_t data); 44 | size_t write(const uint8_t *data, size_t quantity); 45 | virtual int available(void); 46 | virtual int read(void); 47 | virtual int peek(void); 48 | virtual void flush(void); 49 | using Print::write; 50 | 51 | void onService(void){}; 52 | void onReceive(void (*)(int)){}; 53 | void onRequest(void (*)(void)){}; 54 | 55 | private: 56 | uint8_t i2c_port; 57 | u32 i2c_speed; 58 | 59 | bool transmissionBegun; 60 | uint8_t slaveAddress; 61 | 62 | // RX Buffer 63 | RingBuffer rxBuffer; 64 | 65 | // TX buffer 66 | RingBuffer txBuffer; 67 | uint8_t txAddress; 68 | 69 | void (*onRequestCallback)(void){}; 70 | void (*onReceiveCallback)(int){}; 71 | 72 | }; 73 | 74 | extern TwoWire Wire; 75 | 76 | #endif -------------------------------------------------------------------------------- /platform.txt: -------------------------------------------------------------------------------- 1 | # WizIO 2018 Georgi Angelov 2 | # https://github.com/Wiz-IO/Arduino-Quectel-BC66/blob/master/README.md 3 | # the.wizarda@gmail.com 4 | # 5 | # Arduino Core and platform. 6 | # For more info: 7 | # https:\\github.com\arduino\Arduino\wiki\Arduino-IDE-1.5---3rd-party-Hardware-specification 8 | 9 | name=WizIO 10 | version=2.0.0 11 | 12 | compiler.path={build.compiler_path} 13 | compiler.c.cmd=arm-none-eabi-gcc 14 | compiler.cpp.cmd=arm-none-eabi-g++ 15 | compiler.c.elf.cmd=arm-none-eabi-g++ 16 | compiler.ar.cmd=arm-none-eabi-ar 17 | compiler.objcopy.cmd=arm-none-eabi-objcopy 18 | compiler.size.cmd=arm-none-eabi-size 19 | 20 | compiler.include="-I{build.core.path}\" "-I{build.core.path}\include\" "-I{build.core.path}\ril\inc\" "-I{build.core.path}\api\" "-I{build.core.path}\api\arch\" "-I{build.core.path}\api\lwip\" "-I{build.core.path}\api\freertos\" 21 | 22 | compiler.S.flags=-x assembler-with-cpp 23 | 24 | compiler.gcc.c.flags=-Os -Wall -g -fno-strict-aliasing -ffunction-sections -fdata-sections -Wno-pointer-sign -Wstrict-prototypes -Wp,-w "-DARDUINO=200" 25 | 26 | compiler.c.flags=-std=c11 27 | 28 | compiler.cpp.flags=-std=c++11 -fno-exceptions -fno-non-call-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics 29 | 30 | compiler.c.elf.flags=-nostartfiles -nodefaultlibs -fno-use-cxa-atexit -Xlinker --gc-sections -Wl,--gc-sections 31 | 32 | compiler.ar.flags=rcs 33 | 34 | compiler.objcopy.remove.flags=--strip-debug 35 | 36 | compiler.objcopy.bin.flags=-O binary 37 | 38 | ###### Compile S files 39 | recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {build.mcu} {compiler.S.flags} {compiler.c.flags} {compiler.include} {includes} "{source_file}" -o "{object_file}" 40 | 41 | ###### C Compile files 42 | recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {build.mcu} {compiler.c.flags} {build.extra_flags} {compiler.gcc.c.flags} {compiler.include} {includes} "{source_file}" -c -o "{object_file}" 43 | 44 | ###### CPP Compile files 45 | recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {build.mcu} {compiler.cpp.flags} {build.extra_flags} {compiler.gcc.c.flags} {compiler.include} {includes} "{source_file}" -c -o "{object_file}" 46 | 47 | ###### AR Create archives 48 | recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{archive_file_path}" "{object_file}" 49 | 50 | ###### ELF Combine gc-sections, archives, and objects 51 | recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {build.mcu} {compiler.c.elf.flags} "-T{build.core.path}/cpp_bc66.ld" -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group "{build.path}/{archive_file}" {object_files} "{build.core.path}/lib_app_start_bc66.a" "{build.core.path}/lib_{build.firmware}.a" -Wl,--end-group -v 52 | 53 | ###### Create BIN 54 | recipe.objcopy.bin.1.pattern="{compiler.path}{compiler.objcopy.cmd}" -g -R .comment "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.dat" 55 | recipe.objcopy.bin.2.pattern="{compiler.path}{compiler.objcopy.cmd}" -O binary "{build.path}/{build.project_name}.dat" "{build.path}/APPGS3MDM32A01.bin" 56 | 57 | ###### Add header to BIN 58 | recipe.objcopy.hex.cmd.windows=gfh.bat 59 | recipe.objcopy.hex.1.pattern="{runtime.tools.bc66_tools.path}/GFH_Generator.exe" "{build.path}/APPGS3MDM32A01.bin" 60 | recipe.objcopy.hex.2.pattern=cmd /C copy /y "{runtime.tools.bc66_tools.path}\app_image_bin.cfg" "{build.path}\" 61 | 62 | ###### Compute size 63 | recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" 64 | recipe.size.regex=^(?:\.iram0\.text|\.iram0\.vectors|\.dram0\.data|\.flash\.text|\.flash\.rodata|)\s+([0-9]+).* 65 | recipe.size.regex.data=^(?:\.dram0\.data|\.dram0\.bss|\.noinit)\s+([0-9]+).* 66 | 67 | 68 | ########################################## 69 | 70 | tools.bc66.cmd=coda.exe 71 | tools.bc66.cmd.windows=coda.exe 72 | tools.bc66.path={runtime.tools.bc66_tools.path} 73 | tools.bc66.upload.params.verbose=-vvvvvv 74 | tools.bc66.upload.params.quiet=-q 75 | tools.bc66.upload.pattern=cmd /C echo [ UPLOAD ] POWER-ON or RESET board to start flashing & cmd /C "{path}\{cmd}" "{build.path}\app_image_bin.cfg" --UART {serial.port.file} -d & cmd /C echo [ DONE ] Power on board 76 | 77 | -------------------------------------------------------------------------------- /programmers.txt: -------------------------------------------------------------------------------- 1 | # WizIO 2018 Georgi Angelov 2 | # https://github.com/Wiz-IO/Arduino-MT2625-BC66/blob/master/README.md 3 | # the.wizarda@gmail.com 4 | 5 | -------------------------------------------------------------------------------- /variants/bc66/variant.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on: 01.15.2019 3 | * Author: Georgi Angelov 4 | */ 5 | 6 | #include 7 | 8 | void initVariant() {} 9 | 10 | HardwareSerial Serial(0); 11 | HardwareSerial Serial1(1); 12 | HardwareSerial Serial2(2); 13 | 14 | -------------------------------------------------------------------------------- /variants/bc66/variant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on: 01.15.2019 3 | * Author: Georgi Angelov 4 | */ 5 | 6 | #ifndef __VARIANT_H__ 7 | #define __VARIANT_H__ 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | 16 | #define LED 4 /* PINNAME_NETLIGHT */ 17 | #define LED_BUILTIN 4 /* PINNAME_NETLIGHT */ 18 | #define ADC0 PIN_ADC0 /* ONLY THIS PIN */ 19 | #define PWM0 PINNAME_NETLIGHT 20 | #define PWM1 PINNAME_RTS_AUX 21 | #define PWM2 PINNAME_GPIO3 22 | 23 | typedef struct 24 | { 25 | uint8_t arduino; 26 | uint8_t device; 27 | void *eint; 28 | } PinDescription; 29 | extern PinDescription pinsMap[18]; 30 | 31 | PinDescription *getArduinoPin(uint8_t arduinoPin); 32 | PinDescription *getDevicePin(uint8_t devicePin); 33 | 34 | typedef void (*eint_callback_t)(uint32_t level); 35 | void eintMode(uint8_t pin, Enum_EintType type, eint_callback_t cb, uint32_t hwDebounce, uint32_t swDebounce, bool automask); 36 | 37 | void analogReference(uint8_t mode) __attribute__((weak)); 38 | void analogOpen(uint8_t pin, /* val, src, div */...); 39 | void analogClose(uint8_t pin); 40 | int analogRead(uint8_t pin); 41 | void analogWrite(uint8_t pin, int val); 42 | 43 | #ifdef __cplusplus 44 | } 45 | 46 | void initVariant(); 47 | 48 | #include 49 | extern HardwareSerial Serial; 50 | extern HardwareSerial Serial1; 51 | extern HardwareSerial Serial2; 52 | 53 | #include 54 | extern DeviceClass Dev; 55 | 56 | #include 57 | extern PSMClass Psm; 58 | 59 | #endif //__cplusplus 60 | 61 | #endif /* __VARIANT_H__ */ 62 | -------------------------------------------------------------------------------- /variants/bc66/variant_pins.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on: 01.15.2019 3 | * Author: Georgi Angelov 4 | */ 5 | 6 | #include "variant.h" 7 | 8 | PinDescription pinsMap[18] = { 9 | {0, PINNAME_SPI_MISO, NULL}, 10 | {1, PINNAME_SPI_MOSI, NULL}, 11 | {2, PINNAME_SPI_SCLK, NULL}, 12 | {3, PINNAME_SPI_CS, NULL}, 13 | {4, PINNAME_NETLIGHT, NULL}, 14 | {5, PINNAME_RI, NULL}, 15 | {6, PINNAME_DCD, NULL}, 16 | {7, PINNAME_CTS_AUX, NULL}, 17 | {8, PINNAME_RTS_AUX, NULL}, 18 | {9, PINNAME_GPIO1, NULL}, 19 | {10, PINNAME_RXD_AUX, NULL}, 20 | {11, PINNAME_TXD_AUX, NULL}, 21 | {12, PINNAME_GPIO2, NULL}, 22 | {13, PINNAME_GPIO3, NULL}, 23 | {14, PINNAME_GPIO4, NULL}, 24 | {15, PINNAME_GPIO5, NULL}, 25 | {16, PINNAME_RXD_DBG, NULL}, 26 | {17, PINNAME_TXD_DBG, NULL}, 27 | }; 28 | --------------------------------------------------------------------------------