韦东山嵌入式linux系列-具体单板的按键驱动程序(查询方式)

news2024/9/25 1:16:24

1 GPIO 操作回顾

(1)使能模块;

(2)设置引脚的模式(工作于GPIO模式);

(3)设置GPIO本身(输入/输出);

(4)GPIO作为输入引脚时,读某个data寄存器获得引脚的电平。

2 百问网 STM32MP157 的按键驱动程序(查询方式)

在 STM32MP157 开发板上,我们为它设计了 2 个按键。

2.1 先看原理图确定引脚及操作方法

平时按键电平为低,按下按键后电平为高。

按键引脚为 GPIOG_IO03、 GPIOG_IO02。

2.2 再看芯片手册确定寄存器及操作方法

步骤1:使能GPIOG

下图为针对 APU 的 GPIOA 至 K 的时钟使能寄存器,低11位有效。为了使用GPIOG,我们需要将对应的 b[6]位设置为 1

英文明明写的是MPU

MPU/MCU -- Microprocessor/Micro controller Unit, 微处理器/微控制器,一般用于低计算应用的RISC计算机体系架构产品,如ARM-M系列处理器。

APU、BPU、CPU、DPU、FPU、GPU、HPU、IPU、MPU、NPU、RPU、TPU、VPU、WPU、XPU、ZPU 都是什么? - 一杯清酒邀明月 - 博客园 (cnblogs.com)

地址偏移量:0xA28
复位值:0x0000 0000

该寄存器用于将相应外设的外设时钟使能位设置为“1”。它将用于为MPU分配外设。写“0”没有作用,读有作用,返回相应位的有效值。写入'1'将相应的位设置为'1'

Bits 31:11保留,必须保持在复位值。
bit10 GPIOKEN: GPIOK外设时钟使能软件设置。
0:写“0”无效,读“0”表示禁用外设时钟
1:写“1”使能外设时钟,读“1”使能外设时钟

其他位一样

步骤2:设置GPIOG_IO03、 GPIOG_IO02为GPIO输入模式

GPIOx_MODER用于配置GPIO的模式,包括输入、通用输出、多功能和模拟共四种模式。该寄存器共32位,涉及16个GPIO,每个GPIO对应 2 位。GPIOx_MODER 的各位定义如下,在这里分别选择00和01两种,各自对应输入和输出模式。(上电默认为输入悬空模式)。其中 00 对应输入功能, 01 对应输出功能

设置 b[7:6]为00就可以配置GPIOG_IO03为输入模式,

配置 b[5:4]为00就可以配置GPIOG_IO02为输入模式。

步骤 3:读取GPIOG_IO02、GPIOG_IO03引脚电平

寄存器地址为:

在参考手册搜关键字gpio

读取 IDR 寄存器获取引脚状态寄存器,得到引脚电平

Bits 31:16保留,必须保持复位值。
bit 15:0 IDR[15:0]:端口x输入数据I/O引脚y (y = 15 ~ 0),这些位是只读的。它们包含相应I/O端口的输入值。

3 代码

board_drv.c

#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/fcntl.h>
#include <linux/fs.h>
#include <linux/signal.h>
#include <linux/mutex.h>
#include <linux/mm.h>
#include <linux/timer.h>
#include <linux/wait.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include <linux/capi.h>
#include <linux/kernelcapi.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/moduleparam.h>

#include "button_drv.h"


// 1主设备号
static int major = 0;
static struct class* button_class;
static struct button_operations *p_button_operations;


void register_button_operations(struct button_operations *opr)
{
	int i;
	p_button_operations = opr;
	for (i = 0; i < opr->count; i++)
	{
		device_create(button_class, NULL, MKDEV(major, i), NULL, "winter_button@%d", i);
	}
}

void unregister_button_operations(void)
{
	int i;
	for (i = 0; i < p_button_operations->count; i++)
	{
		device_destroy(button_class, MKDEV(major, i));
	}
}

EXPORT_SYMBOL(register_button_operations);
EXPORT_SYMBOL(unregister_button_operations);


// 3实现open/read函数
static int button_open (struct inode *inode, struct file *file)
{
	int minor = iminor(inode);
	// 利用此设备号初始化
	p_button_operations->init(minor);
	return 0;
}

static ssize_t button_read (struct file *file, char __user *buf, size_t size, loff_t *off)
{
	unsigned int minor = iminor(file_inode(file));
	char level;
	int err;
	
	level = p_button_operations->read(minor);
	// 将内核数据拷贝到用户空间,也就是读数据
	err = copy_to_user(buf, &level, 1);
	return 1;
}


// 2file_operations结构体
static struct file_operations button_operations = {
	.open = button_open,
	.read = button_read,
};

// 4在入口函数中注册file_operations结构体
int button_init(void)
{
	// 注册file_operations结构体
	major = register_chrdev(0, "winter_button", &button_operations);
	// 注册结点
	button_class = class_create(THIS_MODULE, "winter_button");
	if (IS_ERR(button_class))
		return -1;
	
	return 0;

}

// 出口函数
void button_exit(void)
{
	class_destroy(button_class);
	unregister_chrdev(major, "winter_button");
}

module_init(button_init);
module_exit(button_exit);
MODULE_LICENSE("GPL");

board_drv.h

#ifndef BUTTON_DRV_H
#define BUTTON_DRV_H

struct button_operations {
	int count;
	void (*init) (int which);
	int (*read) (int which);
};

void register_button_operations(struct button_operations *opr);
void unregister_button_operations(void);

#endif

board_xxx.c

#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/fcntl.h>
#include <linux/fs.h>
#include <linux/signal.h>
#include <linux/mutex.h>
#include <linux/mm.h>
#include <linux/timer.h>
#include <linux/wait.h>
#include <linux/skbuff.h>
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include <linux/capi.h>
#include <linux/kernelcapi.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/moduleparam.h>

#include "button_drv.h"

static void board_xxx_button_init_gpio (int which)
{
	printk("%s %s %d, init gpio for button %d\n", __FILE__, __FUNCTION__, __LINE__, which);
}

static int board_xxx_button_read_gpio (int which)
{
	printk("%s %s %d, read gpio for button %d\n", __FILE__, __FUNCTION__, __LINE__, which);
	return 1;
}

static struct button_operations my_buttons_ops ={
	.count = 2,
	.init  = board_xxx_button_init_gpio,
	.read  = board_xxx_button_read_gpio,
};

int board_xxx_button_init(void)
{
	register_button_operations(&my_buttons_ops);
	return 0;
}

void board_xxx_button_exit(void)
{
	unregister_button_operations();
}

module_init(board_xxx_button_init);
module_exit(board_xxx_button_exit);
MODULE_LICENSE("GPL");

board_test.c

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

/*
 * ./button_test /dev/100ask_button0
 *
 */
int main(int argc, char **argv)
{
	int fd;
	char val;
	
	/* 1. 判断参数 */
	if (argc != 2) 
	{
		printf("Usage: %s <dev>\n", argv[0]);
		return -1;
	}

	/* 2. 打开文件 */
	fd = open(argv[1], O_RDWR);
	if (fd == -1)
	{
		printf("can not open file %s\n", argv[1]);
		return -1;
	}

	/* 3. 写文件 */
	read(fd, &val, 1);
	printf("get button : %d\n", val);
	
	close(fd);
	
	return 0;
}

上面4个和之前的都一样,主要不同在board_100ask_stm32mp157.c

主要看 board_100ask_stm32mp157-pro.c。涉及的寄存器挺多,一个一个去执行 ioremap 效率太低。先定义结构体,然后对结构体指针进行 ioremap。对于 GPIO,可以如下定义:

struct stm32mp157_gpio {
  volatile unsigned int MODER;    /*!< GPIO port mode register,               Address offset: 0x00      */
  volatile unsigned int OTYPER;   /*!< GPIO port output type register,        Address offset: 0x04      */
  volatile unsigned int OSPEEDR;  /*!< GPIO port output speed register,       Address offset: 0x08      */
  volatile unsigned int PUPDR;    /*!< GPIO port pull-up/pull-down register,  Address offset: 0x0C      */
  volatile unsigned int IDR;      /*!< GPIO port input data register,         Address offset: 0x10      */
  volatile unsigned int ODR;      /*!< GPIO port output data register,        Address offset: 0x14      */
  volatile unsigned int BSRR;     /*!< GPIO port bit set/reset,               Address offset: 0x18      */
  volatile unsigned int LCKR;     /*!< GPIO port configuration lock register, Address offset: 0x1C      */
  volatile unsigned int AFR[2];   /*!< GPIO alternate function registers,     Address offset: 0x20-0x24 */
} ;

这个顺序是按照偏移量列出的

看一个驱动程序,先看它的入口函数, 下列代码向上层驱动注册一个button_operations 结构体,代码如下。

static struct button_operations my_buttons_ops = {
    .count = 2,
    .init = board_stm32mp157_button_init,
    .read = board_stm32mp157_button_read,
};
// 入口函数
int board_stm32mp157_button_drv_init(void)
{
    register_button_operations(&my_buttons_ops);
    return 0;
}

void board_stm32mp157_button_drv_exit(void)
{
    unregister_button_operations();
}

button_operations 结 构 体 中 有 init 函 数 指 针 , 它 指 向board_stm32mp157_button_init 函数,在里面将会初始化 LED 引脚:使能、设置为 GPIO 模式、设置为输出引脚。代码如下。
值得关注的下列代码中对 ioremap 函数的使用,它们是得到寄存器的虚拟地址,以后使用虚拟地址访问寄存器。

/* RCC_PLL4CR */
static volatile unsigned int *RCC_PLL4CR; 

/* RCC_MP_AHB4ENSETR */
static volatile unsigned int *RCC_MP_AHB4ENSETR;

/* KEY1: PG3, KEY2: PG2 */
static struct stm32mp157_gpio *gpiog;

/* 初始化button, which-哪个button */
static void board_stm32mp157_button_init (int which)
{
    // 没有使能
    if (!RCC_PLL4CR)
    {
        RCC_PLL4CR = ioremap(0x50000000 + 0x894, 4);
        RCC_MP_AHB4ENSETR = ioremap(0x50000000 + 0xA28, 4);

        gpiog = ioremap(0x50008000, sizeof(struct stm32mp157_gpio));
    }

    if (which == 0)
    {
        /* 1. enable PLL4 
         * CG15, b[31:30] = 0b11
         */
		*RCC_PLL4CR |= (1<<0);
		while((*RCC_PLL4CR & (1<<1)) == 0);

		/* 2. enable GPIOG */
		*RCC_MP_AHB4ENSETR |= (1<<6);
		
		/* 3. 设置PG3为GPIO模式, 输入模式 
		 */
		gpiog->MODER &= ~(3<<6);
        
    }
    else if(which == 1)
    {
        /* 1. enable PLL4 
         * CG15, b[31:30] = 0b11
         */
		*RCC_PLL4CR |= (1<<0);
		while((*RCC_PLL4CR & (1<<1)) == 0);

		/* 2. enable GPIOG */
		*RCC_MP_AHB4ENSETR |= (1<<6);
		
		/* 3. 设置PG2为GPIO模式, 输入模式 
		 */
		gpiog->MODER &= ~(3<<4);
    }
    
}

button_operations 结 构 体 中 还 有 有 read 函 数 指 针 , 它 指 向board_stm32mp157_button_read 函数,在里面将会读取并返回按键引脚的电平。代码如下

static int board_stm32mp157_button_read (int which) /* 读button, which-哪个 */
{
    //printk("%s %s line %d, button %d, 0x%x\n", __FILE__, __FUNCTION__, __LINE__, which, *GPIO1_DATAIN);
    if (which == 0)
        return (gpiog->IDR & (1<<3)) ? 1 : 0;
    else
        return (gpiog->IDR & (1<<2)) ? 1 : 0;
}

参考:韦东山嵌入式linux系列-LED驱动程序-CSDN博客

board_100ask_stm32mp157.c

#include <linux/module.h>

#include <linux/fs.h>
#include <linux/io.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/mutex.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/tty.h>
#include <linux/kmod.h>
#include <linux/gfp.h>
#include <asm/io.h>

#include "button_drv.h"


/* RCC_PLL4CR */
static volatile unsigned int* RCC_PLL4CR; 

/* RCC_MP_AHB4ENSETR */
static volatile unsigned int* RCC_MP_AHB4ENSETR; 

/* KEY1: PG3, KEY2: PG2 */
static struct stm32mp157_gpio* gpiog;


struct stm32mp157_gpio {
  volatile unsigned int MODER;    /*!< GPIO port mode register,               Address offset: 0x00      */
  volatile unsigned int OTYPER;   /*!< GPIO port output type register,        Address offset: 0x04      */
  volatile unsigned int OSPEEDR;  /*!< GPIO port output speed register,       Address offset: 0x08      */
  volatile unsigned int PUPDR;    /*!< GPIO port pull-up/pull-down register,  Address offset: 0x0C      */
  volatile unsigned int IDR;      /*!< GPIO port input data register,         Address offset: 0x10      */
  volatile unsigned int ODR;      /*!< GPIO port output data register,        Address offset: 0x14      */
  volatile unsigned int BSRR;     /*!< GPIO port bit set/reset,               Address offset: 0x18      */
  volatile unsigned int LCKR;     /*!< GPIO port configuration lock register, Address offset: 0x1C      */
  volatile unsigned int AFR[2];   /*!< GPIO alternate function registers,     Address offset: 0x20-0x24 */
};





/* 初始化button, which-哪个button */      
static void board_stm32mp157_button_init (int which) 
{
	if (!RCC_PLL4CR)
    {
        RCC_PLL4CR = ioremap(0x50000000 + 0x894, 4);
        RCC_MP_AHB4ENSETR = ioremap(0x50000000 + 0xA28, 4);

        gpiog = ioremap(0x50008000, sizeof(struct stm32mp157_gpio));
    }

    if (which == 0)
    {
        /* 1. enable PLL4 
         * CG15, b[31:30] = 0b11
         */
		*RCC_PLL4CR |= (1<<0);
		while((*RCC_PLL4CR & (1<<1)) == 0);

		/* 2. enable GPIOG */
		*RCC_MP_AHB4ENSETR |= (1<<6);
		
		/* 3. 设置PG3为GPIO模式, 输入模式 
		 */
		gpiog->MODER &= ~(3<<6);
        
    }
    else if(which == 1)
    {
        /* 1. enable PLL4 
         * CG15, b[31:30] = 0b11
         */
		*RCC_PLL4CR |= (1<<0);
		while((*RCC_PLL4CR & (1<<1)) == 0);

		/* 2. enable GPIOG */
		*RCC_MP_AHB4ENSETR |= (1<<6);
		
		/* 3. 设置PG2为GPIO模式, 输入模式 
		 */
		gpiog->MODER &= ~(3<<4);
    }
}


/* 读button, which-哪个 */
static int board_stm32mp157_button_read (int which)
{
	//printk("%s %s line %d, button %d, 0x%x\n", __FILE__, __FUNCTION__, __LINE__, which, *GPIO1_DATAIN);
    if (which == 0)
    {
		return (gpiog->IDR & (1<<3)) ? 1 : 0;
	}
    else
    {
		return (gpiog->IDR & (1<<2)) ? 1 : 0;
	}
}


static struct button_operations my_buttons_ops = {
    .count = 2,
    .init = board_stm32mp157_button_init,
    .read = board_stm32mp157_button_read,
};

int board_stm32mp157_button_drv_init(void)
{
    register_button_operations(&my_buttons_ops);
    return 0;
}

void board_stm32mp157_button_drv_exit(void)
{
    unregister_button_operations();
}

module_init(board_stm32mp157_button_drv_init);
module_exit(board_stm32mp157_button_drv_exit);

MODULE_LICENSE("GPL");

编译

4 测试

在开发板挂载 Ubuntu 的NFS目录

mount -t nfs -o nolock,vers=3 192.168.5.11:/home/book/nfs_rootfs/ /mnt

将ko文件和测试代码拷贝到挂载目录,安装驱动

insmod button_drv.ko
insmod board_100ask_stm32mp157.ko

执行测试程序观察它的返回值(执行测试程序的同时操作按键):

./button_test /dev/winter_button@0
./button_test /dev/winter_button@1

执行程序的同时,按下按键,输出是0

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

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

相关文章

Linux_make/Makefile的理解

1.make是一个命令&#xff0c;makefile是一个文件, 依赖关系和依赖方法. a.快速使用一下 i.创建一个Makefile文件(首字母也可以小写) b.依赖关系和依赖方法 i.依赖关系: 我为什么要帮你? mybin:mytest.c ii.依赖方法: 怎么帮? gcc -o mybin mytest.c make之前要注意先创建…

UE4-构建光照后导入的静态网格体变黑

当我们将我们的静态网格体导入到项目当中的时候&#xff0c;此时我们进行重新构建光照&#xff0c;我们在从新构建完光照后&#xff0c;会发现我们的静态网格体全部变黑了&#xff0c;此时是因为没有设置光照贴图分辨率和坐标索引引起的。 将General Settings中的L…

Unite 上海 强势回归

​​​ 他回归了 Unite 大会是一年一度的 Unity 全球开发者盛会。今年&#xff0c;Unite 将于 7 月盛夏点亮上海外滩。此次盛会&#xff0c;我们将以“团结”为核心&#xff0c;凝聚全球 3000 多位 Unity 社区精英的力量&#xff0c;共同开启 Unity 技术的新纪元。 在这里&am…

【C++】透析类和对象(上)

有不懂的&#xff0c;可翻阅我之前文章哦&#xff01; 个人主页&#xff1a;CSDN_小八哥向前冲 所属专栏&#xff1a;C入门 目录 类的定义 访问限定符 类域 类的实例化 实例化概念 对象大小 this指针 类的默认成员函数 构造函数 析构函数 模拟栈&#xff08;初学者&…

(最最最全)远程服务器连接新手教程-服务器基本指令、连接服务器、安装Anaconda、配置Conda、配置环境、bashrc环境变量修改(为空怎么办)

一、服务器基本指令 ls - 列出当前目录的文件和子目录cd - 改变当前目录pwd - 显示当前目录的路径df - 查看当前内存mkdir - 创建新目录rm - 删除文件cp - 复制文件mv - 移动或重命名文件 https://blog.csdn.net/weixin_43693391/article/details/133984143?ops_request_mis…

Ubuntu20.04版本升级openssh9.8p1方法

一、问题描述&#xff1a; 8.5p1 和 9.7p1 之间的openssh版本漏洞可能会导致linux系统以root身份进行RCE&#xff0c;所以需安装最新版本 二、解决方法&#xff1a; 将当前openssh版本升级到最新的版本即openssh-9.8p1版本&#xff0c;OpenSSL大版本升级且OpenSSH有新稳定版本…

今天我们聊聊C#的并发和并行

并发和并行是现代编程中的两个重要概念&#xff0c;它们可以帮助开发人员创建高效、响应迅速、高性能的应用程序。在C#中&#xff0c;这些概念尤为重要&#xff0c;因为该语言提供了对多线程和异步编程的强大支持。本文将介绍C#中并发和并行编程的关键概念、优点&#xff0c;并…

CSS(二)——CSS 背景

CSS 背景 CSS 背景属性用于定义HTML元素的背景。 CSS 背景属性 Property描述background简写属性&#xff0c;作用是将背景属性设置在一个声明中。background-attachment背景图像是否固定或者随着页面的其余部分滚动。background-color设置元素的背景颜色。background-image把…

秋招突击——7/24——知识补充——JVM类加载机制

文章目录 引言类加载机制知识点复习类的生命周期1、加载2、连接——验证3、连接——准备4、连接——解析5、初始化 类加载器和类加载机制类加载器类加载机制——双亲委派模型 面试题整理1、类加载是什么2、类加载的过程是什么3、有哪些类加载器&#xff1f;4、双亲委派模型是什…

FineBI连接MySQL5.7

一、在FineBI系统管理中&#xff0c;点击【新建数据库连接】 选择MySQL数据库 配置数据库连接&#xff0c;如下&#xff0c;其中数据库名称就是需要连接的目标数据库

STM32工业物联网系统教程

目录 引言环境准备工业物联网系统基础代码实现&#xff1a;实现工业物联网系统 4.1 数据采集模块 4.2 数据处理与分析模块 4.3 通信与网络系统实现 4.4 用户界面与数据可视化应用场景&#xff1a;工业监测与优化问题解决方案与优化收尾与总结 1. 引言 工业物联网&#xff08…

QCefView 在Clion+vs2022下编译

目录 QCefView 的编译Note下载代码方式一:可直接通过github下载方式二: csdn下载编译代码1. 解压文件2. 按照规定重新放置代码文件3. 将cef 的zip 放入CefViewCore中的dep文件夹内4. 使用Clion打开QCefView工程文件夹测试代码附QCefView 的编译 Note 需要使用VS2022 编译,VS…

配置linux客户端免密登录服务端linux主机的root用户

在192.168.30.129端口&#xff0c;对192.168.30.130端口进行免密登录 登录成功

[嵌入式Linux]-常见编译框架与软件包组成

嵌入式常见编译框架与软件包组成 1.嵌入式开发准备工作 主芯片资料包括&#xff1a; 主芯片资料 主芯片开发参考手册&#xff1b;主芯片数据手册&#xff1b;主芯片规格书&#xff1b; 硬件参考 主芯片硬件设计参考资料&#xff1b;主芯片配套公板硬件工程&#xff1b; 软件…

三分钟追踪工作流表单引擎几大优势

众所周知&#xff0c;企业都希望能实现开源节流。那么&#xff0c;如何实现这一目标是很多人都在思考的重要问题。低代码技术平台可操作性强、可视化界面丰富而简洁高效、灵活可靠&#xff0c;在推动企业流程化办公的过程中发挥了重要的市场价值和作用。本文将给大家介绍清楚低…

ROS小车设计问题记录

演示视频 问题小计 串口发送数据乱码IMU JY60 串口接收车轮测速电机调速 串口发送数据乱码 使用Send_User_Data()数据错误&#xff0c;数据帧输出为0x32&#xff1b;使用HAL_UART_Transmit_DMA()输出正确&#xff0c;数据帧输出为0x55。 解决&#xff1a; 将数组_data_to_sne…

vscode配置latex环境制作【文档、简历、resume】

vscode配置latex环境制作【文档、简历、resume】 1. 安装Tex Live及vscode插件 可以参考&#xff1a;vscode配置latex环境制作beamer ppt 2. 添加vscode配置文件 打开vscode&#xff0c;按下Ctrl Shift P打开搜索框&#xff0c;搜索Preference: Open User Settings (JSON…

[Linux]Mysql之主从同步

AB复制 一、主从复制概述 主从复制&#xff0c;是用来建立一个和主数据库完全一样的数据库环境&#xff0c;称为从数据库&#xff1b;主数据库一般是准实时的业务数据库。 主从复制的作用 1.做数据的热备&#xff0c;作为后备数据库&#xff0c;主数据库服务器故障后&#xf…

【人工智能】Transformers之Pipeline(五):深度估计(depth-estimation)

目录 一、引言 二、深度估计&#xff08;depth-estimation&#xff09; 2.1 概述 2.2 技术路径 2.3 应用场景 2.4 pipeline参数 2.4.1 pipeline对象实例化参数 2.4.2 pipeline对象使用参数 2.4 pipeline实战 2.5 模型排名 三、总结 一、引言 pipeline&#xff08…

【Stable Diffusion】AI生成新玩法:图像风格迁移

【Stable Diffusion】 AI生成新玩法&#xff1a;图像风格迁移 1 背景导入 你是否曾梦想过让自己融入梵高的星空之中 或是将一幅风景画赋予毕加索的立体主义之魂 还是把人物送进宫崎骏的动画世界&#xff1f; 下面让我们来看看如何通过 Stable Diffusion 实现在图像中玩…