From 32a0f31c206084dc0792dddab9879b5a01ee3fe5 Mon Sep 17 00:00:00 2001 From: Bigbits Date: Sat, 23 Mar 2019 20:01:19 +0800 Subject: [PATCH] Add README Signed-off-by: Bigbits --- README.md | 24 +++++++++++++++++-- cores/arduino/WCharacter.h | 1 + cores/arduino/WInterrupts.c | 48 ++++++++++++++++++++----------------- cores/arduino/WInterrupts.h | 2 +- cores/arduino/main.cpp | 2 +- 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index ba08a87..0a4816b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,22 @@ -# Kenduino-core -k210 arduino core +# 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.编写程序 编译 上传 完成 \ No newline at end of file diff --git a/cores/arduino/WCharacter.h b/cores/arduino/WCharacter.h index 1ae6ebf..420a004 100644 --- a/cores/arduino/WCharacter.h +++ b/cores/arduino/WCharacter.h @@ -22,6 +22,7 @@ #include #include "wiring_constants.h" +#include "wiring_digital.h" #ifdef __cplusplus extern "C"{ diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index 380d6b5..b42b302 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -6,30 +6,34 @@ void attachInterrupt(uint8_t intnum, voidFuncPtr callback, uint8_t mode) { plic_irq_callback_t _callback = (plic_irq_callback_t)callback; - switch(mode){ - case LOW : - gpiohs_set_pin_edge(intnum, GPIO_PE_LOW); - break; - case HIGH : - gpiohs_set_pin_edge(intnum, GPIO_PE_HIGH); - break; - case FALLING : - gpiohs_set_pin_edge(intnum, GPIO_PE_FALLING); - break; - case CHANGE : - gpiohs_set_pin_edge(intnum, GPIO_PE_BOTH); - break; - case RISING : - gpiohs_set_pin_edge(intnum, GPIO_PE_RISING); - break; + int gpionum = getGpio(intnum); + if(gpionum >= 0){ + switch(mode){ + case LOW : + gpiohs_set_pin_edge((uint8_t)gpionum, GPIO_PE_LOW); + break; + case HIGH : + gpiohs_set_pin_edge((uint8_t)gpionum, GPIO_PE_HIGH); + break; + case FALLING : + gpiohs_set_pin_edge((uint8_t)gpionum, GPIO_PE_FALLING); + break; + case CHANGE : + gpiohs_set_pin_edge((uint8_t)gpionum, GPIO_PE_BOTH); + break; + case RISING : + gpiohs_set_pin_edge((uint8_t)gpionum, GPIO_PE_RISING); + break; + } + gpiohs_irq_register((uint8_t)gpionum, 10, _callback, NULL); + sysctl_enable_irq(); } - gpiohs_irq_register(intnum, 1, _callback, NULL); - sysctl_enable_irq(); - } void detachInterrupt(uint8_t intnum) { - gpiohs_irq_unregister(intnum); - -} \ No newline at end of file + int gpionum = getGpio(intnum); + if(gpionum >= 0){ + gpiohs_irq_unregister((uint8_t)gpionum); + } +} diff --git a/cores/arduino/WInterrupts.h b/cores/arduino/WInterrupts.h index 8938c1c..3bcb9b1 100644 --- a/cores/arduino/WInterrupts.h +++ b/cores/arduino/WInterrupts.h @@ -35,7 +35,7 @@ extern "C"{ #define DEFAULT 1 #define EXTERNAL 0 -#define digitalPinToInterrupt(P) +#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. diff --git a/cores/arduino/main.cpp b/cores/arduino/main.cpp index bdf76c1..f8c7188 100644 --- a/cores/arduino/main.cpp +++ b/cores/arduino/main.cpp @@ -5,7 +5,7 @@ #define cmb() __asm__ __volatile__ ("" ::: "memory") - +extern "C"{ void * __dso_handle = 0 ;} /* * \brief Main entry point of Arduino application