PSoc62™开发板之i2c通信

实验目的

使用模拟i2c接口读取温湿度气压模块BME280数据

实验准备

  • PSoc62™开发板
  • 温湿度气压模块BME280
  • 公母头杜邦线

板载资源

本次实验是通过模拟i2c时序的方式来进行通信,理论上可以有非常多的方式配置i2c引脚,不像硬件i2c那样芯片出厂引脚已经固定好,所以这里不再列举i2c的GPIO资源,采用模拟i2c的好处是比较容易移植

模块电路

GPIO引脚

MCU_ARD_SCL -> P8.0

MCU_ARD_SDA -> P8.1

在这里插入图片描述

模块连接图

右侧排母从上往下第1、2引脚分别对应SCL、SDA

在这里插入图片描述

实物连接图

依次连接BME280模块的VCC、GND、SDL、SDA引脚

在这里插入图片描述

使能i2c接口

在创建的RT-Thread串口工程中打开RT-Thread Settings,点击右边的箭头<<进入详细页,使用前先使能i2c1,其中,pin number和GPIO的对应关系:P8.0 : 8 x 8 = 64,P8.1 : 8 x 8 + 1 = 65

在这里插入图片描述

i2c-tool软件包

i2c-tool是一个很方便的i2c通信调试工具,它可以查看总线上挂载设备地址、对i2c设备进行读写操作,安装方法如下

在这里插入图片描述

BME280的设备地址可以通过查询的方式得到,如下图所示

在这里插入图片描述

查询BME280设备ID命令,0x76是BME280设备地址,0xd0是设备ID的寄存器地址;如果通信正常,按照手册描述设备ID应该是0x60

i2c read i2c1 0x76 0xd0

程序设计

readCalibrationDatacalibration_Tcalibration_Pcalibration_H用于读取和校准BME280的数据

static unsigned long int hum_raw,temp_raw,pres_raw;
static rt_uint8_t data[8];
static signed long int t_fine;
static uint16_t dig_T1;
static int16_t dig_T2;
static int16_t dig_T3;
static uint16_t dig_P1;
static int16_t dig_P2;
static int16_t dig_P3;
static int16_t dig_P4;
static int16_t dig_P5;
static int16_t dig_P6;
static int16_t dig_P7;
static int16_t dig_P8;
static int16_t dig_P9;
static int8_t  dig_H1;
static int16_t dig_H2;
static int8_t  dig_H3;
static int16_t dig_H4;
static int16_t dig_H5;
static int8_t  dig_H6;
static signed long int temp_cal;
static unsigned long int press_cal,hum_cal;
static double temp_act;
static double press_act;
static double hum_act;static void readCalibrationData()
{uint8_t data[32];read_bme280_reg(0x88, data, 24);read_bme280_reg(0xa1, data + 24, 1);read_bme280_reg(0xe1, data + 25, 7);dig_T1 = (data[1] << 8) | data[0];dig_T2 = (data[3] << 8) | data[2];dig_T3 = (data[5] << 8) | data[4];dig_P1 = (data[7] << 8) | data[6];dig_P2 = (data[9] << 8) | data[8];dig_P3 = (data[11]<< 8) | data[10];dig_P4 = (data[13]<< 8) | data[12];dig_P5 = (data[15]<< 8) | data[14];dig_P6 = (data[17]<< 8) | data[16];dig_P7 = (data[19]<< 8) | data[18];dig_P8 = (data[21]<< 8) | data[20];dig_P9 = (data[23]<< 8) | data[22];dig_H1 = data[24];dig_H2 = (data[26]<< 8) | data[25];dig_H3 = data[27];dig_H4 = (data[28]<< 4) | (0x0F & data[29]);dig_H5 = (data[30] << 4) | ((data[29] >> 4) & 0x0F);dig_H6 = data[31];
}static signed long int calibration_T(signed long int adc_T)
{signed long int var1, var2, T;var1 = ((((adc_T >> 3) - ((signed long int)dig_T1<<1))) * ((signed long int)dig_T2)) >> 11;var2 = (((((adc_T >> 4) - ((signed long int)dig_T1)) * ((adc_T>>4) - ((signed long int)dig_T1))) >> 12) * ((signed long int)dig_T3)) >> 14;t_fine = var1 + var2;T = (t_fine * 5 + 128) >> 8;return T;
}static unsigned long int calibration_P(signed long int adc_P)
{signed long int var1, var2;unsigned long int P;var1 = (((signed long int)t_fine)>>1) - (signed long int)64000;var2 = (((var1>>2) * (var1>>2)) >> 11) * ((signed long int)dig_P6);var2 = var2 + ((var1*((signed long int)dig_P5))<<1);var2 = (var2>>2)+(((signed long int)dig_P4)<<16);var1 = (((dig_P3 * (((var1>>2)*(var1>>2)) >> 13)) >>3) + ((((signed long int)dig_P2) * var1)>>1))>>18;var1 = ((((32768+var1))*((signed long int)dig_P1))>>15);if (var1 == 0){return 0;}P = (((unsigned long int)(((signed long int)1048576)-adc_P)-(var2>>12)))*3125;if(P<0x80000000){P = (P << 1) / ((unsigned long int) var1);}else{P = (P / (unsigned long int)var1) * 2;}var1 = (((signed long int)dig_P9) * ((signed long int)(((P>>3) * (P>>3))>>13)))>>12;var2 = (((signed long int)(P>>2)) * ((signed long int)dig_P8))>>13;P = (unsigned long int)((signed long int)P + ((var1 + var2 + dig_P7) >> 4));return P;
}static unsigned long int calibration_H(signed long int adc_H)
{signed long int v_x1;v_x1 = (t_fine - ((signed long int)76800));v_x1 = (((((adc_H << 14) -(((signed long int)dig_H4) << 20) - (((signed long int)dig_H5) * v_x1)) +((signed long int)16384)) >> 15) * (((((((v_x1 * ((signed long int)dig_H6)) >> 10) *(((v_x1 * ((signed long int)dig_H3)) >> 11) + ((signed long int) 32768))) >> 10) + (( signed long int)2097152)) *((signed long int) dig_H2) + 8192) >> 14));v_x1 = (v_x1 - (((((v_x1 >> 15) * (v_x1 >> 15)) >> 7) * ((signed long int)dig_H1)) >> 4));v_x1 = (v_x1 < 0 ? 0 : v_x1);v_x1 = (v_x1 > 419430400 ? 419430400 : v_x1);return (unsigned long int)(v_x1 >> 12);
}

i2c读写接口封装

static int read_bme280_reg(rt_uint8_t reg_addr, rt_uint8_t *data, rt_uint8_t len)
{struct rt_i2c_msg msgs[2];msgs[0].addr = BME280_ADDR;msgs[0].flags = RT_I2C_WR;msgs[0].buf = &reg_addr;msgs[0].len = 1;msgs[1].addr = BME280_ADDR;msgs[1].flags = RT_I2C_RD;msgs[1].buf = data;msgs[1].len = len;if (rt_i2c_transfer(i2c_bus, msgs, 2) == 2){return RT_EOK;}elsereturn -RT_ERROR;
}static int8_t write_bme280_reg(uint8_t reg, uint8_t *data, uint16_t len)
{rt_uint8_t tmp = reg;struct rt_i2c_msg msgs[2];msgs[0].addr  = BME280_ADDR;                        /* Slave address */msgs[0].flags = RT_I2C_WR;                          /* Write flag */msgs[0].buf   = &tmp;                               /* Slave register address */msgs[0].len   = 1;                                  /* Number of bytes sent */msgs[1].addr  = BME280_ADDR;                        /* Slave address */msgs[1].flags = RT_I2C_WR | RT_I2C_NO_START;        /* Read flag */msgs[1].buf   = data;                               /* Read data pointer */msgs[1].len   = len;                                /* Number of bytes read */if (rt_i2c_transfer(i2c_bus, msgs, 2) != 2){return -RT_ERROR;}return RT_EOK;
}

init_bme280用于初始化i2c设备

static int init_bme280(void)
{i2c_bus = (struct rt_i2c_bus_device *) rt_device_find(BME280_I2C_BUS_NAME);if (i2c_bus == RT_NULL){rt_kprintf("can't find %s device!\n", BME280_I2C_BUS_NAME);return RT_ERROR;}rt_uint8_t data;int size = read_bme280_reg(0xD0, &data, 1);rt_kprintf("bme280 device id : %x\n", data);uint8_t osrs_t = 1;             //Temperature oversampling x 1uint8_t osrs_p = 1;             //Pressure oversampling x 1uint8_t osrs_h = 1;             //Humidity oversampling x 1uint8_t mode = 3;               //Normal modeuint8_t t_sb = 5;               //Tstandby 1000msuint8_t filter = 0;             //Filter offuint8_t spi3w_en = 0;           //3-wire SPI Disableuint8_t ctrl_meas_reg = (osrs_t << 5) | (osrs_p << 2) | mode;uint8_t config_reg    = (t_sb << 5) | (filter << 2) | spi3w_en;uint8_t ctrl_hum_reg  = osrs_h;write_bme280_reg(0xF2, &ctrl_hum_reg, 1);write_bme280_reg(0xF4, &ctrl_meas_reg, 1);write_bme280_reg(0xF5, &config_reg, 1);readCalibrationData();return RT_EOK;
}

整合起来的代码

#include <rtthread.h>
#include <rtdevice.h>
#include "drv_gpio.h"#define LED_PIN                 GET_PIN(0, 1)
#define BME280_I2C_BUS_NAME     "i2c1"
#define BME280_ADDR             0x76static struct rt_i2c_bus_device *i2c_bus;
static rt_thread_t bme280_thread = RT_NULL;
static unsigned long int hum_raw,temp_raw,pres_raw;
static rt_uint8_t data[8];static signed long int t_fine;
static uint16_t dig_T1;
static int16_t dig_T2;
static int16_t dig_T3;
static uint16_t dig_P1;
static int16_t dig_P2;
static int16_t dig_P3;
static int16_t dig_P4;
static int16_t dig_P5;
static int16_t dig_P6;
static int16_t dig_P7;
static int16_t dig_P8;
static int16_t dig_P9;
static int8_t  dig_H1;
static int16_t dig_H2;
static int8_t  dig_H3;
static int16_t dig_H4;
static int16_t dig_H5;
static int8_t  dig_H6;
static signed long int temp_cal;
static unsigned long int press_cal,hum_cal;
static double temp_act;
static double press_act;
static double hum_act;static signed long int calibration_T(signed long int adc_T)
{signed long int var1, var2, T;var1 = ((((adc_T >> 3) - ((signed long int)dig_T1<<1))) * ((signed long int)dig_T2)) >> 11;var2 = (((((adc_T >> 4) - ((signed long int)dig_T1)) * ((adc_T>>4) - ((signed long int)dig_T1))) >> 12) * ((signed long int)dig_T3)) >> 14;t_fine = var1 + var2;T = (t_fine * 5 + 128) >> 8;return T;
}static unsigned long int calibration_P(signed long int adc_P)
{signed long int var1, var2;unsigned long int P;var1 = (((signed long int)t_fine)>>1) - (signed long int)64000;var2 = (((var1>>2) * (var1>>2)) >> 11) * ((signed long int)dig_P6);var2 = var2 + ((var1*((signed long int)dig_P5))<<1);var2 = (var2>>2)+(((signed long int)dig_P4)<<16);var1 = (((dig_P3 * (((var1>>2)*(var1>>2)) >> 13)) >>3) + ((((signed long int)dig_P2) * var1)>>1))>>18;var1 = ((((32768+var1))*((signed long int)dig_P1))>>15);if (var1 == 0){return 0;}P = (((unsigned long int)(((signed long int)1048576)-adc_P)-(var2>>12)))*3125;if(P<0x80000000){P = (P << 1) / ((unsigned long int) var1);}else{P = (P / (unsigned long int)var1) * 2;}var1 = (((signed long int)dig_P9) * ((signed long int)(((P>>3) * (P>>3))>>13)))>>12;var2 = (((signed long int)(P>>2)) * ((signed long int)dig_P8))>>13;P = (unsigned long int)((signed long int)P + ((var1 + var2 + dig_P7) >> 4));return P;
}static unsigned long int calibration_H(signed long int adc_H)
{signed long int v_x1;v_x1 = (t_fine - ((signed long int)76800));v_x1 = (((((adc_H << 14) -(((signed long int)dig_H4) << 20) - (((signed long int)dig_H5) * v_x1)) +((signed long int)16384)) >> 15) * (((((((v_x1 * ((signed long int)dig_H6)) >> 10) *(((v_x1 * ((signed long int)dig_H3)) >> 11) + ((signed long int) 32768))) >> 10) + (( signed long int)2097152)) *((signed long int) dig_H2) + 8192) >> 14));v_x1 = (v_x1 - (((((v_x1 >> 15) * (v_x1 >> 15)) >> 7) * ((signed long int)dig_H1)) >> 4));v_x1 = (v_x1 < 0 ? 0 : v_x1);v_x1 = (v_x1 > 419430400 ? 419430400 : v_x1);return (unsigned long int)(v_x1 >> 12);
}static int read_bme280_reg(rt_uint8_t reg_addr, rt_uint8_t *data, rt_uint8_t len)
{struct rt_i2c_msg msgs[2];msgs[0].addr = BME280_ADDR;msgs[0].flags = RT_I2C_WR;msgs[0].buf = &reg_addr;msgs[0].len = 1;msgs[1].addr = BME280_ADDR;msgs[1].flags = RT_I2C_RD;msgs[1].buf = data;msgs[1].len = len;if (rt_i2c_transfer(i2c_bus, msgs, 2) == 2){return RT_EOK;}elsereturn -RT_ERROR;
}static int8_t write_bme280_reg(uint8_t reg, uint8_t *data, uint16_t len)
{rt_uint8_t tmp = reg;struct rt_i2c_msg msgs[2];msgs[0].addr  = BME280_ADDR;                        /* Slave address */msgs[0].flags = RT_I2C_WR;                          /* Write flag */msgs[0].buf   = &tmp;                               /* Slave register address */msgs[0].len   = 1;                                  /* Number of bytes sent */msgs[1].addr  = BME280_ADDR;                        /* Slave address */msgs[1].flags = RT_I2C_WR | RT_I2C_NO_START;        /* Read flag */msgs[1].buf   = data;                               /* Read data pointer */msgs[1].len   = len;                                /* Number of bytes read */if (rt_i2c_transfer(i2c_bus, msgs, 2) != 2){return -RT_ERROR;}return RT_EOK;
}static void readCalibrationData()
{uint8_t data[32];read_bme280_reg(0x88, data, 24);read_bme280_reg(0xa1, data + 24, 1);read_bme280_reg(0xe1, data + 25, 7);dig_T1 = (data[1] << 8) | data[0];dig_T2 = (data[3] << 8) | data[2];dig_T3 = (data[5] << 8) | data[4];dig_P1 = (data[7] << 8) | data[6];dig_P2 = (data[9] << 8) | data[8];dig_P3 = (data[11]<< 8) | data[10];dig_P4 = (data[13]<< 8) | data[12];dig_P5 = (data[15]<< 8) | data[14];dig_P6 = (data[17]<< 8) | data[16];dig_P7 = (data[19]<< 8) | data[18];dig_P8 = (data[21]<< 8) | data[20];dig_P9 = (data[23]<< 8) | data[22];dig_H1 = data[24];dig_H2 = (data[26]<< 8) | data[25];dig_H3 = data[27];dig_H4 = (data[28]<< 4) | (0x0F & data[29]);dig_H5 = (data[30] << 4) | ((data[29] >> 4) & 0x0F);dig_H6 = data[31];
}static int init_bme280(void)
{i2c_bus = (struct rt_i2c_bus_device *) rt_device_find(BME280_I2C_BUS_NAME);if (i2c_bus == RT_NULL){rt_kprintf("can't find %s device!\n", BME280_I2C_BUS_NAME);return RT_ERROR;}rt_uint8_t data;int size = read_bme280_reg(0xD0, &data, 1);rt_kprintf("bme280 device id : %x\n", data);uint8_t osrs_t = 1;             //Temperature oversampling x 1uint8_t osrs_p = 1;             //Pressure oversampling x 1uint8_t osrs_h = 1;             //Humidity oversampling x 1uint8_t mode = 3;               //Normal modeuint8_t t_sb = 5;               //Tstandby 1000msuint8_t filter = 0;             //Filter offuint8_t spi3w_en = 0;           //3-wire SPI Disableuint8_t ctrl_meas_reg = (osrs_t << 5) | (osrs_p << 2) | mode;uint8_t config_reg    = (t_sb << 5) | (filter << 2) | spi3w_en;uint8_t ctrl_hum_reg  = osrs_h;write_bme280_reg(0xF2, &ctrl_hum_reg, 1);write_bme280_reg(0xF4, &ctrl_meas_reg, 1);write_bme280_reg(0xF5, &config_reg, 1);readCalibrationData();return RT_EOK;
}static void bme280_entry(void* paremeter)
{init_bme280();while(1){read_bme280_reg(0xf7, data, 8);pres_raw = (data[0] << 12) | (data[1] << 4) | (data[2] >> 4);temp_raw = (data[3] << 12) | (data[4] << 4) | (data[5] >> 4);hum_raw  = (data[6] << 8) | data[7];temp_cal = calibration_T(temp_raw);press_cal = calibration_P(pres_raw);hum_cal = calibration_H(hum_raw);temp_act = (double)temp_cal / 100.0;press_act = (double)press_cal;hum_act = (double)hum_cal / 1024.0;rt_kprintf("Temperature=%4dC, Humidity=%4d%, Pressure=%4dPa \r\n",(int)temp_act,(int)hum_act,(int)press_act);rt_thread_mdelay(500);}
}int main(void)
{bme280_thread = rt_thread_create("bme280", bme280_entry, RT_NULL, 1024, 16, 20);if(bme280_thread != RT_NULL){rt_thread_startup(bme280_thread);}rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);for (;;){rt_pin_write(LED_PIN, PIN_HIGH);rt_thread_mdelay(500);rt_pin_write(LED_PIN, PIN_LOW);rt_thread_mdelay(500);}
}

实验效果

运行效果如下,控制台终端间隔500ms打印当前环境的温度、湿度、气压数据

PSoc62™开发板之BME280模块Bring Up

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/635979.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Summary for Packaging and Assembly Technologies for Integrated Systems

目录 Introduction Type of Packages: Packaging of integrated devices Question 1: Question 2: Question 3: Question 4: Question 5: Report 1: Front-end and back-end process Question 6: Question 7: Inspection Process Report 2: Prototyping and mas…

【谭浩强C程序设计精讲 chap4】选择结构程序设计

文章目录 第4章 选择结构程序设计一、用 if 语句实现选择结构二、用 switch 语句实现多分支选择结构三、条件运算符和条件表达式 第4章 选择结构程序设计 一、用 if 语句实现选择结构 一般形式&#xff1a; if (表达式)  语句1 [ else  语句2 ] 其他形式&#xff0c;常用的…

web前端项目-3D台球游戏【附源码】

3D台球 【3D台球】这款游戏的操作简洁明了&#xff0c;玩家只需要简单的练习两分钟便能够掌握。玩家需要用鼠标控制击球的方向和力度&#xff0c;将白球打进洞中。每次进球后&#xff0c;玩家需要选择下一个要击打的球&#xff0c;直到所有的球都打进洞中。但要注意避免黑球进…

【Unity】URP报错Object reference not set to an instance of an object

使用URP之后&#xff0c;Unity报错&#xff1a;显示不正常 NullReferenceException: Object reference not set to an instance of an object UnityEngine.Rendering.Universal.UniversalAdditionalCameraData.get_cameraStack () (at Library/PackageCache/com.unity.render-p…

Flink实时数仓同步:拉链表实战详解

一、背景 在大数据领域&#xff0c;业务数据通常最初存储在关系型数据库&#xff0c;例如MySQL。然而&#xff0c;为了满足日常分析和报表等需求&#xff0c;大数据平台会采用多种不同的存储方式来容纳这些业务数据。这些存储方式包括离线仓库、实时仓库等&#xff0c;根据不同…

智能AI写作到底怎么样?这几款AI写作非常好用

近年来&#xff0c;人工智能&#xff08;AI&#xff09;技术的快速发展已经渗透到各个领域&#xff0c;包括写作领域。AI写作软件通过模仿指定作家的风格和语言&#xff0c;能够生成高质量的文章。这种技术的出现引发了广泛的讨论和争议。本文将探讨AI写作的优点&#xff0c;并…

Windows给docker设置阿里源

windows环境搭建专栏&#x1f517;点击跳转 Windows系统的docker设置阿里源 文章目录 Windows系统的docker设置阿里源1.获得镜像加速器2.配置docker 由于我们生活在中国大陆&#xff0c;所以外网的访问总是那么慢又困难&#xff0c;用docker拉取几兆的小镜象还能忍受&#xff…

单元测试之Stub和Mock

实例 Analyze类会检查filename的长度&#xff0c;如果小于8&#xff0c;我们就会使用一个实现IWebService的类来记录错误. 我们需要给Analyze方法写单元测试。 public class LogAnalyzer {private IWebService service;private IEmailService email;public IWebService Serv…

软考十大管理领域49个过程开展频次总结

1、仅开展一次或仅在预定义时点开展的项目管理过程 序号 过程 过程组 说明 1 制定项目章程 启动 项目章程尽量在整个项目期间保持不变 2 制订项目管理计划 计划 各种管理(程序性)计划和项目基准尽量在整个项目期间保持不变 3 规划范围管理 除规划沟通管…

【微信小程序开发】环境介绍和基本使用

文章目录 前言1. 项目的基本组成结构1.1 JSON 配置文件的作用1.2 如何新建小程序页面1.3 修改项目首页1.4 WXML 模板1.5 WXSS 样式1.6 JS 逻辑交互 2. 宿主环境2.1 什么是宿主环境2.2 通信模型2.3 运行机制2.4 组件2.4.1 view 组件的基本使用&#xff1a;2.4.2 scroll-view 组件…

强网杯2023 crypto

speed up 当时看到这个题目 也是觉得易懂 并且可以解出来的 但是数字实在是过大了兄弟 题目意思是计算2^27的阶乘,并获取得到每一位数的数字之和,flag即为该数字的sha256编码 2^27为134217728 gmpy2包是支持大数运算的,故利用其fac方法进行尝试,在等待一段时间后可以得到对…

2024第十二届中国(上海)国际流体机械展览会(CFME2024)

2024上海流体机械展|泵展|风机展|压缩机展 2024第十二届中国(上海)国际流体机械展览会(CFME2024) 泵阀门风机压缩机减变速机真空干燥设备展 时间&#xff1a;2024年11月25日-27日 地点&#xff1a;国家会展中心&#xff08;上海虹桥&#xff09; ◆展会背景&#xff1a; &q…

从 Context 看 Go 设计模式:接口、封装和并发控制

文章目录 Context 的基本结构Context 的实现和传递机制为什么 Context 不直接传递指针案例&#xff1a;DataStore结论 在 Go 语言中&#xff0c; context 包是并发编程的核心&#xff0c;用于传递取消信号和请求范围的值。但其传值机制&#xff0c;特别是为什么不通过指针传递…

智慧工地解决方案及案例:PPT全文26页,附下载

关键词&#xff1a;智慧工地解决方案&#xff0c;智慧工地建设&#xff0c;智慧工地整体架构&#xff0c;数字化工地&#xff0c;智慧工程 一、智慧工地建设对传统建筑业的影响 1、提高了施工效率和质量&#xff1a;智慧工地建设采用了先进的信息技术和管理方法&#xff0c;可…

力扣343. 整数拆分(动态规划)

Problem: 343. 整数拆分 文章目录 题目描述思路解题方法复杂度Code 题目描述 思路 该题目可以抽象成动态规划中的爬楼梯模型&#xff0c;将整数的拆分类比为上台阶&#xff1a; 1.每个阶段可以从整数中划分出1、2、…k的一个整数 2.int dp[n 1] dp[i]表示为i的整数划分的最大…

Next-GPT: Any-to-Any Multimodal LLM

Next-GPT: Any-to-Any Multimodal LLM 最近在调研一些多模态大模型相关的论文&#xff0c;发现Arxiv上出的论文根本看不过来&#xff0c;遂决定开辟一个新坑《一页PPT说清一篇论文》。自己在读论文的过程中会用一页PPT梳理其脉络和重点信息&#xff0c;旨在帮助自己和读者快速了…

线程池的简单介绍及使用

线程池 线程池的参数介绍拒绝策略 线程池的任务处理流程使用Executors创建常见的线程池 线程池的参数介绍 corePoolSize: (核心线程数)这是线程池中始终存在的线程数&#xff0c;即使这些线程处于空闲状态。maximumPoolSize:(最大线程数) 是线程池允许的最大线程数。keepAliveT…

免费200万Tokens 用科大讯飞API调用星火大模型服务

简介 自ChatGPT火了之后&#xff0c;国内的大模型发展如雨后春笋。其中的佼佼者之一就是科大讯飞研发的星火大模型,现在大模型已经更新到V3 版本&#xff0c;而且对开发者也是相当友好&#xff0c;注册就送200万tokens,讯飞1tokens 约等于 1.5 个中文汉字 或者 0.8 个英文单词…

安卓开发-day

一、安卓项目结构 1、manifests文件夹 Android系统配置文件夹&#xff0c;包含一个AndroidManifest.xml文件&#xff1b; AndroidMainifest.xml文件是每个android项目必须要包含的文件&#xff08;项目唯一&#xff09;&#xff0c;创建项目时默认就会生成这个文件&#xff0…

【Python学习】Python学习21- 正则表达式(1)

目录 【Python学习】Python学习21- 正则表达式&#xff08;1&#xff09; 前言re.match函数实例 re.search方法re.match与re.search的区别参考 文章所属专区 Python学习 前言 本章节主要说明Python的正则表达式。 正则表达式是一个特殊的字符序列&#xff0c;它能帮助你方便的…