23 Commits

Author SHA1 Message Date
Bigbits
c74b948b53 add open-ec super speed support. 2019-04-26 20:18:50 +08:00
Bigbits
93fbb08ad6 add c flags 2019-04-26 15:45:44 +08:00
Bigbits
3debc75348 Modify package name. 2019-04-25 07:51:00 +08:00
Bigbits
c07ca972f3 Fix include path for PlatformIO. 2019-04-25 06:51:20 +08:00
Bigbits
8a3ae10f1c Use the usual variants folders. 2019-04-24 20:31:21 +08:00
Bits
b53e72fe8e Add OSX upload cmd #3 2019-04-20 20:07:31 +08:00
Bigbits
d6e171190c Add package.json 2019-04-19 17:42:54 +08:00
Bigbits
827797bdb2 Specifying a PID will cause errors on other Arduino boards. 2019-04-16 12:08:05 +08:00
Bigbits
6116e6b348 Fix interrupts bug. 2019-04-13 17:54:13 +08:00
Bigbits
fd93da2c00 Fix io bug. 2019-04-12 20:36:57 +08:00
Bigbits
0c42ce6f28 fix a bug 2019-04-12 19:31:59 +08:00
Bigbits
63d00b0ea5 Modify the Serial1.begin baudrate. #2 2019-04-12 16:58:02 +08:00
Bigbits
23062f3df7 Specify the include file 2019-04-07 17:43:20 +08:00
Bigbits
dfed93ad27 Add lvgl support 2019-04-07 17:37:51 +08:00
Bigbits
7dc6ee2366 Some fix 2019-04-07 17:18:07 +08:00
Bigbits
170fb03039 Add Ticker lib (Hardware Timer) 2019-04-07 14:48:39 +08:00
Bigbits
e13913f802 Add TouchScreen Library 2019-04-05 22:49:54 +08:00
Neucrack
57abaf8159 add bin export 2019-04-04 11:49:32 +08:00
Neucrack
a9749d24ce remove kflash color syntax for linux... 2019-04-03 16:59:14 +08:00
Neucrack
c5023445b4 add install doc link 2019-04-03 15:20:50 +08:00
Neucrack
afc08d3dd1 replace k-flash with kflash.py on windows 2019-04-03 14:51:07 +08:00
Neucrack
38671731ce update readme 2019-04-02 18:55:12 +08:00
Neucrack
806c7dc762 add license 2019-04-02 18:53:06 +08:00
38 changed files with 1475 additions and 73 deletions

3
.gitmodules vendored
View File

@@ -7,3 +7,6 @@
[submodule "libraries/WiFiEsp"]
path = libraries/WiFiEsp
url = https://github.com/btx000/WiFiEsp
[submodule "libraries/lv_arduino"]
path = libraries/lv_arduino
url = https://github.com/btx000/lv_arduino.git

28
LICENSE.md Normal file
View File

@@ -0,0 +1,28 @@
License
======
All the source code in this repository is released under LGPL or Apache v2.0 license even more.
All the sources created/modified by the repository owner are released under Apache v2.0 license and contains the following copyright notice:
Copyright 2019 Sipeed Co.,Ltd.
Most of the source files contains license and copyright notice, please check the individual files for more information.
Also check the license information in individual components directories.
```
Copyright 2019 Sipeed Co.,Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

View File

@@ -1,43 +1,22 @@
# Arduino Core for Kendryte K210
## Windows
### 1.首选项添加下列地址 然后打开开发版管理器下载开发包
>https://bigbits.oss-cn-qingdao.aliyuncs.com/Arduino_for_k210/package_k210_index.json
### 2.安装好之后添加工具链目录到PATH环境变量
>C:\Users\\**(username)**\AppData\Local\Arduino15\packages\Kenduino\tools\riscv64-unknown-elf-gcc\8.2.0\bin
### 3.安装[.Net core runtime](https://download.visualstudio.microsoft.com/download/pr/3f05ee2d-5372-43d6-9562-be86632a53d4/1361281426efa7ff206289adb0411f55/dotnet-runtime-3.0.0-preview3-27503-5-win-x64.exe)
### 4.开发板选择Sipeed M1 Board 编程器选 k-flash
### 5.连接开发板选对应的串口号
### 6.编写程序 编译 上传 完成
----
## Ubuntu
### 1.首选项添加下列地址 然后打开开发版管理器下载开发包
>https://bigbits.oss-cn-qingdao.aliyuncs.com/Arduino_for_k210/package_k210_index.json
### 2.需要解决usb串口访问权限
>sudo usermode -a -G dialout **(username)**
### 3.安装pyserial
>pip3 install pyserial
### 4.开发板选择Sipeed M1 Board 编程器选 k-flash
### 5.连接开发板选对应的串口号
### 6.编写程序 编译 上传 完成
----
## Windows
### 1.Add the following address to the **Preferences** and open the **Boards Manager** to download the development kit.
>https://bigbits.oss-cn-qingdao.aliyuncs.com/Arduino_for_k210/package_k210_index.json
### 2.Add the toolchain directory to the PATH environment variable after installation.
>C:\Users\\**(username)**\AppData\Local\Arduino15\packages\Kenduino\tools\riscv64-unknown-elf-gcc\8.2.0\bin
### 3.Install [.Net core runtime](https://download.visualstudio.microsoft.com/download/pr/3f05ee2d-5372-43d6-9562-be86632a53d4/1361281426efa7ff206289adb0411f55/dotnet-runtime-3.0.0-preview3-27503-5-win-x64.exe)
### 4.Board selects Sipeed M1 Board & Programmer to choose k-flash.
### 5.Connect the development board and then choose the serial port.
### 6.Now you can write the Arduino code and upload it to the k210 board.
----
## Ubuntu
### 1.Add the following address to the **Preferences** and open the **Boards Manager** to download the development kit.
>https://bigbits.oss-cn-qingdao.aliyuncs.com/Arduino_for_k210/package_k210_index.json
### 2.Enter the following command in the terminal to solve the problem of usb serial port access rights.
>sudo usermode -a -G dialout **(username)**
### 3.Install pyserial
>pip3 install pyserial
### 4.Board selects Sipeed M1 Board & Programmer to choose k-flash.
### 5.Connect the development board and then choose the serial port.
### 6.Now you can write the Arduino code and upload it to the k210 board.
----
Maixduino
========
Arduino core for Maix Board (K210)
## Docs
Docs: [maixduino.sipeed.com](https://maixduino.sipeed.com/)
## Install
Refer install doc: [Install](https://maixduino.sipeed.com/en/get_started/install.html)
## Other SDK
If you want to code by scripts, refer to our [MaixPy](https://maixpy.sipeed.com)

View File

@@ -7,8 +7,6 @@ menu.toolsloc = Tool Install Location
############# Sipeed M1 Dock Board ###############
m1.name = Sipeed "Maix One Dock"/"Maix Bit" Board
m1.vid.0=0x1A86
m1.pid.0=0x7523
## Toolchain
m1.menu.toolsloc.default=Default
@@ -35,7 +33,7 @@ m1.menu.burn_tool_firmware.dan = Default
m1.menu.burn_tool_firmware.dan.build.burn_tool_firmware = dan
## Point to the file for ./variants/<variant>/pins_arduino.h
m1.build.variant=standard
m1.build.variant=sipeed_maix_one
## "The 'core' file directory for this board, in ./cores
m1.build.core=arduino
@@ -58,9 +56,6 @@ m1.build.ldscript={runtime.platform.path}/cores/arduino/kendryte-standalone-sdk/
go.name = Sipeed Maix Go Board
go.vid.0=0x0403
go.pid.0=0x6010
## Toolchain
go.menu.toolsloc.default=Default
@@ -76,9 +71,11 @@ go.menu.clksrc.600.build.f_cpu = 600000000L
## Burn baud rate
go.menu.burn_baudrate.2000000 = 2 Mbps
go.menu.burn_baudrate.4500000 = 4.5 Mbps (Must open-ec!)
go.menu.burn_baudrate.1500000 = 1.5 Mbps
go.menu.burn_baudrate.1000000 = 1 Mbps
go.menu.burn_baudrate.2000000.build.burn_baudrate = 2000000
go.menu.burn_baudrate.4500000.build.burn_baudrate = 4500000
go.menu.burn_baudrate.1500000.build.burn_baudrate = 1500000
go.menu.burn_baudrate.1000000.build.burn_baudrate = 1000000
@@ -89,7 +86,7 @@ go.menu.burn_tool_firmware.goE.build.burn_tool_firmware = goE
go.menu.burn_tool_firmware.goD.build.burn_tool_firmware = goD
## Core settings
go.build.variant= standard
go.build.variant= sipeed_maix_go
go.build.core = arduino
## This sets a define for use in the compiled code.

View File

@@ -107,6 +107,7 @@ UARTClass::read(void)
while(this->_buff->available()){
return this->_buff->read_char();
}
return -1;
}
void

View File

@@ -3,11 +3,13 @@
#include "wiring_constants.h"
#include "plic.h"
void attachInterrupt(uint8_t intnum, voidFuncPtr callback, uint8_t mode)
void attachInterrupt(uint8_t intnum, voidFuncPtr user_callback, uint8_t mode)
{
plic_irq_callback_t _callback = (plic_irq_callback_t)callback;
int gpionum = getGpio(intnum);
if(gpionum >= 0){
fpioa_function_t function = FUNC_GPIOHS0 + gpionum;
fpioa_set_function(intnum, function);
gpiohs_set_drive_mode(gpionum, GPIO_DM_INPUT_PULL_UP);
switch(mode){
case LOW :
gpiohs_set_pin_edge((uint8_t)gpionum, GPIO_PE_LOW);
@@ -25,7 +27,7 @@ void attachInterrupt(uint8_t intnum, voidFuncPtr callback, uint8_t mode)
gpiohs_set_pin_edge((uint8_t)gpionum, GPIO_PE_RISING);
break;
}
gpiohs_irq_register((uint8_t)gpionum, 10, _callback, NULL);
gpiohs_irq_register((uint8_t)gpionum, 10, gpiohs_callback, user_callback);
sysctl_enable_irq();
}
}
@@ -37,3 +39,10 @@ void detachInterrupt(uint8_t intnum)
gpiohs_irq_unregister((uint8_t)gpionum);
}
}
int gpiohs_callback(void *ctx)
{
voidFuncPtr user_callback = ctx;
user_callback();
return 0;
}

View File

@@ -35,7 +35,7 @@ extern "C"{
#define DEFAULT 1
#define EXTERNAL 0
#define digitalPinToInterrupt(Pin) Pin;
#define digitalPinToInterrupt(Pin) Pin
typedef void (*voidFuncPtr)(void);
/*
* \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs. Use digitalPinToInterrupt(pin) to get the correct intnum.
@@ -49,6 +49,8 @@ void attachInterrupt(uint8_t intnum, voidFuncPtr callback, uint8_t mode);
*/
void detachInterrupt(uint8_t intnum);
int gpiohs_callback(void *ctx);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus

View File

@@ -1,5 +1,5 @@
#include "SPI.h"
#include "../../../libraries/SPI/src/SPI.h"
#include "stdio.h"
#include "utils.h"

View File

@@ -96,6 +96,13 @@ int8_t getPwmPin(void)
return -1;
}
uint32_t analogRead( uint32_t ulPin )
{
#if (defined(BOARD_SIPEED_MAIX_GO) || defined(BOARD_SIPEED_MAIX_ONE_DOCK) )
return 0;
#endif
}
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus

View File

@@ -19,7 +19,6 @@ void pinMode(uint8_t dwPin, uint8_t dwMode){
fpioa_function_t function = FUNC_GPIOHS0 + gpionum;
fpioa_set_function(dwPin, function);
gpiohs_set_drive_mode((uint8_t)gpionum, (gpio_drive_mode_t)dwMode);
gpiohs_set_pin((uint8_t)gpionum, GPIO_PV_LOW);
}
return ;
}

View File

@@ -0,0 +1,48 @@
#include <Sipeed_ST7789.h>
#include "touchscreen.h"
SPIClass spi_(SPI0); // MUST be SPI0 for Maix series on board LCD
Sipeed_ST7789 lcd(320, 240, spi_);
TouchScreen touchscreen;
int key = KEY0;
int touchscreen_status = 0;
int touchscreen_x = 0;
int touchscreen_y = 0;
int status_last = TOUCH_NONE;
int x_last = 0;
int y_last = 0;
bool draw = false;
void setup()
{
pinMode(key, INPUT);
lcd.begin(15000000, COLOR_RED);
touchscreen.begin();
touchscreen.calibrate(320,240);
}
void loop()
{
touchscreen.read();
touchscreen_status = touchscreen.getStatus();
touchscreen_x = touchscreen.getX();
touchscreen_y = touchscreen.getY();
if(draw){
lcd.writeLine(x_last,y_last,touchscreen_x,touchscreen_y,COLOR_WHITE);
}
if(status_last!=touchscreen_status){
if (touchscreen_status == TOUCH_BEGIN || touchscreen_status == TOUCH_MOVE)
draw = true;
else
draw = false;
status_last=touchscreen_status;
}
x_last = touchscreen_x;
y_last = touchscreen_y;
if(digitalRead(key) == LOW)
{
lcd.fillScreen(COLOR_BLACK);
}
}

View File

@@ -0,0 +1,29 @@
#######################################
# Syntax Coloring Map For Wire
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
#######################################
# Methods and Functions (KEYWORD2)
#######################################
begin KEYWORD2
read KEYWORD2
getStatus KEYWORD2
getX KEYWORD2
getY KEYWORD2
calibrate KEYWORD2
is_init KEYWORD2
end KEYWORD2
#######################################
# Instances (KEYWORD2)
#######################################
#######################################
# Constants (LITERAL1)
#######################################

View File

@@ -0,0 +1,10 @@
name=Touchscreen
version=1.0
author=BigBits
maintainer=BigBits<bigbits@bigbits.com>
sentence=NS2009 Touchscreen driver
paragraph=NS2009 Touchscreen driver
category=Display
url=
architectures=k210
includes=touchscreen.h

View File

@@ -0,0 +1,74 @@
/*
* libc/filter/mean.c
*/
#include <math.h>
#include <stddef.h>
#include <mean.h>
#include "stdlib.h"
#define touchscreen_malloc(p) malloc(p)
#define touchscreen_free(p) free(p)
struct mean_filter_t *mean_alloc(int length)
{
struct mean_filter_t *filter;
int i;
if (length <= 0)
return NULL;
filter = touchscreen_malloc(sizeof(struct mean_filter_t));
if (!filter)
return NULL;
filter->buffer = touchscreen_malloc(sizeof(int) * length);
if (!filter->buffer)
{
touchscreen_free(filter);
return NULL;
}
for (i = 0; i < length; i++)
filter->buffer[i] = 0;
filter->length = length;
filter->index = 0;
filter->count = 0;
filter->sum = 0;
return filter;
}
void mean_free(struct mean_filter_t *filter)
{
if (filter)
{
if (filter->buffer)
touchscreen_free(filter->buffer);
touchscreen_free(filter);
}
}
int mean_update(struct mean_filter_t *filter, int value)
{
filter->sum -= filter->buffer[filter->index];
filter->sum += value;
filter->buffer[filter->index] = value;
filter->index = (filter->index + 1) % filter->length;
if (filter->count < filter->length)
filter->count++;
return filter->sum / filter->count;
}
void mean_clear(struct mean_filter_t *filter)
{
int i;
if (filter)
{
for (i = 0; i < filter->length; i++)
filter->buffer[i] = 0;
filter->index = 0;
filter->count = 0;
filter->sum = 0;
}
}

View File

@@ -0,0 +1,27 @@
#ifndef __MEAN_H__
#define __MEAN_H__
#ifdef __cplusplus
extern "C"
{
#endif
struct mean_filter_t
{
int *buffer;
int length;
int index;
int count;
int sum;
};
struct mean_filter_t *mean_alloc(int length);
void mean_free(struct mean_filter_t *filter);
int mean_update(struct mean_filter_t *filter, int value);
void mean_clear(struct mean_filter_t *filter);
#ifdef __cplusplus
}
#endif
#endif /* __MEAN_H__ */

View File

@@ -0,0 +1,138 @@
/*
* libc/filter/median.c
*/
#include <math.h>
#include <stddef.h>
#include <median.h>
#include "stdlib.h"
#define touchscreen_malloc(p) malloc(p)
#define touchscreen_free(p) free(p)
struct median_filter_t *median_alloc(int length)
{
struct median_filter_t *filter;
if (length <= 0)
return NULL;
filter = touchscreen_malloc(sizeof(struct median_filter_t));
if (!filter)
return NULL;
filter->buffer = touchscreen_malloc(sizeof(int) * length);
filter->index = touchscreen_malloc(sizeof(int) * length);
if (!filter->buffer || !filter->index)
{
if (filter->buffer)
touchscreen_free(filter->buffer);
if (filter->index)
touchscreen_free(filter->index);
touchscreen_free(filter);
return NULL;
}
filter->length = length;
filter->position = 0;
filter->count = 0;
return filter;
}
void median_free(struct median_filter_t *filter)
{
if (filter)
{
if (filter->buffer)
touchscreen_free(filter->buffer);
if (filter->index)
touchscreen_free(filter->index);
touchscreen_free(filter);
}
}
int median_update(struct median_filter_t *filter, int value)
{
int pos = filter->position;
int cnt = filter->count;
int *idx;
int cidx;
int oidx;
int oval;
int result;
if (cnt > 0)
{
if (cnt == filter->length)
{
oidx = 0;
while (filter->index[oidx] != pos)
++oidx;
oval = filter->buffer[pos];
}
else
{
filter->index[pos] = pos;
oidx = pos;
oval = INT_MAX;
}
filter->buffer[pos] = value;
idx = &filter->index[oidx];
if (oval < value)
{
while (++oidx != cnt)
{
cidx = *(++idx);
if (filter->buffer[cidx] < value)
{
*idx = *(idx - 1);
*(idx - 1) = cidx;
}
else
{
break;
}
}
}
else if (oval > value)
{
while (oidx-- != 0)
{
cidx = *(--idx);
if (filter->buffer[cidx] > value)
{
*idx = *(idx + 1);
*(idx + 1) = cidx;
}
else
{
break;
}
}
}
result = filter->buffer[filter->index[cnt / 2]];
}
else
{
filter->buffer[0] = value;
filter->index[0] = 0;
filter->position = 0;
filter->count = 0;
result = value;
}
pos++;
filter->position = (pos == filter->length) ? 0 : pos;
if (cnt < filter->length)
filter->count++;
return result;
}
void median_clear(struct median_filter_t *filter)
{
if (filter)
{
filter->position = 0;
filter->count = 0;
}
}

View File

@@ -0,0 +1,30 @@
#ifndef __MEDIAN_H__
#define __MEDIAN_H__
#ifdef __cplusplus
extern "C"
{
#endif
#define INT_MIN (-1 - 0x7fffffff)
#define INT_MAX 0x7fffffff
struct median_filter_t
{
int *buffer;
int *index;
int length;
int position;
int count;
};
struct median_filter_t *median_alloc(int length);
void median_free(struct median_filter_t *filter);
int median_update(struct median_filter_t *filter, int value);
void median_clear(struct median_filter_t *filter);
#ifdef __cplusplus
}
#endif
#endif /* __MEDIAN_H__ */

View File

@@ -0,0 +1,174 @@
#include "ns2009.h"
#include <string.h>
#include <stdlib.h>
#include <tsfilter.h>
#include <stdio.h>
#include "fpioa.h"
#include "sleep.h"
#include <math.h>
#include "stdlib.h"
#define touchscreen_malloc(p) malloc(p)
#define touchscreen_free(p) free(p)
static uint8_t ns2009_read(uint8_t cmd, int *val)
{
uint8_t ret, buf[2];
ret = ns2009_hal_i2c_recv(&cmd, 1, buf, 2);
if (ret != 0)
return 0;
if (val)
*val = (buf[0] << 4) | (buf[1] >> 4);
return 1;
}
static void push_event_begin(struct ts_ns2009_event_t *ts_event, int x, int y)
{
ts_event->type = TOUCH_BEGIN;
ts_event->x = x;
ts_event->y = y;
}
static void push_event_move(struct ts_ns2009_event_t *ts_event, int x, int y)
{
ts_event->type = TOUCH_MOVE;
ts_event->x = x;
ts_event->y = y;
}
static void push_event_end(struct ts_ns2009_event_t *ts_event, int x, int y)
{
ts_event->type = TOUCH_END;
ts_event->x = x;
ts_event->y = y;
}
static void push_event_none(struct ts_ns2009_event_t *ts_event)
{
ts_event->type = TOUCH_NONE;
ts_event->x = 0;
ts_event->y = 0;
}
int ts_ns2009_poll(struct ts_ns2009_pdata_t *ts_ns2009_pdata)
{
int x = 0, y = 0, z1 = 0;
if (ns2009_read(NS2009_LOW_POWER_READ_Z1, &z1))
{
if ((z1 > 70) && (z1 < 2000))
{
ns2009_read(NS2009_LOW_POWER_READ_X, &x);
ns2009_read(NS2009_LOW_POWER_READ_Y, &y);
tsfilter_update(ts_ns2009_pdata->filter, &x, &y);
if (!ts_ns2009_pdata->press)
{
push_event_begin(ts_ns2009_pdata->event, x, y);
ts_ns2009_pdata->press = 1;
}
else
{
if ((ts_ns2009_pdata->x != x) || (ts_ns2009_pdata->y != y))
{
push_event_move(ts_ns2009_pdata->event, x, y);
}
}
ts_ns2009_pdata->x = x;
ts_ns2009_pdata->y = y;
}
else
{
if (ts_ns2009_pdata->press)
{
tsfilter_clear(ts_ns2009_pdata->filter);
push_event_end(ts_ns2009_pdata->event, ts_ns2009_pdata->x, ts_ns2009_pdata->y);
ts_ns2009_pdata->press = 0;
}
}
}
else
{
push_event_none(ts_ns2009_pdata->event);
}
return 1;
}
int ts_ns2009_set_calibration(struct ts_ns2009_pdata_t *ts_ns2009_pdata, int cmd, void *arg)
{
int cal[7];
if (cmd == NS2009_IOCTL_SET_CALBRATION)
{
if (!arg)
return -1;
memcpy(cal, arg, sizeof(int) * 7);
tsfilter_setcal(ts_ns2009_pdata->filter, cal);
return 0;
}
return -1;
}
// "ts-ns2009@0" : {
// "i2c-bus" : "i2c-v3s.0",
// "slave-address" : 72,
// "median-filter-length" : 5,
// "mean-filter-length" : 5,
// "calibration" : [ 14052, 21, -2411064, -67, 8461, -1219628, 65536 ],
// "poll-interval-ms" : 10
// },
//[-4278, -68, 16701858, -8, -5930, 21990146, 65536]
//{65, 5853, -1083592, -4292, -15, 16450115, 65536};
struct ts_ns2009_pdata_t *ts_ns2009_probe(int* cal, int* err)
{
struct ts_ns2009_pdata_t *ts_ns2009_pdata;
*err = 0;
if (!ns2009_read(NS2009_LOW_POWER_READ_Z1, NULL))
{
*err = 5; // EIO
return NULL;
}
ts_ns2009_pdata = touchscreen_malloc(sizeof(struct ts_ns2009_pdata_t));
if (!ts_ns2009_pdata)
{
*err = 12; //ENOMEM
return NULL;
}
ts_ns2009_pdata->filter = tsfilter_alloc(5, 5);
tsfilter_setcal(ts_ns2009_pdata->filter, cal);
//
ts_ns2009_pdata->x = 0;
ts_ns2009_pdata->y = 0;
ts_ns2009_pdata->press = 0;
//
ts_ns2009_pdata->event = touchscreen_malloc(sizeof(struct ts_ns2009_event_t));
ts_ns2009_pdata->event->x = 0;
ts_ns2009_pdata->event->y = 0;
ts_ns2009_pdata->event->type = TOUCH_NONE;
return ts_ns2009_pdata;
}
void ts_ns2009_remove(struct ts_ns2009_pdata_t *ts_ns2009_pdata)
{
if (ts_ns2009_pdata->filter)
{
tsfilter_free(ts_ns2009_pdata->filter);
ts_ns2009_pdata->filter = NULL;
}
if (ts_ns2009_pdata->event)
{
touchscreen_free(ts_ns2009_pdata->event);
ts_ns2009_pdata->filter = NULL;
}
if (ts_ns2009_pdata)
{
touchscreen_free(ts_ns2009_pdata);
ts_ns2009_pdata->filter = NULL;
}
}

View File

@@ -0,0 +1,56 @@
#ifndef __NS2009_H
#define __NS2009_H
#include <stdio.h>
/* clang-format off */
#define NS2009_SLV_ADDR 0x48
#define NS2009_IOCTL_SET_CALBRATION 0x1
/* clang-format on */
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
enum
{
NS2009_LOW_POWER_READ_X = 0xc0,
NS2009_LOW_POWER_READ_Y = 0xd0,
NS2009_LOW_POWER_READ_Z1 = 0xe0,
NS2009_LOW_POWER_READ_Z2 = 0xf0,
};
enum event_type
{
TOUCH_NONE = 0,
TOUCH_BEGIN,
TOUCH_MOVE,
TOUCH_END
};
struct ts_ns2009_event_t
{
enum event_type type;
int x, y;
} __attribute__((aligned(8)));
struct ts_ns2009_pdata_t
{
struct tsfilter_t *filter;
struct ts_ns2009_event_t *event;
int x, y;
int press;
} __attribute__((aligned(8)));
int ts_ns2009_poll(struct ts_ns2009_pdata_t *ts_ns2009_pdata);
int ts_ns2009_set_calibration(struct ts_ns2009_pdata_t *ts_ns2009_pdata, int cmd, void *arg);
struct ts_ns2009_pdata_t *ts_ns2009_probe(int* cal, int* err);
void ts_ns2009_remove(struct ts_ns2009_pdata_t *ts_ns2009_pdata);
int ns2009_hal_i2c_recv(const uint8_t *send_buf, size_t send_buf_len, uint8_t *receive_buf,
size_t receive_buf_len);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif

View File

@@ -0,0 +1,117 @@
#include "touchscreen.h"
#include "Wire.h"
extern "C"
{
#include "tscal.h"
}
TouchScreen::TouchScreen()
{
}
TouchScreen::~TouchScreen()
{
}
int
TouchScreen::begin()
{
int err;
Wire.begin();
ts_ns2009_pdata = ts_ns2009_probe(calibration, &err); //calibration
if (ts_ns2009_pdata == NULL || err!=0)
return err;
_is_init = true;
return 0;
}
bool
TouchScreen::is_init()
{
return _is_init;
}
int
TouchScreen::read()
{
ts_ns2009_poll(ts_ns2009_pdata);
_x = 0;
_y = 0;
switch (ts_ns2009_pdata->event->type)
{
case TOUCH_BEGIN:
_x = ts_ns2009_pdata->event->x;
_y = ts_ns2009_pdata->event->y;
_status = TOUCHSCREEN_STATUS_PRESS;
break;
case TOUCH_MOVE:
_x = ts_ns2009_pdata->event->x;
_y = ts_ns2009_pdata->event->y;
_status = TOUCHSCREEN_STATUS_MOVE;
break;
case TOUCH_END:
_x= ts_ns2009_pdata->event->x;
_y= ts_ns2009_pdata->event->y;
_status = TOUCHSCREEN_STATUS_RELEASE;
break;
default:
break;
}
return 0;
}
int
TouchScreen::getStatus()
{
return _status;
}
int
TouchScreen::getX()
{
return _x;
}
int
TouchScreen::getY()
{
return _y;
}
int
TouchScreen::end()
{
ts_ns2009_remove(ts_ns2009_pdata);
_is_init = false;
return 0;
}
int
TouchScreen::calibrate(int w, int h)
{
return do_tscal(ts_ns2009_pdata, w, h, calibration);
}
//////////////HAL//////////////
int ns2009_hal_i2c_recv(const uint8_t *send_buf, size_t send_buf_len, uint8_t *receive_buf,
size_t receive_buf_len)
{
Wire.beginTransmission(NS2009_SLV_ADDR);
Wire.write(send_buf,send_buf_len);
Wire.endTransmission();
Wire.requestFrom(NS2009_SLV_ADDR,receive_buf_len);
while(Wire.available()){
*receive_buf++ = Wire.read();
}
return 0;
}

View File

@@ -0,0 +1,64 @@
#ifndef __TOUCHSCREEN_H_
#define __TOUCHSCREEN_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "stdbool.h"
typedef enum{
TOUCHSCREEN_STATUS_IDLE =0,
TOUCHSCREEN_STATUS_RELEASE,
TOUCHSCREEN_STATUS_PRESS,
TOUCHSCREEN_STATUS_MOVE
} touchscreen_type_t;
#ifdef __cplusplus
}//extern "C"
#endif
#include "Wire.h"
#include "ns2009.h"
#define CALIBRATION_SIZE 7
#ifdef __cplusplus
class TouchScreen{
public :
TouchScreen();
~TouchScreen();
int begin();
int read();
int getStatus();
int getX();
int getY();
int calibrate(int w = 320, int h = 240);
bool is_init();
int end();
private:
int calibration[CALIBRATION_SIZE] = {
-6,
-5941,
22203576,
4232,
-8,
-700369,
65536
};
bool _is_init = false ;
ts_ns2009_pdata_t *ts_ns2009_pdata;
int _status = TOUCHSCREEN_STATUS_IDLE;
int _x = 0;
int _y = 0;
};
#endif
#include "stdlib.h"
#define touchscreen_malloc(p) malloc(p)
#define touchscreen_free(p) free(p)
#endif

View File

@@ -0,0 +1,235 @@
#include "ns2009.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "lcd.h"
#include "tscal.h"
#include "sleep.h"
static int perform_calibration(struct tscal_t *cal)
{
float n, x, y, x2, y2, xy, z, zx, zy;
float det, a, b, c, e, f, i;
float scaling = 65536.0;
int j;
n = x = y = x2 = y2 = xy = 0;
for (j = 0; j < 5; j++)
{
n += 1.0;
x += (float)cal->x[j];
y += (float)cal->y[j];
x2 += (float)(cal->x[j] * cal->x[j]);
y2 += (float)(cal->y[j] * cal->y[j]);
xy += (float)(cal->x[j] * cal->y[j]);
}
det = n * (x2 * y2 - xy * xy) + x * (xy * y - x * y2) + y * (x * xy - y * x2);
if (det < 0.1 && det > -0.1)
return 0;
a = (x2 * y2 - xy * xy) / det;
b = (xy * y - x * y2) / det;
c = (x * xy - y * x2) / det;
e = (n * y2 - y * y) / det;
f = (x * y - n * xy) / det;
i = (n * x2 - x * x) / det;
z = zx = zy = 0;
for (j = 0; j < 5; j++)
{
z += (float)cal->xfb[j];
zx += (float)(cal->xfb[j] * cal->x[j]);
zy += (float)(cal->xfb[j] * cal->y[j]);
}
cal->a[0] = (int)((b * z + e * zx + f * zy) * (scaling));
cal->a[1] = (int)((c * z + f * zx + i * zy) * (scaling));
cal->a[2] = (int)((a * z + b * zx + c * zy) * (scaling));
z = zx = zy = 0;
for (j = 0; j < 5; j++)
{
z += (float)cal->yfb[j];
zx += (float)(cal->yfb[j] * cal->x[j]);
zy += (float)(cal->yfb[j] * cal->y[j]);
}
cal->a[3] = (int)((b * z + e * zx + f * zy) * (scaling));
cal->a[4] = (int)((c * z + f * zx + i * zy) * (scaling));
cal->a[5] = (int)((a * z + b * zx + c * zy) * (scaling));
cal->a[6] = (int)scaling;
return 1;
}
//画线
//x1,y1:起点坐标
//x2,y2:终点坐标
void lcd_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
{
uint16_t t;
int xerr = 0, yerr = 0, delta_x, delta_y, distance;
int incx, incy, uRow, uCol;
delta_x = x2 - x1; //计算坐标增量
delta_y = y2 - y1;
uRow = x1;
uCol = y1;
if (delta_x > 0)
incx = 1; //设置单步方向
else if (delta_x == 0)
incx = 0; //垂直线
else
{
incx = -1;
delta_x = -delta_x;
}
if (delta_y > 0)
incy = 1;
else if (delta_y == 0)
incy = 0; //水平线
else
{
incy = -1;
delta_y = -delta_y;
}
if (delta_x > delta_y)
distance = delta_x; //选取基本增量坐标轴
else
distance = delta_y;
for (t = 0; t <= distance + 1; t++) //画线输出
{
lcd_draw_point(uRow, uCol, color); //画点
xerr += delta_x;
yerr += delta_y;
if (xerr > distance)
{
xerr -= distance;
uRow += incx;
}
if (yerr > distance)
{
yerr -= distance;
uCol += incy;
}
}
}
//在指定位置画一个指定大小的圆
//(x,y):中心点
//r :半径
void lcd_draw_circle(uint16_t x0, uint16_t y0, uint8_t r, uint16_t color)
{
int a, b;
int di;
a = 0;
b = r;
di = 3 - (r << 1); //判断下个点位置的标志
while (a <= b)
{
lcd_draw_point(x0 + a, y0 - b, color); //5
lcd_draw_point(x0 + b, y0 - a, color); //0
lcd_draw_point(x0 + b, y0 + a, color); //4
lcd_draw_point(x0 + a, y0 + b, color); //6
lcd_draw_point(x0 - a, y0 + b, color); //1
lcd_draw_point(x0 - b, y0 + a, color);
lcd_draw_point(x0 - a, y0 - b, color); //2
lcd_draw_point(x0 - b, y0 - a, color); //7
a++;
//使用Bresenham算法画圆
if (di < 0)
di += 4 * a + 6;
else
{
di += 10 + 4 * (a - b);
b--;
}
}
}
static void lcd_draw_cross(int x, int y, uint16_t color)
{
lcd_draw_line(x - 12, y, x + 13, y, color); //横线
lcd_draw_line(x, y - 12, x, y + 13, color); //竖线
lcd_draw_point(x + 1, y + 1, color);
lcd_draw_point(x - 1, y + 1, color);
lcd_draw_point(x + 1, y - 1, color);
lcd_draw_point(x - 1, y - 1, color);
lcd_draw_circle(x, y, 6, color); //画中心圈
}
static void cairo_draw_string(int x, int y, const char *title)
{
lcd_draw_string(x, y, title, WHITE);
}
int do_tscal(struct ts_ns2009_pdata_t *ts_ns2009_pdata, int width, int height, int* c)
{
struct tscal_t cal;
lcd_ctl_t lcd_ctl;
// char buffer[256];
int index;
c[0] = 1;
c[1] = 0;
c[2] = 0;
c[3] = 0;
c[4] = 1;
c[5] = 0;
c[6] = 1;
ts_ns2009_set_calibration(ts_ns2009_pdata, NS2009_IOCTL_SET_CALBRATION, c);
cal.xfb[0] = 50;
cal.yfb[0] = 50;
cal.xfb[1] = width - 50;
cal.yfb[1] = 50;
cal.xfb[2] = width - 50;
cal.yfb[2] = height - 50;
cal.xfb[3] = 50;
cal.yfb[3] = height - 50;
cal.xfb[4] = width / 2;
cal.yfb[4] = height / 2;
index = 0;
lcd_clear(BLACK);
lcd_draw_cross(cal.xfb[index], cal.yfb[index], RED);
while (1)
{
ts_ns2009_poll(ts_ns2009_pdata);
if (ts_ns2009_pdata->event->type == TOUCH_END)
{
cal.x[index] = ts_ns2009_pdata->event->x;
cal.y[index] = ts_ns2009_pdata->event->y;
if (++index >= 5)
{
if (perform_calibration(&cal))
{
ts_ns2009_set_calibration(ts_ns2009_pdata, NS2009_IOCTL_SET_CALBRATION, &cal.a[0]);
// sprintf(buffer, "[%d,%d,%d,%d,%d,%d,%d]", cal.a[0], cal.a[1], cal.a[2], cal.a[3], cal.a[4], cal.a[5], cal.a[6]);
}
else
{
// sprintf(buffer, "%s", "calibration failed");
}
lcd_clear(BLACK);
// cairo_draw_string(0, height / 2, buffer);
memcpy(c, cal.a, 7*sizeof(int));
ts_ns2009_pdata->event->type = TOUCH_NONE;
break;
}
lcd_clear(BLACK);
lcd_draw_cross(cal.xfb[index], cal.yfb[index], RED);
}
ts_ns2009_pdata->event->type = TOUCH_NONE;
}
return 0;
}

View File

@@ -0,0 +1,15 @@
#ifndef __TSCAL_H
#define __TSCAL_H
#include <stdio.h>
struct tscal_t
{
int x[5], xfb[5];
int y[5], yfb[5];
int a[7];
};
int do_tscal(struct ts_ns2009_pdata_t *ts_ns2009_pdata, int w, int h, int* cal_ret);
#endif

View File

@@ -0,0 +1,98 @@
#include <stddef.h>
#include <tsfilter.h>
#include "stdlib.h"
#define touchscreen_malloc(p) malloc(p)
#define touchscreen_free(p) free(p)
struct tsfilter_t *tsfilter_alloc(int ml, int nl)
{
struct tsfilter_t *filter;
if (ml <= 0 || nl <= 0)
return NULL;
filter = touchscreen_malloc(sizeof(struct tsfilter_t));
if (!filter)
return NULL;
filter->mx = median_alloc(ml);
filter->my = median_alloc(ml);
filter->nx = mean_alloc(nl);
filter->ny = mean_alloc(nl);
filter->cal[0] = 1;
filter->cal[1] = 0;
filter->cal[2] = 0;
filter->cal[3] = 0;
filter->cal[4] = 1;
filter->cal[5] = 0;
filter->cal[6] = 1;
if (!filter->mx || !filter->my || !filter->nx || !filter->ny)
{
if (filter->mx)
median_free(filter->mx);
if (filter->my)
median_free(filter->my);
if (filter->nx)
mean_free(filter->nx);
if (filter->ny)
mean_free(filter->ny);
}
return filter;
}
void tsfilter_free(struct tsfilter_t *filter)
{
if (filter)
{
if (filter->mx)
median_free(filter->mx);
if (filter->my)
median_free(filter->my);
if (filter->nx)
mean_free(filter->nx);
if (filter->ny)
mean_free(filter->ny);
touchscreen_free(filter);
}
}
void tsfilter_setcal(struct tsfilter_t *filter, int *cal)
{
if (filter)
{
filter->cal[0] = cal[0];
filter->cal[1] = cal[1];
filter->cal[2] = cal[2];
filter->cal[3] = cal[3];
filter->cal[4] = cal[4];
filter->cal[5] = cal[5];
filter->cal[6] = cal[6];
}
}
void tsfilter_update(struct tsfilter_t *filter, int *x, int *y)
{
int tx, ty;
tx = median_update(filter->mx, *x);
ty = median_update(filter->my, *y);
tx = mean_update(filter->nx, tx);
ty = mean_update(filter->ny, ty);
*x = (filter->cal[2] + filter->cal[0] * tx + filter->cal[1] * ty) / filter->cal[6];
*y = (filter->cal[5] + filter->cal[3] * tx + filter->cal[4] * ty) / filter->cal[6];
}
void tsfilter_clear(struct tsfilter_t *filter)
{
if (filter)
{
if (filter->mx)
median_clear(filter->mx);
if (filter->my)
median_clear(filter->my);
if (filter->nx)
mean_clear(filter->nx);
if (filter->ny)
mean_clear(filter->ny);
}
}

View File

@@ -0,0 +1,29 @@
#ifndef __TSFILTER_H__
#define __TSFILTER_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <median.h>
#include <mean.h>
struct tsfilter_t
{
struct median_filter_t *mx, *my;
struct mean_filter_t *nx, *ny;
int cal[7];
} __attribute__((aligned(8)));
struct tsfilter_t *tsfilter_alloc(int ml, int nl);
void tsfilter_free(struct tsfilter_t *filter);
void tsfilter_setcal(struct tsfilter_t *filter, int *cal);
void tsfilter_update(struct tsfilter_t *filter, int *x, int *y);
void tsfilter_clear(struct tsfilter_t *filter);
#ifdef __cplusplus
}
#endif
#endif /* __TSFILTER_H__ */

View File

@@ -0,0 +1,26 @@
#include <Arduino.h>
#include <Ticker.h>
// attach a LED to GPIO 21
#define LED_PIN 13
Ticker tickerSetHigh(TIMER1);
Ticker tickerSetLow(TIMER2);
void setPin(int state) {
digitalWrite(LED_PIN, state);
}
void setup() {
pinMode(LED_PIN, OUTPUT);
// every 25 ms, call setPin(0)
tickerSetLow.attach_ms(25, setPin, 0);
// every 26 ms, call setPin(1)
tickerSetHigh.attach_ms(26, setPin, 1);
}
void loop() {
}

View File

@@ -0,0 +1,42 @@
#include <Arduino.h>
#include <Ticker.h>
// attach a LED to pPIO 13
#define LED_PIN 13
Ticker blinker(TIMER0);
Ticker toggler(TIMER1);
Ticker changer(TIMER2);
float blinkerPace = 0.1; //seconds
const float togglePeriod = 5; //seconds
void change() {
blinkerPace = 0.5;
}
void blink() {
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
}
void toggle() {
static bool isBlinking = false;
if (isBlinking) {
blinker.detach();
isBlinking = false;
}
else {
blinker.attach(blinkerPace, blink);
isBlinking = true;
}
digitalWrite(LED_PIN, LOW); //make sure LED on on after toggling (pin LOW = led ON)
}
void setup() {
pinMode(LED_PIN, OUTPUT);
toggler.attach(togglePeriod, toggle);
changer.once(30, change);
}
void loop() {
}

View File

@@ -0,0 +1,22 @@
#######################################
# Datatypes (KEYWORD1)
#######################################
Ticker KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
attach KEYWORD2
attach_ms KEYWORD2
once KEYWORD2
once_ms KEYWORD2
detach KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
TIMER0 LITERAL1
TIMER1 LITERAL1
TIMER2 LITERAL1

View File

@@ -0,0 +1,9 @@
name=Ticker
version=1.0
author=BigBits
maintainer=BigBits <bigbits@bigbits.cc>
sentence=Allows to call functions with a given interval.
paragraph=Allows to call functions with a given interval.
category=Timing
url=
architectures=k210

View File

@@ -0,0 +1,40 @@
#include "Ticker.h"
#include "sysctl.h"
static int timer_callback(void* ctx);
Ticker::Ticker(timer_id_t id)
:timer_id(id)
{
timer_init(timer_device_number_t(timer_id));
}
Ticker::~Ticker()
{
detach();
}
void
Ticker::_attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, size_t arg)
{
user_callback = callback;
_arg = arg;
timer_set_interval(timer_device_number_t(timer_id), TIMER_CHANNEL_0, milliseconds * 1000000);
timer_irq_register(timer_device_number_t(timer_id), TIMER_CHANNEL_0, !repeat, 4, timer_callback, this);
timer_set_enable(timer_device_number_t(timer_id), TIMER_CHANNEL_0, 1);
sysctl_enable_irq();
}
void
Ticker::detach()
{
timer_irq_unregister(timer_device_number_t(timer_id), TIMER_CHANNEL_0);
timer_set_enable(timer_device_number_t(timer_id), TIMER_CHANNEL_0, 0);
}
static int timer_callback(void* ctx)
{
auto &driver = *reinterpret_cast<Ticker *>(ctx);
driver.user_callback((void *)driver._arg);
return 0;
}

View File

@@ -0,0 +1,91 @@
#ifndef TICKER_H
#define TICKER_H
#include "utils.h"
#include "timer.h"
#include "stdio.h"
#include "stdint.h"
typedef enum{
TIMER0 = 0,
TIMER1,
TIMER2,
TIMER_MAX
}timer_id_t;
class Ticker
{
public:
Ticker(timer_id_t id = TIMER2);
~Ticker();
typedef void (*callback_t)(void);
typedef void (*callback_with_arg_t)(void*);
void attach(float seconds, callback_t callback)
{
_attach_ms(seconds * 1000, true, reinterpret_cast<callback_with_arg_t>(callback), 0);
}
void attach_ms(uint32_t milliseconds, callback_t callback)
{
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), 0);
}
template<typename TArg>
void attach(float seconds, void (*callback)(TArg), TArg arg)
{
configASSERT(sizeof(TArg) <= sizeof(size_t));
size_t arg32 = (size_t)arg;
_attach_ms(seconds * 1000, true, reinterpret_cast<callback_with_arg_t>(callback), arg32);
}
template<typename TArg>
void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
{
configASSERT(sizeof(TArg) <= sizeof(size_t));
size_t arg32 = (size_t)arg;
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), arg32);
}
void once(float seconds, callback_t callback)
{
_attach_ms(seconds * 1000, false, reinterpret_cast<callback_with_arg_t>(callback), 0);
}
void once_ms(uint32_t milliseconds, callback_t callback)
{
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), 0);
}
template<typename TArg>
void once(float seconds, void (*callback)(TArg), TArg arg)
{
configASSERT(sizeof(TArg) <= sizeof(size_t));
size_t arg32 = (size_t)(arg);
_attach_ms(seconds * 1000, false, reinterpret_cast<callback_with_arg_t>(callback), arg32);
}
template<typename TArg>
void once_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
{
configASSERT(sizeof(TArg) <= sizeof(size_t));
size_t arg32 = (size_t)(arg);
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), arg32);
}
void detach();
bool active();
callback_with_arg_t user_callback = NULL;
size_t _arg;
protected:
void _attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, size_t arg);
private:
timer_id_t timer_id;
}__attribute__((packed));
#endif

1
libraries/lv_arduino Submodule

Submodule libraries/lv_arduino added at 3a1df1b16b

6
package.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "framework-maixduino",
"description": "Arduino Wiring-based Framework (K210 Core)",
"version": "0.3.8",
"url": "https://github.com/sipeed/Maixduino"
}

View File

@@ -1,5 +1,5 @@
name = Maixduino
version = 0.2.3
version = 0.3.8
# arch
arch = k210
@@ -21,7 +21,7 @@ compiler.lib_hal_inc.path={runtime.platform.path}/cores/arduino/hal/include
compiler.cores.path={runtime.platform.path}/cores/arduino/
compiler.preproc.flags=-I{build.system.path}/include -I{compiler.cores.path} -I{compiler.lib_hal_inc.path} -I{compiler.sdk.path}/bsp/include -I{compiler.sdk.path}/drivers/include -I{compiler.sdk.path}/utils/include -I{compiler.sdk.path}/freertos/conf -I{compiler.sdk.path}/freertos/include -I{compiler.sdk.path}/freertos/portable -I{compiler.clib.path}
compiler.both.flags=-mcmodel=medany -mabi=lp64f -march=rv64imafc -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -fno-zero-initialized-in-bss -Os -ggdb -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Werror=frame-larger-than=65536 -Wno-unused-parameter -Wno-sign-compare -Wno-error=missing-braces -Wno-error=return-type -Wno-error=pointer-sign -Wno-missing-braces -Wno-strict-aliasing -Wno-implicit-fallthrough -Wno-missing-field-initializers -Wno-int-to-pointer-cast -Wno-error=comment -Wno-error=logical-not-parentheses -Wno-error=duplicate-decl-specifier -Wno-error=parentheses -lpthread
compiler.both.flags=-mcmodel=medany -mabi=lp64f -march=rv64imafc -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -fno-zero-initialized-in-bss -Os -ggdb -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Werror=frame-larger-than=65536 -Wno-unused-parameter -Wno-sign-compare -Wno-error=missing-braces -Wno-error=return-type -Wno-error=pointer-sign -Wno-missing-braces -Wno-strict-aliasing -Wno-implicit-fallthrough -Wno-missing-field-initializers -Wno-int-to-pointer-cast -Wno-error=comment -Wno-error=logical-not-parentheses -Wno-error=duplicate-decl-specifier -Wno-error=parentheses -Wno-error=narrowing -Wno-error=unused-value
compiler.debug.flags=-DCONFIG_LOG_ENABLE -DCONFIG_LOG_LEVEL=LOG_INFO -DDEBUG=1 -D__riscv64
@@ -84,14 +84,18 @@ recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -B "{build.path}/{build.project_name}.elf"
recipe.size.regex=\s*[0-9]+\s+[0-9]+\s+[0-9]+\s+([0-9]+).*
## Save hex
recipe.output.tmp_file={build.project_name}.bin
recipe.output.save_file={build.project_name}.{build.variant}.bin
# Uploader tools
# -------------------
tools.kflash.path={runtime.tools.kflash.path}/
tools.kflash.cmd=python3 {runtime.tools.kflash.path}/kflash.py
tools.kflash.cmd.windows={runtime.tools.kflash.path}/k-flash
tools.kflash.cmd.windows={runtime.tools.kflash.path}/kflash_py
tools.kflash.cmd.macosx=/usr/local/bin/python3 {runtime.tools.kflash.path}/kflash.py
tools.kflash.program.pattern={cmd} -n -p {serial.port} -b {build.burn_baudrate} -B {build.burn_tool_firmware} {build.path}/{build.project_name}.bin
tools.kflash.program.pattern.windows="{cmd}" -d {serial.port} -b {build.burn_baudrate} {build.path}/{build.project_name}.bin
tools.kflash.program.pattern.windows="{cmd}" -n -p {serial.port} -b {build.burn_baudrate} -B {build.burn_tool_firmware} {build.path}/{build.project_name}.bin

View File

@@ -28,7 +28,10 @@ extern class UARTClass Serial3;
#define LED_BLUE 12
#define LED_RED 14
/* KEY */
#define KEY0 16
#define KEY0 15
#define PIN_KEY_DOWN 16
#define PIN_KEY_UP 17
#define PIN_KEY_PRESS 15
/* MIC ARRAY */
#define MIC_BCK 18
#define MIC_WS 19

View File

@@ -1,11 +0,0 @@
// API compatibility
#ifdef BOARD_SIPEED_MAIX_ONE_DOCK
#include "sipeedm1.h"
#else
#ifdef BOARD_SIPEED_MAIX_GO
#include "sipeed_go.h"
#endif //BOARD_SIPEED_MAIX_GO
#endif