• 按键中断实验


     按键中断实验

    1、按键电路图分析

    按键抬起时,PF9引脚输入高电平,按键按下时,PF9引脚输入低电平。

    2、分析按键中断的数据手册

    2.1 分析2.5.2章节,确定GPIOF,RCC,EXTI,GIC外设分别接到哪个总线上,以及外设寄存器对应的基地址

    2.2 分析RCC章节,使能GPIOF外设控制器的时钟

    2.3 分析GPIO章节,设置GPIO引脚为输入模式

    2.3.1 GPIOx_MODER寄存器

    2.3.2 GPIOx_PUPDR寄存器

    2.4 分析EXTI章节,设置中断信号的检测

    2.4.1 EXTI_FTSR1寄存器

    1. KEY1--》PF9--》EXTI9---》EXTI9对应的输入事件的编号,需要查看数据手册的21.3章节的表118,如下图所示,
    2. 可知EXTI9对应的输入事件的编号位输入事件9号。
    3. EXTI_FTSR1[9]写1,使能下降沿触发中断。及当有下降沿时就认为是一个中断信号。

    2.4.2 EXTI_FPR1寄存器

    1. KEY1--》PF9--》EXTI9---》EXTI9对应的输入事件的编号,需要查看数据手册的21.3章节的表118
    2. 可知EXTI9对应的输入事件的编号位输入事件9号。
    3. EXTI_FPR1[9]写1,清除下降沿中断挂起标志位。

    2.4.3 EXTI_EXTICR3寄存器

    1. EXTI中总共有16个EXTI,从EXTI0-EXTI9,EXTI_EXTICR寄存器的每8位管理一个EXTI外设,
    2. 几个寄存器最多管理4个EXTI,因此需要4个寄存器工程管理16个EXTI。
    3. KEY1--> PF9 ---> EXTI9 ---》EXTI_EXTICR3[15:8] --->0x5,将PF9连接到EXTI9

    2.4.4 EXTI_C1IMR1寄存器

    1. KEY1--》PF9--》EXTI9---》EXTI9对应的输入事件的编号,需要查看数据手册的21.3章节的表118
    2. 可知EXTI9对应的输入事件的编号为输入事件9号。
    3. EXTI_C1IMR1[9]写1,不屏蔽中断信号。

    2.5 分析GIC章节,设置全局中断控制器

    GICD_CTLR : GICD层全局使能寄存器

    GICD_ISENABLER : GICD层中断设置使能寄存器

    GICD_ICPENDR :GICD层中断清除挂起寄存器

    GICD_IPRIORITYR : GICD层中断优先级设置寄存器

    GICD_ITARGETSR : GICD层中断目标分配寄存器

    GICC_CTLR : GICC层全局使能寄存器

    GICC_PMR : GICC层优先级屏蔽寄存器

    GICC_IAR : GICC层中断应答寄存器

    GICC_EOIR :GICC层中断处理结束寄存器

    2.5.1 中断号的获取

    每个中断外设都有一个唯一的中断号,通过查看芯片手册的21.2章节的表117,如下图所示:

    KEY1 ---》 PF9 ---》 EXTI9 ----》中断号:99
    

    2.5.2 GIC全局中断控制器的介绍

    2.5.3 GICD介绍

    2.5.4 GICD_CTLR : GICD层全局使能寄存器

    2.5.5 GICD_ISENABLER : GICD层中断设置使能寄存器

    1. 前提:KEY1 ---》 PF9 ---》 EXTI9 ----》中断号:99
    2. GICD_ISENABLER : GICD层中断设置使能寄存器
    3. GICD_ISENABLER寄存器的每1位管理一个中断号,一个寄存器最多管理32个中断号。
    4. GIC控制器支持16个SGIs,16个PPIs, 256个SPIs, GIC控制器总共支持288个中断号,
    5. GICD_ISENABLER寄存器要想管理288个中断号,最少需要9(288/32)个寄存器。
    6. 99号中断对应GICD_ISENABLER寄存器的哪一个,哪一位?
    7. 99 / 32 = 3 ...... 3
    8. 商对应着寄存器的编号,余数对应操作寄存器的位。
    9. GICD_ISENABLER3[3] 写1, 使能99号中断

    2.5.6 GICD_ICPENDR :GICD层中断清除挂起寄存器

    1. 前提:KEY1 ---》 PF9 ---》 EXTI9 ----》中断号:99
    2. GICD_ICPENDR :GICD层中断清除挂起寄存器
    3. GICD_ICPENDR寄存器的每1位管理一个中断号,一个寄存器最多管理32个中断号。
    4. GIC控制器支持16个SGIs,16个PPIs, 256个SPIs, GIC控制器总共支持288个中断号,
    5. GICD_ICPENDR寄存器要想管理288个中断号,最少需要9(288/32)个寄存器。
    6. 99号中断对应GICD_ICPENDR寄存器的哪一个,哪一位?
    7. 99 / 32 = 3 ...... 3
    8. 商对应着寄存器的编号,余数对应操作寄存器的位。
    9. GICD_ICPENDR3[3]
    10. 1, 清除99号中断挂起标志位
    11. 0,没有影响
    12. 0:表示99号中断没有发生
    13. 1:表示99号中断发生

    2.5.7 GICD_IPRIORITYR : GICD层中断优先级设置寄存器

    1. 前提:KEY1 ---》 PF9 ---》 EXTI9 ----》中断号:99
    2. GICD_IPRIORITYR : GICD层中断优先级设置寄存器
    3. GICD_IPRIORITYR寄存器的每8(5位有效位+3位保留位)位管理一个中断号,一个寄存器最多管理4个中断号。
    4. GIC控制器支持16个SGIs,16个PPIs, 256个SPIs, GIC控制器总共支持288个中断号,
    5. GICD_IPRIORITYR寄存器要想管理288个中断号,最少需要72(288/4)个寄存器。
    6. 99号中断对应GICD_IPRIORITYR寄存器的哪一个,哪5位?
    7. 99 / 4 = 24 ...... 3
    8. 商对应着寄存器的编号,(余数*8+3) 对应操作寄存器的最低位。
    9. GICD_IPRIORITYR24[31:27] 设置中断的优先等级,数越小,优先级越高

    2.5.8 GICD_ITARGETSR : GICD层中断目标分配寄存器

    1. 前提:KEY1 ---》 PF9 ---》 EXTI9 ----》中断号:99
    2. GICD_ITARGETSR : GICD层中断目标分配寄存器
    3. GICD_ITARGETSR寄存器的每8(6位保留位+2位有效位)位管理一个中断号,一个寄存器最多管理4个中断号。
    4. GIC控制器支持16个SGIs,16个PPIs, 256个SPIs, GIC控制器总共支持288个中断号,
    5. GICD_ITARGETSR寄存器要想管理288个中断号,最少需要72(288/4)个寄存器。
    6. 99号中断对应GICD_ITARGETSR寄存器的哪一个,哪2位?
    7. 99 / 4 = 24 ...... 3
    8. 商对应着寄存器的编号,(余数*8) 对应操作寄存器的最低位。
    9. GICD_ITARGETSR24[25:24] 分配中断到不同的CPU接口中
    10. 01 : 分配给CPU接口0
    11. 10 : 分配给CPU接口1
    12. 11 : 分配给CPU接口0和CPU接口1
    13. 这个寄存器的每1位管理一个CPU核,STM32MP1处理器有两个CPU核,因此需要两位即可

    2.5.9 GICC介绍

    2.5.10 GICC_CTLR : GICC层全局使能寄存器

    2.5.11 GICC_PMR : GICC层优先级屏蔽寄存器

    1. 如果一个中断信号的优先级值高于GICC_PMR寄存器字段中的值,则对应的中断将会被转发到CPU中,
    2. 中断信号的优先级通过GICD_IPRIORITYR寄存器进行配置。
    3. 假设中断信号的优先级为10, GICC_PMR[7:3]为20, 此中断信号被转发到CPU中。
    4. 假设中断信号的优先级为20, GICC_PMR[7:3]为10, 此中断信号不被转发到CPU中。

    2.5.12 GICC_IAR : GICC层中断应答寄存器

    2.5.13 GICC_EOIR :GICC层中断处理结束寄存器

    3、编写按键中断的驱动代码

    4、代码实现:

    4.1interrupt.c

    1. #include "../include/interrupt.h"
    2. void hal_gpio_IT_init(gpio_t *gpios, unsigned int pins)
    3. {
    4. // 1. 使用GPIOF控制器的时钟
    5. RCC->MP_AHB4ENSETR = 0xFF;
    6. // 2. 设置PF9引脚为输入的功能
    7. gpios->MODER &= ~(0x3 << (pins * 2));
    8. }
    9. // KEY1->PF9->EXTI9-->输入事件编号为:9
    10. void hal_exti_IT_init(input_event_t input_event,
    11. gpio_exti_t gpio_exti, trigger_t trigger)
    12. {
    13. // 1. 设置PF9连接到EXTI9上 EXTI_EXTICR3[15:8] = 0x5
    14. switch (input_event / 4)
    15. {
    16. case 0:
    17. EXTI->EXTICR1 &= ~(0xFF << (input_event % 4 * 8));
    18. EXTI->EXTICR1 |= (gpio_exti << (input_event % 4 * 8));
    19. break;
    20. case 1:
    21. EXTI->EXTICR2 &= ~(0xFF << (input_event % 4 * 8));
    22. EXTI->EXTICR2 |= (gpio_exti << (input_event % 4 * 8));
    23. break;
    24. case 2:
    25. EXTI->EXTICR3 &= ~(0xFF << (input_event % 4 * 8));
    26. EXTI->EXTICR3 |= (gpio_exti << (input_event % 4 * 8));
    27. break;
    28. case 3:
    29. EXTI->EXTICR4 &= ~(0xFF << (input_event % 4 * 8));
    30. EXTI->EXTICR4 |= (gpio_exti << (input_event % 4 * 8));
    31. break;
    32. }
    33. // 2. 设置KEY1按键为下降沿检测 EXTI_FTSR1[9] = 0x1
    34. if (trigger != RISING_TRIGGER)
    35. {
    36. EXTI->FTSR1 |= (0x1 << input_event);
    37. }
    38. else
    39. {
    40. EXTI->RTSR1 |= (0x1 << input_event);
    41. }
    42. // 3. 使能EXTI9中断 EXTI_C1IMR1[9] = 0x1
    43. EXTI->C1IMR1 |= (0x1 << input_event);
    44. }
    45. // KEY1->PF9->EXTI9-->中断号为99
    46. void hal_gic_IT_init(unsigned int it_id, unsigned int pri)
    47. {
    48. // 1. 设置GICD层的中断使能 GICD_ISENABLER3[3] = 0x1
    49. GICD->ISENABLER[it_id / 32] |= (0x1 << (it_id % 32));
    50. // 2. 设置GICD层的中断优先级 GICD_IPRIORITYR24[31:27] = 自己定义 范围0-31
    51. GICD->IPRIORITYR[it_id / 4] &= ~(0x1F << (it_id % 4 * 8 + 3));
    52. GICD->IPRIORITYR[it_id / 4] |= (pri << (it_id % 4 * 8 + 3));
    53. // 3. 设置GICD层中断目标分配 GICD_ITARGETSR24[25:24] = 0x1
    54. GICD->ITARGETSR[it_id / 4] &= ~(0x3 << (it_id % 4 * 8));
    55. GICD->ITARGETSR[it_id / 4] |= (0x3 << (it_id % 4 * 8));
    56. // 4. 设置GICD层全局中断使能 GICD_CTLR[0] = 0x1
    57. GICD->CTRL |= (0x1 << 0);
    58. // 5. 设置GICC层中断优先级屏蔽 GICC_PMR[7:3] = 0x1F 自己也可以给其他值
    59. GICC->PMR |= (0x1F << 3);
    60. // 6. 设置GICC层全局中断使能 GICC_CTLR[0] = 0x1
    61. GICC->CTRL |= (0x1 << 0);
    62. }
    63. void hal_clear_exti_IT(input_event_t input_event, trigger_t trigger)
    64. {
    65. if (trigger != RISING_TRIGGER)
    66. {
    67. EXTI->FPR1 |= (0x1 << input_event);
    68. }
    69. else
    70. {
    71. EXTI->RPR1 |= (0x1 << input_event);
    72. }
    73. }
    74. void hal_clear_gic_IT(unsigned int it_id)
    75. {
    76. GICD->ICPENDR[it_id / 32] |= (0x1 << (it_id % 32));
    77. }

    4.2interrupt.h

    1. #ifndef __INTERRUPT_H__
    2. #define __INTERRUPT_H__
    3. #include "stm32mp1xx_gpio.h"
    4. #include "stm32mp1xx_rcc.h"
    5. #include "stm32mp1xx_exti.h"
    6. #include "stm32mp1xx_gic.h"
    7. #include "gpio.h"
    8. typedef enum
    9. {
    10. INPUT_ENENT_0 = 0,
    11. INPUT_ENENT_1,
    12. INPUT_ENENT_2,
    13. INPUT_ENENT_3,
    14. INPUT_ENENT_4,
    15. INPUT_ENENT_5,
    16. INPUT_ENENT_6,
    17. INPUT_ENENT_7,
    18. INPUT_ENENT_8,
    19. INPUT_ENENT_9,
    20. INPUT_ENENT_10,
    21. INPUT_ENENT_11,
    22. INPUT_ENENT_12,
    23. INPUT_ENENT_13,
    24. INPUT_ENENT_14,
    25. INPUT_ENENT_15,
    26. } input_event_t;
    27. typedef enum
    28. {
    29. RISING_TRIGGER = 0,
    30. FALLING_TRIGGER,
    31. } trigger_t;
    32. typedef enum
    33. {
    34. GPIOA_EXTI = 0,
    35. GPIOB_EXTI,
    36. GPIOC_EXTI,
    37. GPIOD_EXTI,
    38. GPIOE_EXTI,
    39. GPIOF_EXTI,
    40. GPIOG_EXTI,
    41. GPIOH_EXTI,
    42. GPIOI_EXTI,
    43. GPIOJ_EXTI,
    44. } gpio_exti_t;
    45. void hal_gpio_IT_init(gpio_t *gpios, unsigned int pins);
    46. void hal_exti_IT_init(input_event_t input_event,
    47. gpio_exti_t gpio_exti, trigger_t trigger);
    48. void hal_gic_IT_init(unsigned int it_id, unsigned int pri);
    49. void hal_clear_exti_IT(input_event_t input_event, trigger_t trigger);
    50. void hal_clear_gic_IT(unsigned int it_id);
    51. #endif

    4.3gpio.h

    1. #ifndef __GPIO_H__
    2. #define __GPIO_H__
    3. #include "stm32mp1xx_gpio.h"
    4. // 1. 封装RCC_MP_AHB4ENSETR寄存器,封装GPIOE,GPIOF寄存器
    5. #define RCC_MP_AHB4ENSETR (*(volatile unsigned int *)0x50000A28)
    6. // 2. 封装LED灯控制的函数
    7. #define GPIO_PIN_0 0U
    8. #define GPIO_PIN_1 1U
    9. #define GPIO_PIN_2 2U
    10. #define GPIO_PIN_3 3U
    11. #define GPIO_PIN_4 4U
    12. #define GPIO_PIN_5 5U
    13. #define GPIO_PIN_6 6U
    14. #define GPIO_PIN_7 7U
    15. #define GPIO_PIN_8 8U
    16. #define GPIO_PIN_9 9U
    17. #define GPIO_PIN_10 10U
    18. #define GPIO_PIN_11 11U
    19. #define GPIO_PIN_12 12U
    20. #define GPIO_PIN_13 13U
    21. #define GPIO_PIN_14 14U
    22. #define GPIO_PIN_15 15U
    23. typedef enum
    24. {
    25. GPIO_INPUT = 0,
    26. GPIO_OUTPUT,
    27. GPIO_AF,
    28. GPIO_ANALOG,
    29. } gpio_mode_t; // gpio引脚模式的枚举类型
    30. typedef enum
    31. {
    32. GPIO_PP = 0,
    33. GPIO_OD,
    34. } gpio_type_t; // gpio引脚的类型
    35. typedef enum
    36. {
    37. GPIO_LOW_SPEED = 0,
    38. GPIO_MEDIUM_SPEED,
    39. GPIO_HIGH_SPEED,
    40. GPIO_VERY_HIGH_SPEED,
    41. } gpio_speed_t; // gpio引脚的速度
    42. typedef enum
    43. {
    44. GPIO_NO_PUPD = 0,
    45. GPIO_UP,
    46. GPIO_DOWN,
    47. } gpio_pupd_t;
    48. typedef enum
    49. {
    50. GPIO_RESET = 0,
    51. GPIO_SET,
    52. } gpio_statues_t;
    53. typedef struct
    54. {
    55. unsigned int pins; // 哪个引脚
    56. gpio_mode_t mode; // 引脚的模式
    57. gpio_type_t type; // 引脚的类型
    58. gpio_speed_t speed; // 引脚的速度
    59. gpio_pupd_t pupd; // 引脚的上拉和下拉
    60. } gpio_init_t; // gpio引脚初始化的结构体
    61. /*
    62. 功能:GPIO引脚的初始化
    63. 参数:
    64. gpios : 哪个组的gpio引脚
    65. gpio_init : 引脚初始化的结构体
    66. */
    67. void hal_gpio_init(gpio_t *gpios, gpio_init_t *gpio_init);
    68. /*
    69. 功能:写gpio引脚的状态函数
    70. 参数:
    71. gpios : 哪个组的gpio引脚
    72. pins : 哪个引脚
    73. statues : 引脚的状态
    74. */
    75. void hal_gpio_write(gpio_t *gpios, unsigned int pins, gpio_statues_t statues);
    76. /*
    77. 功能:读gpio引脚状态的函数
    78. 参数:
    79. gpios : 哪个组的gpio引脚
    80. pins : 哪个引脚
    81. 返回值:
    82. statues : 引脚的状态
    83. */
    84. gpio_statues_t hal_gpio_read(gpio_t *gpios, unsigned int pins);
    85. void hal_gpio_toggle(gpio_t *gpios, unsigned int pins);
    86. #endif

    4.3stm32mp1xx_gpio.h

    1. #ifndef __STM32MP1xx_GPIO_H__
    2. #define __STM32MP1xx_GPIO_H__
    3. typedef struct {
    4. volatile unsigned int MODER; // 0x00
    5. volatile unsigned int OTYPER; // 0x04
    6. volatile unsigned int OSPEEDR; // 0x08
    7. volatile unsigned int PUPDR; // 0x0C
    8. volatile unsigned int IDR; // 0x10
    9. volatile unsigned int ODR; // 0x14
    10. volatile unsigned int BSRR; // 0x18
    11. volatile unsigned int LCKR; // 0x1C
    12. volatile unsigned int AFRL; // 0x20
    13. volatile unsigned int AFRH; // 0x24
    14. volatile unsigned int BRR; // 0x28
    15. volatile unsigned int res;
    16. volatile unsigned int SECCFGR; // 0x30
    17. }gpio_t;
    18. #define GPIOA ((gpio_t *)0x50002000)
    19. #define GPIOB ((gpio_t *)0x50003000)
    20. #define GPIOC ((gpio_t *)0x50004000)
    21. #define GPIOD ((gpio_t *)0x50005000)
    22. #define GPIOE ((gpio_t *)0x50006000)
    23. #define GPIOF ((gpio_t *)0x50007000)
    24. #define GPIOG ((gpio_t *)0x50008000)
    25. #define GPIOH ((gpio_t *)0x50009000)
    26. #define GPIOI ((gpio_t *)0x5000A000)
    27. #define GPIOJ ((gpio_t *)0x5000B000)
    28. #define GPIOK ((gpio_t *)0x5000C000)
    29. #define GPIOZ ((gpio_t *)0x54004000)
    30. #endif // __STM32MP1xx_GPIO_H__

    4.4stm32mp1xx_rcc.h

    1. #ifndef __STM32MP1XX_RCC_H__
    2. #define __STM32MP1XX_RCC_H__
    3. typedef struct {
    4. volatile unsigned int TZCR; // 0x000
    5. volatile unsigned int res1[2]; // 0x004-0x008
    6. volatile unsigned int OCENSETR; // 0x00C
    7. volatile unsigned int OCENCLRR; // 0x010
    8. volatile unsigned int res2[1]; // 0x014
    9. volatile unsigned int HSICFGR; // 0x018
    10. volatile unsigned int CSICFGR; // 0x01C
    11. volatile unsigned int MPCKSELR; // 0x020
    12. volatile unsigned int ASSCKSELR; // 0x024
    13. volatile unsigned int PCK12SELR; // 0x028
    14. volatile unsigned int MPCKDIVR; // 0x02C
    15. volatile unsigned int AXIDIVR; // 0x030
    16. volatile unsigned int res3[2];
    17. volatile unsigned int APB4DIVR; // 0x03C
    18. volatile unsigned int APB5DIVR; // 0x040
    19. volatile unsigned int RTCDIVR; // 0x044
    20. volatile unsigned int MSSCKSELR; // 0x048
    21. volatile unsigned int res4[13];
    22. volatile unsigned int PLL1CR; // 0x080
    23. volatile unsigned int PLL1CFGR1; // 0x084
    24. volatile unsigned int PLL1CFGR2; // 0x088
    25. volatile unsigned int PLL1FRACR; // 0x08C
    26. volatile unsigned int PLL1CSGR; // 0x090
    27. volatile unsigned int PLL2CR; // 0x094
    28. volatile unsigned int PLL2CFGR1; // 0x098
    29. volatile unsigned int PLL2CFGR2; // 0x09C
    30. volatile unsigned int PLL2FRACR; // 0x0A0
    31. volatile unsigned int PLL2CSGR; // 0x0A4
    32. volatile unsigned int res5[6];
    33. volatile unsigned int I2C46CKSELR; // 0x0C0
    34. volatile unsigned int SPI6CKSELR; // 0x0C4
    35. volatile unsigned int UART1CKSELR; // 0x0C8
    36. volatile unsigned int RNG1CKSELR; // 0x0CC
    37. volatile unsigned int CPERCKSELR; // 0x0D0
    38. volatile unsigned int STGENCKSELR; // 0x0D4
    39. volatile unsigned int DDRITFCR; // 0x0D8
    40. volatile unsigned int res6[9];
    41. volatile unsigned int MP_BOOTCR; // 0x100
    42. volatile unsigned int MP_SREQSETR; // 0x104
    43. volatile unsigned int MP_SREQCLRR; // 0x108
    44. volatile unsigned int MP_GCR; // 0x10C
    45. volatile unsigned int MP_APRSTCR; // 0x110
    46. volatile unsigned int MP_APRSTSR; // 0x114
    47. volatile unsigned int res7[10];
    48. volatile unsigned int BDCR; // 0x140
    49. volatile unsigned int RDLSICR; // 0x144
    50. volatile unsigned int res8[14];
    51. volatile unsigned int APB4RSTSETR; // 0x180
    52. volatile unsigned int APB4RSTCLRR; // 0x184
    53. volatile unsigned int APB5RSTSETR; // 0x188
    54. volatile unsigned int APB5RSTCLRR; // 0x18C
    55. volatile unsigned int AHB5RSTSETR; // 0x190
    56. volatile unsigned int AHB5RSTCLRR; // 0x194
    57. volatile unsigned int AHB6RSTSETR; // 0x198
    58. volatile unsigned int AHB6RSTCLRR; // 0x19C
    59. volatile unsigned int TZAHB6RSTSELR;// 0x1A0
    60. volatile unsigned int TZAHB6RSTCLRR;// 0x1A4
    61. volatile unsigned int res9[22];
    62. volatile unsigned int MP_APB4ENSETR;// 0x200
    63. volatile unsigned int MP_APB4ENCLRR;// 0x204
    64. volatile unsigned int MP_APB5ENSETR;// 0x208
    65. volatile unsigned int MP_APB5ENCLRR;// 0x20C
    66. volatile unsigned int MP_AHB5ENSETR;// 0x210
    67. volatile unsigned int MP_AHB5ENCLRR;// 0x214
    68. volatile unsigned int MP_AHB6ENSETR;// 0x218
    69. volatile unsigned int MP_AHB6ENCLRR;// 0x21C
    70. volatile unsigned int MP_TZAHB6ENSELR;// 0x220
    71. volatile unsigned int MP_TZAHB6ENCLRR;// 0x224
    72. volatile unsigned int res10[22];
    73. volatile unsigned int MC_APB4ENSETR; // 0x280
    74. volatile unsigned int MC_APB4ENCLRR; // 0x284
    75. volatile unsigned int MC_APB5ENSETR; // 0x288
    76. volatile unsigned int MC_APB5ENCLRR; // 0x28C
    77. volatile unsigned int MC_AHB5ENSETR; // 0x290
    78. volatile unsigned int MC_AHB5ENCLRR; // 0x294
    79. volatile unsigned int MC_AHB6ENSETR; // 0x298
    80. volatile unsigned int MC_AHB6ENCLRR; // 0x29C
    81. volatile unsigned int res11[24];
    82. volatile unsigned int MP_APB4LPENSETR; // 0x300
    83. volatile unsigned int MP_APB4LPENCLRR; // 0x304
    84. volatile unsigned int MP_APB5LPENSETR; // 0x308
    85. volatile unsigned int MP_APB5LPENCLRR; // 0x30C
    86. volatile unsigned int MP_AHB5LPENSETR; // 0x310
    87. volatile unsigned int MP_AHB5LPENCLRR; // 0x314
    88. volatile unsigned int MP_AHB6LPENSETR; // 0x318
    89. volatile unsigned int MP_AHB6LPENCLRR; // 0x31C
    90. volatile unsigned int MP_TZAHB6LPENSETR; // 0x320
    91. volatile unsigned int MP_TZAHB6LPENCLRR; // 0x324
    92. volatile unsigned int res12[22];
    93. volatile unsigned int MC_APB4LPENSETR; // 0x380
    94. volatile unsigned int MC_APB4LPENCLRR; // 0x384
    95. volatile unsigned int MC_APB5LPENSETR; // 0x388
    96. volatile unsigned int MC_APB5LPENCLRR; // 0x38C
    97. volatile unsigned int MC_AHB5LPENSETR; // 0x390
    98. volatile unsigned int MC_AHB5LPENCLRR; // 0x394
    99. volatile unsigned int MC_AHB6LPENSETR; // 0x398
    100. volatile unsigned int MC_AHB6LPENCLRR; // 0x39C
    101. volatile unsigned int res13[24];
    102. volatile unsigned int BR_RSTSCLRR; // 0x400
    103. volatile unsigned int MP_GRSTCSETR; // 0x404
    104. volatile unsigned int MP_RSTSR; // 0x408
    105. volatile unsigned int MP_IWDGFZSETR; // 0x40C
    106. volatile unsigned int MP_IWDGFZCLRR; // 0x410
    107. volatile unsigned int MP_CIER; // 0x414
    108. volatile unsigned int MP_CIFR; // 0x418
    109. volatile unsigned int PWRLPDLYCR; // 0x41C
    110. volatile unsigned int MP_RSTSS; // 0x420
    111. volatile unsigned int res14[247];
    112. volatile unsigned int MCO1CFGR; // 0x800
    113. volatile unsigned int MCO2CFGR; // 0x804
    114. volatile unsigned int OCRDYR; // 0x808
    115. volatile unsigned int DBGCFGR; // 0x80C
    116. volatile unsigned int res15[4];
    117. volatile unsigned int RCK3SELR; // 0x820
    118. volatile unsigned int RCK4SELR; // 0x824
    119. volatile unsigned int TIMG1PRER; // 0x828
    120. volatile unsigned int TIMG2PRER; // 0x82C
    121. volatile unsigned int MCUDIVR; // 0x830
    122. volatile unsigned int APB1DIVR; // 0x834
    123. volatile unsigned int APB2DIVR; // 0x838
    124. volatile unsigned int APB3DIVR; // 0x83C
    125. volatile unsigned int res16[16];
    126. volatile unsigned int PLL3CR; // 0x880
    127. volatile unsigned int PLL3CFGR1; // 0x884
    128. volatile unsigned int PLL3CFGR2; // 0x888
    129. volatile unsigned int PLL3FRACR; // 0x88C
    130. volatile unsigned int PLL3CSGR; // 0x890
    131. volatile unsigned int PLL4CR; // 0x894
    132. volatile unsigned int PLL4CFGR1; // 0x898
    133. volatile unsigned int PLL4CFGR2; // 0x89C
    134. volatile unsigned int PLL4FRACR; // 0x8A0
    135. volatile unsigned int PLL4CSGR; // 0x8A4
    136. volatile unsigned int res17[6];
    137. volatile unsigned int I2C12CKSELR; // 0x8C0
    138. volatile unsigned int I2C35CKSELR; // 0x8C4
    139. volatile unsigned int SAI1CKSELR; // 0x8C8
    140. volatile unsigned int SAI2CKSELR; // 0x8CC
    141. volatile unsigned int SAI3CKSELR; // 0x8D0
    142. volatile unsigned int SAI4CKSELR; // 0x8D4
    143. volatile unsigned int SPI2S1CKSELR; // 0x8D8
    144. volatile unsigned int SPI2S23CKSELR; // 0x8DC
    145. volatile unsigned int SPI45CKSELR; // 0x8E0
    146. volatile unsigned int UART6CKSELR; // 0x8E4
    147. volatile unsigned int UART24CKSELR; // 0x8E8
    148. volatile unsigned int UART35CKSELR; // 0x8EC
    149. volatile unsigned int UART78CKSELR; // 0x8F0
    150. volatile unsigned int SDMMC12CKSELR; // 0x8F4
    151. volatile unsigned int SDMMC3CKSELR; // 0x8F8
    152. volatile unsigned int ETHCKSELR; // 0x8FC
    153. volatile unsigned int QSPICKSELR; // 0x900
    154. volatile unsigned int FMCCKSELR; // 0x904
    155. volatile unsigned int res18[1];
    156. volatile unsigned int FDCANCKSELR; // 0x90C
    157. volatile unsigned int res19[1];
    158. volatile unsigned int SPDIFCKSELR; // 0x914
    159. volatile unsigned int CECCKSELR; // 0x918
    160. volatile unsigned int USBCKSELR; // 0x91C
    161. volatile unsigned int RNG2CKSELR; // 0x920
    162. volatile unsigned int DSICKSELR; // 0x924
    163. volatile unsigned int ADCCKSELR; // 0x928
    164. volatile unsigned int LPTIM45CKSELR; // 0x92C
    165. volatile unsigned int LPTIM23CKSELR; // 0x930
    166. volatile unsigned int LPTIM1CKSELR; // 0x934
    167. volatile unsigned int res20[18];
    168. volatile unsigned int APB1RSTSETR; // 0x980
    169. volatile unsigned int APB1RSTCLRR; // 0x984
    170. volatile unsigned int APB2RSTSETR; // 0x988
    171. volatile unsigned int APB2RSTCLRR; // 0x98C
    172. volatile unsigned int APB3RSTSETR; // 0x990
    173. volatile unsigned int APB3RSTCLRR; // 0x994
    174. volatile unsigned int AHB2RSTSETR; // 0x998
    175. volatile unsigned int AHB2RSTCLRR; // 0x99C
    176. volatile unsigned int AHB3RSTSETR; // 0x9A0
    177. volatile unsigned int AHB3RSTCLRR; // 0x9A4
    178. volatile unsigned int AHB4RSTSETR; // 0x9A8
    179. volatile unsigned int AHB4RSTCLRR; // 0x9AC
    180. volatile unsigned int res21[20];
    181. volatile unsigned int MP_APB1ENSETR; // 0xA00
    182. volatile unsigned int MP_APB1ENCLRR; // 0xA04
    183. volatile unsigned int MP_APB2ENSETR; // 0xA08
    184. volatile unsigned int MP_APB2ENCLRR; // 0xA0C
    185. volatile unsigned int MP_APB3ENSETR; // 0xA10
    186. volatile unsigned int MP_APB3ENCLRR; // 0xA14
    187. volatile unsigned int MP_AHB2ENSETR; // 0xA18
    188. volatile unsigned int MP_AHB2ENCLRR; // 0xA1C
    189. volatile unsigned int MP_AHB3ENSETR; // 0xA20
    190. volatile unsigned int MP_AHB3ENCLRR; // 0xA24
    191. volatile unsigned int MP_AHB4ENSETR; // 0xA28
    192. volatile unsigned int MP_AHB4ENCLRR; // 0xA2C
    193. volatile unsigned int res22[2];
    194. volatile unsigned int MP_MLAHBENSETR; // 0xA38
    195. volatile unsigned int MP_MLAHBENCLRR; // 0xA3C
    196. volatile unsigned int res23[16];
    197. volatile unsigned int MC_APB1ENSETR; // 0xA80
    198. volatile unsigned int MC_APB1ENCLRR; // 0xA84
    199. volatile unsigned int MC_APB2ENSETR; // 0xA88
    200. volatile unsigned int MC_APB2ENCLRR; // 0xA8C
    201. volatile unsigned int MC_APB3ENSETR; // 0xA90
    202. volatile unsigned int MC_APB3ENCLRR; // 0xA94
    203. volatile unsigned int MC_AHB2ENSETR; // 0xA98
    204. volatile unsigned int MC_AHB2ENCLRR; // 0xA9C
    205. volatile unsigned int MC_AHB3ENSETR; // 0xAA0
    206. volatile unsigned int MC_AHB3ENCLRR; // 0xAA4
    207. volatile unsigned int MC_AHB4ENSETR; // 0xAA8
    208. volatile unsigned int MC_AHB4ENCLRR; // 0xAAC
    209. volatile unsigned int MC_AXIMENSETR; // 0xAB0
    210. volatile unsigned int MC_AXIMENCLRR; // 0xAB4
    211. volatile unsigned int MC_MLAHBENSETR; // 0xAB8
    212. volatile unsigned int MC_MLAHBENCLRR; // 0xABC
    213. volatile unsigned int res24[16];
    214. volatile unsigned int MP_APB1LPENSETR; // 0xB00
    215. volatile unsigned int MP_APB1LPENCLRR; // 0xB04
    216. volatile unsigned int MP_APB2LPENSETR; // 0xB08
    217. volatile unsigned int MP_APB2LPENCLRR; // 0xB0C
    218. volatile unsigned int MP_APB3LPENSETR; // 0xB10
    219. volatile unsigned int MP_APB3LPENCLRR; // 0xB14
    220. volatile unsigned int MP_AHB2LPENSETR; // 0xB18
    221. volatile unsigned int MP_AHB2LPENCLRR; // 0xB1C
    222. volatile unsigned int MP_AHB3LPENSETR; // 0xB20
    223. volatile unsigned int MP_AHB3LPENCLRR; // 0xB24
    224. volatile unsigned int MP_AHB4LPENSETR; // 0xB28
    225. volatile unsigned int MP_AHB4LPENCLRR; // 0xB2C
    226. volatile unsigned int MP_AXIMLPENSETR; // 0xB30
    227. volatile unsigned int MP_AXIMLPENCLRR; // 0xB34
    228. volatile unsigned int MP_MLAHBLPENSETR; // 0xB38
    229. volatile unsigned int MP_MLAHBLPENCLRR; // 0xB3C
    230. volatile unsigned int res25[16];
    231. volatile unsigned int MC_APB1LPENSETR; // 0xB80
    232. volatile unsigned int MC_APB1LPENCLRR; // 0xB84
    233. volatile unsigned int MC_APB2LPENSETR; // 0xB88
    234. volatile unsigned int MC_APB2LPENCLRR; // 0xB8C
    235. volatile unsigned int MC_APB3LPENSETR; // 0xB90
    236. volatile unsigned int MC_APB3LPENCLRR; // 0xB94
    237. volatile unsigned int MC_AHB2LPENSETR; // 0xB98
    238. volatile unsigned int MC_AHB2LPENCLRR; // 0xB9C
    239. volatile unsigned int MC_AHB3LPENSETR; // 0xBA0
    240. volatile unsigned int MC_AHB3LPENCLRR; // 0xBA4
    241. volatile unsigned int MC_AHB4LPENSETR; // 0xBA8
    242. volatile unsigned int MC_AHB4LPENCLRR; // 0xBAC
    243. volatile unsigned int MC_AXIMLPENSETR; // 0xBB0
    244. volatile unsigned int MC_AXIMLPENCLRR; // 0xBB4
    245. volatile unsigned int MC_MLAHBLPENSETR; // 0xBB8
    246. volatile unsigned int MC_MLAHBLPENCLRR; // 0xBBC
    247. volatile unsigned int res26[16];
    248. volatile unsigned int MC_RSTSCLRR; // 0xC00
    249. volatile unsigned int res27[4];
    250. volatile unsigned int MC_CIER; // 0xC14
    251. volatile unsigned int MC_CIFR; // 0xC18
    252. volatile unsigned int res28[246];
    253. volatile unsigned int VERR; // 0xFF4
    254. volatile unsigned int IDR; // 0xFF8
    255. volatile unsigned int SIDR; // 0xFFC
    256. }rcc_t;
    257. #define RCC ((rcc_t *)0x50000000)
    258. #endif // __STM32MP1XX_RCC_H__

    4.5stm32mp1xx_exti.h

    1. #ifndef __STM32MP1XX_EXTI_H__
    2. #define __STM32MP1XX_EXTI_H__
    3. typedef struct{
    4. volatile unsigned int RTSR1; // EXTI rising trigger selection register
    5. volatile unsigned int FTSR1; // EXTI falling trigger selection register
    6. volatile unsigned int SWIER1; // EXTI software interrupt event register
    7. volatile unsigned int RPR1; // EXTI rising edge pending register
    8. volatile unsigned int FPR1; // EXTI falling edge pending register
    9. volatile unsigned int TZENR1; // EXTI TrustZone enable register
    10. volatile unsigned int RES1[2];
    11. volatile unsigned int RTSR2; // EXTI rising trigger selection register
    12. volatile unsigned int FTSR2; // EXTI falling trigger selection register
    13. volatile unsigned int SWIER2; // EXTI software interrupt event register
    14. volatile unsigned int RPR2; // EXTI rising edge pending register
    15. volatile unsigned int FPR2; // EXTI falling edge pending register
    16. volatile unsigned int TZENR2; // EXTI TrustZone enable register
    17. volatile unsigned int RES2[2];
    18. volatile unsigned int RTSR3; // EXTI rising trigger selection register
    19. volatile unsigned int FTSR3; // EXTI falling trigger selection register
    20. volatile unsigned int SWIER3; // EXTI software interrupt event register
    21. volatile unsigned int RPR3; // EXTI rising edge pending register
    22. volatile unsigned int FPR3; // EXTI falling edge pending register
    23. volatile unsigned int TZENR3; // EXTI TrustZone enable register
    24. volatile unsigned int RES3[2];
    25. volatile unsigned int EXTICR1; // EXTI external interrupt selection register 1
    26. volatile unsigned int EXTICR2; // EXTI external interrupt selection register 2
    27. volatile unsigned int EXTICR3; // EXTI external interrupt selection register 3
    28. volatile unsigned int EXTICR4; // EXTI external interrupt selection register 4
    29. volatile unsigned int RES4[4];
    30. volatile unsigned int C1IMR1; // EXTI CPU1 wakeup with interrupt mask register
    31. volatile unsigned int C1EMR1; // EXTI CPU1 wakeup with event mask register
    32. volatile unsigned int RES5[2];
    33. volatile unsigned int C1IMR2; // EXTI CPU1 wakeup with interrupt mask register
    34. volatile unsigned int C1EMR2; // EXTI CPU1 wakeup with event mask register
    35. volatile unsigned int RES6[2];
    36. volatile unsigned int C1IMR3; // EXTI CPU1 wakeup with interrupt mask register
    37. volatile unsigned int C1EMR3; // EXTI CPU1 wakeup with event mask register
    38. volatile unsigned int RES7[6];
    39. volatile unsigned int C2IMR1; // EXTI CPU2 wakeup with interrupt mask register
    40. volatile unsigned int C2EMR1; // EXTI CPU2 wakeup with event mask register
    41. volatile unsigned int RES8[2];
    42. volatile unsigned int C2IMR2; // EXTI CPU2 wakeup with interrupt mask register
    43. volatile unsigned int C2EMR2; // EXTI CPU2 wakeup with event mask register
    44. volatile unsigned int RES9[2];
    45. volatile unsigned int C2IMR3; // EXTI CPU2 wakeup with interrupt mask register
    46. volatile unsigned int C2EMR3; // EXTI CPU2 wakeup with event mask register
    47. volatile unsigned int RES10[2];
    48. }exti_t;
    49. #define EXTI ((exti_t*)0x5000D000)
    50. #endif //__STM32MP1XX_EXTI_H__

    4.6stm32mp1xx_gic.h

    1. #ifndef __STM32MP1XX_GIC_H__
    2. #define __STM32MP1XX_GIC_H__
    3. typedef struct {
    4. volatile unsigned int CTRL;
    5. volatile unsigned int TYPER;
    6. volatile unsigned int IIDR;
    7. volatile unsigned int RES1[29];
    8. volatile unsigned int IGROUPR[9];
    9. volatile unsigned int RES2[23];
    10. volatile unsigned int ISENABLER[9];
    11. volatile unsigned int RES3[23];
    12. volatile unsigned int ICENABLER[9];
    13. volatile unsigned int RES4[23];
    14. volatile unsigned int ISPENDR[9];
    15. volatile unsigned int RES5[23];
    16. volatile unsigned int ICPENDR[9];
    17. volatile unsigned int RES6[23];
    18. volatile unsigned int ISACTIVER[9];
    19. volatile unsigned int RES7[23];
    20. volatile unsigned int ICACTIVER[9];
    21. volatile unsigned int RES8[23];
    22. volatile unsigned int IPRIORITYR[72];
    23. volatile unsigned int RES9[184];
    24. volatile unsigned int ITARGETSR[72];
    25. volatile unsigned int RES10[184];
    26. volatile unsigned int ICFGR[18];
    27. volatile unsigned int RES11[46];
    28. }gicd_t;
    29. #define GICD ((gicd_t*)0xA0021000)
    30. typedef struct {
    31. volatile unsigned int CTRL;
    32. volatile unsigned int PMR;
    33. volatile unsigned int BRR;
    34. volatile unsigned int IAR;
    35. volatile unsigned int EOIR;
    36. volatile unsigned int RPR;
    37. volatile unsigned int HPPIR;
    38. volatile unsigned int ABPR;
    39. volatile unsigned int AIAR;
    40. volatile unsigned int AEOIR;
    41. volatile unsigned int AHPPIR;
    42. volatile unsigned int RES1[41];
    43. volatile unsigned int APR0;
    44. volatile unsigned int RES2[3];
    45. volatile unsigned int NSAPR0;
    46. volatile unsigned int RES3[6];
    47. volatile unsigned int IIDR;
    48. volatile unsigned int RES4[960];
    49. volatile unsigned int DIRDIR;
    50. }gicc_t;
    51. #define GICC ((gicc_t*)0xA0022000)
    52. #endif // __STM32MP1XX_GIC_H__

  • 相关阅读:
    SQL注入 Less24(二次注入)
    理解JavaScript事件循环机制
    2022-07-29 java之异常
    云上本地化运营,东非第一大电商平台Kilimall的出海经
    CorelDRAW 2023全新版矢量图形制作工具
    dreamweaver动漫HTML网站制作——海贼王主题网页1页海贼王我当定了(HTML+CSS)
    【分布式存储】聊一下分布式存储中分片机制
    从输入URL到页面展示这中间发生了什么?
    同相放大电路电阻热噪声分析的一些思考
    Linux SSH连接远程服务器(免密登录、scp和sftp传输文件)
  • 原文地址:https://blog.csdn.net/a2998658795/article/details/126688096