• Zynq中断与AMP~双核串口环回之PS与PL通信


    实现思路:

    1.通过PL实现定时器每隔特定的时间为CPU0和CPU1发送硬中断;

    2.注册Uart中断,使用超时中断事件,当发送指定命令的时候,CPU0会因为Uart中断停止硬中断,将发送的命令中指定的数据写入到缓存区A中,并且向CPU1发送软中断;

    3.CPU1收到来自CPU0的软中断,停止指向自身的硬中断,检查缓存区A中的指定数据,如果符合约定的命令,将缓存区A中的数据写入缓存区B,且向CPU0发送软中断;

    4.CPU0收到来自CPU1的软中断,将缓存区B的数据读出并且通过Uart完成发送;

    细节:

    这里的缓存区RAM可以通过创建IP直接创建,也可以通过IP核:

            Block Memory Generator

            进行创建,因为是GP口,地址和数据默认为 32 位。

    此外:对于AXI LITE缓存区主要是通过Xil提供的驱动实现的,但也可以输出给PL;

    实验现象:

    部分代码:

    其中读写Bram的代码可参考:

    Axi_Lite接口的IP核与地址与缓冲与AxiGP0-CSDN博客

    CPU0中配置的Uart中断回调函数

            设置的是超时中断触发,set阈值那个不太好用。

            检测收到的Uart数据,符合标准则发送软中断给CPU1,并且禁用硬中断;

    1. void Uart0_IntrHandler(void *CallBackRef, u32 Event, unsigned int EventData)
    2. {
    3. if (Event == XUARTPS_EVENT_RECV_TOUT) {
    4. TotalReceivedCount = EventData;
    5. if (TotalReceivedCount == 8
    6. && RecvBuffer[0] == 0x55 && RecvBuffer[1] == 0x55
    7. && RecvBuffer[2] == 0x00 && RecvBuffer[3] == 0x01)
    8. {
    9. XScuGic_Disable(&GIC_SGI_instance_point, Interrupt_ID_Hardware_1);
    10. XScuGic_Disable(&GIC_SGI_instance_point, Interrupt_ID_Hardware_0);
    11. Axi_WriteRamA(RecvBuffer,TotalReceivedCount);
    12. printf("Close SPI\n\r");
    13. XScuGic_SoftwareIntr(&GIC_SGI_instance_point,
    14. Interrupt_ID_SGI_15,
    15. XSCUGIC_SPI_CPU1_MASK);
    16. }
    17. else if(TotalReceivedCount == 8 && RecvBuffer[0] == 0x66)
    18. {
    19. XScuGic_Enable(&GIC_SGI_instance_point, Interrupt_ID_Hardware_0);
    20. printf("Open SPI\n\r");
    21. }
    22. }
    23. XUartPs_Recv(&Uart_Instance_point, RecvBuffer, TEST_BUFFER_SIZE);
    24. }

    CPU1的软中断回调函数

    检查缓存区A中的数据是否符合要求,如果符合要求则写入缓存区B,

    同时向CPU0发送软中断;

    1. void SGI_IntrHandler(void *CallBackRef){
    2. u32 origin_command;
    3. print("SG1!\n\r");
    4. Axi_ReadRamA(COMMAND_BUFFER,8);
    5. if(COMMAND_BUFFER[4]==0x04 && COMMAND_BUFFER[5] == 0x05
    6. && COMMAND_BUFFER[6]==0x06 && COMMAND_BUFFER[7] == 0x07)
    7. {
    8. Axi_WriteRamB(COMMAND_BUFFER,8);
    9. XScuGic_SoftwareIntr(&GIC_SGI_instance_point, Interrupt_ID_SGI_14, CPU_id_0);
    10. }
    11. }

    CPU0的软中断回调函数

    将缓存区B中的数据用Uart发送;

    1. void SGI_IntrHandler(void *CallBackRef){
    2. Axi_ReadRamB(SendBuffer,8);
    3. XUartPs_Send(&Uart_Instance_point, SendBuffer, 8);
    4. print("SG0!\n\r");
    5. }

    整体代码:

    1. /******************************************************************************
    2. *
    3. * Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
    4. *
    5. * Permission is hereby granted, free of charge, to any person obtaining a copy
    6. * of this software and associated documentation files (the "Software"), to deal
    7. * in the Software without restriction, including without limitation the rights
    8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    9. * copies of the Software, and to permit persons to whom the Software is
    10. * furnished to do so, subject to the following conditions:
    11. *
    12. * The above copyright notice and this permission notice shall be included in
    13. * all copies or substantial portions of the Software.
    14. *
    15. * Use of the Software is limited solely to applications:
    16. * (a) running on a Xilinx device, or
    17. * (b) that interact with a Xilinx device through a bus or interconnect.
    18. *
    19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    22. * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    23. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
    24. * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    25. * SOFTWARE.
    26. *
    27. * Except as contained in this notice, the name of the Xilinx shall not be used
    28. * in advertising or otherwise to promote the sale, use or other dealings in
    29. * this Software without prior written authorization from Xilinx.
    30. *
    31. ******************************************************************************/
    32. /*
    33. * helloworld.c: simple test application
    34. *
    35. * This application configures UART 16550 to baud rate 9600.
    36. * PS7 UART (Zynq) is not initialized by this application, since
    37. * bootrom/bsp configures it to baud rate 115200
    38. *
    39. * ------------------------------------------------
    40. * | UART TYPE BAUD RATE |
    41. * ------------------------------------------------
    42. * uartns550 9600
    43. * uartlite Configurable only in HW design
    44. * ps7_uart 115200 (configured by bootrom/bsp)
    45. */
    46. #include
    47. #include "platform.h"
    48. #include "xil_printf.h"
    49. #include "xil_mmu.h"
    50. #include "xscugic.h"
    51. #include "xuartps.h"
    52. #include "xparameters.h"
    53. #include "xil_exception.h"
    54. #include "Axi_REG_List.h"
    55. #define COMM_VAL (*(volatile unsigned long *)(0xFFFF0000))
    56. #define APP_CPU1_ADDR 0x02000000
    57. #define OCM_ADDR 0xFFFF0000
    58. #define Interrupt_ID_SGI_14 0x0D
    59. #define Interrupt_ID_SGI_15 0x0E
    60. #define Interrupt_ID_Hardware_0 61
    61. #define Interrupt_ID_Hardware_1 62
    62. #define DistBaseAddress XPAR_PS7_SCUGIC_0_DIST_BASEADDR
    63. //AXI BaseAddr
    64. #define Axi_RamA_BaseAddr 0x43C00000
    65. #define Axi_RamB_BaseAddr 0x43C10000
    66. //GIC
    67. #define XIL_EXCEPTION_ID_INT XIL_EXCEPTION_ID_IRQ_INT
    68. #define GIC_DECIVE_ID_INT XPAR_SCUGIC_0_DEVICE_ID
    69. //CPU_ID
    70. #define CPU_id_0 XSCUGIC_SPI_CPU0_MASK
    71. #define CPU_id_1 XSCUGIC_SPI_CPU1_MASK
    72. //Uart
    73. #define Interrupt_ID_Uart_0 XPS_UART0_INT_ID
    74. #define Uart_Decive_ID XPAR_PS7_UART_0_DEVICE_ID
    75. static XUartPs_Config *Uart_ConFig;
    76. static XUartPs Uart_Instance_point;
    77. #define TEST_BUFFER_SIZE 32
    78. u8 SendBuffer[TEST_BUFFER_SIZE]; /* Buffer for Transmitting Data */
    79. u8 RecvBuffer[TEST_BUFFER_SIZE]; /* Buffer for Receiving Data */
    80. volatile int TotalReceivedCount;
    81. //SGI
    82. static XScuGic_Config *GIC_SGI_ConFig;
    83. static XScuGic GIC_SGI_instance_point;
    84. int Uart_init();
    85. int GIC_SGI_init();
    86. void Uart_SetHandler_Event();
    87. void SGI_IntrHandler(void *CallBackRef);
    88. void Hardware_IntrHandler(void *CallBackRef);
    89. void Uart0_IntrHandler(void *CallBackRef, u32 Event, unsigned int EventData);
    90. void Axi_WriteRamA(u8 *Data_addr_point, u32 Write_ByteLong);
    91. void Axi_ReadRamB (u8 *Data_addr_point, u32 Read_ByteLong );
    92. int main()
    93. {
    94. int Status;
    95. COMM_VAL = 0;
    96. Status = Uart_init();
    97. if (Status != XST_SUCCESS) {
    98. return XST_FAILURE;
    99. }
    100. Status = GIC_SGI_init();
    101. if (Status != XST_SUCCESS) {
    102. return XST_FAILURE;
    103. }
    104. Xil_SetTlbAttributes(0xFFFF0000,0x14de2);
    105. Uart_SetHandler_Event();
    106. while(1){
    107. print("CPU0: Hello World CPU 0\n\r");
    108. COMM_VAL = 1;
    109. while(COMM_VAL == 1){
    110. }
    111. }
    112. return 0;
    113. }
    114. int GIC_SGI_init(){
    115. int Status;
    116. Xil_ExceptionInit();
    117. GIC_SGI_ConFig = XScuGic_LookupConfig(GIC_DECIVE_ID_INT);
    118. if (NULL == GIC_SGI_ConFig) {
    119. return XST_FAILURE;
    120. }
    121. Status = XScuGic_CfgInitialize(&GIC_SGI_instance_point,
    122. GIC_SGI_ConFig,
    123. GIC_SGI_ConFig->CpuBaseAddress);
    124. if (Status != XST_SUCCESS) {
    125. return XST_FAILURE;
    126. }
    127. Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
    128. (Xil_ExceptionHandler) XScuGic_InterruptHandler,
    129. &GIC_SGI_instance_point);
    130. //---------------------------------------------------------------//
    131. //SGI
    132. Status = XScuGic_Connect(&GIC_SGI_instance_point,
    133. Interrupt_ID_SGI_14,
    134. (Xil_InterruptHandler )SGI_IntrHandler,
    135. (void *)&GIC_SGI_instance_point
    136. );
    137. if (Status != XST_SUCCESS) {
    138. return XST_FAILURE;
    139. }
    140. XScuGic_Enable(&GIC_SGI_instance_point,
    141. Interrupt_ID_SGI_14);
    142. //SPI hardware----------------------------------------------------//
    143. Status = XScuGic_Connect(&GIC_SGI_instance_point,
    144. Interrupt_ID_Hardware_0,
    145. (Xil_InterruptHandler )Hardware_IntrHandler,
    146. (void *)&GIC_SGI_instance_point
    147. );
    148. if (Status != XST_SUCCESS) {
    149. return XST_FAILURE;
    150. }
    151. XScuGic_SetPriTrigTypeByDistAddr(DistBaseAddress,
    152. Interrupt_ID_Hardware_0,
    153. 0x20,
    154. 0x03);
    155. XScuGic_InterruptMaptoCpu(&GIC_SGI_instance_point,
    156. CPU_id_0,
    157. Interrupt_ID_Hardware_0);
    158. XScuGic_Enable(&GIC_SGI_instance_point,
    159. Interrupt_ID_Hardware_0);
    160. //Uart interrupt--------------------------------------------------//
    161. Status = XScuGic_Connect(&GIC_SGI_instance_point,
    162. Interrupt_ID_Uart_0,
    163. (Xil_InterruptHandler )XUartPs_InterruptHandler,
    164. (void *)&Uart_Instance_point
    165. );
    166. if (Status != XST_SUCCESS) {
    167. return XST_FAILURE;
    168. }
    169. XScuGic_Enable(&GIC_SGI_instance_point, Interrupt_ID_Uart_0);
    170. //---------------------------------------------------------------//
    171. Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
    172. return XST_SUCCESS;
    173. }
    174. int Uart_init(){
    175. s32 Status = XST_SUCCESS;
    176. Uart_ConFig = XUartPs_LookupConfig(Uart_Decive_ID);
    177. if (NULL == Uart_ConFig) {
    178. return XST_FAILURE;
    179. }
    180. Status = XUartPs_CfgInitialize(&Uart_Instance_point,
    181. Uart_ConFig,
    182. Uart_ConFig->BaseAddress);
    183. if (Status != XST_SUCCESS) {
    184. return XST_FAILURE;
    185. }
    186. Status = XUartPs_SelfTest(&Uart_Instance_point);
    187. if (Status != XST_SUCCESS) {
    188. return XST_FAILURE;
    189. }
    190. Status = XUartPs_SetBaudRate(&Uart_Instance_point,115200);
    191. if (Status != XST_SUCCESS) {
    192. return XST_FAILURE;
    193. }
    194. return Status;
    195. }
    196. void Uart_SetHandler_Event(){
    197. u32 IntrMask = 0;
    198. int Index;
    199. XUartPs_SetHandler(&Uart_Instance_point,
    200. (XUartPs_Handler) Uart0_IntrHandler,
    201. &Uart_Instance_point);
    202. IntrMask = XUARTPS_IXR_TOUT|XUARTPS_IXR_RXOVR;
    203. XUartPs_SetInterruptMask(&Uart_Instance_point, IntrMask);
    204. XUartPs_SetOperMode(&Uart_Instance_point,XUARTPS_OPER_MODE_NORMAL);
    205. XUartPs_SetRecvTimeout(&Uart_Instance_point,8);
    206. // XUartPs_SetFifoThreshold(&Uart_Instance_point,8);
    207. // Clear Buffer
    208. for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
    209. SendBuffer[Index] = 0;
    210. RecvBuffer[Index] = 0;
    211. }
    212. XUartPs_Recv(&Uart_Instance_point, RecvBuffer, TEST_BUFFER_SIZE);
    213. // XUartPs_Send(&Uart_Instance_point, SendBuffer, TEST_BUFFER_SIZE);
    214. }
    215. void SGI_IntrHandler(void *CallBackRef){
    216. Axi_ReadRamB(SendBuffer,8);
    217. XUartPs_Send(&Uart_Instance_point, SendBuffer, 8);
    218. print("SG0!\n\r");
    219. }
    220. void Hardware_IntrHandler(void *CallBackRef){
    221. // print("Hardware:CLOCK Interrupt CPU0!\n\r");
    222. print("H0!\n\r");
    223. }
    224. /**************************************************************************/
    225. /**
    226. *
    227. * This function is the handler which performs processing to handle data events
    228. * from the device. It is called from an interrupt context. so the amount of
    229. * processing should be minimal.
    230. *
    231. * This handler provides an example of how to handle data for the device and
    232. * is application specific.
    233. *
    234. * @param CallBackRef contains a callback reference from the driver,
    235. * in this case it is the instance pointer for the XUartPs driver.
    236. * @param Event contains the specific kind of event that has occurred.
    237. * @param EventData contains the number of bytes sent or received for sent
    238. * and receive events.
    239. *
    240. * @return None.
    241. *
    242. * @note None.
    243. *
    244. ***************************************************************************/
    245. void Uart0_IntrHandler(void *CallBackRef, u32 Event, unsigned int EventData)
    246. {
    247. if (Event == XUARTPS_EVENT_RECV_TOUT) {
    248. TotalReceivedCount = EventData;
    249. if (TotalReceivedCount == 8
    250. && RecvBuffer[0] == 0x55 && RecvBuffer[1] == 0x55
    251. && RecvBuffer[2] == 0x00 && RecvBuffer[3] == 0x01)
    252. {
    253. XScuGic_Disable(&GIC_SGI_instance_point, Interrupt_ID_Hardware_1);
    254. XScuGic_Disable(&GIC_SGI_instance_point, Interrupt_ID_Hardware_0);
    255. Axi_WriteRamA(RecvBuffer,TotalReceivedCount);
    256. printf("Close SPI\n\r");
    257. XScuGic_SoftwareIntr(&GIC_SGI_instance_point,
    258. Interrupt_ID_SGI_15,
    259. XSCUGIC_SPI_CPU1_MASK);
    260. }
    261. else if(TotalReceivedCount == 8 && RecvBuffer[0] == 0x66)
    262. {
    263. XScuGic_Enable(&GIC_SGI_instance_point, Interrupt_ID_Hardware_0);
    264. printf("Open SPI\n\r");
    265. }
    266. }
    267. XUartPs_Recv(&Uart_Instance_point, RecvBuffer, TEST_BUFFER_SIZE);
    268. }
    269. void Axi_WriteRamA(u8 *Data_addr_point, u32 Write_ByteLong){
    270. int i;
    271. for ( i = 0; i < Write_ByteLong; i++)
    272. {
    273. AXI_REG_LIST_mWriteReg(Axi_RamA_BaseAddr,i*4 ,*(Data_addr_point + i));
    274. }
    275. }
    276. void Axi_ReadRamB(u8 *Data_addr_point, u32 Read_ByteLong){
    277. int i;
    278. u32 Read_Data_Origin;
    279. for ( i = 0; i < Read_ByteLong; i++)
    280. {
    281. Read_Data_Origin = AXI_REG_LIST_mReadReg(Axi_RamB_BaseAddr, i*4);
    282. *(Data_addr_point + i) = (u8) Read_Data_Origin;
    283. }
    284. }
    1. /******************************************************************************
    2. *
    3. * Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
    4. *
    5. * Permission is hereby granted, free of charge, to any person obtaining a copy
    6. * of this software and associated documentation files (the "Software"), to deal
    7. * in the Software without restriction, including without limitation the rights
    8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    9. * copies of the Software, and to permit persons to whom the Software is
    10. * furnished to do so, subject to the following conditions:
    11. *
    12. * The above copyright notice and this permission notice shall be included in
    13. * all copies or substantial portions of the Software.
    14. *
    15. * Use of the Software is limited solely to applications:
    16. * (a) running on a Xilinx device, or
    17. * (b) that interact with a Xilinx device through a bus or interconnect.
    18. *
    19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    22. * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    23. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
    24. * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    25. * SOFTWARE.
    26. *
    27. * Except as contained in this notice, the name of the Xilinx shall not be used
    28. * in advertising or otherwise to promote the sale, use or other dealings in
    29. * this Software without prior written authorization from Xilinx.
    30. *
    31. ******************************************************************************/
    32. /*
    33. * helloworld.c: simple test application
    34. *
    35. * This application configures UART 16550 to baud rate 9600.
    36. * PS7 UART (Zynq) is not initialized by this application, since
    37. * bootrom/bsp configures it to baud rate 115200
    38. *
    39. * ------------------------------------------------
    40. * | UART TYPE BAUD RATE |
    41. * ------------------------------------------------
    42. * uartns550 9600
    43. * uartlite Configurable only in HW design
    44. * ps7_uart 115200 (configured by bootrom/bsp)
    45. */
    46. #include
    47. #include "platform.h"
    48. #include "xil_printf.h"
    49. #include "xil_mmu.h"
    50. #include "xscugic.h"
    51. #include "Axi_REG_List.h"
    52. #include "xuartps.h"
    53. #include "xparameters.h"
    54. #include "xil_exception.h"
    55. #define COMM_VAL (*(volatile unsigned long *)(0xFFFF0000))
    56. #define APP_CPU1_ADDR 0x02000000
    57. #define OCM_ADDR 0xFFFF0000
    58. #define Interrupt_ID_SGI_14 0x0D
    59. #define Interrupt_ID_SGI_15 0x0E
    60. #define Interrupt_ID_Hardware_0 61
    61. #define Interrupt_ID_Hardware_1 62
    62. #define DistBaseAddress XPAR_PS7_SCUGIC_0_DIST_BASEADDR
    63. #define CPU_id_0 XSCUGIC_SPI_CPU0_MASK
    64. #define CPU_id_1 XSCUGIC_SPI_CPU1_MASK
    65. //AXI BaseAddr
    66. #define Axi_RamA_BaseAddr 0x43C00000
    67. #define Axi_RamB_BaseAddr 0x43C10000
    68. //GIC
    69. #define XIL_EXCEPTION_ID_INT XIL_EXCEPTION_ID_IRQ_INT
    70. #define GIC_DECIVE_ID_INT XPAR_SCUGIC_0_DEVICE_ID
    71. #define TEST_BUFFER_SIZE 32
    72. u8 Media_Buffer[TEST_BUFFER_SIZE];
    73. static XScuGic_Config *GIC_SGI_ConFig;
    74. static XScuGic GIC_SGI_instance_point;
    75. int GIC_SGI_init();
    76. void SGI_IntrHandler(void *CallBackRef);
    77. void Hardware_IntrHandler(void *CallBackRef);
    78. void Axi_ReadRamA (u8 *Data_addr_point, u32 Read_ByteLong );
    79. void Axi_WriteRamB(u8 *Data_addr_point, u32 Write_ByteLong);
    80. int main()
    81. {
    82. int Status;
    83. Xil_SetTlbAttributes(0xFFFF0000,0x14de2);
    84. while(1){
    85. while(COMM_VAL == 1){
    86. print("CPU1: Hello World CPU 1\n\r");
    87. Status = GIC_SGI_init();
    88. if (Status != XST_SUCCESS) {
    89. return XST_FAILURE;
    90. }
    91. while (1){
    92. }
    93. }
    94. }
    95. return 0;
    96. }
    97. int GIC_SGI_init(){
    98. int Status;
    99. Xil_ExceptionInit();
    100. GIC_SGI_ConFig = XScuGic_LookupConfig(GIC_DECIVE_ID_INT);
    101. if (NULL == GIC_SGI_ConFig) {
    102. return XST_FAILURE;
    103. }
    104. Status = XScuGic_CfgInitialize(&GIC_SGI_instance_point,
    105. GIC_SGI_ConFig,
    106. GIC_SGI_ConFig->CpuBaseAddress);
    107. if (Status != XST_SUCCESS) {
    108. return XST_FAILURE;
    109. }
    110. Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
    111. (Xil_ExceptionHandler) XScuGic_InterruptHandler,
    112. &GIC_SGI_instance_point);
    113. Status = XScuGic_Connect(&GIC_SGI_instance_point,
    114. Interrupt_ID_SGI_15,
    115. (Xil_InterruptHandler )SGI_IntrHandler,
    116. (void *)&GIC_SGI_instance_point
    117. );
    118. if (Status != XST_SUCCESS) {
    119. return XST_FAILURE;
    120. }
    121. XScuGic_Enable(&GIC_SGI_instance_point,
    122. Interrupt_ID_SGI_15);
    123. //HGI
    124. Status = XScuGic_Connect(&GIC_SGI_instance_point,
    125. Interrupt_ID_Hardware_1,
    126. (Xil_InterruptHandler )Hardware_IntrHandler,
    127. (void *)&GIC_SGI_instance_point
    128. );
    129. if (Status != XST_SUCCESS) {
    130. return XST_FAILURE;
    131. }
    132. XScuGic_SetPriTrigTypeByDistAddr(DistBaseAddress,
    133. Interrupt_ID_Hardware_1,
    134. 0x21,
    135. 0x03);
    136. XScuGic_InterruptMaptoCpu(&GIC_SGI_instance_point,
    137. XSCUGIC_SPI_CPU1_MASK,
    138. Interrupt_ID_Hardware_1);
    139. XScuGic_Enable(&GIC_SGI_instance_point,
    140. Interrupt_ID_Hardware_1);
    141. Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
    142. return XST_SUCCESS;
    143. }
    144. void SGI_IntrHandler(void *CallBackRef){
    145. u32 origin_command;
    146. print("SG1!\n\r");
    147. Axi_ReadRamA(Media_Buffer,8);
    148. if(Media_Buffer[4]==0x04 && Media_Buffer[5] == 0x05
    149. && Media_Buffer[6]==0x06 && Media_Buffer[7] == 0x07)
    150. {
    151. Axi_WriteRamB(Media_Buffer,8);
    152. XScuGic_SoftwareIntr(&GIC_SGI_instance_point, Interrupt_ID_SGI_14, CPU_id_0);
    153. }
    154. }
    155. void Hardware_IntrHandler(void *CallBackRef){
    156. print("H1!\n\r");
    157. }
    158. void Axi_ReadRamA(u8 *Data_addr_point, u32 Read_ByteLong){
    159. int i;
    160. u32 Read_Data_Origin;
    161. for ( i = 0; i < Read_ByteLong; i++)
    162. {
    163. Read_Data_Origin = AXI_REG_LIST_mReadReg(Axi_RamA_BaseAddr, i*4);
    164. *(Data_addr_point + i) = (u8) Read_Data_Origin;
    165. }
    166. }
    167. void Axi_WriteRamB(u8 *Data_addr_point, u32 Write_ByteLong){
    168. int i;
    169. for ( i = 0; i < Write_ByteLong; i++)
    170. {
    171. AXI_REG_LIST_mWriteReg(Axi_RamB_BaseAddr,i*4 ,*(Data_addr_point + i));
    172. }
    173. }

  • 相关阅读:
    JetBrains WebStorm 2024 mac/win版:效率至上,编码无忧
    基于springboot的教材预定系统平台
    尚硅谷-尚医通项目(源码+功能语言描述_可借鉴)
    神经网络(ANN)
    static关键字
    Flink CDC 2.0 主要是借鉴 DBLog 算法
    多旋翼无人机仿真 rotors_simulator:基于PID控制器的速度控制
    深入理解Python生成器和yield
    深入理解nginx一致性哈希负载均衡模块[上]
    ansible的安装和简单的块使用
  • 原文地址:https://blog.csdn.net/NoNoUnknow/article/details/133934875