编译通过 仿真启动 请知悉 改处理器没有csr

This commit is contained in:
RuigeLee
2024-10-25 17:46:21 +08:00
parent 4737700f56
commit 78d54d2083
20 changed files with 880 additions and 69 deletions

40
tb/sw/axi_gpio/gpio.c Normal file
View File

@@ -0,0 +1,40 @@
#include <stdint.h>
#include "gpio.h"
#ifndef GPIO_BASE
#error GPIO Base address not define!!!
#endif
// for 8 bit gpio
volatile uint32_t *gpio_dat_reg = (uint32_t*)( GPIO_BASE + GPIO_DATA );
volatile uint32_t *gpio_tri_reg = (uint32_t*)( GPIO_BASE + GPIO_TRI );
uint8_t gpio_read()
{
*gpio_tri_reg = 0xff;
return (uint8_t)(*gpio_dat_reg);
}
uint32_t gpio_write( uint32_t data )
{
*gpio_tri_reg = 0x00;
(*gpio_dat_reg) = data;
return 0;
}

24
tb/sw/axi_gpio/gpio.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef _GPIO_H_
#define _GPIO_H_
#include <stdint.h>
#define GPIO_BASE 0x20000000U
#define GPIO_DATA 0x0000
#define GPIO_TRI 0x0004
#define GPIO2_DATA 0x0008
#define GPIO2_TRI 0x000C
#define GIER 0x011C
#define IP_IER 0x0128
#define IP_ISR 0x0120
extern uint8_t gpio_read();
extern uint32_t gpio_write( uint32_t data );
void gpio_test();
#endif