diff --git a/bin/ecos-init_project b/bin/ecos-init_project index 5245f78..fdcd429 100755 --- a/bin/ecos-init_project +++ b/bin/ecos-init_project @@ -33,9 +33,9 @@ echo_available_templates() { echo "| rng | | | | √ |" echo "| rtc | | | | √ |" echo "| smoke_test | | | | √ |" - echo "| spi_st7735 | √* | √ | | √ |" + echo "| spi_st7735 | √* | | | √ |" echo "| spi_st7735_clock | √* | | | √ |" - echo "| spi_st7735_donut | √ | √ | | √ |" + echo "| spi_st7735_donut | √ | | | √ |" echo "| st7789 | | √ | | √ |" echo "| timer | | | | √ |" echo "| wdg | | | | √ |" diff --git a/templates/filesystem_test/c2/main.c b/templates/filesystem_test/c2/main.c index 94ac2b7..430cc97 100644 --- a/templates/filesystem_test/c2/main.c +++ b/templates/filesystem_test/c2/main.c @@ -1,5 +1,5 @@ #include "main.h" -#include "init.h" +#include "ffinit.h" void main(void){ @@ -13,4 +13,4 @@ void main(void){ while(1){ // printf("ENDING\n"); } -} \ No newline at end of file +} diff --git a/templates/i2c_scan/c2/main.c b/templates/i2c_scan/c2/main.c index 9de26e5..f0a82f2 100644 --- a/templates/i2c_scan/c2/main.c +++ b/templates/i2c_scan/c2/main.c @@ -1,6 +1,14 @@ #include "main.h" #include "board.h" + +// I2C状态寄存器位定义 +#define I2C_STATUS_RXACK ((uint8_t)0x80) // (1 << 7) +#define I2C_STATUS_BUSY ((uint8_t)0x40) // (1 << 6) +#define I2C_STATUS_TIP ((uint8_t)0x02) // (1 << 1) +#define I2C_START_WRITE ((uint8_t)0x90) +#define I2C_STOP ((uint8_t)0x40) + static bool i2c_probe_device_quiet(uint8_t addr) { // 保存原来的stdout,临时重定向以抑制错误输出 // 由于这是嵌入式环境,我们直接通过寄存器操作来检测ACK @@ -127,14 +135,14 @@ void i2c_print_scan_result(uint8_t start_addr, uint8_t end_addr) { void main(void){ - sys_uart_init(); + hal_sys_uart_init(); printf("Hello, World!\n"); // 初始化I2C - i2c_config_t i2c_config = { + hal_i2c_config_t i2c_config = { .pscr = 99, }; - i2c_init(&i2c_config); + hal_i2c_init(HAL_I2C_PORT_0,&i2c_config); // 执行I2C设备扫描 printf("\n=== I2C Device Scanner ===\n"); diff --git a/templates/i2c_scan/c2/main.h b/templates/i2c_scan/c2/main.h index c2b91c2..cd49d96 100644 --- a/templates/i2c_scan/c2/main.h +++ b/templates/i2c_scan/c2/main.h @@ -9,13 +9,14 @@ // Components headers // #include "timer.h" // #include "qspi.h" -#include "gpio.h" +//#include "gpio.h" // #include "pwm.h" // #include "hp_uart.h" -#include "i2c.h" +#include "hal_i2c.h" +#include "hal_sys_uart.h" // Device headers // #include "st7735.h" // #include "sgp30.h" -#define PSRAM_SCKL_FREQ_MHZ (CONFIG_CPU_FREQ_MHZ / CONFIG_PSRAM_NUM) \ No newline at end of file +#define PSRAM_SCKL_FREQ_MHZ (CONFIG_CPU_FREQ_MHZ / CONFIG_PSRAM_NUM) diff --git a/templates/minesweeper/c2/main.c b/templates/minesweeper/c2/main.c index 0a2f4ca..1adf242 100644 --- a/templates/minesweeper/c2/main.c +++ b/templates/minesweeper/c2/main.c @@ -243,7 +243,7 @@ typedef enum state_t {NEW_GAME, IN_GAME, GAME_OVER} state_t; #define MAX_BLOCKS 128u int main(void) { - sys_uart_init(); + hal_sys_uart_init(); state_t state = GAME_OVER; state_t next_state; // user input diff --git a/templates/minesweeper/c2/main.h b/templates/minesweeper/c2/main.h index 058fdf9..ec1a67c 100644 --- a/templates/minesweeper/c2/main.h +++ b/templates/minesweeper/c2/main.h @@ -7,15 +7,15 @@ #include "generated/autoconf.h" // Components headers -#include "timer.h" -#include "qspi.h" -#include "gpio.h" -#include "pwm.h" -#include "hp_uart.h" -#include "i2c.h" +#include "hal_timer.h" +#include "hal_qspi.h" +#include "hal_gpio.h" +#include "hal_pwm.h" +#include "hal_hp_uart.h" +#include "hal_i2c.h" // Device headers #include "st7735.h" #include "sgp30.h" -#define PSRAM_SCKL_FREQ_MHZ (CONFIG_CPU_FREQ_MHZ / CONFIG_PSRAM_NUM) \ No newline at end of file +#define PSRAM_SCKL_FREQ_MHZ (CONFIG_CPU_FREQ_MHZ / CONFIG_PSRAM_NUM) diff --git a/templates/st7789/c2/main.c b/templates/st7789/c2/main.c index 780db41..82282bf 100644 --- a/templates/st7789/c2/main.c +++ b/templates/st7789/c2/main.c @@ -1,17 +1,22 @@ #include "main.h" void main(void){ - sys_uart_init(); + hal_sys_uart_init(); printf("ST7789 LCD TEST!\n"); - qspi_config_t qspi_config = { + + hal_qspi_config_t qspi_config = { .clkdiv = 1, }; - qspi_init(&qspi_config); + hal_qspi_init(HAL_QSPI_PORT_0, &qspi_config); st7789_device_t st7789 = { - .dc_pin = GPIO_NUM_0, - .rst_pin = GPIO_NUM_1, + .dc_gpio_port = 0, + .dc_gpio_pin = GPIO_NUM_0, + .rst_gpio_port = 0, + .rst_gpio_pin = GPIO_NUM_1, + .qspi_port = HAL_QSPI_PORT_0, + .qspi_cs = HAL_QSPI_CS_0, .screen_width = 240, .screen_height = 240, .rotation = 2, @@ -22,4 +27,4 @@ void main(void){ st7789_fill(&st7789, 0, 0, 240, 240, 0xFFFFFFFF); st7789_fill(&st7789, 0, 0, 240, 240, 0x00000000); st7789_fill(&st7789, 0, 0, 240, 240, 0xAAAAAAAA); -} \ No newline at end of file +} diff --git a/templates/st7789/c2/main.h b/templates/st7789/c2/main.h index 08dbcda..dba9c32 100644 --- a/templates/st7789/c2/main.h +++ b/templates/st7789/c2/main.h @@ -7,16 +7,16 @@ #include "generated/autoconf.h" // Components headers -#include "timer.h" -#include "qspi.h" -#include "gpio.h" -#include "pwm.h" -#include "hp_uart.h" -#include "i2c.h" +#include "hal_timer.h" +#include "hal_qspi.h" +#include "hal_gpio.h" +#include "hal_pwm.h" +#include "hal_hp_uart.h" +#include "hal_i2c.h" // Device headers #include "st7735.h" #include "sgp30.h" #include "st7789.h" -#define PSRAM_SCKL_FREQ_MHZ (CONFIG_CPU_FREQ_MHZ / CONFIG_PSRAM_NUM) \ No newline at end of file +#define PSRAM_SCKL_FREQ_MHZ (CONFIG_CPU_FREQ_MHZ / CONFIG_PSRAM_NUM)