1#include "device_info.hcs" 2root { 3 platform { 4 gpio_config { 5 template default_config { 6 match_attr = "default_config"; 7 /* gpio_num_t, gpio_pull_mode_t, gpio_drive_cap_t */ 8 /* GPIO号 上下拉状态 驱动强度 */ 9 gpio_attr = ["GPIO_NUM_2", "GPIO_PULLUP_ONLY", "GPIO_DRIVE_CAP_DEFAULT"]; 10 } 11 gpio_0 :: default_config { // 双色LED(红色) 12 gpio_attr = ["GPIO_NUM_2", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 13 } 14 gpio_1 :: default_config { // 双色LED(蓝色) 15 gpio_attr = ["GPIO_NUM_27", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 16 } 17 gpio_2 :: default_config { // 电源使能 18 gpio_attr = ["GPIO_NUM_26", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 19 } 20 gpio_3 :: default_config { // 独立按键 21 gpio_attr = ["GPIO_NUM_39", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 22 } 23 gpio_4 :: default_config { // SPI_LCD 数据命令控制脚 24 gpio_attr = ["GPIO_NUM_15", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 25 } 26 gpio_5 :: default_config { // SPI_LCD 复位引脚 27 gpio_attr = ["GPIO_NUM_18", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 28 } 29 gpio_6 :: default_config { // SPI_LCD 背光控制引脚 30 gpio_attr = ["GPIO_NUM_22", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 31 } 32 gpio_7 :: default_config { // NFC芯片复位引脚 33 gpio_attr = ["GPIO_NUM_10", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 34 } 35 gpio_8 :: default_config { // NFC中断引脚 36 gpio_attr = ["GPIO_NUM_13", "GPIO_FLOATING", "GPIO_DRIVE_CAP_DEFAULT"]; 37 } 38 } 39 uart_config { 40 template default_config { 41 match_attr = "config_uart0";// 匹配字符串,与device_info.hcs中对应 42 uart_port = 0; // 串口端口: UART0 43 baudrate = 115200; // 波特率 44 /* Tx引脚GPIO号、Rx引脚GPIO号、rts引脚GPIO号、cts引脚GPIO号*/ 45 uart_gpio_pin = [1, 3, 255, 255]; // 串口引脚GPIO号, 无流控则引脚号置为255 46 /* uart_word_length_t uart_parity_t uart_stop_bits_t uart_hw_flowcontrol_t */ 47 /* 数据位 、 校验位、 停止位、 流控 */ 48 uart_attr = ["UART_DATA_8_BITS", "UART_PARITY_DISABLE", "UART_STOP_BITS_1", "UART_HW_FLOWCTRL_DISABLE"]; 49 } 50 uart_0 :: default_config { 51 match_attr = "config_uart0"; 52 uart_port = 0; 53 uart_gpio_pin = [1, 3, 255, 255]; // 串口引脚GPIO号, 无流控则引脚号置为255 54 } 55 } 56 adc_config { 57 adc1_config { 58 match_attr = "adc1_config"; 59 handle = 1; // 1: adc1 2:adc2 60 channel = 6; // 6: GPIO34, ADC1_CHANNEL:0-7, ADC2_CHANNEL:0-9 61 } 62 } 63 watchdog_config { 64 watchdog0_config { 65 match_attr = "watchdog0"; 66 id = 0; // 看门狗ID 67 timeout = 1; // 看门狗超时时间,单位s 68 } 69 } 70 pwm_config { 71 template default_config { 72 match_attr = "config_pwm0"; 73 channel = "LEDC_CHANNEL_0"; // PWM通道, 对应 ledc_channel_t 枚举 74 timer = "LEDC_TIMER_0"; // 定时器单元,对应 ledc_timer_t 枚举 75 freq_hz = 2000; // PWM周期频率(单位Hz) 76 gpio_pin = "GPIO_NUM_21"; // 外部PWM输出的GPIO Pin脚,对应 gpio_num_t 枚举 77 } 78 pwm0 :: default_config { 79 match_attr = "config_pwm0"; 80 } 81 pwm1 :: default_config { 82 match_attr = "config_pwm1"; 83 channel = "LEDC_CHANNEL_1"; 84 timer = "LEDC_TIMER_1"; 85 pwm_pin = "GPIO_NUM_25"; 86 } 87 } 88 i2c_config { 89 template default_config { 90 match_attr = "i2c0_config"; 91 mode = 0; // I2C主从模式 0:master 1:slave 92 port = 0; // I2C端口号 93 scl_pin = 4; // SCL引脚号 94 sda_pin = 9; // SDA引脚号 95 speed = 400000; // I2C时钟频率 96 } 97 i2c0 :: default_config{ 98 port = 0; 99 } 100 } 101 spi_config { 102 template default_config { 103 match_attr = "spi0_config"; 104 spi_num = 0; // SPI端口号 105 miso_pin = 25; 106 mosi_pin = 23; 107 sck_pin = 19; 108 cs_pin = 5; 109 speed = 10000000; // 时钟信号频率、单位(hz) 110 mode = 0; // SPI模式,表示CPOL与CPHA配置(0-3) 111 max_transfer_size = 35108; // 最大传输字节数 112 queue_size = 1; // 队列长度 113 dma_chn = 0; 114 } 115 spi1 :: default_config { 116 match_attr = "spi1_config"; 117 spi_num = 1; 118 dma_chn = 2; 119 } 120 } 121 } 122} 123