diff --git a/bsp/es32f0654/README.md b/bsp/es32f0654/README.md index f93d1d3caabf2ab2591a2b8b7f6e52a4490b9681..ff25d6a58fb462266ce150aec91cbf97a8696811 100644 --- a/bsp/es32f0654/README.md +++ b/bsp/es32f0654/README.md @@ -9,7 +9,7 @@ ### 1.1 开发板介绍 主要内容如下: -ES-PDS-ES32F0654 是东软载波微电子官方推出的一款基于 ARM Cortex-M0 内核的开发板,最高主频为 48Mhz(实际使用24Mhz),可满足基础功能测试及高端功能扩展等开发需求。 +ES-PDS-ES32F0654 是东软载波微电子官方推出的一款基于 ARM Cortex-M0 内核的开发板,最高主频为 48MHz,可满足基础功能测试及高端功能扩展等开发需求。 开发板外观如下图所示: @@ -19,30 +19,31 @@ ES-PDS-ES32F0654-V1.0 该开发板常用 **板载资源** 如下: -- MCU:ES32F0654LT,主频 24MHz,256KB FLASH,32KB RAM,54 GPIOs -- 外部 FLASH:W25Q128(SPI,16MB)、EEPROM(24c02) +- MCU:ES32F0654LT,主频 48MHz,32KB SRAM,256KB FLASH,54 GPIOs +- 外部模块:SPI FLASH (MX25L64,8MB)、I2C EEPROM (M24C04,512B) - 常用外设 - - LED:2个,(红色,PC8-PC9) + - 可调电阻:1个,(PB00) + - LED:2个,(PC8/PC9) - 按键:3个,K1(PF00),K2(PF01),RESET(MRST) -- 常用接口:串口、GPIO、SPI、I2C +- 常用接口:GPIO、UART、SPI、I2C - 调试接口,ESLinkⅡ(EastSoft 官方推出的开发工具,有标准版和mini版两种版本,均自带 CDC 串口功能) SWD 下载 外设支持: 本 BSP 目前对外设的支持情况如下: -| **板载外设** | **支持情况** | **备注** | +| **板载外设** | **支持情况** | **备注** | | :---------------- | :----------: | :------------------------------------| | SPI FLASH | 支持 | | -| **片上外设** | **支持情况** | **备注** | +| **片上外设** | **支持情况** | **备注** | | :---------------- | :----------: | :------------------------------------| | GPIO | 支持 | 54 GPIOs | | UART | 支持 | UART0/1/2/3 | -| SPI | 支持 | SPI0/1 | +| SPI | 支持 | SPI0/1 | | I2C | 支持 | I2C0/1 | -| **扩展模块** | **支持情况** | **备注** | +| **扩展模块** | **支持情况** | **备注** | 更多详细信息请咨询[上海东软载波微电子技术支持](http://www.essemi.com/) diff --git a/bsp/es32f0654/drivers/board.c b/bsp/es32f0654/drivers/board.c index 9c4098fda67be7215549d52585e1455e9ff1727a..8918377750fd6c7dca0e6f3b5bbe3c51965f3b8d 100644 --- a/bsp/es32f0654/drivers/board.c +++ b/bsp/es32f0654/drivers/board.c @@ -42,14 +42,11 @@ void NVIC_Configuration(void) *******************************************************************************/ void SystemClock_Config(void) { - /* hosc 8MHz, from hosc/2 pll to 48MHz */ - cmu_pll1_config(CMU_PLL1_INPUT_HOSC_2, CMU_PLL1_OUTPUT_48M); + /* hosc 12MHz, from hosc/3 pll to 48MHz */ + cmu_pll1_config(CMU_PLL1_INPUT_HOSC_3, CMU_PLL1_OUTPUT_48M); /* MCLK 48MHz*/ cmu_clock_config(CMU_CLOCK_PLL1, 48000000); - - /* SYSCLK 24MHz */ - cmu_div_config(CMU_SYS, CMU_DIV_2); } /******************************************************************************* diff --git a/bsp/es32f0654/drivers/drv_gpio.c b/bsp/es32f0654/drivers/drv_gpio.c index 2f4fa29292e9266122df31b0d5b9fbc9cfc6bc7b..59143cb622641afa9678cf624a4123068489c691 100644 --- a/bsp/es32f0654/drivers/drv_gpio.c +++ b/bsp/es32f0654/drivers/drv_gpio.c @@ -60,7 +60,7 @@ static const struct pin_index pins[] = __ES32F0_PIN(27, B, 1), __ES32F0_PIN(28, B, 2), __ES32F0_PIN(29, B, 10), - __ES32F0_PIN_DEFAULT, + __ES32F0_PIN(30, B, 11), __ES32F0_PIN_DEFAULT, __ES32F0_PIN_DEFAULT, __ES32F0_PIN(33, B, 12), diff --git a/bsp/es32f0654/drivers/drv_spi.c b/bsp/es32f0654/drivers/drv_spi.c index bd57d5c1ac79e7f463c43ed1190879a782c51632..b2c675b9f980eee1e6eb19b7bb75abc1a80245fc 100644 --- a/bsp/es32f0654/drivers/drv_spi.c +++ b/bsp/es32f0654/drivers/drv_spi.c @@ -28,6 +28,7 @@ rt_err_t spi_configure(struct rt_spi_device *device, spi_handle_t *hspi; hspi = (spi_handle_t *)device->bus->parent.user_data; + /* config spi mode */ if (cfg->mode & RT_SPI_SLAVE) { hspi->init.mode = SPI_MODE_SLAVER; @@ -77,13 +78,35 @@ rt_err_t spi_configure(struct rt_spi_device *device, { hspi->init.ss_en = ENABLE; } + + /* config spi clock */ if (cfg->max_hz >= cmu_get_pclk1_clock() / 2) { - hspi->init.baud = SPI_BAUD_2; + /*pclk1 max speed 48MHz, spi master max speed 10MHz*/ + if (cmu_get_pclk1_clock() / 2 <= 10000000) + { + hspi->init.baud = SPI_BAUD_2; + } + else if (cmu_get_pclk1_clock() / 4 <= 10000000) + { + hspi->init.baud = SPI_BAUD_4; + } + else + { + hspi->init.baud = SPI_BAUD_8; + } } else if (cfg->max_hz >= cmu_get_pclk1_clock() / 4) { - hspi->init.baud = SPI_BAUD_4; + /*pclk1 max speed 48MHz, spi master max speed 10MHz*/ + if (cmu_get_pclk1_clock() / 4 <= 10000000) + { + hspi->init.baud = SPI_BAUD_4; + } + else + { + hspi->init.baud = SPI_BAUD_8; + } } else if (cfg->max_hz >= cmu_get_pclk1_clock() / 8) { @@ -215,7 +238,7 @@ int es32f0_spi_register_bus(SPI_TypeDef *SPIx, const char *name) } else if (SPIx == SPI1) { - _spi1.perh = SPI0; + _spi1.perh = SPI1; spi_bus = &_spi_bus1; spi = &_spi1; diff --git a/bsp/es32f0654/drivers/drv_uart.c b/bsp/es32f0654/drivers/drv_uart.c index 172c736d751e5f8b649fe4416ecec77ba5cc8b05..4a8838108ae1669d88d02c396841e38b9f5b1030 100644 --- a/bsp/es32f0654/drivers/drv_uart.c +++ b/bsp/es32f0654/drivers/drv_uart.c @@ -42,7 +42,6 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial gpio_init_initstructure.type = GPIO_TYPE_TTL; #ifdef BSP_USING_UART0 - gpio_init_initstructure.func = GPIO_FUNC_3; gpio_init(GPIOB, GPIO_PIN_10, &gpio_init_initstructure); @@ -51,11 +50,9 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial gpio_init(GPIOB, GPIO_PIN_11, &gpio_init_initstructure); NVIC_EnableIRQ(UART0_IRQn); - #endif /* uart0 gpio init */ #ifdef BSP_USING_UART1 - gpio_init_initstructure.func = GPIO_FUNC_3; gpio_init(GPIOC, GPIO_PIN_10, &gpio_init_initstructure); @@ -64,11 +61,9 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial gpio_init(GPIOC, GPIO_PIN_11, &gpio_init_initstructure); NVIC_EnableIRQ(UART1_IRQn); - #endif /* uart1 gpio init */ #ifdef BSP_USING_UART2 - gpio_init_initstructure.func = GPIO_FUNC_5; gpio_init(GPIOC, GPIO_PIN_12, &gpio_init_initstructure); @@ -77,11 +72,9 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial gpio_init(GPIOD, GPIO_PIN_2, &gpio_init_initstructure); NVIC_EnableIRQ(BS16T1_UART2_IRQn); - #endif /* uart2 gpio init */ #ifdef BSP_USING_UART3 - gpio_init_initstructure.func = GPIO_FUNC_4; gpio_init(GPIOC, GPIO_PIN_4, &gpio_init_initstructure); @@ -90,7 +83,6 @@ static rt_err_t es32f0x_configure(struct rt_serial_device *serial, struct serial gpio_init(GPIOC, GPIO_PIN_5, &gpio_init_initstructure); NVIC_EnableIRQ(BS16T2_UART3_IRQn); - #endif /* uart3 gpio init */ uart->huart.init.mode = UART_MODE_UART; diff --git a/bsp/es32f0654/template.uvoptx b/bsp/es32f0654/template.uvoptx index d3460f8030f85e3caf83d78770133e0765e337a6..a89435d3f3d35bf83ac0afc8b9c03ee9950ac054 100644 --- a/bsp/es32f0654/template.uvoptx +++ b/bsp/es32f0654/template.uvoptx @@ -22,11 +22,11 @@ - rt-thread_es32f065x + rt-thread 0x4 ARM-ADS - 24000000 + 12000000 1 1 @@ -73,11 +73,11 @@ 0 - 1 + 0 0 1 - 255 + 0 0 1 @@ -95,7 +95,7 @@ 1 0 1 - 0 + 1 1 1 0 @@ -117,18 +117,13 @@ 0 - CMSIS_AGDI - -X"Any" -UAny -O206 -S0 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0ES32F065x -FS00 -FL040000 + JL2CM3 + -U12345678 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0ES32F065x.FLM -FS00 -FL040000 -FP0($$Device:ES32F0654LT$Flash\ES32F065x.FLM) 0 UL2CM3 - UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0es32f0xx -FL040000 -FS00 -FP0($$Device:ES32F0654LT$Flash\es32f0xx.FLM) - - - 0 - JL2CM3 - -U12345678 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -TO18 -TC10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0ES32F065x -FS00 -FL040000 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0ES32F065x -FS00 -FL040000 -FP0($$Device:ES32F0654LT$Flash\ES32F065x.FLM)) diff --git a/bsp/es32f0654/template.uvprojx b/bsp/es32f0654/template.uvprojx index be655d2f35a0490c1cad2de8c39522c8e0c2add2..cac27e88536037ff2a9ff3fa4d0dbdab818dd8dc 100644 --- a/bsp/es32f0654/template.uvprojx +++ b/bsp/es32f0654/template.uvprojx @@ -7,7 +7,7 @@ - rt-thread_es32f065x + rt-thread 0x4 ARM-ADS