锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

英飞凌 AURIX 系列单片机的HSM详解(4)——Tricore核与HSM核之间的通信方法

时间:2023-07-01 20:37:00 hsm数显温度变送器

本系列的其他文章:

英飞凌 AURIX 系列单片机的HSM详解(1)-什么是HSM》

《英飞凌 AURIX 单片机系列HSM详解(2)-和HSM相关的UCB和寄存器》
《英飞凌 AURIX 单片机系列HSM详细说明(3)-开发方法
《英飞凌 AURIX 单片机系列HSM详解(4)——Tricore核与HSM核之间的通信方法
《英飞凌 AURIX 单片机系列HSM详解(5)——HSM硬件加速模块的使用》

因为HSM有一个单独的ARM核,在实际使用过程中HSM核与主CPU Tricore核之间需要通信。本文介绍了两者之间的通信方法。

1. 中断


HSM核可以向主核发送中断,支持两个中断。Tricore核中断控制寄存器地址分别为:0xF0038870u 、0xF0038874u,在iLLD定义如下:

/** \brief  870, HSM Service Request */ #define SRC_HSM_HSM0_HSM0 /*lint --e(923)*/ (*(volatile Ifx_SRC_SRCR*)0xF0038870u)  /** Alias (User Manual Name) for SRC_HSM_HSM0_HSM0. * To use register names with standard convension, please use SRC_HSM_HSM0_HSM0. */ #define SRC_HSM0 (SRC_HSM_HSM0_HSM0)  /** \brief  874, HSM Service Request */ #define SRC_HSM_HSM0_HSM1 /*lint --e(923)*/ (*(volatile Ifx_SRC_SRCR*)0xF0038874u)  /** Alias (User Manual Name) for SRC_HSM_HSM0_HSM1. * To use register names with standard convension, please use SRC_HSM_HSM0_HSM1. */ #define SRC_HSM1 (SRC_HSM_HSM0_HSM1) 


初始化中断后,HSM核可以该软件触发中断,使主Tricore核进入中断执行程序。

主要初始化中断示例代码:

void init_interrupts(void) {  SRC_HSM0.U = (0 << 11) | (1 << 10) | 1;  /* 0<11 => ON CPU0, 1<<10 => Enable*/  interruptHandlerInstall(1, (uint32) &Bridge2Host_IRQHandler); } sint32 Bridge2Host_IRQHandler(void) {  /***中断处理函数***/ } 


2. 共享内存


TC3XX系列MCU有一块RAM在主核和HSM核之间互相传递数据,被称为主核与HSM核之间的桥梁(Bridge):

在这里插入图片描述

其定义如下:

/*------------- BRIDGE Module   ----------------------------------------------*/ typedef struct {        uint32_t RESERVED0[2]             ;   __IO uint32_t HSM_ID                   ; // Module Identifier Register        uint32_t RESERVED1[5]             ;   __IO uint32_t HT2HSMF                  ; // Host to HSM Flag Register   __IO uint32_t HT2HSMIE                 ; // Host to HSM Interrupt Enable   __IO uint32_t HSM2HTF                  ; // HSM to Host Flag Register   __IO uint32_t HSM2HTIE                 ; // HSM to Host Interrupt Enable   __IO uint32_t HSM2HTIS                 ; // HSM to Host Interrupt Select   __IO uint32_t HSM2HTS                  ; // HSM to Host Status   __IO uint32_t HT2HSMS                  ; // Host to HSM Status        uint32_t RESERVED2                ;   __IO uint32_t CLKCTRL                  ; // Clock Control Register        uint32_t RESERVED3[7]             ;   __IO uint32_t DBGCTRL                  ; // Debug Control Register   __IO uint32_t PINCTRL                  ; // Pin Control Register        uint32_t RESERVED4[6]             ;   __IO uint32_t ERRCTRL                  ; // Error Control Register   __IO uint32_t ERRIE                    ; // Error Interrupt Enable Register   __IO uint32_t ERRADDR                  ; // Error Address Register        uint32_t RESERVED5[5]             ;   __IO uint32_t EXTIF                    ; // External Interrupt Flag Register   __IO uint32_t EXTIE                    ; // External Interrupt Enable        uint32_t RESERVED6[6]             ;   __IO uint32_t SAHBASE                  ; // Single Access to Host Base Address Register        uint32_t RESERVED7[7]             ;   __IO uint32_t RSTCTRL                  ; // Reset Control Register   __IO uint32_t RSTPWD                   ; // Reset Password Register        uint32_t RESERVED8[2]             ;   __IO uint32_t SENSIF                   ; // Sensor Interrupt Flag Register   __IO uint32_t SENSIE                   ; // Sensor Interrupt Enable Register   __IO uint32_t SENSAPPRST               ; // Sensor Application Reset Enable Register   __IO uint32_t SENSSYSRST               ; // Sensor System Reset Enable Register        uint32_t RESERVED9[16320]         ;   __IO uint32_t SAHMEM[16384]            ; // Single Access to Host Memory Window } HSM_BRIDGE_TypeDef; 


我们可以看到0xF0040000-0xF004FFFF该地址空间中的一些地址被定义为寄存器,可用于HSM核与主核之间的相互控制、触发中断、获取状态等定义HSM用户手册。

0xF0050000-0xF005FFFF这个地址空间没有具体的定义,但也是HSM可访问核和主核的区域。在使用时,我们可以在这个空间中定义一些大数据块,例如存储待加解密的数据buffer和解密后的数据buffer,定义好之后就可以了buffer入口地址通过上述寄存器(HSM2HTS & HT2HSMS)在HSM核与主核之间的传输可以实现大量数据的传输,传输过程中不需要数据copy。

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章