diff --git a/bsp/essemi/es32f369x/applications/SConscript b/bsp/essemi/es32f369x/applications/SConscript index e0c84e8f1426ab2abb2c870cea377371a7c752f3..570db2d32ea8eb46521420206817f1b60a894f82 100644 --- a/bsp/essemi/es32f369x/applications/SConscript +++ b/bsp/essemi/es32f369x/applications/SConscript @@ -2,10 +2,18 @@ Import('RTT_ROOT') Import('rtconfig') from building import * -cwd = os.path.join(str(Dir('#')), 'applications') -src = Glob('*.c') +src = Glob('*.c') -CPPPATH = [cwd, str(Dir('#'))] +if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']): + src += ['arduino_main.cpp'] + +cwd = GetCurrentDir() +CPPPATH = [cwd] group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) +list = os.listdir(cwd) +for item in list: + if os.path.isfile(os.path.join(cwd, item, 'SConscript')): + group = group + SConscript(os.path.join(item, 'SConscript')) + Return('group') diff --git a/bsp/essemi/es32f369x/applications/arduino_main.cpp b/bsp/essemi/es32f369x/applications/arduino_main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5cbdff75ce2636b36d345fe6c55a8d85bb43f0b0 --- /dev/null +++ b/bsp/essemi/es32f369x/applications/arduino_main.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-10 Meco Man first version + * 2022-07-07 shiwa Adapt ES32F369x + */ +#include + +void setup(void) +{ + /* put your setup code here, to run once: */ + pinMode(LED_BUILTIN, OUTPUT); +} + +void loop(void) +{ + /* put your main code here, to run repeatedly: */ + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + delay(250); +} diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/README.md b/bsp/essemi/es32f369x/applications/arduino_pinout/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d3441160d1fcd7523a309b7a0dff005dcbf7029e --- /dev/null +++ b/bsp/essemi/es32f369x/applications/arduino_pinout/README.md @@ -0,0 +1,167 @@ +# ES32F3696的Arduino生态兼容说明 + +## 1 RTduino - RT-Thread的Arduino生态兼容层 + +ES32F3696已经适配了RTduino,可正常使用全部功能,包含GPIO/PWM及I2C/SPI通信接口。除标准arduino uno的接口外,该开发板还额外添加了4个led和一个方向键对应的GPIO,方便使用。 + +### 1.1 使用Keil+Env + +1. Env 工具下敲入 menuconfig 命令,或者 RT-Thread Studio IDE 下选择 RT-Thread Settings: + +```Kconfig +Hardware Drivers Config ---> + Onboard Peripheral Drivers ---> + [*] Support Arduino +``` + +2. 进入RTduino配置,打开需要使用的各项配置 (SPI,I2C,Adafrui等) + +```Kconfig +RT-Thread online packages ---> + system packages ---> + RTduino: Arduino Ecological Compatibility Layer +``` + +3. 使用 pkgs --update下载RTduino包 +4. 使用scons --target=mdk5生成代码 + +### 1.2 使用RT-Thread Studio + +1. 选择 文件 -> 导入 -> BSP导入 + + ![image-20220630160208893](picture/image-20220630160208893.png) + +2. 选择es32f369x的bsp路径,并填写工程名称、芯片名(es32f3696lx) + + ![image-20220630160331334](picture/image-20220630160331334.png) + +3. 打开RT-Thread Settings,选择硬件,开启RTduino支持 + + ![image-20220706134522478](picture/image-20220706134522478.png) + + 保存后稍等片刻,等待Studio下载库并完成配置 + +* 可能遇到的问题与解决方案 + +1. Unknown flag "-T" + + 项目->属性->C/C++构建->GNU ARM Cross C++ Linker -> General在右侧添加lds连接脚本`"${workspace_loc:/${ProjName}/drivers/linker_scripts/link.lds}"`(需要先删除原有的再添加) + + ![image-20220701145240404](picture/image-20220701145240404.png) + +2. 启动时直接进入Fault + + 选择 项目->属性->C/C++构建->GNU ARM Cross C++ Complier-> Miscellaneous ,在Other compiler flags 中添加` -mcpu=cortex-m3 -mthumb` + + ![image-20220701145153781](picture/image-20220701145153781.png) + +## 2 Arduino引脚排布 + +该BSP遵照Arduino UNO板的引脚排列方式 ,并额外扩展了一些LED和按键 + +| Arduino引脚编号 | ES32引脚编号 | 备注 | +| --------------- | ------------ | ---------------- | +| D0 | PE3 | UART2 RX | +| D1 | PE2 | UART2 TX | +| D2 | PE4 | 普通IO | +| D3 | PA2 | PWM2 通道3 | +| D4 | PE5 | 普通IO | +| D5 | PA1 | PWM2 通道2 | +| D6 | PA0 | PWM2 通道1 | +| D7 | PE6 | 普通IO | +| D8 | PB8 | 普通IO | +| D9 | PB9 | 普通IO | +| D10 | PB0 | 普通IO | +| D11 | PB5 | SPI1_MOSI/普通IO | +| D12 | PB4 | SPI1_MISO/普通IO | +| D13 | PD3 | SPI1_SCK/普通IO | +| D14 | PB7 | I2C0_SDA | +| D15 | PB6 | I2C0_SCL | +| D16 | PC8 | LED4 | +| D17 | PC12 | LED5 | +| D18 | PC7 | LED6 | +| D19 | PC6 | LED7 | +| D20 | PF1 | KEY_UP | +| D21 | PF4 | KEY_DOWN | +| D22 | PF6 | KEY_LEFT | +| D23 | PF0 | KEY_RIGHT | +| D24 | PF7 | KEY_CENTER | +| A0 | PC0 | ADC | +| A1 | PC1 | ADC | +| A2 | PC2 | ADC | +| A3 | PC3 | ADC | +| A4 | PA4 | ADC | +| A5 | PA5 | ADC | + + + +## 3 I2C总线 + +ES32-Arduino支持的I2C总线是:i2c0。 + +I2C的引脚都是被RT-Thread I2C设备框架接管的,不需要直接操控这两个引脚,直接引用`#include `(Arduino官方I2C头文件)即可使用。或者使用`Adafruit_I2CDevice.h`控制 + +## 4 SPI总线 + +ES32-Arduino的SPI总线是spi0总线, `SCK`、`MISO`、`MOSI`引脚是被RT-Thread SPI设备框架接管的,不需要直接操控这3个引脚,直接引用`#include `(Arduino官方SPI头文件)即可使用。按照Arduino的编程标准,用户需要自行控制片选信号。或者使用`Adafruit_SPIDevice.h`控制 + +## 5 测试说明 + +在applications/arduino_pinout/examples/arduino_examples.cpp文件中,已经根据功能预设了一系列函数用于测试arduino各个功能,可根据测试需要,取消注释对应的宏定义即可启用对应的测试。如果需要测试,请将arduino_examples.cpp文件的内容覆盖到applications/arduino_main.cpp文件中 + +1. RTduino各功能测试 + +目前支持的测试如下: + +| 宏定义 | 名称 | 描述 | +| ---------------------- | ------------------ | ------------------------------------------------------------ | +| ARDU_TEST_GPIO | 数字GPIO测试 | 测试数字管脚的输出功能,包括两个管脚输出高/低电平,一个管脚输出一个0.5s周期的方波 | +| ARDU_TEST_PWM | 模拟PWM输出测试 | PWM功能输出测试,分别在三个PWM管脚输出不同的三种占空比的方波 | +| ARDU_TEST_ADAFRUIT_I2C | AdafruitI2C测试 | 使用AdafruitI2C库发送数据,测试正常可以收到不断发送的"ABtestabtest" | +| ARDU_TEST_ADAFRUIT_SPI | AdafruitSPI测试 | 使用AdafruitSPI库发送数据,测试正常可收到不断的"test" | +| ARDU_TEST_I2C | I2C测试 | 通过I2C接口发送数据,测试正常可收到不断的"test" | +| ARDU_TEST_SPI | SPI测试 | 通过SPI接口发送和接收数据,测试正常可收到不断的"test" | +| ARDU_TEST_INT | 中断测试 | 测试外部中断,按下方向键的中键会打印相关信息 | +| ARDU_TEST_DIGITAL_READ | 数字读测试 | 不断读取各个方向键的状态,并在按下时输出信息 | +| ARDU_TEST_ADC_READ | ADC测试 | 循环读取各个ADC的数据,并通过串口打印 | +| ARDU_TEST_BMI160_PKG | 第三方BMI160包测试 | 测试导入的BMI160库是否正常,程序会不断读取传感器数据并通过串口打印 | + +2. 第三方arduino库导入测试 + + 用法:下载完毕后解压放到 packages\RTduino-latest\libraries\user目录下即可 + + 需要修改一处:这个库有一处函数重载歧义,856行需改为Wire.requestFrom(dev->id,(uint8_t)len); + + 选择BMI160的库DFRobot_BMI160用于测试,用keil编译时存在以下问题: + + 1. 缺少INT8_C和UINT8_C宏定义,手动添加 + + ```c + #ifndef INT8_C + #define INT8_C(x) ((int8_t)x) + #endif + #ifndef UINT8_C + #define UINT8_C(x) ((uint8_t)x) + #endif + ``` + + 2. keil的AC5不支持类变量直接初始化,目前版本的AC6编译器会报错,需要修改工程文件,删掉所有的 --cpp11 --c11 --gnu + + 解决以上问题后,能成功调用传感器获取加速度和重力等信息 + + 如果用RT-Thread Studio编译,则不存在这些问题,只需修改存在歧义的问题即可直接使用 + +## 6 其他说明 + +### 1.ADC +目前ES32的ADC返回的是原始值,需要计算转换为实际的电压值,暂时不支持分辨率调节,会出现警告信息。 +### 2.对非数字IO的管脚不要调用pinMode +非数字IO的管脚在其他地方已经初始化了,再次调用pinMode会使他变为普通管脚且无法再重新初始化为非数字IO的功能。即对于任意管脚可以调用pinMode使它变为数字IO管脚,但这一过程不可逆,原有的预设功能将会失效 +### 3.SPI/I2C/UART使用 + +默认只开启了spi0、i2c0及uart2(默认控制台串口),如果需要使用其他的spi/i2c/uart可以在配置中启用,并在初始化时指定名称即可。如果想要调整管脚信息,可以使用ESCodeMaker辅助,但要注意打开对应的外设。 + +SPI必须先调用begin才能使用其他函数 + +### 4.RTduino编译报错 "posix/xxx.h cannot find" +如果编译报错为 "posix/xxx.h cannot find",请更新rt-thread到最新版本(从github仓库拉取最新的源码) diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/SConscript b/bsp/essemi/es32f369x/applications/arduino_pinout/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..beb0cb7a7cc223686d345c51f35dd83da3e880e1 --- /dev/null +++ b/bsp/essemi/es32f369x/applications/arduino_pinout/SConscript @@ -0,0 +1,9 @@ +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') +inc = [cwd] + +group = DefineGroup('Arduino', src, depend = ['PKG_USING_RTDUINO'], CPPPATH = inc) + +Return('group') diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/examples/arduino_examples.cpp b/bsp/essemi/es32f369x/applications/arduino_pinout/examples/arduino_examples.cpp new file mode 100644 index 0000000000000000000000000000000000000000..25ec3520365efac6e8fdf989872b5087f5bba433 --- /dev/null +++ b/bsp/essemi/es32f369x/applications/arduino_pinout/examples/arduino_examples.cpp @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-10 Meco Man first version + */ + +#include +#include +#include +#include +#define ARDU_TEST_GPIO +#define ARDU_TEST_PWM +//#define ARDU_TEST_ADAFRUIT_I2C +//#define ARDU_TEST_ADAFRUIT_SPI +//#define ARDU_TEST_SPI +//#define ARDU_TEST_I2C +#define ARDU_TEST_INT +#define ARDU_TEST_DIGITAL_READ +//#define ARDU_TEST_ADC_READ +//#define ARDU_TEST_BMI160_PKG + +#if defined(ARDU_TEST_ADAFRUIT_I2C) || defined(ARDU_TEST_ADAFRUIT_SPI) +#include +#endif +#ifdef ARDU_TEST_ADAFRUIT_I2C +#include +Adafruit_I2CDevice i2c_dev(0x2D); +Adafruit_BusIO_Register i2c_reg(&i2c_dev, 0x6261, 2, 0, 2); +#endif +#ifdef ARDU_TEST_ADAFRUIT_SPI +#include "Adafruit_SPIDevice.h" +Adafruit_SPIDevice spi_dev(D10, 100000); +#endif +#ifdef ARDU_TEST_BMI160_PKG +#include "DFRobot_BMI160.h" +DFRobot_BMI160 *bmi160; +#endif + + +static char buf[16] = {"test"}; +static char buf2[16] = {"AB"}; + +void test_int() +{ + Serial.println("Interrupt Triggered\r\n"); +} +void setup(void) +{ + /* put your setup code here, to run once: */ + //串口 + Serial.write("Hello from Arduino\r\n"); + +#ifdef ARDU_TEST_GPIO //数字管脚输出 + pinMode(D2, OUTPUT); + pinMode(D4, OUTPUT); + digitalWrite(D4, 1); + pinMode(D7, OUTPUT); + digitalWrite(D7, 0); + pinMode(D18, OUTPUT); //LED6 +#endif + + pinMode(D21, INPUT); + + +#ifdef ARDU_TEST_PWM //测试PWM输出 + analogWriteFrequency(10); + analogWrite(D3, 80); + analogWrite(D5, 127); + analogWrite(D6, 200); +#endif + +#ifdef ARDU_TEST_ADAFRUIT_I2C //ADAFRUIT I2C + i2c_dev.begin(); +#endif +#ifdef ARDU_TEST_ADAFRUIT_SPI //ADAFRUIT SPI + spi_dev.begin(); +#endif + +#ifdef ARDU_TEST_I2C //I2C + Wire.begin(); +#endif + +#ifdef ARDU_TEST_SPI //SPI + SPI.begin(); + SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE1)); + pinMode(D10, OUTPUT); + digitalWrite(D10, HIGH); +#endif + +#ifdef ARDU_TEST_INT //中断输入 + attachInterrupt(digitalPinToInterrupt(D24), test_int, FALLING); +#endif + +#ifdef ARDU_TEST_DIGITAL_READ //数字管脚输入 + pinMode(D20,INPUT); + pinMode(D21,INPUT); + pinMode(D22,INPUT); + pinMode(D23,INPUT); +#endif +#ifdef ARDU_TEST_BMI160_PKG + bmi160=new DFRobot_BMI160(); + int result= bmi160->I2cInit(); + if (result) + { + rt_kprintf("BMI160 Init failed.%d\r\n",result); + } + bmi160->setStepPowerMode(bmi160->stepNormalPowerMode); +#endif +} + +void loop(void) +{ + /* put your main code here, to run repeatedly: */ + static int count = 0; + count++; +#ifdef ARDU_TEST_GPIO + digitalWrite(D2, 1); + digitalWrite(D18, 0); +#endif + delay(250); +#ifdef ARDU_TEST_GPIO + digitalWrite(D2, 0); + digitalWrite(D18, 1); +#endif + delay(250); + +#ifdef ARDU_TEST_ADC_READ + int val = analogRead(A0 + count % 6); + rt_kprintf("A%d=%d\r\n", count % 6, val); +#endif + +#ifdef ARDU_TEST_ADAFRUIT_I2C + i2c_dev.write((uint8_t *)buf, strlen(buf), true, (uint8_t *)buf2, 2); + i2c_reg.write((uint8_t *)buf, 4); +#endif + +#ifdef ARDU_TEST_ADAFRUIT_SPI + spi_dev.beginTransactionWithAssertingCS(); + spi_dev.transfer((uint8_t *)buf, strlen(buf)); + spi_dev.endTransactionWithDeassertingCS(); +#endif + +#ifdef ARDU_TEST_I2C + Wire.beginTransmission(0x2D); + Wire.write((uint8_t *)buf, strlen(buf)); + Wire.endTransmission(); +#endif + +#ifdef ARDU_TEST_SPI + digitalWrite(D10, LOW); + SPI.transfer((uint8_t *)buf, 4); + digitalWrite(D10, HIGH); + buf[4] = 0; + Serial.print(buf); +#endif + +#ifdef ARDU_TEST_DIGITAL_READ + if (digitalRead(D20) == LOW) { + Serial.println("UP"); + } + if (digitalRead(D21) == LOW) { + Serial.println("DOWN"); + } + if (digitalRead(D22) == LOW) { + Serial.println("LEFT"); + } + if (digitalRead(D23) == LOW) { + Serial.println("RIGHT"); + } +#endif +#ifdef ARDU_TEST_BMI160_PKG + int16_t data[16]={0,0,0}; + int result=bmi160->getAccelData(data); + rt_kprintf("Accel[R=%d]:%d,%d,%d\r\n",result,data[0],data[1],data[2]); + result=bmi160->getAccelGyroData(data); + rt_kprintf("Gyro [R=%d]:%d,%d,%d\r\n",result,data[0],data[1],data[2]); +#endif + +} diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160208893.png b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160208893.png new file mode 100644 index 0000000000000000000000000000000000000000..59c42fcc6659196cb47e7358808b60fd56d3d838 Binary files /dev/null and b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160208893.png differ diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160329321.png b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160329321.png new file mode 100644 index 0000000000000000000000000000000000000000..0a27571606f6388ef6ac49d588d4274a2d7aec8f Binary files /dev/null and b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160329321.png differ diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160331334.png b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160331334.png new file mode 100644 index 0000000000000000000000000000000000000000..0a27571606f6388ef6ac49d588d4274a2d7aec8f Binary files /dev/null and b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220630160331334.png differ diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701144515678.png b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701144515678.png new file mode 100644 index 0000000000000000000000000000000000000000..8c21ccbe857cd9ffea40c346a3d9e889e46c47c3 Binary files /dev/null and b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701144515678.png differ diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145115443.png b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145115443.png new file mode 100644 index 0000000000000000000000000000000000000000..268f5e9e0d8059d5f1eca9c88f1cad3af302ff15 Binary files /dev/null and b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145115443.png differ diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145153781.png b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145153781.png new file mode 100644 index 0000000000000000000000000000000000000000..4056eb8ba6795a00cca66e701887e886abbbd3f0 Binary files /dev/null and b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145153781.png differ diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145240404.png b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145240404.png new file mode 100644 index 0000000000000000000000000000000000000000..5d425bf0c4a22394e33115518f4e944e8f9bea36 Binary files /dev/null and b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220701145240404.png differ diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220706134522478.png b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220706134522478.png new file mode 100644 index 0000000000000000000000000000000000000000..175d4da1d8ef5abae06da7be9c6eae043b7ac005 Binary files /dev/null and b/bsp/essemi/es32f369x/applications/arduino_pinout/picture/image-20220706134522478.png differ diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/pins_arduino.c b/bsp/essemi/es32f369x/applications/arduino_pinout/pins_arduino.c new file mode 100644 index 0000000000000000000000000000000000000000..70f233cf00fddf794a65337340402fa08959b4d7 --- /dev/null +++ b/bsp/essemi/es32f369x/applications/arduino_pinout/pins_arduino.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-10 Meco Man first version + * 2022-07-07 shiwa Adapt ES32F369x + */ +#include +#include +#include "drv_gpio.h" +#include "pins_arduino.h" + +/* + {Arduino Pin, RT-Thread Pin [, Device Name(PWM or ADC), Channel]} + [] means optional + Digital pins must NOT give the device name and channel. + Analog pins MUST give the device name and channel(ADC, PWM or DAC). + Arduino Pin must keep in sequence. +*/ +const pin_map_t pin_map_table[]= +{ + {D0/*, GET_PIN(E,3)*/}, /* UART2_RX */ + {D1/*, GET_PIN(E,2)*/}, /* UART2_TX */ + {D2, GET_PIN(E,4)}, /* GPIO0 */ + {D3, GET_PIN(A,2),"pwm2",3}, /* PWM2 GP32C4T0 CH3 */ + {D4, GET_PIN(E,5)}, /* GPIO1 */ + {D5, GET_PIN(A,1),"pwm2",2}, /* PWM2 GP32C4T0 CH2 */ + {D6, GET_PIN(A,0),"pwm2",1}, /* PWM2 GP32C4T0 CH1 */ + {D7, GET_PIN(E,6)}, /* GPIO2 */ + + {D8, GET_PIN(B,8)}, /* GPIO3 */ + {D9, GET_PIN(B,9)}, /* GPIO4 */ + {D10, GET_PIN(B,0)}, /* GPIO5 */ + {D11/*, GET_PIN(B,5)*/}, /* SPI0_MOSI */ + {D12/*, GET_PIN(B,4)*/}, /* SPI0_MISO */ + {D13/*, GET_PIN(D,3)*/}, /* SPI0_SCK */ + + {D14/*, GET_PIN(B,7)*/}, /* I2C0_SDA */ + {D15/*, GET_PIN(B,6)*/}, /* I2C0_SCL */ + + {D16, GET_PIN(C,8)}, /* LED4 */ + {D17, GET_PIN(C,12)}, /* LED5 */ + {D18, GET_PIN(C,7)}, /* LED6 */ + {D19, GET_PIN(C,6)}, /* LED7 */ + + {D20, GET_PIN(F,1)}, /* KEY_UP */ + {D21, GET_PIN(F,4)}, /* KEY_DOWN */ + {D22, GET_PIN(F,6)}, /* KEY_LEFT */ + {D23, GET_PIN(F,0)}, /* KEY_RIGHT */ + {D24, GET_PIN(F,7)}, /* KEY_CENTER */ + + {A0, GET_PIN(C,0),"adc0",0}, /* ADC0 */ + {A1, GET_PIN(C,1),"adc0",1}, /* ADC0 */ + {A2, GET_PIN(C,2),"adc0",2}, /* ADC0 */ + {A3, GET_PIN(C,3),"adc0",3}, /* ADC0 */ + {A4, GET_PIN(A,4),"adc0",4}, /* ADC0 */ + {A5, GET_PIN(A,5),"adc0",5}, /* ADC0 */ +}; diff --git a/bsp/essemi/es32f369x/applications/arduino_pinout/pins_arduino.h b/bsp/essemi/es32f369x/applications/arduino_pinout/pins_arduino.h new file mode 100644 index 0000000000000000000000000000000000000000..e493e6916ba6a6725b107a8c49ac9f65242f78c7 --- /dev/null +++ b/bsp/essemi/es32f369x/applications/arduino_pinout/pins_arduino.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-10 Meco Man first version + * 2022-07-07 shiwa Adapt ES32F369x + */ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +/* pins alias. Must keep in sequence */ +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) + +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) +#define D14 (14) +#define D15 (15) +#define D16 (16) +#define D17 (17) +#define D18 (18) +#define D19 (19) +#define D20 (20) +#define D21 (21) +#define D22 (22) +#define D23 (23) +#define D24 (24) + +#define A0 (25) +#define A1 (26) +#define A2 (27) +#define A3 (28) +#define A4 (29) +#define A5 (30) + +#define F_CPU 96000000L /* CPU: 96MHz */ + +#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c0" + +#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi0" + +#define LED_BUILTIN D16 + +#endif /* Pins_Arduino_h */ diff --git a/bsp/essemi/es32f369x/drivers/ES/es_conf_info_map.h b/bsp/essemi/es32f369x/drivers/ES/es_conf_info_map.h index 002a074b8d4b7bd75556977b6db7a99d66f57b2a..1a4b4062bda47195c1cd5706b5411668ff838b4f 100644 --- a/bsp/essemi/es32f369x/drivers/ES/es_conf_info_map.h +++ b/bsp/essemi/es32f369x/drivers/ES/es_conf_info_map.h @@ -1,23 +1,5 @@ /* - * Change Logs: - * Date Author Notes - * 2021-04-20 liuhy the first version - * - * Copyright (C) 2021 Shanghai Eastsoft Microelectronics Co., Ltd. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * 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 - * - * 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. + * Copyright (C) 2021 Shanghai Eastsoft Microelectronics Co., Ltd. * */ @@ -39,39 +21,40 @@ struct pin_index }; -#define ES_GPIO_ADC_CH0_GPIO GPIOC -#define ES_GPIO_ADC_CH1_GPIO GPIOC -#define ES_GPIO_ADC_CH2_GPIO GPIOC -#define ES_GPIO_ADC_CH3_GPIO GPIOC -#define ES_GPIO_ADC_CH4_GPIO GPIOA -#define ES_GPIO_ADC_CH5_GPIO GPIOA -#define ES_GPIO_ADC_CH6_GPIO GPIOA -#define ES_GPIO_ADC_CH7_GPIO GPIOA -#define ES_GPIO_ADC_CH8_GPIO GPIOA -#define ES_GPIO_ADC_CH9_GPIO GPIOA -#define ES_GPIO_ADC_CH10_GPIO GPIOA -#define ES_GPIO_ADC_CH11_GPIO GPIOA -#define ES_GPIO_ADC_CH12_GPIO GPIOC -#define ES_GPIO_ADC_CH13_GPIO GPIOC -#define ES_GPIO_ADC_CH14_GPIO GPIOB -#define ES_GPIO_ADC_CH15_GPIO GPIOB - -#define ES_GPIO_ADC_CH0_PIN GPIO_PIN_0 -#define ES_GPIO_ADC_CH1_PIN GPIO_PIN_1 -#define ES_GPIO_ADC_CH2_PIN GPIO_PIN_2 -#define ES_GPIO_ADC_CH3_PIN GPIO_PIN_3 -#define ES_GPIO_ADC_CH4_PIN GPIO_PIN_0 -#define ES_GPIO_ADC_CH5_PIN GPIO_PIN_1 -#define ES_GPIO_ADC_CH6_PIN GPIO_PIN_2 -#define ES_GPIO_ADC_CH7_PIN GPIO_PIN_3 -#define ES_GPIO_ADC_CH8_PIN GPIO_PIN_4 -#define ES_GPIO_ADC_CH9_PIN GPIO_PIN_5 -#define ES_GPIO_ADC_CH10_PIN GPIO_PIN_6 -#define ES_GPIO_ADC_CH11_PIN GPIO_PIN_7 -#define ES_GPIO_ADC_CH12_PIN GPIO_PIN_4 -#define ES_GPIO_ADC_CH13_PIN GPIO_PIN_5 -#define ES_GPIO_ADC_CH14_PIN GPIO_PIN_0 -#define ES_GPIO_ADC_CH15_PIN GPIO_PIN_1 +#define ES_GPIO_ADC_CH0_GPIO GPIOC +#define ES_GPIO_ADC_CH0_PIN GPIO_PIN_0 +#define ES_GPIO_ADC_CH1_GPIO GPIOC +#define ES_GPIO_ADC_CH1_PIN GPIO_PIN_1 +#define ES_GPIO_ADC_CH2_GPIO GPIOC +#define ES_GPIO_ADC_CH2_PIN GPIO_PIN_2 +#define ES_GPIO_ADC_CH3_GPIO GPIOC +#define ES_GPIO_ADC_CH3_PIN GPIO_PIN_3 +#define ES_GPIO_ADC_CH4_GPIO GPIOA +#define ES_GPIO_ADC_CH4_PIN GPIO_PIN_0 +#define ES_GPIO_ADC_CH5_GPIO GPIOA +#define ES_GPIO_ADC_CH5_PIN GPIO_PIN_1 +#define ES_GPIO_ADC_CH6_GPIO GPIOA +#define ES_GPIO_ADC_CH6_PIN GPIO_PIN_2 +#define ES_GPIO_ADC_CH7_GPIO GPIOA +#define ES_GPIO_ADC_CH7_PIN GPIO_PIN_3 +#define ES_GPIO_ADC_CH8_GPIO GPIOA +#define ES_GPIO_ADC_CH8_PIN GPIO_PIN_4 +#define ES_GPIO_ADC_CH9_GPIO GPIOA +#define ES_GPIO_ADC_CH9_PIN GPIO_PIN_5 +#define ES_GPIO_ADC_CH10_GPIO GPIOA +#define ES_GPIO_ADC_CH10_PIN GPIO_PIN_6 +#define ES_GPIO_ADC_CH11_GPIO GPIOA +#define ES_GPIO_ADC_CH11_PIN GPIO_PIN_7 +#define ES_GPIO_ADC_CH12_GPIO GPIOC +#define ES_GPIO_ADC_CH12_PIN GPIO_PIN_4 +#define ES_GPIO_ADC_CH13_GPIO GPIOC +#define ES_GPIO_ADC_CH13_PIN GPIO_PIN_5 +#define ES_GPIO_ADC_CH14_GPIO GPIOB +#define ES_GPIO_ADC_CH14_PIN GPIO_PIN_0 +#define ES_GPIO_ADC_CH15_GPIO GPIOB +#define ES_GPIO_ADC_CH15_PIN GPIO_PIN_1 + + static const struct pin_index pins[] = { @@ -264,10 +247,6 @@ static const struct pin_index pins[] = #define ES_PIN_GPIO_B_9 96 #define ES_PIN_GPIO_E_0 97 #define ES_PIN_GPIO_E_1 98 - -/* UART_TX */ - - #ifndef ES_UART0_TX_GPIO_FUNC #define ES_UART0_TX_GPIO_FUNC GPIO_FUNC_3 #endif @@ -683,24 +662,24 @@ static const struct pin_index pins[] = #endif #ifndef ES_UART2_RX_PIN -#ifdef ES_PIN_GPIO_E_3 -#define ES_UART2_RX_PIN ES_PIN_GPIO_E_3 +#ifdef ES_PIN_GPIO_B_4 +#define ES_UART2_RX_PIN ES_PIN_GPIO_B_4 #endif #endif #ifndef ES_UART2_RX_GPIO_FUNC -#define ES_UART2_RX_GPIO_FUNC GPIO_FUNC_5 +#define ES_UART2_RX_GPIO_FUNC GPIO_FUNC_3 #endif #ifndef ES_UART2_RX_GPIO_PORT -#define ES_UART2_RX_GPIO_PORT GPIOB +#define ES_UART2_RX_GPIO_PORT GPIOE #endif #ifndef ES_UART2_RX_GPIO_PIN -#define ES_UART2_RX_GPIO_PIN GPIO_PIN_4 +#define ES_UART2_RX_GPIO_PIN GPIO_PIN_3 #endif #ifndef ES_UART2_RX_PIN -#ifdef ES_PIN_GPIO_B_4 -#define ES_UART2_RX_PIN ES_PIN_GPIO_B_4 +#ifdef ES_PIN_GPIO_E_3 +#define ES_UART2_RX_PIN ES_PIN_GPIO_E_3 #endif #endif @@ -1759,40 +1738,40 @@ static const struct pin_index pins[] = #endif #ifndef ES_SPI0_SCK_PIN -#ifdef ES_PIN_GPIO_D_3 -#define ES_SPI0_SCK_PIN ES_PIN_GPIO_D_3 +#ifdef ES_PIN_GPIO_B_3 +#define ES_SPI0_SCK_PIN ES_PIN_GPIO_B_3 #endif #endif #ifndef ES_SPI0_SCK_GPIO_FUNC -#define ES_SPI0_SCK_GPIO_FUNC GPIO_FUNC_4 +#define ES_SPI0_SCK_GPIO_FUNC GPIO_FUNC_6 #endif #ifndef ES_SPI0_SCK_GPIO_PORT -#define ES_SPI0_SCK_GPIO_PORT GPIOB +#define ES_SPI0_SCK_GPIO_PORT GPIOA #endif #ifndef ES_SPI0_SCK_GPIO_PIN -#define ES_SPI0_SCK_GPIO_PIN GPIO_PIN_3 +#define ES_SPI0_SCK_GPIO_PIN GPIO_PIN_5 #endif #ifndef ES_SPI0_SCK_PIN -#ifdef ES_PIN_GPIO_B_3 -#define ES_SPI0_SCK_PIN ES_PIN_GPIO_B_3 +#ifdef ES_PIN_GPIO_A_5 +#define ES_SPI0_SCK_PIN ES_PIN_GPIO_A_5 #endif #endif #ifndef ES_SPI0_SCK_GPIO_FUNC -#define ES_SPI0_SCK_GPIO_FUNC GPIO_FUNC_6 +#define ES_SPI0_SCK_GPIO_FUNC GPIO_FUNC_4 #endif #ifndef ES_SPI0_SCK_GPIO_PORT -#define ES_SPI0_SCK_GPIO_PORT GPIOA +#define ES_SPI0_SCK_GPIO_PORT GPIOD #endif #ifndef ES_SPI0_SCK_GPIO_PIN -#define ES_SPI0_SCK_GPIO_PIN GPIO_PIN_5 +#define ES_SPI0_SCK_GPIO_PIN GPIO_PIN_3 #endif #ifndef ES_SPI0_SCK_PIN -#ifdef ES_PIN_GPIO_A_5 -#define ES_SPI0_SCK_PIN ES_PIN_GPIO_A_5 +#ifdef ES_PIN_GPIO_D_3 +#define ES_SPI0_SCK_PIN ES_PIN_GPIO_D_3 #endif #endif @@ -2971,7 +2950,8 @@ static const struct pin_index pins[] = /* GP16C2T_CH2N */ - #define ES_RTT_APP_LED_PIN ES_PIN_GPIO_C_6 + + #endif diff --git a/bsp/essemi/es32f369x/drivers/Kconfig b/bsp/essemi/es32f369x/drivers/Kconfig index 6e70e9674c456f0bc3c572eb92dfa1d2f2a3f72c..c162b779d752c4efae9ef51f79d5ac624081f1dc 100644 --- a/bsp/essemi/es32f369x/drivers/Kconfig +++ b/bsp/essemi/es32f369x/drivers/Kconfig @@ -7,12 +7,25 @@ menu "Hardware Drivers Config" bool "Enable GPIO" select RT_USING_PIN default y - source "drivers/ES/Kconfig" endmenu menu "Onboard Peripheral Drivers" + config BSP_USING_ARDUINO + bool "Support Arduino" + select PKG_USING_RTDUINO + select BSP_USING_GPIO + select BSP_USING_UART2 + select BSP_USING_SPI0 + select BSP_USING_I2C0 + select BSP_USING_ADC0 + select BSP_USING_GP32C4T0_PWM + imply RTDUINO_USING_SERVO + imply RTDUINO_USING_WIRE + imply RTDUINO_USING_SPI + imply RTDUINO_USING_ADAFRUIT + default n config BSP_USING_SPI_FLASH bool "Enable SPI FLASH (W25Q64 spi0)" diff --git a/bsp/essemi/es32f369x/drivers/board.h b/bsp/essemi/es32f369x/drivers/board.h index 871ab7436e355bfa4e51e7ddfffc6115ef1b89f6..8e01cab7b8e01863314ed2ddb2db70c82374faab 100644 --- a/bsp/essemi/es32f369x/drivers/board.h +++ b/bsp/essemi/es32f369x/drivers/board.h @@ -27,7 +27,7 @@ #include #include "es_conf_info_cmu.h" - +#include "es_conf_info_gpio.h" #define ES32F3_SRAM_SIZE 0x18000 #define ES32F3_SRAM_END (0x20000000 + ES32F3_SRAM_SIZE) diff --git a/bsp/essemi/es32f369x/drivers/drv_i2c.c b/bsp/essemi/es32f369x/drivers/drv_i2c.c index bea6e9fe0efbafb6e6a1d807406eeefcea4f6f76..519052d308ffb1c2e58a499a2ff6239e66dbcaa9 100644 --- a/bsp/essemi/es32f369x/drivers/drv_i2c.c +++ b/bsp/essemi/es32f369x/drivers/drv_i2c.c @@ -107,6 +107,162 @@ static void _i2c_init(void) #endif } +#define _I2C_NO_START 0x1 +#define _I2C_NO_STOP 0x2 +int _i2c_master_req(i2c_handle_t *hperh, uint16_t dev_addr, uint32_t timeout,uint32_t req_write) +{ + if (hperh->init.addr_mode == I2C_ADDR_7BIT) { + CLEAR_BIT(hperh->perh->CON2, I2C_CON2_ADD10_MSK); + } + else { + SET_BIT(hperh->perh->CON2, I2C_CON2_ADD10_MSK); + } + + MODIFY_REG(hperh->perh->CON2, I2C_CON2_SADD_MSK, dev_addr << I2C_CON2_SADD_POSS); + if (req_write) + CLEAR_BIT(hperh->perh->CON2, I2C_CON2_RD_WRN_MSK); + else + SET_BIT(hperh->perh->CON2, I2C_CON2_RD_WRN_MSK); + + return OK; +} +int _i2c_wait_flag(i2c_handle_t *hperh, uint32_t flag, flag_status_t status, uint32_t timeout) +{ + uint32_t tickstart = 0; + + tickstart = ald_get_tick(); + while (I2C_GET_FLAG(hperh, flag) == status) { + if ((timeout == 0) || ((ald_get_tick() - tickstart ) > timeout)) { + hperh->error_code |= I2C_ERROR_TIMEOUT; + return TIMEOUT; + } + } + + return OK; +} +int _i2c_wait_txe(i2c_handle_t *hperh, uint32_t timeout) +{ + uint32_t tickstart = ald_get_tick(); + + while (I2C_GET_FLAG(hperh, I2C_STAT_THTH) == RESET) { + if (I2C_GET_IT_FLAG(hperh, I2C_IT_ARLO)) { + hperh->error_code |= I2C_ERROR_ARLO; + return ERROR; + } + + if (I2C_GET_IT_FLAG(hperh, I2C_IT_NACK) == SET) { + hperh->error_code |= I2C_ERROR_AF; + return ERROR; + } + + if ((timeout == 0) || ((ald_get_tick() - tickstart) > timeout)) { + hperh->error_code |= I2C_ERROR_TIMEOUT; + return ERROR; + } + } + + return OK; +} +int _i2c_master_send(i2c_handle_t *hperh, uint16_t dev_addr, uint8_t *buf, + uint32_t size, uint32_t timeout,uint32_t flag) +{ + if (hperh->state != I2C_STATE_READY) + return BUSY; + + if ((buf == NULL) || (size == 0)) + return ERROR; + if ((flag&_I2C_NO_START)==0x0) //NOSTART==0 + { + if (_i2c_wait_flag(hperh, I2C_STAT_BUSY, SET, 100) != OK) + return BUSY; + _i2c_master_req(hperh, dev_addr, timeout,1); + } + assert_param(IS_I2C_TYPE(hperh->perh)); + __LOCK(hperh); + + hperh->state = I2C_STATE_BUSY_TX; + hperh->mode = I2C_MODE_MASTER; + hperh->error_code = I2C_ERROR_NONE; + hperh->p_buff = buf; + hperh->xfer_size = size; + hperh->xfer_count = 0; + + if ((flag&_I2C_NO_STOP)!=0) //NOSTOP==1 + SET_BIT(hperh->perh->CON2, I2C_CON2_RELOAD_MSK); + else + CLEAR_BIT(hperh->perh->CON2, I2C_CON2_RELOAD_MSK); + + if (size <= 0xFF) { + MODIFY_REG(hperh->perh->CON2, I2C_CON2_NBYTES_MSK, size << I2C_CON2_NBYTES_POSS); + } + else { + MODIFY_REG(hperh->perh->CON2, I2C_CON2_NBYTES_MSK, 0xFF << I2C_CON2_NBYTES_POSS); + SET_BIT(hperh->perh->CON2, I2C_CON2_RELOAD_MSK); + } + + + SET_BIT(hperh->perh->FCON, I2C_FCON_TXFRST_MSK); + if ((flag&_I2C_NO_START)==0x0) //NOSTART=0 + SET_BIT(hperh->perh->CON2, I2C_CON2_START_MSK); + + while (size > 0) { + hperh->perh->TXDATA = (*buf++); + size--; + hperh->xfer_count++; + + if (_i2c_wait_txe(hperh, timeout) != OK) + goto ERROR; + + if (((hperh->xfer_count % 0xFF) == 0) && (READ_BIT(hperh->perh->CON2, I2C_CON2_RELOAD_MSK))) { + if (_i2c_wait_flag(hperh, I2C_STAT_TCR, RESET, 10) == OK) { + if (size > 0xFF) { + MODIFY_REG(hperh->perh->CON2, I2C_CON2_NBYTES_MSK, 0xFF << I2C_CON2_NBYTES_POSS); + } + else { + MODIFY_REG(hperh->perh->CON2, I2C_CON2_NBYTES_MSK, size << I2C_CON2_NBYTES_POSS); + if ((flag&_I2C_NO_STOP)==0) + CLEAR_BIT(hperh->perh->CON2, I2C_CON2_RELOAD_MSK); + } + } + else { + goto ERROR; + } + } + } + + if (READ_BIT(hperh->perh->CON2, I2C_CON2_AUTOEND_MSK) == SET) + goto SUCCESS; + + //NOSTOP==1 + if ((flag&_I2C_NO_STOP)!=0&&_i2c_wait_flag(hperh, I2C_STAT_TCR, RESET, 10) == OK) + { + goto SUCCESS; + } + + if (_i2c_wait_flag(hperh, I2C_STAT_TC, RESET, 10) == OK) { + if ((flag&_I2C_NO_STOP)==0x0) //NOSTOP==0 + SET_BIT(hperh->perh->CON2, I2C_CON2_STOP_MSK); + goto SUCCESS; + } + else { + goto ERROR; + } + +ERROR: + SET_BIT(hperh->perh->CON2, I2C_CON2_STOP_MSK); + hperh->state = I2C_STATE_READY; + hperh->mode = I2C_MODE_NONE; + __UNLOCK(hperh); + + return ERROR; + +SUCCESS: + hperh->state = I2C_STATE_READY; + hperh->mode = I2C_MODE_NONE; + __UNLOCK(hperh); + + return OK; +} static rt_size_t es32f3_master_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], @@ -129,7 +285,9 @@ static rt_size_t es32f3_master_xfer(struct rt_i2c_bus_device *bus, } else { - if (ald_i2c_master_send(bus->priv, msg->addr << 1, msg->buf, msg->len, TIMEOUT) != 0) + uint32_t f=((msg->flags&RT_I2C_NO_START)?0x1:0)|((msg->flags&RT_I2C_NO_STOP)?0x2:0); + + if (_i2c_master_send(bus->priv, msg->addr << 1, msg->buf, msg->len, TIMEOUT,f) != 0) { LOG_E("i2c bus write failed,i2c bus stop!\n"); goto out; @@ -140,7 +298,7 @@ static rt_size_t es32f3_master_xfer(struct rt_i2c_bus_device *bus, ret = i; out: - LOG_E("send stop condition\n"); + //LOG_E("send stop condition\n"); return ret; } diff --git a/bsp/essemi/es32f369x/drivers/linker_scripts/link.lds b/bsp/essemi/es32f369x/drivers/linker_scripts/link.lds new file mode 100644 index 0000000000000000000000000000000000000000..6843e2a21816a87c031fa7fcb4969531380b0984 --- /dev/null +++ b/bsp/essemi/es32f369x/drivers/linker_scripts/link.lds @@ -0,0 +1,170 @@ +/* + * linker script for ES32F3696LT with GNU ld es32f36xx only change first 9 line + */ + +/* Program Entry, set to mark it as "used" and avoid gc */ +MEMORY +{ + ROM (rx) : ORIGIN = 0x00000000, LENGTH = 512k /* 256K flash */ + RAM (rw) : ORIGIN = 0x20000000, LENGTH = 96k /* 32K sram */ +} +ENTRY(Reset_Handler) +_system_stack_size = 0x400; + +SECTIONS +{ + .text : + { + . = ALIGN(4); + _stext = .; + KEEP(*(.isr_vector)) /* Startup code */ + + . = ALIGN(4); + *(.text) /* remaining code */ + *(.text.*) /* remaining code */ + *(.rodata) /* read-only data (constants) */ + *(.rodata*) + *(.glue_7) + *(.glue_7t) + *(.gnu.linkonce.t*) + + /* section information for finsh shell */ + . = ALIGN(4); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + + . = ALIGN(4); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + + /* section information for utest */ + . = ALIGN(4); + __rt_utest_tc_tab_start = .; + KEEP(*(UtestTcTab)) + __rt_utest_tc_tab_end = .; + + /* section information for at server */ + . = ALIGN(4); + __rtatcmdtab_start = .; + KEEP(*(RtAtCmdTab)) + __rtatcmdtab_end = .; + . = ALIGN(4); + + /* section information for initial. */ + . = ALIGN(4); + __rt_init_start = .; + KEEP(*(SORT(.rti_fn*))) + __rt_init_end = .; + + . = ALIGN(4); + + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + + . = ALIGN(4); + + _etext = .; + } > ROM = 0 + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + + /* This is used by the startup in order to initialize the .data secion */ + _sidata = .; + } > ROM + __exidx_end = .; + + /* .data section which is used for initialized data */ + + .data : AT (_sidata) + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _sdata = . ; + + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + + + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .data secion */ + _edata = . ; + } >RAM + + .stack : + { + . = ALIGN(4); + _sstack = .; + . = . + _system_stack_size; + . = ALIGN(4); + _estack = .; + } >RAM + + __bss_start = .; + .bss : + { + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; + + *(.bss) + *(.bss.*) + *(COMMON) + + . = ALIGN(4); + /* This is used by the startup in order to initialize the .bss secion */ + _ebss = . ; + + *(.bss.init) + } > RAM + __bss_end = .; + + _end = .; + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + * Symbols in the DWARF debugging sections are relative to the beginning + * of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +}