Skip to content

Commit

Permalink
Signed-off-by: WizIO <the.wizarda@gmail.com>
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiz-IO committed Apr 12, 2019
1 parent 672ec0f commit c346e48
Show file tree
Hide file tree
Showing 132 changed files with 27,373 additions and 0 deletions.
32 changes: 32 additions & 0 deletions boards.txt
@@ -0,0 +1,32 @@
# WizIO 2018 Georgi Angelov
# https://github.com/Wiz-IO/Arduino-Quectel-M66
# the.wizarda@gmail.com
#
# Arduino Core and platform.
# For more info:
# https:\\github.com\arduino\Arduino\wiki\Arduino-IDE-1.5---3rd-party-Hardware-specification

menu.firmware=Firmware

M66.build.core=opencpu
M66.build.variant=m66
M66.name=Quectel M66 Module
M66.build.board=Quectel M66
M66.build.compiler_path={runtime.tools.bc66_gcc.path}\bin\
M66.build.mcu=-march=armv5te -mfloat-abi=soft -mfpu=vfp -mthumb-interwork
M66.build.extra_flags=
M66.build.f_cpu=260000000L

M66.menu.firmware.V1=M66FAR01A12BT
M66.menu.firmware.V1.build.firmware=M66FAR01A12BT

M66.upload.maximum_size=368640
M66.upload.maximum_data_size=102400
M66.upload.tool=m66
M66.upload.protocol=quectel
M66.upload.use_1200bps_touch=false
M66.upload.wait_for_upload_port=false
M66.upload.native_usb=false
M66.upload.via_ssh=false


79 changes: 79 additions & 0 deletions cores/opencpu/Arduino.h
@@ -0,0 +1,79 @@
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 28 September 2018 by Georgi Angelov
*/

#ifndef Arduino_h
#define Arduino_h

#include <interface.h>
#include <variant.h>

#ifdef __cplusplus
extern "C"
{
#endif

#include "pgmspace.h"
#include "binary.h"
#include "constants.h"

unsigned int seconds(void);
unsigned int millis(void);
unsigned int micros(void);
void delay(unsigned int);
void delayMicroseconds(unsigned int us);

void pinMode(uint8_t, uint8_t);
void digitalWrite(uint8_t, uint8_t);
int digitalRead(uint8_t);

void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);

unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) __attribute__((weak));
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) __attribute__((weak));

void yield(void) __attribute__((weak));
void interrupts(void) __attribute__((weak));
void noInterrupts(void) __attribute__((weak));
void attachInterrupt(uint8_t, void (*)(void), int mode) __attribute__((weak));
void detachInterrupt(uint8_t) __attribute__((weak));

#ifdef __cplusplus
} // extern "C"

////////////////////////////////////////////////////////////////////////////////////////////////

#include "WCharacter.h"
#include "WString.h"

long random(long);
long random(long howsmall, long howbig);
void randomSeed(unsigned long seed);
long map(long x, long in_min, long in_max, long out_min, long out_max);
unsigned int makeWord(unsigned int w);
unsigned int makeWord(unsigned char h, unsigned char l);

void noTone(uint8_t _pin) __attribute__((weak));
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0) __attribute__((weak));

#endif //__cplusplus

#endif //Arduino_h
45 changes: 45 additions & 0 deletions cores/opencpu/Client.h
@@ -0,0 +1,45 @@
/*
Client.h - Base class that provides Client
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef client_h
#define client_h
#include "Print.h"
#include "Stream.h"
#include "IPAddress.h"

class Client : public Stream {

public:
virtual int connect(IPAddress ip, uint16_t port) =0;
virtual int connect(const char *host, uint16_t port) =0;
virtual size_t write(uint8_t) =0;
virtual size_t write(const uint8_t *buf, size_t size) =0;
virtual int available() = 0;
virtual int read() = 0;
virtual int read(uint8_t *buf, size_t size) = 0;
virtual int peek() = 0;
virtual void flush() = 0;
virtual void stop() = 0;
virtual uint8_t connected() = 0;
virtual operator bool() = 0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
};

#endif
97 changes: 97 additions & 0 deletions cores/opencpu/DEV.cpp
@@ -0,0 +1,97 @@
#include "DEV.h"

void DeviceClass::getImsi(char *buffer, uint32_t size)
{
if (buffer && size > 15)
{
memset(buffer, 0, size);
api_getIMSI(buffer);
}
}

void DeviceClass::getImsi(String &s)
{
char buffer[16];
memset(buffer, 0, 16);
api_getIMSI(buffer);
s = buffer;
}

void DeviceClass::getImei(char *buffer, uint32_t size)
{
if (buffer && size > 15)
{
memset(buffer, 0, size);
api_getIMEI(buffer);
}
}

void DeviceClass::getImei(String &s)
{
char buffer[16];
memset(buffer, 0, 16);
api_getIMEI(buffer);
s = buffer;
}

int DeviceClass::getSimStatus()
{
return api_getSimStatus(); // 0 = READY,
}

void DeviceClass::enterPin(const char *pin)
{
int res;
if (pin)
{
Dev.ril.sendf("AP+CPIN =\"%s\"", pin);
if (ril.waitForResponse() == 1)
return;
}
TRACE("[PIN] ERROR\n");
while (true)
Ql_Sleep(1000);
}

void DeviceClass::waitSimReady(const char *pin)
{
int status;
do
{
delayEx(100);
status = api_getSimStatus();
if (status == -666) // TODO status enum
enterPin(pin);
} while (0 != status);
}

void DeviceClass::waitCreg()
{
while (1)
{
int res = getCreg();
if (res == 5 || res == 1)
break;
delayEx(100);
}
}

void DeviceClass::waitCgreg()
{
while (1)
{
int res = getCgreg();
if (res == 5 || res == 1)
break;
delayEx(100);
}
}

void DeviceClass::waitCereg(){
waitCreg();
delay(200);
waitCgreg();
delay(200);
}

DeviceClass Dev;
99 changes: 99 additions & 0 deletions cores/opencpu/DEV.h
@@ -0,0 +1,99 @@
#ifndef __DEV_H__
#define __DEV_H__

#include <interface.h>
#include "RilClass.h"
extern HardwareSerial Virtual;

typedef void (*vCallback)(void);
typedef void (*uCallback)(u32, u32);
typedef void (*mCallback)(ST_MSG *msg);

class DeviceClass
{
public:
DeviceClass()
{
onMessage = NULL;
onUrc = NULL;
wtdID = -1;
}

RilClass ril = RilClass(Virtual);
RilClass &operator=(RilClass &ril);
void begin()
{
ril.begin();
}

mCallback onMessage;
void m_Message(ST_MSG *m)
{
if (onMessage)
onMessage(m);
}

uCallback onUrc;
void m_Urc(u32 urc, u32 data)
{
if (onUrc)
onUrc(urc, data);
}

const char *getVersion() { return api_getVersion(); }
void getImsi(char *imsi, uint32_t size = 16);
void getImsi(String &s);

void getImei(char *imei, uint32_t size = 16);
void getImei(String &s);

int getSimStatus();
void waitSimReady(const char *pin = NULL);
void enterPin(const char *pin);

int getCreg() { return api_getNetworkState(1); }
void waitCreg();

int getCgreg() { return api_getNetworkState(2); }
void waitCgreg();
void waitCereg();

void reset() { Ql_Reset(0); }
void powerOff() { Ql_PowerDown(1); }
int powerReason() { return Ql_GetPowerOnReason(); }
void Sleep() { Ql_SleepEnable(); }
void noSleep() { Ql_SleepDisable(); }

///for pin pulse
int watchdog(uint8_t pin, unsigned int interval = 1000)
{
if (interval < 200)
interval == 200;
//A2Q(pin);
return Ql_WTD_Init(0, (Enum_PinName)pin, interval);
}
///internal watchdog
void beginWatchdog(unsigned int interval = 1000)
{
if (interval < 400)
interval = 400;
wtdID = Ql_WTD_Start(interval);
}
void endWatchdog()
{
if (wtdID > 0)
Ql_WTD_Stop(wtdID);
}
void kickWatchdog()
{
if (wtdID > 0)
Ql_WTD_Feed(wtdID);
}

private:
int wtdID;
};

extern DeviceClass Dev;

#endif //__DEV_H__

0 comments on commit c346e48

Please sign in to comment.